浏览代码

样本自定义查询组件bug修复、样本来源添加显示列功能

jianglw 4 年之前
父节点
当前提交
1f372a695f

+ 19 - 19
src/dashoo.cn/frontend_animal/src/components/samples/samplesearchdialog.vue

@@ -275,7 +275,6 @@ export default {
   // },
   data () {
     return {
-      tableHeight: window.innerHeight - 230,
       samplesearchdialogVisable: false,
       orAnd: 'and',
       orgtreelist: [],
@@ -424,7 +423,6 @@ export default {
           value: 'Area',
           label: '取样地区',
           type: 'str',
-          iconTag: 'sampleSource'
         }, {
           value: 'SurveyDate',
           label: '采样日期',
@@ -676,7 +674,7 @@ export default {
     // 获取类型
     acquritype (row) {
       if (row.kuoz === 'false') {
-        if (row.iconTag == 'SampleSource') {
+        if (row.Type == 'SampleSource') {
           for (var i = 0; i < this.data2.length; i++) {
             if (this.data2[i].value === row.Field) {
               return this.data2[i].type
@@ -738,24 +736,26 @@ export default {
       }).then(() => {
         service.postRequest('dashoo.biobank.bee-0.1', 'SampleRelated', 'DeleteSearchTemplate', {id: Id})
           .then(res => {
-            if (res.info.code === 0) {
+            if (res.code === 0) {
+              _this.$message({
+                type: 'success',
+                message: res.msg
+              })
               let tabs = _this.searchTemplates
               let activeName = _this.currentSearchTemplateName
               if (activeName === targetName) {
                 tabs.forEach((tab, index) => {
-                  if (tab.Name === targetName) {
+                  if (tab.name === targetName) {
                     let nextTab = tabs[index + 1] || tabs[index - 1]
                     if (nextTab) {
-                      activeName = nextTab.Name
+                      activeName = nextTab.name
                       _this.searchTableData = this.getSearchTableData(nextTab.Fields)
                     }
                   }
                 })
               }
-
-              this.$observer.$emit('handleSeach', true)
               _this.currentSearchTemplateName = activeName
-              _this.searchTemplates = tabs.filter(tab => tab.Name !== targetName)
+              _this.searchTemplates = tabs.filter(tab => tab.name !== targetName)
             } else {
               _this.$message({
                 type: 'warning',
@@ -772,16 +772,16 @@ export default {
       })
     },
 
-    saveAndSearchWithTemplate () {
-      let _this = this
-      this.saveSearchTemplate(function () {
-        _this.currentSearchTemplate = _this.currentSearchTemplateName
-        _this.searchWithTemplate(_this.currentSearchTemplateName)
-      })
-    },
-    searchWithTemplate () {
-
-    },
+    // saveAndSearchWithTemplate () {
+    //   let _this = this
+    //   this.saveSearchTemplate(function () {
+    //     _this.currentSearchTemplate = _this.currentSearchTemplateName
+    //     _this.searchWithTemplate(_this.currentSearchTemplateName)
+    //   })
+    // },
+    // searchWithTemplate () {
+    //
+    // },
     // 自定义搜索名称发生变化
     customsearchnamechange () {
 

+ 0 - 1
src/dashoo.cn/frontend_animal/src/components/samples/samplesourcesearchdialog.vue

@@ -259,7 +259,6 @@ export default {
   // },
   data () {
     return {
-      tableHeight: window.innerHeight - 230,
       samplesourcesearchdialogVisable: false,
       orAnd: 'and',
       orgtreelist: [],

+ 183 - 59
src/dashoo.cn/frontend_animal/src/pages/biobank/source/animal.vue

@@ -23,6 +23,8 @@
           <router-link :to="'/biobank/source/addsource/operationb'">
             <el-button type="primary" size="mini" style="margin-left:10px; margin-top: -4px;">添加</el-button>
           </router-link>
+          <el-button type="primary" size="mini" style="margin-left:10px; margin-top: -4px;"
+                     @click="columndialogVisible = true">显示列</el-button>
           <!-- <el-button size="mini" type="primary" style="margin-left:10px; margin-top: -4px;"
             @click="importVisible = true">导入</el-button> -->
         </span>
@@ -34,8 +36,10 @@
             <el-input size="mini" style="width: 165px;" v-model="searchform.InnerNo" placeholder="请输入来源内码"></el-input>
           </el-form-item>
           <el-form-item label="创建日期">
-            <el-date-picker size="mini" style="width: 220px" v-model="CreateOn" type="daterange" range-separator="至"
-                            start-placeholder="开始日期" end-placeholder="结束日期"></el-date-picker>
+            <el-date-picker size="mini" style="width: 110px" v-model="CreateOnStart" type="date"
+                            placeholder="开始日期"></el-date-picker>
+            <el-date-picker size="mini" style="width: 110px" v-model="CreateOnEnd" type="date"
+                            placeholder="结束日期"></el-date-picker>
           </el-form-item>
           <el-form-item>
             <el-dropdown split-button type="primary" size="mini" @click="seachdata" @command="searchCommand">
@@ -82,33 +86,52 @@
             </span>
           </template>
         </el-table-column>
-        <el-table-column prop="Name" sortable min-width="80" label="样本源名称" align="center" show-overflow-tooltip>
-        </el-table-column>
-        <el-table-column prop="Genus" sortable min-width="80" label="蜂种" align="center" show-overflow-tooltip>
-        </el-table-column>
-        <el-table-column prop="InnerNo" sortable align="center" label="来源内码" min-width="160" show-overflow-tooltip>
-        </el-table-column>
-        <el-table-column prop="AddressLine" sortable align="center" label="取样地区" min-width="160" show-overflow-tooltip>
-          <template slot-scope="scope">
-            <p>{{getaddress(scope.row)}}</p>
-          </template>
-        </el-table-column>
-        <el-table-column prop="Amount" sortable label="数量" align="center" show-overflow-tooltip min-width="60">
-          <template slot-scope="scope">
-            <p>{{scope.row.Amount}} {{scope.row.Unit}}</p>
-          </template>
-        </el-table-column>
-        <el-table-column prop="AuditorStatus" sortable label="审核状态" align="center" min-width="80">
-          <template slot-scope="scope">
-            <el-tag v-show="scope.row.AuditorStatus=='0'" type="warning">未审核</el-tag>
-            <el-tag v-show="scope.row.AuditorStatus=='1'" type="success">审核成功</el-tag>
-            <el-tag v-show="scope.row.AuditorStatus=='2'" type="danger">审核失败</el-tag>
-          </template>
-        </el-table-column>
-        <el-table-column prop="AuditorName" sortable label="审核人" align="center" show-overflow-tooltip></el-table-column>
-        <el-table-column prop="SurveyDate" sortable align="center" label="采样日期" min-width="80" show-overflow-tooltip>
+<!--        <el-table-column prop="Name" sortable min-width="80" label="样本源名称" align="center" show-overflow-tooltip>-->
+<!--        </el-table-column>-->
+<!--        <el-table-column prop="Genus" sortable min-width="80" label="蜂种" align="center" show-overflow-tooltip>-->
+<!--        </el-table-column>-->
+<!--        <el-table-column prop="InnerNo" sortable align="center" label="来源内码" min-width="160" show-overflow-tooltip>-->
+<!--        </el-table-column>-->
+<!--        <el-table-column prop="AddressLine" sortable align="center" label="取样地区" min-width="160" show-overflow-tooltip>-->
+<!--          <template slot-scope="scope">-->
+<!--            <p>{{getaddress(scope.row)}}</p>-->
+<!--          </template>-->
+<!--        </el-table-column>-->
+<!--        <el-table-column prop="Amount" sortable label="数量" align="center" show-overflow-tooltip min-width="60">-->
+<!--          <template slot-scope="scope">-->
+<!--            <p>{{scope.row.Amount}} {{scope.row.Unit}}</p>-->
+<!--          </template>-->
+<!--        </el-table-column>-->
+<!--        <el-table-column prop="AuditorStatus" sortable label="审核状态" align="center" min-width="80">-->
+<!--          <template slot-scope="scope">-->
+<!--            <el-tag v-show="scope.row.AuditorStatus=='0'" type="warning">未审核</el-tag>-->
+<!--            <el-tag v-show="scope.row.AuditorStatus=='1'" type="success">审核成功</el-tag>-->
+<!--            <el-tag v-show="scope.row.AuditorStatus=='2'" type="danger">审核失败</el-tag>-->
+<!--          </template>-->
+<!--        </el-table-column>-->
+<!--        <el-table-column prop="AuditorName" sortable label="审核人" align="center" show-overflow-tooltip></el-table-column>-->
+<!--        <el-table-column prop="SurveyDate" sortable align="center" label="采样日期" min-width="80" show-overflow-tooltip>-->
+<!--          <template slot-scope="scope">-->
+<!--            <p>{{jstimehandle(scope.row.SurveyDate)}}</p>-->
+<!--          </template>-->
+<!--        </el-table-column>-->
+        <el-table-column :label="item.name" :key="item.name" v-if="item.show" v-for="item in showcolumn"
+                         :width="item.columnwidth" align="center" show-overflow-tooltip>
           <template slot-scope="scope">
-            <p>{{jstimehandle(scope.row.SurveyDate)}}</p>
+            <template v-if="item.filed === 'Address'">
+              {{getaddress(scope.row)}}
+            </template>
+            <template v-else-if="item.filed === 'SurveyDate'">
+              {{jstimehandle(scope.row[item.filed])}}
+            </template>
+            <template v-else-if="item.filed === 'AuditorStatus'">
+              <el-tag v-show="scope.row.AuditorStatus=='0'" type="warning">未审核</el-tag>
+              <el-tag v-show="scope.row.AuditorStatus=='1'" type="success">审核成功</el-tag>
+              <el-tag v-show="scope.row.AuditorStatus=='2'" type="danger">审核失败</el-tag>
+            </template>
+            <template v-else>
+              {{scope.row[item.filed]}}
+            </template>
           </template>
         </el-table-column>
       </el-table>
@@ -154,8 +177,10 @@
           </el-col>
           <el-col :span="12">
             <el-form-item label="采样日期">
-              <el-date-picker size="mini" style="width: 240px" v-model="SurveyDate" type="daterange" range-separator="至"
-                              start-placeholder="开始日期" end-placeholder="结束日期"></el-date-picker>
+              <el-date-picker size="mini" style="width: 120px" v-model="SurveyDateStart" type="date"
+                              placeholder="开始日期"></el-date-picker>
+              <el-date-picker size="mini" style="width: 120px" v-model="SurveyDateEnd" type="date"
+                              placeholder="结束日期"></el-date-picker>
             </el-form-item>
           </el-col>
           <el-col :span="12">
@@ -209,6 +234,23 @@
       </div>
     </el-dialog>
 
+    <el-dialog title="选中显示列(拖拽可以实现排序)" :visible.sync="columndialogVisible" top="5vh">
+      <el-checkbox :indeterminate="isIndeterminate" v-model="checkAll" @change="handleCheckAllChange"
+                   style="margin-left:15px;">全选</el-checkbox>
+      <div style="margin: 10px 0;"></div>
+      <draggable v-model="showcolumn">
+        <transition-group class="sampshowfiledsort_ul sampshowfiledsort_ul_tags" tag="ul">
+          <li v-for="item in showcolumn" :key="item.filed">
+            <el-checkbox v-model="item.show" :label="item.filed" @change="checkedshowall()">{{item.name}}</el-checkbox>
+          </li>
+        </transition-group>
+      </draggable>
+      <div slot="footer" class="dialog-footer">
+        <el-button @click="columndialogVisible = false">取 消</el-button>
+        <el-button type="primary" @click="saveshowfiled()">确 定</el-button>
+      </div>
+    </el-dialog>
+
     <!-- 自定义查询 -->
     <samplesourcesearchdialog @close="closeDialog"
                         ref="samplesourcesearchdialog"></samplesourcesearchdialog>
@@ -246,6 +288,10 @@ export default {
       currentSearchTemplateName: '', // 当前搜索模板名称
       searchTemplates: [], // 自定义模板
       list: [], // table显示数据集
+      showcolumn: [], // 显示列
+      columndialogVisible: false, // 自定义显示列弹框
+      isIndeterminate: false,
+      checkAll: true,
       exportloading: false,
       searchform: {
         GenusId: '',
@@ -266,8 +312,12 @@ export default {
         starttime: null,
         endtime: null
       },
+      SurveyDateStart: '', // 采样开始日期
+      SurveyDateEnd: '', // 采样结束日期
       SurveyDate: [], // 采样日期
-      CreateOn: [],
+      CreateOnStart: '', // 创建开始日期
+      CreateOnEnd: '', // 创建结束日期
+      CreateOn: [], // 创建日期
       currentItemCount: 0,
       currentPage: 1,
       size: 200,
@@ -284,7 +334,6 @@ export default {
     }
   },
   created () {
-    let _this = this
     // console.log('jlw', store.get('samplestoredseach'))
     if (this.$route.query.size && this.$route.query.currentPage) {
       this.size = parseInt(this.$route.query.size)
@@ -323,10 +372,58 @@ export default {
     } else {
       store.set('samplestoredseach', '')
     }
+    let cachecols = store.get('sapmsourceinputshowcolumn')
+    if (cachecols && cachecols !== '') {
+      this.showcolumn = cachecols
+    } else {
+      this.showcolumn = [{
+        filed: 'Name',
+        name: '样本源名称',
+        show: true,
+        kuoz: false
+      }, {
+        filed: 'Genus',
+        name: '蜂种',
+        show: true,
+        kuoz: false
+      }, {
+        filed: 'InnerNo',
+        name: '来源内码',
+        show: true,
+        kuoz: false
+      }, {
+        filed: 'Address',
+        name: '取样地区',
+        show: true,
+        kuoz: false
+      }, {
+        filed: 'Amount',
+        name: '数量',
+        show: true,
+        kuoz: false
+      }, {
+        filed: 'AuditorStatus',
+        name: '审核状态',
+        show: true,
+        kuoz: false
+      }, {
+        filed: 'AuditorName',
+        name: '审核人',
+        show: true,
+        kuoz: false
+      }, {
+        filed: 'SurveyDate',
+        name: '采样日期',
+        show: true,
+        kuoz: false
+      }]
+    }
     this.filehost = process.env.imgserverhost
     this.initdata()
     this.getAnimalGenus()
+    this.checkedshowall()
     this.getProjectlist()
+    this.getAllSearchTab()
     this.importfileparam = {
       accode: this.authUser.Profile.AccCode
     }
@@ -534,33 +631,6 @@ export default {
           console.error(err)
         })
     },
-    // getSearchTableData (searchFields) {
-    //   let data = searchFields.map(function (ele) {
-    //     // if (ele['OrAnd'] === 'or') {
-    //     //   ele['Guanxi'] = '或者'
-    //     // } else {
-    //     //   ele['Guanxi'] = '并且'
-    //     // }
-    //
-    //     // _this.searchTemplates.forEach((item) => {
-    //     //   item.Fields.forEach((it) => {
-    //     //     if (it.TagIcon == "cascader") {
-    //     //       it.Value = "[" + it.Value + "]"
-    //     //     }
-    //     //   })
-    //     // })
-    //     if (ele['Operate'] === 'between') {
-    //       ele['Value'] = ele['Value'].split('--')
-    //     }
-    //     if (ele.TagIcon == 'cascader') {
-    //       ele.Value = ele.Value.split('/')
-    //     }
-    //     return ele
-    //   })
-    //
-    //   return data || []
-    // },
-
     getSearchTableData (searchFields) {
       let data = searchFields.map(function (ele) {
         if (ele['OrAnd'] === 'or') {
@@ -607,7 +677,27 @@ export default {
       this.initdata()
     },
     seachdata () {
+      console.log("this.SurveyDateStart", this.SurveyDateStart)
+      console.log("this.SurveyDateEnd", this.SurveyDateEnd)
       this.currentPage = 1
+      this.SurveyDate = []
+      if ((this.SurveyDateStart != '' && this.SurveyDateEnd == '') || (this.SurveyDateStart == '' && this.SurveyDateEnd != '')) {
+        this.$message.error('请输入完整采集日期!')
+      } else if (this.SurveyDateStart > this.SurveyDateEnd) {
+        this.$message.error('开始日期不能大于结束日期,请重新输入!')
+      } else if (this.SurveyDateStart != '' && this.SurveyDateEnd != ''){
+        this.SurveyDate.push(this.SurveyDateStart)
+        this.SurveyDate.push(this.SurveyDateEnd)
+      }
+      if ((this.CreateOnStart != '' && this.CreateOnEnd == '') || (this.CreateOnStart == '' && this.CreateOnEnd != '')) {
+        this.$message.error('请输入完整创建日期!')
+      } else if (this.CreateOnStart > this.CreateOnEnd) {
+        this.$message.error('开始日期不能大于结束日期,请重新输入!')
+      } else if (this.CreateOnStart != '' && this.CreateOnEnd != ''){
+        this.CreateOn.push(this.CreateOnStart)
+        this.CreateOn.push(this.CreateOnEnd)
+      }
+      console.log("CreateOn", this.CreateOn)
       this.initdata()
     },
     searchCommand (command) {
@@ -875,6 +965,40 @@ export default {
     handleSelectionChange (val) {
       this.multipleSelection = val
       console.log('this.multipleSelection', this.multipleSelection)
+    },
+    // 自定义显示列保存操作
+    saveshowfiled () {
+      store.set('sapmsourceinputshowcolumn', this.showcolumn)
+      this.columndialogVisible = false
+      this.$message({
+        type: 'success',
+        message: '自定义显示列设置成功'
+      })
+      this.initData()
+    },
+    checkedshowall () {
+      let tc = 0
+      for (var i = 0; i < this.showcolumn.length; i++) {
+        if (this.showcolumn[i].show) {
+          tc++
+        }
+      }
+      if (tc > 0 && tc < this.showcolumn.length) {
+        this.isIndeterminate = true
+        this.checkAll = false
+      } else {
+        this.isIndeterminate = false
+        if (tc === 0) {
+          this.checkAll = false
+        } else {
+          this.checkAll = true
+        }
+      }
+    },
+    handleCheckAllChange (val) {
+      for (var i = 0; i < this.showcolumn.length; i++) {
+        this.showcolumn[i].show = val
+      }
     }
   }
 }

+ 2 - 106
src/dashoo.cn/frontend_animal/src/pages/samples/stored/index.vue

@@ -109,7 +109,7 @@
               {{jstimehandle(scope.row[item.filed])}}
             </template>
             <template v-else-if="item.filed === 'SurveyDate'">
-              {{Jstimehandle(scope.row[item.filed])}}
+              {{jstimehandle(scope.row[item.filed])}}
             </template>
             <template v-else-if="item.filed === 'Location'">
               <router-link :to="'/equipment/'+scope.row.EquipmentId +'/manage_new' + getstationurl(scope.row)">
@@ -539,13 +539,6 @@
       this.getAllSearchTab()
     },
 
-    mounted () {
-      let _this = this
-      window.clickmodeltypetag = function (val, e) {
-        _this.clickmodeltypetag(val)
-      }
-    },
-
     methods: {
       initData () {
         this.CreateOn = []
@@ -610,6 +603,7 @@
           params = Object.assign(params, params3)
         }
         store.set('samplestoredseach', params)
+        _this.getAllSearchTab()
         this.$axios.get('/sampleinput/animallist', {
           params
         })
@@ -776,18 +770,6 @@
           return val.substring(0, 19)
         }
       },
-      Jstimehandle (val) {
-        if (val === '') {
-          return '----'
-        } else if (val === '0001-01-01T08:00:00+08:00') {
-          return '----'
-        } else if (val === '5000-01-01T23:59:59+08:00') {
-          return '永久'
-        } else {
-          val = val.replace('T', ' ')
-          return val.substring(0, 10)
-        }
-      },
       jssubstrhandle (val, no) {
         let position = val.split(';')
         return position[no]
@@ -1119,26 +1101,6 @@
         return ''
       },
 
-      /*  addSearchTab (name) {
-        for (let i = 0; i < this.searchTemplates.length; i++) {
-          if (this.searchTemplates[i].Name == name) {
-            this.$message('名称已经存在')
-            return
-          }
-        }
-        this.searchTemplates.push({
-          Name: name,
-          Fields: []
-        }),
-        this.currentSearchTemplateName = name
-
-        for (let i = 0; i < this.searchTemplates.length; i++) {
-          if (this.searchTemplates[i].Name == this.currentSearchTemplateName) {
-            this.searchTableData = this.getSearchTableData(this.searchTemplates[i].Fields)
-          }
-        }
-      }, */
-
       getAllSearchTab () {
         let _this = this
         // getSearchTemplate({ Type: 'sample' })
@@ -1170,72 +1132,6 @@
             console.error(err)
           })
       },
-      /* getAllSearchTab () {
-        let _this = this
-        this.$axios.get('/sampleinput/searchTemplate', {})
-          .then(res => {
-            if (res.data && res.data.items && res.data.items.length > 0) {
-              _this.searchTemplates = res.data.items.map(function (e) {
-                e.Fields = JSON.parse(e.Template)
-                return e
-              })
-              _this.currentSearchTemplateName = _this.searchTemplates[0].Name
-              _this.searchTableData = this.getSearchTableData(this.searchTemplates[0].Fields)
-            } else {
-              // _this.$message({
-              //   type: 'warning',
-              //   message: res.data.message,
-              // })
-            }
-          })
-          .catch(err => {
-            // handle error
-            console.error(err)
-          })
-      }, */
-
-      removeSearchTab (targetName) {
-        let _this = this
-        this.$axios.delete('/sampleinput/searchTemplate?name=' + targetName, {})
-          .then(res => {
-            if (res.data.code == 0) {
-              let tabs = _this.searchTemplates
-              let activeName = _this.currentSearchTemplateName
-              if (activeName === targetName) {
-                tabs.forEach((tab, index) => {
-                  if (tab.Name === targetName) {
-                    let nextTab = tabs[index + 1] || tabs[index - 1]
-                    if (nextTab) {
-                      activeName = nextTab.Name
-                      _this.searchTableData = this.getSearchTableData(nextTab.Fields)
-                    }
-                  }
-                })
-              }
-
-              _this.currentSearchTemplateName = activeName
-              _this.searchTemplates = tabs.filter(tab => tab.Name !== targetName)
-            } else {
-              _this.$message({
-                type: 'warning',
-                message: res.data.message
-              })
-            }
-          })
-          .catch(err => {
-            // handle error
-            console.error(err)
-          })
-      },
-
-      clickmodeltypetag (val) {
-        this.currentSearchTemplateName = val.getAttribute('id')
-        for (let i = 0; i < this.searchTemplates.length; i++) {
-          if (this.searchTemplates[i].Name == this.currentSearchTemplateName) {
-            this.searchTableData = this.getSearchTableData(this.searchTemplates[i].Fields)
-          }
-        }
-      },
 
       handleSearchCommand (command) {
         if (command == 'search') {