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
import request from '@/utils/http'
 
function normalizeText(value) {
  return String(value ?? '').trim()
}
 
function normalizeQueryParams(params = {}) {
  const result = {
    current: params.current || 1,
    pageSize: params.pageSize || params.size || 20
  }
 
  ;['condition', 'code', 'name', 'spec', 'model', 'color', 'size', 'barcode', 'groupId'].forEach((key) => {
    const value = params[key]
    if (value === undefined || value === null || value === '') {
      return
    }
    if (typeof value === 'string') {
      const trimmed = normalizeText(value)
      if (trimmed) {
        result[key] = trimmed
      }
      return
    }
    result[key] = value
  })
 
  return result
}
 
function normalizeGroupTreeParams(params = {}) {
  return {
    condition: normalizeText(params.condition)
  }
}
 
export function fetchMatnrPage(params = {}) {
  return request.post({
    url: '/matnr/page',
    params: normalizeQueryParams(params)
  })
}
 
export function fetchMatnrDetail(id) {
  return request.get({ url: `/matnr/${id}` })
}
 
export function fetchMatnrGroupTree(params = {}) {
  return request.post({
    url: '/matnrGroup/tree',
    params: normalizeGroupTreeParams(params)
  })
}