From a56c7f5fbe4b171a82561dce3b3b0ff6c5c30386 Mon Sep 17 00:00:00 2001
From: ludc
Date: 星期一, 22 一月 2024 17:30:58 +0800
Subject: [PATCH] 可用字符集,前后缀,应用,可以用字符集接口下拉和正则接口提交

---
 Source/UBCS-WEB/src/views/code/code.vue |  174 ++++++++++++++++++++++++++++++++++++++-------------------
 1 files changed, 115 insertions(+), 59 deletions(-)

diff --git a/Source/UBCS-WEB/src/views/code/code.vue b/Source/UBCS-WEB/src/views/code/code.vue
index 652c87d..8847b03 100644
--- a/Source/UBCS-WEB/src/views/code/code.vue
+++ b/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:婊¤冻闄愬埗锛宖alse锛氫笉婊¤冻闄愬埗
+     */
+    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);
       //涓篺orm缁戝畾鍊�
       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;
       }
-    },
+    },*/
     /** 鐮佹绫诲瀷鏀瑰彉鏃讹紝澧炲姞瀵瑰簲鐨刦orm琛ㄥ崟涓殑灞炴��*/
     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") || [];

--
Gitblit v1.9.3