zhou zhou
1 天以前 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
import request from '@/utils/http'
 
function normalizeText(value) {
  return typeof value === 'string' ? value.trim() : value
}
 
function normalizeNumber(value) {
  if (value === '' || value === null || value === undefined) {
    return null
  }
  const numericValue = Number(value)
  return Number.isFinite(numericValue) ? numericValue : null
}
 
function withTextParam(target, key, value) {
  const normalized = normalizeText(value)
  if (normalized) {
    target[key] = normalized
  }
}
 
function withNumberParam(target, key, value) {
  const normalized = normalizeNumber(value)
  if (normalized !== null) {
    target[key] = normalized
  }
}
 
export function buildLocItemPageParams(params = {}) {
  const payload = {
    current: params.current || 1,
    pageSize: params.pageSize || params.size || 20
  }
 
  ;[
    'condition',
    'type',
    'maktx',
    'matnrCode',
    'trackCode',
    'unit',
    'batch',
    'splrBatch',
    'spec',
    'model',
    'fieldsIndex',
    'memo'
  ].forEach((key) => withTextParam(payload, key, params[key]))
 
  ;['locId', 'orderId', 'orderItemId', 'wkType', 'matnrId', 'anfme', 'status'].forEach((key) =>
    withNumberParam(payload, key, params[key])
  )
 
  if (params.timeStart) {
    payload.timeStart = params.timeStart
  }
  if (params.timeEnd) {
    payload.timeEnd = params.timeEnd
  }
 
  return payload
}
 
export function fetchLocItemPage(params = {}) {
  return request.post({
    url: '/locItem/page',
    params: buildLocItemPageParams(params)
  })
}
 
export function fetchLocItemDetail(id) {
  return request.get({
    url: `/locItem/${id}`
  })
}
 
export function fetchEnabledFields() {
  return request.get({
    url: '/fields/enable/list'
  })
}