|
|
@ -67,6 +67,7 @@ import TableHead from '@/components/TableHead/src/TableHead.vue' |
|
|
|
import ImportForm from '@/components/ImportForm/src/ImportForm.vue' |
|
|
|
import Detail from '@/components/Detail/src/Detail.vue' |
|
|
|
import * as TableActionRelApi from '@/api/system/tableActionRel' |
|
|
|
import { validateCode } from '@/utils/validator' |
|
|
|
|
|
|
|
defineOptions({ name: 'MessageSet' }) |
|
|
|
|
|
|
@ -121,6 +122,7 @@ const HeadButttondata = [ |
|
|
|
const buttonBaseClick = (val, item) => { |
|
|
|
if (val == 'add') { // 新增 |
|
|
|
openForm('create') |
|
|
|
resetTemplateSet(null) |
|
|
|
} else if (val == 'import') { // 导入 |
|
|
|
handleImport() |
|
|
|
} else if (val == 'export') { // 导出 |
|
|
@ -143,6 +145,7 @@ const butttondata = [ |
|
|
|
const buttonTableClick = async (val, row) => { |
|
|
|
if (val == 'edit') { // 编辑 |
|
|
|
openForm('update', row) |
|
|
|
resetTemplateSet(row) |
|
|
|
} else if (val == 'delete') { // 删除 |
|
|
|
handleDelete(row.id) |
|
|
|
} |
|
|
@ -152,17 +155,15 @@ const alreadySelectedActionList = ref() |
|
|
|
/** 添加/修改操作 */ |
|
|
|
const basicFormRef = ref() |
|
|
|
const openForm = (type: string, row?: any) => { |
|
|
|
TableActionRelApi.getTableActionRelNoPage({}).then(res=>{ |
|
|
|
tableActionRef.value = res |
|
|
|
}); |
|
|
|
MessageSetApi.getMessageSetNoPage({}).then(res=>{ |
|
|
|
alreadySelectedActionList.value = res |
|
|
|
}); |
|
|
|
basicFormRef.value.open(type, row) |
|
|
|
} |
|
|
|
|
|
|
|
// form表单提交 |
|
|
|
const formsSuccess = async (formType,data) => { |
|
|
|
if(!validateMessageMethod(data)){ |
|
|
|
message.warning("至少选择一种发送模板!") |
|
|
|
return; |
|
|
|
} |
|
|
|
var isHave =MessageSet.allSchemas.formSchema.some(function (item) { |
|
|
|
return item.field === 'activeTime' || item.field === 'expireTime'; |
|
|
|
}); |
|
|
@ -245,27 +246,112 @@ const searchFormClick = (searchData) => { |
|
|
|
} |
|
|
|
|
|
|
|
const onChange = (field, cur) => { |
|
|
|
|
|
|
|
const formSchema = MessageSet.allSchemas.formSchema |
|
|
|
if (field == 'tableName') { |
|
|
|
// 首先,根据cur筛选出actionList |
|
|
|
let actionList = tableActionRef.value.filter(element => element.tableName === cur); |
|
|
|
|
|
|
|
// 接着,从actionList中筛除掉已经存在于alreadySelectedActionList中的项 |
|
|
|
actionList = actionList.filter(element => |
|
|
|
!alreadySelectedActionList.value.some(elementA => |
|
|
|
element.tableName == elementA.tableName && element.act == elementA.act |
|
|
|
) |
|
|
|
); |
|
|
|
|
|
|
|
// 更新MessageSet.allSchemas.formSchema中对应元素的componentProps.options |
|
|
|
const formItem = MessageSet.allSchemas.formSchema.find(element => element.field == 'act'); |
|
|
|
if (formItem && formItem.componentProps) { |
|
|
|
formItem.componentProps.options = actionList; |
|
|
|
formItem.componentProps.optionsAlias = { valueField: 'act', labelField: 'name' }; |
|
|
|
dealSubSelection(cur,null) |
|
|
|
let setV = {} |
|
|
|
setV['act'] = null |
|
|
|
basicFormRef.value.formRef.setValues(setV) |
|
|
|
} |
|
|
|
if(field == 'smsTemplateEnabled'){ |
|
|
|
if(cur){ |
|
|
|
formSchema.find(item=>item.field == 'smsTemplateId').componentProps.disabled = false |
|
|
|
MessageSetRules.smsTemplateId = [{required:true,message:'请选择站内信模板'}] |
|
|
|
}else{ |
|
|
|
formSchema.find(item=>item.field == 'smsTemplateId').componentProps.disabled = true |
|
|
|
MessageSetRules.smsTemplateId = [{required:false,message:'请选择站内信模板'}] |
|
|
|
|
|
|
|
const setV = {} |
|
|
|
setV['smsTemplateId'] = '' |
|
|
|
basicFormRef.value.formRef.setValues(setV) |
|
|
|
} |
|
|
|
}else if(field == 'emailTemplateEnabled'){ |
|
|
|
if(cur){ |
|
|
|
formSchema.find(item=>item.field == 'emailTemplateId').componentProps.disabled = false |
|
|
|
MessageSetRules.emailTemplateId = [{required:true,message:'请选择站内信模板'}] |
|
|
|
}else{ |
|
|
|
formSchema.find(item=>item.field == 'emailTemplateId').componentProps.disabled = true |
|
|
|
MessageSetRules.emailTemplateId = [{required:false,message:'请选择站内信模板'}] |
|
|
|
const setV = {} |
|
|
|
setV['emailTemplateId'] = '' |
|
|
|
basicFormRef.value.formRef.setValues(setV) |
|
|
|
} |
|
|
|
}else if(field == 'internalMessageTemplateEnabled'){ |
|
|
|
if(cur){ |
|
|
|
formSchema.find(item=>item.field == 'internalMessageTemplateId').componentProps.disabled = false |
|
|
|
MessageSetRules.internalMessageTemplateId = [{required:true,message:'请选择站内信模板'}] |
|
|
|
}else{ |
|
|
|
formSchema.find(item=>item.field == 'internalMessageTemplateId').componentProps.disabled = true |
|
|
|
MessageSetRules.internalMessageTemplateId = [{required:false,message:'请选择站内信模板'}] |
|
|
|
const setV = {} |
|
|
|
setV['internalMessageTemplateId'] = '' |
|
|
|
basicFormRef.value.formRef.setValues(setV) |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
const resetTemplateSet = (row) =>{ |
|
|
|
const formSchema = MessageSet.allSchemas.formSchema |
|
|
|
formSchema.find(item=>item.field == 'smsTemplateId').componentProps.disabled = true |
|
|
|
formSchema.find(item=>item.field == 'emailTemplateId').componentProps.disabled = true |
|
|
|
formSchema.find(item=>item.field == 'internalMessageTemplateId').componentProps.disabled = true |
|
|
|
formSchema.find(item=>item.field == 'act').componentProps.options = [] |
|
|
|
MessageSetRules.smsTemplateId = [{required:false,message:'请选择短信模板'}] |
|
|
|
MessageSetRules.emailTemplateId = [{required:false,message:'请选择邮件模板'}] |
|
|
|
MessageSetRules.internalMessageTemplateId = [{required:false,message:'请选择站内信模板'}] |
|
|
|
if(row){ |
|
|
|
dealSubSelection(row.tableName,row) |
|
|
|
if(row.smsTemplateEnabled){ |
|
|
|
formSchema.find(item=>item.field == 'smsTemplateId').componentProps.disabled = false |
|
|
|
MessageSetRules.smsTemplateId = [{required:true,message:'请选择短信模板'}] |
|
|
|
} |
|
|
|
if(row.emailTemplateEnabled){ |
|
|
|
formSchema.find(item=>item.field == 'emailTemplateId').componentProps.disabled = false |
|
|
|
MessageSetRules.emailTemplateId = [{required:true,message:'请选择邮件模板'}] |
|
|
|
} |
|
|
|
if(row.internalMessageTemplateEnabled){ |
|
|
|
formSchema.find(item=>item.field == 'internalMessageTemplateId').componentProps.disabled = false |
|
|
|
MessageSetRules.internalMessageTemplateId = [{required:true,message:'请选择站内信模板'}] |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
const validateMessageMethod = (data) => { |
|
|
|
if(data.smsTemplateId || data.emailTemplateId || data.internalMessageTemplateId) { |
|
|
|
return true |
|
|
|
} |
|
|
|
return false |
|
|
|
} |
|
|
|
|
|
|
|
const dealSubSelection = (cur,row) =>{ |
|
|
|
basicFormRef.value.formLoading = true |
|
|
|
TableActionRelApi.getTableActionRelNoPage({}).then(res=>{ |
|
|
|
tableActionRef.value = res |
|
|
|
MessageSetApi.getMessageSetNoPage({}).then(res=>{ |
|
|
|
alreadySelectedActionList.value = res |
|
|
|
const formSchema = MessageSet.allSchemas.formSchema |
|
|
|
// 首先,根据cur筛选出actionList |
|
|
|
let actionList = tableActionRef.value.filter(element => element.tableName === cur); |
|
|
|
|
|
|
|
// 接着,从actionList中筛除掉已经存在于alreadySelectedActionList中的项 |
|
|
|
actionList = actionList.filter(element => |
|
|
|
!alreadySelectedActionList.value.some(elementA => |
|
|
|
element.tableName == elementA.tableName && element.act == elementA.act |
|
|
|
) || (row?.tableName == element.tableName && row.act == element.act) |
|
|
|
); |
|
|
|
|
|
|
|
// 更新MessageSet.allSchemas.formSchema中对应元素的componentProps.options |
|
|
|
const formItem = formSchema.find(element => element.field == 'act'); |
|
|
|
if (formItem && formItem.componentProps) { |
|
|
|
formItem.componentProps.options = actionList; |
|
|
|
formItem.componentProps.optionsAlias = { valueField: 'act', labelField: 'name' }; |
|
|
|
} |
|
|
|
basicFormRef.value.formLoading = false |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
/** 初始化 **/ |
|
|
|
onMounted(async () => { |
|
|
|