zjk
2026-07-31 8665daa7aa863f96d0d8f27c167edae1efc38022
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
export function getResponseData(response) {
  return response && response.data !== undefined ? response.data : response
}
 
export function getPageRows(response) {
  const data = getResponseData(response) || {}
  return data.records || data.list || data.rows || []
}
 
export function getPageTotal(response) {
  const data = getResponseData(response) || {}
  return Number(data.total || data.totalCount || getPageRows(response).length || 0)
}
 
export function normalizeBoolean(value) {
  return value === true || value === 'true' || value === 1 || value === '1'
}
 
export function booleanText(value) {
  return normalizeBoolean(value) ? '启用' : '禁用'
}
 
export function onlineText(value) {
  const status = normalizeOnlineStatus(value)
  if (status === 'ONLINE') {
    return '在线'
  }
  if (status === 'OFFLINE') {
    return '离线'
  }
  return '未激活'
}
 
export function onlineStatusClass(value) {
  return normalizeOnlineStatus(value).toLowerCase()
}
 
function normalizeOnlineStatus(value) {
  const status = String(value === undefined || value === null ? '' : value).trim().toUpperCase()
  if (status === 'ONLINE' || status === '1' || status === 'TRUE') {
    return 'ONLINE'
  }
  if (status === 'OFFLINE' || status === '0' || status === 'FALSE') {
    return 'OFFLINE'
  }
  return 'UNACTIVATED'
}
 
export function toIdArray(value) {
  if (Array.isArray(value)) {
    return value
  }
  if (value === undefined || value === null || value === '') {
    return []
  }
  return [value]
}
 
export function normalizeAreaOptions(list) {
  return (list || []).map(item => ({
    id: item.areaId,
    label: item.areaName,
    children: normalizeAreaOptions(item.children)
  }))
}
 
export function flattenArea(list, result = []) {
  (list || []).forEach(item => {
    result.push(item)
    flattenArea(item.children, result)
  })
  return result
}