import type { VbenFormSchema } from '#/adapter/form'; import type { VxeTableGridOptions } from '#/adapter/vxe-table'; import { DICT_TYPE } from '@vben/constants'; import { getDictOptions } from '@vben/hooks'; import { getSimpleProductList } from '#/api/iot/product/product'; import { getRangePickerDefaultProps } from '#/utils'; /** 列表的搜索表单 */ export function useGridFormSchema(): VbenFormSchema[] { return [ { fieldName: 'name', label: '规则名称', component: 'Input', componentProps: { placeholder: '请输入规则名称', allowClear: true, }, }, { fieldName: 'productId', label: '产品', component: 'ApiSelect', componentProps: { api: getSimpleProductList, labelField: 'name', valueField: 'id', placeholder: '请选择产品', allowClear: true, }, }, { fieldName: 'status', label: '规则状态', component: 'Select', componentProps: { options: getDictOptions(DICT_TYPE.COMMON_STATUS, 'number'), placeholder: '请选择状态', allowClear: true, }, }, { fieldName: 'createTime', label: '创建时间', component: 'RangePicker', componentProps: getRangePickerDefaultProps(), }, ]; } /** 列表的字段 */ export function useGridColumns(): VxeTableGridOptions['columns'] { return [ { type: 'checkbox', width: 40 }, { field: 'id', title: '规则编号', minWidth: 80, }, { field: 'name', title: '规则名称', minWidth: 150, }, { field: 'productId', title: '所属产品', minWidth: 150, slots: { default: 'product' }, }, { field: 'description', title: '规则描述', minWidth: 200, }, { field: 'status', title: '规则状态', minWidth: 100, cellRender: { name: 'CellDict', props: { type: DICT_TYPE.COMMON_STATUS }, }, }, { field: 'sinkCount', title: '数据流转数', minWidth: 100, }, { field: 'createTime', title: '创建时间', minWidth: 180, formatter: 'formatDateTime', }, { title: '操作', width: 240, fixed: 'right', slots: { default: 'actions' }, }, ]; }