|
@ -6,7 +6,7 @@ |
|
|
:title="dialogTitle" |
|
|
:title="dialogTitle" |
|
|
:width="800" |
|
|
:width="800" |
|
|
> |
|
|
> |
|
|
<Form ref="formRef" v-loading="formLoading" :rules="rules" :schema="allSchemas.formSchema" @onChange="onChange" /> |
|
|
<Form ref="formRef" v-loading="formLoading" :rules="rules" :schema="showSchemas.formSchema" @onChange="onChange" /> |
|
|
<template #footer> |
|
|
<template #footer> |
|
|
<el-button :disabled="formLoading" type="primary" @click="submitForm">确 定</el-button> |
|
|
<el-button :disabled="formLoading" type="primary" @click="submitForm">确 定</el-button> |
|
|
<el-button @click="dialogVisible = false">取 消</el-button> |
|
|
<el-button @click="dialogVisible = false">取 消</el-button> |
|
@ -17,6 +17,7 @@ |
|
|
import * as MailTemplateApi from '@/api/system/mail/template' |
|
|
import * as MailTemplateApi from '@/api/system/mail/template' |
|
|
import { fi } from 'element-plus/es/locale' |
|
|
import { fi } from 'element-plus/es/locale' |
|
|
import { allSchemas, rules } from './template.data' |
|
|
import { allSchemas, rules } from './template.data' |
|
|
|
|
|
import { cloneDeep } from 'lodash-es' |
|
|
|
|
|
|
|
|
defineOptions({ name: 'SystemMailTemplateForm' }) |
|
|
defineOptions({ name: 'SystemMailTemplateForm' }) |
|
|
|
|
|
|
|
@ -31,6 +32,7 @@ const formRef = ref() // 表单 Ref |
|
|
|
|
|
|
|
|
/** 打开弹窗 */ |
|
|
/** 打开弹窗 */ |
|
|
const open = async (type: string, id?: number) => { |
|
|
const open = async (type: string, id?: number) => { |
|
|
|
|
|
showSchemas.value.formSchema = allSchemas.formSchema.filter(item => item.field != 'deptIdList' && item.field != 'roleIdList' &&item.field != 'postIdList'&&item.field != 'userIdList'); |
|
|
dialogVisible.value = true |
|
|
dialogVisible.value = true |
|
|
dialogTitle.value = t('action.' + type) |
|
|
dialogTitle.value = t('action.' + type) |
|
|
formType.value = type |
|
|
formType.value = type |
|
@ -88,13 +90,13 @@ const onChange = async (field, cur) => { |
|
|
formRef.value.setValues(setV); |
|
|
formRef.value.setValues(setV); |
|
|
|
|
|
|
|
|
// 禁用所有字段 |
|
|
// 禁用所有字段 |
|
|
const fieldsToDisable = ['roleIdList', 'deptIdList', 'postIdList', 'userIdList']; |
|
|
// const fieldsToDisable = ['roleIdList', 'deptIdList', 'postIdList', 'userIdList']; |
|
|
fieldsToDisable.forEach(field => { |
|
|
// fieldsToDisable.forEach(field => { |
|
|
const item = allSchemas.formSchema.find(item => item.field === field); |
|
|
// const item = allSchemas.formSchema.find(item => item.field === field); |
|
|
if (item) { |
|
|
// if (item) { |
|
|
item.componentProps.disabled = true; |
|
|
// item.componentProps.disabled = true; |
|
|
} |
|
|
// } |
|
|
}); |
|
|
// }); |
|
|
|
|
|
|
|
|
// 根据当前receiverType启用相应字段 |
|
|
// 根据当前receiverType启用相应字段 |
|
|
const fieldMap = { |
|
|
const fieldMap = { |
|
@ -105,11 +107,37 @@ const onChange = async (field, cur) => { |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
const enableField = fieldMap[cur]; |
|
|
const enableField = fieldMap[cur]; |
|
|
if (enableField) { |
|
|
if (enableField == 'deptIdList') { |
|
|
|
|
|
showSchemas.value.formSchema = allSchemas.formSchema.filter(item => item.field != 'roleIdList' &&item.field != 'postIdList'&&item.field != 'userIdList'); |
|
|
const itemToEnable = allSchemas.formSchema.find(item => item.field === enableField); |
|
|
const itemToEnable = allSchemas.formSchema.find(item => item.field === enableField); |
|
|
if (itemToEnable) { |
|
|
if (itemToEnable) { |
|
|
itemToEnable.componentProps.disabled = false; |
|
|
itemToEnable.componentProps.disabled = false; |
|
|
|
|
|
rules.deptIdList = [{ required: true, message: '请选择部门' }]; |
|
|
} |
|
|
} |
|
|
|
|
|
} else if (enableField == 'roleIdList') { |
|
|
|
|
|
showSchemas.value.formSchema = allSchemas.formSchema.filter(item => item.field != 'deptIdList' &&item.field != 'postIdList'&&item.field != 'userIdList'); |
|
|
|
|
|
const itemToEnable = allSchemas.formSchema.find(item => item.field === enableField); |
|
|
|
|
|
if (itemToEnable) { |
|
|
|
|
|
itemToEnable.componentProps.disabled = false; |
|
|
|
|
|
rules.roleIdList = [{ required: true, message: '请选择角色' }]; |
|
|
|
|
|
} |
|
|
|
|
|
} else if (enableField == 'postIdList') { |
|
|
|
|
|
showSchemas.value.formSchema = allSchemas.formSchema.filter(item => item.field != 'deptIdList' &&item.field != 'roleIdList'&&item.field != 'userIdList'); |
|
|
|
|
|
const itemToEnable = allSchemas.formSchema.find(item => item.field === enableField); |
|
|
|
|
|
if (itemToEnable) { |
|
|
|
|
|
itemToEnable.componentProps.disabled = false; |
|
|
|
|
|
rules.postIdList = [{ required: true, message: '请选择岗位' }]; |
|
|
|
|
|
} |
|
|
|
|
|
} else if (enableField == 'userIdList') { |
|
|
|
|
|
showSchemas.value.formSchema = allSchemas.formSchema.filter(item => item.field != 'deptIdList' &&item.field != 'roleIdList'&&item.field != 'postIdList'); |
|
|
|
|
|
const itemToEnable = allSchemas.formSchema.find(item => item.field === enableField); |
|
|
|
|
|
if (itemToEnable) { |
|
|
|
|
|
itemToEnable.componentProps.disabled = false; |
|
|
|
|
|
rules.userIdList = [{ required: true, message: '请选择用户' }]; |
|
|
|
|
|
} |
|
|
|
|
|
} else { |
|
|
|
|
|
showSchemas.value.formSchema = allSchemas.formSchema.filter(item => item.field != 'roleIdList' && item.field != 'deptIdList' &&item.field != 'userIdList'&&item.field != 'postIdList'); |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
@ -127,15 +155,15 @@ const resetReceiverType = () => { |
|
|
formRef.value.setValues(setV); |
|
|
formRef.value.setValues(setV); |
|
|
|
|
|
|
|
|
// 禁用所有字段 |
|
|
// 禁用所有字段 |
|
|
const fieldsToDisable = ['roleIdList', 'deptIdList', 'postIdList', 'userIdList']; |
|
|
// const fieldsToDisable = ['roleIdList', 'deptIdList', 'postIdList', 'userIdList']; |
|
|
fieldsToDisable.forEach(field => { |
|
|
// fieldsToDisable.forEach(field => { |
|
|
const item = allSchemas.formSchema.find(item => item.field === field); |
|
|
// const item = allSchemas.formSchema.find(item => item.field === field); |
|
|
if (item) { |
|
|
// if (item) { |
|
|
item.componentProps.disabled = true; |
|
|
// item.componentProps.disabled = true; |
|
|
} |
|
|
// } |
|
|
}); |
|
|
// }); |
|
|
} |
|
|
} |
|
|
|
|
|
const showSchemas = ref(cloneDeep(allSchemas)) |
|
|
const showReceiver = (data) => { |
|
|
const showReceiver = (data) => { |
|
|
if(data){ |
|
|
if(data){ |
|
|
// 根据当前receiverType启用相应字段 |
|
|
// 根据当前receiverType启用相应字段 |
|
@ -146,11 +174,16 @@ const showReceiver = (data) => { |
|
|
4: 'userIdList' |
|
|
4: 'userIdList' |
|
|
}; |
|
|
}; |
|
|
const enableField = fieldMap[data.receiverType]; |
|
|
const enableField = fieldMap[data.receiverType]; |
|
|
if (enableField) { |
|
|
if (enableField == 'roleIdList') { |
|
|
const itemToEnable = allSchemas.formSchema.find(item => item.field === enableField); |
|
|
showSchemas.value.formSchema = allSchemas.formSchema.filter(item => item.field != 'deptIdList' &&item.field != 'postIdList'&&item.field != 'userIdList'); |
|
|
if (itemToEnable) { |
|
|
} else if (enableField == 'deptIdList') { |
|
|
itemToEnable.componentProps.disabled = false; |
|
|
showSchemas.value.formSchema = allSchemas.formSchema.filter(item => item.field != 'roleIdList' &&item.field != 'postIdList'&&item.field != 'userIdList'); |
|
|
} |
|
|
} else if (enableField == 'postIdList') { |
|
|
|
|
|
showSchemas.value.formSchema = allSchemas.formSchema.filter(item => item.field != 'roleIdList' &&item.field != 'deptIdList'&&item.field != 'userIdList'); |
|
|
|
|
|
} else if (enableField == 'userIdList') { |
|
|
|
|
|
showSchemas.value.formSchema = allSchemas.formSchema.filter(item => item.field != 'roleIdList' &&item.field != 'postIdList'&&item.field != 'deptIdList'); |
|
|
|
|
|
} else { |
|
|
|
|
|
showSchemas.value.formSchema = allSchemas.formSchema.filter(item => item.field != 'roleIdList' && item.field != 'deptIdList' &&item.field != 'userIdList'&&item.field != 'postIdList'); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|