分配用户国际化

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

@@ -697,6 +697,18 @@ export default {
stop:'Pause', stop:'Pause',
preScope:'Scope of authority', preScope:'Scope of authority',
dataPer:'Data permission', dataPer:'Data permission',
userId:'User number',
account:'Login account',
userName:'User nickname',
phone:'Phone',
email:'Email',
userStaus:'User status',
selectPls:'Please select the user to be assigned',
suss:'{oper}success',
giveUser:'Authorized user',
cancelGive:'Cancel authorization',
cancelSure:'Confirm to cancel the authorization of the data item with user number [{userId}]?',
batchCancel:'Batch cancellation of authorization',
}, },
dept:{ dept:{
classInfo:' Department information', classInfo:' Department information',

View File

@@ -132,7 +132,7 @@ export default {
ttile: '没有访问权限', ttile: '没有访问权限',
subTitle:'请不要进行非法操作,您可以返回主页面或返回', subTitle:'请不要进行非法操作,您可以返回主页面或返回',
backHome: '返回首页', backHome: '返回首页',
back: '返回', back: '返回',
}, },
err404: { err404: {
ttile: '找不到匹配页面', ttile: '找不到匹配页面',
@@ -440,7 +440,7 @@ export default {
}, },
}, },
faultManage: { faultManage: {
activeAlarm: { activeAlarm: {
all:'所有', all:'所有',
neType: '告警设备类型', neType: '告警设备类型',
neName: '告警网元名称', neName: '告警网元名称',
@@ -697,6 +697,18 @@ export default {
stop:'暂停', stop:'暂停',
preScope:'权限范围', preScope:'权限范围',
dataPer:'数据权限', dataPer:'数据权限',
userId:'用户编号',
account:'登录账号',
userName:'用户昵称',
phone:'手机号码',
email:'电子邮箱',
userStaus:'用户状态',
selectPls:'请选择要分配的用户',
suss:'{oper}成功',
giveUser:'授权用户',
cancelGive:'取消授权',
cancelSure:'确认取消用户编号为 【{userId}】 的数据项授权?',
batchCancel:'批量取消授权',
}, },
dept:{ dept:{
classInfo:'部门信息', classInfo:'部门信息',

View File

@@ -92,38 +92,38 @@ let tableState: TabeStateType = reactive({
/**表格字段列 */ /**表格字段列 */
let tableColumns: ColumnsType = [ let tableColumns: ColumnsType = [
{ {
title: '用户编号', title: t('views.system.role.userId'),
dataIndex: 'userId', dataIndex: 'userId',
align: 'center', align: 'center',
}, },
{ {
title: '登录账号', title: t('views.system.role.account'),
dataIndex: 'userName', dataIndex: 'userName',
align: 'center', align: 'center',
}, },
{ {
title: '用户昵称', title: t('views.system.role.userName'),
dataIndex: 'nickName', dataIndex: 'nickName',
align: 'center', align: 'center',
}, },
{ {
title: '手机号码', title: t('views.system.role.phone'),
dataIndex: 'phonenumber', dataIndex: 'phonenumber',
align: 'center', align: 'center',
}, },
{ {
title: '电子邮箱', title: t('views.system.role.email'),
dataIndex: 'email', dataIndex: 'email',
align: 'center', align: 'center',
}, },
{ {
title: '用户状态', title: t('views.system.role.userStaus'),
dataIndex: 'status', dataIndex: 'status',
key: 'status', key: 'status',
align: 'center', align: 'center',
}, },
{ {
title: '创建时间', title: t('views.system.role.createTime'),
dataIndex: 'createTime', dataIndex: 'createTime',
align: 'center', align: 'center',
customRender(opt) { customRender(opt) {
@@ -132,7 +132,7 @@ let tableColumns: ColumnsType = [
}, },
}, },
{ {
title: '操作', title: t('common.operate'),
key: 'userId', key: 'userId',
align: 'center', align: 'center',
}, },
@@ -156,7 +156,7 @@ let tablePagination = reactive({
showSizeChanger: true, showSizeChanger: true,
/**数据总数 */ /**数据总数 */
total: 0, total: 0,
showTotal: (total: number) => `总共 ${total}`, showTotal: (total: number) => t('common.tablePaginationTotal', { total }),
onChange: (page: number, pageSize: number) => { onChange: (page: number, pageSize: number) => {
tablePagination.current = page; tablePagination.current = page;
tablePagination.pageSize = pageSize; tablePagination.pageSize = pageSize;
@@ -208,7 +208,7 @@ function fnModalVisibleBySelectUser() {
*/ */
function fnModalOk(userIds: string[] | number[]) { function fnModalOk(userIds: string[] | number[]) {
if (userIds.length <= 0) { if (userIds.length <= 0) {
message.error(`请选择要分配的用户`, 2); message.error(t('views.system.role.selectPls'), 2);
return; return;
} }
const key = 'authUserChecked'; const key = 'authUserChecked';
@@ -221,7 +221,9 @@ function fnModalOk(userIds: string[] | number[]) {
if (res.code === RESULT_CODE_SUCCESS) { if (res.code === RESULT_CODE_SUCCESS) {
modalState.visibleBySelectUser = false; modalState.visibleBySelectUser = false;
message.success({ message.success({
content: `授权用户添加成功`, content: t('views.system.role.suss', {
oper: t('views.system.role.giveUser'),
}),
key, key,
duration: 3, duration: 3,
}); });
@@ -246,7 +248,7 @@ function fnRecordDelete(userId: string | number) {
} }
Modal.confirm({ Modal.confirm({
title: t('common.tipTitle'), title: t('common.tipTitle'),
content: `确认取消用户编号为 【${userId}】 的数据项授权?`, content: t('views.system.role.cancelSure', { userId: userId }),
onOk() { onOk() {
const key = 'authUserChecked'; const key = 'authUserChecked';
message.loading({ content: t('common.loading'), key }); message.loading({ content: t('common.loading'), key });
@@ -254,7 +256,9 @@ function fnRecordDelete(userId: string | number) {
res => { res => {
if (res.code === RESULT_CODE_SUCCESS) { if (res.code === RESULT_CODE_SUCCESS) {
message.success({ message.success({
content: `取消授权成功`, content: t('views.system.role.suss', {
oper: t('views.system.role.cancelGive'),
}),
key, key,
duration: 3, duration: 3,
}); });
@@ -286,7 +290,7 @@ function fnClose() {
function fnGetList(pageNum?: number) { function fnGetList(pageNum?: number) {
if (tableState.loading) return; if (tableState.loading) return;
tableState.loading = true; tableState.loading = true;
if(pageNum){ if (pageNum) {
queryParams.pageNum = pageNum; queryParams.pageNum = pageNum;
} }
authUserAllocatedList(toRaw(queryParams)).then(res => { authUserAllocatedList(toRaw(queryParams)).then(res => {
@@ -325,40 +329,45 @@ onMounted(() => {
<a-form :model="queryParams" name="queryParams" layout="horizontal"> <a-form :model="queryParams" name="queryParams" layout="horizontal">
<a-row :gutter="16"> <a-row :gutter="16">
<a-col :lg="6" :md="12" :xs="24"> <a-col :lg="6" :md="12" :xs="24">
<a-form-item label="角色名称" name="roleName"> <a-form-item
<a-input :label="t('views.system.role.roleName')"
:value="roleName" name="roleName"
disabled >
placeholder="请输入角色名称" <a-input :value="roleName" disabled></a-input>
></a-input>
</a-form-item> </a-form-item>
</a-col> </a-col>
<a-col :lg="6" :md="12" :xs="24"> <a-col :lg="6" :md="12" :xs="24">
<a-form-item label="登录账号" name="userName"> <a-form-item
:label="t('views.system.role.account')"
name="userName"
>
<a-input <a-input
v-model:value="queryParams.userName" v-model:value="queryParams.userName"
allow-clear allow-clear
:maxlength="30" :maxlength="30"
placeholder="请输入登录账号"
></a-input> ></a-input>
</a-form-item> </a-form-item>
</a-col> </a-col>
<a-col :lg="6" :md="12" :xs="24"> <a-col :lg="6" :md="12" :xs="24">
<a-form-item label="手机号码" name="phonenumber"> <a-form-item
:label="t('views.system.role.phone')"
name="phonenumber"
>
<a-input <a-input
v-model:value="queryParams.phonenumber" v-model:value="queryParams.phonenumber"
allow-clear allow-clear
:maxlength="11" :maxlength="11"
placeholder="请输入手机号码"
></a-input> ></a-input>
</a-form-item> </a-form-item>
</a-col> </a-col>
<a-col :lg="6" :md="12" :xs="24"> <a-col :lg="6" :md="12" :xs="24">
<a-form-item label="用户状态" name="status"> <a-form-item
:label="t('views.system.role.userStaus')"
name="status"
>
<a-select <a-select
v-model:value="queryParams.status" v-model:value="queryParams.status"
allow-clear allow-clear
placeholder="请选择用户状态"
:options="dict.sysNormalDisable" :options="dict.sysNormalDisable"
> >
</a-select> </a-select>
@@ -369,11 +378,11 @@ onMounted(() => {
<a-space :size="8"> <a-space :size="8">
<a-button type="primary" @click.prevent="fnGetList(1)"> <a-button type="primary" @click.prevent="fnGetList(1)">
<template #icon><SearchOutlined /></template> <template #icon><SearchOutlined /></template>
搜索</a-button {{ t('common.search') }}</a-button
> >
<a-button type="default" @click.prevent="fnQueryReset"> <a-button type="default" @click.prevent="fnQueryReset">
<template #icon><ClearOutlined /></template> <template #icon><ClearOutlined /></template>
重置</a-button {{ t('common.reset') }}</a-button
> >
</a-space> </a-space>
</a-form-item> </a-form-item>
@@ -388,7 +397,7 @@ onMounted(() => {
<a-space :size="8" align="center"> <a-space :size="8" align="center">
<a-button type="default" @click.prevent="fnClose()"> <a-button type="default" @click.prevent="fnClose()">
<template #icon><CloseOutlined /></template> <template #icon><CloseOutlined /></template>
关闭 {{ t('common.cancel') }}
</a-button> </a-button>
<a-button <a-button
type="primary" type="primary"
@@ -396,7 +405,7 @@ onMounted(() => {
v-perms:has="['system:role:add']" v-perms:has="['system:role:add']"
> >
<template #icon><UsergroupAddOutlined /></template> <template #icon><UsergroupAddOutlined /></template>
分配用户 {{ t('views.system.role.distributeUser') }}
</a-button> </a-button>
<a-button <a-button
type="default" type="default"
@@ -406,7 +415,7 @@ onMounted(() => {
v-perms:has="['system:role:remove']" v-perms:has="['system:role:remove']"
> >
<template #icon><UsergroupDeleteOutlined /></template> <template #icon><UsergroupDeleteOutlined /></template>
批量取消授权 {{ t('views.system.role.batchCancel') }}
</a-button> </a-button>
</a-space> </a-space>
</template> </template>
@@ -415,31 +424,31 @@ onMounted(() => {
<template #extra> <template #extra>
<a-space :size="8" align="center"> <a-space :size="8" align="center">
<a-tooltip> <a-tooltip>
<template #title>搜索栏</template> <template #title>{{ t('common.searchBarText') }}</template>
<a-switch <a-switch
v-model:checked="tableState.seached" v-model:checked="tableState.seached"
checked-children="" :checked-children="t('common.switch.show')"
un-checked-children="" :un-checked-children="t('common.switch.hide')"
size="small" size="small"
/> />
</a-tooltip> </a-tooltip>
<a-tooltip> <a-tooltip>
<template #title>表格斑马纹</template> <template #title>{{ t('common.zebra') }}</template>
<a-switch <a-switch
v-model:checked="tableState.striped" v-model:checked="tableState.striped"
checked-children="" :checked-children="t('common.switch.show')"
un-checked-children="" :un-checked-children="t('common.switch.hide')"
size="small" size="small"
/> />
</a-tooltip> </a-tooltip>
<a-tooltip> <a-tooltip>
<template #title>刷新</template> <template #title>{{ t('common.reloadText') }}</template>
<a-button type="text" @click.prevent="fnGetList()"> <a-button type="text" @click.prevent="fnGetList()">
<template #icon><ReloadOutlined /></template> <template #icon><ReloadOutlined /></template>
</a-button> </a-button>
</a-tooltip> </a-tooltip>
<a-tooltip placement="topRight"> <a-tooltip placement="topRight">
<template #title>密度</template> <template #title>{{ t('common.sizeText') }}</template>
<a-dropdown placement="bottomRight" trigger="click"> <a-dropdown placement="bottomRight" trigger="click">
<a-button type="text"> <a-button type="text">
<template #icon><ColumnHeightOutlined /></template> <template #icon><ColumnHeightOutlined /></template>
@@ -449,9 +458,15 @@ onMounted(() => {
:selected-keys="[tableState.size as string]" :selected-keys="[tableState.size as string]"
@click="fnTableSize" @click="fnTableSize"
> >
<a-menu-item key="default">默认</a-menu-item> <a-menu-item key="default"
<a-menu-item key="middle">中等</a-menu-item> >{{ t('common.size.default') }}
<a-menu-item key="small">紧凑</a-menu-item> </a-menu-item>
<a-menu-item key="middle"
>{{ t('common.size.middle') }}
</a-menu-item>
<a-menu-item key="small"
>{{ t('common.size.small') }}
</a-menu-item>
</a-menu> </a-menu>
</template> </template>
</a-dropdown> </a-dropdown>
@@ -483,7 +498,7 @@ onMounted(() => {
<template v-if="column.key === 'userId'"> <template v-if="column.key === 'userId'">
<a-space :size="8" align="center"> <a-space :size="8" align="center">
<a-tooltip> <a-tooltip>
<template #title>取消授权</template> <template #title>{{t('views.system.role.cancelGive')}}</template>
<a-button <a-button
type="link" type="link"
@click.prevent="fnRecordDelete(record.userId)" @click.prevent="fnRecordDelete(record.userId)"

View File

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