From f5f8aaedd1d488fb20a293182dd7a40e2e82096e Mon Sep 17 00:00:00 2001
From: wangting <675591594@qq.com>
Date: 星期二, 30 四月 2024 12:20:44 +0800
Subject: [PATCH] 添加action

---
 Source/ProjectWeb/src/actions/base/BaseAction.js |   54 ++++++++++++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 50 insertions(+), 4 deletions(-)

diff --git a/Source/ProjectWeb/src/actions/base/BaseAction.js b/Source/ProjectWeb/src/actions/base/BaseAction.js
index c4cec61..2482fde 100644
--- a/Source/ProjectWeb/src/actions/base/BaseAction.js
+++ b/Source/ProjectWeb/src/actions/base/BaseAction.js
@@ -9,7 +9,44 @@
  * action閫氱敤鍏ュ彛
  */
 export const doAction = (button,options,callback) => {
+  options.paramVOS = paramLow(options.paramVOS)
   options.paramVOS['title']=replaceFreeMarker(options.paramVOS.title,options.dataStore,options.sourceData);
+  let isShow = true;
+  if (options.paramVOS['initvalue'] && typeof(options.paramVOS.initvalue)=='string') {
+    let values = options.paramVOS['initvalue'].split(';');
+    let initValues = {}
+    values.forEach((item,i) => {
+      if(isShow){
+        item = item.replace(':', '=');
+        if (item.indexOf('${') > -1) {
+          if (item.split('=')[1].indexOf('.') > -1) {
+            if (options.sourceData.length < 1 || !options.sourceData.oid) {
+              isShow = false;
+              Vue.prototype.$message.error("璇峰厛閫夋嫨涓�鏉℃潵婧愭暟鎹�")
+              return false;
+            }
+            let name = item.split('=')[1].split('.')[1].replace('${', '').replace('}', '');
+            initValues[item.split('=')[0]] = options.sourceData[name]
+          } else {
+            if (options.dataStore.length < 1) {
+              isShow = false;
+              Vue.prototype.$message.error("璇峰厛閫夋嫨涓�鏉℃暟鎹�");
+              return false;
+            }
+            let name = item.split('=')[1].replace('${', '').replace('}', '');
+            initValues[item.split('=')[0]] = options.dataStore[0][name];
+
+          }
+        }
+      }
+    })
+    if(isShow){
+      options.paramVOS['initvalue'] = initValues
+    }
+  }
+  if(!isShow){
+    return;
+  }
 
   if(button.url && button.url!='null'){
     //鏈夐厤缃產ction璺緞锛屼娇鐢ㄨ矾寰勫搴旂殑js
@@ -117,7 +154,7 @@
  * @param preEventName 鍓嶇疆浜嬩欢鍚嶇О锛岄粯璁eforeevent
  */
 export const callPreEvent = (options,fnTarget,callback,preEventName) => {
-  let beforeEvent = options.paramVOS[preEventName || 'beforeevent'];
+  let beforeEvent = options.paramVOS[preEventName || 'prepvent'];
   if(beforeEvent) {
     let buttonParse = parseEventByUrl(beforeEvent,options,true);
     if(validatenull(buttonParse.jsPath)){
@@ -172,10 +209,10 @@
  * @param isBefore 鏄惁涓哄墠缃簨浠讹紝鍚﹀垯涓哄悗缃�
  * @returns {{jsPath: js鐨勮矾寰�, options: 鎸夐挳鐨勯厤缃俊鎭�, methodName: (string)鏂规硶鐨勫悕瀛梷}
  */
-export const parseEventByUrl = (url,options,isBefore) => {
+export const parseEventByUrl = (url,options,isBefore,defalutmethodName) => {
   //鏍规嵁閰嶇疆鏍煎紡鍖栦簨浠�
   let jsPath = url;
-  let methodName = isBefore?"doBefore":"doAfter";
+  let methodName = defalutmethodName || (isBefore?"doBefore":"doAfter");
   let params = {};
   if (url.indexOf("?")) {
     let temp = url.substring(0, url.indexOf("?"));
@@ -211,12 +248,21 @@
       jsPath = url;
     }
   }
+  if(!options){
+    options={
+      paramVOS:{}
+    }
+  }else if(!options.paramVOS){
+    options.paramVOS={}
+  }
+
   for (var key in params) {
     options.paramVOS[key.toLowerCase()] = params[key];
   }
   return {
     jsPath:jsPath,
     methodName:methodName,
-    options:options
+    options:options,
+    params:params
   };
 };

--
Gitblit v1.9.3