| | |
| | | import type { VbenFormSchema } from '#/adapter/form'; |
| | | import type { VbenFormApi, VbenFormSchema } from '#/adapter/form'; |
| | | import type { VxeTableGridOptions } from '#/adapter/vxe-table'; |
| | | import type { MesWmSnApi } from '#/api/mes/wm/sn'; |
| | | import type { DescriptionItemSchema } from '#/components/description'; |
| | | |
| | | import { markRaw } from 'vue'; |
| | | |
| | | import { MesWmSnStatusEnum } from '@vben/constants'; |
| | | import { formatDateTime } from '@vben/utils'; |
| | | |
| | | import { getRangePickerDefaultProps } from '#/utils'; |
| | | import { MdItemSelect } from '#/views/mes/md/item/components'; |
| | | import { |
| | | WmWarehouseAreaSelect, |
| | | WmWarehouseLocationSelect, |
| | | WmWarehouseSelect, |
| | | } from '#/views/wls/warehouse/components'; |
| | | |
| | | /** SN 状态选项(无独立字典,使用常量映射) */ |
| | | export const SN_STATUS_OPTIONS = [ |
| | | { label: '在库', value: MesWmSnStatusEnum.IN_STOCK }, |
| | | { label: '已出库', value: MesWmSnStatusEnum.OUT_STOCK }, |
| | | ]; |
| | | |
| | | /** 生成 SN 码的表单 */ |
| | | export function useFormSchema(): VbenFormSchema[] { |
| | |
| | | }, |
| | | ]; |
| | | } |
| | | |
| | | /** 在库单件列表的搜索表单 */ |
| | | export function useInStockGridFormSchema(): VbenFormSchema[] { |
| | | return [ |
| | | { |
| | | fieldName: 'code', |
| | | label: 'SN 码', |
| | | component: 'Input', |
| | | componentProps: { |
| | | allowClear: true, |
| | | placeholder: '请输入 SN 码', |
| | | }, |
| | | }, |
| | | { |
| | | fieldName: 'itemId', |
| | | label: '物料', |
| | | component: markRaw(MdItemSelect), |
| | | componentProps: { |
| | | placeholder: '请选择物料', |
| | | }, |
| | | }, |
| | | { |
| | | fieldName: 'batchCode', |
| | | label: '批次号', |
| | | component: 'Input', |
| | | componentProps: { |
| | | allowClear: true, |
| | | placeholder: '请输入批次号', |
| | | }, |
| | | }, |
| | | { |
| | | fieldName: 'status', |
| | | label: '状态', |
| | | component: 'Select', |
| | | componentProps: { |
| | | allowClear: true, |
| | | options: SN_STATUS_OPTIONS, |
| | | placeholder: '请选择状态', |
| | | }, |
| | | }, |
| | | ]; |
| | | } |
| | | |
| | | /** 在库单件列表的字段 */ |
| | | export function useInStockGridColumns(): VxeTableGridOptions<MesWmSnApi.Sn>['columns'] { |
| | | return [ |
| | | { |
| | | field: 'code', |
| | | title: 'SN 码', |
| | | minWidth: 180, |
| | | }, |
| | | { |
| | | field: 'itemCode', |
| | | title: '物料编码', |
| | | minWidth: 120, |
| | | }, |
| | | { |
| | | field: 'itemName', |
| | | title: '物料名称', |
| | | minWidth: 150, |
| | | }, |
| | | { |
| | | field: 'specification', |
| | | title: '规格型号', |
| | | minWidth: 120, |
| | | }, |
| | | { |
| | | field: 'unitName', |
| | | title: '单位', |
| | | width: 80, |
| | | }, |
| | | { |
| | | field: 'batchCode', |
| | | title: '批次号', |
| | | minWidth: 120, |
| | | }, |
| | | { |
| | | field: 'status', |
| | | title: '状态', |
| | | width: 90, |
| | | slots: { default: 'status' }, |
| | | }, |
| | | { |
| | | field: 'warehouseId', |
| | | title: '仓库', |
| | | minWidth: 140, |
| | | slots: { default: 'locations' }, |
| | | }, |
| | | { |
| | | field: 'createTime', |
| | | title: '生成时间', |
| | | width: 180, |
| | | formatter: 'formatDateTime', |
| | | }, |
| | | { |
| | | title: '操作', |
| | | width: 140, |
| | | fixed: 'right', |
| | | slots: { default: 'actions' }, |
| | | }, |
| | | ]; |
| | | } |
| | | |
| | | /** SN 码入库登记的表单 */ |
| | | export function useInStockFormSchema( |
| | | formApi?: VbenFormApi, |
| | | ): VbenFormSchema[] { |
| | | return [ |
| | | { |
| | | fieldName: 'code', |
| | | label: 'SN 码', |
| | | component: 'Input', |
| | | componentProps: { |
| | | placeholder: '扫码枪扫入或输入 SN 码', |
| | | }, |
| | | rules: 'required', |
| | | }, |
| | | { |
| | | fieldName: 'itemId', |
| | | label: '物料', |
| | | component: markRaw(MdItemSelect), |
| | | componentProps: { |
| | | placeholder: '请选择物料(须启用序列号管理)', |
| | | }, |
| | | rules: 'selectRequired', |
| | | }, |
| | | { |
| | | fieldName: 'warehouseId', |
| | | label: '仓库', |
| | | component: markRaw(WmWarehouseSelect), |
| | | componentProps: { |
| | | onChange: () => |
| | | formApi?.setValues({ areaId: undefined, locationId: undefined }), |
| | | placeholder: '请选择仓库', |
| | | }, |
| | | rules: 'selectRequired', |
| | | }, |
| | | { |
| | | fieldName: 'locationId', |
| | | label: '库区', |
| | | component: markRaw(WmWarehouseLocationSelect), |
| | | dependencies: { |
| | | triggerFields: ['warehouseId'], |
| | | show: (values) => !!values.warehouseId, |
| | | componentProps: (values) => ({ |
| | | onChange: () => formApi?.setFieldValue('areaId', undefined), |
| | | placeholder: '请选择库区', |
| | | warehouseId: values.warehouseId, |
| | | }), |
| | | }, |
| | | rules: 'selectRequired', |
| | | }, |
| | | { |
| | | fieldName: 'areaId', |
| | | label: '库位', |
| | | component: markRaw(WmWarehouseAreaSelect), |
| | | dependencies: { |
| | | triggerFields: ['locationId'], |
| | | show: (values) => !!values.locationId, |
| | | componentProps: (values) => ({ |
| | | locationId: values.locationId, |
| | | placeholder: '请选择库位', |
| | | }), |
| | | }, |
| | | rules: 'selectRequired', |
| | | }, |
| | | { |
| | | fieldName: 'batchCode', |
| | | label: '批次号', |
| | | component: 'Input', |
| | | componentProps: { |
| | | allowClear: true, |
| | | placeholder: '请输入批次号', |
| | | }, |
| | | }, |
| | | { |
| | | fieldName: 'remark', |
| | | label: '备注', |
| | | component: 'Textarea', |
| | | formItemClass: 'col-span-2', |
| | | componentProps: { |
| | | placeholder: '请输入备注', |
| | | rows: 2, |
| | | }, |
| | | }, |
| | | ]; |
| | | } |
| | | |
| | | /** SN 码出库核销的表单 */ |
| | | export function useOutStockFormSchema(): VbenFormSchema[] { |
| | | return [ |
| | | { |
| | | fieldName: 'code', |
| | | label: 'SN 码', |
| | | component: 'Input', |
| | | componentProps: { |
| | | placeholder: '扫码枪扫入或输入 SN 码', |
| | | }, |
| | | rules: 'required', |
| | | }, |
| | | { |
| | | fieldName: 'itemId', |
| | | label: '物料', |
| | | component: markRaw(MdItemSelect), |
| | | componentProps: { |
| | | placeholder: '请选择物料', |
| | | }, |
| | | rules: 'selectRequired', |
| | | }, |
| | | { |
| | | fieldName: 'remark', |
| | | label: '备注', |
| | | component: 'Textarea', |
| | | formItemClass: 'col-span-2', |
| | | componentProps: { |
| | | placeholder: '请输入备注', |
| | | rows: 2, |
| | | }, |
| | | }, |
| | | ]; |
| | | } |
| | | |
| | | /** SN 码单件详情的描述字段 */ |
| | | export function useSnDetailSchema(): DescriptionItemSchema[] { |
| | | return [ |
| | | { |
| | | field: 'code', |
| | | label: 'SN 码', |
| | | render: (value) => value || '-', |
| | | }, |
| | | { |
| | | field: 'itemCode', |
| | | label: '物料编码', |
| | | render: (value) => value || '-', |
| | | }, |
| | | { |
| | | field: 'itemName', |
| | | label: '物料名称', |
| | | render: (value) => value || '-', |
| | | }, |
| | | { |
| | | field: 'batchCode', |
| | | label: '批次号', |
| | | render: (value) => value || '-', |
| | | }, |
| | | { |
| | | field: 'status', |
| | | label: '状态', |
| | | render: (value) => |
| | | value === MesWmSnStatusEnum.OUT_STOCK |
| | | ? '已出库' |
| | | : value === MesWmSnStatusEnum.IN_STOCK |
| | | ? '在库' |
| | | : '-', |
| | | }, |
| | | { |
| | | field: 'warehouseId', |
| | | label: '在库位置', |
| | | slot: 'location', |
| | | }, |
| | | { |
| | | field: 'lastTransactionTypeName', |
| | | label: '最近流水', |
| | | slot: 'lastTransaction', |
| | | }, |
| | | { |
| | | field: 'lastTransactionTime', |
| | | label: '最近流水时间', |
| | | render: (value) => formatDateTime(value) || '-', |
| | | }, |
| | | ]; |
| | | } |