From 51636e9cd814bddba7a9b4ff21b5bc94e95fb6cb Mon Sep 17 00:00:00 2001
From: wangting <675591594@qq.com>
Date: 星期二, 14 五月 2024 09:21:36 +0800
Subject: [PATCH] 配置文档

---
 Source/ProjectWeb/src/components/dynamic-components/dynamic-form.vue |  356 +++++++++++++++++++++-------------------------------------
 1 files changed, 129 insertions(+), 227 deletions(-)

diff --git a/Source/ProjectWeb/src/components/dynamic-components/dynamic-form.vue b/Source/ProjectWeb/src/components/dynamic-components/dynamic-form.vue
index 9641b5f..e08c6b3 100644
--- a/Source/ProjectWeb/src/components/dynamic-components/dynamic-form.vue
+++ b/Source/ProjectWeb/src/components/dynamic-components/dynamic-form.vue
@@ -1,52 +1,34 @@
 <template>
-  <div class="UI-dynamic" :id="'UI-dynamic-'+areasName+componentVO.oid">
-    <avue-form v-model="form" :option="option">
-      <template v-for="item in slotData" :slot="item.prop + 'Label'">
-        <span>
-          <span>{{ item.label }} </span>
-          <el-tooltip
-            v-if="item.keyAttr"
-            class="item"
-            content="璇ュ睘鎬т负鍏抽敭灞炴��"
-            effect="dark"
-            placement="top-start"
-          >
-            <i class="el-icon-star-on" style="font-size: 17px !important; color: red;vertical-align: baseline;"></i>
-          </el-tooltip>
-        </span>
-      </template>
-      <template slot="menuForm">
-        <dynamic-button type="form" :butttonList="componentVO.buttons" @buttonClick="buttonClick"></dynamic-button>
-      </template>
-
-      <template v-for="item in slotData" :slot="item.prop + ''">
-        <vciWebRefer v-if="item.type == 'refer'"
-                     :key="item.prop"
-                     referType="master"
-                     :data-key="item.prop"
-                     :disabled="item.disabled || false"
-                     :display="item.display || true"
-                     :referConfig="item.referConfig || {}"
-                     :reloadFormKey="(item.referConfig.useFormKey && item.referConfig.formValues && item.referConfig.formValues[item.referConfig.useFormKey]) || ''"
-                     :text="item.referConfig.showProp"
-                     :value="item.prop || item.value"
-                     @setReferValue="setReferValue"
-                     :ref="'referFormRef'+item.prop">
-
-        </vciWebRefer>
-      </template>
-    </avue-form>
+  <div :id="'UI-dynamic-'+areasName+componentVO.oid" class="UI-dynamic">
+    <dynamic-button v-if="componentVO && componentVO.buttons" :key="areasName+'buttons-'+componentVO.oid"
+                    :componentVO="componentVO" :butttonList="componentVO.buttons" :dataStore="[form]" :sourceData="sourceData"
+                    @afterMethod="handleRefresh" type="form"></dynamic-button>
+    <basic-form :key="areasName+'basicForm-'+componentVO.oid"
+                :span="this.componentVO.formDefineVO.columnOneRow?(24/this.componentVO.formDefineVO.columnOneRow) : 12"
+                :formItems="this.componentVO.formDefineVO && this.componentVO.formDefineVO.items"
+                :disabled="!inDialog"
+                :isEdit="canEdit"
+                :formData="form"
+                :initValue="paramVOS.initvalue"
+                @getFormData="getFormData">
+    </basic-form>
   </div>
 </template>
 
 <script>
-import vciWebRefer from '@/components/refer/vciWebRefer'
-import VciWebRefer from "@/components/refer/vciWebRefer";
-import {verifyNull, verifySlash} from "@/util/validate";
+import {dataForm} from "@/api/base/ui";
+
 export default {
   name: "dynamic-form",
-  components: {VciWebRefer},
   props: {
+    //ui涓婁笅鏂囩殑涓氬姟绫诲瀷锛堟垨閾炬帴绫诲瀷锛�
+    uiBtmType: {
+      type: String
+    },
+    //ui涓婁笅鏂�
+    uiContext:{
+      type: String
+    },
     componentVO: {
       type: Object,
       default: {}
@@ -55,18 +37,31 @@
       type: Boolean,
       default: false
     },
+    canEdit:{
+      //鍐呭鏄惁鍙紪杈�
+      type:Boolean,
+      default:false
+    },
+    actionType:{
+      //鎸夐挳鎿嶄綔绫诲瀷
+      default:""
+    },
     areasName: {
       type: String,
       default: ''
     },
-    sourceData:{
+    sourceData: {
       //鎵�灞炲尯鍩熺殑涓婁竴鍖哄煙閫変腑鏁版嵁
-      type:Object,
+      type: Object,
       default: {}
     },
-    dataStore:{
+    //涓婁竴鍖哄煙涓氬姟绫诲瀷
+    sourceBtmType:{
+      type: String
+    },
+    dataStore: {
       //寮圭獥鏃舵寜閽墍灞炲尯鍩熼�変腑鏁版嵁
-      type:Array,
+      type: Array,
       default: []
     },
     paramVOS: {
@@ -81,207 +76,114 @@
   },
   data() {
     return {
-      form: {}
+      form: {},
+      params:{},
+      sourceDataMapParams:{},
+      currentDefineVO:this.componentVO.formDefineVO,
     }
   },
   mounted() {
   },
-  computed: {
-    option() {
-      return {
-        submitBtn: false,
-        emptyBtn: false,
-        height: 300,
-        column: this.getColumnData()
-      }
-    },
-    slotData() {
-      return this.getColumnData()
-    }
-  },
-  watch:{
-    slotData:{
-      handler(newV){
-       this.getDictList(newV)
-      },
-      immediate: true,
-    },
-    form: {
-      handler(val) {
-        if (val) {
-          if (Array.isArray(val)) { // 妫�鏌� val 鏄惁涓烘暟缁�
-            for (let code of val) {
-              if (
-                code.type == "refer" &&
-                code.referConfig &&
-                code.referConfig.useFormKey
-              ) {
-                code.referConfig.formValues = val;
-                // code.referConfigTemp.options = code.referConfig;
-              }
-            }
-          } else if (typeof val === 'object') { // 妫�鏌� val 鏄惁涓哄璞�
-            // 杩唬瀵硅薄鐨勯�昏緫
-          }
-          this.$emit("input", val);
+  watch: {
+    form:{
+      handler(newval) {
+        if(newval) {
+
         }
       },
       deep: true,
-      immediate: true,
+      immediate: true
     },
-    sourceData:{
+    sourceData: {
       handler(newval) {
         //婧愭暟鎹湁鍙樺寲鏃跺彉鏇村綋鍓嶅尯鍩熸暟鎹�
-        console.log(this.areasName);
-        console.log(newval);
-      }
+        this.sourceDataMapParams=this.sourceDataMap();
+        this.getParams();
+        this.handleRefresh();
+      },
+      deep: true,
+      immediate: true
     }
   },
+  created() {
+    this.getParams();
+  },
   methods: {
-    //杞寲鏁版嵁
-    formColumn(formList) {
-        return formList.map(item => {
-          const typeValue = item.type === 'text' ? 'input' : item.type === 'combox' ? 'select' : item.type;
+    sourceDataMap: function () {
+      const sourceDataMap = {};
+      if (Object.keys(this.sourceData).length > 0) {
+        if (this.sourceData.oid) {
+          if (this.sourceData.oid.indexOf('@vcitreesep@') > -1) {
+            this.sourceData.oid = this.sourceData.oid.split('@vcitreesep@')[1];
+          }
+          sourceDataMap.sourceBtmName = this.sourceBtmType;
+          ;
+          sourceDataMap.sourceOid = this.sourceData.oid;
+        }
+        for (let i in this.sourceData) {
+          const item = this.sourceData[i]
+          if (item && item.constructor === Object) continue;
+          if (i == 'type' || i == 'context' || i == 'content') continue;
+          sourceDataMap['sourceData["' + i + '"]'] = item
+        }
+      }
 
-          const focusFunc = item.type === 'refer' ? (i) => {
+      if (Object.keys(this.paramVOS).length > 0) {
+        for (let j in this.paramVOS) {
+          if (this.paramVOS[j] && this.paramVOS[j].constructor === Object) continue;
+          if (j == 'type' || j == 'context' || j == 'content' || j == "getdataurl" || j == "getdatamethod" || j == "url" || j == "method" || j == "uploadfileurl" || j == "title") continue;
+          sourceDataMap['sourceData["' + j + '"]'] = this.paramVOS[j]
+        }
+      }
+      return sourceDataMap;
+    },
+    getParams: function () {
+      const formParams = {
+        btmname: this.currentDefineVO.btmType,
+        btmType: this.currentDefineVO.btmType,
+        formDefineId: this.currentDefineVO.id,
+        oid: this.currentDefineVO.oid
+      };
+      if (this.dataStore[0] && this.dataStore[0].oid) {
+        formParams.oid = this.dataStore[0].oid;
+      }
+      const sourceDataMapList = this.sourceDataMapParams;
 
-          } : undefined;
-
-
-          return {
-            label: item.text,
-            prop: item.field,
-            type: typeValue,
-            labelWidth:item.text.length >= 6 ? 115 : 90,
-            value: item.defaultValue,
-            dicData: item.type === 'combox' ? item.dicData : item.dicUrl,
-            readonly: item.readOnly,
-            disabled: item.disabled,
-            display: !item.hidden,
-            labelSuffix: item.suffix,
-            suffixIcon: item.prefix,
-            placeholder: item.placeholder,
-            clearable: item.clearable,
-            tip: item.tooltips,
-            keyAttr: item.keyAttr,
-            focus:focusFunc,
-            referConfig:item.referConfig,
-            rules: [{
-              required: item.required,
-              message: `璇疯緭鍏�${item.text}!`,
-              trigger: "blur"
-            }]
-          };
+      this.params = Object.assign({}, formParams, sourceDataMapList);
+    },
+    onLoad: function () {
+      if (this.paramVOS.initvalue) {
+        this.form = this.paramVOS.initvalue;
+      }
+      if (Object.keys(this.sourceData).length > 0 && this.isShow && this.actionType != "add") {
+        this.loading = true;
+        dataForm(this.params, this.paramVOS.getdataurl, this.paramVOS.getdatamethod).then(res => {
+          this.form = res.data.obj.data;
+          this.loading = false;
+          this.$emit("setDataStore", {
+            area: this.areasName,
+            type: this.componentVO.uiComponentType,
+            btmType: this.currentDefineVO.btmType,
+            dataStore: [this.form]
+          });
+          this.$emit("setData", {
+            area: this.areasName,
+            type: this.componentVO.uiComponentType,
+            currentDefineVO: this.currentDefineVO,
+            data: this.form
+          });
+        }).catch(error => {
+          this.loading = false;
         });
-    },
-
-    //鏁版嵁鍒ょ┖
-    getColumnData() {
-      if (this.componentVO && this.componentVO.formDefineVO && this.componentVO.formDefineVO.items && this.componentVO.formDefineVO.items.length > 0) {
-        return this.formColumn(this.componentVO.formDefineVO.items)
-      } else {
-        return null;
       }
     },
-
-    buttonClick(item) {
-      console.log(item.id)
+    handleRefresh() {
+      this.form = {}
+      this.onLoad();
     },
-    async getDictList(val) {
-      for (let code of val) {
-        if (!verifyNull(code.dictData) && code.type == "select") {
-          if (
-            verifySlash(code.dictCode) &&
-            Object.prototype.hasOwnProperty.call(code, "dictCode")
-          ) {
-            const res = await getlistByCode(code.dictCode);
-            if (res.success) {
-              const dic = res.data;
-              code.dictData = dic.map((d) => {
-                return {
-                  label: d.name,
-                  key: d.code,
-                  value: d.id,
-                };
-              });
-            }
-          } else {
-            this.getDicts(code.dictCode)
-              .then((res) => {
-                if (res.success) {
-                  const dic = res.obj.datas;
-                  code.dictData = dic.map((d) => {
-                    return {
-                      label: d.name,
-                      key: d.code,
-                      value: d.code,
-                    };
-                  });
-                }
-              })
-              .catch(() => {
-                this.$message.error(` 鏁版嵁瀛楀吀${code.dictCode}閿欒`);
-              });
-          }
-        }
-        if (code.type == "refer") {
-          if (code.referConfig && code.referConfig.useFormKey) {
-            if (verifyNull(code.referConfig.formValuesKey)) {
-              code.referConfig.formValuesKey = "form";
-            }
-            code.referConfig.formValues = this[code.referConfig.formValuesKey];
-          }
-          code.referConfigTemp = {
-            title: code.label,
-            showProp:
-              code.showProp || code.referConfig.showProp || code.prop + "Name",
-            prop: code.prop,
-            propMap: code.propMap || {},
-            placeholder: code.placeholder
-              ? code.placeholder
-              : ` 璇烽�夋嫨` + code.label,
-            options: code.referConfig,
-          };
-        }
-      }
-      this.formTemplateData = val;
-    },
-    setReferValue(data) {
-      if (data && data.prop) {
-        this.form[data.prop] = data.value || "";
-        this.form[data.showProp] = data.text || "";
-        if (data.propMap) {
-          //璇存槑闇�瑕佹槧灏�
-          for (let key in data.propMap) {
-            let mapFields = data.propMap[key].split(",");
-            let value = [];
-            data.rawData.forEach((_item) => {
-              var temp;
-              if (!_item.extendData) {
-                _item.extendData = {};
-              }
-              if (mapFields.length == 1) {
-                var mapField = mapFields[0];
-                temp = _item[mapField] || _item["extendData"][mapField];
-              } else {
-                //鏈夊涓�
-                var mutiTemp = [];
-                mapFields.forEach((_itemField) => {
-                  mutiTemp.push(
-                    _item[_itemField] || _item["extendData"][_itemField]
-                  );
-                });
-                temp = mutiTemp.join(" ");
-              }
-              if (temp != null && temp != "") {
-                value.push(temp);
-              }
-            });
-            this.form[key] = value.join(",");
-          }
-        }
-      }
-    },
+    getFormData(form) {
+      this.form = form;
+    }
   }
 }
 </script>

--
Gitblit v1.9.3