From fc97fca89d00f6af4e99345dc2da2d385a79badf Mon Sep 17 00:00:00 2001
From: qiaoyanqi <qiaoyanqi@jiuqi.com.cn>
Date: Fri, 11 Mar 2022 17:25:14 +0800
Subject: [PATCH] 上张下张抽取出去一个js  多页签 刷新单据,需要判断是否是当前页签

---
 develop/@gms/gms-plugin-billexpand/src/actions/createBill.js            |  4 ++--
 develop/@gms/gms-plugin-billexpand/src/actions/deleteBill.js            |  3 ++-
 develop/@gms/gms-plugin-billexpand/src/actions/pageType.js              | 30 ++++++++++++++----------------
 develop/@gms/gms-plugin-billexpand/src/actions/saveAction.js            |  8 ++------
 develop/@gms/gms-plugin-billexpand/src/actions/submitAction.js          |  6 ++----
 develop/@gms/gms-plugin-billexpand/src/actions/tempSave.js              |  7 ++-----
 develop/@gms/gms-plugin-billexpand/src/query-actions/createBill.js      | 11 ++++-------
 develop/@gms/gms-plugin-billexpand/src/query-actions/editBill.js        | 13 ++++++-------
 develop/@gms/gms-plugin-billexpand/src/query-actions/examineAction.js   | 14 ++++++--------
 develop/@gms/gms-plugin-billexpand/src/query-actions/goToDetail.js      | 19 +++++++++----------
 develop/@gms/gms-plugin-billexpand/src/query-actions/seeDetailAction.js | 14 ++++++--------
 develop/@gms/gms-plugin-billexpand/src/query-actions/util/queryTag.js   | 69 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 develop/@rbc/runner-bill-form/src/views/bill-form-runner.vue            |  5 ++++-
 13 files changed, 128 insertions(+), 75 deletions(-)
 create mode 100644 develop/@gms/gms-plugin-billexpand/src/query-actions/util/queryTag.js

diff --git a/develop/@gms/gms-plugin-billexpand/src/actions/createBill.js b/develop/@gms/gms-plugin-billexpand/src/actions/createBill.js
index 60e0256..98f066e 100644
--- a/develop/@gms/gms-plugin-billexpand/src/actions/createBill.js
+++ b/develop/@gms/gms-plugin-billexpand/src/actions/createBill.js
@@ -1,7 +1,7 @@
-
+import {setQueryIndex} from '../query-actions/util/queryTag.js';
 export default {
     execute(context, param) {
-        GMS.queryObject.index=-1;//上张下张用
+        setQueryIndex(-1);//上张下张用
         // 新建单据状态设置为可编辑,单据id为空
         GMS.vbus.$emit('change-form-state', {state: '', billId: null})
     },
diff --git a/develop/@gms/gms-plugin-billexpand/src/actions/deleteBill.js b/develop/@gms/gms-plugin-billexpand/src/actions/deleteBill.js
index 2b8a656..81d0705 100644
--- a/develop/@gms/gms-plugin-billexpand/src/actions/deleteBill.js
+++ b/develop/@gms/gms-plugin-billexpand/src/actions/deleteBill.js
@@ -1,4 +1,5 @@
 
+import {setQueryIndex} from '../query-actions/util/queryTag.js';
 export default {
   execute(bill, param) {
     GMS.$hideContainer.$Modal.confirm({
@@ -21,7 +22,7 @@ export default {
       if (data.status == 200 && data.data.code == 0) {
         GMS.$hideContainer.$Modal.remove(); 
         GMS.$hideContainer.$Message.success('删除成功');
-        GMS.queryObject.index=-1;//上张下张用
+        setQueryIndex(-1);//上张下张用 ,删除成功后,跳转到新建界面
         GMS.vbus.$emit('change-form-state', {state: '', billId: null})
       } else {
         GMS.$hideContainer.$Modal.remove();
diff --git a/develop/@gms/gms-plugin-billexpand/src/actions/pageType.js b/develop/@gms/gms-plugin-billexpand/src/actions/pageType.js
index 6590a78..bd4f032 100644
--- a/develop/@gms/gms-plugin-billexpand/src/actions/pageType.js
+++ b/develop/@gms/gms-plugin-billexpand/src/actions/pageType.js
@@ -1,4 +1,5 @@
 import { compareData } from "../components-control/util/dataChange.js";
+import {setQueryIndex , getQueryIndex ,getQuerySet} from '../query-actions/util/queryTag.js';
 export default {
   execute(bill, param) {
     // 首张、上张、下张、末张
@@ -6,7 +7,9 @@ export default {
     if (param.name.split('_action_gams')) {
       actionName = param.name.split('_action_gams')[1];
     }
-    let flag = compareData(GMS.oldBillData, bill.getBuillData());
+    let curTagId = window.nros.context.getCurrTag();
+    let oldObj = curTagId && GMS.oldBillDataMap[curTagId]?GMS.oldBillDataMap[curTagId]:GMS.oldBillData;
+    let flag = compareData(oldObj, bill.getBuillData()) || bill.getGlobalParam("noRunTimeFormula");
     if (flag) {
       this.getOtherPage(actionName);
     } else {
@@ -25,38 +28,33 @@ export default {
     }
   },
   async getOtherPage(action) {
-    let page = GMS.queryObject.currentDataQueryConditionSet.page;
-    let index =
-      GMS.queryObject.index == -1
-        ? GMS.queryObject.index
-        : (page.pageNum - 1) * page.size + GMS.queryObject.index;
+    const queryCondition = getQuerySet();
+    let page = queryCondition.page;
+    let index = getQueryIndex() == -1? getQueryIndex() : (page.pageNum - 1) * page.size + getQueryIndex();
     const url = `/rbc/bill/move/${action.toUpperCase()}/${index}`;
     const { data } = await window.GMS.$http.post(
       url,
-      GMS.queryObject.currentDataQueryConditionSet
+      queryCondition
     );
     if (data) {
       console.log(data.data.id);
       if (data.data && data.data.id) {
         if (action == "down") {
-          GMS.queryObject.index++;
+          setQueryIndex('add');
         } else if (action == "upward") {//上张不能无限减小
-          if(GMS.queryObject.index>0){
-            GMS.queryObject.index--;
-          }else{
-            GMS.queryObject.index = 0;
-          }
+          setQueryIndex('min');
         } else if (action == "first") {
-          GMS.queryObject.index = 0;
+          setQueryIndex(0);
         } else if (action == "last") {
-          GMS.queryObject.index = data.data.count - 1;
+          setQueryIndex(data.data.count - 1);
         }
         let state = 'readOnly';
+        let curTagId = window.nros.context.getCurrTag();
         if (
           window.osConfig.appOpenMode &&
           window.osConfig.appOpenMode == "apploader"
         ) {
-          GMS.$hideContainer.$portalAPI.emit("resetBillData", data.data.id,state);
+          GMS.$hideContainer.$portalAPI.emit("resetBillData", data.data.id,state,curTagId);
         } else {
           GMS.vbus.$emit("resetBillData", data.data.id,state);
         }
diff --git a/develop/@gms/gms-plugin-billexpand/src/actions/saveAction.js b/develop/@gms/gms-plugin-billexpand/src/actions/saveAction.js
index 5f730b7..889274b 100644
--- a/develop/@gms/gms-plugin-billexpand/src/actions/saveAction.js
+++ b/develop/@gms/gms-plugin-billexpand/src/actions/saveAction.js
@@ -1,4 +1,5 @@
 import errorMessageUtil from "./util/errorMessageUtil";
+import {initIndexZero} from '../query-actions/util/queryTag.js';
 export default {
   execute: function (bill, param) {
     if (bill) {
@@ -110,12 +111,7 @@ export default {
           bill.getMasterData().setValue("recver", response.data.content.billData.recver);
           bill.getMasterData().setValue("billCode", response.data.content.billData.billCode);
           const id = response.data.content.billData.id;
-          //处理上张下张
-          if (GMS.queryObject) {
-            if(GMS.queryObject.index==-1){
-              GMS.queryObject.index=0;
-            }
-          }
+          initIndexZero();//处理上张下张
           GMS.vbus.$Message.success("保存成功");
           if (param.param && param.param.isApprove) {
             GMS.vbus.$emit('change-form-state', { state: ''})
diff --git a/develop/@gms/gms-plugin-billexpand/src/actions/submitAction.js b/develop/@gms/gms-plugin-billexpand/src/actions/submitAction.js
index c86db14..09c467d 100644
--- a/develop/@gms/gms-plugin-billexpand/src/actions/submitAction.js
+++ b/develop/@gms/gms-plugin-billexpand/src/actions/submitAction.js
@@ -1,5 +1,5 @@
 import errorMessageUtil from "./util/errorMessageUtil";
-
+import {minusIndex} from '../query-actions/util/queryTag.js';
 export default {
   execute: function (bill, param) {
     if (param && param.param && param.param.budgetcontrol) {
@@ -79,9 +79,7 @@ export default {
         bill.setControlsSate(param["_control_name_"], 'enable', true)
         if (code === 200) {
           const id = data.content.billData.id;
-          if(GMS.queryObject){
-            GMS.queryObject.index = GMS.queryObject.index*1 - 1;//上张下张用
-          }
+          minusIndex();//上张下张用
           GMS.$hideContainer.$Message.success('提交成功');
           GMS.vbus.$emit("workflow-state-change", 90)
         } else if (code === 201) {
diff --git a/develop/@gms/gms-plugin-billexpand/src/actions/tempSave.js b/develop/@gms/gms-plugin-billexpand/src/actions/tempSave.js
index 50df941..9e423c2 100644
--- a/develop/@gms/gms-plugin-billexpand/src/actions/tempSave.js
+++ b/develop/@gms/gms-plugin-billexpand/src/actions/tempSave.js
@@ -1,5 +1,5 @@
 import errorMessageUtil from "./util/errorMessageUtil";
-
+import {initIndexZero} from '../query-actions/util/queryTag.js';
 /**
  * 暂存按钮
  * 不触发校验公式 调用已有保存逻辑
@@ -100,10 +100,7 @@ export default {
                 bill.getMasterData().setValue("recver", response.data.content.billData.recver);
                 bill.getMasterData().setValue("billCode", response.data.content.billData.billCode);
                 const id = response.data.content.billData.id;
-                //处理上张下张
-                if(GMS.queryObject.index==-1){
-                    GMS.queryObject.index=0;
-                }
+                initIndexZero();//处理上张下张
                 GMS.vbus.$Message.success("暂存成功");
                 GMS.vbus.$emit('change-form-state', {state: 'readOnly', billId: id})
                 GMS.vbus.$emit("saveSuccess", buidData, param);
diff --git a/develop/@gms/gms-plugin-billexpand/src/query-actions/createBill.js b/develop/@gms/gms-plugin-billexpand/src/query-actions/createBill.js
index 773b5dd..dab8077 100644
--- a/develop/@gms/gms-plugin-billexpand/src/query-actions/createBill.js
+++ b/develop/@gms/gms-plugin-billexpand/src/query-actions/createBill.js
@@ -1,13 +1,10 @@
 import typesBill from "../components-control/typesBill.vue";
 import {getUUID} from './util/lib.js'
+import {setQueryTag} from './util/queryTag.js';
 export default {
   execute(context, param) {
-    GMS.queryObject = {//上张下张用
-      currentDataQueryConditionSet: context.currentDataQueryConditionSet,
-      index:  -1,
-      templateName:param.viewName,
-      isReadOnly:false
-    }
+    const uuid = getUUID();
+    setQueryTag(context.currentDataQueryConditionSet,-1,param.viewName,uuid);//上张下张用 
     let templateName = null;
     if (Object.prototype.toString.call(param) === "[object Array]") {
       templateName = param[0];
@@ -20,7 +17,7 @@ export default {
     ) {
       GMS.$hideContainer.$portalAPI.emit(
         "open-new-page", //打开一个新的页签
-        getUUID(),
+        uuid,
         "runner-bill-form",
         {
           templateName: templateName,
diff --git a/develop/@gms/gms-plugin-billexpand/src/query-actions/editBill.js b/develop/@gms/gms-plugin-billexpand/src/query-actions/editBill.js
index 7f958fe..d9001e6 100644
--- a/develop/@gms/gms-plugin-billexpand/src/query-actions/editBill.js
+++ b/develop/@gms/gms-plugin-billexpand/src/query-actions/editBill.js
@@ -1,13 +1,12 @@
 import typesBill from "../components-control/typesBill.vue";
 import { getUUID } from "./util/lib.js";
+import {setQueryTag} from './util/queryTag.js';
+
 export default {
   execute(context, param) {
-    GMS.queryObject = {//上张下张用
-      currentDataQueryConditionSet: context.currentDataQueryConditionSet,
-      index: context.selects[0]._index||(context.selects[0]._serialIndex)*1-1,
-      templateName:param.viewName,
-      isReadOnly:false
-    }
+    const uuid = getUUID();
+    let index = context.selects[0]._index||(context.selects[0]._serialIndex)*1-1;
+    setQueryTag(context.currentDataQueryConditionSet,index,param.viewName,uuid);//上张下张用 
     GMS.vbus.$off("cacheEcho");
     let templateName = param.viewName;
     let billId = context.selects[0][param.billId];
@@ -17,7 +16,7 @@ export default {
     ) {
       GMS.$hideContainer.$portalAPI.emit(
         "open-new-page", //打开一个新的页签
-        getUUID(),
+        uuid,
         "runner-bill-form",
         {
           templateName: templateName,
diff --git a/develop/@gms/gms-plugin-billexpand/src/query-actions/examineAction.js b/develop/@gms/gms-plugin-billexpand/src/query-actions/examineAction.js
index 78db073..a4be60d 100644
--- a/develop/@gms/gms-plugin-billexpand/src/query-actions/examineAction.js
+++ b/develop/@gms/gms-plugin-billexpand/src/query-actions/examineAction.js
@@ -1,18 +1,16 @@
 import typesBill from "../components-control/typesBill.vue";
 import { getUUID } from "./util/lib.js";
+import {setQueryTag} from './util/queryTag.js';
 export default {
   execute(context, param) {
     if (!param.billId || !param.viewName || !param.taskId) {
       context.dom.$Message.info("请配置跳转页面的参数");
       return;
     }
-    const billState = param.canEdit? '': 'readOnly'
-    GMS.queryObject = {//上张下张用
-      currentDataQueryConditionSet: context.currentDataQueryConditionSet,
-      index: context.selects[0]._index||(context.selects[0]._serialIndex)*1-1,
-      templateName:param.viewName,
-      isReadOnly:true
-    }
+    const uuid = getUUID();
+    const billState = param.canEdit ? '': 'readOnly'
+    let index = context.selects[0]._index||(context.selects[0]._serialIndex)*1-1;
+    setQueryTag(context.currentDataQueryConditionSet,index,param.viewName,uuid);//上张下张用 
     let templateName = param.viewName;
     let billId = context.selects[0][param.billId];
     window.GMS.workflowTaskId = context.selects[0][param.taskId]
@@ -22,7 +20,7 @@ export default {
     ) {
       GMS.$hideContainer.$portalAPI.emit(
         "open-new-page", //打开一个新的页签
-        getUUID(),
+        uuid,
         "runner-bill-form",
         {
           templateName: templateName,
diff --git a/develop/@gms/gms-plugin-billexpand/src/query-actions/goToDetail.js b/develop/@gms/gms-plugin-billexpand/src/query-actions/goToDetail.js
index 94c6ae4..d45ea1a 100644
--- a/develop/@gms/gms-plugin-billexpand/src/query-actions/goToDetail.js
+++ b/develop/@gms/gms-plugin-billexpand/src/query-actions/goToDetail.js
@@ -1,28 +1,27 @@
 import typesBill from '../components-control/typesBill.vue';
 import { getUUID } from "./util/lib.js";
+import {setQueryTag} from './util/queryTag.js';
 export default {
     execute(context, param) {
-        console.log(11111, context, param)
         if (!param.billId || !param.viewName) {
             context.dom.$Message.info("请配置跳转页面的参数");
             return;
         }
-        GMS.queryObject = {//上张下张用
-            currentDataQueryConditionSet: context.currentDataQueryConditionSet,
-            index: context.selects[0]._index||(context.selects[0]._serialIndex)*1-1,
-            templateName: context.selects[0][param.viewName],
-            isReadOnly: true,
-        }
+        const uuid = getUUID();
+        const templateName = context.selects[0][param.viewName];
+        const index = context.selects[0]._index||(context.selects[0]._serialIndex)*1-1;
+
+        setQueryTag(context.currentDataQueryConditionSet,index,templateName,uuid);//上张下张用 
         if (
             window.osConfig.appOpenMode &&
             window.osConfig.appOpenMode == "apploader"
         ) {
             GMS.$hideContainer.$portalAPI.emit(
                 "open-new-page", //打开一个新的页签
-                getUUID(),
+                uuid,
                 "runner-bill-form",
                 {
-                    templateName: context.selects[0][param.viewName],
+                    templateName: templateName,
                     id: context.selects[0][param.billId],
                     state: 'readOnly',
                     hideButtonGroup: param.hideButton? true: false
@@ -34,7 +33,7 @@ export default {
             );
         } else {
             GMS.$hideContainer.addComponent(typesBill, {}, function (c) {
-                c.templateName = context.selects[0][param.viewName];
+                c.templateName = templateName;
                 c.billId = context.selects[0][param.billId];
                 c.init = true;
                 c.modal_visible = true;
diff --git a/develop/@gms/gms-plugin-billexpand/src/query-actions/seeDetailAction.js b/develop/@gms/gms-plugin-billexpand/src/query-actions/seeDetailAction.js
index d76d981..f76c6ff 100644
--- a/develop/@gms/gms-plugin-billexpand/src/query-actions/seeDetailAction.js
+++ b/develop/@gms/gms-plugin-billexpand/src/query-actions/seeDetailAction.js
@@ -1,18 +1,16 @@
 import typesBill from "../components-control/typesBill.vue";
 import { getUUID } from "./util/lib.js";
+import {setQueryTag} from './util/queryTag.js';
 export default {
   execute(context, param) {
     if (!param.billId || !param.viewName) {
       context.dom.$Message.info("请配置跳转页面的参数");
       return;
     }
-    GMS.queryObject = {//上张下张用
-      currentDataQueryConditionSet: context.currentDataQueryConditionSet,
-      index: context.selects[0]._index||(context.selects[0]._serialIndex)*1-1,
-      templateName:param.viewName,
-      isReadOnly:true
-    }
-    let templateName = param.viewName;
+    const templateName = param.viewName;
+    const index = context.selects[0]._index||(context.selects[0]._serialIndex)*1-1;
+    const uuid = getUUID();
+    setQueryTag(context.currentDataQueryConditionSet,index,templateName,uuid);//上张下张用
     let billId = context.selects[0][param.billId];
     if (
       window.osConfig.appOpenMode &&
@@ -20,7 +18,7 @@ export default {
     ) {
         GMS.$hideContainer.$portalAPI.emit(
             "open-new-page", //打开一个新的页签
-            getUUID(),
+            uuid,
             "runner-bill-form",
             {
               templateName: templateName,
diff --git a/develop/@gms/gms-plugin-billexpand/src/query-actions/util/queryTag.js b/develop/@gms/gms-plugin-billexpand/src/query-actions/util/queryTag.js
new file mode 100644
index 0000000..6f714e9
--- /dev/null
+++ b/develop/@gms/gms-plugin-billexpand/src/query-actions/util/queryTag.js
@@ -0,0 +1,69 @@
+/**
+ * 查询列表点击操作按钮,记录当前行信息,用于上张、下张
+ * @author qiaoyanqi
+ * @date 2022-03-11
+ */
+//window.nros.context.getCurrTag() || "router"; //如果是页签形式的话,就需要记录每个页签的情况,如果是路由模式,只记录一种即可。
+/**
+ *
+ * @param {object} querySet -查询条件
+ * @param {number} index -下标
+ * @param {string} templateName - 单据子表
+ * @param {string} uuid - 打开单据的uuid
+ */
+export function setQueryTag(querySet, index, templateName,uuid) {
+  let curTagId = uuid || 'router'; 
+  if(!GMS.queryObject){
+    GMS.queryObject = {};
+  }
+  GMS.queryObject[curTagId] = {
+    //上张下张用
+    currentDataQueryConditionSet: querySet,
+    index: index,
+    templateName: templateName,
+  };
+}
+
+//获取查询条件
+export function getQuerySet() {
+  let curTagId = window.nros.context.getCurrTag() || "router"; 
+  return GMS.queryObject && GMS.queryObject[curTagId].currentDataQueryConditionSet;
+  console.log('没有获取到查询条件');
+}
+
+//获取下标
+export function getQueryIndex() {
+  let curTagId = window.nros.context.getCurrTag() || "router"; 
+  return GMS.queryObject && GMS.queryObject[curTagId].index;
+  console.log('没有获取到下标');
+}
+
+//给下标赋值
+export function setQueryIndex(index) {
+  let curTagId = window.nros.context.getCurrTag() || "router"; 
+  if(GMS.queryObject){
+    if (index == "add") {
+      GMS.queryObject[curTagId].index++;
+    } else if (index == "min") {
+      GMS.queryObject[curTagId].index = getQueryIndex() > 0?GMS.queryObject[curTagId].index--:0;
+    } else {
+      GMS.queryObject[curTagId].index = index;
+    }
+  }
+}
+
+//如果index为-1的话,设置为0
+export function initIndexZero() {
+  let curTagId = window.nros.context.getCurrTag() || "router"; 
+  if (GMS.queryObject && getQueryIndex() == -1) {
+    GMS.queryObject[curTagId].index = 0;
+  }
+}
+
+//下标减一
+export function minusIndex() {
+  let curTagId = window.nros.context.getCurrTag() || "router"; 
+  if (GMS.queryObject) {
+    GMS.queryObject[curTagId].index = getQueryIndex() * 1 - 1; //上张下张用
+  }
+}
diff --git a/develop/@rbc/runner-bill-form/src/views/bill-form-runner.vue b/develop/@rbc/runner-bill-form/src/views/bill-form-runner.vue
index e95a738..50bfead 100644
--- a/develop/@rbc/runner-bill-form/src/views/bill-form-runner.vue
+++ b/develop/@rbc/runner-bill-form/src/views/bill-form-runner.vue
@@ -110,7 +110,10 @@ export default {
         GMS.oldBillDataMap[this.curTagId] = bill.getBuillData()
       }, 100);
     },
-    changeData(billId,state) {
+    changeData(billId,state,curTagId) {
+      if(curTagId!=this.curTagId){
+         return
+      }
       this.init = false;
       this.$nextTick(() => {
         this.type = 'load';
--
libgit2 0.26.0