zhou zhou
18 小时以前 c579731e0c206d6062f8442ec9df70ca781b26f6
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
136
137
138
139
140
141
142
143
144
145
146
import { ElMessageBox } from 'element-plus'
 
function normalizeText(value) {
  return String(value ?? '').trim()
}
 
function normalizeNumber(value) {
  if (value === '' || value === null || value === undefined) {
    return 0
  }
  const numericValue = Number(value)
  return Number.isFinite(numericValue) ? numericValue : 0
}
 
export function createTaskSearchState() {
  return {
    condition: '',
    taskCode: '',
    orgLoc: '',
    targLoc: '',
    barcode: ''
  }
}
 
export function buildTaskPageQueryParams(params = {}) {
  const result = {
    current: params.current || 1,
    pageSize: params.pageSize || params.size || 20
  }
 
  ;['condition', 'taskCode', 'orgLoc', 'targLoc', 'barcode'].forEach((key) => {
    const value = normalizeText(params[key])
    if (value) {
      result[key] = value
    }
  })
 
  return result
}
 
export function normalizeTaskRow(record = {}) {
  return {
    ...record,
    taskCode: record.taskCode || '-',
    taskStatusLabel: record['taskStatus$'] || '-',
    taskTypeLabel: record['taskType$'] || '-',
    warehTypeLabel: record['warehType$'] || '-',
    orgLoc: record.orgLoc || '-',
    orgSiteLabel: record['orgSite$'] || record.orgSite || '-',
    targLoc: record.targLoc || '-',
    targSiteLabel: record['targSite$'] || record.targSite || '-',
    barcode: record.barcode || '-',
    robotCode: record.robotCode || '-',
    sort: normalizeNumber(record.sort),
    statusText: record['status$'] || '-',
    updateTimeText: record['updateTime$'] || record.updateTime || '-',
    createTimeText: record['createTime$'] || record.createTime || '-',
    canComplete: record.canComplete === true
  }
}
 
export function normalizeTaskItemRow(record = {}) {
  return {
    ...record,
    orderTypeLabel: record['orderType$'] || '-',
    wkTypeLabel: record['wkType$'] || '-',
    platWorkCode: record.platWorkCode || '-',
    platItemId: record.platItemId || '-',
    matnrCode: record.matnrCode || '-',
    maktx: record.maktx || '-',
    batch: record.batch || '-',
    unit: record.unit || '-',
    anfme: normalizeNumber(record.anfme),
    updateByText: record['updateBy$'] || '-',
    updateTimeText: record['updateTime$'] || record.updateTime || '-'
  }
}
 
export function canCheckTask(row = {}) {
  return Number(row.taskStatus) === 199 && Number(row.taskType) === 107
}
 
export function canPickTask(row = {}) {
  return Number(row.taskStatus) === 199 && Number(row.taskType) === 103
}
 
export function getTaskActionList(row = {}) {
  return [
    {
      key: 'view',
      label: '查看详情',
      icon: 'ri:eye-line'
    },
    ...(row.canComplete
      ? [
          {
            key: 'complete',
            label: '完成任务',
            icon: 'ri:checkbox-circle-line',
            auth: 'update'
          }
        ]
      : []),
    ...(canCheckTask(row)
      ? [
          {
            key: 'check',
            label: '盘点出库',
            icon: 'ri:file-check-line',
            auth: 'update'
          }
        ]
      : []),
    ...(canPickTask(row)
      ? [
          {
            key: 'pick',
            label: '拣料出库',
            icon: 'ri:paint-line',
            auth: 'update'
          }
        ]
      : []),
    {
      key: 'top',
      label: '任务置顶',
      icon: 'ri:pushpin-line',
      auth: 'update'
    },
    {
      key: 'remove',
      label: '取消任务',
      icon: 'ri:close-circle-line',
      color: '#f56c6c',
      auth: 'delete'
    }
  ]
}
 
export async function confirmTaskAction(message) {
  await ElMessageBox.confirm(message, '提示', {
    type: 'warning',
    confirmButtonText: '确定',
    cancelButtonText: '取消'
  })
}