From c334c2d76c1b51d0fbe1531bf524e1b90f921a7c Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期二, 20 五月 2025 15:16:39 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/dev' into dev

---
 src/views/system/dict/data.vue |  191 ++++++++++++++++++++++++-----------------------
 1 files changed, 99 insertions(+), 92 deletions(-)

diff --git a/src/views/system/dict/data.vue b/src/views/system/dict/data.vue
index aa52991..f4e2c6f 100644
--- a/src/views/system/dict/data.vue
+++ b/src/views/system/dict/data.vue
@@ -1,8 +1,8 @@
 <template>
    <div class="app-container">
-      <el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch" label-width="68px">
+      <el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch">
          <el-form-item label="瀛楀吀鍚嶇О" prop="dictType">
-            <el-select v-model="queryParams.dictType">
+            <el-select v-model="queryParams.dictType" style="width: 200px">
                <el-option
                   v-for="item in typeOptions"
                   :key="item.dictId"
@@ -16,11 +16,12 @@
                v-model="queryParams.dictLabel"
                placeholder="璇疯緭鍏ュ瓧鍏告爣绛�"
                clearable
+               style="width: 200px"
                @keyup.enter="handleQuery"
             />
          </el-form-item>
          <el-form-item label="鐘舵��" prop="status">
-            <el-select v-model="queryParams.status" placeholder="鏁版嵁鐘舵��" clearable>
+            <el-select v-model="queryParams.status" placeholder="鏁版嵁鐘舵��" clearable style="width: 200px">
                <el-option
                   v-for="dict in sys_normal_disable"
                   :key="dict.value"
@@ -90,8 +91,8 @@
          <el-table-column label="瀛楀吀缂栫爜" align="center" prop="dictCode" />
          <el-table-column label="瀛楀吀鏍囩" align="center" prop="dictLabel">
             <template #default="scope">
-               <span v-if="scope.row.listClass == '' || scope.row.listClass == 'default'">{{ scope.row.dictLabel }}</span>
-               <el-tag v-else :type="scope.row.listClass == 'primary' ? '' : scope.row.listClass">{{ scope.row.dictLabel }}</el-tag>
+               <span v-if="(scope.row.listClass == '' || scope.row.listClass == 'default') && (scope.row.cssClass == '' || scope.row.cssClass == null)">{{ scope.row.dictLabel }}</span>
+               <el-tag v-else :type="scope.row.listClass == 'primary' ? '' : scope.row.listClass" :class="scope.row.cssClass">{{ scope.row.dictLabel }}</el-tag>
             </template>
          </el-table-column>
          <el-table-column label="瀛楀吀閿��" align="center" prop="dictValue" />
@@ -107,20 +108,10 @@
                <span>{{ parseTime(scope.row.createTime) }}</span>
             </template>
          </el-table-column>
-         <el-table-column label="鎿嶄綔" align="center" width="150" class-name="small-padding fixed-width">
+         <el-table-column label="鎿嶄綔" align="center" width="160" class-name="small-padding fixed-width">
             <template #default="scope">
-               <el-button
-                  type="text"
-                  icon="Edit"
-                  @click="handleUpdate(scope.row)"
-                  v-hasPermi="['system:dict:edit']"
-               >淇敼</el-button>
-               <el-button
-                  type="text"
-                  icon="Delete"
-                  @click="handleDelete(scope.row)"
-                  v-hasPermi="['system:dict:remove']"
-               >鍒犻櫎</el-button>
+               <el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['system:dict:edit']">淇敼</el-button>
+               <el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)" v-hasPermi="['system:dict:remove']">鍒犻櫎</el-button>
             </template>
          </el-table-column>
       </el-table>
@@ -156,7 +147,7 @@
                   <el-option
                      v-for="item in listClassOptions"
                      :key="item.value"
-                     :label="item.label"
+                     :label="item.label + '(' + item.value + ')'"
                      :value="item.value"
                   ></el-option>
                </el-select>
@@ -166,7 +157,7 @@
                   <el-radio
                      v-for="dict in sys_normal_disable"
                      :key="dict.value"
-                     :label="dict.value"
+                     :value="dict.value"
                   >{{ dict.label }}</el-radio>
                </el-radio-group>
             </el-form-item>
@@ -185,24 +176,25 @@
 </template>
 
 <script setup name="Data">
-import { optionselect as getDictOptionselect, getType } from "@/api/system/dict/type";
-import { listData, getData, delData, addData, updateData } from "@/api/system/dict/data";
+import useDictStore from '@/store/modules/dict'
+import { optionselect as getDictOptionselect, getType } from "@/api/system/dict/type"
+import { listData, getData, delData, addData, updateData } from "@/api/system/dict/data"
 
-const { proxy } = getCurrentInstance();
-const { sys_normal_disable } = proxy.useDict("sys_normal_disable");
+const { proxy } = getCurrentInstance()
+const { sys_normal_disable } = proxy.useDict("sys_normal_disable")
 
-const dataList = ref([]);
-const open = ref(false);
-const loading = ref(true);
-const showSearch = ref(true);
-const ids = ref([]);
-const single = ref(true);
-const multiple = ref(true);
-const total = ref(0);
-const title = ref("");
-const defaultDictType = ref("");
-const typeOptions = ref([]);
-const route = useRoute();
+const dataList = ref([])
+const open = ref(false)
+const loading = ref(true)
+const showSearch = ref(true)
+const ids = ref([])
+const single = ref(true)
+const multiple = ref(true)
+const total = ref(0)
+const title = ref("")
+const defaultDictType = ref("")
+const typeOptions = ref([])
+const route = useRoute()
 // 鏁版嵁鏍囩鍥炴樉鏍峰紡
 const listClassOptions = ref([
   { value: "default", label: "榛樿" }, 
@@ -211,15 +203,15 @@
   { value: "info", label: "淇℃伅" },
   { value: "warning", label: "璀﹀憡" },
   { value: "danger", label: "鍗遍櫓" }
-]);
+])
 
 const data = reactive({
   form: {},
   queryParams: {
     pageNum: 1,
     pageSize: 10,
-    dictName: undefined,
     dictType: undefined,
+    dictLabel: undefined,
     status: undefined
   },
   rules: {
@@ -227,39 +219,42 @@
     dictValue: [{ required: true, message: "鏁版嵁閿�间笉鑳戒负绌�", trigger: "blur" }],
     dictSort: [{ required: true, message: "鏁版嵁椤哄簭涓嶈兘涓虹┖", trigger: "blur" }]
   }
-});
+})
 
-const { queryParams, form, rules } = toRefs(data);
+const { queryParams, form, rules } = toRefs(data)
 
 /** 鏌ヨ瀛楀吀绫诲瀷璇︾粏 */
 function getTypes(dictId) {
   getType(dictId).then(response => {
-    queryParams.value.dictType = response.data.dictType;
-    defaultDictType.value = response.data.dictType;
-    getList();
-  });
+    queryParams.value.dictType = response.data.dictType
+    defaultDictType.value = response.data.dictType
+    getList()
+  })
 }
 
 /** 鏌ヨ瀛楀吀绫诲瀷鍒楄〃 */
 function getTypeList() {
   getDictOptionselect().then(response => {
-    typeOptions.value = response.data;
-  });
+    typeOptions.value = response.data
+  })
 }
+
 /** 鏌ヨ瀛楀吀鏁版嵁鍒楄〃 */
 function getList() {
-  loading.value = true;
+  loading.value = true
   listData(queryParams.value).then(response => {
-    dataList.value = response.rows;
-    total.value = response.total;
-    loading.value = false;
-  });
+    dataList.value = response.rows
+    total.value = response.total
+    loading.value = false
+  })
 }
+
 /** 鍙栨秷鎸夐挳 */
 function cancel() {
-  open.value = false;
-  reset();
+  open.value = false
+  reset()
 }
+
 /** 琛ㄥ崟閲嶇疆 */
 function reset() {
   form.value = {
@@ -271,85 +266,97 @@
     dictSort: 0,
     status: "0",
     remark: undefined
-  };
-  proxy.resetForm("dataRef");
+  }
+  proxy.resetForm("dataRef")
 }
+
 /** 鎼滅储鎸夐挳鎿嶄綔 */
 function handleQuery() {
-  queryParams.value.pageNum = 1;
-  getList();
+  queryParams.value.pageNum = 1
+  getList()
 }
+
 /** 杩斿洖鎸夐挳鎿嶄綔 */
 function handleClose() {
-  const obj = { path: "/system/dict" };
-  proxy.$tab.closeOpenPage(obj);
+  const obj = { path: "/system/dict" }
+  proxy.$tab.closeOpenPage(obj)
 }
+
 /** 閲嶇疆鎸夐挳鎿嶄綔 */
 function resetQuery() {
-  proxy.resetForm("queryRef");
-  queryParams.value.dictType = defaultDictType;
-  handleQuery();
+  proxy.resetForm("queryRef")
+  queryParams.value.dictType = defaultDictType.value
+  handleQuery()
 }
+
 /** 鏂板鎸夐挳鎿嶄綔 */
 function handleAdd() {
-  reset();
-  open.value = true;
-  title.value = "娣诲姞瀛楀吀鏁版嵁";
-  form.value.dictType = queryParams.value.dictType;
+  reset()
+  open.value = true
+  title.value = "娣诲姞瀛楀吀鏁版嵁"
+  form.value.dictType = queryParams.value.dictType
 }
+
 /** 澶氶�夋閫変腑鏁版嵁 */
 function handleSelectionChange(selection) {
-  ids.value = selection.map(item => item.dictCode);
-  single.value = selection.length != 1;
-  multiple.value = !selection.length;
+  ids.value = selection.map(item => item.dictCode)
+  single.value = selection.length != 1
+  multiple.value = !selection.length
 }
+
 /** 淇敼鎸夐挳鎿嶄綔 */
 function handleUpdate(row) {
-  reset();
-  const dictCode = row.dictCode || ids.value;
+  reset()
+  const dictCode = row.dictCode || ids.value
   getData(dictCode).then(response => {
-    form.value = response.data;
-    open.value = true;
-    title.value = "淇敼瀛楀吀鏁版嵁";
-  });
+    form.value = response.data
+    open.value = true
+    title.value = "淇敼瀛楀吀鏁版嵁"
+  })
 }
+
 /** 鎻愪氦鎸夐挳 */
 function submitForm() {
   proxy.$refs["dataRef"].validate(valid => {
     if (valid) {
       if (form.value.dictCode != undefined) {
         updateData(form.value).then(response => {
-          proxy.$modal.msgSuccess("淇敼鎴愬姛");
-          open.value = false;
-          getList();
-        });
+          useDictStore().removeDict(queryParams.value.dictType)
+          proxy.$modal.msgSuccess("淇敼鎴愬姛")
+          open.value = false
+          getList()
+        })
       } else {
         addData(form.value).then(response => {
-          proxy.$modal.msgSuccess("鏂板鎴愬姛");
-          open.value = false;
-          getList();
-        });
+          useDictStore().removeDict(queryParams.value.dictType)
+          proxy.$modal.msgSuccess("鏂板鎴愬姛")
+          open.value = false
+          getList()
+        })
       }
     }
-  });
+  })
 }
+
 /** 鍒犻櫎鎸夐挳鎿嶄綔 */
 function handleDelete(row) {
-  const dictCodes = row.dictCode || ids.value;
+  const dictCodes = row.dictCode || ids.value
   proxy.$modal.confirm('鏄惁纭鍒犻櫎瀛楀吀缂栫爜涓�"' + dictCodes + '"鐨勬暟鎹」锛�').then(function() {
-    return delData(dictCodes);
+    return delData(dictCodes)
   }).then(() => {
-    getList();
-    proxy.$modal.msgSuccess("鍒犻櫎鎴愬姛");
-  }).catch(() => {});
+    getList()
+    proxy.$modal.msgSuccess("鍒犻櫎鎴愬姛")
+    useDictStore().removeDict(queryParams.value.dictType)
+  }).catch(() => {})
 }
+
 /** 瀵煎嚭鎸夐挳鎿嶄綔 */
 function handleExport() {
   proxy.download("system/dict/data/export", {
     ...queryParams.value
-  }, `dict_data_${new Date().getTime()}.xlsx`);
+  }, `dict_data_${new Date().getTime()}.xlsx`)
 }
 
-getTypes(route.params && route.params.dictId);
-getTypeList();
+getTypes(route.params && route.params.dictId)
+getTypeList()
 </script>

--
Gitblit v1.9.3