You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

57 lines
1.7 KiB

2 months ago
  1. /**
  2. * PO 订单行状态选项静态数据查询下拉用不查库
  3. */
  4. export const PO_ORDER_STATUS_OPTIONS = [
  5. { label: '已下达', value: '已下达' },
  6. { label: '待验货', value: '待验货' },
  7. { label: '验货中', value: '验货中' },
  8. { label: '验货完成', value: '验货完成' },
  9. { label: '已取消', value: '已取消' },
  10. { label: '已关闭', value: '已关闭' }
  11. ]
  12. /** 是否可「关闭」 */
  13. export function canClosePoOrder (status) {
  14. return !!status && status !== '已关闭' && status !== '已取消'
  15. }
  16. /** 是否可「打开」(仅已关闭) */
  17. export function canOpenPoOrder (status) {
  18. return status === '已关闭'
  19. }
  20. /**
  21. * 打开时根据验货数量推算恢复状态与后端 PoDetailStatusSupport 规则一致
  22. */
  23. export function resolvePoOrderStatusByInspectQty (row) {
  24. const toInspect = Number(row.toInspectQty != null ? row.toInspectQty : 0)
  25. const approve = Number(row.inspectApproveQty != null ? row.inspectApproveQty : (row.inspectionCompletedQty != null ? row.inspectionCompletedQty : 0))
  26. const qty = Number(row.qty != null ? row.qty : 0)
  27. if (toInspect === 0) {
  28. return '已下达'
  29. }
  30. if (toInspect > 0 && approve === 0) {
  31. return '待验货'
  32. }
  33. if (qty > 0 && approve === qty) {
  34. return '验货完成'
  35. }
  36. if (approve > 0 && (qty === 0 || approve < qty)) {
  37. return '验货中'
  38. }
  39. if (approve > 0 && qty > 0 && approve >= qty) {
  40. return '验货完成'
  41. }
  42. return '待验货'
  43. }
  44. /** 关闭/打开接口入参(id 为空时用 orderNo+site+itemNo 定位) */
  45. export function buildPoDetailActionParams (row, site) {
  46. return {
  47. id: row.id != null && row.id !== '' ? row.id : undefined,
  48. orderNo: row.orderNo,
  49. site: row.site || site,
  50. itemNo: row.itemNo
  51. }
  52. }