模板
This commit is contained in:
parent
09eb91d4b4
commit
1dde2138a7
60
src/api/file/emailTemplate.ts
Normal file
60
src/api/file/emailTemplate.ts
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
import { http } from '@/utils/http/axios';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description: 列表
|
||||||
|
*/
|
||||||
|
export function getEmailTemplateList(params?) {
|
||||||
|
return http.request({
|
||||||
|
url: '/email/template/page',
|
||||||
|
method: 'GET',
|
||||||
|
params,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @description: 根据ID获取详情
|
||||||
|
*/
|
||||||
|
export function getEmailTemplateDetail(id) {
|
||||||
|
return http.request({
|
||||||
|
url: '/email/template/detail/'+id,
|
||||||
|
method: 'get',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @description: 添加
|
||||||
|
*/
|
||||||
|
export function emailTemplateAdd(data:any) {
|
||||||
|
return http.request({
|
||||||
|
url: '/email/template/add',
|
||||||
|
method: 'POST',
|
||||||
|
data,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @description: 更新
|
||||||
|
*/
|
||||||
|
export function emailTemplateUpdate(data:any) {
|
||||||
|
return http.request({
|
||||||
|
url: '/email/template/update',
|
||||||
|
method: 'PUT',
|
||||||
|
data
|
||||||
|
});
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @description: 删除
|
||||||
|
*/
|
||||||
|
export function emailTemplateDelete(id) {
|
||||||
|
return http.request({
|
||||||
|
url: '/email/template/delete/'+id,
|
||||||
|
method: 'DELETE',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @description: 批量删除
|
||||||
|
*/
|
||||||
|
export function emailTemplateBatchDelete(data:any) {
|
||||||
|
return http.request({
|
||||||
|
url: '/email/template/batchDelete',
|
||||||
|
method: 'DELETE',
|
||||||
|
data
|
||||||
|
});
|
||||||
|
}
|
60
src/api/file/smsTemplate.ts
Normal file
60
src/api/file/smsTemplate.ts
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
import { http } from '@/utils/http/axios';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description: 列表
|
||||||
|
*/
|
||||||
|
export function getSmsTemplateList(params?) {
|
||||||
|
return http.request({
|
||||||
|
url: '/sms/template/page',
|
||||||
|
method: 'GET',
|
||||||
|
params,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @description: 根据ID获取详情
|
||||||
|
*/
|
||||||
|
export function getSmsTemplateDetail(id) {
|
||||||
|
return http.request({
|
||||||
|
url: '/sms/template/detail/'+id,
|
||||||
|
method: 'get',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @description: 添加
|
||||||
|
*/
|
||||||
|
export function smsTemplateAdd(data:any) {
|
||||||
|
return http.request({
|
||||||
|
url: '/sms/template/add',
|
||||||
|
method: 'POST',
|
||||||
|
data,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @description: 更新
|
||||||
|
*/
|
||||||
|
export function smsTemplateUpdate(data:any) {
|
||||||
|
return http.request({
|
||||||
|
url: '/sms/template/update',
|
||||||
|
method: 'PUT',
|
||||||
|
data
|
||||||
|
});
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @description: 删除
|
||||||
|
*/
|
||||||
|
export function smsTemplateDelete(id) {
|
||||||
|
return http.request({
|
||||||
|
url: '/sms/template/delete/'+id,
|
||||||
|
method: 'DELETE',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @description: 批量删除
|
||||||
|
*/
|
||||||
|
export function smsTemplateBatchDelete(data:any) {
|
||||||
|
return http.request({
|
||||||
|
url: '/sms/template/batchDelete',
|
||||||
|
method: 'DELETE',
|
||||||
|
data
|
||||||
|
});
|
||||||
|
}
|
45
src/views/file/emailTemplate/columns.ts
Normal file
45
src/views/file/emailTemplate/columns.ts
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
import { h } from 'vue';
|
||||||
|
import { ElTag } from 'element-plus';
|
||||||
|
|
||||||
|
export const columns = [
|
||||||
|
{
|
||||||
|
type: 'selection',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '模板名称',
|
||||||
|
prop: 'title',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '模板编码',
|
||||||
|
prop: 'code',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '模板类型',
|
||||||
|
prop: 'type',
|
||||||
|
render(record) {
|
||||||
|
let typeText = ''
|
||||||
|
switch (record.row.type) {
|
||||||
|
case 1:
|
||||||
|
typeText='普通邮件'
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
typeText='图文邮件'
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
typeText='模板文件'
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return h('span', typeText || '-');
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '创建人',
|
||||||
|
prop: 'createUser',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '创建时间',
|
||||||
|
prop: 'createTime',
|
||||||
|
},
|
||||||
|
];
|
148
src/views/file/emailTemplate/edit.vue
Normal file
148
src/views/file/emailTemplate/edit.vue
Normal file
@ -0,0 +1,148 @@
|
|||||||
|
<template>
|
||||||
|
<el-dialog v-model="props.visible" :title="dialogTitle" :append-to-body="true" width="600" :close-on-click-modal="false"
|
||||||
|
:before-close="dialogClose">
|
||||||
|
<el-form ref="formRef" :model="formData" label-width="90px">
|
||||||
|
<el-form-item
|
||||||
|
label="模板名称"
|
||||||
|
prop="title"
|
||||||
|
:rules="{ required: true, message: '请输入模板名称', trigger: 'blur' }"
|
||||||
|
>
|
||||||
|
<el-input
|
||||||
|
:maxlength="50"
|
||||||
|
placeholder="请输入模板名称"
|
||||||
|
clearable
|
||||||
|
v-model.trim="formData.title"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item
|
||||||
|
label="模板code"
|
||||||
|
prop="code"
|
||||||
|
:rules="{ required: true, message: '请输入模板code', trigger: 'blur' }"
|
||||||
|
>
|
||||||
|
<el-input
|
||||||
|
v-if="!formData.id"
|
||||||
|
:maxlength="100"
|
||||||
|
placeholder="请输入模板code"
|
||||||
|
clearable
|
||||||
|
v-model.trim="formData.code"
|
||||||
|
/>
|
||||||
|
<span v-else>{{formData.code}}</span>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item
|
||||||
|
label="模板内容"
|
||||||
|
prop="content"
|
||||||
|
:rules="{ required: true, message: '请输入模板内容', trigger: 'blur' }"
|
||||||
|
>
|
||||||
|
<el-input
|
||||||
|
placeholder="请输入模板内容"
|
||||||
|
clearable
|
||||||
|
v-model.trim="formData.content"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="邮件类型" prop="type"
|
||||||
|
:rules="{ required: true, message: '请选择邮件类型', trigger: 'blur' }">
|
||||||
|
<el-select
|
||||||
|
v-model="formData.type"
|
||||||
|
placeholder="请选择邮件类型"
|
||||||
|
>
|
||||||
|
<el-option label="普通邮件" :value="1"></el-option>
|
||||||
|
<el-option label="图文邮件" :value="2"></el-option>
|
||||||
|
<el-option label="模板文件" :value="3"></el-option>
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item
|
||||||
|
label="模板文件"
|
||||||
|
prop="filePath"
|
||||||
|
>
|
||||||
|
<UploadFile @upload="fileUpload" file-type=".xlsx.xls.doc.docx" name="file"
|
||||||
|
:file-list="formData.filePath?[{name:formData.fileName,url:formData.filePath}]:[]"/>
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
<template #footer>
|
||||||
|
<span class="dialog-footer">
|
||||||
|
<el-button @click="dialogClose">取消</el-button>
|
||||||
|
<el-button :loading="subLoading" type="primary" @click="submit">确认</el-button>
|
||||||
|
</span>
|
||||||
|
</template>
|
||||||
|
</el-dialog>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import { emailTemplateAdd,emailTemplateUpdate,getEmailTemplateDetail } from '@/api/file/emailTemplate';
|
||||||
|
import { computed, onMounted,shallowRef,reactive,ref,nextTick } from "vue";
|
||||||
|
import { FormInstance } from "element-plus";
|
||||||
|
import { message } from "@/utils/auth";
|
||||||
|
const formRef = shallowRef<FormInstance>();
|
||||||
|
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 formData = reactive({
|
||||||
|
id: "",
|
||||||
|
title:'',
|
||||||
|
code:'',
|
||||||
|
content:'',
|
||||||
|
type:'',
|
||||||
|
filePath:'',
|
||||||
|
fileName:''
|
||||||
|
});
|
||||||
|
|
||||||
|
const fileUpload = async (filePath: any, fileName: any) => {
|
||||||
|
formData.filePath = filePath;
|
||||||
|
formData.fileName = fileName;
|
||||||
|
await nextTick(()=>{
|
||||||
|
formRef.value?.validateField("filePath");
|
||||||
|
})
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
const dialogClose = () => {
|
||||||
|
emit("update:visible", false);
|
||||||
|
};
|
||||||
|
|
||||||
|
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("操作成功");
|
||||||
|
emit("update:visible", false);
|
||||||
|
emit("success");
|
||||||
|
};
|
||||||
|
|
||||||
|
const { isLock: subLoading, lockFn: submit } = useLockFn(handleSubmit);
|
||||||
|
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
if (props.id) {
|
||||||
|
setFormData( props.id );
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
</script>
|
159
src/views/file/emailTemplate/index.vue
Normal file
159
src/views/file/emailTemplate/index.vue
Normal file
@ -0,0 +1,159 @@
|
|||||||
|
<template>
|
||||||
|
<PageWrapper>
|
||||||
|
<el-card :bordered="false" class="pt-3 mb-3 proCard">
|
||||||
|
<BasicForm @register="register" @submit="handleSubmit" @reset="handleReset"></BasicForm>
|
||||||
|
</el-card>
|
||||||
|
<el-card :bordered="false" class="proCard">
|
||||||
|
<BasicTable
|
||||||
|
:columns="columns"
|
||||||
|
:request="loadDataTable"
|
||||||
|
:row-key="(row) => row.id"
|
||||||
|
ref="tableRef"
|
||||||
|
:actionColumn="actionColumn"
|
||||||
|
@selection-change="onSelectionChange"
|
||||||
|
>
|
||||||
|
<template #tableTitle>
|
||||||
|
<el-button type="primary" @click="handleAdd">
|
||||||
|
<template #icon>
|
||||||
|
<el-icon class="el-input__icon">
|
||||||
|
<Plus />
|
||||||
|
</el-icon>
|
||||||
|
</template>
|
||||||
|
添加
|
||||||
|
</el-button>
|
||||||
|
<el-button type="danger" @click="handleDelete()" :disabled="!selectionData.length">
|
||||||
|
<template #icon>
|
||||||
|
<el-icon class="el-input__icon">
|
||||||
|
<Delete />
|
||||||
|
</el-icon>
|
||||||
|
</template>
|
||||||
|
删除
|
||||||
|
</el-button>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<template #action>
|
||||||
|
<TableAction />
|
||||||
|
</template>
|
||||||
|
</BasicTable>
|
||||||
|
</el-card>
|
||||||
|
|
||||||
|
<editDialog
|
||||||
|
v-if="editVisible"
|
||||||
|
:id="emailId"
|
||||||
|
v-model:visible="editVisible"
|
||||||
|
@success="reloadTable"
|
||||||
|
>
|
||||||
|
</editDialog>
|
||||||
|
</PageWrapper>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import { reactive, ref, h,nextTick,defineAsyncComponent } from 'vue';
|
||||||
|
import { ColProps } from 'element-plus';
|
||||||
|
import { schemas } from './querySchemas';
|
||||||
|
import { useForm } from '@/components/Form/index';
|
||||||
|
import { TableAction } from '@/components/Table';
|
||||||
|
import { getEmailTemplateList,emailTemplateDelete,emailTemplateBatchDelete } from '@/api/file/emailTemplate';
|
||||||
|
import { columns } from './columns';
|
||||||
|
import {message,confirm} from "@/utils/auth";
|
||||||
|
const editDialog = defineAsyncComponent(() =>
|
||||||
|
import('./edit.vue')
|
||||||
|
)
|
||||||
|
const emailId =ref(0)
|
||||||
|
const editVisible=ref(false)
|
||||||
|
const selectionData = ref([])
|
||||||
|
const tableRef = ref();
|
||||||
|
const formParams = reactive({
|
||||||
|
title:'',
|
||||||
|
type:''
|
||||||
|
});
|
||||||
|
const actionColumn = reactive({
|
||||||
|
width: 250,
|
||||||
|
label: '操作',
|
||||||
|
prop: 'action',
|
||||||
|
fixed: 'right',
|
||||||
|
render(record) {
|
||||||
|
return h(TableAction, {
|
||||||
|
style: 'button',
|
||||||
|
actions: [
|
||||||
|
{
|
||||||
|
label: '编辑',
|
||||||
|
type: 'warning',
|
||||||
|
onClick: handleEdit.bind(null, record),
|
||||||
|
ifShow: () => {
|
||||||
|
return true;
|
||||||
|
},
|
||||||
|
// auth: ['sys:fileLog:detail'],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '删除',
|
||||||
|
type: 'danger',
|
||||||
|
onClick: handleDelete.bind(null, record),
|
||||||
|
// 根据业务控制是否显示 isShow 和 auth 是并且关系
|
||||||
|
ifShow: () => {
|
||||||
|
return true;
|
||||||
|
},
|
||||||
|
// 根据权限控制是否显示: 有权限,会显示,支持多个
|
||||||
|
// auth: ['basic_list'],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
});
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const loadDataTable = async (res: any) => {
|
||||||
|
const result = await getEmailTemplateList({ ...formParams, ...res });
|
||||||
|
return result;
|
||||||
|
};
|
||||||
|
|
||||||
|
function reloadTable() {
|
||||||
|
tableRef.value.reload({pageNo:1});
|
||||||
|
}
|
||||||
|
const [register, {}] = useForm({
|
||||||
|
labelWidth: 80,
|
||||||
|
layout: 'horizontal',
|
||||||
|
colProps: { span: 6 } as ColProps,
|
||||||
|
submitOnReset:true,
|
||||||
|
schemas
|
||||||
|
});
|
||||||
|
function handleSubmit(values: Recordable) {
|
||||||
|
for (const key in formParams) {
|
||||||
|
if (values[key] != null && values[key] != undefined) {
|
||||||
|
formParams[key] = values[key];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
reloadTable();
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleReset() {
|
||||||
|
for (const key in formParams) {
|
||||||
|
formParams[key] ='';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const handleAdd =async (record: Recordable) => {
|
||||||
|
emailId.value=0
|
||||||
|
await nextTick();
|
||||||
|
editVisible.value=true
|
||||||
|
};
|
||||||
|
const handleEdit = async (record: Recordable) => {
|
||||||
|
emailId.value=record.row.id
|
||||||
|
await nextTick();
|
||||||
|
editVisible.value=true
|
||||||
|
};
|
||||||
|
|
||||||
|
async function handleDelete(record: Recordable) {
|
||||||
|
let ids = []
|
||||||
|
if(!record){
|
||||||
|
ids = selectionData.value.map(({id}) => id);
|
||||||
|
}
|
||||||
|
await confirm('确定要删除?');
|
||||||
|
record? await emailTemplateDelete(record.row.id):await emailTemplateBatchDelete(ids);
|
||||||
|
message("删除成功");
|
||||||
|
reloadTable()
|
||||||
|
}
|
||||||
|
function onSelectionChange(value){
|
||||||
|
selectionData.value = value
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss" scoped></style>
|
33
src/views/file/emailTemplate/querySchemas.ts
Normal file
33
src/views/file/emailTemplate/querySchemas.ts
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
import { FormSchema } from '@/components/Form/index';
|
||||||
|
export const schemas: FormSchema[] = [
|
||||||
|
{
|
||||||
|
field: 'title',
|
||||||
|
component: 'Input',
|
||||||
|
label: '模板名称',
|
||||||
|
componentProps: {
|
||||||
|
placeholder: '请输入模板名称',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'type',
|
||||||
|
component: 'Select',
|
||||||
|
label: '邮件类型',
|
||||||
|
componentProps: {
|
||||||
|
placeholder: '请选择邮件类型',
|
||||||
|
options: [
|
||||||
|
{
|
||||||
|
label: '普通邮件',
|
||||||
|
value: '1',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '图文邮件',
|
||||||
|
value: '2',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '模板文件',
|
||||||
|
value: '3',
|
||||||
|
}
|
||||||
|
],
|
||||||
|
},
|
||||||
|
}
|
||||||
|
];
|
@ -1,5 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<el-dialog v-model="props.visible" :title="dialogTitle" :append-to-body="true" width="800" :close-on-click-modal="false"
|
<el-dialog v-model="props.visible" :title="dialogTitle" :append-to-body="true" width="600" :close-on-click-modal="false"
|
||||||
:before-close="dialogClose">
|
:before-close="dialogClose">
|
||||||
<el-form ref="formRef" :model="formData" label-width="90px">
|
<el-form ref="formRef" :model="formData" label-width="90px">
|
||||||
<el-form-item
|
<el-form-item
|
||||||
|
45
src/views/file/smsTemplate/columns.ts
Normal file
45
src/views/file/smsTemplate/columns.ts
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
import { h } from 'vue';
|
||||||
|
import { ElTag } from 'element-plus';
|
||||||
|
|
||||||
|
export const columns = [
|
||||||
|
{
|
||||||
|
type: 'selection',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '模板名称',
|
||||||
|
prop: 'title',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '模板编码',
|
||||||
|
prop: 'code',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '模板类型',
|
||||||
|
prop: 'type',
|
||||||
|
render(record) {
|
||||||
|
let typeText = ''
|
||||||
|
switch (record.row.type) {
|
||||||
|
case 1:
|
||||||
|
typeText='阿里云'
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
typeText='腾讯云'
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
typeText='华为云'
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return h('span', typeText || '-');
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '创建人',
|
||||||
|
prop: 'createUser',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '创建时间',
|
||||||
|
prop: 'createTime',
|
||||||
|
},
|
||||||
|
];
|
146
src/views/file/smsTemplate/edit.vue
Normal file
146
src/views/file/smsTemplate/edit.vue
Normal file
@ -0,0 +1,146 @@
|
|||||||
|
<template>
|
||||||
|
<el-dialog v-model="props.visible" :title="dialogTitle" :append-to-body="true" width="600" :close-on-click-modal="false"
|
||||||
|
:before-close="dialogClose">
|
||||||
|
<el-form ref="formRef" :model="formData" label-width="90px">
|
||||||
|
<el-form-item
|
||||||
|
label="模板名称"
|
||||||
|
prop="title"
|
||||||
|
:rules="{ required: true, message: '请输入模板名称', trigger: 'blur' }"
|
||||||
|
>
|
||||||
|
<el-input
|
||||||
|
:maxlength="50"
|
||||||
|
placeholder="请输入模板名称"
|
||||||
|
clearable
|
||||||
|
v-model.trim="formData.title"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item
|
||||||
|
label="模板code"
|
||||||
|
prop="code"
|
||||||
|
:rules="{ required: true, message: '请输入模板code', trigger: 'blur' }"
|
||||||
|
>
|
||||||
|
<el-input
|
||||||
|
v-if="!formData.id"
|
||||||
|
:maxlength="100"
|
||||||
|
placeholder="请输入模板code"
|
||||||
|
clearable
|
||||||
|
v-model.trim="formData.code"
|
||||||
|
/>
|
||||||
|
<span v-else>{{formData.code}}</span>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item
|
||||||
|
label="模板编号"
|
||||||
|
prop="number"
|
||||||
|
:rules="{ required: true, message: '请输入模板编号', trigger: 'blur' }"
|
||||||
|
>
|
||||||
|
<el-input
|
||||||
|
:maxlength="100"
|
||||||
|
placeholder="请输入模板编号"
|
||||||
|
clearable
|
||||||
|
v-model.trim="formData.number"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="模板类型" prop="type"
|
||||||
|
:rules="{ required: true, message: '请选择模板类型', trigger: 'blur' }">
|
||||||
|
<el-select
|
||||||
|
v-model="formData.type"
|
||||||
|
placeholder="请选择模板类型"
|
||||||
|
>
|
||||||
|
<el-option label="阿里云" :value="1"></el-option>
|
||||||
|
<el-option label="腾讯云" :value="2"></el-option>
|
||||||
|
<el-option label="华为云" :value="3"></el-option>
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item
|
||||||
|
label="模板内容"
|
||||||
|
prop="content"
|
||||||
|
:rules="{ required: true, message: '请输入模板内容', trigger: 'blur' }"
|
||||||
|
>
|
||||||
|
<el-input
|
||||||
|
placeholder="请输入模板内容"
|
||||||
|
clearable
|
||||||
|
type="textarea"
|
||||||
|
v-model.trim="formData.content"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
|
||||||
|
</el-form>
|
||||||
|
<template #footer>
|
||||||
|
<span class="dialog-footer">
|
||||||
|
<el-button @click="dialogClose">取消</el-button>
|
||||||
|
<el-button :loading="subLoading" type="primary" @click="submit">确认</el-button>
|
||||||
|
</span>
|
||||||
|
</template>
|
||||||
|
</el-dialog>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import { smsTemplateAdd,smsTemplateUpdate,getSmsTemplateDetail } from '@/api/file/smsTemplate';
|
||||||
|
import { computed, onMounted,shallowRef,reactive,ref } from "vue";
|
||||||
|
import { FormInstance } from "element-plus";
|
||||||
|
import { message } from "@/utils/auth";
|
||||||
|
const formRef = shallowRef<FormInstance>();
|
||||||
|
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 formData = reactive({
|
||||||
|
id: "",
|
||||||
|
title:'',
|
||||||
|
code:'',
|
||||||
|
number:'',
|
||||||
|
content:'',
|
||||||
|
type:'',
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
const dialogClose = () => {
|
||||||
|
emit("update:visible", false);
|
||||||
|
};
|
||||||
|
|
||||||
|
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("操作成功");
|
||||||
|
emit("update:visible", false);
|
||||||
|
emit("success");
|
||||||
|
};
|
||||||
|
|
||||||
|
const { isLock: subLoading, lockFn: submit } = useLockFn(handleSubmit);
|
||||||
|
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
if (props.id) {
|
||||||
|
setFormData( props.id );
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
</script>
|
159
src/views/file/smsTemplate/index.vue
Normal file
159
src/views/file/smsTemplate/index.vue
Normal file
@ -0,0 +1,159 @@
|
|||||||
|
<template>
|
||||||
|
<PageWrapper>
|
||||||
|
<el-card :bordered="false" class="pt-3 mb-3 proCard">
|
||||||
|
<BasicForm @register="register" @submit="handleSubmit" @reset="handleReset"></BasicForm>
|
||||||
|
</el-card>
|
||||||
|
<el-card :bordered="false" class="proCard">
|
||||||
|
<BasicTable
|
||||||
|
:columns="columns"
|
||||||
|
:request="loadDataTable"
|
||||||
|
:row-key="(row) => row.id"
|
||||||
|
ref="tableRef"
|
||||||
|
:actionColumn="actionColumn"
|
||||||
|
@selection-change="onSelectionChange"
|
||||||
|
>
|
||||||
|
<template #tableTitle>
|
||||||
|
<el-button type="primary" @click="handleAdd">
|
||||||
|
<template #icon>
|
||||||
|
<el-icon class="el-input__icon">
|
||||||
|
<Plus />
|
||||||
|
</el-icon>
|
||||||
|
</template>
|
||||||
|
添加
|
||||||
|
</el-button>
|
||||||
|
<el-button type="danger" @click="handleDelete()" :disabled="!selectionData.length">
|
||||||
|
<template #icon>
|
||||||
|
<el-icon class="el-input__icon">
|
||||||
|
<Delete />
|
||||||
|
</el-icon>
|
||||||
|
</template>
|
||||||
|
删除
|
||||||
|
</el-button>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<template #action>
|
||||||
|
<TableAction />
|
||||||
|
</template>
|
||||||
|
</BasicTable>
|
||||||
|
</el-card>
|
||||||
|
|
||||||
|
<editDialog
|
||||||
|
v-if="editVisible"
|
||||||
|
:id="smsId"
|
||||||
|
v-model:visible="editVisible"
|
||||||
|
@success="reloadTable"
|
||||||
|
>
|
||||||
|
</editDialog>
|
||||||
|
</PageWrapper>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import { reactive, ref, h,nextTick,defineAsyncComponent } from 'vue';
|
||||||
|
import { ColProps } from 'element-plus';
|
||||||
|
import { schemas } from './querySchemas';
|
||||||
|
import { useForm } from '@/components/Form/index';
|
||||||
|
import { TableAction } from '@/components/Table';
|
||||||
|
import { getSmsTemplateList,smsTemplateDelete,smsTemplateBatchDelete } from '@/api/file/smsTemplate';
|
||||||
|
import { columns } from './columns';
|
||||||
|
import {message,confirm} from "@/utils/auth";
|
||||||
|
const editDialog = defineAsyncComponent(() =>
|
||||||
|
import('./edit.vue')
|
||||||
|
)
|
||||||
|
const smsId =ref(0)
|
||||||
|
const editVisible=ref(false)
|
||||||
|
const selectionData = ref([])
|
||||||
|
const tableRef = ref();
|
||||||
|
const formParams = reactive({
|
||||||
|
title:'',
|
||||||
|
type:''
|
||||||
|
});
|
||||||
|
const actionColumn = reactive({
|
||||||
|
width: 250,
|
||||||
|
label: '操作',
|
||||||
|
prop: 'action',
|
||||||
|
fixed: 'right',
|
||||||
|
render(record) {
|
||||||
|
return h(TableAction, {
|
||||||
|
style: 'button',
|
||||||
|
actions: [
|
||||||
|
{
|
||||||
|
label: '编辑',
|
||||||
|
type: 'warning',
|
||||||
|
onClick: handleEdit.bind(null, record),
|
||||||
|
ifShow: () => {
|
||||||
|
return true;
|
||||||
|
},
|
||||||
|
// auth: ['sys:fileLog:detail'],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '删除',
|
||||||
|
type: 'danger',
|
||||||
|
onClick: handleDelete.bind(null, record),
|
||||||
|
// 根据业务控制是否显示 isShow 和 auth 是并且关系
|
||||||
|
ifShow: () => {
|
||||||
|
return true;
|
||||||
|
},
|
||||||
|
// 根据权限控制是否显示: 有权限,会显示,支持多个
|
||||||
|
// auth: ['basic_list'],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
});
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const loadDataTable = async (res: any) => {
|
||||||
|
const result = await getSmsTemplateList({ ...formParams, ...res });
|
||||||
|
return result;
|
||||||
|
};
|
||||||
|
|
||||||
|
function reloadTable() {
|
||||||
|
tableRef.value.reload({pageNo:1});
|
||||||
|
}
|
||||||
|
const [register, {}] = useForm({
|
||||||
|
labelWidth: 80,
|
||||||
|
layout: 'horizontal',
|
||||||
|
colProps: { span: 6 } as ColProps,
|
||||||
|
submitOnReset:true,
|
||||||
|
schemas
|
||||||
|
});
|
||||||
|
function handleSubmit(values: Recordable) {
|
||||||
|
for (const key in formParams) {
|
||||||
|
if (values[key] != null && values[key] != undefined) {
|
||||||
|
formParams[key] = values[key];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
reloadTable();
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleReset() {
|
||||||
|
for (const key in formParams) {
|
||||||
|
formParams[key] ='';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const handleAdd =async (record: Recordable) => {
|
||||||
|
smsId.value=0
|
||||||
|
await nextTick();
|
||||||
|
editVisible.value=true
|
||||||
|
};
|
||||||
|
const handleEdit = async (record: Recordable) => {
|
||||||
|
smsId.value=record.row.id
|
||||||
|
await nextTick();
|
||||||
|
editVisible.value=true
|
||||||
|
};
|
||||||
|
|
||||||
|
async function handleDelete(record: Recordable) {
|
||||||
|
let ids = []
|
||||||
|
if(!record){
|
||||||
|
ids = selectionData.value.map(({id}) => id);
|
||||||
|
}
|
||||||
|
await confirm('确定要删除?');
|
||||||
|
record? await smsTemplateDelete(record.row.id):await smsTemplateBatchDelete(ids);
|
||||||
|
message("删除成功");
|
||||||
|
reloadTable()
|
||||||
|
}
|
||||||
|
function onSelectionChange(value){
|
||||||
|
selectionData.value = value
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss" scoped></style>
|
33
src/views/file/smsTemplate/querySchemas.ts
Normal file
33
src/views/file/smsTemplate/querySchemas.ts
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
import { FormSchema } from '@/components/Form/index';
|
||||||
|
export const schemas: FormSchema[] = [
|
||||||
|
{
|
||||||
|
field: 'title',
|
||||||
|
component: 'Input',
|
||||||
|
label: '模板名称',
|
||||||
|
componentProps: {
|
||||||
|
placeholder: '请输入模板名称',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'type',
|
||||||
|
component: 'Select',
|
||||||
|
label: '模板类型',
|
||||||
|
componentProps: {
|
||||||
|
placeholder: '请选择模板类型',
|
||||||
|
options: [
|
||||||
|
{
|
||||||
|
label: '阿里云',
|
||||||
|
value: '1',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '腾讯云',
|
||||||
|
value: '2',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '华为云',
|
||||||
|
value: '3',
|
||||||
|
}
|
||||||
|
],
|
||||||
|
},
|
||||||
|
}
|
||||||
|
];
|
Loading…
Reference in New Issue
Block a user