Browse Source

消息通知改造

master_hella_20240701
ljlong_2630 6 months ago
parent
commit
57ed82dd73
  1. 5
      src/api/system/mail/template/index.ts
  2. 5
      src/api/system/notify/template/index.ts
  3. 5
      src/api/system/sms/smsTemplate/index.ts
  4. 128
      src/views/system/messageSet/index.vue
  5. 213
      src/views/system/messageSet/messageSet.data.ts
  6. 2
      src/views/system/tableActionRel/tableActionRel.data.ts

5
src/api/system/mail/template/index.ts

@ -48,3 +48,8 @@ export const deleteMailTemplate = async (id: number) => {
export const sendMail = (data: MailSendReqVO) => {
return request.post({ url: '/system/mail-template/send-mail', data })
}
// 查询邮件模版列表不分页
export const getMailTemplateNoPage = async (params: PageParam) => {
return await request.get({ url: '/system/mail-template/noPage', params })
}

5
src/api/system/notify/template/index.ts

@ -52,3 +52,8 @@ export const deleteNotifyTemplate = async (id: number) => {
export const sendNotify = (data: NotifySendReqVO) => {
return request.post({ url: '/system/notify-template/send-notify', data })
}
// 查询站内信模板列表不分页
export const getNotifyTemplateNoPage = async (params: PageParam) => {
return await request.get({ url: '/system/notify-template/noPage', params })
}

5
src/api/system/sms/smsTemplate/index.ts

@ -62,3 +62,8 @@ export const exportSmsTemplate = (params) => {
export const sendSms = (data: SendSmsReqVO) => {
return request.post({ url: '/system/sms-template/send-sms', data })
}
// 查询待发送列表
export const getSmsTemplateNoPage = (data: SendSmsReqVO) => {
return request.get({ url: '/system/sms-template/noPage', data })
}

128
src/views/system/messageSet/index.vue

@ -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') {
// curactionList
let actionList = tableActionRef.value.filter(element => element.tableName === cur);
// actionListalreadySelectedActionList
actionList = actionList.filter(element =>
!alreadySelectedActionList.value.some(elementA =>
element.tableName == elementA.tableName && element.act == elementA.act
)
);
// MessageSet.allSchemas.formSchemacomponentProps.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
// curactionList
let actionList = tableActionRef.value.filter(element => element.tableName === cur);
// actionListalreadySelectedActionList
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.formSchemacomponentProps.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 () => {

213
src/views/system/messageSet/messageSet.data.ts

@ -2,8 +2,23 @@ import type { CrudSchema } from '@/hooks/web/useCrudSchemas'
import { dateFormatter } from '@/utils/formatTime'
import * as TableActionRelApi from '@/api/system/tableActionRel'
import { getStrDictOptions } from '@/utils/dict'
import * as SmsTemplateApi from '@/api/system/sms/smsTemplate'
import * as MailTemplate from '@/api/system/mail/template'
import * as NotifyTemplate from '@/api/system/notify/template'
const trueFalse = [{
value: true,
label: '是'
},
{
value: false,
label: '否'
}]
const smsTemplateList = await SmsTemplateApi.getSmsTemplateNoPage({})
const mailTemplateList = await MailTemplate.getMailTemplateNoPage({})
const notifyTemplateList = await NotifyTemplate.getNotifyTemplateNoPage({})
// 假设这是TableActionRelApi.getTableActionRelNoPage({})的返回类型
interface Table {
tableName: string;
@ -51,6 +66,9 @@ export const MessageSetRules = reactive({
tableName: [required],
act: [required],
available: [required],
smsTemplateId: [required],
emailTemplateId: [required],
internalMessageTemplateId: [required],
})
export const MessageSet = useCrudSchemas(reactive<CrudSchema[]>([
@ -127,15 +145,204 @@ export const MessageSet = useCrudSchemas(reactive<CrudSchema[]>([
}
}
},
{
label: '短信模板是否启用',
field: 'smsTemplateEnabled',
sort: 'custom',
isSearch: true,
formatter: (_: Recordable, __: TableColumn, cellValue: boolean) => {
return trueFalse.find(item=>cellValue==item.value).label
},
form: {
component: 'Switch',
componentProps: {
activeValue: true,
inactiveValue: false,
},
value: false,
},
search: {
component: 'Select',
componentProps: {
options: [{
value: true,
label: '是'
},
{
value: false,
label: '否'
}]
},
}
},
{
label: '短信模板',
field: 'smsTemplateId',
sort: 'custom',
isSearch: true,
formatter: (_: Recordable, __: TableColumn, cellValue: number) => {
return smsTemplateList.find(item => cellValue == item.id)?.name
},
form: {
component: 'Select',
componentProps: {
options: smsTemplateList,
optionsAlias: {
labelField: 'name',
valueField: 'id'
},
filterable: true,
disabled: true,
}
},
search: {component: 'Select',
componentProps: {
options: smsTemplateList,
optionsAlias: {
labelField: 'name',
valueField: 'id'
},
filterable: true,
}
},
},
{
label: '邮件模板是否启用',
field: 'emailTemplateEnabled',
sort: 'custom',
isSearch: true,
formatter: (_: Recordable, __: TableColumn, cellValue: boolean) => {
return trueFalse.find(item=>cellValue==item.value).label
},
form: {
component: 'Switch',
componentProps: {
activeValue: true,
inactiveValue: false,
},
value: false,
},
search: {
component: 'Select',
componentProps: {
options: [{
value: true,
label: '是'
},
{
value: false,
label: '否'
}]
},
}
},
{
label: '邮件模板',
field: 'emailTemplateId',
sort: 'custom',
isSearch: true,
formatter: (_: Recordable, __: TableColumn, cellValue: number) => {
return mailTemplateList.find(item => cellValue == item.id)?.name
},
form: {
component: 'Select',
componentProps: {
options: mailTemplateList,
optionsAlias: {
labelField: 'name',
valueField: 'id'
},
filterable: true,
disabled: true,
}
},
search: {component: 'Select',
componentProps: {
options: mailTemplateList,
optionsAlias: {
labelField: 'name',
valueField: 'id'
},
filterable: true,
}
},
},
{
label: '内部消息模板是否启用',
field: 'internalMessageTemplateEnabled',
sort: 'custom',
isSearch: true,
formatter: (_: Recordable, __: TableColumn, cellValue: boolean) => {
return trueFalse.find(item=>cellValue==item.value).label
},
form: {
component: 'Switch',
componentProps: {
inactiveValue: false,
activeValue: true,
},
value: false,
},
search: {
component: 'Select',
componentProps: {
options: [{
value: true,
label: '是'
},
{
value: false,
label: '否'
}]
},
}
},
{
label: '内部消息模板',
field: 'internalMessageTemplateId',
sort: 'custom',
isSearch: true,
formatter: (_: Recordable, __: TableColumn, cellValue: number) => {
return notifyTemplateList.find(item => cellValue == item.id)?.name
},
form: {
component: 'Select',
componentProps: {
options: notifyTemplateList,
optionsAlias: {
labelField: 'name',
valueField: 'id'
},
filterable: true,
disabled: true,
}
},
search: {component: 'Select',
componentProps: {
options: notifyTemplateList,
optionsAlias: {
labelField: 'name',
valueField: 'id'
},
filterable: true,
}
},
},
{
label: '是否可用',
field: 'available',
sort: 'custom',
isSearch: true,
dictType: DICT_TYPE.FALSE_OR_TRUE,
dictClass: 'string', // 默认都是字符串类型其他暂不考虑
dictType: DICT_TYPE.TRUE_FALSE,
dictClass: 'string',
form: {
component: 'SelectV2',
component: 'Switch',
componentProps: {
activeValue: 'TRUE',
inactiveValue: 'FALSE',
},
value: 'TRUE',
}
},
{

2
src/views/system/tableActionRel/tableActionRel.data.ts

@ -76,7 +76,7 @@ export const TableActionRel = useCrudSchemas(reactive<CrudSchema[]>([
field: 'available',
sort: 'custom',
isSearch: true,
dictType: DICT_TYPE.FALSE_OR_TRUE,
dictType: DICT_TYPE.TRUE_FALSE,
dictClass: 'string', // 默认都是字符串类型其他暂不考虑
form: {
component: 'SelectV2',

Loading…
Cancel
Save