分配用户国际化

This commit is contained in:
lai
2023-11-10 16:37:51 +08:00
parent 1d4db90b1e
commit b8190bd640
4 changed files with 110 additions and 62 deletions

View File

@@ -7,6 +7,8 @@ import { authUserAllocatedList } from '@/api/system/role';
import { parseDateToStr } from '@/utils/date-utils';
import useDictStore from '@/store/modules/dict';
import { RESULT_CODE_SUCCESS } from '@/constants/result-constants';
import useI18n from '@/hooks/useI18n';
const { t } = useI18n();
const { getDict } = useDictStore();
const emit = defineEmits(['ok', 'cancel', 'update:visible']);
const props = defineProps({
@@ -87,33 +89,38 @@ let tableState: TabeStateType = reactive({
/**表格字段列 */
let tableColumns: ColumnsType = [
{
title: '用户编号',
title: t('views.system.role.userId'),
dataIndex: 'userId',
align: 'center',
},
{
title: '登录账号',
title: t('views.system.role.account'),
dataIndex: 'userName',
align: 'center',
},
{
title: '用户昵称',
title: t('views.system.role.userName'),
dataIndex: 'nickName',
align: 'center',
},
{
title: '手机号码',
title: t('views.system.role.phone'),
dataIndex: 'phonenumber',
align: 'center',
},
{
title: '用户状态',
title: t('views.system.role.email'),
dataIndex: 'email',
align: 'center',
},
{
title: t('views.system.role.userStaus'),
dataIndex: 'status',
key: 'status',
align: 'center',
},
{
title: '创建时间',
title: t('views.system.role.createTime'),
dataIndex: 'createTime',
align: 'center',
customRender(opt) {
@@ -121,6 +128,11 @@ let tableColumns: ColumnsType = [
return parseDateToStr(+opt.value);
},
},
{
title: t('common.operate'),
key: 'userId',
align: 'center',
},
];
/**表格分页器参数 */
@@ -141,7 +153,7 @@ let tablePagination = reactive({
showSizeChanger: true,
/**数据总数 */
total: 0,
showTotal: (total: number) => `总共 ${total}`,
showTotal: (total: number) => t('common.tablePaginationTotal', { total }),
onChange: (page: number, pageSize: number) => {
tablePagination.current = page;
tablePagination.pageSize = pageSize;
@@ -180,7 +192,7 @@ function fnGetList(pageNum?: number) {
function fnModalOk() {
const userIds = tableState.selectedRowKeys;
if (userIds.length <= 0) {
message.error(`请选择要分配的用户`, 2);
message.error(t('views.system.role.selectPls'), 2);
return;
}
emit('update:visible', false);
@@ -228,31 +240,28 @@ watch(
<a-form :model="queryParams" name="queryParams" layout="horizontal">
<a-row :gutter="16">
<a-col :lg="8" :md="12" :xs="24">
<a-form-item label="登录账号" name="userName">
<a-form-item :label="t('views.system.role.account')" name="userName">
<a-input
v-model:value="queryParams.userName"
allow-clear
:maxlength="30"
placeholder="请输入登录账号"
></a-input>
</a-form-item>
</a-col>
<a-col :lg="8" :md="12" :xs="24">
<a-form-item label="手机号码" name="phonenumber">
<a-form-item :label="t('views.system.role.phone')" name="phonenumber">
<a-input
v-model:value="queryParams.phonenumber"
allow-clear
:maxlength="11"
placeholder="请输入手机号码"
></a-input>
</a-form-item>
</a-col>
<a-col :lg="8" :md="12" :xs="24">
<a-form-item label="用户状态" name="status">
<a-form-item :label="t('views.system.role.userStaus')" name="status">
<a-select
v-model:value="queryParams.status"
allow-clear
placeholder="请选择用户状态"
:options="dict.sysNormalDisable"
>
</a-select>
@@ -263,11 +272,11 @@ watch(
<a-space :size="8">
<a-button type="primary" @click.prevent="fnGetList(1)">
<template #icon><SearchOutlined /></template>
搜索</a-button
{{ t('common.search') }}</a-button
>
<a-button type="default" @click.prevent="fnQueryReset">
<template #icon><ClearOutlined /></template>
重置</a-button
{{ t('common.reset') }}</a-button
>
</a-space>
</a-form-item>
@@ -282,7 +291,7 @@ watch(
:loading="tableState.loading"
:data-source="tableState.data"
:size="tableState.size"
:scroll="{ scrollToFirstRowOnChange: true, y: 400, x: true }"
:scroll="{ scrollToFirstRowOnChange: true, y: 400, x: 600 }"
:pagination="tablePagination"
:row-selection="{
type: 'checkbox',