From 9f70a1ee5cdffaef3a96e4042c8eea251df2fa0d Mon Sep 17 00:00:00 2001
From: wupengfei <834520024@qq.com>
Date: 星期三, 06 八月 2025 17:21:56 +0800
Subject: [PATCH] feat: 字典

---
 src/views/DictionaryManage/DictionaryCategoryManage.vue             |    5 ++++-
 src/hooks/dic.ts                                                    |   14 ++++++++++++++
 src/views/DictionaryManage/DataDictionary.vue                       |    6 +++---
 src/views/DictionaryManage/components/AddOrEditDictionaryDialog.vue |    4 ++--
 4 files changed, 23 insertions(+), 6 deletions(-)

diff --git a/src/hooks/dic.ts b/src/hooks/dic.ts
index ee037f2..8543fa8 100644
--- a/src/hooks/dic.ts
+++ b/src/hooks/dic.ts
@@ -25,6 +25,12 @@
     });
   }
 
+  function updateDictionaryCategorySelect() {
+    queryClient.invalidateQueries({
+      queryKey: ['dictionaryServices/getDictionaryCategorySelect'],
+    });
+  }
+
   function getDictionaryCategoryById(id: string) {
     return dictionaryCategoryList.value.find((x) => x.value === id);
   }
@@ -43,6 +49,7 @@
     getDictionaryCategoryById,
     getDictionaryCategoryNameByCode,
     getDictionaryCategoryByCode,
+    updateDictionaryCategorySelect,
   };
 }
 
@@ -96,6 +103,12 @@
     });
   }
 
+  function updateDictionaryDataSelect() {
+    queryClient.invalidateQueries({
+      queryKey: ['dictionaryServices/getDictionaryDataSelect'],
+    });
+  }
+
   return {
     dictionaryDataList,
     ensureQueryData,
@@ -103,5 +116,6 @@
     getDictionaryDataNameById,
     getDictionaryDataNameByCode,
     getDictionaryDataByCode,
+    updateDictionaryDataSelect,
   };
 }
diff --git a/src/views/DictionaryManage/DataDictionary.vue b/src/views/DictionaryManage/DataDictionary.vue
index de06a45..febbb11 100644
--- a/src/views/DictionaryManage/DataDictionary.vue
+++ b/src/views/DictionaryManage/DataDictionary.vue
@@ -86,10 +86,9 @@
   operationBtnMap,
 });
 
-const { dictionaryCategoryList, ensureQueryData, getDictionaryCategoryNameByCode } =
-  useGetDictionaryCategorySelect();
+const { dictionaryCategoryList, ensureQueryData } = useGetDictionaryCategorySelect();
 
-const { getDictionaryDataNameByCode } = useDictionaryDataSelect({
+const { getDictionaryDataNameByCode, updateDictionaryDataSelect } = useDictionaryDataSelect({
   categoryCode: CategoryCode.IndustryCategory,
 });
 
@@ -202,6 +201,7 @@
     let res = await dictionaryServices.saveDictionaryData(params);
     if (res) {
       Message.successMessage('鎿嶄綔鎴愬姛');
+      updateDictionaryDataSelect();
       getList(paginationState.pageIndex);
       dialogState.dialogVisible = false;
     }
diff --git a/src/views/DictionaryManage/DictionaryCategoryManage.vue b/src/views/DictionaryManage/DictionaryCategoryManage.vue
index b110d7b..973e21b 100644
--- a/src/views/DictionaryManage/DictionaryCategoryManage.vue
+++ b/src/views/DictionaryManage/DictionaryCategoryManage.vue
@@ -62,6 +62,7 @@
   operationBtnMap,
 });
 
+const { updateDictionaryCategorySelect } = useGetDictionaryCategorySelect();
 const BaseState = {
   loading: true,
 };
@@ -121,7 +122,7 @@
   }
 }
 
-const { dialogProps, handleAdd, handleEdit, editForm } = useFormDialog({
+const { dialogProps, handleAdd, handleEdit, editForm, dialogState } = useFormDialog({
   onConfirm: handleAddOrEdit,
   defaultFormParams: {
     id: '',
@@ -146,7 +147,9 @@
     let res = await dictionaryServices.saveDictionaryCategory(params);
     if (res) {
       Message.successMessage('鎿嶄綔鎴愬姛');
+      updateDictionaryCategorySelect();
       getList(paginationState.pageIndex);
+      dialogState.dialogVisible = false;
     }
   } catch (error) {}
 }
diff --git a/src/views/DictionaryManage/components/AddOrEditDictionaryDialog.vue b/src/views/DictionaryManage/components/AddOrEditDictionaryDialog.vue
index 9784ece..ba5d3ca 100644
--- a/src/views/DictionaryManage/components/AddOrEditDictionaryDialog.vue
+++ b/src/views/DictionaryManage/components/AddOrEditDictionaryDialog.vue
@@ -10,7 +10,7 @@
       <ProFormItemV2
         label="琛屼笟绫诲瀷:"
         prop="field1"
-        v-if="category?.data?.code === '30'"
+        v-if="category?.data?.code === CategoryCode.Position"
         :check-rules="[{ message: '璇烽�夋嫨琛屼笟绫诲瀷' }]"
       >
         <ProFormSelect
@@ -37,7 +37,7 @@
       <ProFormItemV2 label="缂栧彿:" prop="code">
         <ProFormText v-model.trim="form.code"></ProFormText>
       </ProFormItemV2>
-      <ProFormItemV2 label="鍥剧墖:" prop="src" v-if="category?.data?.code === '50'">
+      <ProFormItemV2 label="鍥剧墖:" prop="src" v-if="category?.data?.code === CategoryCode.Welfare">
         <ProFormImageUpload v-model:file-url="form.field2" :limitFileCount="1"></ProFormImageUpload>
       </ProFormItemV2>
       <ProFormItemV2 label="鐘舵��:" prop="status">

--
Gitblit v1.9.1