| | |
| | | <script lang="ts" setup> |
| | | import type { FormType } from '../data'; |
| | | |
| | | import type { ErpSaleOrderApi } from '#/api/erp/sale/order'; |
| | | import type { MesWmSalesNoticeApi } from '#/api/mes/wm/salesnotice'; |
| | | |
| | | import { computed, ref } from 'vue'; |
| | |
| | | submitSalesNotice, |
| | | updateSalesNotice, |
| | | } from '#/api/mes/wm/salesnotice'; |
| | | import { createSalesNoticeLine } from '#/api/mes/wm/salesnotice/line'; |
| | | import { getSaleOrderItemListByOrderId } from '#/api/erp/sale/order'; |
| | | import { $t } from '#/locales'; |
| | | |
| | | import { useFormSchema } from '../data'; |
| | |
| | | } |
| | | // 新增:保持弹窗打开,切换到编辑模式 |
| | | const id = await createSalesNotice(data); |
| | | // 选择了销售订单时,自动带入订单产品明细 |
| | | if (data.saleOrderId) { |
| | | try { |
| | | const items = await getSaleOrderItemListByOrderId(data.saleOrderId); |
| | | if (items?.length) { |
| | | await Promise.all(items.map((item: ErpSaleOrderApi.SaleOrderItem) => |
| | | createSalesNoticeLine({ |
| | | noticeId: id, |
| | | saleOrderItemId: item.id, |
| | | itemId: item.productId, |
| | | itemCode: item.productBarCode, |
| | | itemName: item.productName, |
| | | unitMeasureName: item.productUnitName, |
| | | quantity: item.count, |
| | | batchCode: item.batchCode, |
| | | oqcCheckFlag: false, |
| | | }), |
| | | )); |
| | | } |
| | | } catch { |
| | | // 获取订单明细失败不影响主流程 |
| | | } |
| | | } |
| | | formData.value = { |
| | | ...data, |
| | | id, |