feat-wip(components): 数据字典相关页面代码提交

This commit is contained in:
Azir-11
2025-12-04 16:03:02 +08:00
committed by 姜永春
parent 40f3f7589b
commit 2736c178c5
6 changed files with 12 additions and 98 deletions

View File

@ -47,7 +47,8 @@ const local: App.I18n.Schema = {
yesOrNo: {
yes: 'Yes',
no: 'No'
}
},
children: 'Children'
},
request: {
logout: 'Logout user after request failed',

View File

@ -47,7 +47,8 @@ const local: App.I18n.Schema = {
yesOrNo: {
yes: '是',
no: '否'
}
},
children: '子项'
},
request: {
logout: '请求失败后登出用户',

View File

@ -318,6 +318,7 @@ export const useTabStore = defineStore(SetupStoreId.Tab, () => {
/** All tabs */
tabs: allTabs,
activeTabId,
homeTab,
initHomeTab,
initTabStore,
addTab,

View File

@ -357,6 +357,7 @@ declare namespace App {
yes: string;
no: string;
};
children: string;
};
request: {
logout: string;

View File

@ -82,6 +82,9 @@ const { columns, columnChecks, data, loading, getData, getDataByPage, mobilePagi
align: 'center',
render: row => (
<div class="flex-center gap-8px">
<NButton type="success" ghost size="small" onClick={() => handleOpenChildren(row.id)}>
{$t('common.children')}
</NButton>
<NButton type="primary" ghost size="small" onClick={() => edit(row.id)}>
{$t('common.edit')}
</NButton>
@ -119,6 +122,8 @@ function handleDelete(id: string) {
function edit(id: string) {
handleEdit(id);
}
function handleOpenChildren(_: string) {}
</script>
<template>

View File

@ -1,7 +1,5 @@
<script setup lang="ts">
import { computed, ref, watch } from 'vue';
import type { DataTableColumns } from 'naive-ui';
import { cloneDeep } from 'lodash-es';
import { jsonClone } from '@sa/utils';
import { dictionaryTypeOptions } from '@/constants/sys/core/dictionary';
import { fetchDictionaryAdd, fetchDictionaryEdit } from '@/service/api';
@ -91,90 +89,10 @@ async function handleSubmit() {
});
}
function handleAddDictionaryItem() {}
const dictionaryItemData: Api.Sys.Core.DictionaryItem[] = [
{
id: '07',
name: '07akioni',
code: '07akioni',
sort: 0,
description: null,
createTime: null,
updateTime: null,
children: [
{
id: '08',
name: '08akioni',
code: '08akioni',
sort: 0,
description: null,
createTime: null,
updateTime: null,
children: [
{
id: '09',
name: '09akioni',
code: '09akioni',
children: [],
sort: 0,
description: null,
createTime: null,
updateTime: null
}
]
}
]
},
{
id: '11',
name: '11akioni',
code: '11akioni',
children: [],
sort: 0,
description: null,
createTime: null,
updateTime: null
}
];
const newDictionaryItemData = ref<Api.Sys.Core.DictionaryItem[]>([]);
const dictionaryItemColumns: DataTableColumns<Api.Sys.Core.DictionaryItem> = [
{
type: 'selection'
},
{
title: 'name',
key: 'name'
},
{
title: 'index',
key: 'index'
}
];
function rowKey(row: Api.Sys.Core.DictionaryItem) {
return row.id;
}
function handleUpdateChecked() {
const dictionaryType = model.value.type;
if (!dictionaryType) {
return;
}
newDictionaryItemData.value = cloneDeep(dictionaryItemData);
if (dictionaryType === 'enum') {
for (const newDictionaryItemDatum of newDictionaryItemData.value) {
newDictionaryItemDatum.children = [];
}
}
}
watch(visible, () => {
if (visible.value) {
handleInitModel();
restoreValidation();
handleUpdateChecked();
}
});
</script>
@ -190,7 +108,7 @@ watch(visible, () => {
<NInput v-model:value="model.code" :placeholder="$t('page.sys.core.dictionary.fields.code')" />
</NFormItem>
<NFormItem :label="$t('page.sys.core.dictionary.fields.type')" path="type">
<NRadioGroup v-model:value="model.type" @change="handleUpdateChecked">
<NRadioGroup v-model:value="model.type">
<NRadio
v-for="item in dictionaryTypeOptions"
:key="item.value"
@ -207,25 +125,12 @@ watch(visible, () => {
/>
</NFormItem>
</NForm>
<NCard :title="$t('page.sys.core.dictionary.item.title')" hoverable embedded>
<template #header-extra>
<NSpace wrap justify="end" class="lt-sm:w-200px">
<NButton size="small" ghost type="primary" @click="handleAddDictionaryItem">
<template #icon>
<icon-ic-round-plus class="text-icon" />
</template>
{{ $t('common.add') }}
</NButton>
</NSpace>
</template>
</NCard>
<template #footer>
<NSpace :size="16">
<NButton @click="closeDrawer">{{ $t('common.cancel') }}</NButton>
<NButton type="primary" @click="handleSubmit">{{ $t('common.confirm') }}</NButton>
</NSpace>
</template>
<NDataTable :columns="dictionaryItemColumns" :data="newDictionaryItemData" :row-key="rowKey" />
</NDrawerContent>
</NDrawer>
</template>