diff --git a/src/views/system/mail/template/MailTemplateForm.vue b/src/views/system/mail/template/MailTemplateForm.vue
index 7b1e6513a..0e517cbdf 100644
--- a/src/views/system/mail/template/MailTemplateForm.vue
+++ b/src/views/system/mail/template/MailTemplateForm.vue
@@ -6,7 +6,7 @@
:title="dialogTitle"
:width="800"
>
-
+
确 定
取 消
@@ -17,6 +17,7 @@
import * as MailTemplateApi from '@/api/system/mail/template'
import { fi } from 'element-plus/es/locale'
import { allSchemas, rules } from './template.data'
+import { cloneDeep } from 'lodash-es'
defineOptions({ name: 'SystemMailTemplateForm' })
@@ -31,6 +32,7 @@ const formRef = ref() // 表单 Ref
/** 打开弹窗 */
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
dialogTitle.value = t('action.' + type)
formType.value = type
@@ -88,13 +90,13 @@ const onChange = async (field, cur) => {
formRef.value.setValues(setV);
// 禁用所有字段
- const fieldsToDisable = ['roleIdList', 'deptIdList', 'postIdList', 'userIdList'];
- fieldsToDisable.forEach(field => {
- const item = allSchemas.formSchema.find(item => item.field === field);
- if (item) {
- item.componentProps.disabled = true;
- }
- });
+ // const fieldsToDisable = ['roleIdList', 'deptIdList', 'postIdList', 'userIdList'];
+ // fieldsToDisable.forEach(field => {
+ // const item = allSchemas.formSchema.find(item => item.field === field);
+ // if (item) {
+ // item.componentProps.disabled = true;
+ // }
+ // });
// 根据当前receiverType启用相应字段
const fieldMap = {
@@ -105,11 +107,37 @@ const onChange = async (field, 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);
+ if (itemToEnable) {
+ 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);
// 禁用所有字段
- const fieldsToDisable = ['roleIdList', 'deptIdList', 'postIdList', 'userIdList'];
- fieldsToDisable.forEach(field => {
- const item = allSchemas.formSchema.find(item => item.field === field);
- if (item) {
- item.componentProps.disabled = true;
- }
- });
+ // const fieldsToDisable = ['roleIdList', 'deptIdList', 'postIdList', 'userIdList'];
+ // fieldsToDisable.forEach(field => {
+ // const item = allSchemas.formSchema.find(item => item.field === field);
+ // if (item) {
+ // item.componentProps.disabled = true;
+ // }
+ // });
}
-
+const showSchemas = ref(cloneDeep(allSchemas))
const showReceiver = (data) => {
if(data){
// 根据当前receiverType启用相应字段
@@ -146,11 +174,16 @@ const showReceiver = (data) => {
4: 'userIdList'
};
const enableField = fieldMap[data.receiverType];
- if (enableField) {
- const itemToEnable = allSchemas.formSchema.find(item => item.field === enableField);
- if (itemToEnable) {
- itemToEnable.componentProps.disabled = false;
- }
+ if (enableField == 'roleIdList') {
+ showSchemas.value.formSchema = allSchemas.formSchema.filter(item => item.field != 'deptIdList' &&item.field != 'postIdList'&&item.field != 'userIdList');
+ } else if (enableField == 'deptIdList') {
+ 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');
}
}
}
diff --git a/src/views/system/mail/template/template.data.ts b/src/views/system/mail/template/template.data.ts
index 87a6836dc..fb344afe3 100644
--- a/src/views/system/mail/template/template.data.ts
+++ b/src/views/system/mail/template/template.data.ts
@@ -95,7 +95,7 @@ const crudSchemas = reactive([
labelField: 'name',
valueField: 'id'
},
- disabled: true,
+ disabled: false,
filterable: true,
multiple: true,
placeholder: "请选择角色"
@@ -113,7 +113,7 @@ const crudSchemas = reactive([
component: 'TreeSelect',
componentProps: { // 假设deptList是部门数据列表
data: deptList,
- disabled: true,
+ disabled: false,
placeholder: "请选择部门",
filterable: true,
multiple: true,
@@ -135,7 +135,7 @@ const crudSchemas = reactive([
labelField: 'name',
valueField: 'id'
},
- disabled: true,
+ disabled: false,
filterable: true,
multiple: true,
placeholder: "请选择"
@@ -157,7 +157,7 @@ const crudSchemas = reactive([
labelField: 'nickname',
valueField: 'id'
},
- disabled: true,
+ disabled: false,
filterable: true,
multiple: true,
placeholder: "请选择"
diff --git a/src/views/system/notify/template/NotifyTemplateForm.vue b/src/views/system/notify/template/NotifyTemplateForm.vue
index e83a8d686..d62c9797f 100644
--- a/src/views/system/notify/template/NotifyTemplateForm.vue
+++ b/src/views/system/notify/template/NotifyTemplateForm.vue
@@ -16,11 +16,11 @@
-
+
-
+
/>
-
+
-
+
-
+