| | |
| | | import { DICT_TYPE } from '@vben/constants'; |
| | | import { getDictOptions } from '@vben/hooks'; |
| | | |
| | | import { MdItemSelect } from '#/views/mes/md/item/components'; |
| | | import { ProLineSelect } from '#/views/mes/pro/line/components'; |
| | | import { UserSelect } from '#/views/system/user/components'; |
| | | import { getRangePickerDefaultProps } from '#/utils'; |
| | | |
| | | /** 表单类型 */ |
| | | export type FormType = 'create' | 'detail' | 'update'; |
| | | /** 表单类型(fill:临时批次码补录正式信息) */ |
| | | export type FormType = 'create' | 'detail' | 'update' | 'fill'; |
| | | |
| | | /** 未绑定托盘下拉选项 */ |
| | | export interface PalletOption { |
| | | label: string; |
| | | value: number; |
| | | itemId?: number; |
| | | itemName?: string; |
| | | itemCode?: string; |
| | | } |
| | | |
| | | /** 新增/修改的表单 */ |
| | | export function useFormSchema(formType: FormType): VbenFormSchema[] { |
| | | export function useFormSchema( |
| | | formType: FormType, |
| | | palletOptions: PalletOption[] = [], |
| | | onPalletChange?: (ids: number[]) => void, |
| | | ): VbenFormSchema[] { |
| | | const disabled = formType === 'detail'; |
| | | return [ |
| | | { |
| | |
| | | component: 'Input', |
| | | componentProps: { |
| | | disabled: true, |
| | | placeholder: '保存后自动生成', |
| | | placeholder: '补录后自动生成', |
| | | }, |
| | | dependencies: { |
| | | triggerFields: [''], |
| | | show: () => formType !== 'create', |
| | | }, |
| | | }, |
| | | { |
| | | fieldName: 'tempCode', |
| | | label: '临时批次码', |
| | | component: 'Input', |
| | | componentProps: { |
| | | disabled: true, |
| | | placeholder: '预生成二维码阶段使用的临时码', |
| | | }, |
| | | dependencies: { |
| | | triggerFields: [''], |
| | | show: () => formType === 'fill', |
| | | }, |
| | | }, |
| | | { |
| | |
| | | }, |
| | | }, |
| | | { |
| | | fieldName: 'itemId', |
| | | label: '品种', |
| | | component: markRaw(MdItemSelect), |
| | | fieldName: 'lineId', |
| | | label: '加工单位', |
| | | component: markRaw(ProLineSelect), |
| | | componentProps: { |
| | | disabled, |
| | | placeholder: '请选择品种(产品品种)', |
| | | placeholder: '请选择加工单位', |
| | | }, |
| | | rules: 'selectRequired', |
| | | }, |
| | | { |
| | | fieldName: 'lineId', |
| | | label: '产线', |
| | | component: markRaw(ProLineSelect), |
| | | fieldName: 'processingTeam', |
| | | label: '加工班组', |
| | | component: 'Input', |
| | | componentProps: { |
| | | allowClear: true, |
| | | disabled, |
| | | placeholder: '请选择产线', |
| | | maxlength: 64, |
| | | placeholder: '请输入加工班组', |
| | | }, |
| | | rules: 'selectRequired', |
| | | }, |
| | | { |
| | | fieldName: 'produceDate', |
| | |
| | | }, |
| | | { |
| | | fieldName: 'planQuantity', |
| | | label: '计划数量', |
| | | label: '加工数量', |
| | | component: 'InputNumber', |
| | | componentProps: { |
| | | class: '!w-full', |
| | | disabled, |
| | | min: 0, |
| | | placeholder: '请输入计划数量', |
| | | placeholder: '请输入加工数量', |
| | | precision: 2, |
| | | }, |
| | | }, |
| | |
| | | placeholder: '请选择责任人', |
| | | }, |
| | | rules: 'selectRequired', |
| | | }, |
| | | { |
| | | fieldName: 'itemId', component: 'Input', |
| | | dependencies: { triggerFields: [''], show: () => false }, |
| | | }, |
| | | { |
| | | fieldName: 'itemName', label: '品种名称', component: 'Input', |
| | | componentProps: { disabled: true, placeholder: '选择托盘后自动带入' }, |
| | | }, |
| | | { |
| | | fieldName: 'itemCode', label: '品种编码', component: 'Input', |
| | | componentProps: { disabled: true, placeholder: '选择托盘后自动带入' }, |
| | | }, |
| | | { |
| | | fieldName: 'palletIds', |
| | | label: '绑定托盘', |
| | | component: 'Select', |
| | | componentProps: { |
| | | allowClear: true, |
| | | disabled, |
| | | maxTagCount: 3, |
| | | dropdownMatchSelectWidth: false, |
| | | dropdownStyle: { minWidth: '360px', maxWidth: 'calc(100vw - 32px)' }, |
| | | mode: 'multiple', |
| | | optionFilterProp: 'label', |
| | | options: palletOptions, |
| | | onChange: onPalletChange, |
| | | placeholder: '请选择相同品种的托盘', |
| | | showSearch: true, |
| | | }, |
| | | dependencies: { |
| | | triggerFields: ['itemId'], |
| | | show: () => formType !== 'detail', |
| | | componentProps: (values) => ({ |
| | | options: palletOptions.map(option => ({ ...option, |
| | | disabled: !option.itemId || (!!values.itemId && option.itemId !== values.itemId), |
| | | })), |
| | | }), |
| | | }, |
| | | help: '只能绑定相同品种的托盘,品种信息自动带入;缺少品种的托盘请先装袋。绑定后批次直接进入生产中:托盘生成正式托盘码,托盘下未录批次的袋码自动级联录入本批次(袋码品种须一致);编辑时仅需勾选新增托盘,已绑定的不可解绑', |
| | | }, |
| | | { |
| | | fieldName: 'remark', |
| | |
| | | /** 列表的搜索表单 */ |
| | | export function useGridFormSchema(): VbenFormSchema[] { |
| | | return [ |
| | | { fieldName: 'businessCode', label: '业务码', component: 'Input', componentProps: { allowClear: true, placeholder: '请输入作业扫码业务码' } }, |
| | | { |
| | | fieldName: 'code', |
| | | label: '批次号', |
| | |
| | | }, |
| | | }, |
| | | { |
| | | fieldName: 'itemId', |
| | | label: '品种', |
| | | component: markRaw(MdItemSelect), |
| | | componentProps: { |
| | | placeholder: '请选择品种', |
| | | }, |
| | | }, |
| | | { |
| | | fieldName: 'lineCode', |
| | | label: '产线编码', |
| | | component: 'Input', |
| | | componentProps: { |
| | | allowClear: true, |
| | | placeholder: '请输入产线编码', |
| | | }, |
| | | }, |
| | | { |
| | | fieldName: 'lineName', |
| | | label: '产线名称', |
| | | label: '加工单位', |
| | | component: 'Input', |
| | | componentProps: { |
| | | allowClear: true, |
| | | placeholder: '请输入产线名称', |
| | | placeholder: '请输入加工单位', |
| | | }, |
| | | }, |
| | | { |
| | | fieldName: 'processingTeam', |
| | | label: '加工班组', |
| | | component: 'Input', |
| | | componentProps: { |
| | | allowClear: true, |
| | | placeholder: '请输入加工班组', |
| | | }, |
| | | }, |
| | | { |
| | |
| | | /** 列表的字段 */ |
| | | export function useGridColumns(): VxeTableGridOptions<MesProBatchApi.Batch>['columns'] { |
| | | return [ |
| | | { field: 'businessCode', title: '业务码(作业扫码)', minWidth: 210 }, |
| | | { |
| | | field: 'code', |
| | | title: '批次号', |
| | |
| | | minWidth: 200, |
| | | slots: { default: 'code' }, |
| | | }, |
| | | { field: 'itemName', title: '品种名称', minWidth: 150 }, |
| | | { field: 'itemCode', title: '品种编码', minWidth: 150 }, |
| | | { |
| | | field: 'itemCode', |
| | | title: '品种编码', |
| | | field: 'lineName', |
| | | title: '加工单位', |
| | | width: 120, |
| | | }, |
| | | { |
| | | field: 'itemName', |
| | | title: '品种名称', |
| | | width: 140, |
| | | }, |
| | | { |
| | | field: 'lineCode', |
| | | title: '产线编码', |
| | | width: 100, |
| | | }, |
| | | { |
| | | field: 'lineName', |
| | | title: '产线名称', |
| | | field: 'processingTeam', |
| | | title: '加工班组', |
| | | width: 120, |
| | | }, |
| | | { |
| | |
| | | }, |
| | | { |
| | | field: 'planQuantity', |
| | | title: '计划数量', |
| | | title: '加工数量', |
| | | width: 100, |
| | | }, |
| | | { |
| | |
| | | }, |
| | | { |
| | | title: '操作', |
| | | width: 200, |
| | | width: 350, |
| | | fixed: 'right', |
| | | slots: { default: 'actions' }, |
| | | }, |