wangting
2024-11-22 3f2e126dd9ea3c47fa473b18d9fd890763918002
Source/plt-web/plt-web-ui/src/components/PLT-basic-component/basicForm.vue
@@ -1,6 +1,6 @@
<template>
  <!--动态模板-->
  <avue-form ref="form" :option="option" v-model="form">
  <avue-form ref="form" :option="option" v-model="form" v-loading="loading">
    <template v-for="item in allColumn" :slot="item.prop+ ''">
      <vciWebRefer
        v-if="item.type === 'refer'"
@@ -83,6 +83,7 @@
  },
  data() {
    return {
      loading:false,
      form: this.formData,
      option: {
        menuBtn:false,
@@ -98,10 +99,6 @@
        text: "input",
        combox: "select",
        truefalse: "switch",
        number: "number",
        textarea: "textarea",
        datetime: "datetime",
        date: "date",
        refer: "refer",
        multiFile:"upload",
        richText:'richText'
@@ -189,24 +186,24 @@
      let col= {
        ...item,
        label: item.text,
        prop: item.field,
        showProp:item.showField,
        prop: item.prop || item.field,
        showProp:item.showProp || item.showField,
        type: type,
        labelWidth: this.labelWidth || (item.text.length >= 6 ? 115 : 90),
        disabled: item.readOnly || this.disabled,
        labelWidth:item.labelWidth || this.labelWidth || (item.text.length >= 6 ? 115 : 90),
        disabled: item.disabled || this.disabled,
        readonly:item.readonly || item.readOnly,
        span: item.span
          ? item.span
          : item.type === "textarea"
            ? 24
            : this.span,
        value: item.defaultValue,
        display: !item.hidden,
        labelSuffix: item.suffix,
        suffixIcon: item.prefix,
        tip: item.tooltips,
        dictCode: item.comboxKey,
        valueFormat: item.dateFormate || "yyyy-MM-dd HH:mm:ss",
        format: item.dateFormate,
        value: item.value || item.defaultValue,
        display: item.display || !item.hidden,
        labelSuffix: item.labelSuffix || item.suffix,
        tip: item.tip || item.tooltips,
        dictCode: item.dictCode || item.comboxKey,
        valueFormat: item.valueFormat ||item.dateFormate ,
        format: item.format || item.dateFormate,
        rules: this.isEdit?(type=="select" || type=="refer" || type=="date" || type=="datetime"?[{
          required: item.required || false,
          message: `请选择${item.text}!`,
@@ -223,7 +220,8 @@
          required: item.required|| false,
          message: `请输入${item.text}!`,
          trigger: "submit"
        }]):[]
        }]):[],
      };
      if(!this.isEdit){
        col.placeholder=col.label;
@@ -238,20 +236,20 @@
          col.display=false
        }
      }
      if (col.type === "select") {
        if(col.data && col.data.length>0){
      if (col.type === "select" || col.type==='radio' || col.type==='checkbox') {
        if (col.data && col.data.length > 0) {
          col.dicData = col.data.map((d) => {
            return {
              label: d.key,
              key: d.value,
              value: d.value,
              attributes:d.attributes
              attributes: d.attributes
            };
          });
        }else if(!validatenull(col.dictCode)) {
        } else if (!validatenull(col.dictCode)) {
          getDicts(col.dictCode).then((res) => {
            if (res.data.success){
              if(res.data.data && res.data.obj == null){
            if (res.data.success) {
              if (res.data.data && res.data.obj == null) {
                res.data.obj = res.data.data
              }
              const dic = res.data.obj;
@@ -260,7 +258,7 @@
                  label: d.value,
                  key: d.key,
                  value: d.key,
                  attributes:d.attributes
                  attributes: d.attributes
                };
              });
            }