diff --git a/packages/app-operation/src/components/BasicData/BoxProductList.tsx b/packages/app-operation/src/components/BasicData/BoxProductList.tsx index 68c9313..80f6f49 100644 --- a/packages/app-operation/src/components/BasicData/BoxProductList.tsx +++ b/packages/app-operation/src/components/BasicData/BoxProductList.tsx @@ -210,6 +210,7 @@ export default function BoxProductList(props: IBoxProductListProps) { >[]; const actionRef = useRef(); + const actionBrandRef = useRef(); return ( ( {(value: RouteContextType) => { @@ -296,12 +298,12 @@ export default function BoxProductList(props: IBoxProductListProps) { ghost={true} search={false} onValueChange={() => { - actionRef.current?.reload(); + actionBrandRef.current?.reload(); }} />, ], }} - actionRef={actionRef} + actionRef={actionBrandRef} ghost={true} params={boxBrandParams} grid={{ column: 1 }} @@ -378,7 +380,7 @@ export default function BoxProductList(props: IBoxProductListProps) { ); } - actionRef.current?.reload(); + actionBrandRef.current?.reload(); }} checkedChildren={intl.formatMessage({ id: @@ -402,6 +404,10 @@ export default function BoxProductList(props: IBoxProductListProps) { ghost={true} search={false} brandId={item.brandId} + onValueChange={() => { + actionBrandRef.current?.reload(); + actionRef.current?.reload(); + }} trigger={() => { return ; }} @@ -412,6 +418,10 @@ export default function BoxProductList(props: IBoxProductListProps) { ghost={true} search={false} brandId={item.brandId} + onValueChange={() => { + actionBrandRef.current?.reload(); + actionRef.current?.reload(); + }} trigger={() => { return ; }} @@ -442,6 +452,9 @@ export default function BoxProductList(props: IBoxProductListProps) { mode={'create'} ghost={true} search={false} + onValueChange={() => { + actionBrandRef.current?.reload(); + }} /> diff --git a/packages/app-operation/src/components/NotifyMessage/NotificationMessage.tsx b/packages/app-operation/src/components/NotifyMessage/NotificationMessage.tsx index 78b3b67..7865c27 100644 --- a/packages/app-operation/src/components/NotifyMessage/NotificationMessage.tsx +++ b/packages/app-operation/src/components/NotifyMessage/NotificationMessage.tsx @@ -80,13 +80,13 @@ const NotificationMessage: React.FC = ({ markAsRead(item.messageReceiverId); } // 可以跳转到消息详情页面 - // history.push(`/message/detail/${item.messageReceiverId}`); + // history.push(`/operation/settings/notify/message-record`); }; // 查看更多消息 const handleViewMore = () => { setDropdownOpen(false); - history.push('/message'); + history.push('/operation/settings/notify/message-record'); }; // 下拉菜单内容 diff --git a/packages/app-operation/src/components/NotifyMessage/NotifyMessageRecordList.tsx b/packages/app-operation/src/components/NotifyMessage/NotifyMessageRecordList.tsx new file mode 100644 index 0000000..3ec9fef --- /dev/null +++ b/packages/app-operation/src/components/NotifyMessage/NotifyMessageRecordList.tsx @@ -0,0 +1,163 @@ +import { BizContainer, BizValueType, ModeType } from '@/components'; +import { business } from '@/services'; +import { useIntl } from '@@/exports'; +import { ActionType, ProColumns } from '@ant-design/pro-components'; +import { ProDescriptionsItemProps } from '@ant-design/pro-descriptions'; +import { Tag } from 'antd'; +import React, { useRef } from 'react'; + +interface INotifyMessageRecordListProps { + ghost?: boolean; + search?: boolean; + onValueChange?: () => void; + mode?: ModeType; + trigger?: () => React.ReactNode; +} + +export default function NotifyMessageRecordList( + props: INotifyMessageRecordListProps, +) { + const { + ghost = false, + search = true, + mode = 'page', + trigger, + onValueChange, + } = props; + const intl = useIntl(); + const intlPrefix = 'notifyMessageRecord'; + const actionRef = useRef(); + + // 是否已读状态映射 + const isReadMap: Record = { + false: { + text: intl.formatMessage({ id: intlPrefix + '.status.unread' }), + color: 'red', + }, + true: { + text: intl.formatMessage({ id: intlPrefix + '.status.read' }), + color: 'default', + }, + }; + + const columns: ProColumns[] = [ + { + title: intl.formatMessage({ id: intlPrefix + '.column.title' }), + dataIndex: ['messageVO', 'title'], + key: 'messageId', + ellipsis: true, + }, + { + title: intl.formatMessage({ id: intlPrefix + '.column.content' }), + dataIndex: ['messageVO', 'content'], + key: 'content', + ellipsis: true, + hideInTable: true, // 内容较长,在表格中隐藏,只在详情中显示 + }, + { + title: intl.formatMessage({ id: intlPrefix + '.column.isRead' }), + dataIndex: 'isRead', + key: 'isRead', + valueType: 'select', + valueEnum: { + true: { + text: isReadMap.true.text, + status: 'Default', + }, + false: { + text: isReadMap.false.text, + status: 'Error', + }, + }, + render: (_, record) => { + const isRead = record.isRead ? 'true' : 'false'; + const isReadInfo = isReadMap[isRead]; + return {isReadInfo.text}; + }, + }, + { + title: intl.formatMessage({ id: intlPrefix + '.column.readAt' }), + dataIndex: 'readAt', + key: 'readAt', + valueType: 'dateTime', + search: false, + hideInTable: true, // 已读时间通常不显示在列表中 + }, + { + title: intl.formatMessage({ id: intlPrefix + '.column.createdAt' }), + dataIndex: 'createdAt', + key: 'createdAt', + valueType: 'dateTime', + search: false, + sorter: true, + }, + ]; + + const detailColumns: ProDescriptionsItemProps< + BusinessAPI.MessageReceiverVO, + BizValueType + >[] = columns as ProDescriptionsItemProps< + BusinessAPI.MessageReceiverVO, + BizValueType + >[]; + + return ( + + rowKey={'messageReceiverId'} + permission={'operation-notify-message-record'} + func={business.messageReceiver} + method={'messageReceiver'} + methodUpper={'MessageReceiver'} + intlPrefix={intlPrefix} + modeType={mode} + onValueChange={onValueChange} + container={{ ghost }} + actionRef={actionRef} + status={false} + page={{ + fieldProps: { + bordered: true, + ghost, + // @ts-ignore + search, + pagination: { + defaultPageSize: 20, + showSizeChanger: true, + showQuickJumper: true, + }, + }, + columns, + options: () => [], + // 自定义行点击事件,点击消息自动标记已读 + onRow: (record: any) => ({ + onClick: async () => { + // 如果未读,标记为已读 + if (!record.isRead) { + try { + await business.messageReceiver.markReadMessageReceiver({ + messageReceiverId: record.messageReceiverId, + }); + actionRef.current?.reload(); + onValueChange?.(); + } catch (error) { + console.error('标记已读失败:', error); + } + } + }, + }), + }} + create={false} + update={false} + destroy={false} + detail={{ + formType: 'drawer', + columns: detailColumns, + trigger, + }} + /> + ); +} diff --git a/packages/app-operation/src/components/NotifyMessage/NotifyMessageTemplateList.tsx b/packages/app-operation/src/components/NotifyMessage/NotifyMessageTemplateList.tsx index b01df59..e62310e 100644 --- a/packages/app-operation/src/components/NotifyMessage/NotifyMessageTemplateList.tsx +++ b/packages/app-operation/src/components/NotifyMessage/NotifyMessageTemplateList.tsx @@ -27,9 +27,6 @@ const variables = [ '车次号', '车牌号', '目的地', - '利润金额', - '瓜农姓名', - '瓜农货款', '录入员姓名', '录入员提审时间', // 采购单审核 diff --git a/packages/app-operation/src/components/NotifyMessage/index.ts b/packages/app-operation/src/components/NotifyMessage/index.ts index 6c987da..cbc616f 100644 --- a/packages/app-operation/src/components/NotifyMessage/index.ts +++ b/packages/app-operation/src/components/NotifyMessage/index.ts @@ -1,2 +1,3 @@ export { default as NotificationMessage } from './NotificationMessage'; +export { default as NotifyMessageRecordList } from './NotifyMessageRecordList'; export { default as NotifyMessageTemplateList } from './NotifyMessageTemplateList'; diff --git a/packages/app-operation/src/locales/zh-CN.ts b/packages/app-operation/src/locales/zh-CN.ts index 777593d..dd0cccd 100644 --- a/packages/app-operation/src/locales/zh-CN.ts +++ b/packages/app-operation/src/locales/zh-CN.ts @@ -3435,4 +3435,24 @@ export default { markReadSuccess: '标记已读成功', markReadFailed: '标记已读失败', }, + notifyMessageRecord: { + column: { + title: '消息标题', + content: '消息内容', + isRead: '阅读状态', + readAt: '已读时间', + createdAt: '接收时间', + option: '操作', + }, + status: { + read: '已读', + unread: '未读', + }, + modal: { + view: { + title: '查看消息详情', + button: '详情', + }, + }, + }, }; diff --git a/packages/app-operation/src/pages/NotifyMessageRecord.tsx b/packages/app-operation/src/pages/NotifyMessageRecord.tsx new file mode 100644 index 0000000..1c52050 --- /dev/null +++ b/packages/app-operation/src/pages/NotifyMessageRecord.tsx @@ -0,0 +1,5 @@ +import { NotifyMessageRecordList } from '@/components'; + +export default function Page() { + return ; +} diff --git a/packages/app-operation/src/services/business/typings.d.ts b/packages/app-operation/src/services/business/typings.d.ts index 6b877e1..093c2c2 100644 --- a/packages/app-operation/src/services/business/typings.d.ts +++ b/packages/app-operation/src/services/business/typings.d.ts @@ -259,6 +259,7 @@ declare namespace BusinessAPI { status?: boolean; /** 纸箱品牌ID */ brandId?: string; + title?: string; /** 品牌类型:1_我方纸箱;2_瓜农纸箱;3_第三方纸箱;4_礼盒; */ type?: 'OUR_BOX' | 'FARMER_BOX' | 'THIRD_PARTY_BOX' | 'GIFT_BOX'; offset?: number;