fjl
fujunling
2023-06-21 2d0fdaca6f7637c68782ae53ed2c3feee4f48db7
Source/UBCS-WEB/src/components/FormTemplate/index.vue
@@ -3,9 +3,8 @@
    :visible.sync="dialogVisible"
    v-if="dialogVisible"
    v-dialogDrag
    top="0vh"
    top="5vh"
    :title="title"
    class="avue-dialog avue-dialog--top"
    :width="width"
    append-to-body
    @opened="openDialog"
@@ -30,14 +29,14 @@
      "
    >
      <el-tabs v-model="activeName" type="border-card" @tab-click="handleClick">
        <el-tab-pane label="码值申请" name="codeApply">
        <el-tab-pane label="码值申请" name="codeApply" v-if="showCodeApply">
          <FormTempalte
            v-bind="$attrs"
            :type="type"
            :selfColumnType="selfColumnType"
            :selfColumnConfig="selfColumnConfig"
            ref="CodeApply"
            @getFormData="getFormData"
            @getFormData="getCodeApplyFormData"
            @referConfigDataUpdate="referConfigDataUpdate"
          ></FormTempalte>
        </el-tab-pane>
@@ -58,18 +57,25 @@
        </el-tab-pane>
      </el-tabs>
    </div>
    <div class="avue-dialog__footer" v-if="type !== 'detail'">
      <el-button @click="close()">取 消</el-button>
      <el-button @click="submit()" type="primary" :loading="submitBtnLoading">{{
        submitText
      }}</el-button>
      <el-button
        @click="resembleQuerySubmit"
        type="primary"
        v-if="showResembleQuery"
        >相似像查询</el-button
      >
    </div>
    <template #footer>
      <div class="" v-if="type !== 'detail'">
        <el-button @click="close()" size="small">取 消</el-button>
        <el-button
          @click="submit()"
          type="primary"
          :loading="submitBtnLoading"
          size="small"
          >{{ submitText }}</el-button
        >
        <el-button
          @click="resembleQuerySubmit"
          type="primary"
          size="small"
          v-if="showResembleQuery"
          >相似像查询</el-button
        >
      </div>
    </template>
  </el-dialog>
</template>
@@ -119,6 +125,7 @@
      resembleTableColumn: [],
      secVOList: [],
      form: {},
      codeApplyForm: {},
      activeName: "codeApply",
      showCodeApply: true,
      showResembleQuery: true,
@@ -154,6 +161,38 @@
          },
        },
      },
      defaultKeys: [
        "oid",
        "id",
        "name",
        "description",
        "revisionoid",
        "nameoid",
        "btmname",
        "lastr",
        "firstr",
        "lastv",
        "firstv",
        "creator",
        "createtime",
        "lastModifier",
        "lastmodifytime",
        "revisionrule",
        "revisionseq",
        "revisionvalue",
        "versionrule",
        "versionseq",
        "versionvalue",
        "lcstatus",
        "ts",
        "owner",
        "checkinby",
        "checkintime",
        "checkoutby",
        "checkouttime",
        "copyfromversion",
        "secretgrade",
      ],
    };
  },
  created() {},
@@ -199,12 +238,12 @@
        })
        .catch((err) => {
          this.loading = false;
          console.log(err);
        });
    },
    // 获取码值申请数据
    getCodeRule() {
      getCodeRule({ codeClassifyOid: this.codeClassifyOid }).then((res) => {
        console.log(res, "resresresresres");
        if (res.data && res.data.code === 200) {
          const typeList = [
            "codefixedsec",
@@ -212,172 +251,10 @@
            "codevariablesec",
            "coderefersec",
          ];
          this.secVOList = [
            {
              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-06 14:10:27.000",
              creator: "1",
              customCodeSerialClass: "",
              data: null,
              description: "",
              displayFlag: "false",
              filterSql: "",
              firstR: "1",
              firstV: "1",
              fixedValueVOList: null,
              getValueClass: "",
              id: "0001",
              lastModifier: "1",
              lastModifyTime: "2023-06-06 14:10:27.000",
              lastR: "1",
              lastV: "1",
              lcStatus: "Exist",
              lcStatusText: "存在",
              lctid: "defaultLC",
              matchClassifyValueFlag: "false",
              name: "分类码段父",
              nameOid: "C2998D32-E89E-6D41-0782-88E97E9EC65B",
              nullableFlag: "false",
              oid: "1668926002119708672",
              orderNum: 1,
              owner: "1",
              parentClassifySecOid: "",
              parentClassifySecText: "",
              pkCodeRule: "B4766355-E4E1-490A-833B-D5AB73E9B877",
              referAttributeId: "",
              referAttributeName: "",
              referBtmId: "",
              referBtmName: "",
              referCodeClassifyOid: "",
              referCodeClassifyOidName: "",
              referConfig: "",
              referValueInfo: "",
              revisionOid: "F0049108-6AAE-EAAD-BC76-E6714C2B8F2A",
              revisionRule: "",
              revisionSeq: 1,
              revisionValue: "",
              secretGrade: null,
              secretGradeText: "",
              sectype: "codeclassifysec",
              sectypeText: "分类码段",
              serialDependFlag: "false",
              serialDependOrder: 0,
              serialStart: "",
              serialStep: 0,
              ts: "2023-06-06 14:10:27.716",
              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_variable",
              codeSecLengthTypeText: "",
              componentCodeFlag: "false",
              copyFromVersion: "",
              createTime: "2023-06-06 14:10:50.000",
              creator: "1",
              customCodeSerialClass: "",
              data: null,
              description: "",
              displayFlag: "false",
              filterSql: "",
              firstR: "1",
              firstV: "1",
              fixedValueVOList: null,
              getValueClass: "",
              id: "000101",
              lastModifier: "1",
              lastModifyTime: "2023-06-06 14:10:50.000",
              lastR: "1",
              lastV: "1",
              lcStatus: "Exist",
              lcStatusText: "存在",
              lctid: "defaultLC",
              matchClassifyValueFlag: "false",
              name: "分类码段子",
              nameOid: "1FDB20E3-9F68-A5B0-D097-2142EA054F9B",
              nullableFlag: "false",
              oid: "00AD9FE0-A31D-7962-10DF-DC6115EF80A5",
              orderNum: 2,
              owner: "1",
              parentClassifySecOid: "1668926002119708672",
              parentClassifySecText: "分类码段",
              pkCodeRule: "B4766355-E4E1-490A-833B-D5AB73E9B877",
              referAttributeId: "",
              referAttributeName: "",
              referBtmId: "",
              referBtmName: "",
              referCodeClassifyOid: "",
              referCodeClassifyOidName: "",
              referConfig: "",
              referValueInfo: "",
              revisionOid: "95183EF9-C9AD-2941-1C99-9E9024330D40",
              revisionRule: "",
              revisionSeq: 1,
              revisionValue: "",
              secretGrade: null,
              secretGradeText: "",
              sectype: "codeclassifysec",
              sectypeText: "分类码段",
              serialDependFlag: "false",
              serialDependOrder: 0,
              serialStart: "",
              serialStep: 0,
              ts: "2023-06-06 14:10:50.084",
              valueCutLength: 0,
              valueCutType: "",
              valueCutTypeText: "",
              versionRule: "0",
              versionSeq: 1,
              versionValue: "1",
            },
          ];
          // this.secVOList = (res.data.data.secVOList || []).filter((item) =>
          //   typeList.includes(item)
          // );
          this.secVOList = (res.data.data.secVOList || []).filter((item) =>
            typeList.includes(item.secType)
          );
          console.log(this.secVOList, "this.secVOListthis.secVOList");
          this.$nextTick(() => {
            if (this.secVOList.length > 0 && this.type === "add") {
              this.showCodeApply = true;
@@ -393,6 +270,9 @@
    getFormData(form) {
      this.form = form;
    },
    getCodeApplyFormData(codeApplyForm) {
      this.codeApplyForm = codeApplyForm;
    },
    // 参照组件数据变更
    referConfigDataUpdate(data) {
      const { field } = data;
@@ -401,8 +281,9 @@
          this.$refs.CodeApply.form[item.oid] = undefined;
          this.$refs.CodeApply.form[item.name] = undefined;
        }
        return item;
      });
      this.$refs.CodeApply.templateRender();
      this.$refs.CodeApply.templateRender(this.secVOList);
    },
    resembleQuerySubmit() {
      this.activeName = "resembleQuery";
@@ -420,7 +301,8 @@
      let codeValidate = true;
      // 进行码值申请校验
      if (this.showCodeApply) {
        codeValidate = await this.$refs.codeApply.validate();
        codeValidate = await this.$refs.CodeApply.validate();
        console.log(9999);
        if (!codeValidate) return;
      }
      // 进行相似项查询
@@ -428,7 +310,22 @@
        this.form
      );
      if (resembleQueryList.length === 0) {
        this.$emit("submit", this.form);
        let resForm = {};
        const { defaultValue, formValue } = this.getDefaultValueAndFormValues(
          this.form
        );
        resForm.data = formValue;
        resForm = Object.assign({}, resForm, defaultValue);
        resForm.secDTOList = [];
        for (const key in this.codeApplyForm) {
          if (Object.hasOwnProperty.call(this.codeApplyForm, key)) {
            const value = this.codeApplyForm[key];
            if (value) {
              resForm.secDTOList.push({ [key]: value });
            }
          }
        }
        this.$emit("submit", resForm);
      } else {
        this.$confirm(
          `该物料已有${resembleQueryList.length}条相似数据,是否继续保存?`,
@@ -444,6 +341,24 @@
          })
          .catch(() => {});
      }
    },
    getDefaultValueAndFormValues(form) {
      let defaultValue = {};
      let formValue = {};
      for (const key in form) {
        if (Object.hasOwnProperty.call(form, key)) {
          const element = form[key];
          if (this.defaultKeys.includes(key)) {
            defaultValue[key] = element;
          } else {
            formValue[key] = element;
          }
        }
      }
      return {
        defaultValue,
        formValue,
      };
    },
    getType(item) {
      return this.selfColumnType[item.sectype];
@@ -489,16 +404,20 @@
          url: "api/ubcs-code/ubcs-code/mdmEngineController/listCodeClassifyValueBySecOid",
          extraParams: {
            classifySecOid: item.oid,
            parentClassifyValueOid: "",
            parentClassifyValueOid: item.parentClassifySecOid
              ? this.codeApplyForm[item.parentClassifySecOid]
              : "",
          },
        };
      } else if (item.sectype == "coderefersec") {
        params = JSON.parse(item.referValueInfo);
      }
      return item.referConfig || params;
      return params;
    },
    getDisabled(item) {
      if (item.sectype === "codeclassifysec") {
        if (item.parentClassifySecOid) {
          if (!this.form[item.parentClassifySecOid]) {
          if (!this.codeApplyForm[item.parentClassifySecOid]) {
            return true;
          } else {
            return false;