---新增参数配置,字典配置国家化

This commit is contained in:
lai
2023-11-11 16:31:42 +08:00
parent cca9973b28
commit 7a93768fd0
8 changed files with 582 additions and 290 deletions

View File

@@ -102,28 +102,28 @@ let tableState: TabeStateType = reactive({
/**表格字段列 */
let tableColumns: ColumnsType = [
{
title: '字典编号',
title: t('views.system.dict.dictId'),
dataIndex: 'dictId',
align: 'center',
},
{
title: '字典名称',
title: t('views.system.dict.dictName'),
dataIndex: 'dictName',
align: 'center',
},
{
title: '字典类型',
title: t('views.system.dict.dictType'),
dataIndex: 'dictType',
align: 'center',
},
{
title: '字典状态',
title: t('views.system.dict.dictSatus'),
dataIndex: 'status',
key: 'status',
align: 'center',
},
{
title: '创建时间',
title: t('views.system.dict.createTime'),
dataIndex: 'createTime',
align: 'center',
customRender(opt) {
@@ -132,7 +132,7 @@ let tableColumns: ColumnsType = [
},
},
{
title: '操作',
title: t('common.operate'),
key: 'dictId',
align: 'center',
},
@@ -156,7 +156,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;
@@ -215,10 +215,20 @@ const modalStateFrom = Form.useForm(
modalState.from,
reactive({
dictName: [
{ required: true, min: 1, max: 50, message: '请正确输入字典名称' },
{
required: true,
min: 1,
max: 50,
message: t('views.system.dict.realDictName'),
},
],
dictType: [
{ required: true, min: 1, max: 50, message: '请正确输入字典类型' },
{
required: true,
min: 1,
max: 50,
message: t('views.system.dict.realDictType'),
},
],
})
);
@@ -229,7 +239,7 @@ const modalStateFrom = Form.useForm(
*/
function fnModalVisibleByVive(dictId: string | number) {
if (!dictId) {
message.error(`字典类型记录存在错误`, 2);
message.error(t('common.getInfoFail'), 2);
return;
}
if (modalState.confirmLoading) return;
@@ -240,10 +250,10 @@ function fnModalVisibleByVive(dictId: string | number) {
hide();
if (res.code === RESULT_CODE_SUCCESS && res.data) {
modalState.from = Object.assign(modalState.from, res.data);
modalState.title = '字典类型信息';
modalState.title = t('views.system.dict.dictInfo');
modalState.visibleByView = true;
} else {
message.error(`获取字典类型信息失败`, 2);
message.error(t('common.getInfoFail'), 2);
}
});
}
@@ -255,7 +265,7 @@ function fnModalVisibleByVive(dictId: string | number) {
function fnModalVisibleByEdit(dictId?: string | number) {
if (!dictId) {
modalStateFrom.resetFields();
modalState.title = '添加字典类型';
modalState.title = t('common.addText') + t('views.system.dict.dictType');
modalState.visibleByEdit = true;
} else {
if (modalState.confirmLoading) return;
@@ -266,10 +276,11 @@ function fnModalVisibleByEdit(dictId?: string | number) {
hide();
if (res.code === RESULT_CODE_SUCCESS && res.data) {
modalState.from = Object.assign(modalState.from, res.data);
modalState.title = '修改字典类型';
modalState.title =
t('common.editText') + t('views.system.dict.dictType');
modalState.visibleByEdit = true;
} else {
message.error(`获取字典类型信息失败`, 2);
message.error(t('common.getInfoFail'), 2);
}
});
}
@@ -292,7 +303,7 @@ function fnModalOk() {
.then(res => {
if (res.code === RESULT_CODE_SUCCESS) {
message.success({
content: `${modalState.title}成功`,
content: t('common.msgSuccess', { msg: modalState.title }),
key,
duration: 2,
});
@@ -312,7 +323,7 @@ function fnModalOk() {
});
})
.catch(e => {
message.error(`请正确填写 ${e.errorFields.length} 处必填信息!`, 2);
message.error(t('common.errorFields', { num: e.errorFields.length }), 2);
});
}
@@ -336,14 +347,14 @@ function fnRecordDelete(dictId: string = '0') {
}
Modal.confirm({
title: t('common.tipTitle'),
content: `确认删除参数编号为 【${dictId}】 的数据项?`,
content: t('views.system.dict.dictType', { dictId }),
onOk() {
const key = 'delType';
message.loading({ content: t('common.loading'), key });
delType(dictId).then(res => {
if (res.code === RESULT_CODE_SUCCESS) {
message.success({
content: `删除成功`,
content: t('common.msgSuccess', { msg: t('common.deleteText') }),
key,
duration: 2,
});
@@ -364,14 +375,16 @@ function fnRecordDelete(dictId: string = '0') {
function fnExportList() {
Modal.confirm({
title: t('common.tipTitle'),
content: `确认根据搜索条件导出xlsx表格文件吗?`,
content: t('views.system.user.exportSure'),
onOk() {
const key = 'exportType';
message.loading({ content: t('common.loading'), key });
exportType(toRaw(queryParams)).then(res => {
if (res.code === RESULT_CODE_SUCCESS) {
message.success({
content: `已完成导出`,
content: t('common.msgSuccess', {
msg: t('views.system.user.export'),
}),
key,
duration: 2,
});
@@ -394,14 +407,14 @@ function fnExportList() {
function fnRefreshCache() {
Modal.confirm({
title: t('common.tipTitle'),
content: `确定要刷新字典数据缓存吗?`,
content: t('views.system.dict.reloadSure'),
onOk() {
const key = 'refreshCache';
message.loading({ content: t('common.loading'), key });
refreshCache().then(res => {
if (res.code === RESULT_CODE_SUCCESS) {
message.success({
content: `刷新缓存成功`,
content: t('views.system.dict.reloadSuss'),
key,
duration: 2,
});
@@ -426,7 +439,7 @@ function fnDataView(dictId: string | number = '0') {
function fnGetList(pageNum?: number) {
if (tableState.loading) return;
tableState.loading = true;
if(pageNum){
if (pageNum) {
queryParams.pageNum = pageNum;
}
if (!queryRangePicker.value) {
@@ -470,42 +483,50 @@ onMounted(() => {
<a-form :model="queryParams" name="queryParams" layout="horizontal">
<a-row :gutter="16">
<a-col :lg="6" :md="12" :xs="24">
<a-form-item label="字典名称" name="dictName">
<a-form-item
:label="t('views.system.dict.dictName')"
name="dictName"
>
<a-input
v-model:value="queryParams.dictName"
allow-clear
placeholder="请输入字典名称"
></a-input>
</a-form-item>
</a-col>
<a-col :lg="6" :md="12" :xs="24">
<a-form-item label="字典类型" name="dictType">
<a-form-item
:label="t('views.system.dict.dictType')"
name="dictType"
>
<a-input
v-model:value="queryParams.dictType"
allow-clear
placeholder="请输入字典类型"
></a-input>
</a-form-item>
</a-col>
<a-col :lg="4" :md="12" :xs="24">
<a-form-item label="字典状态" name="status">
<a-form-item
:label="t('views.system.dict.dictSatus')"
name="status"
>
<a-select
v-model:value="queryParams.status"
allow-clear
placeholder="请选择"
:options="dict.sysNormalDisable"
>
</a-select>
</a-form-item>
</a-col>
<a-col :lg="8" :md="12" :xs="24">
<a-form-item label="创建时间" name="queryRangePicker">
<a-form-item
:label="t('views.system.dict.createTime')"
name="queryRangePicker"
>
<a-range-picker
v-model:value="queryRangePicker"
allow-clear
bordered
value-format="YYYY-MM-DD"
:placeholder="['创建开始', '创建结束']"
style="width: 100%"
></a-range-picker>
</a-form-item>
@@ -515,11 +536,11 @@ onMounted(() => {
<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>
@@ -538,7 +559,7 @@ onMounted(() => {
v-perms:has="['system:dict:add']"
>
<template #icon><PlusOutlined /></template>
新建
{{ t('common.addText') }}
</a-button>
<a-button
type="default"
@@ -548,7 +569,7 @@ onMounted(() => {
v-perms:has="['system:dict:remove']"
>
<template #icon><DeleteOutlined /></template>
删除
{{ t('common.deleteText') }}
</a-button>
<a-button
type="default"
@@ -556,7 +577,7 @@ onMounted(() => {
v-perms:has="['system:dict:data']"
>
<template #icon><ContainerOutlined /></template>
字典数据
{{ t('views.system.dict.dictData') }}
</a-button>
<a-button
type="dashed"
@@ -565,7 +586,7 @@ onMounted(() => {
v-perms:has="['system:dict:remove']"
>
<template #icon><SyncOutlined /></template>
刷新缓存
{{ t('views.system.dict.reload') }}
</a-button>
<a-button
type="dashed"
@@ -573,7 +594,7 @@ onMounted(() => {
v-perms:has="['system:dict:export']"
>
<template #icon><ExportOutlined /></template>
导出
{{ t('common.export') }}
</a-button>
</a-space>
</template>
@@ -582,31 +603,31 @@ onMounted(() => {
<template #extra>
<a-space :size="8" align="center">
<a-tooltip>
<template #title>搜索栏</template>
<template #title>{{ t('common.searchBarText') }}</template>
<a-switch
v-model:checked="tableState.seached"
checked-children=""
un-checked-children=""
:checked-children="t('common.switch.show')"
:un-checked-children="t('common.switch.hide')"
size="small"
/>
</a-tooltip>
<a-tooltip>
<template #title>表格斑马纹</template>
<template #title>{{ t('common.zebra') }}</template>
<a-switch
v-model:checked="tableState.striped"
checked-children=""
un-checked-children=""
:checked-children="t('common.switch.show')"
:un-checked-children="t('common.switch.hide')"
size="small"
/>
</a-tooltip>
<a-tooltip>
<template #title>刷新</template>
<template #title>{{ t('common.reloadText') }}</template>
<a-button type="text" @click.prevent="fnGetList()">
<template #icon><ReloadOutlined /></template>
</a-button>
</a-tooltip>
<a-tooltip placement="topRight">
<template #title>密度</template>
<template #title>{{ t('common.sizeText') }}</template>
<a-dropdown placement="bottomRight" trigger="click">
<a-button type="text">
<template #icon><ColumnHeightOutlined /></template>
@@ -616,9 +637,15 @@ onMounted(() => {
:selected-keys="[tableState.size as string]"
@click="fnTableSize"
>
<a-menu-item key="default">默认</a-menu-item>
<a-menu-item key="middle">中等</a-menu-item>
<a-menu-item key="small">紧凑</a-menu-item>
<a-menu-item key="default"
>{{ t('common.size.default') }}
</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>
</template>
</a-dropdown>
@@ -650,7 +677,7 @@ onMounted(() => {
<template v-if="column.key === 'dictId'">
<a-space :size="8" align="center">
<a-tooltip>
<template #title>查看详情</template>
<template #title>{{ t('common.viewText') }}</template>
<a-button
type="link"
@click.prevent="fnModalVisibleByVive(record.dictId)"
@@ -660,7 +687,7 @@ onMounted(() => {
</a-button>
</a-tooltip>
<a-tooltip>
<template #title>编辑</template>
<template #title>{{ t('common.editText') }}</template>
<a-button
type="link"
@click.prevent="fnModalVisibleByEdit(record.dictId)"
@@ -670,7 +697,7 @@ onMounted(() => {
</a-button>
</a-tooltip>
<a-tooltip>
<template #title>删除</template>
<template #title>{{ t('common.deleteText') }}</template>
<a-button
type="link"
@click.prevent="fnRecordDelete(record.dictId)"
@@ -680,7 +707,9 @@ onMounted(() => {
</a-button>
</a-tooltip>
<a-tooltip>
<template #title>字典数据</template>
<template #title>
{{ t('views.system.dict.dictData') }}
</template>
<a-button
type="link"
@click.prevent="fnDataView(record.dictId)"
@@ -705,12 +734,15 @@ onMounted(() => {
<a-form layout="horizontal">
<a-row :gutter="16">
<a-col :lg="12" :md="12" :xs="24">
<a-form-item label="字典编号" name="dictId">
<a-form-item :label="t('views.system.dict.dictId')" name="dictId">
{{ modalState.from.dictId }}
</a-form-item>
</a-col>
<a-col :lg="12" :md="12" :xs="24">
<a-form-item label="字典状态" name="status">
<a-form-item
:label="t('views.system.dict.dictSatus')"
name="status"
>
<DictTag
:options="dict.sysNormalDisable"
:value="modalState.from.status"
@@ -718,19 +750,20 @@ onMounted(() => {
</a-form-item>
</a-col>
</a-row>
<a-form-item label="字典名称" name="dictName">
<a-form-item :label="t('views.system.dict.dictName')" name="dictName">
{{ modalState.from.dictName }}
</a-form-item>
<a-form-item label="字典类型" name="dictType">
<a-form-item :label="t('views.system.dict.dictType')" name="dictType">
{{ modalState.from.dictType }}
</a-form-item>
<a-form-item label="字典说明" name="remark">
<a-form-item :label="t('views.system.dict.mark')" name="remark">
{{ modalState.from.remark }}
</a-form-item>
</a-form>
<template #footer>
<a-button key="cancel" @click="fnModalCancel">关闭</a-button>
<a-button key="cancel" @click="fnModalCancel">{{
t('common.cancel')
}}</a-button>
</template>
</a-modal>
@@ -749,23 +782,24 @@ onMounted(() => {
<a-row :gutter="16">
<a-col :lg="18" :md="18" :xs="24">
<a-form-item
label="字典名称"
:label="t('views.system.dict.dictName')"
name="dictName"
v-bind="modalStateFrom.validateInfos.dictName"
>
<a-input
v-model:value="modalState.from.dictName"
allow-clear
placeholder="请输入字典名称"
></a-input>
</a-form-item>
</a-col>
<a-col :lg="6" :md="6" :xs="24">
<a-form-item label="字典状态" name="status">
<a-form-item
:label="t('views.system.dict.dictStatus')"
name="status"
>
<a-select
v-model:value="modalState.from.status"
default-value="0"
placeholder="字典状态"
:options="dict.sysNormalDisable"
>
</a-select>
@@ -773,26 +807,24 @@ onMounted(() => {
</a-col>
<a-col :lg="18" :md="18" :xs="24">
<a-form-item
label="字典类型"
:label="t('views.system.dict.dictType')"
name="dictType"
v-bind="modalStateFrom.validateInfos.dictType"
>
<a-input
v-model:value="modalState.from.dictType"
allow-clear
placeholder="请输入字典类型"
></a-input>
</a-form-item>
</a-col>
</a-row>
<a-form-item label="字典说明" name="remark">
<a-form-item :label="t('views.system.dict.mark')" name="remark">
<a-textarea
v-model:value="modalState.from.remark"
:auto-size="{ minRows: 4, maxRows: 6 }"
:maxlength="450"
:show-count="true"
placeholder="请输入参数说明"
/>
</a-form-item>
</a-form>