Bladeren bron

merge fix

scorpio 2 jaren geleden
bovenliggende
commit
01600920a7
3 gewijzigde bestanden met toevoegingen van 78 en 14 verwijderingen
  1. 11 0
      src/api/params/index.js
  2. 1 0
      src/views/home/component/dash.vue
  3. 66 14
      src/views/home/component/form_dialog.vue

+ 11 - 0
src/api/params/index.js

@@ -18,6 +18,17 @@ export default {
      */
   exportResult (params) {
     return fetch('/blade-project-manage-v2/project/v2/projectExport', params, 'post', 'json', {}, 'blob')
+  },
+  /**
+     * 字段搜索
+     */
+  getParamByName (params) {
+    return fetch('/wutong-parse-file/excel-dict/parent-list', {
+      clientId: 'project_web',
+      size: 999,
+      current: 1,
+      ...params
+    })
   }
 
 }

+ 1 - 0
src/views/home/component/dash.vue

@@ -447,6 +447,7 @@ export default {
         link.click()
         link.remove()
         this.diaType = -1
+        this.$message.success('导出成功')
       })
     }
   }

+ 66 - 14
src/views/home/component/form_dialog.vue

@@ -49,11 +49,14 @@
         <img src="../../../assets/img/export.png" class="pic"/>
       </div>
       <div class="flex flex-col">
-        <el-input
+        <el-autocomplete
             v-model="keyWords"
             clearable
             placeholder="字段信息快速搜索"
             prefix-icon="Search"
+            :trigger-on-focus="false"
+            :fetch-suggestions="querySearch"
+            @select="handleSelect"
         />
         <div class="flex flex-wrap flex-align-center">
           <div class="flex flex-center padding radius box-shadow mr-20 mt-20 pointer"
@@ -73,7 +76,7 @@
         </div>
       </div>
       <el-divider/>
-      <div class="hide-scrollbar full-width" style="height: 20vh;overflow-x: scroll">
+      <div v-loading='loading' class="hide-scrollbar full-width" style="height: 20vh;overflow-x: scroll">
         <!--        <div v-if='attaches.length === 0' class='full-width flex flex-center '>-->
         <!--          <el-empty image-size='100'/>-->
         <!--        </div>-->
@@ -118,6 +121,9 @@ export default {
         } else if (val === 1) {
           this.getDict('params_type')
           this.showExport = true
+        } else {
+          this.showExport = false
+          this.showImport = false
         }
       },
       immediate: true
@@ -145,12 +151,13 @@ export default {
     getDict (code) {
       this.$api.common.dicList({ code }).then(res => {
         if (res.code === 200) {
-          this.fieldType = res.data.map(e => {
+          const tmps = res.data.map(e => {
             e.isSelect = false
             e.count = 0
             e.parmas = []
             return e
           })
+          this.fieldType = tmps
         }
       })
     },
@@ -173,17 +180,25 @@ export default {
     switchTab (item, index) {
       this.fieldType[index].isSelect = !this.fieldType[index].isSelect
       this.selectIndex = index
-      if (this.fieldType[index].params === undefined) {
-        this.$api.params.getListByKey({ type: this.fieldType[index].dictKey }).then(res => {
-          if (res.code === 200) {
-            this.fieldType[index].params = res.data.records.map(e => {
-              e.checked = true
-              return e
-            }).filter(sub => sub.code !== 'name')
-            this.fieldType[index].count = res.data.total
+      this.$api.params.getListByKey({ type: this.fieldType[index].dictKey }).then(res => {
+        if (res.code === 200) {
+          const tmps = res.data.records.map(e => {
+            e.checked = this.fieldType[index].params === undefined ? true : this.fieldType[index].params.findIndex(sub => sub.id === e.id) > -1
+            return e
+          }).filter(sub => sub.code !== 'name')
+          if (this.fieldType[index].params !== undefined) {
+            const d = tmps.filter(ele => {
+              return this.fieldType[index].params.findIndex(sub => sub.id === ele.id) === -1
+            })
+            for (let i = 0; i < d.length; i++) {
+              this.fieldType[index].params.push(d[i])
+            }
+          } else {
+            this.fieldType[index].params = tmps
           }
-        })
-      }
+          this.fieldType[index].count = this.fieldType[index].params.filter(e => e.checked).length
+        }
+      })
     },
     importExcel () {
       this.$refs.upload.submit()
@@ -192,7 +207,6 @@ export default {
       const tmp = this.fieldType[parentIndex].params.filter(e => e.checked)
       this.fieldType[parentIndex].count = tmp.length
       for (let i = 0; i < tmp.length; i++) {
-        console.log(tmp[i])
         this.resultParams.push(tmp[i])
       }
     },
@@ -202,10 +216,48 @@ export default {
       const tmpsList = tmps.filter(sub => sub.checked)
       if (tmpsList && tmpsList.length > 0) {
         const result = tmpsList.map(sub => sub.code).join(',')
+        this.loading = true
         this.$emit('export', 'name,' + result)
       } else {
         this.$message.error('未选择任何字段进行导出')
       }
+    },
+    querySearch (string, cb) {
+      if (string && string.length === 0) {
+        return
+      }
+      setTimeout(() => {
+        this.$api.params.getParamByName({ dictValue: string }).then(res => {
+          if (res.code === 200) {
+            const tmp = res.data.records.map(sub => {
+              const item = { value: sub.dictValue, label: sub.dictValue }
+              return Object.assign(sub, item)
+            })
+            cb(tmp)
+          }
+        })
+      }, 500)
+    },
+    handleSelect (item) {
+      const sub = item
+      sub.search = true
+      sub.checked = true
+      const index = this.fieldType.findIndex(e => e.dictKey === sub.type)
+      if (index > -1) {
+        this.fieldType[index].count++
+        if (this.fieldType[index].params === undefined) {
+          this.fieldType[index].params = []
+          this.fieldType[index].params.push(sub)
+        } else {
+          const subIndex = this.fieldType[index].params.findIndex(ele => ele.id === sub.id)
+          if (subIndex > -1) {
+            this.fieldType[index].params[subIndex].checked = true
+          } else {
+            this.fieldType[index].params.push(sub)
+          }
+        }
+        this.fieldType[index].params.count = this.fieldType[index].params.filter(sub => sub.checked).length
+      }
     }
   }
 }