feat: 字典配置前端代码.

This commit is contained in:
lijiahang
2023-10-20 18:45:21 +08:00
parent 437614f026
commit bd02ce1dd0
34 changed files with 226 additions and 570 deletions

View File

@@ -2,12 +2,12 @@
<div class="layout-container">
<!-- 列表-表格 -->
<dict-value-table ref="table"
@openAdd="() => modal.openAdd()"
@openUpdate="(e) => modal.openUpdate(e)" />
@openAdd="() => modal.openAdd()"
@openUpdate="(e) => modal.openUpdate(e)" />
<!-- 添加修改模态框 -->
<dict-value-form-modal ref="modal"
@added="modalAddCallback"
@updated="modalUpdateCallback" />
@added="modalAddCallback"
@updated="modalUpdateCallback" />
</div>
</template>
@@ -21,10 +21,15 @@
import DictValueTable from './components/dict-value-table.vue';
import DictValueFormModal from './components/dict-value-form-modal.vue';
import { ref } from 'vue';
import { onUnmounted, ref } from 'vue';
import { useCacheStore } from '@/store';
import { getDictKeyList } from '@/api/system/dict-key';
import { getTagList } from '@/api/meta/tag';
import { Message } from '@arco-design/web-vue';
const table = ref();
const modal = ref();
const cacheStore = useCacheStore();
// 添加回调
const modalAddCallback = () => {
@@ -36,6 +41,23 @@
table.value.updatedCallback();
};
// 加载字典配置项
const loadDictKeys = async () => {
try {
const { data } = await getDictKeyList();
// 设置到缓存
cacheStore.set('dictKeys', data);
} catch {
Message.error('配置项加载失败');
}
};
loadDictKeys();
// 卸载时清除 cache
onUnmounted(() => {
cacheStore.set('dictKeys', []);
});
</script>
<style lang="less" scoped>