Pārlūkot izejas kodu

体系运行记录盒删除记录时删除对应数据表数据

cfort 3 gadi atpakaļ
vecāks
revīzija
95a5627a60
1 mainītis faili ar 54 papildinājumiem un 10 dzēšanām
  1. 54 10
      src/views/platform/bpmn/bpmInstHis/list.vue

+ 54 - 10
src/views/platform/bpmn/bpmInstHis/list.vue

@@ -490,16 +490,15 @@
                         this.search()
                         this.search()
                         break
                         break
                     case 'remove':
                     case 'remove':
-                        let data = {}
-                        data['tableName'] = 'ibps_bpm_inst_his'
-                        data['paramWhere'] = "{id_:'" + selection.join(',') + "'}"
-                        curdPost('batchDelete', data).then(() => {
-                            this.$message({
-                                message: '删除成功!',
-                                type: 'warning'
-                            })
-                            this.search()
-                        })
+                        if (!data || !data.length) {
+                            this.$message.warning('请选择数据!')
+                            return
+                        }
+                        if (data.length > 10) {
+                            this.$message.warning('单次最多只能删除十条!')
+                            return
+                        }
+                        this.handleDelete(data, selection)
                         break
                         break
                     case 'detail': // 明细
                     case 'detail': // 明细
                         ActionUtils.selectedRecord(selection).then((id) => {
                         ActionUtils.selectedRecord(selection).then((id) => {
@@ -511,6 +510,51 @@
                         break
                         break
                 }
                 }
             },
             },
+            handleDelete(data, selection) {
+                this.$confirm('将删除选中运行记录与对应数据表数据,删除之后无法恢复, 是否确定?', '提示', {
+                    confirmButtonText: '确定',
+                    cancelButtonText: '取消',
+                    type: 'warning',
+                    showClose: false,
+                    closeOnClickModal: false
+                }).then(() => {
+                    let formKeyArr = []
+                    let delList = {}
+                    data.forEach(item => {
+                        let { bizKey, formKey } = item
+                        if (!delList[formKey]) {
+                            delList[formKey] = []
+                        }
+                        delList[formKey].push(bizKey)
+                        if (!formKeyArr.includes(formKey)) {
+                            formKeyArr.push(formKey)
+                        }
+                    })
+                    // console.log(delList, formKeyArr)
+                    const sql = `select a.bo_code_, b.key_ from ibps_form_bo a, ibps_form_def b where a.form_id_ = b.id_ and find_in_set(b.key_, '${formKeyArr.join(',')}')`
+                    // 获取选中记录对应的数据表code
+                    curdPost('sql', sql).then(res => {
+                        let result = res.variables && res.variables.data
+                        let codeList = {}
+                        result.forEach(m => {
+                            codeList[m.key_] = m.bo_code_
+                        })
+                        let req = `{"tableName":"ibps_bpm_inst_his","paramWhere":"{id_:'${selection.join(',')}'}"}`
+                        // 删除选中记录
+                        curdPost('batchDelete', req).then(() => {
+                            // 循环删除对应数据表数据
+                            Object.keys(codeList).forEach(k => {
+                                let temp = `{"tableName":"t_${codeList[k]}","paramWhere":"{id_:'${delList[k].join(',')}'}"}`
+                                curdPost('batchDelete', temp)
+                            })
+                            this.$message.success('删除成功!')
+                            this.search()
+                        })
+                    }).catch(() => {
+                        this.$message.error('获取数据表key值出错,请联系开发人员!')
+                    })
+                })
+            },
             handleNodeClick(typeId, typeName) {
             handleNodeClick(typeId, typeName) {
                 this.tableTitle = typeName.name
                 this.tableTitle = typeName.name
                 this.typeId = typeId
                 this.typeId = typeId