| | |
| | | import type { VbenFormApi, VbenFormSchema } from '#/adapter/form'; |
| | | import type { VbenFormApi, VbenFormSchema } from '#/adapter/form'; |
| | | import type { VxeTableGridOptions } from '#/adapter/vxe-table'; |
| | | import type { MesMdProductBomApi } from '#/api/mes/md/item/productBom'; |
| | | import type { MesProWorkOrderApi } from '#/api/mes/pro/workorder'; |
| | | import { type MesProWorkOrderApi, getWorkOrderApproveProcessList } from '#/api/mes/pro/workorder'; |
| | | import { getSimpleRoleList } from '#/api/system/role'; |
| | | import type { MesProWorkOrderBomApi } from '#/api/mes/pro/workorder/bom'; |
| | | import type { MesProWorkOrderProcessApi } from '#/api/mes/pro/workorder/process'; |
| | | |
| | |
| | | import { getRangePickerDefaultProps } from '#/utils'; |
| | | import { |
| | | MdItemSelect, |
| | | MdProductBomSelect, |
| | | } from '#/views/mes/md/item/components'; |
| | | import { MdVendorSelect } from '#/views/mes/md/vendor/components'; |
| | | |
| | |
| | | disabled: headerReadonly, |
| | | format: 'YYYY-MM-DD', |
| | | placeholder: '请选择需求日期', |
| | | valueFormat: 'x', |
| | | valueFormat: 'YYYY-MM-DD', |
| | | }, |
| | | rules: 'required', |
| | | }, |
| | | { |
| | | fieldName: 'feedbackRole', |
| | | label: '报工角色', |
| | | component: 'ApiSelect', |
| | | componentProps: { |
| | | api: getSimpleRoleList, |
| | | disabled: headerReadonly, |
| | | labelField: 'name', |
| | | valueField: 'code', |
| | | mode: 'multiple', |
| | | placeholder: '请选择报工角色', |
| | | }, |
| | | rules: 'selectRequired', |
| | | }, |
| | | { |
| | | fieldName: 'feedbackApprove', |
| | | label: '是否报工审批', |
| | | component: 'Switch', |
| | | componentProps: { |
| | | class: '!w-auto', |
| | | checkedChildren: '是', |
| | | unCheckedChildren: '否', |
| | | disabled: headerReadonly, |
| | | }, |
| | | defaultValue: false, |
| | | rules: 'required', |
| | | }, |
| | | { |
| | | fieldName: 'processDefinitionKey', |
| | | label: '审批流程', |
| | | component: 'ApiSelect', |
| | | componentProps: { |
| | | api: getWorkOrderApproveProcessList, |
| | | disabled: headerReadonly, |
| | | labelField: 'name', |
| | | valueField: 'key', |
| | | placeholder: '请选择审批流程', |
| | | }, |
| | | dependencies: { |
| | | triggerFields: ['feedbackApprove'], |
| | | show: (values) => !!values.feedbackApprove, |
| | | rules(values) { |
| | | if (values.feedbackApprove) { |
| | | return 'selectRequired'; |
| | | } |
| | | return undefined; |
| | | }, |
| | | }, |
| | | }, |
| | | |
| | | { |
| | | fieldName: 'remark', |
| | | label: '备注', |
| | |
| | | }, |
| | | }, |
| | | { |
| | | field: 'productionStatus', |
| | | title: '生产状态', |
| | | width: 100, |
| | | cellRender: { |
| | | name: 'CellDict', |
| | | props: { type: DICT_TYPE.ORDER_PRODUCTION_STATUS }, |
| | | }, |
| | | }, |
| | | { |
| | | field: 'processProgressList', |
| | | title: '工序生产进度', |
| | | width: 350, |
| | | slots: { default: 'processProgressList' }, |
| | | }, |
| | | { |
| | | field: 'completionProgress', |
| | | title: '完成进度', |
| | | width: 200, |
| | | slots: { default: 'completionProgress' }, |
| | | }, |
| | | { |
| | | field: 'createTime', |
| | | title: '创建时间', |
| | | width: 180, |
| | |
| | | width: 240, |
| | | fixed: 'right', |
| | | slots: { default: 'actions' }, |
| | | }, |
| | | ]; |
| | | } |
| | | |
| | | /** 订单 BOM 子表的字段 */ |
| | | export function useBomGridColumns( |
| | | editable: boolean, |
| | | generatable: boolean, |
| | | ): VxeTableGridOptions<MesProWorkOrderBomApi.WorkOrderBom>['columns'] { |
| | | return [ |
| | | { |
| | | field: 'itemCode', |
| | | title: 'BOM 物料编码', |
| | | width: 120, |
| | | }, |
| | | { |
| | | field: 'itemName', |
| | | title: 'BOM 物料名称', |
| | | minWidth: 150, |
| | | }, |
| | | { |
| | | field: 'itemSpecification', |
| | | title: '规格型号', |
| | | width: 120, |
| | | }, |
| | | { |
| | | field: 'unitMeasureName', |
| | | title: '单位', |
| | | width: 80, |
| | | }, |
| | | { |
| | | field: 'itemOrProduct', |
| | | title: '物料/产品', |
| | | width: 100, |
| | | cellRender: { |
| | | name: 'CellDict', |
| | | props: { type: DICT_TYPE.MES_MD_ITEM_OR_PRODUCT }, |
| | | }, |
| | | }, |
| | | { |
| | | field: 'quantity', |
| | | title: '预计使用量', |
| | | width: 120, |
| | | }, |
| | | { |
| | | field: 'remark', |
| | | title: '备注', |
| | | minWidth: 120, |
| | | }, |
| | | ...(editable || generatable |
| | | ? [ |
| | | { |
| | | title: '操作', |
| | | width: 160, |
| | | fixed: 'right', |
| | | slots: { default: 'actions' }, |
| | | } as const, |
| | | ] |
| | | : []), |
| | | ]; |
| | | } |
| | | |
| | | /** 订单 BOM 新增/修改的表单 */ |
| | | export function useBomFormSchema( |
| | | isCreate: boolean, |
| | | productId?: number, |
| | | formApi?: VbenFormApi, |
| | | ): VbenFormSchema[] { |
| | | return [ |
| | | { |
| | | fieldName: 'itemId', |
| | | label: '物料', |
| | | component: markRaw(MdProductBomSelect), |
| | | componentProps: { |
| | | itemId: productId, |
| | | placeholder: '请选择物料', |
| | | // BOM 物料选中后自动回填预计使用量 |
| | | onChange: async (bom?: MesMdProductBomApi.ProductBom) => { |
| | | await formApi?.setFieldValue('quantity', bom?.quantity ?? undefined); |
| | | }, |
| | | }, |
| | | rules: 'selectRequired', |
| | | dependencies: { |
| | | triggerFields: [''], |
| | | show: () => isCreate, |
| | | }, |
| | | }, |
| | | { |
| | | fieldName: 'itemName', |
| | | label: '物料', |
| | | component: 'Input', |
| | | componentProps: { |
| | | disabled: true, |
| | | }, |
| | | dependencies: { |
| | | triggerFields: [''], |
| | | show: () => !isCreate, |
| | | }, |
| | | }, |
| | | { |
| | | fieldName: 'unitMeasureName', |
| | | label: '单位', |
| | | component: 'Input', |
| | | componentProps: { |
| | | disabled: true, |
| | | }, |
| | | dependencies: { |
| | | triggerFields: [''], |
| | | show: () => !isCreate, |
| | | }, |
| | | }, |
| | | { |
| | | fieldName: 'quantity', |
| | | label: '预计使用量', |
| | | component: 'InputNumber', |
| | | componentProps: { |
| | | class: '!w-full', |
| | | min: 0, |
| | | placeholder: '请输入预计使用量', |
| | | precision: 2, |
| | | }, |
| | | rules: 'required', |
| | | }, |
| | | { |
| | | fieldName: 'remark', |
| | | label: '备注', |
| | | component: 'Textarea', |
| | | componentProps: { |
| | | placeholder: '请输入备注', |
| | | rows: 3, |
| | | }, |
| | | }, |
| | | ]; |
| | | } |
| | |
| | | field: 'drag', |
| | | title: '', |
| | | width: 40, |
| | | fixed: 'left', |
| | | slots: { default: 'dragHandle' }, |
| | | } as const, |
| | | ] |
| | |
| | | { |
| | | type: 'expand', |
| | | width: 50, |
| | | slots: { content: 'expand_content' }, |
| | | } as const, |
| | | { |
| | | field: 'sort', |
| | |
| | | slots: { default: 'backflushFlag' }, |
| | | }, |
| | | { |
| | | field: 'outputItemCode', |
| | | title: '产出物料编码', |
| | | width: 120, |
| | | }, |
| | | { |
| | | field: 'outputItemName', |
| | | title: '产出物料名称', |
| | | width: 120, |
| | | field: 'outputItemNames', |
| | | title: '产出物料', |
| | | width: 160, |
| | | }, |
| | | { |
| | | field: 'remark', |
| | |
| | | }, |
| | | { |
| | | title: '操作', |
| | | width: 120, |
| | | width: 200, |
| | | fixed: 'right', |
| | | slots: { default: 'actions' }, |
| | | }, |