From a94b8b8d9022a7e279337aeb0961fbafb885128c Mon Sep 17 00:00:00 2001
From: 田源 <lastanimals@163.com>
Date: 星期五, 26 四月 2024 15:47:04 +0800
Subject: [PATCH] 整合富文本和上传文件到表单组件

---
 Source/ProjectWeb/src/components/actions/AddEditDialog.vue |  126 +++++++++++++++++++++++++++++++++---------
 1 files changed, 99 insertions(+), 27 deletions(-)

diff --git a/Source/ProjectWeb/src/components/actions/AddEditDialog.vue b/Source/ProjectWeb/src/components/actions/AddEditDialog.vue
index cebbd0c..54343ca 100644
--- a/Source/ProjectWeb/src/components/actions/AddEditDialog.vue
+++ b/Source/ProjectWeb/src/components/actions/AddEditDialog.vue
@@ -3,24 +3,37 @@
              :title="paramVOS.title"
              :visible.sync="visible"
              :width="width"
-             :style="'height:'+height || 'auto'"
+             :fullscreen="paramVOS.content || paramVOS.context"
              :append-to-body="true"
              class="avue-dialog avue-dialog--top"
+             :destroy-on-close="true"
              @close="dialogClose">
-    dialog
-    <basic-form ref="formRef" v-if="paramVOS.form"></basic-form>
-    <ui-view ref="uiViewRef" v-else-if="paramVOS.content || paramVOS.context"></ui-view>
-    <div v-if="paramVOS.form" class="avue-dialog__footer">
-      <el-button type="primary" @click="saveHandler">淇� 瀛�</el-button>
-      <el-button @click="escHandler">鍙� 娑�</el-button>
-      <el-button @click="resetValue">閲� 缃�</el-button>
+    <basic-form ref="formRef" v-if="paramVOS.form"
+                :span="span"
+                :formItems="formItems"
+                :formData="form">
+    </basic-form>
+    <ui-view ref="uiViewRef" v-else-if="paramVOS.content || paramVOS.context"
+             :btmType="paramVOS.type"
+             :context="paramVOS.context"
+             :inDialog="true"
+             :key="'AddEditDialog-'+type"
+             :sourceData="sourceData"
+             :dataStore="dataStore"
+             :paramVOS="paramVOS"
+    ></ui-view>
+    <div slot="footer" class="dialog-footer avue-dialog__footer">
+      <el-button type="primary" plain size="small" @click="saveHandler">淇� 瀛�</el-button>
+      <el-button size="small" @click="dialogClose">鍙� 娑�</el-button>
+      <el-button size="small" @click="resetValue">閲� 缃�</el-button>
     </div>
   </el-dialog>
 </template>
 
 <script>
 import uiView from "@/views/base/UIContentViewerInDialog"
-import {dataForm} from "@/api/base/ui";
+import {getFormDefineById,dataForm} from "@/api/base/ui";
+import {addSave,editSave} from "@/api/base/actions"
 
 export default {
   name: "AddEditDialog",
@@ -42,52 +55,111 @@
     },
     width: {
       type: String,
-      default:'70%'
-    },
-    height: {
-      type: String,
-      default:'500px'
-    },
+      default:'60%'
+    }
   },
   data(){
     return {
-      visible:false
+      type:"add",
+      visible:false,
+      span:12,
+      formItems:[],
+      form:{}
     }
   },
   computed:{
+    title(){
+      return this.paramVOS.title || (this.type=='add'?'娣诲姞':'淇敼')
+    }
   },
   created() {
-
+  },
+  watch: {
+    sourceData: {
+      handler(val) {
+        if (this.paramVOS.form) {
+          this.onLoad();
+        }
+      },
+      deep: true,
+      immediate: true
+    },
   },
   methods: {
     dialogClose() {
       this.visible = false;
     },
     onLoad: function () {
-      if (Object.keys(this.sourceData).length > 0 && this.isShow) {
+      if (Object.keys(this.sourceData).length > 0) {
         this.loading = true;
-        dataForm(this.params).then(res => {
-          this.form = res.data.obj;
-          this.loading = false;
+        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;
+          }
+          if(this.type=="edit"){
+            //鍔犺浇琛ㄥ崟鏁版嵁
+            dataForm(this.params,this.paramVOS.getdataurl,this.paramVOS.getdatamethod).then(res => {
+              this.form = res.data.obj;
+              this.loading = false;
+            }).catch(error => {
+              this.$message.error(error);
+              this.loading = false;
+            });
+          }
         }).catch(error => {
           this.$message.error(error);
           this.loading = false;
         });
+
       }
     },
     saveHandler() {
-      this.dialogClose();
-    },
-    escHandler() {
-      this.dialogClose();
+      this.$refs.formRef.validate((valid, done) => {
+        if (valid) {
+          if(this.type=="add"){
+            addSave(this.form,this.paramVOS.url,this.paramVOS.method).then(() => {
+              this.$message({
+                type: "success",
+                message: "淇濆瓨鎴愬姛!"
+              });
+              if(this.saveCallback){
+                this.saveCallback();
+              }
+              this.dialogClose();
+            }).error((e) => {
+              this.$message.error(e||"淇濆瓨澶辫触")
+            });
+          }else{
+            editSave(this.form,this.paramVOS.url,this.paramVOS.method).then(() => {
+              this.$message({
+                type: "success",
+                message: "淇敼鎴愬姛!"
+              });
+              if(this.saveCallback){
+                this.saveCallback();
+              }
+              this.dialogClose();
+            }).error((e) => {
+              this.$message.error(e||"淇敼澶辫触")
+            });
+          }
+        } else {
+
+        }
+      });
     },
     resetValue() {
-      this.$refs.formRef.resetValue();
+      this.$refs.formRef.resetFields();
     }
   }
 }
 </script>
 
 <style scoped>
-
+.avue-dialog__footer{
+  margin-bottom: 20px;
+}
 </style>

--
Gitblit v1.9.3