feat: dept add i18n
This commit is contained in:
parent
e8c83e6bc6
commit
37070381d5
@ -396,13 +396,18 @@ const local: App.I18n.Schema = {
|
||||
dept: {
|
||||
empty: 'No department information',
|
||||
title: 'Department List',
|
||||
parentId: 'Parent Department',
|
||||
deptName: 'Department Name',
|
||||
orderNum: 'Order Num',
|
||||
deptCategory: 'Department Category',
|
||||
leader: 'Leader',
|
||||
phone: 'Phone',
|
||||
email: 'Email',
|
||||
status: 'Status',
|
||||
sort: 'Sort',
|
||||
createTime: 'Create Time',
|
||||
expandAll: 'Expand All',
|
||||
collapseAll: 'Collapse All',
|
||||
form: {
|
||||
parentId: {
|
||||
required: 'Please select Parent Department',
|
||||
@ -412,6 +417,14 @@ const local: App.I18n.Schema = {
|
||||
required: 'Please enter Department Name',
|
||||
invalid: 'Department Name cannot be empty'
|
||||
},
|
||||
orderNum: {
|
||||
required: 'Please enter Order Num',
|
||||
invalid: 'Order num cannot be empty'
|
||||
},
|
||||
deptCategory: {
|
||||
required: 'Please enter Department Category',
|
||||
invalid: 'Department category cannot be empty'
|
||||
},
|
||||
leader: {
|
||||
required: 'Please enter Leader',
|
||||
invalid: 'Leader cannot be empty'
|
||||
@ -431,8 +444,21 @@ const local: App.I18n.Schema = {
|
||||
sort: {
|
||||
required: 'Please enter Sort',
|
||||
invalid: 'Sort cannot be empty'
|
||||
},
|
||||
deptId: {
|
||||
required: 'Please enter deptId',
|
||||
invalid: 'Dept Id cannot be empty'
|
||||
}
|
||||
},
|
||||
error: {
|
||||
getDeptDataFail: 'Get dept data fail',
|
||||
getDeptUserDataFail: 'Get dept user data fail'
|
||||
},
|
||||
placeholder: {
|
||||
defaultLeaderPlaceHolder: 'Please select leader',
|
||||
addDataLeaderPlaceHolder: 'Department leader can be selected only when updating',
|
||||
deptUserIsEmptyLeaderPlaceHolder: 'Current dept no leader'
|
||||
},
|
||||
addDept: 'Add Department',
|
||||
editDept: 'Edit Department'
|
||||
},
|
||||
|
@ -396,13 +396,18 @@ const local: App.I18n.Schema = {
|
||||
dept: {
|
||||
empty: '暂无部门信息',
|
||||
title: '部门列表',
|
||||
parentId: '上级部门',
|
||||
deptName: '部门名称',
|
||||
orderNum: '排序',
|
||||
deptCategory: '类别编码',
|
||||
leader: '负责人',
|
||||
phone: '联系电话',
|
||||
email: '邮箱',
|
||||
status: '状态',
|
||||
sort: '排序',
|
||||
createTime: '创建时间',
|
||||
expandAll: '全部展开',
|
||||
collapseAll: '全部收起',
|
||||
form: {
|
||||
parentId: {
|
||||
required: '请选择上级部门',
|
||||
@ -412,6 +417,14 @@ const local: App.I18n.Schema = {
|
||||
required: '请输入部门名称',
|
||||
invalid: '部门名称不能为空'
|
||||
},
|
||||
orderNum: {
|
||||
required: '请输入排序',
|
||||
invalid: '排序不能为空'
|
||||
},
|
||||
deptCategory: {
|
||||
required: '请输入类别编码',
|
||||
invalid: '类别编码不能为空'
|
||||
},
|
||||
leader: {
|
||||
required: '请输入负责人',
|
||||
invalid: '负责人不能为空'
|
||||
@ -431,8 +444,21 @@ const local: App.I18n.Schema = {
|
||||
sort: {
|
||||
required: '请输入排序',
|
||||
invalid: '排序不能为空'
|
||||
},
|
||||
deptId: {
|
||||
required: '请输入部门id',
|
||||
invalid: '部门id不能为空'
|
||||
}
|
||||
},
|
||||
error: {
|
||||
getDeptDataFail: '获取部门用户数据失败',
|
||||
getDeptUserDataFail: '获取部门用户数据失败'
|
||||
},
|
||||
placeholder: {
|
||||
defaultLeaderPlaceHolder: '请选择负责人',
|
||||
addDataLeaderPlaceHolder: '仅在更新时可选择部门负责人',
|
||||
deptUserIsEmptyLeaderPlaceHolder: '该部门没有负责人'
|
||||
},
|
||||
addDept: '新增部门',
|
||||
editDept: '编辑部门'
|
||||
},
|
||||
|
25
src/typings/app.d.ts
vendored
25
src/typings/app.d.ts
vendored
@ -568,21 +568,38 @@ declare namespace App {
|
||||
dept: {
|
||||
empty: string;
|
||||
title: string;
|
||||
parentId: string;
|
||||
deptName: string;
|
||||
orderNum: string;
|
||||
deptCategory: string;
|
||||
leader: string;
|
||||
phone: string;
|
||||
email: string;
|
||||
status: string;
|
||||
sort: string;
|
||||
createTime: string;
|
||||
expandAll: string;
|
||||
collapseAll: string;
|
||||
form: {
|
||||
parentId: FormMsg;
|
||||
deptName: FormMsg;
|
||||
orderNum: FormMsg;
|
||||
deptCategory: FormMsg;
|
||||
leader: FormMsg;
|
||||
phone: FormMsg;
|
||||
email: FormMsg;
|
||||
status: FormMsg;
|
||||
sort: FormMsg;
|
||||
deptId: FormMsg;
|
||||
};
|
||||
error: {
|
||||
getDeptDataFail: string;
|
||||
getDeptUserDataFail: string;
|
||||
};
|
||||
placeholder: {
|
||||
defaultLeaderPlaceHolder: string;
|
||||
addDataLeaderPlaceHolder: string;
|
||||
deptUserIsEmptyLeaderPlaceHolder: string;
|
||||
};
|
||||
addDept: string;
|
||||
editDept: string;
|
||||
@ -896,13 +913,21 @@ declare namespace App {
|
||||
|
||||
interface $T {
|
||||
(key: I18nKey): string;
|
||||
|
||||
(key: I18nKey, plural: number, options?: TranslateOptions<LangType>): string;
|
||||
|
||||
(key: I18nKey, defaultMsg: string, options?: TranslateOptions<I18nKey>): string;
|
||||
|
||||
(key: I18nKey, list: unknown[], options?: TranslateOptions<I18nKey>): string;
|
||||
|
||||
(key: I18nKey, list: unknown[], plural: number): string;
|
||||
|
||||
(key: I18nKey, list: unknown[], defaultMsg: string): string;
|
||||
|
||||
(key: I18nKey, named: Record<string, unknown>, options?: TranslateOptions<LangType>): string;
|
||||
|
||||
(key: I18nKey, named: Record<string, unknown>, plural: number): string;
|
||||
|
||||
(key: I18nKey, named: Record<string, unknown>, defaultMsg: string): string;
|
||||
}
|
||||
}
|
||||
|
@ -44,25 +44,25 @@ const {
|
||||
columns: () => [
|
||||
{
|
||||
key: 'deptName',
|
||||
title: '部门名称',
|
||||
title: $t('page.system.dept.deptName'),
|
||||
align: 'center',
|
||||
minWidth: 120
|
||||
},
|
||||
{
|
||||
key: 'deptCategory',
|
||||
title: '类别编码',
|
||||
title: $t('page.system.dept.deptCategory'),
|
||||
align: 'center',
|
||||
minWidth: 120
|
||||
},
|
||||
{
|
||||
key: 'orderNum',
|
||||
title: '排序',
|
||||
title: $t('page.system.dept.sort'),
|
||||
align: 'center',
|
||||
minWidth: 60
|
||||
},
|
||||
{
|
||||
key: 'status',
|
||||
title: '部门状态',
|
||||
title: $t('page.system.dept.status'),
|
||||
align: 'center',
|
||||
minWidth: 120,
|
||||
render(row) {
|
||||
@ -71,7 +71,7 @@ const {
|
||||
},
|
||||
{
|
||||
key: 'createTime',
|
||||
title: '创建时间',
|
||||
title: $t('page.system.dept.createTime'),
|
||||
align: 'center',
|
||||
minWidth: 120
|
||||
},
|
||||
@ -163,7 +163,7 @@ async function addInRow(row: TableDataWithIndex<Api.System.Dept>) {
|
||||
<template>
|
||||
<div class="min-h-500px flex-col-stretch gap-16px overflow-hidden lt-sm:overflow-auto">
|
||||
<DeptSearch v-model:model="searchParams" @reset="resetSearchParams" @search="getData" />
|
||||
<NCard title="部门列表" :bordered="false" size="small" class="sm:flex-1-hidden card-wrapper">
|
||||
<NCard :title="$t('page.system.dept.title')" :bordered="false" size="small" class="sm:flex-1-hidden card-wrapper">
|
||||
<template #header-extra>
|
||||
<TableHeaderOperation
|
||||
v-model:columns="columnChecks"
|
||||
@ -178,13 +178,13 @@ async function addInRow(row: TableDataWithIndex<Api.System.Dept>) {
|
||||
<template #icon>
|
||||
<icon-quill:expand />
|
||||
</template>
|
||||
全部展开
|
||||
{{ $t('page.system.dept.expandAll') }}
|
||||
</NButton>
|
||||
<NButton v-if="isCollapse" :disabled="!data.length" size="small" @click="collapseAll">
|
||||
<template #icon>
|
||||
<icon-quill:collapse />
|
||||
</template>
|
||||
全部收起
|
||||
{{ $t('page.system.dept.collapseAll') }}
|
||||
</NButton>
|
||||
</template>
|
||||
</TableHeaderOperation>
|
||||
|
@ -38,13 +38,13 @@ const { loading: deptLoading, startLoading: startDeptLoading, endLoading: endDep
|
||||
const { loading: userLoading, startLoading: startUserLoading, endLoading: endUserLoading } = useLoading();
|
||||
const deptData = ref<Api.System.Dept[]>([]);
|
||||
const userOptions = ref<CommonType.Option<CommonType.IdType>[]>([]);
|
||||
const placeholder = ref<string>('请选择负责人');
|
||||
const placeholder = ref<string>($t('page.system.dept.placeholder.defaultLeaderPlaceHolder'));
|
||||
const disabled = ref<boolean>(false);
|
||||
|
||||
const title = computed(() => {
|
||||
const titles: Record<NaiveUI.TableOperateType, string> = {
|
||||
add: '新增部门',
|
||||
edit: '编辑部门'
|
||||
add: $t('page.system.dept.addDept'),
|
||||
edit: $t('page.system.dept.editDept')
|
||||
};
|
||||
return titles[props.operateType];
|
||||
});
|
||||
@ -69,10 +69,10 @@ function createDefaultModel(): Model {
|
||||
type RuleKey = Extract<keyof Model, 'deptId' | 'parentId' | 'orderNum' | 'deptName' | 'phone' | 'email'>;
|
||||
|
||||
const rules: Record<RuleKey, App.Global.FormRule> = {
|
||||
deptId: createRequiredRule('部门id不能为空'),
|
||||
parentId: createRequiredRule('上级部门不能为空'),
|
||||
orderNum: createRequiredRule('显示顺序不能为空'),
|
||||
deptName: createRequiredRule('部门名称不能为空'),
|
||||
deptId: createRequiredRule($t('page.system.dept.form.deptId.invalid')),
|
||||
parentId: createRequiredRule($t('page.system.dept.form.parentId.invalid')),
|
||||
orderNum: createRequiredRule($t('page.system.dept.form.orderNum.invalid')),
|
||||
deptName: createRequiredRule($t('page.system.dept.form.deptName.invalid')),
|
||||
phone: patternRules.phone,
|
||||
email: patternRules.email
|
||||
};
|
||||
@ -137,7 +137,7 @@ async function getDeptData() {
|
||||
props.operateType === 'add' ? await fetchGetDeptList() : await fetchGetExcludeDeptList(props.rowData?.deptId);
|
||||
|
||||
if (error) {
|
||||
window.$message?.error(error.message || '获取部门数据失败');
|
||||
window.$message?.error(error.message || $t('page.system.dept.error.getDeptDataFail'));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -149,18 +149,18 @@ async function getDeptData() {
|
||||
|
||||
async function getUserData() {
|
||||
if (props.operateType === 'add' || !props.rowData?.deptId) {
|
||||
placeholder.value = '仅在更新时可选择部门负责人';
|
||||
placeholder.value = $t('page.system.dept.placeholder.addDataLeaderPlaceHolder');
|
||||
disabled.value = true;
|
||||
return;
|
||||
}
|
||||
startUserLoading();
|
||||
const { data, error } = await fetchGetDeptUserList(props.rowData.deptId);
|
||||
if (error) {
|
||||
window.$message?.error(error.message || '获取部门用户数据失败');
|
||||
window.$message?.error(error.message || $t('page.system.dept.error.getDeptUserDataFail'));
|
||||
return;
|
||||
}
|
||||
if (data.length === 0) {
|
||||
placeholder.value = '该部门没有负责人';
|
||||
placeholder.value = $t('page.system.dept.placeholder.deptUserIsEmptyLeaderPlaceHolder');
|
||||
disabled.value = true;
|
||||
}
|
||||
userOptions.value = data.map(item => ({
|
||||
@ -185,7 +185,7 @@ 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="parentId">
|
||||
<NFormItem :label="$t('page.system.dept.parentId')" path="parentId">
|
||||
<NTreeSelect
|
||||
v-model:value="model.parentId"
|
||||
:loading="deptLoading"
|
||||
@ -194,20 +194,24 @@ watch(visible, () => {
|
||||
label-field="deptName"
|
||||
key-field="deptId"
|
||||
default-expand-all
|
||||
placeholder="请选择上级部门"
|
||||
:placeholder="$t('page.system.dept.form.parentId.required')"
|
||||
/>
|
||||
</NFormItem>
|
||||
<NFormItem label="部门名称" path="deptName">
|
||||
<NInput v-model:value="model.deptName" placeholder="请输入部门名称" />
|
||||
<NFormItem :label="$t('page.system.dept.deptName')" path="deptName">
|
||||
<NInput v-model:value="model.deptName" :placeholder="$t('page.system.dept.form.deptName.required')" />
|
||||
</NFormItem>
|
||||
<NFormItem label="显示顺序" path="orderNum">
|
||||
<NInputNumber v-model:value="model.orderNum" class="w-full" placeholder="请输入显示顺序" />
|
||||
<NFormItem :label="$t('page.system.dept.orderNum')" path="orderNum">
|
||||
<NInputNumber
|
||||
v-model:value="model.orderNum"
|
||||
class="w-full"
|
||||
:placeholder="$t('page.system.dept.form.orderNum.required')"
|
||||
/>
|
||||
</NFormItem>
|
||||
<NFormItem label="部门类别编码" path="deptCategory">
|
||||
<NInput v-model:value="model.deptCategory" placeholder="请输入部门类别编码" />
|
||||
<NFormItem :label="$t('page.system.dept.deptCategory')" path="deptCategory">
|
||||
<NInput v-model:value="model.deptCategory" :placeholder="$t('page.system.dept.form.deptCategory.required')" />
|
||||
</NFormItem>
|
||||
|
||||
<NFormItem label="负责人" path="leader">
|
||||
<NFormItem :label="$t('page.system.dept.leader')" path="leader">
|
||||
<NSelect
|
||||
v-model:value="model.leader"
|
||||
:loading="userLoading"
|
||||
@ -217,13 +221,13 @@ watch(visible, () => {
|
||||
/>
|
||||
</NFormItem>
|
||||
|
||||
<NFormItem label="联系电话" path="phone">
|
||||
<NInput v-model:value="model.phone" placeholder="请输入联系电话" />
|
||||
<NFormItem :label="$t('page.system.dept.phone')" path="phone">
|
||||
<NInput v-model:value="model.phone" :placeholder="$t('page.system.dept.form.phone.required')" />
|
||||
</NFormItem>
|
||||
<NFormItem label="邮箱" path="email">
|
||||
<NInput v-model:value="model.email" placeholder="请输入邮箱" />
|
||||
<NFormItem :label="$t('page.system.dept.email')" path="email">
|
||||
<NInput v-model:value="model.email" :placeholder="$t('page.system.dept.form.email.required')" />
|
||||
</NFormItem>
|
||||
<NFormItem label="部门状态" path="status">
|
||||
<NFormItem :label="$t('page.system.dept.status')" path="status">
|
||||
<DictRadio v-model:value="model.status" dict-code="sys_normal_disable" />
|
||||
</NFormItem>
|
||||
</NForm>
|
||||
|
@ -36,13 +36,13 @@ async function search() {
|
||||
<NCollapseItem :title="$t('common.search')" name="user-search">
|
||||
<NForm ref="formRef" :model="model" label-placement="left" :label-width="80">
|
||||
<NGrid responsive="screen" item-responsive>
|
||||
<NFormItemGi span="8" label="部门名称" path="deptName" class="pr-24px">
|
||||
<NInput v-model:value="model.deptName" placeholder="请输入部门名称" />
|
||||
<NFormItemGi span="8" :label="$t('page.system.dept.deptName')" path="deptName" class="pr-24px">
|
||||
<NInput v-model:value="model.deptName" :placeholder="$t('page.system.dept.form.deptName.required')" />
|
||||
</NFormItemGi>
|
||||
<NFormItemGi span="8 " label="部门状态" path="status" class="pr-24px">
|
||||
<NFormItemGi span="8 " :label="$t('page.system.dept.status')" path="status" class="pr-24px">
|
||||
<NSelect
|
||||
v-model:value="model.status"
|
||||
placeholder="请选择部门状态"
|
||||
:placeholder="$t('page.system.dept.form.status.required')"
|
||||
:options="sysNormalDisableOptions"
|
||||
clearable
|
||||
/>
|
||||
|
Loading…
Reference in New Issue
Block a user