签入版本

This commit is contained in:
2026-09-12 18:15:20 +08:00
commit bb84b8cda8
829 changed files with 101465 additions and 0 deletions
@@ -0,0 +1,68 @@
import { h } from 'vue';
export const columns = [
{
title: 'ID',
dataIndex: 'id',
fixed: 'left',
width: 50,
},
{
title: '模板编号',
dataIndex: 'number',
width: 100,
},
{
title: '模板名称',
dataIndex: 'title',
width: 200,
},
{
title: '模板编码',
dataIndex: 'code',
width: 150,
},
{
title: '消息类型',
dataIndex: 'type',
customRender({ record }) {
let typeText = '';
switch (record.type) {
case 1:
typeText = '系统通知';
break;
case 2:
typeText = '用户私信';
break;
case 3:
typeText = '代办事项';
break;
default:
break;
}
return h('span', typeText || '-');
},
},
{
title: '模板内容',
dataIndex: 'content',
width: 350,
},
{
title: '创建人',
dataIndex: 'createUser',
width: 100,
},
{
title: '创建时间',
dataIndex: 'createTime',
width: 180,
},
{
title: '操作',
fixed: 'right',
dataIndex: 'action',
key: 'action',
width: 200,
},
];
+160
View File
@@ -0,0 +1,160 @@
<template>
<a-modal v-model:visible="props.visible" :title="dialogTitle" width="600px" @cancel="dialogClose">
<a-form ref="formRef" :model="formData" :label-col="{ style: { width: '90px' } }">
<a-form-item
label="模板名称"
name="title"
:rules="{ required: true, message: '请输入模板名称', trigger: 'blur' }"
>
<a-input
:maxlength="50"
placeholder="请输入模板名称"
allow-clear
v-model:value="formData.title"
/>
</a-form-item>
<a-form-item
label="模板code"
name="code"
:rules="{ required: true, message: '请输入模板code', trigger: 'blur' }"
>
<a-input
v-if="!formData.id"
:maxlength="100"
placeholder="请输入模板code"
allow-clear
v-model:value="formData.code"
/>
<span v-else>{{ formData.code }}</span>
</a-form-item>
<a-form-item
label="模板编号"
name="number"
:rules="{ required: true, message: '请输入模板编号', trigger: 'blur' }"
>
<a-input
:maxlength="100"
placeholder="请输入模板编号"
allow-clear
v-model:value="formData.number"
/>
</a-form-item>
<a-form-item
label="消息类型"
name="type"
:rules="{ required: true, message: '请选择模板类型', trigger: 'blur' }"
>
<a-select v-model:value="formData.type" placeholder="请选择模板类型">
<a-select-option :value="1">系统通知</a-select-option>
<a-select-option :value="2">用户私信</a-select-option>
<a-select-option :value="3">代办事项</a-select-option>
</a-select>
</a-form-item>
<a-form-item
label="模板内容"
name="content"
:rules="{ required: true, message: '请输入模板内容', trigger: 'blur' }"
>
<a-textarea placeholder="请输入模板内容" allow-clear v-model:value="formData.content" />
</a-form-item>
</a-form>
<template #footer>
<span class="dialog-footer">
<a-button @click="dialogClose">取消</a-button>
<a-button :loading="subLoading" type="primary" @click="submit"> 确定 </a-button>
</span>
</template>
</a-modal>
</template>
<script lang="ts" setup>
import {
messageTemplateAdd,
messageTemplateUpdate,
getMessageTemplateDetail,
} from '@/api/file/messageTemplate';
import { computed, onMounted, shallowRef, reactive } from 'vue';
import type { FormInstance } from 'ant-design-vue';
import { message } from 'ant-design-vue';
import { useLockFn } from '@/utils/useLockFn';
/**
* 定义接收的参数
*/
const props = defineProps({
visible: {
type: Boolean,
required: true,
default: false,
},
id: {
type: Number,
required: true,
default: 0,
},
});
const emit = defineEmits(['success', 'update:visible']);
/**
* 定义弹窗标题
*/
const dialogTitle = computed(() => {
return props.id ? '编辑消息模板' : '新增消息模板';
});
const formRef = shallowRef<FormInstance>();
/**
* 接收表单参数
*/
const formData = reactive({
id: '',
title: '',
code: '',
number: '',
content: '',
type: undefined,
});
/**
* 关闭窗体
*/
const dialogClose = () => {
emit('update:visible', false);
};
/**
* 设置表单数据
*/
const setFormData = async (id: any) => {
const data = await getMessageTemplateDetail(id);
for (const key in formData) {
if (data[key] != null && data[key] != undefined) {
formData[key] = data[key];
}
}
};
/**
* 执行提交表单
*/
const handleSubmit = async () => {
await formRef.value?.validate();
props.id ? await messageTemplateUpdate(formData) : await messageTemplateAdd(formData);
message.success('操作成功');
emit('update:visible', false);
emit('success');
};
const { isLock: subLoading, lockFn: submit } = useLockFn(handleSubmit);
/**
* 钩子函数
*/
onMounted(() => {
if (props.id) {
setFormData(props.id);
}
});
</script>
+210
View File
@@ -0,0 +1,210 @@
<template>
<PageWrapper>
<a-card :bordered="false" class="pt-3 mb-3 proCard">
<BasicForm @register="register" @submit="handleSubmit" @reset="handleReset">
<template #statusSlot="{ model, field }">
<a-input v-model="model[field]" />
</template>
</BasicForm>
</a-card>
<a-card :bordered="false" class="proCard">
<BasicTable
:columns="columns"
:request="loadDataTable"
:row-key="(row) => row.id"
ref="tableRef"
scroll-x="1200"
:row-selection="{ onChange: onSelectionChange }"
virtual-scroll
>
<template #tableTitle>
<a-space>
<a-button type="primary" @click="handleAdd" v-perm="['sys:messageTemplate:add']">
<template #icon>
<PlusOutlined />
</template>
新建
</a-button>
<a-button
type="danger"
@click="handleDelete()"
:disabled="!selectionData.length"
v-perm="['sys:messageTemplate:batchDelete']"
>
<template #icon>
<DeleteOutlined />
</template>
删除
</a-button>
</a-space>
</template>
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'action'">
<a-space>
<a-button
type="primary"
@click="handleEdit(record.id)"
v-perm="['sys:messageTemplate:update']"
>
<template #icon><EditOutlined /></template>
编辑
</a-button>
<a-button
type="primary"
danger
@click="handleDelete(record.id)"
v-perm="['sys:messageTemplate:delete']"
>
<template #icon><DeleteOutlined /></template>
删除
</a-button>
</a-space>
</template>
</template>
</BasicTable>
</a-card>
<editDialog
v-if="editVisible"
:id="fileId"
v-model:visible="editVisible"
@success="reloadTable('noRefresh')"
/>
</PageWrapper>
</template>
<script lang="ts" setup>
import { h, nextTick, reactive, ref, defineAsyncComponent } from 'vue';
import { PlusOutlined, EditOutlined, DeleteOutlined } from '@ant-design/icons-vue';
import { useForm } from '@/components/Form/index';
import {
getMessageTemplateList,
messageTemplateDelete,
messageTemplateBatchDelete,
} from '@/api/file/messageTemplate';
import { columns } from './columns';
import { schemas } from './querySchemas';
import { Modal, message } from 'ant-design-vue';
/**
* 定义参数变量
*/
const fileId = ref(0);
const tableRef = ref();
const editVisible = ref(false);
const selectionData = ref([]);
/**
* 导入组件
*/
const editDialog = defineAsyncComponent(() => import('./edit.vue'));
/**
* 定义查询参数
*/
const formParams = reactive({
title: '',
type: '',
});
/**
* 加载数据列表
* @param res 参数
*/
const loadDataTable = async (res) => {
const result = await getMessageTemplateList({ ...formParams, ...res });
return result;
};
/**
* 刷新数据列表
*/
function reloadTable(noRefresh = '') {
tableRef.value.reload(noRefresh ? {} : { pageNo: 1 });
}
/**
* 执行添加
*/
const handleAdd = async () => {
fileId.value = 0;
await nextTick();
editVisible.value = true;
};
/**
* 执行编辑
* @param id 参数
*/
async function handleEdit(id) {
fileId.value = id;
await nextTick();
editVisible.value = true;
}
/**
* 执行删除
* @param id 参数
*/
async function handleDelete(id) {
Modal.confirm({
title: '提示',
content: '确定要删除?',
onOk: async () => {
id
? await messageTemplateDelete(id)
: await messageTemplateBatchDelete(selectionData.value);
message.success('删除成功');
reloadTable();
},
});
}
/**
* 执行提交表单
* @param values 参数
*/
function handleSubmit(values) {
for (const key in formParams) {
formParams[key] = '';
}
for (const key in values) {
formParams[key] = values[key];
}
reloadTable();
}
/**
* 执行重置
*/
function handleReset() {
for (const key in formParams) {
formParams[key] = '';
}
reloadTable();
}
/**
* 选项发生变化
* @param value 参数
*/
function onSelectionChange(value) {
selectionData.value = value;
}
/**
* 注册
*/
const [register, {}] = useForm({
rowProps: { gutter: [16, 0] },
colProps: {
xs: 24,
sm: 24,
md: 12,
lg: 8,
xl: 6,
},
labelCol: { span: 6, offset: 0 },
schemas,
});
</script>
@@ -0,0 +1,34 @@
import { FormSchema } from '@/components/Form/index';
export const schemas: FormSchema[] = [
{
name: 'title',
component: 'Input',
label: '模板标题',
componentProps: {
placeholder: '请输入模板标题',
},
},
{
name: 'type',
component: 'Select',
label: '消息类型',
componentProps: {
placeholder: '请选择消息类型',
clearable: true,
options: [
{
label: '系统通知',
value: 1,
},
{
label: '用户私信',
value: 2,
},
{
label: '代办事项',
value: 3,
},
],
},
},
];