fix: 页面字段/接口调整

This commit is contained in:
TsMask
2025-02-20 10:47:23 +08:00
parent 814bae0b94
commit 485fa89833
85 changed files with 1133 additions and 1792 deletions

View File

@@ -1,6 +1,5 @@
<script setup lang="ts">
import { useRoute, useRouter } from 'vue-router';
import { getLocalColor, changePrimaryColor } from '@/hooks/useTheme';
import { reactive, ref, onMounted, toRaw } from 'vue';
import { PageContainer } from 'antdv-pro-layout';
import { ProModal } from 'antdv-pro-modal';
@@ -16,7 +15,7 @@ import {
addData,
updateData,
} from '@/api/system/dict/data';
import { getDictOptionselect, getType } from '@/api/system/dict/type';
import { getDictOption, getType } from '@/api/system/dict/type';
import { saveAs } from 'file-saver';
import { parseDateToStr } from '@/utils/date-utils';
import useTabsStore from '@/store/modules/tabs';
@@ -34,18 +33,6 @@ const dictId = route.params && (route.params.dictId as string);
const zh = currentLocale.value === 'zh_CN';
let color = ref<string>(getLocalColor());
/**改变主题色 */
function fnColorChange(e: Event) {
const target = e.target as HTMLInputElement;
if (target.nodeName === 'INPUT') {
changePrimaryColor(target.value ?? '#1890ff');
} else {
changePrimaryColor();
}
color.value = getLocalColor();
}
/**标签类型数据固定项 */
const tagTypeOptions = ref([
{ value: '', label: zh ? '普通文本' : 'Plain text' },
@@ -85,9 +72,9 @@ let queryParams = reactive({
/**字典名称 */
dictType: '',
/**数据标签 */
dictLabel: '',
dataLabel: '',
/**数据状态 */
status: undefined,
statusFlag: undefined,
/**当前页数 */
pageNum: 1,
/**每页条数 */
@@ -98,16 +85,16 @@ let queryParams = reactive({
function fnQueryReset() {
if (dictId && dictId !== '0') {
queryParams = Object.assign(queryParams, {
dictLabel: '',
status: undefined,
dataLabel: '',
statusFlag: undefined,
pageNum: 1,
pageSize: 20,
});
} else {
queryParams = Object.assign(queryParams, {
dictType: '',
dictLabel: '',
status: undefined,
dataLabel: '',
statusFlag: undefined,
pageNum: 1,
pageSize: 20,
});
@@ -143,33 +130,33 @@ let tableState: TabeStateType = reactive({
/**表格字段列 */
let tableColumns: ColumnsType = [
{
title: t('views.system.dictData.dictCode'),
dataIndex: 'dictCode',
title: t('views.system.dictData.dataId'),
dataIndex: 'dataId',
align: 'left',
width: 100,
},
{
title: t('views.system.dictData.dictLabel'),
dataIndex: 'dictLabel',
title: t('views.system.dictData.dataLabel'),
dataIndex: 'dataLabel',
align: 'left',
width: 200,
},
{
title: t('views.system.dictData.dictValue'),
dataIndex: 'dictValue',
title: t('views.system.dictData.dataValue'),
dataIndex: 'dataValue',
align: 'left',
width: 200,
},
{
title: t('views.system.dictData.dictSort'),
dataIndex: 'dictSort',
title: t('views.system.dictData.dataSort'),
dataIndex: 'dataSort',
align: 'left',
width: 100,
},
{
title: t('views.system.dictData.status'),
dataIndex: 'status',
key: 'status',
title: t('views.system.dictData.statusFlag'),
dataIndex: 'statusFlag',
key: 'statusFlag',
align: 'left',
width: 100,
},
@@ -185,7 +172,7 @@ let tableColumns: ColumnsType = [
},
{
title: t('common.operate'),
key: 'dictCode',
key: 'dataId',
align: 'left',
},
];
@@ -249,15 +236,15 @@ let modalState: ModalStateType = reactive({
openByEdit: false,
title: '字典数据',
from: {
dictCode: undefined,
dictLabel: '',
dictSort: 0,
dataId: undefined,
dataLabel: '',
dataSort: 0,
dictType: 'sys_oper_type',
dictValue: '',
dataValue: '',
tagClass: '',
tagType: '',
remark: '',
status: '0',
statusFlag: '0',
createTime: 0,
createBy: undefined,
},
@@ -268,20 +255,26 @@ let modalState: ModalStateType = reactive({
const modalStateFrom = Form.useForm(
modalState.from,
reactive({
dictLabel: [
dictType: [
{
required: true,
min: 1,
max: 50,
message: t('views.system.dictData.dictLabelPleac'),
message: t('common.selectPlease'),
},
],
dictValue: [
dataLabel: [
{
required: true,
min: 1,
max: 50,
message: t('views.system.dictData.dictValuePleac'),
message: t('views.system.dictData.dataLabelPleac'),
},
],
dataValue: [
{
required: true,
min: 1,
max: 50,
message: t('views.system.dictData.dataValuePleac'),
},
],
})
@@ -299,10 +292,10 @@ function fnModalVisibleByVive(row: Record<string, string>) {
/**
* 对话框弹出显示为 新增或者修改
* @param dictCode 数据编号id, 不传为新增
* @param dataId 数据编号id, 不传为新增
*/
function fnModalVisibleByEdit(dictCode?: string | number, record?: any) {
if (!dictCode) {
function fnModalVisibleByEdit(dataId?: string | number, record?: any) {
if (!dataId) {
modalStateFrom.resetFields();
modalState.from.dictType = queryParams.dictType;
modalState.title = t('views.system.dictData.addInfo');
@@ -311,7 +304,7 @@ function fnModalVisibleByEdit(dictCode?: string | number, record?: any) {
if (modalState.confirmLoading) return;
const hide = message.loading(t('common.loading'), 0);
modalState.confirmLoading = true;
getData(dictCode).then(res => {
getData(dataId).then(res => {
modalState.confirmLoading = false;
hide();
if (res.code === RESULT_CODE_SUCCESS) {
@@ -335,7 +328,7 @@ function fnModalOk() {
.then(() => {
modalState.confirmLoading = true;
const from = toRaw(modalState.from);
const dictData = from.dictCode ? updateData(from) : addData(from);
const dictData = from.dataId ? updateData(from) : addData(from);
const key = 'dictData';
message.loading({ content: t('common.loading'), key });
dictData
@@ -378,19 +371,19 @@ function fnModalCancel() {
/**
* 字典删除
* @param dictCode 字典代码
* @param dataId 字典代码
*/
function fnRecordDelete(dictCode: string = '0') {
if (dictCode === '0') {
dictCode = tableState.selectedRowKeys.join(',');
function fnRecordDelete(dataId: string = '0') {
if (dataId === '0') {
dataId = tableState.selectedRowKeys.join(',');
}
Modal.confirm({
title: t('common.tipTitle'),
content: t('views.system.dictData.delTip', { txt: dictCode }),
content: t('views.system.dictData.delTip', { txt: dataId }),
onOk() {
const key = 'delData';
message.loading({ content: t('common.loading'), key });
delData(dictCode).then(res => {
delData(dataId).then(res => {
if (res.code === RESULT_CODE_SUCCESS) {
message.success({
content: t('views.system.dictData.delOk'),
@@ -456,13 +449,14 @@ function fnGetList(pageNum?: number) {
queryParams.pageNum = pageNum;
}
listData(toRaw(queryParams)).then(res => {
if (res.code === RESULT_CODE_SUCCESS && Array.isArray(res.rows)) {
if (res.code === RESULT_CODE_SUCCESS) {
// 取消勾选
if (tableState.selectedRowKeys.length > 0) {
tableState.selectedRowKeys = [];
}
tablePagination.total = res.total;
tableState.data = res.rows;
const { total, rows } = res.data;
tablePagination.total = total;
tableState.data = rows;
if (
tablePagination.total <=
(queryParams.pageNum - 1) * tablePagination.pageSize &&
@@ -478,20 +472,19 @@ function fnGetList(pageNum?: number) {
onMounted(() => {
// 初始字典数据
Promise.allSettled([
getDict('sys_normal_disable'),
getDictOptionselect(),
]).then(resArr => {
if (resArr[0].status === 'fulfilled') {
dict.sysNormalDisable = resArr[0].value;
}
if (resArr[1].status === 'fulfilled') {
const dicts = resArr[1].value;
if (dicts.code === RESULT_CODE_SUCCESS) {
dict.sysDictType = dicts.data;
Promise.allSettled([getDict('sys_normal_disable'), getDictOption()]).then(
resArr => {
if (resArr[0].status === 'fulfilled') {
dict.sysNormalDisable = resArr[0].value;
}
if (resArr[1].status === 'fulfilled') {
const dicts = resArr[1].value;
if (dicts.code === RESULT_CODE_SUCCESS) {
dict.sysDictType = dicts.data;
}
}
}
});
);
// 指定字典id列表数据
if (dictId && dictId !== '0') {
getType(dictId).then(res => {
@@ -535,11 +528,11 @@ onMounted(() => {
</a-col>
<a-col :lg="6" :md="12" :xs="24">
<a-form-item
:label="t('views.system.dictData.dictLabel')"
name="dictLabel"
:label="t('views.system.dictData.dataLabel')"
name="dataLabel"
>
<a-input
v-model:value="queryParams.dictLabel"
v-model:value="queryParams.dataLabel"
allow-clear
:placeholder="t('common.inputPlease')"
></a-input>
@@ -547,11 +540,11 @@ onMounted(() => {
</a-col>
<a-col :lg="6" :md="12" :xs="24">
<a-form-item
:label="t('views.system.dictData.status')"
name="status"
:label="t('views.system.dictData.statusFlag')"
name="statusFlag"
>
<a-select
v-model:value="queryParams.status"
v-model:value="queryParams.statusFlag"
allow-clear
:placeholder="t('common.selectPlease')"
:options="dict.sysNormalDisable"
@@ -662,7 +655,7 @@ onMounted(() => {
<!-- 表格列表 -->
<a-table
class="table"
row-key="dictCode"
row-key="dataId"
:columns="tableColumns"
:loading="tableState.loading"
:data-source="tableState.data"
@@ -676,10 +669,13 @@ onMounted(() => {
}"
>
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'status'">
<DictTag :options="dict.sysNormalDisable" :value="record.status" />
<template v-if="column.key === 'statusFlag'">
<DictTag
:options="dict.sysNormalDisable"
:value="record.statusFlag"
/>
</template>
<template v-if="column.key === 'dictCode'">
<template v-if="column.key === 'dataId'">
<a-space :size="8" align="center">
<a-tooltip>
<template #title>{{ t('common.viewText') }}</template>
@@ -695,7 +691,7 @@ onMounted(() => {
<template #title>{{ t('common.editText') }}</template>
<a-button
type="link"
@click.prevent="fnModalVisibleByEdit(record.dictCode, record)"
@click.prevent="fnModalVisibleByEdit(record.dataId, record)"
v-perms:has="['system:dict:edit']"
>
<template #icon><FormOutlined /></template>
@@ -705,7 +701,7 @@ onMounted(() => {
<template #title>{{ t('common.deleteText') }}</template>
<a-button
type="link"
@click.prevent="fnRecordDelete(record.dictCode)"
@click.prevent="fnRecordDelete(record.dataId)"
v-perms:has="['system:dict:remove']"
>
<template #icon><DeleteOutlined /></template>
@@ -753,20 +749,20 @@ onMounted(() => {
<a-row>
<a-col :lg="12" :md="12" :xs="24">
<a-form-item
:label="t('views.system.dictData.dictCode')"
name="dictCode"
:label="t('views.system.dictData.dataId')"
name="dataId"
>
{{ modalState.from.dictCode }}
{{ modalState.from.dataId }}
</a-form-item>
</a-col>
<a-col :lg="12" :md="12" :xs="24">
<a-form-item
:label="t('views.system.dictData.status')"
name="status"
:label="t('views.system.dictData.statusFlag')"
name="statusFlag"
>
<DictTag
:options="dict.sysNormalDisable"
:value="modalState.from.status"
:value="modalState.from.statusFlag"
/>
</a-form-item>
</a-col>
@@ -774,18 +770,18 @@ onMounted(() => {
<a-row>
<a-col :lg="12" :md="12" :xs="24">
<a-form-item
:label="t('views.system.dictData.dictLabel')"
name="dictLabel"
:label="t('views.system.dictData.dataLabel')"
name="dataLabel"
>
{{ modalState.from.dictLabel }}
{{ modalState.from.dataLabel }}
</a-form-item>
</a-col>
<a-col :lg="12" :md="12" :xs="24">
<a-form-item
:label="t('views.system.dictData.dictValue')"
name="dictValue"
:label="t('views.system.dictData.dataValue')"
name="dataValue"
>
{{ modalState.from.dictValue }}
{{ modalState.from.dataValue }}
</a-form-item>
</a-col>
</a-row>
@@ -818,16 +814,16 @@ onMounted(() => {
>
<DictTag
:options="parseDataDict(modalState.from)"
:value="modalState.from.dictValue"
:value="modalState.from.dataValue"
/>
</a-form-item>
</a-col>
<a-col :lg="12" :md="12" :xs="24">
<a-form-item
:label="t('views.system.dictData.dictSort')"
name="dictSort"
:label="t('views.system.dictData.dataSort')"
name="dataSort"
>
{{ modalState.from.dictSort }}
{{ modalState.from.dataSort }}
</a-form-item>
</a-col>
</a-row>
@@ -875,24 +871,25 @@ onMounted(() => {
<a-form-item
:label="t('views.system.dictData.dictType')"
name="dictType"
v-bind="modalStateFrom.validateInfos.dictType"
>
<a-select
v-model:value="modalState.from.dictType"
default-value="sys_oper_type"
:placeholder="t('common.selectPlease')"
:options="dict.sysDictType"
:disabled="true"
:disabled="dictId !== '0'"
>
</a-select>
</a-form-item>
</a-col>
<a-col :lg="12" :md="12" :xs="24">
<a-form-item
:label="t('views.system.dictData.status')"
name="status"
:label="t('views.system.dictData.statusFlag')"
name="statusFlag"
>
<a-select
v-model:value="modalState.from.status"
v-model:value="modalState.from.statusFlag"
default-value="0"
:placeholder="t('common.selectPlease')"
:options="dict.sysNormalDisable"
@@ -904,27 +901,27 @@ onMounted(() => {
<a-row>
<a-col :lg="12" :md="12" :xs="24">
<a-form-item
:label="t('views.system.dictData.dictLabel')"
name="dictLabel"
v-bind="modalStateFrom.validateInfos.dictLabel"
:label="t('views.system.dictData.dataLabel')"
name="dataLabel"
v-bind="modalStateFrom.validateInfos.dataLabel"
>
<a-input
v-model:value="modalState.from.dictLabel"
v-model:value="modalState.from.dataLabel"
allow-clear
:placeholder="t('views.system.dictData.dictLabelPleac')"
:placeholder="t('views.system.dictData.dataLabelPleac')"
></a-input>
</a-form-item>
</a-col>
<a-col :lg="12" :md="12" :xs="24">
<a-form-item
:label="t('views.system.dictData.dictValue')"
name="dictValue"
v-bind="modalStateFrom.validateInfos.dictValue"
:label="t('views.system.dictData.dataValue')"
name="dataValue"
v-bind="modalStateFrom.validateInfos.dataValue"
>
<a-input
v-model:value="modalState.from.dictValue"
v-model:value="modalState.from.dataValue"
allow-clear
:placeholder="t('views.system.dictData.dictValuePleac')"
:placeholder="t('views.system.dictData.dataValuePleac')"
></a-input>
</a-form-item>
</a-col>
@@ -965,11 +962,11 @@ onMounted(() => {
</a-col>
<a-col :lg="12" :md="12" :xs="24">
<a-form-item
:label="t('views.system.dictData.dictSort')"
name="dictSort"
:label="t('views.system.dictData.dataSort')"
name="dataSort"
>
<a-input-number
v-model:value="modalState.from.dictSort"
v-model:value="modalState.from.dataSort"
:min="0"
:max="65535"
:placeholder="t('common.inputPlease')"

View File

@@ -46,7 +46,7 @@ let queryParams = reactive({
/**字典类型 */
dictType: '',
/**字典状态 */
status: undefined,
statusFlag: undefined,
/**记录开始时间 */
beginTime: '',
/**记录结束时间 */
@@ -62,7 +62,7 @@ function fnQueryReset() {
queryParams = Object.assign(queryParams, {
dictName: '',
dictType: '',
status: undefined,
statusFlag: undefined,
beginTime: '',
endTime: '',
pageNum: 1,
@@ -119,8 +119,8 @@ let tableColumns: ColumnsType = [
},
{
title: t('views.system.dict.dictSatus'),
dataIndex: 'status',
key: 'status',
dataIndex: 'statusFlag',
key: 'statusFlag',
align: 'center',
width: 100,
},
@@ -202,7 +202,7 @@ let modalState: ModalStateType = reactive({
dictId: undefined,
dictName: '',
dictType: undefined,
status: '0',
statusFlag: '0',
remark: undefined,
},
confirmLoading: false,
@@ -446,13 +446,14 @@ function fnGetList(pageNum?: number) {
queryParams.beginTime = queryRangePicker.value[0];
queryParams.endTime = queryRangePicker.value[1];
listType(toRaw(queryParams)).then(res => {
if (res.code === RESULT_CODE_SUCCESS && Array.isArray(res.rows)) {
if (res.code === RESULT_CODE_SUCCESS) {
// 取消勾选
if (tableState.selectedRowKeys.length > 0) {
tableState.selectedRowKeys = [];
}
tablePagination.total = res.total;
tableState.data = res.rows;
const { total, rows } = res.data;
tablePagination.total = total;
tableState.data = rows;
if (
tablePagination.total <=
(queryParams.pageNum - 1) * tablePagination.pageSize &&
@@ -513,10 +514,10 @@ onMounted(() => {
<a-col :lg="4" :md="12" :xs="24">
<a-form-item
:label="t('views.system.dict.dictSatus')"
name="status"
name="statusFlag"
>
<a-select
v-model:value="queryParams.status"
v-model:value="queryParams.statusFlag"
allow-clear
:options="dict.sysNormalDisable"
>
@@ -669,8 +670,8 @@ onMounted(() => {
}"
>
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'status'">
<DictTag :options="dict.sysNormalDisable" :value="record.status" />
<template v-if="column.key === 'statusFlag'">
<DictTag :options="dict.sysNormalDisable" :value="record.statusFlag" />
</template>
<template v-if="column.key === 'dictId'">
<a-space :size="8" align="center">
@@ -740,10 +741,10 @@ onMounted(() => {
<a-form-item :label="t('views.system.dict.dictType')" name="dictType">
{{ modalState.from.dictType }}
</a-form-item>
<a-form-item :label="t('views.system.dict.dictSatus')" name="status">
<a-form-item :label="t('views.system.dict.dictSatus')" name="statusFlag">
<DictTag
:options="dict.sysNormalDisable"
:value="modalState.from.status"
:value="modalState.from.statusFlag"
/>
</a-form-item>
<a-form-item :label="t('views.system.dict.mark')" name="remark">
@@ -800,9 +801,9 @@ onMounted(() => {
allow-clear
></a-input>
</a-form-item>
<a-form-item :label="t('views.system.dict.dictSatus')" name="status">
<a-form-item :label="t('views.system.dict.dictSatus')" name="statusFlag">
<a-select
v-model:value="modalState.from.status"
v-model:value="modalState.from.statusFlag"
default-value="0"
:options="dict.sysNormalDisable"
>