@a2simcode/ui 0.0.70 → 0.0.71
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/barcode/index.d.ts +3 -3
- package/dist/components/barcode/src/barcode.vue.d.ts +1 -1
- package/dist/components/date/index.d.ts +98 -0
- package/dist/components/date/src/date.vue.d.ts +78 -0
- package/dist/components/index.d.ts +3 -1
- package/dist/components/slider/index.d.ts +3 -3
- package/dist/components/slider/src/slider.vue.d.ts +1 -1
- package/dist/components/tabs/index.d.ts +3 -3
- package/dist/components/tabs/src/tabs.vue.d.ts +1 -1
- package/dist/simcode-ui.es.js +4800 -4609
- package/dist/simcode-ui.umd.js +2 -2
- package/dist/stats.html +1 -1
- package/dist/ui.css +1 -1
- package/docs/components/date.md +76 -0
- package/docs/components/meta/date.ts +275 -0
- package/docs/examples/date/basic.vue +73 -0
- package/docs/examples/date/default-value.vue +59 -0
- package/docs/examples/date/format.vue +75 -0
- package/docs/examples/date/range.vue +66 -0
- package/docs/examples/date/types.vue +79 -0
- package/docs/examples/page/log.vue +437 -205
- package/docs/examples/table/editable.vue +1 -0
- package/docs/examples/table-panel/filter.vue +12 -2
- package/docs/examples/table-panel/sub-table-lazy.vue +18 -0
- package/package.json +1 -1
|
@@ -1,207 +1,439 @@
|
|
|
1
|
-
<template>
|
|
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
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
1
|
+
<template>
|
|
2
|
+
<div class="j-block j-user-center-log" style="height: 600px">
|
|
3
|
+
<j-page :noPadding="true" :schema="schema" />
|
|
4
|
+
</div>
|
|
5
|
+
</template>
|
|
6
|
+
<script lang="ts" setup>
|
|
7
|
+
import type { TableColumnCompConfig, ColumnSchemaConfig, LayerParamType } from '@a2simcode/ui'
|
|
8
|
+
|
|
9
|
+
import { ref, h, defineComponent, resolveComponent } from 'vue'
|
|
10
|
+
import { iconLoaded, loadIcon } from '@iconify/vue'
|
|
11
|
+
|
|
12
|
+
const ExecuteResultLayer = defineComponent({
|
|
13
|
+
name: 'ExecuteResultLayer',
|
|
14
|
+
props: {
|
|
15
|
+
text: {
|
|
16
|
+
type: String,
|
|
17
|
+
default: '',
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
setup(props) {
|
|
21
|
+
const JCodeMirror = resolveComponent('j-code-mirror')
|
|
22
|
+
return () =>
|
|
23
|
+
h(JCodeMirror, {
|
|
24
|
+
readOnly: true,
|
|
25
|
+
value: props.text || '',
|
|
26
|
+
})
|
|
27
|
+
},
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
const browsers = [
|
|
31
|
+
{ name: 'Chrome', icon: 'logos:chrome' },
|
|
32
|
+
{ name: 'Firefox', icon: 'logos:firefox' },
|
|
33
|
+
{ name: 'Safari', icon: 'logos:safari' },
|
|
34
|
+
{ name: 'Edge', icon: 'logos:microsoft-edge' },
|
|
35
|
+
]
|
|
36
|
+
|
|
37
|
+
interface ColumnType {
|
|
38
|
+
label: string
|
|
39
|
+
id: string
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const columns: ColumnType[] = [
|
|
43
|
+
{ label: '浏览器', id: 'j_BrowserTag' },
|
|
44
|
+
{
|
|
45
|
+
label: '类型',
|
|
46
|
+
id: 'j_CategoryId',
|
|
47
|
+
},
|
|
48
|
+
{ label: '时间', id: 'j_CreateDate' },
|
|
49
|
+
{ label: '时长(ms)', id: 'j_Times' },
|
|
50
|
+
{ label: '请求接口', id: 'j_Url' },
|
|
51
|
+
{ label: '请求类型', id: 'j_OperateType' },
|
|
52
|
+
{ label: 'IP', id: 'j_IPAddress' },
|
|
53
|
+
{ label: '结果', id: 'j_Result' },
|
|
54
|
+
{ label: '描述', id: 'j_ExecuteResult' },
|
|
55
|
+
]
|
|
56
|
+
|
|
57
|
+
const columnsConfig: Record<string, TableColumnCompConfig> = {
|
|
58
|
+
j_BrowserTag: {
|
|
59
|
+
width: 72,
|
|
60
|
+
type: 'j-icon',
|
|
61
|
+
align: 'center',
|
|
62
|
+
dataType: 'options',
|
|
63
|
+
fieldFormat: (row: Record<string, any>) =>
|
|
64
|
+
browsers.find((b) => b.name === row.j_BrowserTag)?.icon || '',
|
|
65
|
+
options: browsers.map((b) => ({ label: b.name, value: b.name })),
|
|
66
|
+
},
|
|
67
|
+
j_CategoryId: {
|
|
68
|
+
type: 'j-tag',
|
|
69
|
+
width: 100,
|
|
70
|
+
align: 'center',
|
|
71
|
+
dataType: 'options',
|
|
72
|
+
options: [
|
|
73
|
+
{ label: '登录', value: 1, color: '#e8ffea' },
|
|
74
|
+
{ label: '访问', value: 2, color: '#e8f3ff' },
|
|
75
|
+
{ label: '操作', value: 3, color: '#e5f9f8' },
|
|
76
|
+
{ label: '文件下载', value: 5, color: '#fff7e8' },
|
|
77
|
+
{ label: '文件预览', value: 6, color: '#f5f2ff' },
|
|
78
|
+
{ label: '接口请求', value: 7, color: '#f0f5ff' },
|
|
79
|
+
{ label: '接口限流', value: 8, color: '#fffce8' },
|
|
80
|
+
{ label: '接口熔断', value: 9, color: '#fff2e8' },
|
|
81
|
+
{ label: '异常', value: 4, color: '#ffece8' },
|
|
82
|
+
],
|
|
83
|
+
},
|
|
84
|
+
j_CreateDate: {
|
|
85
|
+
width: 168,
|
|
86
|
+
type: 'dateTime',
|
|
87
|
+
},
|
|
88
|
+
j_Times: {
|
|
89
|
+
width: 80,
|
|
90
|
+
align: 'center',
|
|
91
|
+
type: 'number',
|
|
92
|
+
},
|
|
93
|
+
j_Url: {
|
|
94
|
+
width: 200,
|
|
95
|
+
isSearchKeyword: true,
|
|
96
|
+
},
|
|
97
|
+
j_OperateType: {
|
|
98
|
+
width: 96,
|
|
99
|
+
align: 'center',
|
|
100
|
+
type: 'j-tag',
|
|
101
|
+
dataType: 'options',
|
|
102
|
+
options: [
|
|
103
|
+
{ label: 'GET', value: 'GET', color: '#e8f3ff' },
|
|
104
|
+
{ label: 'POST', value: 'POST', color: '#e8ffea' },
|
|
105
|
+
{ label: 'PUT', value: 'PUT', color: '#fff7e8' },
|
|
106
|
+
{ label: 'DELETE', value: 'DELETE', color: '#ffece8' },
|
|
107
|
+
],
|
|
108
|
+
},
|
|
109
|
+
|
|
110
|
+
j_IPAddress: {
|
|
111
|
+
width: 120,
|
|
112
|
+
isSearchKeyword: true,
|
|
113
|
+
},
|
|
114
|
+
j_Result: {
|
|
115
|
+
type: 'j-tag',
|
|
116
|
+
width: 72,
|
|
117
|
+
align: 'center',
|
|
118
|
+
dataType: 'options',
|
|
119
|
+
fieldFormat: (row: Record<string, any>) => (row.j_Result === 1 ? 1 : 2),
|
|
120
|
+
options: [
|
|
121
|
+
{ label: '成功', value: 1, color: '#e8ffea' },
|
|
122
|
+
{ label: '失败', value: 2, color: '#ffece8' },
|
|
123
|
+
],
|
|
124
|
+
},
|
|
125
|
+
j_ExecuteResult: {
|
|
126
|
+
type: 'link',
|
|
127
|
+
width: 60,
|
|
128
|
+
align: 'center',
|
|
129
|
+
frozen: 'right',
|
|
130
|
+
fieldFormat: () => '查看',
|
|
131
|
+
click: ({ row, openLayer }: { row: any; openLayer: (params: LayerParamType) => void }) => {
|
|
132
|
+
openLayer({
|
|
133
|
+
title: '描述',
|
|
134
|
+
name: ExecuteResultLayer,
|
|
135
|
+
config: { text: row?.j_ExecuteResult || '' },
|
|
136
|
+
width: 1000,
|
|
137
|
+
height: 600,
|
|
138
|
+
hasBtns: false,
|
|
139
|
+
})
|
|
140
|
+
},
|
|
141
|
+
},
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
const myColumns: ColumnSchemaConfig[] = []
|
|
145
|
+
columns.forEach((item) => {
|
|
146
|
+
const config = columnsConfig[item.id || ''] || {}
|
|
147
|
+
const schemaItem: ColumnSchemaConfig = {
|
|
148
|
+
id: item.id || '',
|
|
149
|
+
type: config.type || '',
|
|
150
|
+
config: { ...config, label: item.label || '' },
|
|
151
|
+
}
|
|
152
|
+
myColumns.push(schemaItem)
|
|
153
|
+
})
|
|
154
|
+
|
|
155
|
+
// Mock API
|
|
156
|
+
const mockData = Array.from({ length: 100 }).map((_, i) => ({
|
|
157
|
+
j_Id: i + 1,
|
|
158
|
+
j_BrowserTag: browsers[i % browsers.length].name,
|
|
159
|
+
j_CategoryId: (i % 9) + 1,
|
|
160
|
+
j_CreateDate: new Date(Date.now() - Math.floor(Math.random() * 1000000000)).toISOString(),
|
|
161
|
+
j_Times: Math.floor(Math.random() * 1000),
|
|
162
|
+
j_Url: `/api/v1/resource/${i}`,
|
|
163
|
+
j_OperateType: ['GET', 'POST', 'PUT', 'DELETE'][i % 4],
|
|
164
|
+
j_IPAddress: `192.168.1.${i}`,
|
|
165
|
+
j_Result: i % 5 === 0 ? 2 : 1,
|
|
166
|
+
j_ExecuteResult: JSON.stringify({ status: 200, message: 'Success' }),
|
|
167
|
+
}))
|
|
168
|
+
|
|
169
|
+
const api = {
|
|
170
|
+
getMyPage: async (params: any) => {
|
|
171
|
+
console.log(JSON.stringify(params), 'params')
|
|
172
|
+
// Simulate API call
|
|
173
|
+
await new Promise((resolve) => setTimeout(resolve, 300))
|
|
174
|
+
|
|
175
|
+
let result = [...mockData]
|
|
176
|
+
|
|
177
|
+
// Filter
|
|
178
|
+
if (params.filter && params.filter.cond && params.filter.cond.length > 0) {
|
|
179
|
+
const { rel, cond } = params.filter
|
|
180
|
+
const parseDateVal = (s: string) => {
|
|
181
|
+
if (!s) return NaN
|
|
182
|
+
const str = s.includes('T') ? s : s.replace(' ', 'T')
|
|
183
|
+
const d = new Date(str)
|
|
184
|
+
return d.getTime()
|
|
185
|
+
}
|
|
186
|
+
const dayStart = (d: Date) =>
|
|
187
|
+
new Date(d.getFullYear(), d.getMonth(), d.getDate(), 0, 0, 0, 0).getTime()
|
|
188
|
+
const dayEnd = (d: Date) =>
|
|
189
|
+
new Date(d.getFullYear(), d.getMonth(), d.getDate(), 23, 59, 59, 999).getTime()
|
|
190
|
+
const monthStart = (y: number, m: number) => new Date(y, m, 1, 0, 0, 0, 0).getTime()
|
|
191
|
+
const monthEnd = (y: number, m: number) => new Date(y, m + 1, 0, 23, 59, 59, 999).getTime()
|
|
192
|
+
const quarterRange = (y: number, q: number) => {
|
|
193
|
+
const startMonth = (q - 1) * 3
|
|
194
|
+
const start = monthStart(y, startMonth)
|
|
195
|
+
const end = monthEnd(y, startMonth + 2)
|
|
196
|
+
return [start, end] as const
|
|
197
|
+
}
|
|
198
|
+
const weekStartEnd = (d: Date) => {
|
|
199
|
+
const dow = (d.getDay() + 6) % 7
|
|
200
|
+
const startD = new Date(d)
|
|
201
|
+
startD.setDate(d.getDate() - dow)
|
|
202
|
+
const endD = new Date(startD)
|
|
203
|
+
endD.setDate(startD.getDate() + 6)
|
|
204
|
+
return [dayStart(startD), dayEnd(endD)] as const
|
|
205
|
+
}
|
|
206
|
+
const rangeFromFormula = (f: string) => {
|
|
207
|
+
const now = new Date()
|
|
208
|
+
if (f === 'today') return [dayStart(now), dayEnd(now)] as const
|
|
209
|
+
if (f === 'yesterday') {
|
|
210
|
+
const d = new Date(now)
|
|
211
|
+
d.setDate(now.getDate() - 1)
|
|
212
|
+
return [dayStart(d), dayEnd(d)] as const
|
|
213
|
+
}
|
|
214
|
+
if (f === 'tomorrow') {
|
|
215
|
+
const d = new Date(now)
|
|
216
|
+
d.setDate(now.getDate() + 1)
|
|
217
|
+
return [dayStart(d), dayEnd(d)] as const
|
|
218
|
+
}
|
|
219
|
+
if (f === 'last7days') {
|
|
220
|
+
const end = dayEnd(now)
|
|
221
|
+
const d = new Date(now)
|
|
222
|
+
d.setDate(now.getDate() - 6)
|
|
223
|
+
const start = dayStart(d)
|
|
224
|
+
return [start, end] as const
|
|
225
|
+
}
|
|
226
|
+
if (f === 'last30days') {
|
|
227
|
+
const end = dayEnd(now)
|
|
228
|
+
const d = new Date(now)
|
|
229
|
+
d.setDate(now.getDate() - 29)
|
|
230
|
+
const start = dayStart(d)
|
|
231
|
+
return [start, end] as const
|
|
232
|
+
}
|
|
233
|
+
if (f === 'thisWeek') return weekStartEnd(now)
|
|
234
|
+
if (f === 'lastWeek') {
|
|
235
|
+
const d = new Date(now)
|
|
236
|
+
d.setDate(now.getDate() - 7)
|
|
237
|
+
return weekStartEnd(d)
|
|
238
|
+
}
|
|
239
|
+
if (f === 'nextWeek') {
|
|
240
|
+
const d = new Date(now)
|
|
241
|
+
d.setDate(now.getDate() + 7)
|
|
242
|
+
return weekStartEnd(d)
|
|
243
|
+
}
|
|
244
|
+
if (f === 'thisMonth') {
|
|
245
|
+
const y = now.getFullYear()
|
|
246
|
+
const m = now.getMonth()
|
|
247
|
+
return [monthStart(y, m), monthEnd(y, m)] as const
|
|
248
|
+
}
|
|
249
|
+
if (f === 'lastMonth') {
|
|
250
|
+
const d = new Date(now)
|
|
251
|
+
d.setMonth(now.getMonth() - 1)
|
|
252
|
+
const y = d.getFullYear()
|
|
253
|
+
const m = d.getMonth()
|
|
254
|
+
return [monthStart(y, m), monthEnd(y, m)] as const
|
|
165
255
|
}
|
|
256
|
+
if (f === 'nextMonth') {
|
|
257
|
+
const d = new Date(now)
|
|
258
|
+
d.setMonth(now.getMonth() + 1)
|
|
259
|
+
const y = d.getFullYear()
|
|
260
|
+
const m = d.getMonth()
|
|
261
|
+
return [monthStart(y, m), monthEnd(y, m)] as const
|
|
262
|
+
}
|
|
263
|
+
if (f === 'thisQuarter') {
|
|
264
|
+
const y = now.getFullYear()
|
|
265
|
+
const q = Math.floor(now.getMonth() / 3) + 1
|
|
266
|
+
return quarterRange(y, q)
|
|
267
|
+
}
|
|
268
|
+
if (f === 'lastQuarter') {
|
|
269
|
+
let y = now.getFullYear()
|
|
270
|
+
let q = Math.floor(now.getMonth() / 3)
|
|
271
|
+
if (q === 0) {
|
|
272
|
+
q = 4
|
|
273
|
+
y = y - 1
|
|
274
|
+
}
|
|
275
|
+
return quarterRange(y, q)
|
|
276
|
+
}
|
|
277
|
+
if (f === 'nextQuarter') {
|
|
278
|
+
let y = now.getFullYear()
|
|
279
|
+
let q = Math.floor(now.getMonth() / 3) + 2
|
|
280
|
+
if (q === 5) {
|
|
281
|
+
q = 1
|
|
282
|
+
y = y + 1
|
|
283
|
+
}
|
|
284
|
+
return quarterRange(y, q)
|
|
285
|
+
}
|
|
286
|
+
if (f === 'thisYear') {
|
|
287
|
+
const y = now.getFullYear()
|
|
288
|
+
return [
|
|
289
|
+
new Date(y, 0, 1).getTime(),
|
|
290
|
+
new Date(y, 11, 31, 23, 59, 59, 999).getTime(),
|
|
291
|
+
] as const
|
|
292
|
+
}
|
|
293
|
+
if (f === 'lastYear') {
|
|
294
|
+
const y = now.getFullYear() - 1
|
|
295
|
+
return [
|
|
296
|
+
new Date(y, 0, 1).getTime(),
|
|
297
|
+
new Date(y, 11, 31, 23, 59, 59, 999).getTime(),
|
|
298
|
+
] as const
|
|
299
|
+
}
|
|
300
|
+
if (f === 'nextYear') {
|
|
301
|
+
const y = now.getFullYear() + 1
|
|
302
|
+
return [
|
|
303
|
+
new Date(y, 0, 1).getTime(),
|
|
304
|
+
new Date(y, 11, 31, 23, 59, 59, 999).getTime(),
|
|
305
|
+
] as const
|
|
306
|
+
}
|
|
307
|
+
return [NaN, NaN] as const
|
|
308
|
+
}
|
|
309
|
+
result = result.filter((item) => {
|
|
310
|
+
const matches = cond.map((c: any) => {
|
|
311
|
+
const rawVal = item[c.field as keyof typeof item]
|
|
312
|
+
const val = rawVal == null ? '' : String(rawVal)
|
|
313
|
+
const target = c.value == null ? '' : String(c.value)
|
|
314
|
+
|
|
315
|
+
if (c.type === 'dateTime') {
|
|
316
|
+
const ts = parseDateVal(val)
|
|
317
|
+
if (c.method === 'eq') {
|
|
318
|
+
const t = parseDateVal(target)
|
|
319
|
+
return ts === t
|
|
320
|
+
} else if (c.method === 'ne') {
|
|
321
|
+
const t = parseDateVal(target)
|
|
322
|
+
return ts !== t
|
|
323
|
+
} else if (c.method === 'gte') {
|
|
324
|
+
const t = parseDateVal(target)
|
|
325
|
+
return ts >= t
|
|
326
|
+
} else if (c.method === 'lte') {
|
|
327
|
+
const t = parseDateVal(target)
|
|
328
|
+
return ts <= t
|
|
329
|
+
} else if (c.method === 'range') {
|
|
330
|
+
if (!target) return true
|
|
331
|
+
const [s, e] = target.split(',')
|
|
332
|
+
const st = parseDateVal(s)
|
|
333
|
+
const et = parseDateVal(e)
|
|
334
|
+
if (isNaN(st) && isNaN(et)) return true
|
|
335
|
+
if (!isNaN(st) && !isNaN(et)) return ts >= st && ts <= et
|
|
336
|
+
if (!isNaN(st) && isNaN(et)) return ts >= st
|
|
337
|
+
if (isNaN(st) && !isNaN(et)) return ts <= et
|
|
338
|
+
return true
|
|
339
|
+
} else if (c.method === 'formula') {
|
|
340
|
+
const [st, et] = rangeFromFormula(target)
|
|
341
|
+
if (isNaN(st) || isNaN(et)) return true
|
|
342
|
+
return ts >= st && ts <= et
|
|
343
|
+
} else if (c.method === 'not_empty') {
|
|
344
|
+
return val !== '' && val !== 'null' && val !== 'undefined'
|
|
345
|
+
} else if (c.method === 'empty') {
|
|
346
|
+
return val === '' || val === 'null' || val === 'undefined'
|
|
347
|
+
}
|
|
348
|
+
return false
|
|
349
|
+
} else {
|
|
350
|
+
if (c.method === 'eq') {
|
|
351
|
+
return val === target
|
|
352
|
+
} else if (c.method === 'ne') {
|
|
353
|
+
return val !== target
|
|
354
|
+
} else if (c.method === 'like') {
|
|
355
|
+
return val.includes(target)
|
|
356
|
+
} else if (c.method === 'unlike') {
|
|
357
|
+
return !val.includes(target)
|
|
358
|
+
} else if (c.method === 'in') {
|
|
359
|
+
const targetList = target.split(',')
|
|
360
|
+
return targetList.includes(val)
|
|
361
|
+
} else if (c.method === 'nin') {
|
|
362
|
+
const targetList = target.split(',')
|
|
363
|
+
return !targetList.includes(val)
|
|
364
|
+
} else if (c.method === 'not_empty') {
|
|
365
|
+
return val !== '' && val !== 'null' && val !== 'undefined'
|
|
366
|
+
} else if (c.method === 'empty') {
|
|
367
|
+
return val === '' || val === 'null' || val === 'undefined'
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
return false
|
|
371
|
+
})
|
|
372
|
+
|
|
373
|
+
if (rel === 'and') return matches.every((x: boolean) => x)
|
|
374
|
+
if (rel === 'or') return matches.some((x: boolean) => x)
|
|
375
|
+
return true
|
|
376
|
+
})
|
|
166
377
|
}
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
378
|
+
|
|
379
|
+
// Sort
|
|
380
|
+
if (params.pagination && params.pagination.sort) {
|
|
381
|
+
const [field, order] = params.pagination.sort.split(' ')
|
|
382
|
+
result.sort((a, b) => {
|
|
383
|
+
const valA = a[field as keyof typeof a]
|
|
384
|
+
const valB = b[field as keyof typeof b]
|
|
385
|
+
if (valA < valB) return order === 'ASC' ? -1 : 1
|
|
386
|
+
if (valA > valB) return order === 'ASC' ? 1 : -1
|
|
387
|
+
return 0
|
|
388
|
+
})
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
// Pagination
|
|
392
|
+
const page = params.pagination?.page || 1
|
|
393
|
+
const rows = params.pagination?.rows || 20
|
|
394
|
+
const start = (page - 1) * rows
|
|
395
|
+
const end = start + rows
|
|
396
|
+
|
|
397
|
+
return {
|
|
398
|
+
total: result.length,
|
|
399
|
+
rows: result.slice(start, end),
|
|
400
|
+
}
|
|
401
|
+
},
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
const schema = [
|
|
405
|
+
{
|
|
406
|
+
id: 'mainTable',
|
|
407
|
+
type: 'j-table-panel',
|
|
408
|
+
config: {
|
|
409
|
+
columns: myColumns,
|
|
410
|
+
rowKey: 'j_Id',
|
|
411
|
+
sort: 'j_CreateDate DESC',
|
|
412
|
+
isPage: true,
|
|
413
|
+
loadData: async (params: Record<string, any>) => {
|
|
414
|
+
let res = await api.getMyPage(params)
|
|
415
|
+
if (res && res.rows) {
|
|
416
|
+
const iconsToLoad = new Set()
|
|
417
|
+
res.rows.forEach((item: any) => {
|
|
418
|
+
const browser = browsers.find((b) => item.j_BrowserTag && item.j_BrowserTag === b.name)
|
|
419
|
+
if (browser) {
|
|
420
|
+
iconsToLoad.add(browser.icon)
|
|
421
|
+
}
|
|
422
|
+
})
|
|
423
|
+
|
|
424
|
+
await Promise.all(
|
|
425
|
+
[...iconsToLoad].map(async (icon) => {
|
|
426
|
+
if (!iconLoaded(icon as string)) {
|
|
427
|
+
await loadIcon(icon as string)
|
|
428
|
+
}
|
|
429
|
+
})
|
|
430
|
+
)
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
console.log(res, 'res')
|
|
434
|
+
return res
|
|
435
|
+
},
|
|
436
|
+
},
|
|
437
|
+
},
|
|
438
|
+
]
|
|
439
|
+
</script>
|