From 8e93a889280064483b901959e3b42f966d0ad371 Mon Sep 17 00:00:00 2001
From: wangting <wangting@vci-tech.com>
Date: 星期二, 24 十二月 2024 14:30:13 +0800
Subject: [PATCH] 图标管理,图标选择组件,图标显示组件

---
 Source/plt-web/plt-web-ui/src/components/PLT-basic-component/input-icon.vue |   72 ++++++++++++++++++++++-------------
 1 files changed, 45 insertions(+), 27 deletions(-)

diff --git a/Source/plt-web/plt-web-ui/src/components/PLT-basic-component/input-icon.vue b/Source/plt-web/plt-web-ui/src/components/PLT-basic-component/input-icon.vue
index 156d397..6c25d75 100644
--- a/Source/plt-web/plt-web-ui/src/components/PLT-basic-component/input-icon.vue
+++ b/Source/plt-web/plt-web-ui/src/components/PLT-basic-component/input-icon.vue
@@ -2,7 +2,7 @@
   <div>
     <el-input :width="width" :class="inputClass" :style="inputStyle" :clearable="true" :value="value"
               :disabled="disabled" :placeholder="placeholder" type="text" :size="size" @clear="clearValue" @focus="handleFocus">
-      <span slot="append" v-html="svgHtml"></span>
+      <span slot="append" v-html="svgHtml" style="font-size: 18px;height:18px;display: block"></span>
     </el-input>
     <el-dialog v-dialogDrag
                v-dialog-resize
@@ -17,10 +17,10 @@
           <span class="tag-group__title">鍒嗙被</span>
           <el-tag
             v-for="item in types"
-            :key="item.value"
-            :type="checkedTypes.includes(item.value)?'success':'info'" size="small"
-            effect="plain" @click="changeType(item.value)">
-            {{ item.label }}
+            :key="item.key"
+            :type="checkedTypes.includes(item.key)?'success':'info'" size="small"
+            effect="plain" @click="changeType(item.key)">
+            {{ item.value }}
           </el-tag>
         </div>
         <avue-input v-model="searchText" @change="handleSearch" placeholder="鏌ヨ" size="mini" prefixIcon="el-icon-search" style="width: 300px;max-width: 30%"></avue-input>
@@ -30,8 +30,8 @@
           <el-tab-pane v-for="item in iconList" :label="item.lable" :name="item.lable" style="height: calc(60vh - 80px);;overflow: auto ">
             <div class="iconList">
               <div class="iconItem" v-for="svg in item.list" :data-value="svg.name" @click="checkSvg(svg,item.lable)">
-                <div v-html="svg.content"></div>
-                <!--<span>{{svg.name.split(':')[1]}}</span>-->
+                <div class="svgContent" v-html="svg.content"></div>
+                <span>{{svg.name.split(':')[1]}}</span>
               </div>
             </div>
           </el-tab-pane>
@@ -47,6 +47,7 @@
 import func from "@/util/func";
 import store from "@/store";
 import {getIcons} from "@/api/UI/Icons";
+import {getDicts} from "@/api/system/dict";
 
 export default {
   name: "input-icon",
@@ -79,16 +80,7 @@
   data(){
     return {
       visible: false,
-      types: [{
-        label:'鎸夐挳',
-        value:0
-      },{
-        label:'鏍囩浜�',
-        value:1
-      },{
-        label:'鏍囩涓�',
-        value:2
-      }],
+      types: [],
       checkedTypes:[],
       searchText:'',
       activeName:'',
@@ -105,6 +97,7 @@
     }
   },
   created(){
+    this.getGroups();
     if (!validatenull(this.$store.state.icons)) {
       this.iconList = this.$store.state.icons;
     } else {
@@ -115,16 +108,31 @@
       this.activeName=this.iconList[0].lable;
     }else {
       getIcons().then(res => {
-        this.iconList=res.data.data;
-        this.allIconList=this.iconList;
-        store.dispatch("setIcons", this.iconList);
-        if(this.iconList&&this.iconList.length>0) {
-          this.activeName=this.iconList[0].lable;
+        if (res.data.success) {
+          this.iconList = res.data.data;
+          this.allIconList = this.iconList;
+          store.dispatch("setIcons", this.iconList);
+          if (this.iconList.length > 0) {
+            this.activeName = this.iconList[0].lable;
+          }
+        } else {
+          this.$message.error(res.data.msg);
         }
       })
     }
+
+    this.svgHtml=func.getSVGByName(this.value);
   },
   methods:{
+    getGroups() {
+      getDicts('EnumIconGroups').then(res => {
+        if (res.data.success) {
+          this.types = res.data.obj;
+        } else {
+          this.$message.error(res.data.msg);
+        }
+      })
+    },
     dialogClose() {
       this.visible = false;
     },
@@ -148,9 +156,16 @@
         this.iconList=this.allIconList
       }else{
         const checkedTypes=JSON.stringify(this.checkedTypes);
-        this.iconList=this.allIconList.filter(item=> {
-          return checkedTypes.indexOf(JSON.stringify(item.groups))!=-1;
+        const iconList=[];
+        this.allIconList.forEach(item=>{
+          iconList.push({
+            lable:item.lable,
+            list:item.list.filter(iconitem=> {
+              return checkedTypes.indexOf(iconitem.groups)!=-1;
+            })
+          })
         })
+        this.iconList=iconList;
       }
       this.activeName=this.iconList[0].lable;
     },
@@ -197,11 +212,14 @@
   flex-wrap: wrap;
 }
 .iconList .iconItem{
-  width: 65px;
-  margin: 6px;
+  width: 85px;
+  margin: 6px 5px 10px 5px;
   text-align: center;
 }
-.iconList .iconItem div:hover{
+.iconList .iconItem .svgContent{
+  font-size: 24px;
+}
+.iconList .iconItem .svgContent:hover{
   transform: scale(1.5);
 }
 .iconList .iconItem span{

--
Gitblit v1.9.3