From 8835c9e1dec836d6d8159e78b9df12ad6402ad98 Mon Sep 17 00:00:00 2001
From: 田源 <lastanimals@163.com>
Date: 星期四, 14 十一月 2024 10:03:24 +0800
Subject: [PATCH] 修复bug 整合代码

---
 Source/plt-web/plt-web-ui/src/components/actions/base/AddEditDialog.vue |  201 +++++++++++++++++++++++++------------------------
 1 files changed, 102 insertions(+), 99 deletions(-)

diff --git a/Source/plt-web/plt-web-ui/src/components/actions/base/AddEditDialog.vue b/Source/plt-web/plt-web-ui/src/components/actions/base/AddEditDialog.vue
index 83a3836..7e62c19 100644
--- a/Source/plt-web/plt-web-ui/src/components/actions/base/AddEditDialog.vue
+++ b/Source/plt-web/plt-web-ui/src/components/actions/base/AddEditDialog.vue
@@ -1,44 +1,45 @@
 <template>
   <el-dialog v-dialogDrag
+             :append-to-body="true"
+             :close-on-click-modal="false"
+             :destroy-on-close="true"
+             :fullscreen="fullscreen"
              :title="title"
              :visible.sync="visible"
              :width="width"
-             :fullscreen="fullscreen"
-             :append-to-body="true"
-             top="0"
              class="avue-dialog"
-             :destroy-on-close="true"
-             :close-on-click-modal="false"
+             top="0"
              @close="dialogClose">
-    <basic-form ref="formRef" v-if="paramVOS.form"
-                :key="'dialog-'+paramVOS.form"
+    <basic-form v-if="paramVOS.form" :key="'dialog-'+paramVOS.form"
+                ref="formRef"
+                v-loading="loading"
+                :formData="form"
+                :formItems="formItems"
+                :initValue="paramVOS.initvalue"
+                :isEdit="true"
                 :span="span"
                 :style="fullscreen?'':'height:'+height"
-                :isEdit="true"
-                :formItems="formItems"
-                :formData="form"
-                :initValue="paramVOS.initvalue"
                 :uploadattachment="paramVOS.uploadattachment || false"
                 @getFormData="getFormData">
     </basic-form>
-    <ui-view ref="uiViewRef" v-else-if="paramVOS.context"
-             :key="'AddEditDialog-'+type"
-             :style="fullscreen?'':'height:'+height"
-             :btmType="paramVOS.type"
-             :context="paramVOS.context"
-             :inDialog="true"
-             :canEdit="true"
+    <ui-view v-else-if="paramVOS.context" :key="'AddEditDialog-'+type"
+             ref="uiViewRef"
              :actionType="type"
-             :sourceData="sourceData"
+             :btmType="paramVOS.type"
+             :canEdit="true"
+             :context="paramVOS.context"
              :dataStore="dataStore"
+             :inDialog="true"
              :paramVOS="paramVOS"
+             :sourceData="sourceData"
+             :style="fullscreen?'':'height:'+height"
              @getFormData="getFormData"
     ></ui-view>
     <div v-if="showSave" class="dialog-footer avue-dialog__footer">
-      <el-button type="primary" plain size="small" @click="formSave" v-if="paramVOS.form">淇� 瀛�</el-button>
-      <el-button type="primary" plain size="small" @click="contextSave" v-else>淇� 瀛�</el-button>
+      <el-button v-if="paramVOS.form" plain size="small" type="primary" @click="formSave">淇� 瀛�</el-button>
+      <el-button v-else plain size="small" type="primary" @click="contextSave">淇� 瀛�</el-button>
       <el-button size="small" @click="dialogClose">鍙� 娑�</el-button>
-      <el-button size="small" @click="resetValue" v-if="paramVOS.form">閲� 缃�</el-button>
+      <el-button v-if="paramVOS.form" size="small" @click="resetValue">閲� 缃�</el-button>
     </div>
   </el-dialog>
 </template>
@@ -46,13 +47,13 @@
 <script>
 import uiView from "@/views/base/UIContentViewerInDialog"
 import {parseEventByUrl} from "@/components/actions/BaseAction"
-import {getFormDefineById,dataForm} from "@/api/base/ui";
-import {addSave,editSave} from "@/api/base/actions"
+import {getFormDefineById, dataForm} from "@/api/base/ui";
+import {addSave, editSave} from "@/api/base/actions"
 import {validatenull} from "@/util/validate"
 
 export default {
   name: "AddEditDialog",
-  components:{uiView},
+  components: {uiView},
   props: {
     sourceData: {
       //鎵�灞炲尯鍩熺殑涓婁竴鍖哄煙閫変腑鏁版嵁
@@ -69,22 +70,23 @@
       default: {}
     }
   },
-  data(){
+  data() {
     return {
-      type:"add",
-      visible:false,
-      showSave:this.paramVOS.customBtn || true,
-      span:12,
-      formItems:[],
-      form:{},
-      btmDefaultKeys : ['oid', 'id', 'name', 'description', 'revisionoid', 'nameoid', 'btmname', 'lastr', 'firstr', 'lastv', 'firstv', 'creator', 'createtime', 'lastModifier', 'lastmodifytime', 'revisionrule', 'revisionseq', 'revisionvalue', 'versionrule', 'versionseq', 'versionvalue', 'lcstatus', 'ts', 'owner', 'checkinby', 'checkintime', 'checkoutby', 'checkouttime', 'copyfromversion', 'secretgrade'],
-      linkDefaultKeys :['oid','creator','createtime','lastmodifier','lastmodifytime','f_oid','foid','f_revisionoid','frevisionoid','f_nameoid','fnameoid','f_btmname','fbtmname','t_oid','toid','t_revisionoid','trevisionoid','t_nameoid','tnameoid','t_btmname','tbtmname','ts']
+      loading: false,
+      type: "add",
+      visible: false,
+      showSave: this.paramVOS.customBtn || true,
+      span: 12,
+      formItems: [],
+      form: {},
+      btmDefaultKeys: ['oid', 'id', 'name', 'description', 'revisionoid', 'nameoid', 'btmname', 'lastr', 'firstr', 'lastv', 'firstv', 'creator', 'createtime', 'lastModifier', 'lastmodifytime', 'revisionrule', 'revisionseq', 'revisionvalue', 'versionrule', 'versionseq', 'versionvalue', 'lcstatus', 'ts', 'owner', 'checkinby', 'checkintime', 'checkoutby', 'checkouttime', 'copyfromversion', 'secretgrade'],
+      linkDefaultKeys: ['oid', 'creator', 'createtime', 'lastmodifier', 'lastmodifytime', 'f_oid', 'foid', 'f_revisionoid', 'frevisionoid', 'f_nameoid', 'fnameoid', 'f_btmname', 'fbtmname', 't_oid', 'toid', 't_revisionoid', 'trevisionoid', 't_nameoid', 'tnameoid', 't_btmname', 'tbtmname', 'ts']
 
     }
   },
-  computed:{
-    title(){
-      return this.paramVOS.title || (this.type=='add'?'娣诲姞':'淇敼')
+  computed: {
+    title() {
+      return this.paramVOS.title || (this.type == 'add' ? '娣诲姞' : '淇敼')
     },
     width() {
       if (!validatenull(this.paramVOS.width)) {
@@ -97,7 +99,7 @@
         return "60%";
       }
     },
-    height(){
+    height() {
       if (!validatenull(this.paramVOS.height)) {
         if (this.paramVOS.height.includes("px") || this.paramVOS.height.includes("%")) {
           return this.paramVOS.height;
@@ -108,10 +110,10 @@
         return "auto"
       }
     },
-    fullscreen(){
-      if(this.paramVOS.width || this.paramVOS.height){
+    fullscreen() {
+      if (this.paramVOS.width || this.paramVOS.height) {
         return false;
-      }else if(this.paramVOS.form){
+      } else if (this.paramVOS.form) {
         return false;
       }
       return true;
@@ -137,13 +139,13 @@
     onLoad: function () {
       if (Object.keys(this.sourceData).length > 0) {
         this.loading = true;
-        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;
+        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;
+            this.form = this.paramVOS.initvalue;
           }
-          if(this.type=="edit") {
+          if (this.type == "edit") {
             //鍔犺浇琛ㄥ崟鏁版嵁
             let sourceDataMap = {};
             for (let i in this.sourceData) {
@@ -156,13 +158,14 @@
               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.data;
               this.loading = false;
             }).catch(error => {
               this.$message.error(error);
               this.loading = false;
             })
           }
+          this.loading = false;
         }).catch(error => {
           this.$message.error(error);
           this.loading = false;
@@ -170,27 +173,27 @@
 
       }
     },
-    contextSave(){
-      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;
-          this.formDefineId=this.$refs.uiViewRef.data[key].DefineVO.id;
+    contextSave() {
+      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;
+          this.formDefineId = this.$refs.uiViewRef.data[key].DefineVO.id;
           if (this.paramVOS.savebeforeevent) {
-            var urlobj = parseEventByUrl(this.paramVOS.savebeforeevent,null,null,'doAction');
-            if(urlobj.params){
-              Object.assign(this.paramVOS,urlobj.params);
+            var urlobj = parseEventByUrl(this.paramVOS.savebeforeevent, null, null, 'doAction');
+            if (urlobj.params) {
+              Object.assign(this.paramVOS, urlobj.params);
             }
-            if(validatenull(urlobj.jsPath)){
+            if (validatenull(urlobj.jsPath)) {
               this.saveBforeHandle(this.paramVOS);
-            }else{
+            } else {
               try {
                 import(`./${urlobj.jsPath}.js`).then(module => {
                   module[urlobj.methodName]({
                     paramVOS: this.paramVOS,
                     dataStore: this.dataStore,
-                    sourceData:this.sourceData
-                  },this.formSaveHandle);
+                    sourceData: this.sourceData
+                  }, this.formSaveHandle);
                 })
               } catch (error) {
                 this.$message.error('鏈壘鍒颁繚瀛樺墠缃簨浠舵墽琛宩s');
@@ -204,18 +207,18 @@
       }
     },
     formSave() {
-      let that=this;
+      let that = this;
       this.$refs.formRef.validate((valid, done) => {
         if (valid) {
-          this.formDefineId=this.paramVOS.form;
+          this.formDefineId = this.paramVOS.form;
           if (this.paramVOS.savebeforeevent) {
-            var urlobj = parseEventByUrl(this.paramVOS.savebeforeevent,null,null,'doAction');
-            if(urlobj.params){
-              Object.assign(this.paramVOS,urlobj.params);
+            var urlobj = parseEventByUrl(this.paramVOS.savebeforeevent, null, null, 'doAction');
+            if (urlobj.params) {
+              Object.assign(this.paramVOS, urlobj.params);
             }
-            if(validatenull(urlobj.jsPath)){
+            if (validatenull(urlobj.jsPath)) {
               this.saveBforeHandle(this.paramVOS);
-            }else{
+            } else {
               try {
                 import(`./${urlobj.jsPath}.js`).then(module => {
                   module[urlobj.methodName]({
@@ -236,11 +239,11 @@
         }
       });
     },
-    formSaveHandle(){
-      let that=this;
+    formSaveHandle() {
+      let that = this;
       let formValues = this.getValues();
-      if(formValues.otherValue.releaseFileOids){
-        formValues.otherValue.releaseFileOids=formValues.otherValue.releaseFileOids.split(',');
+      if (formValues.otherValue.releaseFileOids) {
+        formValues.otherValue.releaseFileOids = formValues.otherValue.releaseFileOids.split(',');
       }
       if (!formValues.defaultValues.btmname) {
         formValues.defaultValues.btmname = this.paramVOS.type;
@@ -251,33 +254,33 @@
         afterEvent: this.paramVOS.afterevent,
         beforeServerEvent: this.paramVOS.beforeserverevent,
         afterServerEvent: this.paramVOS.afterserverevent,
-        releaseFileOids: formValues.otherValue.releaseFileOids||[],
+        releaseFileOids: formValues.otherValue.releaseFileOids || [],
         data: formValues.otherValue
       }
       Object.assign(datas, formValues.defaultValues);
-      if(that.type=="add"){
-        addSave(datas,that.paramVOS.url,that.paramVOS.method).then(() => {
+      if (that.type == "add") {
+        addSave(datas, that.paramVOS.url, that.paramVOS.method).then(() => {
           that.$message({
             type: "success",
-            message: that.paramVOS.successmsg||"淇濆瓨鎴愬姛!"
+            message: that.paramVOS.successmsg || "淇濆瓨鎴愬姛!"
           });
-          if(that.saveCallback){
-            that.saveCallback(that.type,that.form);
+          if (that.saveCallback) {
+            that.saveCallback(that.type, that.form);
           }
           if (this.paramVOS.saveafterevent) {
-            let urlobj = parseEventByUrl(this.paramVOS.saveafterevent,null,null,'doAction');
-            if(urlobj.params){
-              Object.assign(this.paramVOS,urlobj.params);
+            let urlobj = parseEventByUrl(this.paramVOS.saveafterevent, null, null, 'doAction');
+            if (urlobj.params) {
+              Object.assign(this.paramVOS, urlobj.params);
             }
-            if(validatenull(urlobj.jsPath)){
+            if (validatenull(urlobj.jsPath)) {
               this.saveAfterHandle(this.paramVOS);
-            }else{
+            } else {
               try {
                 import(`./${urlobj.jsPath}.js`).then(module => {
                   module[urlobj.methodName]({
                     paramVOS: this.paramVOS,
                     dataStore: this.dataStore,
-                    sourceData:this.sourceData
+                    sourceData: this.sourceData
                   });
                 })
               } catch (error) {
@@ -287,29 +290,29 @@
           }
           that.dialogClose();
         });
-      }else{
-        editSave(datas,that.paramVOS.url,that.paramVOS.method).then(() => {
+      } else {
+        editSave(datas, that.paramVOS.url, that.paramVOS.method).then(() => {
           that.$message({
             type: "success",
-            message: that.paramVOS.successmsg||"淇敼鎴愬姛!"
+            message: that.paramVOS.successmsg || "淇敼鎴愬姛!"
           });
-          if(that.saveCallback){
-            that.saveCallback(that.type,that.form);
+          if (that.saveCallback) {
+            that.saveCallback(that.type, that.form);
           }
           if (this.paramVOS.saveafterevent) {
-            let urlobj = parseEventByUrl(this.paramVOS.saveafterevent,null,null,'doAction');
-            if(urlobj.params){
-              Object.assign(this.paramVOS,urlobj.params);
+            let urlobj = parseEventByUrl(this.paramVOS.saveafterevent, null, null, 'doAction');
+            if (urlobj.params) {
+              Object.assign(this.paramVOS, urlobj.params);
             }
-            if(validatenull(urlobj.jsPath)){
+            if (validatenull(urlobj.jsPath)) {
               this.saveAfterHandle(this.paramVOS);
-            }else{
+            } else {
               try {
                 import(`./${urlobj.jsPath}.js`).then(module => {
                   module[urlobj.methodName]({
                     paramVOS: this.paramVOS,
                     dataStore: this.dataStore,
-                    sourceData:this.sourceData
+                    sourceData: this.sourceData
                   });
                 })
               } catch (error) {
@@ -321,7 +324,7 @@
         });
       }
     },
-    getValues(){
+    getValues() {
       let defaultValues = {}, otherValue = {};
       for (var key in this.form) {
         if (this.btmDefaultKeys.indexOf(key.toLowerCase()) > -1) {
@@ -331,8 +334,8 @@
         }
       }
       return {
-        defaultValues:defaultValues,
-        otherValue:otherValue
+        defaultValues: defaultValues,
+        otherValue: otherValue
       }
     },
     resetValue() {
@@ -344,11 +347,11 @@
       this.form = form;
     },
     //淇濆瓨鍓嶇疆浜嬩欢
-    saveBforeHandle(params){
+    saveBforeHandle(params) {
       this.$message.info('鎵ц淇濆瓨鍓嶇疆浜嬩欢');
     },
     //淇濆瓨鍚庣疆浜嬩欢
-    saveAfterHandle(params){
+    saveAfterHandle(params) {
       this.$message.info('淇濆瓨鍚庣疆浜嬩欢鎵ц');
     },
   }

--
Gitblit v1.9.3