| | |
| | | /** 表单类型 */ |
| | | export type NoticeFormType = 'create' | 'update' | 'detail'; |
| | | |
| | | /** 通知模板类型 */ |
| | | export const NOTICE_TYPE = { |
| | | TEXT: 1, |
| | | CARD: 2, |
| | | FILE: 3, |
| | | NEWS: 4, |
| | | } as const; |
| | | |
| | | export const NOTICE_TYPE_OPTIONS = [ |
| | | { label: '纯文本通知', value: NOTICE_TYPE.TEXT }, |
| | | { label: '图文卡片(填报/链接)', value: NOTICE_TYPE.CARD }, |
| | | { label: '文件通知(上传文件推送)', value: NOTICE_TYPE.FILE }, |
| | | { label: '图文消息(标题+摘要+封面)', value: NOTICE_TYPE.NEWS }, |
| | | ]; |
| | | |
| | | /** 通知表单 */ |
| | | export function useNoticeFormSchema(formType: NoticeFormType): VbenFormSchema[] { |
| | | const readonly = formType === 'detail'; |
| | |
| | | dependencies: { triggerFields: [''], show: () => false }, |
| | | }, |
| | | { |
| | | fieldName: 'noticeType', |
| | | label: '通知模板', |
| | | component: 'Select', |
| | | componentProps: { |
| | | options: NOTICE_TYPE_OPTIONS, |
| | | placeholder: '请选择通知模板', |
| | | disabled: readonly, |
| | | }, |
| | | rules: 'required', |
| | | }, |
| | | { |
| | | fieldName: 'title', |
| | | label: '通知标题', |
| | | component: 'Input', |
| | | componentProps: { placeholder: '请输入通知标题', disabled: readonly }, |
| | | rules: 'required', |
| | | formItemClass: 'col-span-2', |
| | | }, |
| | | { |
| | | fieldName: 'content', |
| | | label: '通知正文', |
| | | component: 'Textarea', |
| | | componentProps: { |
| | | rows: 8, |
| | | placeholder: '请输入通知正文', |
| | | rows: 6, |
| | | placeholder: '纯文本通知必填;其它模板可作为补充说明', |
| | | disabled: readonly, |
| | | }, |
| | | rules: 'required', |
| | | help: '推送时超过 600 字会自动截断,建议把关键信息放前面', |
| | | help: '纯文本通知推送时超过 600 字会自动截断,建议把关键信息放前面', |
| | | formItemClass: 'col-span-2', |
| | | }, |
| | | { |
| | | fieldName: 'summary', |
| | | label: '摘要', |
| | | component: 'Textarea', |
| | | componentProps: { |
| | | rows: 3, |
| | | placeholder: '图文卡片/图文消息展示的摘要', |
| | | disabled: readonly, |
| | | }, |
| | | dependencies: { |
| | | triggerFields: ['noticeType'], |
| | | show: (values) => |
| | | values.noticeType === NOTICE_TYPE.CARD || |
| | | values.noticeType === NOTICE_TYPE.NEWS, |
| | | }, |
| | | formItemClass: 'col-span-2', |
| | | }, |
| | | { |
| | | fieldName: 'linkUrl', |
| | | label: '跳转链接', |
| | | component: 'Input', |
| | | componentProps: { |
| | | placeholder: '填报页面或详情页地址,如 https://...', |
| | | disabled: readonly, |
| | | }, |
| | | dependencies: { |
| | | triggerFields: ['noticeType'], |
| | | show: (values) => |
| | | values.noticeType === NOTICE_TYPE.CARD || |
| | | values.noticeType === NOTICE_TYPE.NEWS, |
| | | }, |
| | | formItemClass: 'col-span-2', |
| | | }, |
| | | { |
| | | fieldName: 'linkBtnText', |
| | | label: '按钮文案', |
| | | component: 'Input', |
| | | componentProps: { |
| | | placeholder: '如:去填报 / 查看详情', |
| | | disabled: readonly, |
| | | }, |
| | | dependencies: { |
| | | triggerFields: ['noticeType'], |
| | | show: (values) => values.noticeType === NOTICE_TYPE.CARD, |
| | | }, |
| | | }, |
| | | { |
| | | fieldName: 'coverUrl', |
| | | label: '封面图地址', |
| | | component: 'Input', |
| | | componentProps: { |
| | | placeholder: '图文消息封面图地址(选填)', |
| | | disabled: readonly, |
| | | }, |
| | | dependencies: { |
| | | triggerFields: ['noticeType'], |
| | | show: (values) => values.noticeType === NOTICE_TYPE.NEWS, |
| | | }, |
| | | formItemClass: 'col-span-2', |
| | | }, |
| | | { |
| | | fieldName: 'fileBlobId', |
| | | label: '通知文件', |
| | | component: 'FileUpload', |
| | | componentProps: { |
| | | valueKey: 'id', |
| | | maxNumber: 1, |
| | | multiple: false, |
| | | showDescription: !readonly, |
| | | disabled: readonly, |
| | | }, |
| | | dependencies: { |
| | | triggerFields: ['noticeType'], |
| | | show: (values) => values.noticeType === NOTICE_TYPE.FILE, |
| | | }, |
| | | help: '企业微信文件消息上限 20MB', |
| | | formItemClass: 'col-span-2', |
| | | }, |
| | | { |
| | |
| | | export function useNoticeGridColumns(): VxeTableGridOptions<WxCpNoticeApi.Notice>['columns'] { |
| | | return [ |
| | | { |
| | | field: 'noticeTypeName', |
| | | title: '模板', |
| | | width: 150, |
| | | }, |
| | | { |
| | | field: 'title', |
| | | title: '通知标题', |
| | | minWidth: 220, |