zouzs 2 долоо хоног өмнө
parent
commit
2bb5f3ed70

+ 10 - 0
src/api/system/dict.ts

@@ -146,3 +146,13 @@ export const getDictDataByType = (dictType: string) => {
     baseUrlApi(`system/dict/data/type/${dictType}`)
   );
 };
+
+/**
+ * 刷新字典缓存
+ */
+export const refreshDictCache = () => {
+  return http.request<BasicResponseModel>(
+    "delete",
+    baseUrlApi("system/dict/type/refreshCache")
+  );
+};

+ 19 - 1
src/views/system/dict/index.vue

@@ -1,7 +1,7 @@
 <script setup lang="ts">
 import { isString } from "@pureadmin/utils";
 import { useMultiTagsStoreHook } from "@/store/modules/multiTags";
-import { useRouter, useRoute } from "vue-router";
+import { useRouter } from "vue-router";
 import {
   type PlusColumn,
   PlusDialogForm,
@@ -14,6 +14,7 @@ import {
   deleteSystemDictType,
   getSystemDictById,
   getSystemDictList,
+  refreshDictCache,
   updateSystemDictType
 } from "@/api/system/dict";
 import { computed, reactive, ref, toRefs } from "vue";
@@ -41,6 +42,20 @@ const refresh = () => {
   plusPageInstance.value?.getList();
 };
 
+const handleRefresh = async () => {
+  try {
+    let res = await refreshDictCache();
+    if (res.code === 200) {
+      ElMessage.success("刷新缓存成功");
+      refresh();
+    } else {
+      ElMessage.error(res.msg);
+    }
+  } catch (e) {
+    ElMessage.error("刷新缓存失败");
+  }
+};
+
 const dialogTitle = computed(() => (state.isCreate ? "新增" : "编辑"));
 
 const tableConfig: PlusColumn[] = [
@@ -303,6 +318,9 @@ const { form, confirmLoading, rules, dialogVisible } = toRefs(state);
           <el-button size="default" type="success" @click="handleCreate">
             新增
           </el-button>
+          <el-button size="default" type="default" @click="handleRefresh">
+            刷新缓存
+          </el-button>
         </el-row>
       </template>
     </PlusPage>

+ 2 - 3
src/views/system/logininfor/index.vue

@@ -1,14 +1,13 @@
 <script setup lang="ts">
 import {
   type PlusColumn,
-  type OptionsRow,
   PlusPage,
   PlusDialog,
   PlusDescriptions,
   PlusPageInstance,
   useTable
 } from "plus-pro-components";
-import { computed, reactive, type Ref, ref, toRefs } from "vue";
+import { computed, reactive, ref, toRefs } from "vue";
 import { useDict, useDictClass, useDictValue } from "@/utils/dict";
 import { ElMessage, ElMessageBox } from "element-plus";
 import {
@@ -21,7 +20,7 @@ defineOptions({
   name: "Logininfor"
 });
 
-const { sys_common_status } = useDict("sys_common_status", "sys_oper_type");
+const { sys_common_status } = useDict("sys_common_status");
 
 const plusPageInstance = ref<PlusPageInstance | null>(null);