fujunling
2023-08-23 44246a2082c74db213faa0e2c97445ec1173068b
Source/UBCS-WEB/src/components/FormTemplate/FormTemplate.vue
@@ -50,7 +50,7 @@
    // 默认禁用元素
    disabledProp: {
      type: Array,
      default: () => ["id","lcstatus"],
      default: () => ["id", "lcstatus"],
    },
    templateOid: {
      type: String,
@@ -80,6 +80,11 @@
      type: Object,
      default: () => ({}),
    },
    // 一行放几个表单
    trendsSpan: {
      type: Number,
      default: 8,
    },
  },
  data() {
    return {
@@ -103,9 +108,6 @@
        date: "date",
        refer: "refer",
      },
      // 假数据
      testItems: [],
      trendsSpan: 8,
      defaultValue: {},
      // 表单属性
      attributes: [],
@@ -115,9 +117,20 @@
  mounted() {
    this.handleResize();
  },
  computed: {
    localTrendsSpan() {
      if (this.trendsSpan) {
        return this.trendsSpan;
      } else {
        let windowWidth = document.body.clientWidth;
        return 24 / Math.floor(windowWidth / 500);
      }
    },
  },
  methods: {
    // 渲染表单模板
    templateRender(formItemList) {
      console.log(formItemList, "formItemList");
      // 无需分组数据
      let column = [];
      let group = [];
@@ -137,7 +150,8 @@
        if (
          formItem.type === "combox" &&
          formItem.comboxKey &&
          (!Array.isArray(formItem.dicData) || formItem.dicData.length === 0) &&(!Array.isArray(formItem.data) || formItem.data.length === 0)
          (!Array.isArray(formItem.dicData) || formItem.dicData.length === 0) &&
          (!Array.isArray(formItem.data) || formItem.data.length === 0)
        ) {
          dictKeys.push({ dictKey: formItem.comboxKey, field: formItem.field });
        }
@@ -145,9 +159,9 @@
        if (this.disabledProp.includes(formItem.field)) {
          formItem.readOnly = true;
        }
        if(formItem.field=='lcstatus'){
          formItem.field=formItem.field+'_text';
          formItem.readOnly=true;
        if (formItem.field == "lcstatus") {
          formItem.field = formItem.field + "_text";
          formItem.readOnly = true;
        }
        // 设置表单校验的规则,文本
        let message = "请选择";
@@ -190,7 +204,11 @@
                  options: formItem.referConfig,
                }
              : {},
          span: formItem.span ? formItem.span : formItem.type === "textarea" ? 24 : this.trendsSpan,
          span: formItem.span
            ? formItem.span
            : formItem.type === "textarea"
            ? 24
            : this.localTrendsSpan,
          rules: [
            {
              required: formItem.required,
@@ -217,6 +235,7 @@
        }
      });
      this.slotColumnList = slotColumnList;
      console.log(column, "column");
      this.$set(this.option, "column", column);
      this.$set(this.option, "group", group);
      this.updateIndex++;
@@ -260,9 +279,9 @@
    },
    // 根据屏幕动态配置表单布局
    handleResize() {
      let windowWidth = document.body.clientWidth;
      this.trendsSpan = 24 / Math.floor(windowWidth / 500);
      this.updateIndex++;
      // let windowWidth = document.body.clientWidth;
      // this.trendsSpan = 24 / Math.floor(windowWidth / 500);
      // this.updateIndex++;
    },
    // 前后缀
    preOrSufFixShow(type, val) {