Просмотр исходного кода

Merge branch 'master' of http://119.23.210.103:3000/wy/zdqy_firm_former

luoaoxuan 1 год назад
Родитель
Сommit
afa92fe145

+ 11 - 16
src/business/platform/data/templaterender/components/import-columns-dialog.vue

@@ -285,14 +285,18 @@ export default {
                     selectFieldsTableData.push({ title: target[f] || null, dataType: '', disabled: true, checked: false, key: '' })
                 }
             }
+            const labelList = Object.keys(this.fields).map(key => ({
+                key,
+                label: this.fields[key].label,
+                field_type: this.fields[key].field_type || this.fields[key].type
+            }))
             selectFieldsTableData.forEach(s => {
-                for (var f in this.fields) {
-                    if (s.title === this.fields[f].label) {
-                        s.dataType = this.fields[f].field_type || this.fields[f].type
-                        s.disabled = !this.fields[f].label === s.title
-                        s.checked = this.fields[f].label === s.title
-                        s.key = f
-                    }
+                const t = labelList.find(i => i.label === s.title)
+                if (t) {
+                    s.dataType = t.field_type || t.type
+                    s.disabled = !t.label === s.title
+                    s.checked = t.label === s.title
+                    s.key = t.key
                 }
             })
             this.selectFieldsTableData = selectFieldsTableData
@@ -376,15 +380,6 @@ export default {
             // 列表数据处理
             const tableData = JSON.parse(JSON.stringify(this.tableData.data))
             const saveData = []
-            const gysmlSql = 'select * FROM t_gysml'
-            // 去除字符串里的空格
-            function trim (str) {
-                var reg = /\s+/g
-                if (typeof str === 'string') {
-                    var trimStr = str.replace(reg, '')
-                }
-                return trimStr
-            }
             switch (formKey) {
                 default:
                     tableData.forEach(data => {

+ 29 - 23
src/business/platform/data/templaterender/templates/list.vue

@@ -187,7 +187,7 @@
             :template-key="dataTemplate.key"
             :add-data-cont="addDataCont"
             :previous-data-template="dataTemplate"
-            @callback="search"
+            @callback="search('callback')"
             @close="closeDataTemplateFormrenderDialog"
         />
         <!-- 流程定义选择器 -->
@@ -248,7 +248,7 @@
             :task-id="taskId"
             :add-data-cont="addDataCont"
             :previous-data-template="dataTemplate"
-            @callback="search"
+            @callback="search('callback')"
             @close="loadFlowFData"
         />
         <Scan
@@ -691,16 +691,19 @@ export default {
             }
             const { listData } = this
             const allSelectId = this.getAllSelectId()
-            for (let i = 0; i < listData.length; i++) {
-                const row = listData[i]
-                if (allSelectId.indexOf(this.getPkValue(row)) >= 0) {
+            listData.forEach(row => {
+                const pkValue = this.getPkValue(row)
+                if (allSelectId.includes(pkValue)) {
                     if (this.multiple) {
                         tableEl.toggleSelectionRow(row, true)
                     } else {
                         tableEl.setSelectionRadio(row)
                     }
+                    // fixbug: 替换所有选中列表中的数据为最新数据,避免脚本返回的选中数据不更新
+                    const index = this.selectionAll.findIndex(item => this.getPkValue(item) === pkValue)
+                    this.selectionAll[index] = row
                 }
-            }
+            })
         },
         /**
          * 获取选择的ID
@@ -714,6 +717,10 @@ export default {
             }
             return [this.getPkValue(this.selectionAll)]
         },
+        initSelect () {
+            this.selection = this.multiple ? [] : {}
+            this.selectionAll = this.multiple ? [] : {}
+        },
         /**
          * 根据key获取对象的值
          * 用于解决key值大小写不同的问题
@@ -736,14 +743,19 @@ export default {
         /**
          * 加载数据
          */
-        loadData (outerKey) {
+        loadData (outerKey, type) {
             // 仅模板类型为对话框时触发页内loading事件,其余根据接口判定触发全局loading
             this.loading = this.dataTemplate.type === 'dialog'
             if (this.$utils.isEmpty(this.template)) return
             queryDataTable(this.getFormatParams(outerKey), this.dataTemplate.type).then((response) => {
                 this.loading = false
                 ActionUtils.handleListData(this, response.data)
-                this.setSelectRow()
+                // 回调查询不再选中原有数据
+                if (type !== 'callback') {
+                    this.setSelectRow()
+                } else {
+                    this.initSelect()
+                }
                 if (this.$refs.crud) {
                     this.$refs.crud.handleTableHeight()
                     debounce(() => {
@@ -791,7 +803,6 @@ export default {
                                     refSerchForm.params[getBuildSearchForm.prop[0]] = val[0]
                                     refSerchForm.params[getBuildSearchForm.prop[1]] = val[1]
                                     refSerchForm.params['daterange-prefix' + index] = [val[0], val[1]]
-
                                     break
                             }
                             // refSerchForm.params[getBuildSearchForm.modelValue] = val
@@ -835,9 +846,9 @@ export default {
             this.loadData()
         },
         // 查询数据
-        search () {
+        search (type) {
             this.hadDoSearch = true
-            this.loadData()
+            this.loadData('', type)
             this.addDataCont = {}
         },
         /* 流程页面关闭,刷新当前页面*/
@@ -1759,6 +1770,7 @@ export default {
             }).then((response) => {
                 this.afterScript(action, position, selection, data, () => {
                     ActionUtils.removeSuccessMessage()
+                    this.initSelect()
                     this.search()
                 })
             }).catch(() => {})
@@ -1807,22 +1819,16 @@ export default {
             })
         },
         setValue (data) {
-            const obj = {}
-            Object.values(data).forEach((item) => {
+            return Object.values(data).reduce((obj, item) => {
                 obj[item] = ''
-            })
-            return obj
+                return obj
+            }, {})
         },
         getKeys (data) {
-            const obj = {}
-            if (data.length > 0) {
-                data.forEach((item) => {
-                    obj[item.label] = item.name
-                })
+            return data.reduce((obj, item) => {
+                obj[item.label] = item.name
                 return obj
-            } else {
-                return obj
-            }
+            }, {})
         },
         xlsxFileClick () {
             this.xlsxFileVisible = true