Files
orion-visor/orion-ops-ui/src/views/system/dict-value/index.vue

71 lines
1.7 KiB
Vue
Raw Normal View History

2023-10-20 17:07:53 +08:00
<template>
<div class="layout-container" v-if="render">
2023-10-20 17:07:53 +08:00
<!-- 列表-表格 -->
<dict-value-table ref="table"
2023-10-20 18:45:21 +08:00
@openAdd="() => modal.openAdd()"
@openUpdate="(e) => modal.openUpdate(e)" />
2023-10-20 17:07:53 +08:00
<!-- 添加修改模态框 -->
<dict-value-form-modal ref="modal"
2023-10-20 18:45:21 +08:00
@added="modalAddCallback"
@updated="modalUpdateCallback" />
2023-10-20 17:07:53 +08:00
</div>
</template>
<script lang="ts">
export default {
name: 'systemDictValue'
};
</script>
<script lang="ts" setup>
import DictValueTable from './components/dict-value-table.vue';
import DictValueFormModal from './components/dict-value-form-modal.vue';
import { ref, onBeforeMount, onUnmounted } from 'vue';
2023-10-20 18:45:21 +08:00
import { useCacheStore } from '@/store';
import { getDictKeyList } from '@/api/system/dict-key';
import { Message } from '@arco-design/web-vue';
2023-10-20 17:07:53 +08:00
const render = ref(false);
2023-10-20 17:07:53 +08:00
const table = ref();
const modal = ref();
2023-10-20 18:45:21 +08:00
const cacheStore = useCacheStore();
2023-10-20 17:07:53 +08:00
// 添加回调
const modalAddCallback = () => {
table.value.addedCallback();
};
// 修改回调
const modalUpdateCallback = () => {
table.value.updatedCallback();
};
2023-10-20 18:45:21 +08:00
// 加载字典配置项
const loadDictKeys = async () => {
try {
const { data } = await getDictKeyList();
// 设置到缓存
cacheStore.set('dictKeys', data);
} catch {
Message.error('配置项加载失败');
}
};
onBeforeMount(async () => {
// 加载字典值
await loadDictKeys();
render.value = true;
});
2023-10-20 18:45:21 +08:00
// 卸载时清除 cache
onUnmounted(() => {
cacheStore.reset('dictKeys');
2023-10-20 18:45:21 +08:00
});
2023-10-20 17:07:53 +08:00
</script>
<style lang="less" scoped>
</style>