ludc
2023-11-14 2be0ef348c881796d66e112463f62be5ef374527
Source/UBCS-WEB/src/components/FormTemplate/FormTemplate.vue
@@ -26,13 +26,14 @@
      </template>
      <template :slot="item.prop + ''" v-for="item in slotColumnList">
        <vciWebRefer
          :key="item.prop" :data-key="item.prop"
          :key="item.dataKey" :data-key="item.dataKey"
          v-if="item.type == 'refer'"
          :referConfig="item.referConfig || {}"
          :value="form[item.referConfig.field] || item.value"
          :text="form[item.referConfig.showField]"
          :disabled="item.disabled"
          :display="item.display"
          :reloadData="item.referConfig.reloadData || false"
          @setReferValue="setReferValue"
        ></vciWebRefer>
      </template>
@@ -42,7 +43,7 @@
<script>
import { getFormDetail } from "@/api/formTemplate";
import { getDictionary } from "../../api/system/dict";
import { getEnumDictionary } from "../../api/system/dict";
import vciWebRefer from "../refer/vciWebRefer.vue";
export default {
  name: "FormTemplate",
@@ -61,6 +62,10 @@
      type: String,
      default: "",
    },
    LoadingStatus:{
      type: String,
      default : "code"
    },
    // 列表数据oid
    rowOid: {
      type: String,
@@ -69,7 +74,7 @@
    // 表单类型(add, edit, detail)
    type: {
      type: String,
      default: "add",
      default: "",
    },
    // 自定义表单类型
    selfColumnType: {
@@ -96,6 +101,9 @@
  },
  data() {
    return {
      add:'',
      codeattrsecValue:'',
      ValidataValue:false,
      eventFlag:{},
      TreeValueForm:'',
      updateIndex: 0,
@@ -127,8 +135,12 @@
  mounted() {
    this.handleResize();
  },
  updated() {
  },
  created() {
    if (this.LoadingStatus === 'code') {
      this.loading = false;
    }
  },
  computed: {
    localTrendsSpan() {
@@ -148,6 +160,7 @@
      immediate: true,
      handler(newV) {
        this.$emit("getFormData", newV);
        // console.log("getFormData", newV)
      },
    },
    TreeValue:{
@@ -158,7 +171,7 @@
      },
      deep:true,
      immediate:true
    }
    },
  },
  methods: {
    // 渲染表单模板
@@ -177,7 +190,11 @@
      let dictKeys = [];
      let slotColumnList = [];
      formItemList.forEach((formItem) => {
        // console.log('formItem',formItem)
        formItem = this.resetFormConfig(formItem);
        // if(formItem.type === "datetime"){
        //   return;
        // }
        if (formItem.type === "line") {
          group.push({
            label: formItem.text,
@@ -217,7 +234,16 @@
          formItem.fieldMap[fieldMapKey]='id'
          formItem.fieldMap[formItem.field+'id']='id'
        }
        let columnItem = {
          change:(val)=>{
            if(val.column.field === "drawingno"){
              this.codeattrsecValue=val.value;
            }
            // console.log(this.codeattrsecValue)
          },
          dataKey:formItem.dataKey || formItem.field,
          label: formItem.text,
          labelslot: true,
          prop: this.$utilFunc.isValuableObj(formItem.referConfig)
@@ -231,11 +257,12 @@
          append: this.preOrSufFixShow("text", formItem.suffix),
          prefixIcon: this.preOrSufFixShow("icon", formItem.prefix),
          suffixIcon: this.preOrSufFixShow("icon", formItem.suffix),
          valueFormat:formItem.dateFormate,
          valueFormat:formItem.dateFormate || "yyyy-MM-dd HH:mm:ss",
          format: formItem.dateFormate,
          keyAttr: formItem.keyAttr,
          value: (formItem.dicData && formItem.dicData.length > 0 && formItem.secType == "codefixedsec" ? formItem.dicData[0].id : null) ||
            (formItem.secType == "codedatesec"?formItem.codeDateValue: null) || ( TreeValue&& formItem.secType == "codelevelsec" ? TreeValue : null) ,
            (formItem.secType == "codedatesec" ? formItem.codeDateValue: null) || ( TreeValue && formItem.secType == "codelevelsec" ? TreeValue : null) ||
            (formItem.secType == "codeattrsec" ? this.add : null),
          placeholder: formItem.inputTip,
          comboxKey: formItem.comboxKey,
          tip: formItem.tooltips,
@@ -278,6 +305,8 @@
            value: "key",
          },
        };
        // console.log('formItem',formItem)
        // console.log('columnItem',columnItem)
        slotColumnList.push(columnItem);
        if (group.length === 0) {
          column.push(columnItem);
@@ -295,14 +324,15 @@
      this.geDictData(dictKeys);
      this.getFormDetail();
    },
    //修改级联项
    changeChildItem(items,TreeValue) {
      let column = this.option.column;
      let group = this.option.group;
      let that=this;
      items.forEach((item) => {
        let formItem = this.resetFormConfig(item);
        if (formItem.field == "lcstatus") {
          formItem.field = formItem.field + "_text";
          formItem.readOnly = true;
@@ -322,6 +352,9 @@
          formItem.fieldMap[formItem.field + 'id'] = 'id'
        }
        let columnItem = {
          change:(val)=>{
            console.log('1',val)
          },
          label: formItem.text,
          labelslot: true,
          prop: this.$utilFunc.isValuableObj(formItem.referConfig)
@@ -335,7 +368,7 @@
          append: this.preOrSufFixShow("text", formItem.suffix),
          prefixIcon: this.preOrSufFixShow("icon", formItem.prefix),
          suffixIcon: this.preOrSufFixShow("icon", formItem.suffix),
          valueFormat: formItem.dateFormate,
          valueFormat: formItem.dateFormate || "yyyy-MM-dd HH:mm:ss",
          format: formItem.dateFormate,
          keyAttr: formItem.keyAttr,
          value: (formItem.dicData && formItem.dicData.length > 0 && formItem.secType == "codefixedsec" ? formItem.dicData[0].id : null) ||
@@ -384,22 +417,22 @@
        };
        if (group.length === 0) {
          this.slotColumnList.forEach((index, colItem) => {
          that.slotColumnList.forEach((colItem,index) => {
            if (colItem.field == columnItem.field) {
              this.slotColumnList[index] = columnItem;
              that.slotColumnList[index] = columnItem;
              column[index] = columnItem;
              return;
            }
          })
        } else {
          this.slotColumnList.forEach((index, colItem) => {
          that.slotColumnList.forEach((colItem,index) => {
            if (colItem.field == columnItem.field) {
              this.slotColumnList[index] = columnItem;
              that.slotColumnList[index] = columnItem;
              return;
            }
          })
          group.forEach((index, groupItem) => {
            groupItem.column.forEach((colIndex, colItem) => {
          group.forEach((groupItem,index) => {
            groupItem.column.forEach((colItem,colIndex) => {
              if (colItem.field == columnItem.field) {
                group[index].column[colIndex] = columnItem;
                return;
@@ -408,8 +441,8 @@
          });
        }
      });
      this.$set(this.option, "column", column);
      this.$set(this.option, "group", group);
      that.$set(that.option, "column", column);
      that.$set(that.option, "group", group);
    },
    // 使用传入的表单数据配置
    resetFormConfig(formItem) {
@@ -428,6 +461,7 @@
              if (Object.hasOwnProperty.call(element, newAttr)) {
                const oldAttr = element[newAttr];
                formItem[newAttr] = formItem[oldAttr];
              }
            }
          } else if (configType === "directVoluation") {
@@ -477,13 +511,13 @@
    // 异步获取字典数据
    geDictData(dictKeys) {
      dictKeys.forEach((dictObj) => {
        getDictionary({ code: dictObj.dictKey }).then((res) => {
        getEnumDictionary({ code: dictObj.dictKey }).then((res) => {
          if (res.data && res.data.code === 200) {
            this.option.column = this.option.column.map((item) => {
              if (item.field === dictObj.field) {
                let dictData = (res.data.data || []).map((itm) => {
                  itm.value = itm.dictValue;
                  itm.key = itm.dictKey;
                  itm.value = itm.itemName;
                  itm.key = itm.itemValue;
                  return itm;
                });
                item.dicData = dictData;
@@ -501,6 +535,7 @@
          if (valid) {
            done();
            resolve(true);
            this.ValidataValue=true;
          } else {
            resolve(false);
          }