Pārlūkot izejas kodu

解决审批流编辑刷新丢失params的BUG

Alfyn 3 nedēļas atpakaļ
vecāks
revīzija
9f33a33fdc
1 mainītis faili ar 33 papildinājumiem un 16 dzēšanām
  1. 33 16
      src/views/Approval/Edit.vue

+ 33 - 16
src/views/Approval/Edit.vue

@@ -37,17 +37,17 @@
       </section>
     </div>
     <!-- 所有人 -->
-    <promoterDrawer /> 
+    <promoterDrawer />
     <!-- 抄送人 -->
     <copyerDrawer />
     <!-- 审批人 -->
     <approverDrawer :directorMaxLevel="directorMaxLevel" />
     <errorDialog :visible.sync="tipVisible" :list="tipList" />
     <conditionDrawer />
-  </div> 
+  </div>
 </template>
 <script>
-import { approvalPost,approvalDetails } from '@/api/Approval/index.js'
+import { approvalPost, approvalDetails } from '@/api/Approval/index.js'
 import errorDialog from '@/components/workFlow/dialog/errorDialog'
 import promoterDrawer from '@/components/workFlow/drawer/promoterDrawer'
 import approverDrawer from '@/components/workFlow/drawer/approverDrawer'
@@ -55,6 +55,10 @@ import copyerDrawer from '@/components/workFlow/drawer/copyerDrawer'
 import conditionDrawer from '@/components/workFlow/drawer/conditionDrawer'
 import nodeWrap from '@/components/workFlow/nodeWrap'
 import { mapMutations } from 'vuex'
+import storage from 'store'
+import expirePlugin from 'store/plugins/expire'
+
+storage.addPlugin(expirePlugin)
 export default {
   components: {
     errorDialog,
@@ -84,16 +88,8 @@ export default {
     this.flowPermission = flowPermission
     this.directorMaxLevel = directorMaxLevel
     this.workFlowDef = workFlowDef
-    if (this.$route.params.name) {
-      this.workFlowDef.name = this.$route.params.name
-    }
-    approvalDetails(this.$route.params.id).then(({data})=>{
-      if(data.nodes){
-        this.nodeConfig = data.nodes
-        Object.assign(this.nodeConfig, data.nodes)
-      }
-    })
     this.setTableId(tableId)
+    this.getNodeConfig()
   },
   methods: {
     ...mapMutations(['setTableId', 'setIsTried']),
@@ -140,10 +136,10 @@ export default {
       const params = JSON.parse(JSON.stringify(this.$route.params))
       params.nodes = this.nodeConfig
       delete params.id
-      if(!params.object_id) delete params.object_id
-      if(!params.object_type) delete params.object_type
-      const res =  await approvalPost(params)
-      this.$message.success(this.$t('save.ok'));
+      if (!params.object_id) delete params.object_id
+      if (!params.object_type) delete params.object_type
+      const res = await approvalPost(params)
+      this.$message.success(this.$t('save.ok'))
     },
     //缩放
     zoomSize(type) {
@@ -206,6 +202,27 @@ export default {
         },
       }
     },
+    //获取历史数据
+    getNodeConfig() {
+      let approvalName
+      let approvalId
+      if (this.$route.params.name && this.$route.params.id) {
+        approvalName = this.$route.params.name
+        approvalId = this.$route.params.id
+        storage.set('approval_params', JSON.stringify(this.$route.params), new Date().getTime() + 24 * 60 * 60 * 1000)
+      } else {
+        let approval_params = storage.get('approval_params') ? JSON.parse(storage.get('approval_params')) : { name: '', id: '' }
+        approvalName = approval_params.name
+        approvalId = approval_params.id
+      }
+      this.workFlowDef.name = approvalName
+      approvalDetails(approvalId).then(({ data }) => {
+        if (data.nodes) {
+          this.nodeConfig = data.nodes
+          Object.assign(this.nodeConfig, data.nodes)
+        }
+      })
+    },
   },
 }
 </script>