From fbf4f0990b1f3b4f06a198f47d6513494f690d2c Mon Sep 17 00:00:00 2001
From: 田源 <lastanimals@163.com>
Date: 星期一, 04 十二月 2023 11:50:56 +0800
Subject: [PATCH] 整合代码

---
 Source/UBCS-WEB/src/views/ruleBasic/usableCharacter.vue |  274 ++++++++++++++++++++++++++++++++++++++++--------------
 1 files changed, 204 insertions(+), 70 deletions(-)

diff --git a/Source/UBCS-WEB/src/views/ruleBasic/usableCharacter.vue b/Source/UBCS-WEB/src/views/ruleBasic/usableCharacter.vue
index 0ac88fd..a92827c 100644
--- a/Source/UBCS-WEB/src/views/ruleBasic/usableCharacter.vue
+++ b/Source/UBCS-WEB/src/views/ruleBasic/usableCharacter.vue
@@ -4,7 +4,8 @@
     <el-header>
       <div style="margin-bottom: 15px">
         缂栫爜瑙勫垯锛�
-        <el-select v-model="select" filterable  :filter-method="filterValue" placeholder="璇烽�夋嫨" size="small" @click="selectHandler">
+        <el-select v-model="select" :filter-method="filterValue" filterable placeholder="璇烽�夋嫨" size="small"
+                   @change="selectHandler">
           <el-option v-for="(item,index) in queryReleasedList"
                      :key="item.oid"
                      :label="item.name"
@@ -14,6 +15,7 @@
     </el-header>
     <el-main>
       <el-table
+        v-loading="loading"
         :data="tableData"
         :header-cell-style="{background:'#FAFAFA',color:'#505050'}"
         border
@@ -22,170 +24,194 @@
         <el-table-column
           align="center"
           label="1"
-          prop="aa"
+          prop="1"
         >
         </el-table-column>
         <el-table-column
           align="center"
           label="2"
-          prop="b"
+          prop="2"
         >
         </el-table-column>
         <el-table-column
           align="center"
           label="3"
-          prop="c">
+          prop="3">
         </el-table-column>
         <el-table-column
           align="center"
           label="4"
-          prop="d">
+          prop="4">
         </el-table-column>
         <el-table-column
           align="center"
           label="5"
-          prop="e">
+          prop="5">
         </el-table-column>
         <el-table-column
           align="center"
           label="6"
-          prop="f">
+          prop="6">
         </el-table-column>
         <el-table-column
           align="center"
           label="7"
-          prop="g">
+          prop="7">
         </el-table-column>
         <el-table-column
           align="center"
           label="8"
-          prop="h">
+          prop="8">
         </el-table-column>
         <el-table-column
           align="center"
           label="9"
-          prop="i">
+          prop="9">
         </el-table-column>
         <el-table-column
           align="center"
           label="10"
-          prop="j">
+          prop="10">
         </el-table-column>
         <el-table-column
           align="center"
           label="11"
-          prop="k">
+          prop="11">
         </el-table-column>
         <el-table-column
           align="center"
           label="12"
-          prop="l">
+          prop="12">
         </el-table-column>
         <el-table-column
           align="center"
           label="13"
-          prop="m">
+          prop="13">
         </el-table-column>
         <el-table-column
           align="center"
           label="14"
-          prop="n">
+          prop="14">
         </el-table-column>
         <el-table-column
           align="center"
           label="15"
-          prop="o">
+          prop="15">
         </el-table-column>
       </el-table>
     </el-main>
     <el-footer>
-      <div style="width: 260px; display: flex; align-items: center;margin-top: 5px">
+      <div style="width: 460px; display: flex; align-items: center;margin-top: 5px">
         <p>鍊硷細</p>
-        <el-input v-model="characterValue" size="small" style="flex: 1;"></el-input>
+        <el-input v-model="characterValue" size="small" style="flex: 1; display: flex;">
+          <template slot="prefix">
+            <div style="display: flex; align-items: center;height: 100%;text-align: center;margin-left: 5px">
+              <el-tag v-for="(item,index) in this.editValueList" :key="index" closable size="small"
+                      @close="handleClose(item,index)">
+                {{ item }}
+              </el-tag>
+            </div>
+          </template>
+        </el-input>
       </div>
     </el-footer>
+    <el-dialog :visible.sync="editVisble" append-to-body title="淇敼鍙敤瀛楃" width="40%">
+      <el-input v-model="characterValue" size="small"></el-input>
+      <span slot="footer" class="dialog-footer">
+        <el-button @click="editVisble = false">鍙� 娑�</el-button>
+        <el-button type="primary" @click="editSaveHandler">纭� 瀹�</el-button>
+  </span>
+    </el-dialog>
     <div style="margin-bottom: 10px;text-align: center">
-      <el-button icon="el-icon-plus" plain size="small" type="success">娣诲姞</el-button>
-      <el-button icon="el-icon-edit" plain size="small" type="primary">淇敼</el-button>
-      <el-button icon="el-icon-delete" plain size="small" type="danger">鍒犻櫎</el-button>
+      <el-button icon="el-icon-plus" plain size="small" type="success" @click="addSaveHandler">娣诲姞</el-button>
+      <el-button icon="el-icon-edit" plain size="small" type="primary" @click="editDialog">淇敼</el-button>
+      <el-button icon="el-icon-delete" plain size="small" type="danger" @click="delSaveHandler">鍒犻櫎</el-button>
     </div>
   </basic-container>
 </template>
 
 <script>
-import {getList} from "@/api/code/codeCharcter"
+import {getList, addSave, editSave, deleteSave} from "@/api/code/codeCharcter"
 import {gridCodeRule} from "@/api/code/codeCharcter"
 
 export default {
   name: "usableCharacter",
   data() {
     return {
+      loading: false,
+      editValueList: [],
       //涓嬫媺妗嗘暟缁�
-      queryReleasedList:[],
+      queryReleasedList: [],
       //涓嬫媺妗嗗垵濮嬫暟鎹暟缁�
       characterReleasedList: [],
       characterValue: "",
-      tableData: [
-        {
-          aa: 'a1',
-          b: 'b1',
-          c: 'c1',
-          d: 'd1',
-          e: 'e1',
-          f: 'f1',
-          g: 'b1',
-          h: 'c1',
-          i: 'd1',
-          j: 'e1',
-          k: 'f1',
-          l: 'a1',
-          m: 'b1',
-          n: 'c1',
-          o: 'd1',
-        },
-        {
-          aa: 'a2',
-          b: 'b2',
-          c: 'c2',
-          d: 'd2',
-          e: 'e2',
-          f: 'f2'
-        },
-      ],
+      characterEditOldValue: "",
+      tableData: [],
       select: "",
+      selectValue: "",
+      editVisble: false
     }
   },
-  watch:{
-    select:{
-      handler(newV){
+  watch: {
+    select: {
+      handler(newV) {
         // console.log(newV)
       }
     }
   },
   created() {
-    getList({codeRuleId:"1717377846655193088",chartType:"charset",chartValue:"鏍囧噯瑙勫垯"}).then(res=>{
-      console.log(res)
-    })
-    this.getCodeRule()
+    this.getCodeRule();
   },
   methods: {
-    cellClickHandler(row, column) {
-      console.log(row)
-      console.log(column)
-      console.log(row[column.property])
-      this.characterValue = row[column.property]
+    editDialog() {
+      if (this.editValueList.length > 1) {
+        this.$message.warning('鍙兘閫夋嫨涓�鏉℃暟鎹紒');
+        return;
+      }
+      if (this.editValueList.length === 0) {
+        this.$message.warning('璇烽�夋嫨涓�鏉℃暟鎹紒');
+        return;
+      }
+      this.editVisble = true;
     },
-    getCodeRule() {
-      //缂栫爜瑙勫垯宸插彂甯冩暟鎹簮
-      gridCodeRule({["conditionMap" + "[lcStatus_like]"]: "Released"}).then(res => {
+    handleClose(tag, index) {
+      this.$delete(this.editValueList, index);
+      if (this.editValueList.length === 0) {
+        this.characterValue = "";
+        return;
+      }
+    },
+    cellClickHandler(row, column) {
+      this.characterValue = row[column.property];
+      this.characterEditOldValue = row[column.property];
+      if (this.editValueList.includes(row[column.property])) {
+        this.$message.warning('璇锋鏌ュ瓧绗﹂泦鏄惁鏈夐噸澶嶏紒')
+      } else if (row[column.property] === undefined || row[column.property] === null) {
+        this.$message.warning('璇锋鏌ュ瓧绗﹂泦鏄惁鏈夌┖鍊硷紒');
+      } else {
+        this.editValueList.push(row[column.property]);
+      }
+      // else if (this.editValueList.some(value => value.trim() === '')) {
+      //   this.$message.warning('璇锋鏌ュ瓧绗﹂泦鏄惁鏈夌┖鍊硷紒');
+      // }
+    },
+    async getCodeRule() {
+      try {
+        // 缂栫爜瑙勫垯宸插彂甯冩暟鎹簮
+        const res = await gridCodeRule({["conditionMap" + "[lcStatus_like]"]: "Released"});
         this.characterReleasedList = res.data.data.records;
         this.queryReleasedList = this.characterReleasedList;
-        this.select = this.characterReleasedList[0].name;
-      })
+        this.select = this.characterReleasedList[0].oid;
+        this.loading = true;
+        const res2 = await getList({codeRuleId: this.select, chartType: "charset", chartValue: this.characterValue});
+        this.tableData = res2.data.data;
+        this.loading = false;
+      } catch (error) {
+        this.$message.warning(error)
+      }
     },
     //缂栫爜瑙勫垯涓嬫媺妗嗘悳绱�
     filterValue(query) {
-      console.log(query)
       if (query !== "") {
         this.queryReleasedList = this.characterReleasedList.filter(item => {
           return item.name.includes(query.toString());
@@ -194,8 +220,116 @@
         this.queryReleasedList = this.characterReleasedList;
       }
     },
-    selectHandler(val){
-      console.log(1)
+    selectHandler(val) {
+      this.selectValue = val;
+      this.characterValue = ""
+      this.getTableData()
+    },
+    getTableData() {
+      this.loading = true;
+      // const targetObject = this.characterReleasedList.find(obj => obj.oid === this.selectValue);
+      // const chartValue = targetObject.name;
+      getList({codeRuleId: this.select, chartType: "charset", chartValue: this.characterValue}).then(res => {
+        console.log(res.data.data);
+        this.tableData = res.data.data;
+        this.loading = false;
+      });
+    },
+    addSaveHandler() {
+      if (!this.characterValue) {
+        this.$message.warning('璇峰~鍐欒娣诲姞鐨勫�硷紒');
+        return; // 鍒ゆ柇杈撳叆鍊�
+      }
+      ;
+      if (this.editValueList.length != 0) {
+        this.$message.warning('璇峰厛鍙栨秷宸查�夋嫨鐨勫�硷紒');
+        return; // 鍒ゆ柇杈撳叆鍊�
+      }
+      ;
+      const targetObject = this.characterReleasedList.find(obj => obj.oid === this.select);
+      if (!targetObject) {
+        return; // 鏌ユ壘瀵瑰簲typeText
+      }
+      ;
+      const codeRuleCharacterVO = {
+        codeRuleId: this.select,
+        chartType: "charset",
+        chartValue: this.characterValue,
+        chartTypeText: targetObject.name
+      };
+
+      addSave(codeRuleCharacterVO)
+        .then(res => {
+          this.$message.success(res.data.msg);
+          this.characterValue = "";
+          this.getTableData();
+        }).catch(error => {
+        this.$message.error('娣诲姞澶辫触');
+      });
+    },
+    editSaveHandler() {
+      if (this.characterEditOldValue === "") {
+        this.$message.warning('璇烽�夋嫨淇敼鐨勫�硷紒');
+        return; // 鍒ゆ柇閫夋嫨鍊�
+      }
+
+      if (this.characterValue === "") {
+        this.$message.warning('璇峰~鍐欒淇敼鐨勫�硷紒');
+        return; // 鍒ゆ柇杈撳叆鍊�
+      }
+
+      const targetObject = this.characterReleasedList.find(obj => obj.oid === this.select);
+      if (!targetObject) {
+        return; // 鏌ユ壘瀵瑰簲typeText
+      }
+
+      const codeRuleCharacterVO = {
+        codeRuleId: this.select,
+        chartType: "charset",
+        chartValue: this.characterValue,
+        oldChartValue: this.characterEditOldValue,
+        chartTypeText: targetObject.name
+      };
+
+      editSave(codeRuleCharacterVO)
+        .then(res => {
+          this.$message.success(res.data.msg);
+          this.characterValue = "";
+          this.editVisble = false;
+          this.editValueList = [];
+          this.getTableData();
+        }).catch(error => {
+        this.$message.error('淇敼澶辫触');
+      });
+    },
+    delSaveHandler() {
+      //鍒ゆ柇閫夋嫨鏁版嵁characterEditOldValue
+      if (this.characterEditOldValue === "" || this.characterValue === "") {
+        this.$message.warning('璇烽�夋嫨瑕佸垹闄ょ殑鍊�');
+        return;
+      }
+
+      const targetObject = this.characterReleasedList.find(obj => obj.oid === this.select);
+      if (!targetObject) {
+        return; // 鏌ユ壘瀵瑰簲typeText
+      }
+      const value = this.editValueList.join("");
+      const codeRuleCharacterVO = {
+        codeRuleId: this.select,
+        chartType: "charset",
+        chartValue: value,
+        chartTypeText: targetObject.name
+      };
+
+      deleteSave(codeRuleCharacterVO)
+        .then(res => {
+          this.$message.success(res.data.msg);
+          this.editValueList = [];
+          this.characterValue = "";
+          this.getTableData();
+        }).catch(error => {
+        this.$message.error('鍒犻櫎澶辫触');
+      });
     }
   }
 }

--
Gitblit v1.9.3