UNPKG

cnetong-core-frontend

Version:

- CURD组件的编辑对话框增加按钮slot

64 lines (59 loc) 1.78 kB
import CacheStores from "./CacheStores"; import store from "@/store"; import { Notification } from "element-ui"; function notify() { Notification.success({ title: "成功", message: "系统字典已经更新." }); } export default { // 监听字典改变 async OBSERVER_TOPIC_CACHE_CODE(data) { await store.dispatch("base/refreshSysCode", data.message.codetype); notify(); }, // 监听树改变 async OBSERVER_TOPIC_CACHE_TREE(data) { await CacheStores.codeTreeStore.iterate((value, key, iterationNumber) => { if (key.startsWith(data.message.treetype)) { CacheStores.codeTreeStore.removeItem(key); } }); CacheStores.codeTreeStore.setItem("VERSION", data.message.version); notify(); }, /** * 修正缓存数据 * @param {String } tocpic 要修正的主题 * @param {String} version 检测版本号. */ async repairWith(tocpic, version) { if (!version) { return; } if (!tocpic) { return; } // 树刷新 if (tocpic === "OBSERVER_TOPIC_CACHE_TREE") { let data = await CacheStores.codeTreeStore.getItem("VERSION"); if (data !== version) { CacheStores.codeTreeStore.iterate((value, key, iterationNumber) => { CacheStores.codeTreeStore.removeItem(key); }); } CacheStores.codeTreeStore.setItem("VERSION", version); } // 字典项刷新 if (tocpic === "OBSERVER_TOPIC_CACHE_CODE") { let data = await CacheStores.codeListStore.getItem("VERSION"); if (data !== version) { CacheStores.codeListStore.iterate((value, key, iterationNumber) => { CacheStores.codeListStore.removeItem(key); }); } CacheStores.codeListStore.setItem("VERSION", version); } } };