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: { yesOrNo: {
yes: 'Yes', yes: 'Yes',
no: 'No' no: 'No'
} },
children: 'Children'
}, },
request: { request: {
logout: 'Logout user after request failed', logout: 'Logout user after request failed',

View File

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

View File

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

View File

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

View File

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

View File

@ -1,7 +1,5 @@
<script setup lang="ts"> <script setup lang="ts">
import { computed, ref, watch } from 'vue'; import { computed, ref, watch } from 'vue';
import type { DataTableColumns } from 'naive-ui';
import { cloneDeep } from 'lodash-es';
import { jsonClone } from '@sa/utils'; import { jsonClone } from '@sa/utils';
import { dictionaryTypeOptions } from '@/constants/sys/core/dictionary'; import { dictionaryTypeOptions } from '@/constants/sys/core/dictionary';
import { fetchDictionaryAdd, fetchDictionaryEdit } from '@/service/api'; 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, () => { watch(visible, () => {
if (visible.value) { if (visible.value) {
handleInitModel(); handleInitModel();
restoreValidation(); restoreValidation();
handleUpdateChecked();
} }
}); });
</script> </script>
@ -190,7 +108,7 @@ watch(visible, () => {
<NInput v-model:value="model.code" :placeholder="$t('page.sys.core.dictionary.fields.code')" /> <NInput v-model:value="model.code" :placeholder="$t('page.sys.core.dictionary.fields.code')" />
</NFormItem> </NFormItem>
<NFormItem :label="$t('page.sys.core.dictionary.fields.type')" path="type"> <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 <NRadio
v-for="item in dictionaryTypeOptions" v-for="item in dictionaryTypeOptions"
:key="item.value" :key="item.value"
@ -207,25 +125,12 @@ watch(visible, () => {
/> />
</NFormItem> </NFormItem>
</NForm> </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> <template #footer>
<NSpace :size="16"> <NSpace :size="16">
<NButton @click="closeDrawer">{{ $t('common.cancel') }}</NButton> <NButton @click="closeDrawer">{{ $t('common.cancel') }}</NButton>
<NButton type="primary" @click="handleSubmit">{{ $t('common.confirm') }}</NButton> <NButton type="primary" @click="handleSubmit">{{ $t('common.confirm') }}</NButton>
</NSpace> </NSpace>
</template> </template>
<NDataTable :columns="dictionaryItemColumns" :data="newDictionaryItemData" :row-key="rowKey" />
</NDrawerContent> </NDrawerContent>
</NDrawer> </NDrawer>
</template> </template>