zhou zhou
2 天以前 aaf8a50511d77dbc209ca93bbba308c21179a8bc
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
export const CHECK_ORDER_REPORT_TITLE = '盘点单报表'
 
const CHECK_EXCE_STATUS_MAP = {
  0: { label: '未执行', tagType: 'info' },
  1: { label: '执行中', tagType: 'warning' },
  2: { label: '已完成', tagType: 'success' },
  8: { label: '已取消', tagType: 'danger' }
}
 
function normalizeText(value) {
  return String(value ?? '').trim()
}
 
function getExceStatusConfig(status, statusText) {
  const fallback = CHECK_EXCE_STATUS_MAP[Number(status)] || {
    label: statusText || '-',
    tagType: 'info'
  }
  return {
    label: statusText || fallback.label,
    tagType: fallback.tagType
  }
}
 
export function createCheckOrderSearchState() {
  return {
    condition: '',
    code: '',
    wkType: '',
    exceStatus: '',
    arrTime: '',
    memo: ''
  }
}
 
export function buildCheckOrderSearchParams(params = {}) {
  const result = {}
  ;['condition', 'code', 'wkType', 'memo'].forEach((key) => {
    const value = normalizeText(params[key])
    if (value) {
      result[key] = value
    }
  })
 
  if (params.arrTime) {
    result.arrTime = params.arrTime
  }
 
  if (params.exceStatus !== '' && params.exceStatus !== undefined && params.exceStatus !== null) {
    result.exceStatus = Number(params.exceStatus)
  }
 
  return result
}
 
export function buildCheckOrderPageQueryParams(params = {}) {
  return {
    current: params.current || 1,
    pageSize: params.pageSize || params.size || 20,
    ...buildCheckOrderSearchParams(params)
  }
}
 
export function buildCheckOrderDetailQueryParams(params = {}) {
  return {
    orderId: params.orderId,
    current: params.current || 1,
    pageSize: params.pageSize || params.size || 20
  }
}
 
export function normalizeCheckOrderRow(record = {}) {
  const exceStatusConfig = getExceStatusConfig(record.exceStatus, record['exceStatus$'])
  return {
    ...record,
    code: record.code || '-',
    wkTypeLabel: record['wkType$'] || record.wkType || '-',
    checkTypeLabel: record.checkType$ || record.checkType || '-',
    anfme: record.anfme ?? 0,
    workQty: record.workQty ?? 0,
    qty: record.qty ?? 0,
    arrTimeText: record['arrTime$'] || record.arrTime || '-',
    updateByText: record['updateBy$'] || '-',
    updateTimeText: record['updateTime$'] || record.updateTime || '-',
    createByText: record['createBy$'] || '-',
    createTimeText: record['createTime$'] || record.createTime || '-',
    memo: record.memo || '-',
    exceStatusText: exceStatusConfig.label,
    exceStatusTagType: exceStatusConfig.tagType,
    canCancel: Number(record.exceStatus) === 0
  }
}
 
export function normalizeCheckOrderItemRow(record = {}) {
  return {
    ...record,
    orderCode: record.orderCode || '-',
    platOrderCode: record.platOrderCode || '-',
    matnrId: record.matnrId ?? '-',
    matnrCode: record.matnrCode || '-',
    maktx: record.maktx || '-',
    stockUnit: record.stockUnit || '-',
    splrBatch: record.splrBatch || '-',
    splrCode: record.splrCode || '-',
    splrName: record.splrName || '-',
    barcode: record.barcode || record.trackCode || '-',
    anfme: record.anfme ?? 0,
    workQty: record.workQty ?? 0,
    updateByText: record['updateBy$'] || '-',
    updateTimeText: record['updateTime$'] || record.updateTime || '-'
  }
}
 
export function getCheckOrderActionList(row = {}) {
  const normalizedRow = normalizeCheckOrderRow(row)
  return [
    {
      key: 'view',
      label: '查看详情',
      icon: 'ri:eye-line'
    },
    {
      key: 'print',
      label: '打印',
      icon: 'ri:printer-line'
    },
    {
      key: 'cancel',
      label: '取消单据',
      icon: 'ri:close-circle-line',
      color: 'var(--el-color-danger)',
      disabled: !normalizedRow.canCancel
    }
  ]
}