Browse Source

流程页面缓存问题

lxf 1 year ago
parent
commit
81e0a182b8
1 changed files with 42 additions and 34 deletions
  1. 42 34
      src/views/process/processApproval/index.vue

+ 42 - 34
src/views/process/processApproval/index.vue

@@ -4,24 +4,28 @@
       <div class="top">
         <div class="commons-title title">
           {{
-            route.query.flowName
-              ? route.query.flowName + (route.query.processType ? typeName[route.query.processType] : "(发起)")
-              : keyName[route.query.flowKey] + "(审批)"
+            queryData.query.flowName
+              ? queryData.query.flowName + (queryData.query.processType ? typeName[queryData.query.processType] : "(发起)")
+              : keyName[queryData.query.flowKey] + "(审批)"
           }}
         </div>
         <div class="line"></div>
-        <Subscribe :queryData="detailsData.data" v-if="route.query.flowKey == 'apply_buy'" ref="makeDom"></Subscribe>
-        <Purchase :queryData="detailsData.data" v-else-if="route.query.flowKey == 'purchase'" ref="makeDom"></Purchase>
-        <Order :queryData="detailsData.data" v-else-if="route.query.flowKey == 'order'" ref="makeDom"></Order>
+        <Subscribe :queryData="detailsData.data" v-if="queryData.query.flowKey == 'apply_buy'" ref="makeDom"></Subscribe>
+        <Purchase :queryData="detailsData.data" v-else-if="queryData.query.flowKey == 'purchase'" ref="makeDom"></Purchase>
+        <Order :queryData="detailsData.data" v-else-if="queryData.query.flowKey == 'order'" ref="makeDom"></Order>
       </div>
-      <div class="bottom" v-if="route.query.processType != 20">
+      <div class="bottom" v-if="queryData.query.processType != 20">
         <div class="commons-title title">处理意见</div>
         <el-form :model="flowForm" :rules="flowRules" ref="flowFormDom">
           <el-form-item prop="remark" label-width="0px" label="">
             <el-input type="textarea" placeholder="请输入" v-model="flowForm.remark"> </el-input>
           </el-form-item>
           <el-form-item>
-            <el-button type="primary" v-if="!route.query.processType || ['30', '40'].includes(route.query.processType)" @click="handleSaveDraft" v-preReClick>
+            <el-button
+              type="primary"
+              v-if="!queryData.query.processType || ['30', '40'].includes(queryData.query.processType)"
+              @click="handleSaveDraft"
+              v-preReClick>
               保存草稿
             </el-button>
             <el-button type="primary" v-if="approvalRecordData.buttonInfoList.length == 0" @click="handleSubmit" v-preReClick>提交</el-button>
@@ -40,13 +44,13 @@
               v-for="item in recordList"
               :key="item.id"
               :class="
-                !route.query.flowId
+                !queryData.query.flowId
                   ? ''
                   : item.status == 2
                   ? 'flow-orange'
-                  : item.status == 3 && !route.query.flowId
+                  : item.status == 3 && !queryData.query.flowId
                   ? 'flow-orange'
-                  : item.status == 3 && route.query.flowId
+                  : item.status == 3 && queryData.query.flowId
                   ? 'flow-grey'
                   : ''
               ">
@@ -184,11 +188,11 @@ const handleSubmit = async (_type) => {
       flowFormDom.value.validate((valid) => {
         if (valid) {
           const data = { ...proxy.$refs.makeDom.getFormData() };
-          if (route.query.processType == "10" || route.query.processType == "30") {
+          if (queryData.query.processType == "10" || queryData.query.processType == "30") {
             if (_type && _type == 1) {
               proxy
                 .post("/flowExample/setStartData", {
-                  exampleId: route.query.flowId,
+                  exampleId: queryData.query.flowId,
                   startData: data,
                 })
                 .then();
@@ -198,8 +202,8 @@ const handleSubmit = async (_type) => {
                 ...flowForm,
                 data,
                 handleType: _type,
-                version: route.query.version,
-                flowId: route.query.flowId,
+                version: queryData.query.version,
+                flowId: queryData.query.flowId,
               })
               .then((res) => {
                 handleResult(res);
@@ -226,31 +230,32 @@ const handleSubmit = async (_type) => {
 const skipPage = () => {
   const useTagsStore = useTagsViewStore();
   useTagsStore.delVisitedView(router.currentRoute.value);
-  if (route.query.processType && route.query.processType != "40") {
+  if (queryData.query.processType && queryData.query.processType != "40") {
     router.replace({
       path: "/oa/1/dealWith",
     });
   } else {
     ElMessage({ message: "操作成功!", type: "success" });
-    if (route.query.flowKey == "order") {
+    if (queryData.query.flowKey == "order") {
       refreshStore().setRefresh("order");
       if (proxy.useUserStore().user.deptId === "100") {
         router.replace({
-          path: flowKeyCollect[route.query.flowKey].backPath,
+          path: flowKeyCollect[queryData.query.flowKey].backPath,
         });
       } else {
         router.replace({
-          path: flowKeyCollect[route.query.flowKey].backPathTwo,
+          path: flowKeyCollect[queryData.query.flowKey].backPathTwo,
         });
       }
     } else {
       router.replace({
-        path: flowKeyCollect[route.query.flowKey].backPath,
+        path: flowKeyCollect[queryData.query.flowKey].backPath,
       });
     }
   }
 };
-let queryData = reactive({
+const queryData = reactive({
+  query: {},
   data: {},
 });
 // 记录
@@ -280,7 +285,7 @@ const getRecords = (_id) => {
   } else {
     proxy
       .post("/flowExample/getFlowNode", {
-        flowKey: route.query.flowKey,
+        flowKey: queryData.query.flowKey,
       })
       .then((res) => {
         recordList.value = res;
@@ -291,31 +296,34 @@ const handleSaveDraft = async () => {
   const flag = await proxy.$refs.makeDom.handleSubmit();
   if (flag) {
     let data = proxy.$refs.makeDom.getFormData();
-    if (route.query.flowKey == "order") {
+    if (queryData.query.flowKey == "order") {
       data.status = "0";
     }
     if (data.id) {
-      proxy.post(flowKeyCollect[route.query.flowKey].edit, data).then(() => {
+      proxy.post(flowKeyCollect[queryData.query.flowKey].edit, data).then(() => {
         skipPage();
       });
     } else {
-      proxy.post(flowKeyCollect[route.query.flowKey].add, data).then(() => {
+      proxy.post(flowKeyCollect[queryData.query.flowKey].add, data).then(() => {
         skipPage();
       });
     }
   }
 };
 onMounted(() => {
+  if (route.query) {
+    queryData.query = route.query;
+  }
   //processType 10 为修改 20为查看 30回退发起 40为草稿修改
-  flowForm.flowKey = route.query.flowKey;
-  flowForm.tenantType = route.query.tenantType;
-  if (route.query.random) {
+  flowForm.flowKey = queryData.query.flowKey;
+  flowForm.tenantType = queryData.query.tenantType;
+  if (queryData.query.random) {
     useTagsViewStore().visitedViews = useTagsViewStore().visitedViews.map((item) => {
-      if (item.query && item.query.random === route.query.random) {
+      if (item.query && item.query.random === queryData.query.random) {
         return {
           ...item,
-          name: route.query.flowName,
-          title: route.query.flowName,
+          name: queryData.query.flowName,
+          title: queryData.query.flowName,
         };
       } else {
         return {
@@ -324,12 +332,12 @@ onMounted(() => {
       }
     });
   }
-  if (route.query.id) {
-    proxy.post(flowKeyCollect[route.query.flowKey].detail, { id: route.query.id }).then((res) => {
+  if (queryData.query.id) {
+    proxy.post(flowKeyCollect[queryData.query.flowKey].detail, { id: queryData.query.id }).then((res) => {
       detailsData.data = { ...res };
     });
   }
-  getRecords(route.query.flowId);
+  getRecords(queryData.query.flowId);
 });
 </script>
 <style lang="scss" scoped>