ludc
2023-12-08 c892580371ef4679c858e2da98f71a9345aa3d80
Source/UBCS-WEB/src/components/FormTemplate/FormTemplate.vue
@@ -103,14 +103,14 @@
      type: String,
      default: "",
    },
    selectRow:{
      type:Array,
      default:[]
    selectRow: {
      type: Array,
      default: []
    }
  },
  data() {
    return {
      selectValue:"",
      selectValue: "",
      //年代号
      dataYearCode: {
        type: "",
@@ -206,20 +206,20 @@
      }
    },
    dataYearCode: {
      deep:true,
      immediate:true,
      deep: true,
      immediate: true,
      handler(newV) {
        this.$emit("dataYearCode", newV)
      }
    },
    selectRow:{
      handler(newval){
        console.log(newval);
    selectRow: {
      handler(newval) {
        // console.log(newval);
        let ids = newval.map(item => item.id);
        this.selectValue= ids.join(",");
        this.selectValue = ids.join(",");
      },
      deep:true,
      immediate:true
      deep: true,
      immediate: true
    }
  },
  methods: {
@@ -240,6 +240,7 @@
      let slotColumnList = [];
      formItemList.forEach((formItem) => {
        formItem = this.resetFormConfig(formItem);
        // console.log(formItem)
        //属性码段规则
        if (formItem.secType === "codeattrsec") {
          this.attrList.push(formItem);
@@ -296,8 +297,8 @@
              this.codeattrsecValue = val.value;
              return;
            }
            //是否系列-系列号
            if (val.column.field === "isSeries") {
            //修订为-系列号
            if (val.column.field === "reviseSeries") {
              if (val.value === "false") {
                this.isShow = true;
              } else {
@@ -323,7 +324,8 @@
          field: formItem.field,
          type: this.columnType[formItem.type],
          dicData: this.getDataList(formItem.type, formItem.data),
          disabled: this.type === "detail" ? true : formItem.readOnly || (formItem.codeValueApplyStatus && formItem.codeValueApplyStatus == 2 ? true : false),
          disabled: this.type === "detail" ? true : formItem.readOnly || (formItem.codeValueApplyStatus && formItem.codeValueApplyStatus == 2 ? true : false) ||
            (this.status === 'amend' ? (formItem.field === "reviseSeries" ? (formItem.value == 'false' ? true : false) : false) : false),
          prepend: this.preOrSufFixShow("text", formItem.prefix),
          append: this.preOrSufFixShow("text", formItem.suffix),
          prefixIcon: this.preOrSufFixShow("icon", formItem.prefix),
@@ -331,12 +333,12 @@
          valueFormat: formItem.dateFormate || "yyyy-MM-dd HH:mm:ss",
          format: formItem.dateFormate,
          keyAttr: formItem.keyAttr,
          value:formItem.defaultValue || (formItem.dicData && formItem.dicData.length > 0 && formItem.secType == "codefixedsec" ? formItem.dicData[0].id : null) ||
          value: formItem.defaultValue || (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 == "codeattrsec" ? this.add : null) || (this.status === "apply" && formItem.field === "codeStandardEditType" ? "1" : null) ||
            (this.status === "amend" && formItem.field === "codeStandardEditType" ? "2" : null) ||
            //父组件如果是参照数据会将selectRow置空,selectRow不为空就说明不是参照要回填源标准号数据
            (this.status === "amend" && this.selectRow && (formItem.field === "oldcode" ? this.selectValue : null)),
            (this.status === "amend" ? (this.selectRow && (formItem.field === "oldcode" ? this.selectValue : null)) : null),
          placeholder: formItem.inputTip,
          comboxKey: formItem.comboxKey,
          tip: formItem.tooltips,
@@ -399,7 +401,127 @@
    },
    //修改级联项
    changeChildItem(items, TreeValue, type) {
      type = type || "add"
      type = type || "add";
      let column = this.option.column;
      let group = this.option.group;
      // let column = [];
      // let group = [];
      let that = this;
      items.forEach((item) => {
        let formItem = this.resetFormConfig(item);
        if (formItem.field == "lcstatus") {
          formItem.field = formItem.field + "_text";
          formItem.readOnly = true;
        }
        // 设置表单校验的规则,文本
        let message = "请选择";
        let trigger = "change";
        if (formItem.type === "text") {
          message = "请输入";
          trigger = "blur";
        }
        let fieldMapKey = ''
        if (formItem.type == "refer" && !formItem.fieldMap) {
          fieldMapKey = formItem.field + 'Id'
          formItem.fieldMap = {}
          formItem.fieldMap[fieldMapKey] = 'id'
          formItem.fieldMap[formItem.field + 'id'] = 'id'
        }
        let columnItem = {
          label: formItem.text,
          labelslot: true,
          prop: this.$utilFunc.isValuableObj(formItem.referConfig)
            ? formItem.showField || formItem.field
            : formItem.field,
          field: formItem.field,
          type: this.columnType[formItem.type],
          dicData: this.getDataList(formItem.type, formItem.data),
          disabled: this.type === "detail" ? true : formItem.readOnly || (formItem.codeValueApplyStatus && formItem.codeValueApplyStatus == 2 ? true : false) ||
            (this.status  ? (formItem.field === "reviseSeries" ? (formItem.value == 'false' ? true : false) : false) : false),
          prepend: this.preOrSufFixShow("text", formItem.prefix),
          append: this.preOrSufFixShow("text", formItem.suffix),
          prefixIcon: this.preOrSufFixShow("icon", formItem.prefix),
          suffixIcon: this.preOrSufFixShow("icon", formItem.suffix),
          valueFormat: formItem.dateFormate || "yyyy-MM-dd HH:mm:ss",
          format: formItem.dateFormate,
          keyAttr: formItem.keyAttr,
          value: formItem.defaultValue || (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 == "codeattrsec" ? this.add : null) || (this.status === "apply" && formItem.field === "codeStandardEditType" ? "1" : null) ||
            (this.status === "amend" && formItem.field === "codeStandardEditType" ? "2" : null) ||
            //父组件如果是参照数据会将selectRow置空,selectRow不为空就说明不是参照要回填源标准号数据
            (this.status === "amend" ? (this.selectRow && (formItem.field === "oldcode" ? this.selectValue : null)) : null),
          placeholder: formItem.inputTip,
          comboxKey: formItem.comboxKey,
          tip: formItem.tooltips,
          display: !formItem.hidden,
          maxlength: formItem.maxlength,
          filterable: true,
          referConfig:
            formItem.type == "refer"
              ? {
                title: formItem.text,
                showField: formItem.showField || formItem.field,
                field: formItem.field,
                fieldMap: formItem.fieldMap || {},
                placeholder: formItem.inputTip,
                options: formItem.referConfig
              }
              : {},
          span: formItem.span
            ? formItem.span
            : formItem.type === "textarea"
              ? 24
              : this.localTrendsSpan,
          rules: [
            {
              required: formItem.required,
              message: `${message}${formItem.text}`,
              trigger,
            },
            {
              // 如果没有正则则匹配任何字符
              pattern: formItem.verify ? formItem.verify : /[\s\S.]*/g,
              message: formItem.tooltips,
              trigger,
            },
          ],
          props: {
            label: "value",
            value: "key",
          },
        };
        if (group.length === 0) {
          that.slotColumnList.forEach((colItem, index) => {
            if (colItem.field == columnItem.field) {
              that.slotColumnList[index] = columnItem;
              column[index] = columnItem;
              return;
            }
          })
        } else {
          that.slotColumnList.forEach((colItem, index) => {
            if (colItem.field == columnItem.field) {
              that.slotColumnList[index] = columnItem;
              return;
            }
          })
          group.forEach((groupItem, index) => {
            groupItem.column.forEach((colItem, colIndex) => {
              if (colItem.field == columnItem.field) {
                group[index].column[colIndex] = columnItem;
                return;
              }
            })
          });
        }
      });
      that.$set(that.option, "column", column);
      that.$set(that.option, "group", group);
    },
    //标准-修订
    changeStatusItem(items, TreeValue, type) {
      type = type || "add";
      // let column = this.option.column;
      // let group = this.option.group;
      let column = [];
@@ -434,7 +556,8 @@
          field: formItem.field,
          type: this.columnType[formItem.type],
          dicData: this.getDataList(formItem.type, formItem.data),
          disabled: type === "detail" ? true : formItem.readOnly || (formItem.codeValueApplyStatus && formItem.codeValueApplyStatus == 2 ? true : false),
          disabled: this.type === "detail" ? true : formItem.readOnly || (formItem.codeValueApplyStatus && formItem.codeValueApplyStatus == 2 ? true : false) ||
            (this.status === 'amend' ? (formItem.field === "reviseSeries" ? (formItem.value == 'false' ? true : false) : false) : false),
          prepend: this.preOrSufFixShow("text", formItem.prefix),
          append: this.preOrSufFixShow("text", formItem.suffix),
          prefixIcon: this.preOrSufFixShow("icon", formItem.prefix),
@@ -442,15 +565,15 @@
          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) ||
          value: formItem.defaultValue || (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 == "codeattrsec" ? this.add : null) || (this.status === "apply" && formItem.field === "codeStandardEditType" ? "1" : null)  ||
            (this.status === "amend" && formItem.field === "codeStandardEditType" ? "2" : null),
            (formItem.secType == "codeattrsec" ? this.add : null) || (this.status === "apply" && formItem.field === "codeStandardEditType" ? "1" : null) ||
            (this.status === "amend" && formItem.field === "codeStandardEditType" ? "2" : null) ||
            //父组件如果是参照数据会将selectRow置空,selectRow不为空就说明不是参照要回填源标准号数据
            (this.status === "amend" ? (this.selectRow && (formItem.field === "oldcode" ? this.selectValue : null)) : null),
          placeholder: formItem.inputTip,
          comboxKey: formItem.comboxKey,
          tip: formItem.tooltips,
          // hidden:formItem.secType && formItem.codeValueApplyStatus == 3 ? true : false,
          // readonly:formItem.codeValueApplyStatus && formItem.codeValueApplyStatus == 2 ?true : false ,
          display: !formItem.hidden,
          maxlength: formItem.maxlength,
          filterable: true,
@@ -617,7 +740,7 @@
    // 获取表单详情数据
    getFormDetail() {
      if (this.type === "add") return;
      if(this.templateOid){
      if (this.templateOid) {
        getFormDetail({templateOid: this.templateOid, oid: this.rowOid}).then(
          (res) => {
            this.form = Object.assign(this.form, res.data.data[0]);