签入版本
This commit is contained in:
@@ -0,0 +1,79 @@
|
||||
import { h } from 'vue';
|
||||
|
||||
export const columns = [
|
||||
{
|
||||
title: 'ID',
|
||||
dataIndex: 'id',
|
||||
fixed: 'left',
|
||||
width: 50,
|
||||
},
|
||||
{
|
||||
title: '模板名称',
|
||||
dataIndex: 'title',
|
||||
width: 150,
|
||||
},
|
||||
{
|
||||
title: '模板编码',
|
||||
dataIndex: 'code',
|
||||
width: 150,
|
||||
},
|
||||
{
|
||||
title: '模板类型',
|
||||
dataIndex: 'type',
|
||||
width: 100,
|
||||
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: 'fileName',
|
||||
width: 100,
|
||||
},
|
||||
{
|
||||
title: '文件路径',
|
||||
dataIndex: 'filePath',
|
||||
width: 100,
|
||||
customRender({ record }) {
|
||||
return h(
|
||||
'a',
|
||||
{
|
||||
href: record.filePath,
|
||||
target: '_blank',
|
||||
},
|
||||
'点击查看文件',
|
||||
);
|
||||
},
|
||||
},
|
||||
{
|
||||
title: '创建人',
|
||||
dataIndex: 'createUser',
|
||||
width: 100,
|
||||
},
|
||||
{
|
||||
title: '创建时间',
|
||||
dataIndex: 'createTime',
|
||||
width: 180,
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
fixed: 'right',
|
||||
dataIndex: 'action',
|
||||
key: 'action',
|
||||
width: 200,
|
||||
},
|
||||
];
|
||||
@@ -0,0 +1,176 @@
|
||||
<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="content"
|
||||
:rules="{ required: true, message: '请输入模板内容', trigger: 'blur' }"
|
||||
>
|
||||
<a-textarea placeholder="请输入模板内容" allow-clear v-model:value="formData.content" />
|
||||
</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="filePath"
|
||||
:rules="{ required: true, message: '请上传模板文件', trigger: 'blur' }"
|
||||
>
|
||||
<UploadFile
|
||||
@upload="fileUpload"
|
||||
file-type=".xlsx.xls.doc.docx"
|
||||
name="file"
|
||||
:file-list="
|
||||
formData.filePath ? [{ name: formData.fileName, url: formData.filePath }] : []
|
||||
"
|
||||
/>
|
||||
</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 {
|
||||
emailTemplateAdd,
|
||||
emailTemplateUpdate,
|
||||
getEmailTemplateDetail,
|
||||
} from '@/api/file/emailTemplate';
|
||||
import { computed, onMounted, shallowRef, reactive, ref, nextTick } from 'vue';
|
||||
import type { FormInstance } from 'ant-design-vue';
|
||||
import { message } from 'ant-design-vue';
|
||||
import { useLockFn } from '@/utils/useLockFn';
|
||||
import UploadFile from '@/components/Upload/file.vue';
|
||||
|
||||
/**
|
||||
* 定义接收的参数
|
||||
*/
|
||||
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: '',
|
||||
content: '',
|
||||
type: undefined,
|
||||
code: '',
|
||||
filePath: '',
|
||||
fileName: '',
|
||||
});
|
||||
|
||||
/**
|
||||
* 上传文件
|
||||
* @param filePath 文件路径
|
||||
* @param fileName 文件名称
|
||||
*/
|
||||
const fileUpload = async (filePath: any, fileName: any) => {
|
||||
formData.filePath = filePath;
|
||||
formData.fileName = fileName;
|
||||
await formRef.value?.validateFields('filePath');
|
||||
};
|
||||
|
||||
/**
|
||||
* 关闭窗体
|
||||
*/
|
||||
const dialogClose = () => {
|
||||
emit('update:visible', false);
|
||||
};
|
||||
|
||||
/**
|
||||
* 设置表单数据
|
||||
* @param id 参数
|
||||
*/
|
||||
const setFormData = async (id: any) => {
|
||||
const data = await getEmailTemplateDetail(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 emailTemplateUpdate(formData) : await emailTemplateAdd(formData);
|
||||
message.success('操作成功');
|
||||
emit('update:visible', false);
|
||||
emit('success');
|
||||
};
|
||||
|
||||
const { isLock: subLoading, lockFn: submit } = useLockFn(handleSubmit);
|
||||
|
||||
/**
|
||||
* 钩子函数
|
||||
*/
|
||||
onMounted(() => {
|
||||
if (props.id) {
|
||||
setFormData(props.id);
|
||||
}
|
||||
});
|
||||
</script>
|
||||
@@ -0,0 +1,207 @@
|
||||
<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:emailTemplate:add']">
|
||||
<template #icon>
|
||||
<PlusOutlined />
|
||||
</template>
|
||||
新建
|
||||
</a-button>
|
||||
|
||||
<a-button
|
||||
type="danger"
|
||||
@click="handleDelete()"
|
||||
:disabled="!selectionData.length"
|
||||
v-perm="['sys:emailTemplate: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:emailTemplate:update']"
|
||||
>
|
||||
<template #icon><EditOutlined /></template>
|
||||
编辑
|
||||
</a-button>
|
||||
<a-button
|
||||
type="primary"
|
||||
danger
|
||||
@click="handleDelete(record.id)"
|
||||
v-perm="['sys:emailTemplate: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 {
|
||||
getEmailTemplateList,
|
||||
emailTemplateDelete,
|
||||
emailTemplateBatchDelete,
|
||||
} from '@/api/file/emailTemplate';
|
||||
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 getEmailTemplateList({ ...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;
|
||||
}
|
||||
|
||||
/**
|
||||
* 执行删除
|
||||
*/
|
||||
async function handleDelete(id) {
|
||||
Modal.confirm({
|
||||
title: '提示',
|
||||
content: '确定要删除?',
|
||||
onOk: async () => {
|
||||
id ? await emailTemplateDelete(id) : await emailTemplateBatchDelete(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',
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
];
|
||||
@@ -0,0 +1,57 @@
|
||||
import { h } from 'vue';
|
||||
|
||||
export const columns = [
|
||||
{
|
||||
title: 'ID',
|
||||
dataIndex: 'id',
|
||||
fixed: 'left',
|
||||
width: 50,
|
||||
},
|
||||
{
|
||||
title: '模板名称',
|
||||
dataIndex: 'name',
|
||||
width: 150,
|
||||
},
|
||||
{
|
||||
title: '模板编码',
|
||||
dataIndex: 'code',
|
||||
width: 150,
|
||||
},
|
||||
{
|
||||
title: '文件名称',
|
||||
dataIndex: 'fileName',
|
||||
width: 150,
|
||||
},
|
||||
{
|
||||
title: '文件路径',
|
||||
dataIndex: 'filePath',
|
||||
width: 150,
|
||||
customRender({ record }) {
|
||||
return h(
|
||||
'a',
|
||||
{
|
||||
href: record.filePath,
|
||||
target: '_blank',
|
||||
},
|
||||
'点击查看文件',
|
||||
);
|
||||
},
|
||||
},
|
||||
{
|
||||
title: '创建人',
|
||||
dataIndex: 'createUser',
|
||||
width: 100,
|
||||
},
|
||||
{
|
||||
title: '创建时间',
|
||||
dataIndex: 'createTime',
|
||||
width: 180,
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
fixed: 'right',
|
||||
dataIndex: 'action',
|
||||
key: 'action',
|
||||
width: 200,
|
||||
},
|
||||
];
|
||||
@@ -0,0 +1,171 @@
|
||||
<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="name"
|
||||
:rules="{ required: true, message: '请输入模板名称', trigger: 'blur' }"
|
||||
>
|
||||
<a-input
|
||||
:maxlength="50"
|
||||
placeholder="请输入模板名称"
|
||||
allow-clear
|
||||
v-model:value="formData.name"
|
||||
/>
|
||||
</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="filePath"
|
||||
:rules="{ required: true, message: '请上传模板文件', trigger: 'blur' }"
|
||||
>
|
||||
<UploadFile
|
||||
@upload="fileUpload"
|
||||
file-type=".xlsx.xls.doc.docx"
|
||||
name="file"
|
||||
:file-list="
|
||||
formData.filePath ? [{ name: formData.fileName, url: formData.filePath }] : []
|
||||
"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="排序" name="sort">
|
||||
<a-input-number v-model:value="formData.sort" />
|
||||
</a-form-item>
|
||||
<div class="flex">
|
||||
<a-form-item label="备注" name="contactNote" class="flex-1">
|
||||
<a-input
|
||||
v-model:value="formData.note"
|
||||
type="textarea"
|
||||
placeholder="请输入备注"
|
||||
allow-clear
|
||||
/>
|
||||
</a-form-item>
|
||||
</div>
|
||||
</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 {
|
||||
fileTemplateAdd,
|
||||
fileTemplateUpdate,
|
||||
getFileTemplateDetail,
|
||||
} from '@/api/file/fileTemplate';
|
||||
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';
|
||||
import UploadFile from '@/components/Upload/file.vue';
|
||||
|
||||
/**
|
||||
* 定义接收的参数
|
||||
*/
|
||||
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: '',
|
||||
name: '',
|
||||
code: '',
|
||||
filePath: '',
|
||||
fileName: '',
|
||||
sort: '',
|
||||
note: '',
|
||||
});
|
||||
|
||||
/**
|
||||
* 文件上传
|
||||
* @param filePath 文件路径
|
||||
* @param fileName 文件名称
|
||||
*/
|
||||
const fileUpload = async (filePath: any, fileName: any) => {
|
||||
formData.filePath = filePath;
|
||||
formData.fileName = fileName;
|
||||
await formRef.value?.validateFields('filePath');
|
||||
};
|
||||
|
||||
/**
|
||||
* 关闭窗体
|
||||
*/
|
||||
const dialogClose = () => {
|
||||
emit('update:visible', false);
|
||||
};
|
||||
|
||||
/**
|
||||
* 设置表单数据
|
||||
* @param id 参数
|
||||
*/
|
||||
const setFormData = async (id: any) => {
|
||||
const data = await getFileTemplateDetail(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 fileTemplateUpdate(formData) : await fileTemplateAdd(formData);
|
||||
message.success('操作成功');
|
||||
emit('update:visible', false);
|
||||
emit('success');
|
||||
};
|
||||
|
||||
const { isLock: subLoading, lockFn: submit } = useLockFn(handleSubmit);
|
||||
|
||||
/**
|
||||
* 钩子函数
|
||||
*/
|
||||
onMounted(() => {
|
||||
if (props.id) {
|
||||
setFormData(props.id);
|
||||
}
|
||||
});
|
||||
</script>
|
||||
@@ -0,0 +1,206 @@
|
||||
<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:fileTemplate:add']">
|
||||
<template #icon>
|
||||
<PlusOutlined />
|
||||
</template>
|
||||
新建
|
||||
</a-button>
|
||||
|
||||
<a-button
|
||||
type="danger"
|
||||
@click="handleDelete()"
|
||||
:disabled="!selectionData.length"
|
||||
v-perm="['sys:fileTemplate: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:fileTemplate:update']"
|
||||
>
|
||||
<template #icon><EditOutlined /></template>
|
||||
编辑
|
||||
</a-button>
|
||||
<a-button
|
||||
type="primary"
|
||||
danger
|
||||
@click="handleDelete(record.id)"
|
||||
v-perm="['sys:fileTemplate: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 {
|
||||
getFileTemplateList,
|
||||
fileTemplateDelete,
|
||||
fileTemplateBatchDelete,
|
||||
} from '@/api/file/fileTemplate';
|
||||
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({
|
||||
name: '',
|
||||
});
|
||||
|
||||
/**
|
||||
* 加载数据列表
|
||||
*/
|
||||
const loadDataTable = async (res) => {
|
||||
const result = await getFileTemplateList({ ...formParams, ...res });
|
||||
return result;
|
||||
};
|
||||
|
||||
/**
|
||||
* 刷新数据列表
|
||||
* @param noRefresh 参数
|
||||
*/
|
||||
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 fileTemplateDelete(id) : await fileTemplateBatchDelete(selectionData.value);
|
||||
message.success('删除成功');
|
||||
reloadTable();
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 执行提交表单
|
||||
*/
|
||||
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,11 @@
|
||||
import { FormSchema } from '@/components/Form/index';
|
||||
export const schemas: FormSchema[] = [
|
||||
{
|
||||
name: 'name',
|
||||
component: 'Input',
|
||||
label: '模板名称',
|
||||
componentProps: {
|
||||
placeholder: '请输入模板名称',
|
||||
},
|
||||
},
|
||||
];
|
||||
@@ -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,
|
||||
},
|
||||
];
|
||||
@@ -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>
|
||||
@@ -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,
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
];
|
||||
@@ -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: 150,
|
||||
},
|
||||
{
|
||||
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,
|
||||
},
|
||||
];
|
||||
@@ -0,0 +1,157 @@
|
||||
<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 { smsTemplateAdd, smsTemplateUpdate, getSmsTemplateDetail } from '@/api/file/smsTemplate';
|
||||
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);
|
||||
};
|
||||
|
||||
/**
|
||||
* 设置表单数据
|
||||
* @param id 参数
|
||||
*/
|
||||
const setFormData = async (id: any) => {
|
||||
const data = await getSmsTemplateDetail(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 smsTemplateUpdate(formData) : await smsTemplateAdd(formData);
|
||||
message.success('操作成功');
|
||||
emit('update:visible', false);
|
||||
emit('success');
|
||||
};
|
||||
|
||||
const { isLock: subLoading, lockFn: submit } = useLockFn(handleSubmit);
|
||||
|
||||
/**
|
||||
* 钩子函数
|
||||
*/
|
||||
onMounted(() => {
|
||||
if (props.id) {
|
||||
setFormData(props.id);
|
||||
}
|
||||
});
|
||||
</script>
|
||||
@@ -0,0 +1,208 @@
|
||||
<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:smsTemplate:add']">
|
||||
<template #icon>
|
||||
<PlusOutlined />
|
||||
</template>
|
||||
新建
|
||||
</a-button>
|
||||
|
||||
<a-button
|
||||
type="danger"
|
||||
@click="handleDelete()"
|
||||
:disabled="!selectionData.length"
|
||||
v-perm="['sys:smsTemplate: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:smsTemplate:update']"
|
||||
>
|
||||
<template #icon><EditOutlined /></template>
|
||||
编辑
|
||||
</a-button>
|
||||
<a-button
|
||||
type="primary"
|
||||
danger
|
||||
@click="handleDelete(record.id)"
|
||||
v-perm="['sys:smsTemplate: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 {
|
||||
getSmsTemplateList,
|
||||
smsTemplateDelete,
|
||||
smsTemplateBatchDelete,
|
||||
} from '@/api/file/smsTemplate';
|
||||
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 getSmsTemplateList({ ...formParams, ...res });
|
||||
return result;
|
||||
};
|
||||
|
||||
/**
|
||||
* 刷新数据列表
|
||||
* @param noRefresh 参数
|
||||
*/
|
||||
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 smsTemplateDelete(id) : await smsTemplateBatchDelete(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();
|
||||
}
|
||||
|
||||
/**
|
||||
* 选项发生变化
|
||||
*/
|
||||
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',
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
];
|
||||
Reference in New Issue
Block a user