Source/UBCS-WEB/src/views/code/code.vue
@@ -404,9 +404,7 @@
                margin-top: 20px;
                display: flex;
                align-items: center;
                justify-content: center;
              "
            >
                justify-content: center;">
              <el-button
                class="button"
                icon="el-icon-circle-plus"
@@ -642,19 +640,35 @@
            <el-form-item
              :label-width="leftFormLabelWidth"
              label="前缀:">
              <el-input
              <!-- <el-input
                v-model="form.prefixCode"
                :readonly="basicSecOnlyRead"
              ></el-input>
              ></el-input> -->
              <el-select v-model="form.prefixCode" :disabled="basicSecOnlyRead">
                <el-option
                  v-for="(option, index) in preFixOrSuffixChars"
                  :key="index"
                  :label="option.label"
                  :value="option.value">
                </el-option>
              </el-select>
            </el-form-item>
            <el-form-item
              :label-width="leftFormLabelWidth"
              label="后缀:">
              <el-input
              <!-- <el-input
                v-model="form.suffixCode"
                :readonly="basicSecOnlyRead">
              </el-input>
              </el-input> -->
              <el-select v-model="form.suffixCode" :disabled="basicSecOnlyRead">
                <el-option
                  v-for="(option, index) in preFixOrSuffixChars"
                  :key="index"
                  :label="option.label"
                  :value="option.value">
                </el-option>
              </el-select>
            </el-form-item>
            <el-form-item :label-width="leftFormLabelWidth" label="描述:">
@@ -838,13 +852,12 @@
                  :disabled="basicSecOnlyRead"
                  filterable
                  placeholder="请选择"
                  @blur="inputSelectBlur"
                >
                  <el-option
                    v-for="item in enumParam.codeFillSeparator"
                    :key="item.dictKey"
                    :label="item.dictValue"
                    :value="item.dictValue"
                    :key="item.lable"
                    :label="item.lable"
                    :value="item.value"
                  >
                  </el-option>
                </el-select>
@@ -1144,13 +1157,12 @@
                  :disabled="basicSecOnlyRead"
                  filterable
                  placeholder="请选择"
                  @blur="inputSelectBlur"
                >
                  <el-option
                    v-for="item in enumParam.codeFillSeparator"
                    :key="item.dictKey"
                    :label="item.dictValue"
                    :value="item.dictValue"
                    :key="item.lable"
                    :label="item.lable"
                    :value="item.value"
                  >
                  </el-option>
                </el-select>
@@ -1333,8 +1345,9 @@
  deleteCodeClassifyValue,
  saveCodeClassifyValueOrder,
} from "@/api/code/codeClassifyValue";
import { getSelectList, getRegexStr } from "@/api/code/codeCharcter"
import {getDictionary} from "@/api/omd/enum";
import {getDictionaryBiz} from "@/api/system/dictbiz";
// import {getDictionaryBiz} from "@/api/system/dictbiz";
import optionBasic from "@/const/code/codebasic";
import optionRule from "@/const/code/mdmrule";
import attrOption from "@/const/code/selectAttrOptionDialog";
@@ -1682,6 +1695,9 @@
      //引用码段中参照配置组件相关参数
      referConfigOption: {},
      referConfigVisble: false,
      preFixOrSuffixChars: [], //前后缀字符列表
    };
  },
  computed: {
@@ -2001,9 +2017,12 @@
      this.codeFixdForm.codeFixedSecOid = row.codefixedsecoid;
    },
    /** 新增码值*/
    addCodeSecValue(condition) {
    async addCodeSecValue(condition) {
      if (condition === "codefixedsec") {
        if (!this.tipsCodeSecValueMessage(this.codeFixdForm.id)) {
          return;
        }
        if(!await this.regexCharacter(this.codeFixdForm.id)){
          return;
        }
        this.codeFixdForm.codeFixedSecOid = this.codefixedsecOrCodeclassifysec.oid;
@@ -2028,6 +2047,9 @@
        if (!this.tipsCodeSecValueMessage(this.codeClassifyForm.id)) {
          return;
        }
        if(!await this.regexCharacter(this.codeClassifyForm.id)){
          return;
        }
        this.codeClassifyForm.codeClassifySecOid =
          this.codefixedsecOrCodeclassifysec.oid;
        addSaveCodeClassifyValue(this.codeClassifyForm).then(
@@ -2050,39 +2072,13 @@
        );
      }
    },
    /** 清空码值表单 */
    clearFixedOrClassifyForm(condition) {
      //点击取消时清空表单与当前选中的码值,并禁用按钮
      this.selectedFixedOrCodeclassifyValue = "";
      if (condition === "close") {
        this.codeFixdForm = this.$options.data().codeFixdForm;
        this.codeClassifyForm = this.$options.data().codeClassifyForm;
      }
      if (condition === "codefixedsec") {
        this.codeFixdForm.description = "";
        this.codeFixdForm.codeFixedSecOid = "";
      } else {
        this.codeClassifyForm = this.$options.data().codeClassifyForm;
      }
    },
    /** 添加或修改码值之前对码值长度根据规则进行校验 */
    tipsCodeSecValueMessage(id) {
      if (id.trim() == "") {
        this.$message.warning("码值不能为空!");
        return false;
      }
      if (id.trim().length > this.codefixedsecOrCodeclassifysec.codeSecLength) {
        this.$message.warning(
          "码值长度不能大于" + this.codefixedsecOrCodeclassifysec.codeSecLength
        );
        return false;
      }
      return true;
    },
    /** 修改码值 */
    editCodeSecValue(condition) {
    async editCodeSecValue(condition) {
      if (condition == "codefixedsec") {
        if (!this.tipsCodeSecValueMessage(this.codeFixdForm.id)) {
          return;
        }
        if(!await this.regexCharacter(this.codeFixdForm.id)){
          return;
        }
        //以前是直接把当前选中行的所有数据都进行提交,但其实只需要传输一些必要参数即可,这儿做了修改,需要传其他参数的请自行添加
@@ -2112,6 +2108,9 @@
        if (!this.tipsCodeSecValueMessage(this.codeClassifyForm.id)) {
          return;
        }
        if(!await this.regexCharacter(this.codeFixdForm.id)){
          return;
        }
        this.codeClassifyForm.oid =
          this.selectedFixedOrCodeclassifyValue.attributes.oid;
        // 分类码段,子分类和父分类之间不能相互更改
@@ -2139,6 +2138,54 @@
          }
        );
      }
    },
    /**
     * 可用字符集码值正则校验
     * @return true:满足限制,false:不满足限制
     */
    async regexCharacter(str){
      var regex = null;
      // 获取到配置好的可用字符正则
      await getRegexStr({codeRuleId: this.selectionList[0].oid,chartType: "charset"}).then(res=>{
        // console.log(res.data.data);
        regex = new RegExp(res.data.data);
      });
      // console.log(regex);
      // console.log(regex.test(str));
      if(regex != "" && !regex.test(str)){
        this.$message.warning("添加的码值未在可用字符集中配置!");
        return false;
      }
      return true;
    },
    /** 清空码值表单 */
    clearFixedOrClassifyForm(condition) {
      //点击取消时清空表单与当前选中的码值,并禁用按钮
      this.selectedFixedOrCodeclassifyValue = "";
      if (condition === "close") {
        this.codeFixdForm = this.$options.data().codeFixdForm;
        this.codeClassifyForm = this.$options.data().codeClassifyForm;
      }
      if (condition === "codefixedsec") {
        this.codeFixdForm.description = "";
        this.codeFixdForm.codeFixedSecOid = "";
      } else {
        this.codeClassifyForm = this.$options.data().codeClassifyForm;
      }
    },
    /** 添加或修改码值之前对码值长度根据规则进行校验 */
    tipsCodeSecValueMessage(id) {
      if (id.trim() == "") {
        this.$message.warning("码值不能为空!");
        return false;
      }
      if (id.trim().length > this.codefixedsecOrCodeclassifysec.codeSecLength) {
        this.$message.warning(
          "码值长度不能大于" + this.codefixedsecOrCodeclassifysec.codeSecLength
        );
        return false;
      }
      return true;
    },
    /** 删除码值 */
    delCodeSecValue(condition) {
@@ -2335,7 +2382,6 @@
    },
    /** 上移下移等操作的保存*/
    async saveCodeFixedOrClassifyValueOption(condition, editOrderNumdata) {
      //保存对固定码段码值的上移下移移出等操作
      if (condition == "fixedValue") {
        let data = {
@@ -2810,7 +2856,18 @@
      //console.log(this.form);
      //为form绑定值
      this.changeSectypeFormItems(condition == "add" ? null : row);
      // 获取前后缀可用字符
      this.loadPreOrSuffixChars();
      // 补位时字符
      // this.loadCodeFillSeparator();
      this.addBasicCodeSettingBox = true;
    },
    /** 获取前后缀字符 */
    loadPreOrSuffixChars(){
      getSelectList({codeRuleId: this.selectionList[0].oid,chartType: "prefix"}).then(res=>{
        this.preFixOrSuffixChars = res.data.data;
        // console.log(this.preFixOrSuffixChars);
      })
    },
    /** 新增基础码段*/
    async saveOrEditBasicCode() {
@@ -3343,12 +3400,12 @@
        this.form.referConfig = "";
      }
    },
    /** 补位时的字符,实现可输可选*/
    inputSelectBlur(e) {
    /** 补位时的字符,实现可输可选 TODO:因为增加了可用字符集控制,所以这儿弃用了可用字符集的效果*/
    /*inputSelectBlur(e) {
      if (e.target.value) {
        this.form.codeFillSeparator = e.target.value;
      }
    },
    },*/
    /** 码段类型改变时,增加对应的form表单中的属性*/
    changeSectypeFormItems(row) {
      //console.log(row)
@@ -3541,7 +3598,7 @@
      if (enumCach == null) {
        getDictionary({code: enumKey}).then((res) => {
          enumCach = res.data.data;
          localStorage.setItem(enumKey, JSON.stringify(res.data.data));
          localStorage.setItem(enumKey, JSON.stringify(enumCach));
        });
      }
      return enumCach;
@@ -3551,7 +3608,7 @@
      this.loadCodeSecType();
      this.loadCodeSecLength();
      this.loadCodeFillType();
      this.loadCodeFillSeparator();
      // this.loadCodeFillSeparator();
      this.loadCodeLevelType();
      this.loadCodeCutType();
      this.loadCodeGetValueType();
@@ -3570,15 +3627,14 @@
    loadCodeFillSeparator() {
      //let enumCach = JSON.parse(localStorage.getItem("codeFillSeparator"));
      //if (enumCach == null) {
      getDictionaryBiz({code: "codeFillSeparator"}).then((res) => {
      getSelectList({codeRuleId: this.selectionList[0].oid,chartType: "fillerChar"}).then((res) => {
        this.enumParam.codeFillSeparator = res.data.data;
        //console.log(this.enumParam.codeFillSeparator);
        localStorage.setItem(
          "codeFillSeparator",
          JSON.stringify(res.data.data)
        );
        // localStorage.setItem(
        //   "codeFillSeparator",
        //   JSON.stringify(res.data.data)
        // );
      });
      //}
    },
    loadCodeLevelType() {
      this.enumParam.codeLevelType = this.getLocalStorageEnum("codeLevelType") || [];