| | |
| | | |
| | | import { h, markRaw } from 'vue'; |
| | | |
| | | import { DICT_TYPE, MesAutoCodeRuleCode } from '@vben/constants'; |
| | | import { |
| | | DICT_TYPE, |
| | | MesAutoCodeRuleCode, |
| | | MesWmSalesNoticeOutStatusEnum, |
| | | } from '@vben/constants'; |
| | | |
| | | import { Button } from 'ant-design-vue'; |
| | | import { Button, Tag } from 'ant-design-vue'; |
| | | |
| | | import { z } from '#/adapter/form'; |
| | | import { generateAutoCode } from '#/api/mes/md/autocode/record'; |
| | | import { ErpSaleOrderSelect } from '#/views/erp/sale/order/components'; |
| | | import { MdClientSelect } from '#/views/mes/md/client/components'; |
| | | import { MdItemSelect } from '#/views/mes/md/item/components'; |
| | | |
| | |
| | | rules: 'required', |
| | | }, |
| | | { |
| | | fieldName: 'salesOrderCode', |
| | | label: '销售订单编号', |
| | | component: 'Input', |
| | | fieldName: 'saleOrderId', |
| | | label: '销售订单', |
| | | component: markRaw(ErpSaleOrderSelect), |
| | | componentProps: { |
| | | placeholder: '请输入销售订单编号', |
| | | placeholder: '请选择销售订单', |
| | | // 选择销售订单后,自动回填客户信息 |
| | | onChange: (item: any) => { |
| | | if (item?.customerId && formApi) { |
| | | formApi.setFieldValue('clientId', item.customerId); |
| | | formApi.setFieldValue('clientName', item.customerName); |
| | | } |
| | | }, |
| | | }, |
| | | }, |
| | | { |
| | | fieldName: 'clientName', |
| | | label: '', |
| | | component: 'Input', |
| | | dependencies: { |
| | | triggerFields: [''], |
| | | show: () => false, |
| | | }, |
| | | }, |
| | | { |
| | |
| | | component: markRaw(MdClientSelect), |
| | | componentProps: { |
| | | placeholder: '请选择客户', |
| | | disabled: true, |
| | | }, |
| | | dependencies: { |
| | | triggerFields: ['clientName'], |
| | | componentProps: (values) => ({ |
| | | placeholder: '请选择客户', |
| | | disabled: true, |
| | | clientName: values.clientName as string, |
| | | }), |
| | | }, |
| | | rules: 'selectRequired', |
| | | }, |
| | |
| | | }, |
| | | }, |
| | | { |
| | | field: 'outStatus', |
| | | title: '出库状态', |
| | | minWidth: 100, |
| | | cellRender: { |
| | | name: 'CellTag', |
| | | props: { |
| | | formatter: ({ row }: { row: MesWmSalesNoticeApi.SalesNotice }) => { |
| | | const statusMap: Record<number, { color: string; label: string }> = { |
| | | [MesWmSalesNoticeOutStatusEnum.NONE]: { color: 'default', label: '未出库' }, |
| | | [MesWmSalesNoticeOutStatusEnum.PARTIAL]: { color: 'warning', label: '部分出库' }, |
| | | [MesWmSalesNoticeOutStatusEnum.ALL]: { color: 'success', label: '全部出库' }, |
| | | }; |
| | | const status = statusMap[row.outStatus ?? MesWmSalesNoticeOutStatusEnum.NONE]; |
| | | return { color: status?.color, label: status?.label ?? '未出库' }; |
| | | }, |
| | | }, |
| | | }, |
| | | }, |
| | | { |
| | | title: '操作', |
| | | width: 200, |
| | | fixed: 'right', |
| | |
| | | width: 100, |
| | | }, |
| | | { |
| | | field: 'outCount', |
| | | title: '已出库数量', |
| | | width: 100, |
| | | formatter: ({ cellValue }: { cellValue: number }) => (cellValue || 0).toFixed(2), |
| | | }, |
| | | { |
| | | field: 'outProgress', |
| | | title: '出库进度', |
| | | width: 120, |
| | | cellRender: { |
| | | name: 'CellText', |
| | | props: { |
| | | formatter: ({ row }: { row: MesWmSalesNoticeLineApi.SalesNoticeLine }) => { |
| | | const quantity = row.quantity || 0; |
| | | const outCount = row.outCount || 0; |
| | | const percent = quantity > 0 ? Math.round((outCount / quantity) * 100) : 0; |
| | | return `${outCount.toFixed(2)} / ${quantity.toFixed(2)} (${percent}%)`; |
| | | }, |
| | | }, |
| | | }, |
| | | }, |
| | | { |
| | | field: 'batchCode', |
| | | title: '批次号', |
| | | minWidth: 120, |