Jelajahi Sumber

体系运行记录盒内审管审归档调整、删除记录时同步删除对应数据表数据

cfort 3 tahun lalu
induk
melakukan
6644cbc1eb

+ 46 - 11
src/views/platform/bpmn/bpmInstHis/corresponding/index.js

@@ -23,15 +23,50 @@ export const listTypeData = {
     '1022458337893023744': 'sheBeiWeiHu',
 }
 
-// 特殊类型,内审管审特殊处理
-export const specialType = {
-    '859879582994530304': [
-        '首次会议签到',
-        '首次会议纪要',
-        '不符合项汇总',
-        '末次会议签到',
-        '末次会议纪要',
-        '不符合项整改'
-    ],
-    '859879751135789056': []
+// 内审管审类型ID
+const neishen = '859879582994530304'
+const guanshen = '859879751135789056'
+
+let specialType = {}
+let specialBtn = {}
+let specialParams = {}
+let specialTable = {}
+let specialField = {}
+
+specialType[neishen] = [
+    '首次会议签到',
+    '首次会议纪要',
+    '不符合项汇总',
+    '末次会议签到',
+    '末次会议纪要',
+    '不符合项整改'
+]
+specialType[guanshen] = [
+    
+]
+
+specialBtn[neishen] = {
+    label: '不符合项报告与纠正措施记录',
+    desc: '改进'
+}
+specialBtn[guanshen] = {
+    label: '改进项与跟踪验证',
+    desc: '整改'
+}
+
+specialParams[neishen] = 'zheng_gai_qian_ji as beforeImprove, zheng_gai_hou_jia as afterImprove, bian_zhi_ri_qi_ as flag'
+specialParams[guanshen] = 'gai_jin_qian_jian as beforeImprove, fu_jian_ as afterImprove, bian_hao_ as flag'
+
+specialTable[neishen] = 't_bfhxbgyjzcsjlbx'
+specialTable[guanshen] = 't_glpsjhb'
+
+specialField[neishen] = 'ji_hua_zong_wai_j'
+specialField[guanshen] = 'zong_wai_jian_'
+
+export {
+    specialType,
+    specialBtn,
+    specialParams,
+    specialTable,
+    specialField
 }

+ 167 - 23
src/views/platform/bpmn/bpmInstHis/list.vue

@@ -41,14 +41,63 @@
                     trigger="click"
                     @show="getReportAndFile(scope.row)"
                 >
-                    <!-- 触发事件 -->
-                    <!-- @click="handleAction('detail',null,null,scope.row)"-->
-                    <div class="div_test el-icon-s-order" slot="reference">查阅记录</div>
-                    <!-- 弹框内容 -->
+                    <!-- 二级菜单,内审管审特有 -->
+                    <template v-if="specialType.hasOwnProperty(typeId)">
+                        <el-popover
+                            :ref="'popover3-' + scope.row.id"
+                            placement="left"
+                            width="350"
+                            popper-class="popverClass"
+                            trigger="click"
+                        >
+                            <div class="sub_operation el-icon-s-order" slot="reference">{{ specialBtn[typeId].label }}</div>
+                            <div v-if="record.special && record.special.length" class="div_content">
+                                <div v-for="item in record.special" class="content_item">
+                                    <div class="sub_content">
+                                        <div class="title">{{ specialBtn[typeId].desc }}项{{ item.flag }}</div>
+                                        <div class="sub_item">
+                                            <div class="desc">{{ specialBtn[typeId].desc }}前</div>
+                                            <ibps-attachment
+                                                v-model="item.beforeImprove"
+                                                placeholder="请选择"
+                                                :download="true"
+                                                :readonly="true"
+                                                accept="*"
+                                                :multiple="true"
+                                                upload-type="attachment"
+                                                store="id"
+                                                media-type=""
+                                                media=""
+                                                style="width: 100%;"
+                                            />
+                                        </div>
+                                        <div class="sub_item">
+                                            <div class="desc">{{ specialBtn[typeId].desc }}后</div>
+                                            <ibps-attachment
+                                                v-model="item.afterImprove"
+                                                placeholder="请选择"
+                                                :download="true"
+                                                :readonly="true"
+                                                accept="*"
+                                                :multiple="true"
+                                                upload-type="attachment"
+                                                store="id"
+                                                media-type=""
+                                                media=""
+                                                style="width: 100%;"
+                                            />
+                                        </div>
+                                    </div>
+                                </div>
+                            </div>
+                            <div v-else>无对应数据</div>
+                        </el-popover>
+                    </template>
+                    <div class="div_operation el-icon-s-order" slot="reference">查阅记录</div>
                     <div class="div_content">
                         <!-- 获取所有输出报告-->
                         <template v-if="record.report.length">
-                            <div v-for="item in record.report" class="content_butts">
+                            <div v-for="item in record.report" class="content_item">
                                 <span style="cursor: pointer;" @click="openReport(item, record.bizKey)">
                                     <i class="el-icon-tickets" style="font-size: 18px;"/>
                                     <!-- 截取表单名称 -->
@@ -57,7 +106,7 @@
                                 <br/>
                             </div>
                         </template>
-                        <div v-if="record.file.length" class="content_butts">
+                        <div v-if="record.file.length" class="content_item">
                             <ibps-attachment
                                 v-model="fileId"
                                 placeholder="请选择"
@@ -72,6 +121,7 @@
                                 style="width: 100%;"
                             />
                         </div>
+                        <div v-if="!record.report.length && !record.file.length">无报表及附件数据</div>
                     </div>
                 </el-popover>
             </template>
@@ -110,7 +160,8 @@
     import BpmnFormrender from '@/business/platform/bpmn/form/dialog'
     import curdPost from '@/business/platform/form/utils/custom/joinCURD.js'
     import IbpsAttachment from '@/business/platform/file/attachment/selector'
-    import { specialType } from './corresponding/index'
+    import { specialType, specialBtn, specialParams, specialTable, specialField } from './corresponding/index'
+    
     export default {
         components: {
             IbpsTypeTree,
@@ -152,6 +203,7 @@
                     file: [],
                     table: [],
                     field: [],
+                    special: [],
                     bizKey: ''
                 },
                 title: '',
@@ -163,6 +215,8 @@
                 sorts: {},
                 // 默认过滤部分分类
                 hasPermission: true,
+                specialType,
+                specialBtn,
                 listConfig: {
                     toolbars: [
                         { key: 'search' }
@@ -227,12 +281,10 @@
                         if (temp.length === 4) {
                             // 判断截取内容是否为数字,如果不是则截取创建时间的作为年份
                             item.tYear = isNaN(Number(temp[0])) ? item.createTime.slice(0, 4) : temp[0]
-                            item.tYear = temp[0]
                             item.tDept = temp[2]
                             item.tUser = temp[3]
                         } else if (temp.length > 1) {
                             item.tYear = isNaN(Number(temp[0])) ? item.createTime.slice(0, 4) : temp[0]
-                            item.tYear = temp[0]
                             item.tDept = temp[1]
                             item.tUser = temp[2]
                         }
@@ -254,6 +306,15 @@
             },
             // 获取报表数据及附件数据
             getReportAndFile({ procDefKey, bizKey, subject }) {
+                // 每次获取前先清除原先数据
+                this.record = {
+                    report: [],
+                    file: [],
+                    table: [],
+                    field: [],
+                    special: [],
+                    bizKey: ''
+                }
                 if (this.isDisable) {
                     this.$message.error('请勿快速点击!');
                     return
@@ -268,18 +329,20 @@
                     file: temp.fu_jian_nei_rong_ ? temp.fu_jian_nei_rong_.split('.') : [],
                     table: temp.shi_fou_zi_biao_ ? temp.shi_fou_zi_biao_.split('.') : [],
                     field: temp.guan_lian_zi_duan ? temp.guan_lian_zi_duan.split('.') : [],
+                    special: [],
                     bizKey
                 }
                 let typeIndex = ''
                 // 特殊类型处理
-                if (specialType.hasOwnProperty(this.typeId)) {
-                    specialType[this.typeId].forEach((item, index) => {
+                if (this.specialType.hasOwnProperty(this.typeId)) {
+                    this.specialType[this.typeId].forEach((item, index) => {
                         // 判断当前流程在哪一步,以此决定报表展示
                         if (subject.includes(item)) {
                             // 数组下标+2为当前报表文件排序
                             typeIndex = index + 2
                         }
                     })
+                    this.getSpecicalFile(bizKey)
                 }
                 console.log(typeIndex)
                 if (typeIndex !== '') {
@@ -343,6 +406,15 @@
                 }
                 return value
             },
+            // 获取内审管审文件
+            getSpecicalFile(id) {
+                let sql = `select ${specialParams[this.typeId]} from ${specialTable[this.typeId]} where ${specialField[this.typeId]} = '${id}'`
+                console.log(sql)
+                curdPost('sql', sql).then(res => {
+                    const { data = [] } = res.variables || {}
+                    this.record.special = data
+                })
+            },
             // 打开报表
             openReport(path, id) {
                 this.srcUrl = `${this.$reportPash.replace('show', 'pdf')}${path}&id_=${id}`
@@ -418,16 +490,15 @@
                         this.search()
                         break
                     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
                     case 'detail': // 明细
                         ActionUtils.selectedRecord(selection).then((id) => {
@@ -439,6 +510,51 @@
                         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) {
                 this.tableTitle = typeName.name
                 this.typeId = typeId
@@ -474,9 +590,37 @@
             margin-top: -8px;
         }
     }
-    .main-container .div_test {
+    .div_operation {
         cursor: pointer;
     }
+    .sub_operation {
+        width: 100%;
+        height: 20px;
+        line-height: 20px;
+        color: #08c0b7;
+        // color: #85ce61;
+        cursor: pointer;
+        &:before {
+            font-size: 18px;
+            margin-right: 5px;
+        }
+    }
+    .sub_content {
+        .title {
+            margin-bottom: 4px;
+            font-weight: bold;
+        }
+        .sub_item {
+            display: flex;
+            align-items: center;
+            .desc {
+                margin-top: 6px;
+            }
+            > div:last-child {
+                width: calc(100% - 45px) !important;
+            }
+        }
+    }
     .main-container .el-popover.popverClass {
         .div_content {
             .content_checkbox {
@@ -487,7 +631,7 @@
                 }
                 z-index: 999;
             }
-            .content_butts {
+            .content_item {
                 z-index: 999;
                 margin-top: 20px;
                 display: flex;