重新整理仓库

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>

View File

@@ -0,0 +1,203 @@
<template>
<div class="ele-body">
<a-card :bordered="false" :body-style="{ padding: '16px' }">
<ele-split-layout
width="366px"
allow-collapse
:right-style="{ overflow: 'hidden' }"
:style="{ minHeight: 'calc(100vh - 152px)' }"
>
<!-- 表格 -->
<ele-pro-table
ref="tableRef"
row-key="dictId"
:columns="columns"
:datasource="datasource"
v-model:current="current"
selection-type="radio"
:row-selection="{ columnWidth: 32 }"
:need-page="false"
:toolkit="[]"
height="calc(100vh - 290px)"
tools-theme="default"
bordered
class="sys-dict-table"
@done="done"
>
<template #toolbar>
<a-space :size="10">
<a-button type="primary" class="ele-btn-icon" @click="openEdit()">
<template #icon>
<plus-outlined />
</template>
<span>新建</span>
</a-button>
<a-button
type="primary"
:disabled="!current"
class="ele-btn-icon"
@click="openEdit(current)"
>
<template #icon>
<edit-outlined />
</template>
<span>修改</span>
</a-button>
<a-button
danger
type="primary"
:disabled="!current"
class="ele-btn-icon"
@click="remove"
>
<template #icon>
<delete-outlined />
</template>
<span>删除</span>
</a-button>
</a-space>
</template>
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'dictName'">
<a-space>
<a-tooltip :title="`${record.dictCode}`">
{{ record.dictName }}
<span class="dict-code">{{ record.dictCode }}</span>
</a-tooltip>
</a-space>
</template>
</template>
</ele-pro-table>
<template #content>
<dict-data
v-if="current && current.dictId"
:dict-id="current.dictId"
/>
</template>
</ele-split-layout>
</a-card>
<!-- 编辑弹窗 -->
<dict-edit v-model:visible="showEdit" :data="editData" @done="reload" />
</div>
</template>
<script lang="ts" setup>
import { createVNode, ref } from 'vue';
import { message, Modal } from 'ant-design-vue';
import {
PlusOutlined,
EditOutlined,
DeleteOutlined,
ExclamationCircleOutlined
} from '@ant-design/icons-vue';
import type { EleProTable } from 'ele-admin-pro';
import type {
DatasourceFunction,
ColumnItem,
EleProTableDone
} from 'ele-admin-pro/es/ele-pro-table/types';
import DictData from './components/dict-data.vue';
import DictEdit from './components/dict-edit.vue';
import { listDictionaries, removeDictionary } from '@/api/system/dictionary';
import type { Dictionary } from '@/api/system/dictionary/model';
// 表格实例
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
// 表格列配置
const columns = ref<ColumnItem[]>([
// {
// key: 'index',
// width: 45,
// ellipsis: true,
// align: 'center',
// fixed: 'left',
// hideInSetting: true,
// customRender: ({ index }) => index + (tableRef.value?.tableIndex ?? 0)
// },
{
title: 'ID',
dataIndex: 'dictId',
key: 'dictId',
width: 50,
align: 'center',
fixed: 'left'
},
{
title: '字典名称',
dataIndex: 'dictName',
key: 'dictName'
}
]);
// 表格选中数据
const current = ref<Dictionary | null>(null);
// 是否显示编辑弹窗
const showEdit = ref(false);
// 编辑回显数据
const editData = ref<Dictionary | null>(null);
// 表格数据源
const datasource: DatasourceFunction = () => {
return listDictionaries();
};
/* 表格渲染完成回调 */
const done: EleProTableDone<Dictionary> = (res) => {
if (res.data?.length) {
current.value = res.data[0];
}
};
/* 刷新表格 */
const reload = () => {
tableRef?.value?.reload();
};
/* 打开编辑弹窗 */
const openEdit = (row?: Dictionary | null) => {
editData.value = row ?? null;
showEdit.value = true;
};
/* 删除 */
const remove = () => {
Modal.confirm({
title: '提示',
content: '确定要删除选中的字典吗?',
icon: createVNode(ExclamationCircleOutlined),
maskClosable: true,
onOk: () => {
const hide = message.loading('请求中..', 0);
removeDictionary(current.value?.dictId)
.then((msg) => {
hide();
message.success(msg);
reload();
})
.catch((e) => {
hide();
message.error(e.message);
});
}
});
};
</script>
<script lang="ts">
export default {
name: 'SystemDictionary'
};
</script>
<style lang="less" scoped>
.sys-dict-table :deep(.ant-table-body) {
overflow: auto !important;
overflow: overlay !important;
}
.dict-code {
color: #cccccc;
}
</style>

View File

@@ -0,0 +1,195 @@
<template>
<div class="ele-body">
<a-card :bordered="false" :body-style="{ padding: '0px' }">
<ele-split-layout
width="266px"
allow-collapse
:right-style="{ overflow: 'hidden' }"
:style="{ minHeight: 'calc(100vh - 152px)' }"
>
<!-- 表格 -->
<ele-pro-table
ref="tableRef"
row-key="dictId"
:columns="columns"
:datasource="datasource"
v-model:current="current"
selection-type="radio"
:row-selection="{ columnWidth: 32 }"
:need-page="false"
:toolkit="[]"
height="calc(100vh - 290px)"
tools-theme="default"
bordered
class="sys-dict-table"
@done="done"
>
<template #toolbar>
<a-space :size="10">
<a-button type="primary" class="ele-btn-icon" @click="openEdit()">
<template #icon>
<plus-outlined />
</template>
<span>新建</span>
</a-button>
<a-button
type="primary"
:disabled="!current"
class="ele-btn-icon"
@click="openEdit(current)"
>
<template #icon>
<edit-outlined />
</template>
<span>修改</span>
</a-button>
<a-button
danger
type="primary"
:disabled="!current"
class="ele-btn-icon"
@click="remove"
>
<template #icon>
<delete-outlined />
</template>
<span>删除</span>
</a-button>
</a-space>
</template>
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'dictName'">
<a-space :size="size">
<a-tooltip :title="`${record.dictCode}`">
{{ record.dictName }}
<!-- <span class="dict-code">{{ record.dictCode }}</span>-->
</a-tooltip>
</a-space>
</template>
</template>
</ele-pro-table>
<template #content>
<dict-data
v-if="current && current.dictId"
:dict-id="current.dictId"
/>
</template>
</ele-split-layout>
</a-card>
<!-- 编辑弹窗 -->
<dict-edit v-model:visible="showEdit" :data="editData" @done="reload" />
</div>
</template>
<script lang="ts" setup>
import { createVNode, ref } from 'vue';
import { message, Modal } from 'ant-design-vue';
import {
PlusOutlined,
EditOutlined,
DeleteOutlined,
ExclamationCircleOutlined
} from '@ant-design/icons-vue';
import type { EleProTable } from 'ele-admin-pro';
import type {
DatasourceFunction,
ColumnItem,
EleProTableDone
} from 'ele-admin-pro/es/ele-pro-table/types';
import DictData from './components/dict-data.vue';
import DictEdit from './components/dict-edit.vue';
import { listDictionaries, removeDictionary } from '@/api/system/dictionary';
import type { Dictionary } from '@/api/system/dictionary/model';
// 表格实例
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
// 表格列配置
const columns = ref<ColumnItem[]>([
{
key: 'index',
width: 45,
ellipsis: true,
align: 'center',
fixed: 'left',
hideInSetting: true,
customRender: ({ index }) => index + (tableRef.value?.tableIndex ?? 0)
},
{
title: '字典名称',
dataIndex: 'dictName',
key: 'dictName'
}
]);
// 表格选中数据
const current = ref<Dictionary | null>(null);
// 是否显示编辑弹窗
const showEdit = ref(false);
// 编辑回显数据
const editData = ref<Dictionary | null>(null);
// 表格数据源
const datasource: DatasourceFunction = () => {
return listDictionaries();
};
/* 表格渲染完成回调 */
const done: EleProTableDone<Dictionary> = (res) => {
if (res.data?.length) {
current.value = res.data[0];
}
};
/* 刷新表格 */
const reload = () => {
tableRef?.value?.reload();
};
/* 打开编辑弹窗 */
const openEdit = (row?: Dictionary | null) => {
editData.value = row ?? null;
showEdit.value = true;
};
/* 删除 */
const remove = () => {
Modal.confirm({
title: '提示',
content: '确定要删除选中的字典吗?',
icon: createVNode(ExclamationCircleOutlined),
maskClosable: true,
onOk: () => {
const hide = message.loading('请求中..', 0);
removeDictionary(current.value?.dictId)
.then((msg) => {
hide();
message.success(msg);
reload();
})
.catch((e) => {
hide();
message.error(e.message);
});
}
});
};
</script>
<script lang="ts">
export default {
name: 'SystemDictionary'
};
</script>
<style lang="less" scoped>
.sys-dict-table :deep(.ant-table-body) {
overflow: auto !important;
overflow: overlay !important;
}
.dict-code {
color: #cccccc;
}
</style>