import type { CrudSchema } from '@/hooks/web/useCrudSchemas' import { dateFormatter } from '@/utils/formatTime' import { TableColumn } from '@/types/table' import * as ShopApi from '@/api/basedata/workshop' const shopList = await ShopApi.selectAllShops() // 表单校验 export const ProlineRules = reactive({ lineNo: [required], lineName: [required], shopId: [required] }) export const Proline = useCrudSchemas(reactive([ // { // label: '主键、自增', // field: 'id', // sort: 'custom', // isForm: false, // }, { label: '产线编号', field: 'lineNo', sort: 'custom', isSearch: false, }, { label: '产线名称', field: 'lineName', sort: 'custom', isSearch: true, }, { label: '产线描述', field: 'lineDesc', sort: 'custom', isSearch: false, }, { label: '所属车间', field: 'shopId', formatter: (_: Recordable, __: TableColumn, cellValue: number) => { return shopList.find((obj) => obj.id === cellValue)?.shopName }, search: { show: true, component: 'Select', api: () => shopList, componentProps: { optionsAlias: { labelField: 'shopName', valueField: 'id' } } }, form: { component: 'Select', api: () => shopList, componentProps: { optionsAlias: { labelField: 'shopName', valueField: 'id' } } } }, { label: '创建时间', field: 'createTime', sort: 'custom', formatter: dateFormatter, isSearch: false, search: { component: 'DatePicker', componentProps: { valueFormat: 'YYYY-MM-DD HH:mm:ss', type: 'daterange', defaultTime: [new Date('1 00:00:00'), new Date('1 23:59:59')] } }, isForm: false, }, { label: '操作', field: 'action', isForm: false, table: { width: 150, fixed: 'right' } } ]))