重新整理仓库

This commit is contained in:
2025-07-25 13:03:01 +08:00
commit 469af7f7f9
979 changed files with 171962 additions and 0 deletions

View File

@@ -0,0 +1,181 @@
<!-- 字典项编辑弹窗 -->
<template>
<ele-modal
:width="460"
:visible="visible"
:confirm-loading="loading"
:body-style="{ paddingBottom: '8px' }"
:title="isUpdate ? '修改字典项' : '添加字典项'"
@update:visible="updateVisible"
@ok="save"
>
<a-form
:label-col="{ md: { span: 6 }, sm: { span: 6 }, xs: { span: 24 } }"
:wrapper-col="{ md: { span: 18 }, sm: { span: 18 }, xs: { span: 24 } }"
>
<a-form-item label="字典项名称" v-bind="validateInfos.dictDataName">
<a-input
allow-clear
:maxlength="20"
placeholder="请输入字典项名称"
v-model:value="form.dictDataName"
/>
</a-form-item>
<a-form-item label="字典项值" v-bind="validateInfos.dictDataCode">
<a-input
allow-clear
:maxlength="20"
placeholder="请输入字典项值"
v-model:value="form.dictDataCode"
/>
</a-form-item>
<a-form-item label="排序号" v-bind="validateInfos.sortNumber">
<a-input-number
:min="0"
:max="9999"
class="ele-fluid"
placeholder="请输入排序号"
v-model:value="form.sortNumber"
/>
</a-form-item>
<a-form-item label="备注">
<a-textarea
:rows="4"
:maxlength="200"
placeholder="请输入备注"
v-model:value="form.comments"
/>
</a-form-item>
<a-divider style="margin-bottom: 20px" />
<a-form-item label="预留字段" v-bind="validateInfos.component">
<a-input
allow-clear
:maxlength="100"
placeholder="预设字段:组件路径(选填)"
v-model:value="form.component"
/>
</a-form-item>
</a-form>
</ele-modal>
</template>
<script lang="ts" setup>
import { ref, reactive, watch } from 'vue';
import { Form, message } from 'ant-design-vue';
import { assignObject } from 'ele-admin-pro';
import {
addDictionaryData,
updateDictionaryData
} from '@/api/system/dictionary-data';
import type { DictionaryData } from '@/api/system/dictionary-data/model';
const useForm = Form.useForm;
const emit = defineEmits<{
(e: 'done'): void;
(e: 'update:visible', visible: boolean): void;
}>();
const props = defineProps<{
// 弹窗是否打开
visible: boolean;
// 修改回显的数据
data?: DictionaryData | null;
// 字典id
dictId: number;
}>();
// 是否是修改
const isUpdate = ref(false);
// 提交状态
const loading = ref(false);
// 表单数据
const form = reactive<DictionaryData>({
dictDataId: undefined,
dictDataName: '',
dictDataCode: '',
path: '',
component: '',
sortNumber: 100,
comments: ''
});
// 表单验证规则
const rules = reactive({
dictDataName: [
{
required: true,
message: '请输入字典项名称',
type: 'string',
trigger: 'blur'
}
],
dictDataCode: [
{
required: true,
message: '请输入字典项值',
type: 'string',
trigger: 'blur'
}
],
sortNumber: [
{
required: true,
message: '请输入排序号',
type: 'number',
trigger: 'blur'
}
]
});
const { resetFields, validate, validateInfos } = useForm(form, rules);
/* 保存编辑 */
const save = () => {
validate()
.then(() => {
loading.value = true;
const saveOrUpdate = isUpdate.value
? updateDictionaryData
: addDictionaryData;
saveOrUpdate({
...form,
dictId: props.dictId
})
.then((msg) => {
loading.value = false;
message.success(msg);
updateVisible(false);
emit('done');
})
.catch((e) => {
loading.value = false;
message.error(e.message);
});
})
.catch(() => {});
};
/* 更新visible */
const updateVisible = (value) => {
emit('update:visible', value);
};
watch(
() => props.visible,
(visible) => {
if (visible) {
if (props.data) {
assignObject(form, props.data);
isUpdate.value = true;
} else {
isUpdate.value = false;
}
} else {
resetFields();
}
}
);
</script>

View File

@@ -0,0 +1,70 @@
<!-- 搜索表单 -->
<template>
<a-row :gutter="16">
<a-col :xl="6" :lg="8" :md="11" :sm="24" :xs="24">
<a-input
v-model:value.trim="where.keywords"
placeholder="输入关键字搜索"
allow-clear
/>
</a-col>
<a-col :xl="18" :lg="16" :md="13" :sm="24" :xs="24">
<a-space :size="10" style="flex-wrap: wrap">
<a-button type="primary" class="ele-btn-icon" @click="search">
<template #icon>
<search-outlined />
</template>
<span>查询</span>
</a-button>
<a-button type="primary" class="ele-btn-icon" @click="add">
<template #icon>
<plus-outlined />
</template>
<span>新建</span>
</a-button>
<a-button danger type="primary" class="ele-btn-icon" @click="remove">
<template #icon>
<delete-outlined />
</template>
<span>删除</span>
</a-button>
</a-space>
</a-col>
</a-row>
</template>
<script lang="ts" setup>
import {
PlusOutlined,
DeleteOutlined,
SearchOutlined
} from '@ant-design/icons-vue';
import useSearch from '@/utils/use-search';
import type { DictionaryDataParam } from '@/api/system/dictionary-data/model';
const emit = defineEmits<{
(e: 'search', where?: DictionaryDataParam): void;
(e: 'add'): void;
(e: 'remove'): void;
}>();
// 表单数据
const { where } = useSearch<DictionaryDataParam>({
keywords: ''
});
/* 搜索 */
const search = () => {
emit('search', where);
};
/* 添加 */
const add = () => {
emit('add');
};
/* 删除 */
const remove = () => {
emit('remove');
};
</script>

View File

@@ -0,0 +1,207 @@
<template>
<!-- 表格 -->
<ele-pro-table
ref="tableRef"
row-key="dictDataId"
:columns="columns"
:datasource="datasource"
tool-class="ele-toolbar-form"
v-model:selection="selection"
:row-selection="{ columnWidth: 48 }"
:scroll="{ x: 800 }"
height="calc(100vh - 290px)"
tools-theme="default"
bordered
class="sys-dict-data-table"
>
<template #toolbar>
<dict-data-search
@search="reload"
@add="openEdit()"
@remove="removeBatch"
/>
</template>
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'action'">
<a-space>
<a @click="openEdit(record)">修改</a>
<a-divider type="vertical" />
<a-popconfirm
title="确定要删除此字典项吗?"
@confirm="remove(record)"
>
<a class="ele-text-danger">删除</a>
</a-popconfirm>
</a-space>
</template>
</template>
</ele-pro-table>
<!-- 编辑弹窗 -->
<dict-data-edit
v-model:visible="showEdit"
:data="current"
:dict-id="dictId"
@done="reload"
/>
</template>
<script lang="ts" setup>
import { createVNode, ref, watch } from 'vue';
import { message, Modal } from 'ant-design-vue';
import { ExclamationCircleOutlined } from '@ant-design/icons-vue';
import type { EleProTable } from 'ele-admin-pro';
import type {
DatasourceFunction,
ColumnItem
} from 'ele-admin-pro/es/ele-pro-table/types';
import { toDateString } from 'ele-admin-pro';
import DictDataSearch from './dict-data-search.vue';
import DictDataEdit from './dict-data-edit.vue';
import {
pageDictionaryData,
removeDictionaryData,
removeDictionaryDataBatch
} from '@/api/system/dictionary-data';
import type {
DictionaryData,
DictionaryDataParam
} from '@/api/system/dictionary-data/model';
const props = defineProps<{
// 字典id
dictId: number;
}>();
// 表格实例
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
// 表格列配置
const columns = ref<ColumnItem[]>([
{
title: '字典项名称',
dataIndex: 'dictDataName',
ellipsis: true,
sorter: true
},
{
title: '字典项值',
dataIndex: 'dictDataCode',
ellipsis: true,
sorter: true
},
{
title: '排序号',
dataIndex: 'sortNumber',
sorter: true,
width: 120,
align: 'center'
},
{
title: '创建时间',
dataIndex: 'createTime',
sorter: true,
ellipsis: true,
customRender: ({ text }) => toDateString(text)
},
{
title: '操作',
key: 'action',
width: 130,
align: 'center',
hideInSetting: true
}
]);
// 表格选中数据
const selection = ref<DictionaryData[]>([]);
// 当前编辑数据
const current = ref<DictionaryData | null>(null);
// 是否显示编辑弹窗
const showEdit = ref(false);
// 表格数据源
const datasource: DatasourceFunction = ({ page, limit, where, orders }) => {
return pageDictionaryData({
...where,
...orders,
page,
limit,
dictId: props.dictId
});
};
/* 刷新表格 */
const reload = (where?: DictionaryDataParam) => {
tableRef?.value?.reload({ page: 1, where });
};
/* 打开编辑弹窗 */
const openEdit = (row?: DictionaryData) => {
current.value = row ?? null;
showEdit.value = true;
};
/* 删除单个 */
const remove = (row: DictionaryData) => {
const hide = message.loading('请求中..', 0);
removeDictionaryData(row.dictDataId)
.then((msg) => {
hide();
message.success(msg);
reload();
})
.catch((e) => {
hide();
message.error(e.message);
});
};
/* 批量删除 */
const removeBatch = () => {
if (!selection.value.length) {
message.error('请至少选择一条数据');
return;
}
Modal.confirm({
title: '提示',
content: '确定要删除选中的字典项吗?',
icon: createVNode(ExclamationCircleOutlined),
maskClosable: true,
onOk: () => {
const hide = message.loading('请求中..', 0);
removeDictionaryDataBatch(selection.value.map((d) => d.dictDataId))
.then((msg) => {
hide();
message.success(msg);
reload();
})
.catch((e) => {
hide();
message.error(e.message);
});
}
});
};
// 监听字典id变化
watch(
() => props.dictId,
() => {
reload();
}
);
</script>
<style lang="less" scoped>
.sys-dict-data-table :deep(.ant-table-body) {
overflow: auto !important;
overflow: overlay !important;
}
.sys-dict-data-table :deep(.ant-table-pagination.ant-pagination) {
padding: 0 4px;
margin-bottom: 0;
}
</style>

View File

@@ -0,0 +1,160 @@
<!-- 字典编辑弹窗 -->
<template>
<ele-modal
:width="460"
:visible="visible"
:confirm-loading="loading"
:title="isUpdate ? '修改字典' : '添加字典'"
:body-style="{ paddingBottom: '8px' }"
@update:visible="updateVisible"
@ok="save"
>
<a-form
:label-col="{ md: { span: 5 }, sm: { span: 5 }, xs: { span: 24 } }"
:wrapper-col="{ md: { span: 19 }, sm: { span: 19 }, xs: { span: 24 } }"
>
<a-form-item label="字典名称" v-bind="validateInfos.dictName">
<a-input
allow-clear
:maxlength="20"
placeholder="请输入字典名称"
v-model:value="form.dictName"
/>
</a-form-item>
<a-form-item label="字典标识" v-bind="validateInfos.dictCode">
<a-input
allow-clear
:maxlength="20"
placeholder="请输入字典标识"
v-model:value="form.dictCode"
/>
</a-form-item>
<a-form-item label="排序号" v-bind="validateInfos.sortNumber">
<a-input-number
:min="0"
:max="9999"
class="ele-fluid"
placeholder="请输入排序号"
v-model:value="form.sortNumber"
/>
</a-form-item>
<a-form-item label="备注">
<a-textarea
:rows="4"
:maxlength="200"
placeholder="请输入备注"
v-model:value="form.comments"
/>
</a-form-item>
</a-form>
</ele-modal>
</template>
<script lang="ts" setup>
import { ref, reactive, watch } from 'vue';
import { Form, message } from 'ant-design-vue';
import { assignObject } from 'ele-admin-pro';
import { addDictionary, updateDictionary } from '@/api/system/dictionary';
import type { Dictionary } from '@/api/system/dictionary/model';
const useForm = Form.useForm;
const emit = defineEmits<{
(e: 'done'): void;
(e: 'update:visible', visible: boolean): void;
}>();
const props = defineProps<{
// 弹窗是否打开
visible: boolean;
// 修改回显的数据
data?: Dictionary | null;
}>();
// 是否是修改
const isUpdate = ref(false);
// 提交状态
const loading = ref(false);
// 表单数据
const form = reactive<Dictionary>({
dictId: undefined,
dictName: '',
dictCode: '',
sortNumber: 100,
comments: ''
});
// 表单验证规则
const rules = reactive({
dictName: [
{
required: true,
message: '请输入字典名称',
type: 'string',
trigger: 'blur'
}
],
dictCode: [
{
required: true,
message: '请输入字典标识',
type: 'string',
trigger: 'blur'
}
],
sortNumber: [
{
required: true,
message: '请输入排序号',
type: 'number',
trigger: 'blur'
}
]
});
const { resetFields, validate, validateInfos } = useForm(form, rules);
/* 保存编辑 */
const save = () => {
validate()
.then(() => {
loading.value = true;
const saveOrUpdate = isUpdate.value ? updateDictionary : addDictionary;
saveOrUpdate(form)
.then((msg) => {
loading.value = false;
message.success(msg);
updateVisible(false);
emit('done');
})
.catch((e) => {
loading.value = false;
message.error(e.message);
});
})
.catch(() => {});
};
/* 更新visible */
const updateVisible = (value: boolean) => {
emit('update:visible', value);
};
watch(
() => props.visible,
(visible) => {
if (visible) {
if (props.data) {
assignObject(form, props.data);
isUpdate.value = true;
} else {
isUpdate.value = false;
}
} else {
resetFields();
}
}
);
</script>