fujunling
2023-06-05 ee07d050ac5e52ded8f0de0872085ef9b00790ee
动态表单
已修改6个文件
555 ■■■■ 文件已修改
Source/UBCS-WEB/src/components/FormTemplate/CodeApply.vue 427 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Source/UBCS-WEB/src/components/FormTemplate/FormTempalte.vue 45 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Source/UBCS-WEB/src/components/FormTemplate/ResembleQuery.vue 14 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Source/UBCS-WEB/src/components/FormTemplate/index.vue 57 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Source/UBCS-WEB/src/views/MasterData/FormTempalteTest.vue 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Source/UBCS-WEB/vue.config.js 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Source/UBCS-WEB/src/components/FormTemplate/CodeApply.vue
@@ -1,7 +1,6 @@
<template>
  <FormTempalte
    ref="FormTempalte"
    :visible="visible"
    :selfColumnType="selfColumnType"
    :selfColumnConfig="selfColumnConfig"
    :columnList="columnList"
@@ -10,14 +9,13 @@
<script>
import { getCodeRule } from "@/api/formTemplate.js";
import FormTempalte from "./FormTempalte.vue";
export default {
  name: "CodeApply",
  components: { FormTempalte },
  components: { FormTempalte: () => import('./FormTempalte.vue') },
  props: {
    visible: {
      type: Boolean,
      default: false
      default: false,
    },
    codeClassifyOid: {
      type: String,
@@ -59,7 +57,406 @@
          },
        },
      },
      columnList: [],
      columnList: [
        {
          btmname: "codebasicsec",
          checkInBy: "",
          checkInTime: null,
          checkOutBy: "",
          checkOutTime: null,
          codeDateFormatStr: "",
          codeFillFlag: "",
          codeFillLength: "",
          codeFillLimit: 0,
          codeFillSeparator: "",
          codeFillType: "",
          codeFillTypeText: "",
          codeGetValueType: "",
          codeGetValueTypeText: "",
          codeLevelType: "",
          codeLevelTypeText: "",
          codeLevelValue: 0,
          codeSecLength: "10",
          codeSecLengthType: "code_sec_length_variable",
          codeSecLengthTypeText: "",
          componentCodeFlag: "false",
          copyFromVersion: "",
          createTime: "2023-06-02 10:23:33.000",
          creator: "1",
          customCodeSerialClass: "",
          data: null,
          description: "",
          displayFlag: "false",
          filterSql: "",
          firstR: "1",
          firstV: "1",
          fixedValueVOList: [
            {
              btmname: "codefixedvalue",
              checkInBy: "",
              checkInTime: null,
              checkOutBy: "",
              checkOutTime: null,
              codefixedsecoid: "5591ED23-D218-8B84-9789-1E5EB21A49B9",
              codefixedsecoidName: null,
              copyFromVersion: "",
              createTime: "2023-06-02 10:47:45.000",
              creator: "1",
              data: null,
              description: "",
              firstR: "1",
              firstV: "1",
              id: "002",
              lastModifier: "1",
              lastModifyTime: "2023-06-02 10:47:45.000",
              lastR: "1",
              lastV: "1",
              lcStatus: "Exist",
              lcStatusText: "存在",
              lctid: "defaultLC",
              name: "",
              nameOid: "B8BB82F0-9B9E-3E7C-4324-62F13A64B369",
              oid: "375AE030-DCB2-B116-1C71-DA1AB971E249",
              ordernum: 0,
              owner: "1",
              revisionOid: "9BF1CABA-EB6D-0B80-0938-D4DC779D5AF0",
              revisionRule: "",
              revisionSeq: 1,
              revisionValue: "",
              secretGrade: null,
              secretGradeText: "",
              ts: "2023-06-02 10:47:45.635",
              versionRule: "0",
              versionSeq: 1,
              versionValue: "1",
            },
            {
              btmname: "codefixedvalue",
              checkInBy: "",
              checkInTime: null,
              checkOutBy: "",
              checkOutTime: null,
              codefixedsecoid: "5591ED23-D218-8B84-9789-1E5EB21A49B9",
              codefixedsecoidName: null,
              copyFromVersion: "",
              createTime: "2023-06-02 10:47:42.000",
              creator: "1",
              data: null,
              description: "",
              firstR: "1",
              firstV: "1",
              id: "001",
              lastModifier: "1",
              lastModifyTime: "2023-06-02 10:47:42.000",
              lastR: "1",
              lastV: "1",
              lcStatus: "Exist",
              lcStatusText: "存在",
              lctid: "defaultLC",
              name: "",
              nameOid: "804FA254-1158-C355-9CE2-7CA444955AFC",
              oid: "821F6250-C763-FB0E-92F5-A9C07F1B951C",
              ordernum: 0,
              owner: "1",
              revisionOid: "6CF50C9D-2606-948A-03B1-26158627CE33",
              revisionRule: "",
              revisionSeq: 1,
              revisionValue: "",
              secretGrade: null,
              secretGradeText: "",
              ts: "2023-06-02 10:47:42.527",
              versionRule: "0",
              versionSeq: 1,
              versionValue: "1",
            },
          ],
          getValueClass: "",
          id: "0001",
          lastModifier: "1",
          lastModifyTime: "2023-06-02 10:23:33.000",
          lastR: "1",
          lastV: "1",
          lcStatus: "Exist",
          lcStatusText: "存在",
          lctid: "defaultLC",
          matchClassifyValueFlag: "",
          name: "固定码段",
          nameOid: "C01CA64B-8358-D3A7-D38D-9DE7A5D748C8",
          nullableFlag: "false",
          oid: "5591ED23-D218-8B84-9789-1E5EB21A49B9",
          orderNum: 1,
          owner: "1",
          parentClassifySecOid: "",
          parentClassifySecText: "",
          pkCodeRule: "B95872A6-9CEA-D490-8F1B-9D26548CAF96",
          referAttributeId: "",
          referAttributeName: "",
          referBtmId: "",
          referBtmName: "",
          referCodeClassifyOid: "",
          referCodeClassifyOidName: "",
          referConfig: "",
          referValueInfo: "",
          revisionOid: "EE7A9BC0-FEF3-061B-A750-132121D86D83",
          revisionRule: "",
          revisionSeq: 1,
          revisionValue: "",
          secretGrade: null,
          secretGradeText: "",
          sectype: "codefixedsec",
          sectypeText: "固定码段",
          serialDependFlag: "false",
          serialDependOrder: 0,
          serialStart: "",
          serialStep: 0,
          ts: "2023-06-02 10:23:33.733",
          valueCutLength: 0,
          valueCutType: "code_cut_none",
          valueCutTypeText: "不截取",
          versionRule: "0",
          versionSeq: 1,
          versionValue: "1",
        },
        {
          btmname: "codebasicsec",
          checkInBy: "",
          checkInTime: null,
          checkOutBy: "",
          checkOutTime: null,
          codeDateFormatStr: "",
          codeFillFlag: "",
          codeFillLength: "",
          codeFillLimit: 0,
          codeFillSeparator: "0",
          codeFillType: "code_fill_right",
          codeFillTypeText: "",
          codeGetValueType: "",
          codeGetValueTypeText: "",
          codeLevelType: "",
          codeLevelTypeText: "",
          codeLevelValue: 0,
          codeSecLength: "10",
          codeSecLengthType: "",
          codeSecLengthTypeText: "",
          componentCodeFlag: "false",
          copyFromVersion: "",
          createTime: "2023-06-02 10:24:07.000",
          creator: "1",
          customCodeSerialClass: "",
          data: null,
          description: "可变码段",
          displayFlag: "false",
          filterSql: "",
          firstR: "1",
          firstV: "1",
          fixedValueVOList: null,
          getValueClass: "",
          id: "0002",
          lastModifier: "1",
          lastModifyTime: "2023-06-02 10:24:07.000",
          lastR: "1",
          lastV: "1",
          lcStatus: "Exist",
          lcStatusText: "存在",
          lctid: "defaultLC",
          matchClassifyValueFlag: "",
          name: "可变码段",
          nameOid: "02AED8DD-C40D-7E00-C88A-3DB65A3027A4",
          nullableFlag: "false",
          oid: "A4508759-4213-2F07-04ED-A8C224303F44",
          orderNum: 2,
          owner: "1",
          parentClassifySecOid: "",
          parentClassifySecText: "",
          pkCodeRule: "B95872A6-9CEA-D490-8F1B-9D26548CAF96",
          referAttributeId: "",
          referAttributeName: "",
          referBtmId: "",
          referBtmName: "",
          referCodeClassifyOid: "",
          referCodeClassifyOidName: "",
          referConfig: "",
          referValueInfo: "",
          revisionOid: "E4C77B6E-13AE-55EB-4147-64B4526BFEE4",
          revisionRule: "",
          revisionSeq: 1,
          revisionValue: "",
          secretGrade: null,
          secretGradeText: "",
          sectype: "codevariablesec",
          sectypeText: "可变码段",
          serialDependFlag: "false",
          serialDependOrder: 0,
          serialStart: "",
          serialStep: 0,
          ts: "2023-06-02 10:24:07.804",
          valueCutLength: 0,
          valueCutType: "",
          valueCutTypeText: "",
          versionRule: "0",
          versionSeq: 1,
          versionValue: "1",
        },
        {
          btmname: "codebasicsec",
          checkInBy: "",
          checkInTime: null,
          checkOutBy: "",
          checkOutTime: null,
          codeDateFormatStr: "",
          codeFillFlag: "",
          codeFillLength: "",
          codeFillLimit: 0,
          codeFillSeparator: "",
          codeFillType: "",
          codeFillTypeText: "",
          codeGetValueType: "",
          codeGetValueTypeText: "",
          codeLevelType: "",
          codeLevelTypeText: "",
          codeLevelValue: 0,
          codeSecLength: "10",
          codeSecLengthType: "code_sec_length_static",
          codeSecLengthTypeText: "",
          componentCodeFlag: "false",
          copyFromVersion: "",
          createTime: "2023-06-02 10:25:07.000",
          creator: "1",
          customCodeSerialClass: "",
          data: null,
          description: "分类码段子",
          displayFlag: "false",
          filterSql: "",
          firstR: "1",
          firstV: "1",
          fixedValueVOList: [
            {
              btmname: "codefixedvalue",
              checkInBy: "",
              checkInTime: null,
              checkOutBy: "",
              checkOutTime: null,
              codefixedsecoid: "8FD660BF-BA04-AB4F-8076-B5C43845621B",
              codefixedsecoidName: null,
              copyFromVersion: "",
              createTime: "2023-06-02 10:43:44.000",
              creator: "1",
              data: null,
              description: "",
              firstR: "1",
              firstV: "1",
              id: "000101",
              lastModifier: "1",
              lastModifyTime: "2023-06-02 10:43:44.000",
              lastR: "1",
              lastV: "1",
              lcStatus: "Exist",
              lcStatusText: "存在",
              lctid: "defaultLC",
              name: "",
              nameOid: "D135277F-E638-EB02-CEF1-AD99B889CA94",
              oid: "F7FEFFB7-0832-8CAF-2965-50757D01B878",
              ordernum: 0,
              owner: "1",
              revisionOid: "AF362124-06FD-F209-442F-8A13842CEB40",
              revisionRule: "",
              revisionSeq: 1,
              revisionValue: "",
              secretGrade: null,
              secretGradeText: "",
              ts: "2023-06-02 10:43:44.838",
              versionRule: "0",
              versionSeq: 1,
              versionValue: "1",
            },
            {
              btmname: "codefixedvalue",
              checkInBy: "",
              checkInTime: null,
              checkOutBy: "",
              checkOutTime: null,
              codefixedsecoid: "8FD660BF-BA04-AB4F-8076-B5C43845621B",
              codefixedsecoidName: null,
              copyFromVersion: "",
              createTime: "2023-06-02 10:43:49.000",
              creator: "1",
              data: null,
              description: "",
              firstR: "1",
              firstV: "1",
              id: "000102",
              lastModifier: "1",
              lastModifyTime: "2023-06-02 10:43:49.000",
              lastR: "1",
              lastV: "1",
              lcStatus: "Exist",
              lcStatusText: "存在",
              lctid: "defaultLC",
              name: "",
              nameOid: "4F0F0F48-6146-5E62-7E4C-C1ED5E7D788C",
              oid: "F11E47E7-1360-5914-BA03-B6844E37AFB4",
              ordernum: 0,
              owner: "1",
              revisionOid: "B4797510-7232-B6FF-077D-918F9B36D3C3",
              revisionRule: "",
              revisionSeq: 1,
              revisionValue: "",
              secretGrade: null,
              secretGradeText: "",
              ts: "2023-06-02 10:43:49.254",
              versionRule: "0",
              versionSeq: 1,
              versionValue: "1",
            },
          ],
          getValueClass: "",
          id: "00031",
          lastModifier: "1",
          lastModifyTime: "2023-06-02 10:25:07.000",
          lastR: "1",
          lastV: "1",
          lcStatus: "Exist",
          lcStatusText: "存在",
          lctid: "defaultLC",
          matchClassifyValueFlag: "",
          name: "分类码段子",
          nameOid: "69BEE3EC-F560-1C41-F56B-107F5B43C051",
          nullableFlag: "false",
          oid: "8FD660BF-BA04-AB4F-8076-B5C43845621B",
          orderNum: 4,
          owner: "1",
          parentClassifySecOid: "",
          parentClassifySecText: "",
          pkCodeRule: "B95872A6-9CEA-D490-8F1B-9D26548CAF96",
          referAttributeId: "",
          referAttributeName: "",
          referBtmId: "",
          referBtmName: "",
          referCodeClassifyOid: "",
          referCodeClassifyOidName: "",
          referConfig: "",
          referValueInfo: "",
          revisionOid: "EA98821E-60A0-1D18-4F70-96B0E0740B44",
          revisionRule: "",
          revisionSeq: 1,
          revisionValue: "",
          secretGrade: null,
          secretGradeText: "",
          sectype: "codefixedsec",
          sectypeText: "固定码段",
          serialDependFlag: "false",
          serialDependOrder: 0,
          serialStart: "",
          serialStep: 0,
          ts: "2023-06-02 10:25:07.764",
          valueCutLength: 0,
          valueCutType: "code_cut_none",
          valueCutTypeText: "不截取",
          versionRule: "0",
          versionSeq: 1,
          versionValue: "1",
        },
      ],
    };
  },
  created() {
@@ -73,13 +470,14 @@
    getCodeRule() {
      getCodeRule({ codeClassifyOid: this.codeClassifyOid }).then((res) => {
        if (res.data && res.data.code === 200) {
          this.defaultValue = res.data.data;
          this.columnList = res.data.data.secVOList || [];
          console.log(res.data.data.secVOList, 'res.data.data.secVOList');
          this.codeRuleOid = res.data.data.oid;
          // this.defaultValue = res.data.data;
          // this.columnList = res.data.data.secVOList || [];
          // this.codeRuleOid = res.data.data.oid;
          this.$nextTick(() => {
            this.$refs.FormTempalte.init(res.data.data.secVOList)
          })
            // 测试数据展示
            // this.$refs.FormTempalte.init(res.data.data.secVOList);
            this.$refs.FormTempalte.init(this.columnList);
          });
        }
      });
    },
@@ -114,11 +512,10 @@
      }
    },
    async validate() {
      return await this.$refs.FormTempalte.validate()
    }
      return await this.$refs.FormTempalte.validate();
    },
  },
  watch: {
  },
  watch: {},
};
</script>
Source/UBCS-WEB/src/components/FormTemplate/FormTempalte.vue
@@ -197,7 +197,7 @@
          tooltips: "请输入数字",
          type: "text",
          unique: false,
          verify: "/[0-9]/",
          verify: /^[0-9]+$/g,
        },
        {
          comboxKey: null,
@@ -513,7 +513,9 @@
      })
        .then((res) => {
          if (res.status === 200) {
            this.templateRender(res.data.formDefineVO.items);
            this.templateRender(this.testItems);
            // 测试数据展示
            // this.templateRender(res.data.formDefineVO.items);
            this.$emit("getFormTemplateEnd", res.data);
          }
        })
@@ -575,14 +577,12 @@
          format: formItem.dateFormate,
          keyAttr: formItem.keyAttr,
          value: formItem.defaultValue,
          // tip: formItem.tooltips,
          // tipPlacement: "right",
          placeholder: formItem.inputTip,
          comboxKey: formItem.comboxKey,
          display: !formItem.hidden,
          maxlength: formItem.maxlength,
          filterable: true,
          referConfig:formItem.referConfig,
          referConfig: formItem.referConfig,
          change: () => {
            this.changeFun(formItem.displayExtension, formItem.prop);
          },
@@ -618,7 +618,8 @@
      this.formIndex++;
      this.loading = false;
      this.geDictData(dictKeys);
      this.getFormDetail()
      // 测试数据展示
      // this.getFormDetail();
    },
    // 使用传入的表单数据配置
    resetFormConfig(formItem) {
@@ -709,26 +710,28 @@
      });
    },
    // 表单校验
     validate() {
    validate() {
      return new Promise((resolve) => {
        this.$refs.form.validate((valid, done, msg) => {
          console.error(msg, valid)
        if (valid) {
          resolve(true)
        } else {
          resolve(false);
        }
          console.error(msg, valid);
          if (valid) {
            done();
            resolve(true);
          } else {
            resolve(false);
          }
        });
      });
      })
    },
    // 获取表单数据
    // 获取表单详情数据
    getFormDetail() {
      if (this.type === 'add') return
      getFormDetail({templateOid: this.templateOid, oid: this.rowOid}).then(res => {
        console.log(res, 'res');
      })
    }
      if (this.type === "add") return;
      getFormDetail({ templateOid: this.templateOid, oid: this.rowOid }).then(
        (res) => {
          console.log(res, "res");
        }
      );
    },
  },
  watch: {
    // 表单数据修改反馈到父组件
Source/UBCS-WEB/src/components/FormTemplate/ResembleQuery.vue
@@ -37,6 +37,7 @@
      type="detail"
      :visible.sync="formTemplateVisible"
      :templateOid="this.resembleTemplateOid"
      :rowOid="rowOid"
      :codeClassifyOid="this.resembleCodeClassifyOid"
    ></FormTemplateDialog>
  </div>
@@ -44,11 +45,10 @@
<script>
import { findLike } from "@/api/formTemplate.js";
import FormTemplateDialog from "./index.vue";
export default {
  name: "ResembleQuery",
  components: { FormTemplateDialog },
  components: { FormTemplateDialog: () => import('./index.vue') },
  props: {
    column: {
      type: Array,
@@ -79,10 +79,13 @@
    return {
      formTemplateVisible: false,
      activeName: "findlike",
      tableData: [],
      tableData: [
        {id: '*****', materialclassifyText: '001', tuhao: 'tuhao', iod: '123123131312'}
      ],
      loading: false,
      resembleTemplateOid: "78B8C7C5-A042-0B96-FE6D-65421451782A",
      resembleCodeClassifyOid: "4524E801-6CC6-92E8-1AC3-2AB9604E8F96",
      rowOid: '',
      defaultValue: {},
      secVOList: [],
      defaultKeys: [
@@ -136,12 +139,15 @@
      params = Object.assign(params, defaultValue);
      findLike(params).then((res) => {
        this.loading = false;
        this.tableData = res.data.data || [];
        // this.tableData = res.data.data || [];
      });
    },
    openFormTemlpate(row) {
      this.$forceUpdate()
      console.log(row, 'row.oid');
      this.codetemplateoid = row.codetemplateoid;
      this.rowOid = row.oid
      this.formTemplateVisible = true;
    },
    getDefaultValueAndFormValues(form) {
Source/UBCS-WEB/src/components/FormTemplate/index.vue
@@ -13,14 +13,22 @@
      v-bind="$attrs"
      :visible="visible"
      :type="type"
      :rowOid="rowOid"
      v-if="dialogVisible"
      ref="FormTempalte"
      @getFormTemplateEnd="getFormTemplate"
      @getFormData="getFormData"
    ></FormTempalte>
    <div class="tab_box" v-if="type !== 'detail' && dialogVisible && (showCodeApply || showResembleQuery)">
      <el-tabs v-model="activeName" type="border-card">
    <div
      class="tab_box"
      v-if="
        type !== 'detail' &&
        dialogVisible &&
        (showCodeApply || showResembleQuery)
      "
    >
      <el-tabs v-model="activeName" type="border-card" @tab-click="handleClick">
        <el-tab-pane label="码值申请" name="codeApply" v-if="showCodeApply">
          <CodeApply
            ref="CodeApply"
@@ -48,7 +56,10 @@
      <el-button @click="submit()" type="primary" :loading="submitBtnLoading"
        >确 定</el-button
      >
      <el-button @click="resembleQuerySubmit" type="primary" v-if="showResembleQuery"
      <el-button
        @click="resembleQuerySubmit"
        type="primary"
        v-if="showResembleQuery"
        >相似像查询</el-button
      >
    </div>
@@ -79,6 +90,7 @@
      type: String,
      default: "80%",
    },
    rowOid: ''
  },
  data() {
    return {
@@ -88,6 +100,7 @@
      resembleTableColumn: [],
      secVOList: [],
      form: {},
      activeName: "",
    };
  },
  created() {},
@@ -101,29 +114,25 @@
      },
    },
    showCodeApply() {
      if (this.type === "add") {
        if (this.hasResemble && this.secVOList.length === 0) {
          return false;
        }
      } else {
        return false;
      }
      // 测试数据展示
      // if (this.type === "add") {
      //   if (this.hasResemble && this.secVOList.length === 0) {
      //     return false;
      //   }
      // } else {
      //   return false;
      // }
      return true;
    },
    showResembleQuery() {
      return this.hasResemble;
    },
    activeName() {
      return (
        (this.showCodeApply && "codeApply") ||
        (this.showResembleQuery && "resembleQuery")
      );
    },
  },
  methods: {
    openDialog() {
      this.$nextTick(() => {
        this.$refs.FormTempalte.init();
        this.$refs.CodeApply.getCodeRule();
      });
    },
    close() {
@@ -138,6 +147,9 @@
        data.resembleTableVO.cols &&
        data.resembleTableVO.cols.length > 0;
      this.resembleTableColumn = data.resembleTableVO.cols || [];
      this.activeName =
        (this.showCodeApply && "codeApply") ||
        (this.showResembleQuery && "resembleQuery");
    },
    getFormData(form) {
      this.form = form;
@@ -145,12 +157,21 @@
    resembleQuerySubmit() {
      this.$refs.resembleQueryRef.resembleQuery(this.form);
    },
    handleClick() {
      if (this.activeName === 'resembleQuery') {
        this.resembleQuerySubmit()
      }
    },
    async submit() {
      const formValidate = await this.$refs.FormTempalte.validate();
      let codeValidate = true;
      if (this.showCodeApply) {
        const codeValidate = this.$refs.CodeApply.validate();
        console.log(formValidate, codeValidate);
        codeValidate = await this.$refs.CodeApply.validate();
      }
      this.$emit("submit", {
        form: this.form,
        flag: formValidate && codeValidate,
      });
    },
  },
};
Source/UBCS-WEB/src/views/MasterData/FormTempalteTest.vue
@@ -10,6 +10,7 @@
      :codeRuleOid="this.codeRuleOid"
      :disabledProp="disabledProp"
      :rowOid="rowOid"
      @submit="submit"
    ></FormTemplateDialog>
    <ResembleQueryDialog
      :visible.sync="visible1"
@@ -40,5 +41,10 @@
      rowOid: '6EF696C3-CD87-0E7C-1EA1-8DE3913A95C9'
    };
  },
  methods: {
    submit(data) {
      console.log(data);
    }
  }
};
</script>
Source/UBCS-WEB/vue.config.js
@@ -26,11 +26,11 @@
    proxy: {
      '/api': {
        //本地服务接口地址
         target: 'http://localhost:37000',
        //  target: 'http://localhost:37000',
        // target: 'http://192.168.1.63:37000',
        //target: 'http://192.168.3.7:37000',
        // target: 'http://dev.vci-tech.com:37000',
        //target: 'http://192.168.1.51:37000/',
        target: 'http://dev.vci-tech.com:37000',
        // target: 'http://192.168.1.51:37000/',
        //远程演示服务地址,可用于直接启动项目
        // target: 'https://saber.bladex.vip/api',
        ws: true,