!2 perf: dict add i18n

Merge pull request !2 from small monkey/dict-i18n
This commit is contained in:
马铃薯头
2025-05-19 01:24:44 +00:00
committed by Gitee
8 changed files with 140 additions and 59 deletions

View File

@ -53,7 +53,7 @@ const { columns, columnChecks, data, getData, getDataByPage, loading, mobilePagi
},
{
key: 'dictLabel',
title: '字典标签',
title: $t('page.system.dict.data.label'),
align: 'center',
minWidth: 80,
resizable: true,
@ -66,7 +66,7 @@ const { columns, columnChecks, data, getData, getDataByPage, loading, mobilePagi
},
{
key: 'dictValue',
title: '字典键值',
title: $t('page.system.dict.data.value'),
align: 'center',
minWidth: 80,
resizable: true,
@ -76,7 +76,7 @@ const { columns, columnChecks, data, getData, getDataByPage, loading, mobilePagi
},
{
key: 'dictSort',
title: '字典排序',
title: $t('page.system.dict.data.dictSort'),
align: 'center',
minWidth: 80,
resizable: true,
@ -86,7 +86,7 @@ const { columns, columnChecks, data, getData, getDataByPage, loading, mobilePagi
},
{
key: 'remark',
title: '备注',
title: $t('page.system.dict.data.remark'),
align: 'center',
minWidth: 80,
resizable: true,
@ -96,7 +96,7 @@ const { columns, columnChecks, data, getData, getDataByPage, loading, mobilePagi
},
{
key: 'createTime',
title: '创建时间',
title: $t('page.system.dict.data.createTime'),
align: 'center',
minWidth: 80,
resizable: true,
@ -193,7 +193,7 @@ async function handleReset() {
async function handleRefreshCache() {
const { error } = await fetchRefreshCache();
if (error) return;
window.$message?.success('刷新缓存成功');
window.$message?.success($t('page.system.dict.refreshCacheSuccess'));
await getData();
}
@ -260,7 +260,7 @@ function renderSuffix({ option }: { option: TreeOption }) {
text
type="primary"
icon="material-symbols:drive-file-rename-outline-outline"
tooltip-content="修改"
tooltip-content={$t('common.edit')}
onClick={(event: Event) => {
event.stopPropagation();
handleEditType(option as Api.System.DictType);
@ -270,8 +270,8 @@ function renderSuffix({ option }: { option: TreeOption }) {
text
type="error"
icon="material-symbols:delete-outline"
tooltip-content="删除"
popconfirm-content={`确定删除字典类型 ${option.dictType} `}
tooltip-content={$t('common.delete')}
popconfirm-content={`${$t('page.system.dict.confirmDeleteDictType')} ${option.dictType} `}
onClick={(event: Event) => event.stopPropagation()}
onPositiveClick={() => handleDeleteType(option as Api.System.DictType)}
/>
@ -294,12 +294,12 @@ function handleEditType(dictType: Api.System.DictType) {
async function handleDeleteType(dictType: Api.System.DictType) {
const { error } = await fetchBatchDeleteDictType([dictType.dictId]);
if (error) return;
window.$message?.success('删除成功');
window.$message?.success($t('common.deleteSuccess'));
getTreeData();
}
async function handleExportType() {
download('/system/dict/type/export', searchParams, `字典类型_${new Date().getTime()}.xlsx`);
download('/system/dict/type/export', searchParams, `${$t('page.system.dict.dictType')}_${new Date().getTime()}.xlsx`);
}
const selectable = computed(() => {
@ -308,14 +308,14 @@ const selectable = computed(() => {
</script>
<template>
<TableSiderLayout sider-title="字典类型列表">
<TableSiderLayout :sider-title="$t('page.system.dict.dictTypeTitle')">
<template #header-extra>
<ButtonIcon
v-if="hasAuth('system:dict:add')"
size="small"
icon="material-symbols:add-rounded"
class="h-18px text-icon"
tooltip-content="新增字典类型"
:tooltip-content="$t('page.system.dict.addDictType')"
@click.stop="() => handleAddType()"
/>
<ButtonIcon
@ -323,14 +323,14 @@ const selectable = computed(() => {
size="small"
icon="material-symbols:download-rounded"
class="h-18px text-icon"
tooltip-content="导出字典类型"
:tooltip-content="$t('page.system.dict.exportDictType')"
@click.stop="() => handleExportType()"
/>
<ButtonIcon
size="small"
icon="material-symbols:refresh-rounded"
class="h-18px text-icon"
tooltip-content="刷新列表"
:tooltip-content="$t('page.system.dict.refreshDictType')"
@click.stop="() => handleResetTreeData()"
/>
</template>
@ -354,7 +354,7 @@ const selectable = computed(() => {
@update:selected-keys="handleClickTree"
>
<template #empty>
<NEmpty description="暂无字典类型" class="h-full min-h-200px justify-center" />
<NEmpty :description="$t('page.system.dict.dictTypeIsEmpty')" class="h-full min-h-200px justify-center" />
</template>
</NTree>
</NSpin>
@ -362,7 +362,7 @@ const selectable = computed(() => {
<div class="h-full flex-col-stretch gap-12px overflow-hidden lt-sm:overflow-auto">
<DictDataSearch v-model:model="searchParams" @reset="handleReset" @search="getDataByPage" />
<TableRowCheckAlert v-model:checked-row-keys="checkedRowKeys" />
<NCard title="字典数据列表" :bordered="false" size="small" class="sm:flex-1-hidden card-wrapper">
<NCard :title="$t('page.system.dict.title')" :bordered="false" size="small" class="sm:flex-1-hidden card-wrapper">
<template #header-extra>
<TableHeaderOperation
v-model:columns="columnChecks"
@ -382,7 +382,7 @@ const selectable = computed(() => {
<template #icon>
<icon-material-symbols:refresh-rounded class="text-icon" />
</template>
刷新缓存
{{ $t('page.system.dict.refreshCache') }}
</NButton>
</template>
</TableHeaderOperation>

View File

@ -34,8 +34,8 @@ const { createRequiredRule } = useFormRules();
const title = computed(() => {
const titles: Record<NaiveUI.TableOperateType, string> = {
add: '新增字典数据',
edit: '编辑字典数据'
add: $t('page.system.dict.addDictData'),
edit: $t('page.system.dict.editDictData')
};
return titles[props.operateType];
});
@ -68,9 +68,9 @@ function createDefaultModel(): Model {
type RuleKey = Extract<keyof Model, 'dictCode' | 'dictLabel' | 'dictValue'>;
const rules: Record<RuleKey, App.Global.FormRule> = {
dictCode: createRequiredRule('字典编码不能为空'),
dictLabel: createRequiredRule('字典标签不能为空'),
dictValue: createRequiredRule('字典键值不能为空')
dictCode: createRequiredRule($t('page.system.dict.form.dictCode.invalid')),
dictLabel: createRequiredRule($t('page.system.dict.form.dictLabel.invalid')),
dictValue: createRequiredRule($t('page.system.dict.form.dictValue.invalid'))
};
function handleUpdateModelWhenEdit() {
@ -146,32 +146,41 @@ function renderTagLabel(option: { label: string; value: string }) {
<NDrawer v-model:show="visible" :title="title" display-directive="show" :width="800" class="max-w-90%">
<NDrawerContent :title="title" :native-scrollbar="false" closable>
<NForm ref="formRef" :model="model" :rules="rules">
<NFormItem label="字典类型" path="dictType">
<NInput v-model:value="model.dictType" disabled placeholder="请输入字典类型" />
<NFormItem :label="$t('page.system.dict.dictType')" path="dictType">
<NInput
v-model:value="model.dictType"
disabled
:placeholder="$t('page.system.dict.form.dictType.required')"
/>
</NFormItem>
<NFormItem label="标签样式" path="listClass">
<NFormItem :label="$t('page.system.dict.data.listClass')" path="listClass">
<NSelect
v-model:value="model.listClass"
clearable
:options="listClassOptions"
placeholder="请选择标签样式"
:placeholder="$t('page.system.dict.form.listClass.required')"
:render-label="renderTagLabel"
/>
</NFormItem>
<NFormItem label="数据标签" path="dictLabel">
<NInput v-model:value="model.dictLabel" placeholder="请输入字典标签" />
<NFormItem :label="$t('page.system.dict.data.label')" path="dictLabel">
<NInput v-model:value="model.dictLabel" :placeholder="$t('page.system.dict.form.dictLabel.required')" />
</NFormItem>
<NFormItem label="数据键值" path="dictValue">
<NInput v-model:value="model.dictValue" placeholder="请输入字典键值" />
<NFormItem :label="$t('page.system.dict.data.value')" path="dictValue">
<NInput v-model:value="model.dictValue" :placeholder="$t('page.system.dict.form.dictValue.required')" />
</NFormItem>
<NFormItem label="css类名" path="cssClass">
<NInput v-model:value="model.cssClass" placeholder="请输入样式属性(其他样式扩展)" />
<NFormItem :label="$t('page.system.dict.data.cssClass')" path="cssClass">
<NInput v-model:value="model.cssClass" :placeholder="$t('page.system.dict.form.cssClass.required')" />
</NFormItem>
<NFormItem label="显示排序" path="dictSort">
<NInputNumber v-model:value="model.dictSort" placeholder="请输入字典排序" />
<NFormItem :label="$t('page.system.dict.data.dictSort')" path="dictSort">
<NInputNumber v-model:value="model.dictSort" :placeholder="$t('page.system.dict.form.dictSort.required')" />
</NFormItem>
<NFormItem label="备注" path="remark">
<NInput v-model:value="model.remark" :rows="3" type="textarea" placeholder="请输入备注" />
<NFormItem :label="$t('page.system.dict.data.remark')" path="remark">
<NInput
v-model:value="model.remark"
:rows="3"
type="textarea"
:placeholder="$t('page.system.dict.form.remark.required')"
/>
</NFormItem>
</NForm>
<template #footer>

View File

@ -34,8 +34,14 @@ async function search() {
<NCollapseItem :title="$t('common.search')" name="user-search">
<NForm ref="formRef" :model="model" label-placement="left" :label-width="80">
<NGrid responsive="self" item-responsive>
<NFormItemGi :show-feedback="false" span="12" label="字典标签" path="dictLabel" class="pr-24px">
<NInput v-model:value="model.dictLabel" placeholder="请输入字典标签" />
<NFormItemGi
:show-feedback="false"
span="12"
:label="$t('page.system.dict.data.label')"
path="dictLabel"
class="pr-24px"
>
<NInput v-model:value="model.dictLabel" :placeholder="$t('page.system.dict.form.dictLabel.required')" />
</NFormItemGi>
<NFormItemGi :show-feedback="false" span="12" class="pr-24px">
<NSpace class="w-full" justify="end">

View File

@ -32,8 +32,8 @@ const { createRequiredRule } = useFormRules();
const title = computed(() => {
const titles: Record<NaiveUI.TableOperateType, string> = {
add: '新增字典类型',
edit: '编辑字典类型'
add: $t('page.system.dict.addDictType'),
edit: $t('page.system.dict.editDictType')
};
return titles[props.operateType];
});
@ -53,9 +53,9 @@ function createDefaultModel(): Model {
type RuleKey = Extract<keyof Model, 'dictId' | 'dictName' | 'dictType'>;
const rules: Record<RuleKey, App.Global.FormRule> = {
dictId: createRequiredRule('字典主键不能为空'),
dictName: createRequiredRule('字典名称不能为空'),
dictType: createRequiredRule('字典类型不能为空')
dictId: createRequiredRule($t('page.system.dict.form.dictValue.invalid')),
dictName: createRequiredRule($t('page.system.dict.form.dictName.invalid')),
dictType: createRequiredRule($t('page.system.dict.form.dictType.invalid'))
};
function handleUpdateModelWhenEdit() {
@ -106,14 +106,19 @@ watch(visible, () => {
<NDrawer v-model:show="visible" :title="title" display-directive="show" :width="800" class="max-w-90%">
<NDrawerContent :title="title" :native-scrollbar="false" closable>
<NForm ref="formRef" :model="model" :rules="rules">
<NFormItem label="字典名称" path="dictName">
<NInput v-model:value="model.dictName" placeholder="请输入字典名称" />
<NFormItem :label="$t('page.system.dict.dictName')" path="dictName">
<NInput v-model:value="model.dictName" :placeholder="$t('page.system.dict.form.dictName.required')" />
</NFormItem>
<NFormItem label="字典类型" path="dictType">
<NInput v-model:value="model.dictType" placeholder="请输入字典类型" />
<NFormItem :label="$t('page.system.dict.dictType')" path="dictType">
<NInput v-model:value="model.dictType" :placeholder="$t('page.system.dict.form.dictValue.required')" />
</NFormItem>
<NFormItem label="备注" path="remark">
<NInput v-model:value="model.remark" :rows="3" type="textarea" placeholder="请输入备注" />
<NFormItem :label="$t('page.system.dict.remark')" path="remark">
<NInput
v-model:value="model.remark"
:rows="3"
type="textarea"
:placeholder="$t('page.system.dict.form.remark.required')"
/>
</NFormItem>
</NForm>
<template #footer>