yyb
2 天以前 1bd1061c60c286e3b2216a67090c4976c9c7b35f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
import { computed, type Ref } from "vue";
import { CONTRACT_KIND, type ContractKind } from "./scanOut.constants";
 
const outboundQuantityRows = [
  { label: "已出库数量", key: "shippedQuantity" },
  { label: "不合格出库数量", key: "unqualifiedShippedQuantity" },
  { label: "不合格入库数量", key: "unqualifiedStockedQuantity" },
  { label: "剩余出库数量", key: "remainingShippedQuantity" },
] as const;
 
const inboundQuantityRows = [
  { label: "已入库数量", key: "stockedQuantity" },
  { label: "不合格入库数量", key: "unqualifiedStockedQuantity" },
  { label: "剩余入库数量", key: "remainingQuantity" },
] as const;
 
export const detailFieldRowsSales = [
  { label: "楼层编号", key: "floorCode" },
  { label: "产品大类", key: "productCategory" },
  { label: "规格型号", key: "specificationModel" },
  { label: "厚度", key: "thickness" },
  { label: "宽(mm)", key: "width" },
  { label: "高(mm)", key: "height" },
  { label: "周长(cm)", key: "perimeter" },
  { label: "总面积(m²)", key: "actualTotalArea" },
  { label: "加工要求", key: "processRequirement" },
  { label: "备注", key: "remark" },
  { label: "重箱", key: "heavyBox" },
  { label: "产品状态", key: "approveStatus" },
  { label: "入库状态", key: "productStockStatus" },
  { label: "快递公司", key: "expressCompany" },
  { label: "快递单号", key: "expressNumber" },
  { label: "发货车牌", key: "shippingCarNumber" },
  { label: "发货日期", key: "shippingDate" },
  { label: "数量", key: "quantity" },
  { label: "税率(%)", key: "taxRate" },
  { label: "含税单价(元)", key: "taxInclusiveUnitPrice" },
  { label: "含税总价(元)", key: "taxInclusiveTotalPrice" },
  { label: "不含税总价(元)", key: "taxExclusiveTotalPrice" },
] as const;
 
export const detailFieldRowsPurchase = [
  { label: "产品大类", key: "productCategory" },
  { label: "规格型号", key: "specificationModel" },
  { label: "单位", key: "unit" },
  { label: "数量", key: "quantity" },
  { label: "可用数量", key: "availableQuality" },
  { label: "退货数量", key: "returnQuality" },
  { label: "税率(%)", key: "taxRate" },
  { label: "含税单价(元)", key: "taxInclusiveUnitPrice" },
  { label: "含税总价(元)", key: "taxInclusiveTotalPrice" },
  { label: "不含税总价(元)", key: "taxExclusiveTotalPrice" },
] as const;
 
export const summaryFieldRowsSales = [
  { label: "楼层编号", key: "floorCode" },
  { label: "产品大类", key: "productCategory" },
  { label: "规格型号", key: "specificationModel" },
  { label: "数量", key: "quantity" },
  { label: "产品状态", key: "approveStatus" },
  { label: "入库状态", key: "productStockStatus" },
] as const;
 
export const summaryFieldRowsPurchase = [
  { label: "产品大类", key: "productCategory" },
  { label: "规格型号", key: "specificationModel" },
  { label: "单位", key: "unit" },
  { label: "数量", key: "quantity" },
  { label: "可用数量", key: "availableQuality" },
] as const;
 
type FieldRow = { label: string; key: string };
type ScanScene = "outbound" | "inbound";
 
export function useScanOutFieldRows(contractKindRef: Ref<ContractKind>, scene: ScanScene = "outbound") {
  const quantityRows = scene === "inbound" ? inboundQuantityRows : outboundQuantityRows;
  const fieldRowsByContractKind = {
    [CONTRACT_KIND.sales]: {
      detail: [...detailFieldRowsSales, ...quantityRows],
      summary: [...summaryFieldRowsSales, ...quantityRows],
    },
    [CONTRACT_KIND.purchase]: {
      detail: [...detailFieldRowsPurchase, ...quantityRows],
      summary: [...summaryFieldRowsPurchase, ...quantityRows],
    },
  } satisfies Record<ContractKind, { detail: readonly FieldRow[]; summary: readonly FieldRow[] }>;
 
  const currentContractFieldRows = computed(() => fieldRowsByContractKind[contractKindRef.value]);
 
  const detailFieldRows = computed(() => currentContractFieldRows.value.detail);
  const summaryFieldRows = computed(() => currentContractFieldRows.value.summary);
 
  return { detailFieldRows, summaryFieldRows };
}