import type { VbenFormSchema } from '#/adapter/form'; import type { OnActionClickFn, VxeTableGridOptions } from '#/adapter/vxe-table'; import type { SystemNotifyMessageApi } from '#/api/system/notify/message'; import { getRangePickerDefaultProps } from '@vben/utils'; import { DICT_TYPE, getDictOptions } from '#/utils/dict'; /** 列表的搜索表单 */ export function useGridFormSchema(): VbenFormSchema[] { return [ { fieldName: 'readStatus', label: '是否已读', component: 'Select', componentProps: { options: getDictOptions(DICT_TYPE.INFRA_BOOLEAN_STRING, 'boolean'), allowClear: true, placeholder: '请选择是否已读', }, }, { fieldName: 'createTime', label: '发送时间', component: 'RangePicker', componentProps: { allowClear: true, ...getRangePickerDefaultProps(), }, }, ]; } /** 列表的字段 */ export function useGridColumns( onActionClick: OnActionClickFn, ): VxeTableGridOptions['columns'] { return [ { title: '', width: 40, type: 'checkbox', }, { field: 'templateNickname', title: '发送人', minWidth: 180, }, { field: 'createTime', title: '发送时间', minWidth: 180, formatter: 'formatDateTime', }, { field: 'templateType', title: '类型', minWidth: 120, cellRender: { name: 'CellDict', props: { type: DICT_TYPE.SYSTEM_NOTIFY_TEMPLATE_TYPE }, }, }, { field: 'templateContent', title: '消息内容', minWidth: 300, }, { field: 'readStatus', title: '是否已读', minWidth: 100, cellRender: { name: 'CellDict', props: { type: DICT_TYPE.INFRA_BOOLEAN_STRING }, }, }, { field: 'readTime', title: '阅读时间', minWidth: 180, formatter: 'formatDateTime', }, { field: 'operation', title: '操作', minWidth: 180, align: 'center', fixed: 'right', cellRender: { attrs: { nameField: 'id', nameTitle: '站内信', onClick: onActionClick, }, name: 'CellOperation', options: [ { code: 'detail', text: '查看', show: (row: any) => row.readStatus, }, { code: 'read', text: '已读', show: (row: any) => !row.readStatus, }, ], }, }, ]; }