From 506b5b59e3899d8dd40a61cc8b9a575bbde3caaa Mon Sep 17 00:00:00 2001
From: wangting <675591594@qq.com>
Date: 星期一, 06 五月 2024 18:24:33 +0800
Subject: [PATCH] 添加action

---
 Source/ProjectWeb/src/components/dynamic-components/dynamic-button.vue |    7 -
 Source/ProjectWeb/src/actions/base/BaseAction.js                       |   18 +++-
 Source/ProjectWeb/src/views/base/UIContentViewerInDialog.vue           |   42 +++++++++-
 Source/ProjectWeb/src/components/dynamic-components/index.vue          |    7 +
 Source/ProjectWeb/src/views/base/UIContentArea.vue                     |    6 +
 Source/ProjectWeb/src/components/actions/AddEditDialog.vue             |   33 ++++++--
 Source/ProjectWeb/src/components/dynamic-components/dynamic-form.vue   |   14 ++
 Source/ProjectWeb/src/components/dynamic-components/dynamic-table.vue  |   12 +++
 Source/ProjectWeb/src/components/PLT-basic-component/basicForm.vue     |   20 +++-
 Source/ProjectWeb/src/components/dynamic-components/dynamic-tree.vue   |   58 +++++++++++---
 10 files changed, 170 insertions(+), 47 deletions(-)

diff --git a/Source/ProjectWeb/src/actions/base/BaseAction.js b/Source/ProjectWeb/src/actions/base/BaseAction.js
index 2482fde..c46ad97 100644
--- a/Source/ProjectWeb/src/actions/base/BaseAction.js
+++ b/Source/ProjectWeb/src/actions/base/BaseAction.js
@@ -20,22 +20,30 @@
         item = item.replace(':', '=');
         if (item.indexOf('${') > -1) {
           if (item.split('=')[1].indexOf('.') > -1) {
-            if (options.sourceData.length < 1 || !options.sourceData.oid) {
+            //initvaluenull=true鍏佽鍒濆鍊间负绌�
+            if ((options.sourceData.length < 1 || !options.sourceData.oid) && options.paramVOS['initvaluenull']!=true && options.paramVOS['initvaluenull']!="true") {
               isShow = false;
               Vue.prototype.$message.error("璇峰厛閫夋嫨涓�鏉℃潵婧愭暟鎹�")
               return false;
             }
             let name = item.split('=')[1].split('.')[1].replace('${', '').replace('}', '');
-            initValues[item.split('=')[0]] = options.sourceData[name]
+            if(options.sourceData){
+              initValues[item.split('=')[0]] = options.sourceData[name]
+            }else {
+              initValues[item.split('=')[0]]=""
+            }
           } else {
-            if (options.dataStore.length < 1) {
+            if (options.dataStore.length < 1 && options.paramVOS['initvaluenull'] != true && options.paramVOS['initvaluenull'] != "true") {
               isShow = false;
               Vue.prototype.$message.error("璇峰厛閫夋嫨涓�鏉℃暟鎹�");
               return false;
             }
             let name = item.split('=')[1].replace('${', '').replace('}', '');
-            initValues[item.split('=')[0]] = options.dataStore[0][name];
-
+            if (options.dataStore[0]) {
+              initValues[item.split('=')[0]] = options.dataStore[0][name];
+            } else {
+              initValues[item.split('=')[0]] = "";
+            }
           }
         }
       }
diff --git a/Source/ProjectWeb/src/components/PLT-basic-component/basicForm.vue b/Source/ProjectWeb/src/components/PLT-basic-component/basicForm.vue
index c8c67c8..718ae8f 100644
--- a/Source/ProjectWeb/src/components/PLT-basic-component/basicForm.vue
+++ b/Source/ProjectWeb/src/components/PLT-basic-component/basicForm.vue
@@ -70,7 +70,11 @@
       //琛ㄥ崟鏄惁鍙紪杈�
       type:Boolean,
       default:true
-    }
+    },
+    initValue:{
+      type: Object,
+      default: () => {},
+    },
   },
   data() {
     return {
@@ -103,10 +107,13 @@
   watch: {
     formItems: {
       handler(val) {
-        if(val[0] &&val[0].column && val[0].column.isArray()){
+        if (val[0] && val[0].column && val[0].column.isArray()) {
           this.getInitGroup(val);
-        }else{
+        } else {
           this.getInit(val);
+        }
+        if (this.initValue) {
+          Object.assign(this.form, this.initValue);
         }
       },
       immediate: true,
@@ -154,7 +161,6 @@
         code = this.initItem(code);
         column.push(code);
         this.allColumn.push(code);
-        console.log('allColumn',this.allColumn)
       }
       this.option.column = column;
     },
@@ -220,9 +226,9 @@
         if(col.data && col.data.length>0){
           col.dicData = col.data.map((d) => {
             return {
-              label: d.value,
-              key: d.key,
-              value: d.key,
+              label: d.key,
+              key: d.value,
+              value: d.value,
               attributes:d.attributes
             };
           });
diff --git a/Source/ProjectWeb/src/components/actions/AddEditDialog.vue b/Source/ProjectWeb/src/components/actions/AddEditDialog.vue
index 11347ab..165aa34 100644
--- a/Source/ProjectWeb/src/components/actions/AddEditDialog.vue
+++ b/Source/ProjectWeb/src/components/actions/AddEditDialog.vue
@@ -16,6 +16,7 @@
                 :isEdit="true"
                 :formItems="formItems"
                 :formData="form"
+                :initValue="paramVOS.initvalue"
                 @getFormData="getFormData">
     </basic-form>
     <ui-view ref="uiViewRef" v-else-if="paramVOS.context"
@@ -116,7 +117,7 @@
   created() {
   },
   watch: {
-    sourceData: {
+    paramVOS: {
       handler(val) {
         if (this.paramVOS.form) {
           this.onLoad();
@@ -136,7 +137,6 @@
         getFormDefineById(this.paramVOS.type,this.paramVOS.form).then(result => {
           this.formItems=result.data.obj.items;
           this.span=result.data.obj.columnOneRow?(24/result.data.obj.columnOneRow) : 12;
-
           if (this.paramVOS.initvalue) {
             this.form=this.paramVOS.initvalue;
           }
@@ -153,7 +153,7 @@
               formDefineId: this.paramVOS.form,
               oid: this.dataStore[0].oid
             }, sourceDataMap), this.paramVOS.getdataurl, this.paramVOS.getdatamethod).then(res => {
-              this.form = res.data.obj;
+              this.form=res.data.obj;
               this.loading = false;
             }).catch(error => {
               this.$message.error(error);
@@ -168,9 +168,24 @@
       }
     },
     contextSave(){
-      debugger;
-      if(this.saveCallback){
-        this.saveCallback({});
+      const useDataType=this.paramVOS["useDataType"] || "form";//浣跨敤ui涓婁笅鏂囦腑鐨勫摢涓被鍨嬫暟鎹紝榛樿form銆傚�硷細form銆乼ree銆乼able銆乀reeTable
+      for(let key in this.$refs.uiViewRef.data){
+        if(this.$refs.uiViewRef.data[key].type== useDataType){
+          this.form=this.$refs.uiViewRef.data[key].data;
+          if (this.paramVOS.savebeforeevent) {
+            var urlobj = parseEventByUrl(this.paramVOS.savebeforeevent,null,null,'doAction');
+            import("../"+urlobj.jsPath+".js").then(module => {
+              module[urlobj.methodName]({
+                paramVOS: this.paramVOS,
+                dataStore: this.dataStore,
+                sourceData:this.sourceData
+              },this.formSaveHandle);
+            })
+          } else {
+            this.formSaveHandle();
+          }
+          return;
+        }
       }
     },
     formSave() {
@@ -204,7 +219,7 @@
         formValues.defaultValues.btmname = this.paramVOS.type;
       }
       let datas = {
-        formDefineId: this.paramVOS.form,
+        formDefineId: this.paramVOS.form || "",
         preEvent: this.paramVOS.preevent,
         afterEvent: this.paramVOS.afterevent,
         beforeServerEvent: this.paramVOS.beforeserverevent,
@@ -220,7 +235,7 @@
             message: "淇濆瓨鎴愬姛!"
           });
           if(that.saveCallback){
-            that.saveCallback(that.form);
+            that.saveCallback(that.type,that.form);
           }
           that.dialogClose();
         });
@@ -231,7 +246,7 @@
             message: "淇敼鎴愬姛!"
           });
           if(that.saveCallback){
-            that.saveCallback(that.form);
+            that.saveCallback(that.type,that.form);
           }
           that.dialogClose();
         });
diff --git a/Source/ProjectWeb/src/components/dynamic-components/dynamic-button.vue b/Source/ProjectWeb/src/components/dynamic-components/dynamic-button.vue
index 1341289..58dacf5 100644
--- a/Source/ProjectWeb/src/components/dynamic-components/dynamic-button.vue
+++ b/Source/ProjectWeb/src/components/dynamic-components/dynamic-button.vue
@@ -134,7 +134,7 @@
       const paramVOS = buttonitem.paramVOS;
       const DefineVO = this.componentVO.treeDefineVO || this.componentVO.tableDefineVO || this.componentVO.treeTableDefineVO || this.componentVO.formDefineVO;
       if (!paramVOS['title']) {
-        paramVOS['title'] = buttonitem.name + (DefineVO.title || this.componentVO.description || '');
+        paramVOS['title'] = buttonitem.name + (DefineVO.title || '');
       }
 
       if (!paramVOS['type']) {
@@ -148,14 +148,13 @@
 
       const that = this;
       //paramVOS.customBtn //寮圭獥榛樿鏈変繚瀛樻寜閽�,customBtn涓簍rue鏃跺唴瀹瑰睍绀鸿嚜瀹氫箟鎸夐挳
-      paramVOS.form = "editknowledgefolderall"
       doAction(buttonitem, {
         paramVOS: paramVOS,
         dataStore: this.dataStore || [],
         sourceData: this.sourceData || {}
-      }, function () {
+      }, function (actionType,data) {
         if (that.$parent.handleRefresh) {
-          that.$parent.handleRefresh()
+          that.$parent.handleRefresh(actionType,data)
         }
       });
     }
diff --git a/Source/ProjectWeb/src/components/dynamic-components/dynamic-form.vue b/Source/ProjectWeb/src/components/dynamic-components/dynamic-form.vue
index 91f77bb..3e6a6b5 100644
--- a/Source/ProjectWeb/src/components/dynamic-components/dynamic-form.vue
+++ b/Source/ProjectWeb/src/components/dynamic-components/dynamic-form.vue
@@ -8,6 +8,7 @@
                 :disabled="!inDialog"
                 :isEdit="canEdit"
                 :formData="form"
+                :initValue="paramVOS.initvalue"
                 @getFormData="getFormData">
     </basic-form>
   </div>
@@ -85,8 +86,14 @@
           this.$emit("setDataStore", {
             area: this.areasName,
             type:this.componentVO.uiComponentType,
-            btmType:this.componentVO.treeDefineVO.btmType,
+            btmType:this.currentDefineVO.btmType,
             dataStore:[newval]
+          });
+          this.$emit("setData", {
+            area: this.areasName,
+            type:this.componentVO.uiComponentType,
+            btmType:this.currentDefineVO.btmType,
+            data:newval
           });
         }
       }
@@ -145,10 +152,11 @@
       const sourceDataMapList = this.sourceDataMapParams;
 
       this.params = Object.assign({},formParams, sourceDataMapList);
-      console.log(this.params)
     },
     onLoad:function () {
-      debugger;
+      if (this.paramVOS.initvalue) {
+        this.form=this.paramVOS.initvalue;
+      }
       if (Object.keys(this.sourceData).length>0 && this.isShow) {
         this.loading = true;
         dataForm(this.params).then(res => {
diff --git a/Source/ProjectWeb/src/components/dynamic-components/dynamic-table.vue b/Source/ProjectWeb/src/components/dynamic-components/dynamic-table.vue
index 886e7f7..ce6fe70 100644
--- a/Source/ProjectWeb/src/components/dynamic-components/dynamic-table.vue
+++ b/Source/ProjectWeb/src/components/dynamic-components/dynamic-table.vue
@@ -170,6 +170,18 @@
         }
       }
     },
+    tableList:{
+      handler(newval) {
+        if(newval) {
+          this.$emit("setData", {
+            area: this.areasName,
+            type:this.componentVO.uiComponentType,
+            btmType:this.currentDefineVO.btmType,
+            data:newval
+          });
+        }
+      }
+    },
     'sourceData':{
       handler(newval) {
         if(newval) {
diff --git a/Source/ProjectWeb/src/components/dynamic-components/dynamic-tree.vue b/Source/ProjectWeb/src/components/dynamic-components/dynamic-tree.vue
index 191c5e3..3d80d3a 100644
--- a/Source/ProjectWeb/src/components/dynamic-components/dynamic-tree.vue
+++ b/Source/ProjectWeb/src/components/dynamic-components/dynamic-tree.vue
@@ -106,6 +106,18 @@
         }
       }
     },
+    data:{
+      handler(newval) {
+        if(newval) {
+          this.$emit("setData", {
+            area: this.areasName,
+            type:this.componentVO.uiComponentType,
+            btmType:this.componentVO.treeDefineVO.btmType,
+            data:newval
+          });
+        }
+      }
+    },
     sourceData:{
       handler(newval) {
         //婧愭暟鎹湁鍙樺寲鏃跺彉鏇村綋鍓嶅尯鍩熸暟鎹�
@@ -219,39 +231,57 @@
         parentOid = parentOid.split('@vcitreesep@')[1];
       }
       const parentBtmName = (node.level === 0) ? '' : node.data.attributes.btmname;
-      const params=this.params;
-      if(node.level === 0){
-        params.queryRoot= true;
-      }else {
+      const params = this.params;
+      if (node.level === 0) {
+        params.queryRoot = true;
+      } else {
         delete params.queryRoot;
       }
       getTree(parentOid, parentBtmName, params).then(res => {
         resolve(res.data.treeData)
+        this.$nextTick(()=>{
+          if (this.isRefresh) {
+            this.$refs.tree.setCurrentKey(this.currentClickNode.data.oid);
+            this.isRefresh=false;
+          }
+        })
+
       }).catch(error => {
         this.$message.error(error);
       })
     },
     checkNode(checkedNode, checkedData) {
       if (this.isMuti) {
-        this.checkDatas = checkedData.checkedNodes;
+        let checkDatas = [];
+        checkedData.checkedNodes.forEach(item=>{
+          checkDatas.push(item.attributes)
+        })
+        this.checkDatas=checkDatas;
       }
     },
     changeNode(data, node) {
       if (!this.isMuti) {
-        this.checkDatas = [data];
+        this.checkDatas = [data.attributes];
       }
     },
     clickNode(data, node) {
       this.currentClickNode = node;
     },
-    handleRefresh() {
-      if (!this.lazy) {
-        this.initData();
-      } else {
-        if (this.currentClickNode) {
-          let node = this.currentClickNode.parent;
-          node.loaded = false;
-          node.expand();
+    handleRefresh(type,data) {
+      //type:add\edit\delete
+      if(type=="delete"){
+        this.$refs.tree.remove(this.currentClickNode);
+        this.currentClickNode=null;
+      }else{
+        if (!this.lazy) {
+          this.initData();
+        } else {
+          if (this.currentClickNode) {
+            let node = this.currentClickNode.parent;
+            node.loaded = false;
+            node.expand();
+            this.isRefresh=true;
+          }
         }
       }
       this.checkDatas = [];
diff --git a/Source/ProjectWeb/src/components/dynamic-components/index.vue b/Source/ProjectWeb/src/components/dynamic-components/index.vue
index 5f62cb1..7660ba1 100644
--- a/Source/ProjectWeb/src/components/dynamic-components/index.vue
+++ b/Source/ProjectWeb/src/components/dynamic-components/index.vue
@@ -11,6 +11,7 @@
                  :dataStore="dataStore"
                  :areasName="areasName"
                  :paramVOS="paramVOS"
+                 @setData="setData"
                  @setDataStore="setDataStore"
                  :isShow="isShow">
 
@@ -27,6 +28,7 @@
                 :dataStore="dataStore"
                 :areasName="areasName"
                 :paramVOS="paramVOS"
+                @setData="setData"
                 @setDataStore="setDataStore"
                 :isShow="isShow">
 
@@ -43,6 +45,7 @@
                 :dataStore="dataStore"
                 :areasName="areasName"
                 :paramVOS="paramVOS"
+                @setData="setData"
                 @setDataStore="setDataStore"
                 :isShow="isShow">
   </dynamic-tree>
@@ -58,6 +61,7 @@
                   :dataStore="dataStore"
                   :areasName="areasName"
                   :paramVOS="paramVOS"
+                  @setData="setData"
                   @setDataStore="setDataStore"
                   :isShow="isShow">
 
@@ -129,6 +133,9 @@
     setDataStore(value) {
       this.$emit("setDataStore", value);
       this.dataStore = value.dataStore;
+    },
+    setData(value) {
+      this.$emit("setData", value);
     }
   }
 }
diff --git a/Source/ProjectWeb/src/views/base/UIContentArea.vue b/Source/ProjectWeb/src/views/base/UIContentArea.vue
index 4ae0be8..c9f0c92 100644
--- a/Source/ProjectWeb/src/views/base/UIContentArea.vue
+++ b/Source/ProjectWeb/src/views/base/UIContentArea.vue
@@ -32,6 +32,7 @@
                           :dataStore="dataStore"
                           :areasName="areasName"
                           :paramVOS="paramVOS"
+                          @setData="setData"
                           @setDataStore="setDataStore"
                           :isShow="activeName==(areasName+'-Tab-'+index)?true:false"></compoent-index>
         </div>
@@ -55,6 +56,7 @@
                             :dataStore="dataStore"
                             :areasName="areasName"
                             :paramVOS="paramVOS"
+                            @setData="setData"
                             @setDataStore="setDataStore"
                             :isShow="collapseActiveNames.indexOf(areasName+'-collapse-'+componentIndex)!=-1?true:false"></compoent-index>
           </div>
@@ -72,6 +74,7 @@
                         :dataStore="dataStore"
                         :areasName="areasName"
                         :paramVOS="paramVOS"
+                        @setData="setData"
                         @setDataStore="setDataStore"
                         :isShow="true"></compoent-index>
       </div>
@@ -239,6 +242,9 @@
     handleChange(val) {
       //console.log(val);
     },
+    setData(value) {
+      this.$emit("setData", value);
+    },
     setDataStore(value) {
       this.$emit("setDataStore", value);
       this.dataStore = value.dataStore;
diff --git a/Source/ProjectWeb/src/views/base/UIContentViewerInDialog.vue b/Source/ProjectWeb/src/views/base/UIContentViewerInDialog.vue
index c54bf61..0bd27af 100644
--- a/Source/ProjectWeb/src/views/base/UIContentViewerInDialog.vue
+++ b/Source/ProjectWeb/src/views/base/UIContentViewerInDialog.vue
@@ -12,7 +12,8 @@
                      :canEdit="canEdit"
                      :sourceData="sourceData"
                      :sourceBtmType="btmType"
-                     areas-name="northArea"
+                     areas-name="northAreaInDialog"
+                     @setData="setData"
                      @setDataStore="setDataStore">
       </UIContentArea>
     </el-header>
@@ -31,8 +32,9 @@
                        :canEdit="canEdit"
                        :sourceData="sourceData"
                        :sourceBtmType="btmType"
-                       areas-name="westArea"
+                       areas-name="westAreaInDialog"
                        cradStyle=""
+                       @setData="setData"
                        @setDataStore="setDataStore">
         </UIContentArea>
       </el-aside>
@@ -48,8 +50,9 @@
                          :canEdit="canEdit"
                          :sourceData="checkedData.westAreaInDialog.data[checkedData.westAreaInDialog.data.length-1]"
                          :sourceBtmType="checkedData.westAreaInDialog.DefineVOBtmType"
-                         areas-name="centerArea"
+                         areas-name="centerAreaInDialog"
                          cradStyle=""
+                         @setData="setData"
                          @setDataStore="setDataStore">
           </UIContentArea>
         </el-main>
@@ -65,8 +68,9 @@
                          :canEdit="canEdit"
                          :sourceData="checkedData.centerAreaInDialog.data[checkedData.centerAreaInDialog.data.length-1]"
                          :sourceBtmType="checkedData.centerAreaInDialog.DefineVOBtmType"
-                         areas-name="southArea"
+                         areas-name="southAreaInDialog"
                          cradStyle=""
+                         @setData="setData"
                          @setDataStore="setDataStore">
           </UIContentArea>
         </el-footer>
@@ -116,8 +120,8 @@
   },
   data() {
     return {
+      //鍚勫尯鍩熺殑閫変腑鏁版嵁
       checkedData:{
-        //鍚勫尯鍩熼�変腑鏁版嵁
         northAreaInDialog:{
           DefineVOBtmType:'',
           data:[{}]
@@ -133,6 +137,29 @@
         southAreaInDialog:{
           DefineVOBtmType:'',
           data:[{}]
+        }
+      },
+      //鍚勫尯鍩熸暟鎹�
+      data:{
+        northAreaInDialog:{
+          type:'',
+          btmType:'',
+          data:null
+        },
+        westAreaInDialog:{
+          type:'',
+          btmType:'',
+          data:null
+        },
+        centerAreaInDialog:{
+          type:'',
+          btmType:'',
+          data:null
+        },
+        southAreaInDialog:{
+          type:'',
+          btmType:'',
+          data:null
         }
       },
       uiDefineVO: {},
@@ -174,6 +201,11 @@
         this.centerHeight = '100%';
       }
     },
+    setData(value) {
+      this.data[value.area].btmType = value.btmType;
+      this.data[value.area].data = value.data;
+      this.data[value.area].type = value.type;
+    },
     setDataStore(value) {
       this.checkedData[value.area].DefineVOBtmType = value.btmType;
       this.checkedData[value.area].data = value.dataStore;

--
Gitblit v1.9.3