9 changed files with 317 additions and 4 deletions
@ -0,0 +1,65 @@
@@ -0,0 +1,65 @@
|
||||
<template> |
||||
<BasicModal |
||||
v-bind="$attrs" |
||||
width="720px" |
||||
@register="registerModal" |
||||
@ok="handleSubmit" |
||||
> |
||||
<BasicForm @register="registerForm"/> |
||||
</BasicModal> |
||||
</template> |
||||
<script lang="ts" setup> |
||||
import { BasicForm, useForm } from '/@/components/Form/index'; |
||||
import { concernSendFormSchema } from './concern.data'; |
||||
import { concernFanMessageSend } from '/@/api/platform/common/controller/pushConcernFan'; |
||||
import { BasicModal, ModalProps, useModalInner } from '/@/components/Modal'; |
||||
import { useMessage } from '/@/hooks/web/useMessage'; |
||||
|
||||
const { createMessage } = useMessage(); |
||||
const emit = defineEmits(['success', 'register']); |
||||
const [registerForm, { resetFields, setFieldsValue, validate, clearValidate, updateSchema }] = useForm({ |
||||
labelWidth: 80, |
||||
schemas: concernSendFormSchema, |
||||
showActionButtonGroup: false, |
||||
baseColProps: { span: 24 } |
||||
}); |
||||
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data: BoxPayload = { _tag: '' }) => { |
||||
// 处理清除脏数据 |
||||
await resetFields(); |
||||
await clearValidate(); |
||||
const props: Partial<ModalProps> = { confirmLoading: false }; |
||||
await updateSchema([ |
||||
{ |
||||
field: 'alias', |
||||
defaultValue: data.record?.concernUserId |
||||
}, |
||||
{ |
||||
field: 'pushTypeId', |
||||
componentProps: { |
||||
params: { |
||||
concernFanId: data.record?.id |
||||
}, |
||||
} |
||||
} |
||||
]); |
||||
props.title = '推送关注消息'; |
||||
// 尾部:设置处理后的最终配置数据 |
||||
setModalProps(props); |
||||
}); |
||||
|
||||
async function handleSubmit() { |
||||
try { |
||||
// 提取验证数据 |
||||
const formData = await validate(); |
||||
// 处理提交之前逻辑 |
||||
setModalProps({ confirmLoading: true }); |
||||
await concernFanMessageSend(formData); |
||||
// 处理提交完成之后逻辑 |
||||
closeModal(); |
||||
createMessage.success('推送成功!'); |
||||
emit('success'); |
||||
} finally { |
||||
setModalProps({ confirmLoading: false }); |
||||
} |
||||
} |
||||
</script> |
@ -0,0 +1,70 @@
@@ -0,0 +1,70 @@
|
||||
<template> |
||||
<BasicModal |
||||
v-bind="$attrs" |
||||
width="720px" |
||||
@register="registerModal" |
||||
@ok="handleSubmit" |
||||
> |
||||
<BasicForm @register="registerForm"/> |
||||
</BasicModal> |
||||
</template> |
||||
<script lang="ts" setup> |
||||
import { BasicForm, useForm } from '/@/components/Form/index'; |
||||
import { fanSendFormSchema } from './fan.data'; |
||||
import { concernFanMessageSend } from '/@/api/platform/common/controller/pushConcernFan'; |
||||
import { BasicModal, ModalProps, useModalInner } from '/@/components/Modal'; |
||||
import { useUserStore } from '/@/store/modules/user'; |
||||
import { useMessage } from '/@/hooks/web/useMessage'; |
||||
import { ref, unref } from 'vue'; |
||||
|
||||
const tag = ref<Nullable<string>>(''); |
||||
const { createMessage } = useMessage(); |
||||
const userStore = useUserStore(); |
||||
const userInfoStore = userStore.getUserInfo; |
||||
const emit = defineEmits(['success', 'register']); |
||||
const [registerForm, { resetFields, setFieldsValue, validate, clearValidate, updateSchema }] = useForm({ |
||||
labelWidth: 80, |
||||
schemas: fanSendFormSchema, |
||||
showActionButtonGroup: false, |
||||
baseColProps: { span: 24 } |
||||
}); |
||||
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data: BoxPayload = { _tag: '' }) => { |
||||
// 处理清除脏数据 |
||||
await resetFields(); |
||||
await clearValidate(); |
||||
tag.value = data._tag; |
||||
const props: Partial<ModalProps> = { confirmLoading: false }; |
||||
|
||||
switch (unref(tag)) { |
||||
case 'all': |
||||
break; |
||||
case 'single': |
||||
await updateSchema([ |
||||
{ |
||||
field: 'alias', |
||||
show: false, |
||||
defaultValue: [data.record?.fanUserId] |
||||
}]); |
||||
break; |
||||
} |
||||
props.title = '推送粉丝消息'; |
||||
setModalProps(props); |
||||
}); |
||||
|
||||
async function handleSubmit() { |
||||
try { |
||||
// 提取验证数据 |
||||
const formData = await validate(); |
||||
formData.alias = Array(formData.alias).join(','); |
||||
// 处理提交之前逻辑 |
||||
setModalProps({ confirmLoading: true }); |
||||
await concernFanMessageSend(formData); |
||||
// 处理提交完成之后逻辑 |
||||
closeModal(); |
||||
createMessage.success('推送成功!'); |
||||
emit('success'); |
||||
} finally { |
||||
setModalProps({ confirmLoading: false }); |
||||
} |
||||
} |
||||
</script> |
@ -0,0 +1,77 @@
@@ -0,0 +1,77 @@
|
||||
import {FormSchema} from '/@/components/Form'; |
||||
import {listPushType} from '/@/api/platform/common/controller/pushType'; |
||||
import {listPushConcernFan} from '/@/api/platform/common/controller/pushConcernFan'; |
||||
import {PushAuditStatus} from '/@/enums/pushEnum'; |
||||
import {useUserStore} from '/@/store/modules/user'; |
||||
|
||||
const userStore = useUserStore(); |
||||
const userInfoStore = userStore.getUserInfo; |
||||
|
||||
/** 粉丝用户发送消息表单 */ |
||||
export const fanSendFormSchema: FormSchema[] = [ |
||||
{ |
||||
field: 'userId', |
||||
label: '推送方用户id', |
||||
component: 'Input', |
||||
defaultValue: userInfoStore.id, |
||||
show: false |
||||
}, |
||||
{ |
||||
field: 'remarks', |
||||
label: '任务描述', |
||||
component: 'Input', |
||||
required: true, |
||||
componentProps: { |
||||
showCount: true, |
||||
maxlength: 20, |
||||
} |
||||
}, |
||||
{ |
||||
field: 'title', |
||||
label: '通知标题', |
||||
component: 'Input', |
||||
required: true, |
||||
}, |
||||
{ |
||||
label: '通知内容', |
||||
field: 'text', |
||||
component: 'InputTextArea', |
||||
required: true, |
||||
componentProps: { |
||||
rows: 6 |
||||
}, |
||||
}, |
||||
{ |
||||
field: 'pushTypeId', |
||||
label: '推送类型', |
||||
component: 'ApiSelect', |
||||
componentProps: { |
||||
api: listPushType, |
||||
params: { |
||||
size: 999 |
||||
}, |
||||
labelField: 'name', |
||||
valueField: 'id', |
||||
resultField: 'data' |
||||
}, |
||||
}, |
||||
{ |
||||
field: 'alias', |
||||
label: '推送用户', |
||||
component: 'ApiTreeSelect', |
||||
componentProps: { |
||||
api: listPushConcernFan, |
||||
params: { |
||||
status: PushAuditStatus.APPROVED, |
||||
concernUserId: userInfoStore.id |
||||
}, |
||||
resultField: 'data', |
||||
treeCheckable: true, |
||||
showCheckedStrategy: 'SHOW_PARENT', |
||||
treeDefaultExpandAll: true, |
||||
maxTagCount: 10, |
||||
fieldNames: { label: 'nickName', key: 'fanUserId', value: 'fanUserId' }, |
||||
allowClear: true, |
||||
}, |
||||
}, |
||||
]; |
Loading…
Reference in new issue