n20-common-lib 3.0.22 → 3.0.23
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/package.json +4 -3
- package/src/assets/css/drag-list.scss +22 -14
- package/src/assets/css/normalize.scss +6 -0
- package/src/assets/css/show-column.scss +72 -14
- package/src/assets/css/table copy.scss +234 -0
- package/src/assets/css/table.scss +159 -13
- package/src/assets/realUrl.js +2 -1
- package/src/components/AdvancedFilter/index.vue +1 -1
- package/src/components/ApprovalButtons/showOtherAttrNew.vue +1 -1
- package/src/components/ApprovalRecord/index.vue +5 -5
- package/src/components/DragList/index.vue +33 -12
- package/src/components/Empty/img/searchNoData.png +0 -0
- package/src/components/HandlingAdvice/index.vue +1 -0
- package/src/components/ShowColumn/index copy.vue +18 -33
- package/src/components/ShowColumn/index.vue +244 -59
- package/src/components/TablePro/index copy.vue +462 -0
- package/src/components/TablePro/index.js +9 -2
- package/src/components/TablePro/index.vue +542 -28
- package/src/components/TableSetSize/index copy.vue +69 -0
- package/src/components/TableSetSize/index.vue +10 -13
- package/src/plugins/Print/print-js/src/js/print.js +0 -6
- package/theme/blue.css +3 -0
- package/theme/cctcRed.css +3 -0
- package/theme/fonts/SIMSUN.5e0c362c.ttf +0 -0
- package/theme/fonts/element-icons.535877f5.woff +0 -0
- package/theme/fonts/element-icons.732389de.ttf +0 -0
- package/theme/fonts/iconfont.09d221ee.woff +0 -0
- package/theme/fonts/iconfont.1c4bfacc.ttf +0 -0
- package/theme/fonts/iconfont.a6f34dc7.woff2 +0 -0
- package/theme/fonts/iconfont.f4c32765.ttf +0 -0
- package/theme/green.css +3 -0
- package/theme/lightBlue.css +3 -0
- package/theme/mapleLeafRed.css +3 -0
- package/theme/orange.css +3 -0
- package/theme/purple.css +3 -0
- package/theme/red.css +3 -0
- package/theme/yellow.css +3 -0
- package/src/components/ShowColumn/index copy 2.vue +0 -545
|
@@ -1,545 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<dialog-wrap
|
|
3
|
-
ref="dialog"
|
|
4
|
-
v-drag
|
|
5
|
-
class="p-t-0"
|
|
6
|
-
v-bind="$attrs"
|
|
7
|
-
:visible.sync="visible"
|
|
8
|
-
:title="title"
|
|
9
|
-
:width="width"
|
|
10
|
-
:close-on-click-modal="false"
|
|
11
|
-
@open="popOpen"
|
|
12
|
-
>
|
|
13
|
-
<div class="dialog-view">
|
|
14
|
-
<div class="flex-box">
|
|
15
|
-
<div class="left-c flex-column p-t-m bd-r">
|
|
16
|
-
<div class="flex-box flex-v p-r m-b">
|
|
17
|
-
<span>{{ header }}</span>
|
|
18
|
-
<span class="m-l-m color-999">
|
|
19
|
-
{{ '已选' | $lc }}
|
|
20
|
-
<span class="color-main">{{ dragList.length }}</span>
|
|
21
|
-
</span>
|
|
22
|
-
<el-link :underline="false" type="primary" class="m-l-auto" @click="setAll">{{
|
|
23
|
-
setState ? $lc('全部清空') : $lc('全部选中')
|
|
24
|
-
}}</el-link>
|
|
25
|
-
</div>
|
|
26
|
-
<div class="flex-item p-r" style="height: 50%; overflow: auto">
|
|
27
|
-
<el-checkbox-group :value="dragListN.map((d) => d[labelKey])">
|
|
28
|
-
<template v-if="!columnsGroups">
|
|
29
|
-
<el-checkbox
|
|
30
|
-
v-for="(column, i) in columnsAs"
|
|
31
|
-
:key="i"
|
|
32
|
-
v-hover-tooltip="column[labelKey]"
|
|
33
|
-
:label="column[labelKey]"
|
|
34
|
-
:disabled="column.checked"
|
|
35
|
-
class="m-t"
|
|
36
|
-
@change="(val) => checkChange(val, column)"
|
|
37
|
-
>{{ column[labelKey] }}</el-checkbox
|
|
38
|
-
>
|
|
39
|
-
</template>
|
|
40
|
-
<template v-else>
|
|
41
|
-
<div v-for="gp in columnsGroups" :key="gp.groupId" class="m-b">
|
|
42
|
-
<div class="f-s-b font-w600">{{ gp.groupName }}</div>
|
|
43
|
-
<template v-for="(column, i) in columnsAs">
|
|
44
|
-
<el-checkbox
|
|
45
|
-
v-if="column.groupId === gp.groupId"
|
|
46
|
-
:key="i"
|
|
47
|
-
v-hover-tooltip="column[labelKey]"
|
|
48
|
-
:label="column[labelKey]"
|
|
49
|
-
:disabled="column.checked"
|
|
50
|
-
class="m-t"
|
|
51
|
-
@change="(val) => checkChange(val, column)"
|
|
52
|
-
>{{ column[labelKey] }}</el-checkbox
|
|
53
|
-
>
|
|
54
|
-
</template>
|
|
55
|
-
</div>
|
|
56
|
-
</template>
|
|
57
|
-
</el-checkbox-group>
|
|
58
|
-
</div>
|
|
59
|
-
</div>
|
|
60
|
-
<div v-if="!hasPX" class="right-c flex-column p-t-m">
|
|
61
|
-
<div class="m-b">
|
|
62
|
-
{{ '当前选定项' | $lc }}
|
|
63
|
-
<el-link type="primary" style="visibility: hidden">{{ '当前选定项' | $lc }}</el-link>
|
|
64
|
-
</div>
|
|
65
|
-
<div class="flex-1 overflow-y">
|
|
66
|
-
<drag-list :list="dragList" :label-key="labelKey" :in-show-column="true" />
|
|
67
|
-
</div>
|
|
68
|
-
</div>
|
|
69
|
-
<div v-else class="right-tree flex-column p-t-m">
|
|
70
|
-
<div class="m-b flex-box flex-lr flex-v">
|
|
71
|
-
{{ '当前选定项' | $lc }}
|
|
72
|
-
<el-link class="m-r-s" :underline="false" icon="n20-icon-xinzeng" @click="add">{{
|
|
73
|
-
'新增字段' | $lc
|
|
74
|
-
}}</el-link>
|
|
75
|
-
</div>
|
|
76
|
-
<el-tree
|
|
77
|
-
ref="menu-tree"
|
|
78
|
-
class="menu-tree"
|
|
79
|
-
:data="dragList"
|
|
80
|
-
:props="{
|
|
81
|
-
children: 'children',
|
|
82
|
-
label: 'label'
|
|
83
|
-
}"
|
|
84
|
-
node-key="prop"
|
|
85
|
-
draggable
|
|
86
|
-
style="width: 200px"
|
|
87
|
-
:allow-drop="allowDrop"
|
|
88
|
-
>
|
|
89
|
-
<span slot-scope="{ node, data }" class="menu-item flex-item flex-box flex-lr flex-v">
|
|
90
|
-
<span>
|
|
91
|
-
<i class="n20-drag-icon n20-icon-tuodong"></i>
|
|
92
|
-
<span
|
|
93
|
-
:class="data.isNew ? 'color-success' : 'color-primary'"
|
|
94
|
-
class="text-ellipsis pointer"
|
|
95
|
-
@click="clickItem(data)"
|
|
96
|
-
>{{ data.label }}</span
|
|
97
|
-
>
|
|
98
|
-
</span>
|
|
99
|
-
<el-link
|
|
100
|
-
class="n20-icon-shanchu"
|
|
101
|
-
:underline="false"
|
|
102
|
-
:disabled="data.checked"
|
|
103
|
-
@click.stop="() => removeMenu(node, data)"
|
|
104
|
-
/>
|
|
105
|
-
</span>
|
|
106
|
-
</el-tree>
|
|
107
|
-
</div>
|
|
108
|
-
</div>
|
|
109
|
-
</div>
|
|
110
|
-
<dialogWrap
|
|
111
|
-
v-drag
|
|
112
|
-
:visible.sync="configVisible"
|
|
113
|
-
:title="'表头设置' | $lc"
|
|
114
|
-
width="350px"
|
|
115
|
-
:close-on-click-modal="false"
|
|
116
|
-
>
|
|
117
|
-
<el-form :model="configModel">
|
|
118
|
-
<el-form-item>
|
|
119
|
-
{{ configModel.label }}
|
|
120
|
-
</el-form-item>
|
|
121
|
-
<el-form-item
|
|
122
|
-
:label="'表头宽度' | $lc"
|
|
123
|
-
:rules="[
|
|
124
|
-
{
|
|
125
|
-
type: 'number',
|
|
126
|
-
trigger: ['change', 'blur'],
|
|
127
|
-
validator: validator
|
|
128
|
-
}
|
|
129
|
-
]"
|
|
130
|
-
prop="width"
|
|
131
|
-
>
|
|
132
|
-
<el-input v-model="configModel.width" class="w-224" />
|
|
133
|
-
</el-form-item>
|
|
134
|
-
<el-form-item :label="'是否折行' | $lc">
|
|
135
|
-
<el-radio-group v-model="configModel.wrap">
|
|
136
|
-
<el-radio :label="true">{{ $lc('是') }}</el-radio>
|
|
137
|
-
<el-radio :label="false">{{ $lc('否') }}</el-radio>
|
|
138
|
-
</el-radio-group>
|
|
139
|
-
</el-form-item>
|
|
140
|
-
<el-form-item :label="'是否加粗' | $lc">
|
|
141
|
-
<el-radio-group v-model="configModel.bold">
|
|
142
|
-
<el-radio :label="true">{{ $lc('是') }}</el-radio>
|
|
143
|
-
<el-radio :label="false">{{ $lc('否') }}</el-radio>
|
|
144
|
-
</el-radio-group>
|
|
145
|
-
</el-form-item>
|
|
146
|
-
<el-form-item :label="'对齐方式' | $lc">
|
|
147
|
-
<el-radio-group v-model="configModel.align">
|
|
148
|
-
<el-radio :label="'right'">{{ $lc('右对齐') }}</el-radio>
|
|
149
|
-
<el-radio :label="'left'">{{ $lc('左对齐') }}</el-radio>
|
|
150
|
-
<el-radio :label="'center'">{{ $lc('居中对齐') }}</el-radio>
|
|
151
|
-
</el-radio-group>
|
|
152
|
-
</el-form-item>
|
|
153
|
-
</el-form>
|
|
154
|
-
<div slot="footer">
|
|
155
|
-
<el-button type="primary" @click="configSave">{{ '确定' | $lc }}</el-button>
|
|
156
|
-
</div>
|
|
157
|
-
</dialogWrap>
|
|
158
|
-
<dialogWrap v-drag :visible.sync="configVisibleN" :title="'新增' | $lc" width="350px" :close-on-click-modal="false">
|
|
159
|
-
<el-form :model="configModelN">
|
|
160
|
-
<el-form-item :label="'名称' | $lc" required>
|
|
161
|
-
<el-input v-model="configModelN.label" class="input-w" :placeholder="'请输入' | $lc" />
|
|
162
|
-
</el-form-item>
|
|
163
|
-
</el-form>
|
|
164
|
-
<div slot="footer">
|
|
165
|
-
<el-button type="primary" @click="configSaveN">{{ '确定' | $lc }}</el-button>
|
|
166
|
-
</div>
|
|
167
|
-
</dialogWrap>
|
|
168
|
-
<div slot="footer" class="text-c">
|
|
169
|
-
<el-button type="primary" @click="setChange">{{ '确定' | $lc }}</el-button>
|
|
170
|
-
<el-button plain @click="reset">{{ '恢复默认' | $lc }}</el-button>
|
|
171
|
-
</div>
|
|
172
|
-
</dialog-wrap>
|
|
173
|
-
</template>
|
|
174
|
-
|
|
175
|
-
<script>
|
|
176
|
-
import axios from '../../utils/axios'
|
|
177
|
-
import { $lc } from '../../utils/i18n/index'
|
|
178
|
-
|
|
179
|
-
import { Message } from 'element-ui'
|
|
180
|
-
import forEachs from '../../utils/forEachs'
|
|
181
|
-
import dialogWrap from '../Dialog/index.vue'
|
|
182
|
-
import dragList from '../DragList/index.vue'
|
|
183
|
-
export default {
|
|
184
|
-
name: 'ShowColumn',
|
|
185
|
-
components: { dialogWrap, dragList },
|
|
186
|
-
inheritAttrs: false,
|
|
187
|
-
props: {
|
|
188
|
-
dialogVisible: {
|
|
189
|
-
type: Boolean,
|
|
190
|
-
default: false
|
|
191
|
-
},
|
|
192
|
-
columns: {
|
|
193
|
-
type: Array,
|
|
194
|
-
default: () => []
|
|
195
|
-
},
|
|
196
|
-
columnsGroups: {
|
|
197
|
-
type: Array,
|
|
198
|
-
default: undefined
|
|
199
|
-
},
|
|
200
|
-
checkColumns: {
|
|
201
|
-
type: Array,
|
|
202
|
-
default: () => []
|
|
203
|
-
},
|
|
204
|
-
isExport: {
|
|
205
|
-
type: Boolean,
|
|
206
|
-
default: false
|
|
207
|
-
},
|
|
208
|
-
isFilter: {
|
|
209
|
-
type: Boolean,
|
|
210
|
-
default: false
|
|
211
|
-
},
|
|
212
|
-
labelKey: {
|
|
213
|
-
type: String,
|
|
214
|
-
default: 'label'
|
|
215
|
-
},
|
|
216
|
-
pageId: {
|
|
217
|
-
type: String,
|
|
218
|
-
default: undefined
|
|
219
|
-
},
|
|
220
|
-
autoSave: {
|
|
221
|
-
type: Boolean,
|
|
222
|
-
default: false
|
|
223
|
-
},
|
|
224
|
-
width: {
|
|
225
|
-
type: String,
|
|
226
|
-
default: '1000px'
|
|
227
|
-
},
|
|
228
|
-
hasPX: {
|
|
229
|
-
type: Boolean,
|
|
230
|
-
default: false
|
|
231
|
-
}
|
|
232
|
-
},
|
|
233
|
-
data() {
|
|
234
|
-
return {
|
|
235
|
-
dragList: [],
|
|
236
|
-
configVisible: false,
|
|
237
|
-
enabled: false,
|
|
238
|
-
configModel: {
|
|
239
|
-
wrap: false,
|
|
240
|
-
bold: false,
|
|
241
|
-
align: 'center'
|
|
242
|
-
},
|
|
243
|
-
configModelN: {
|
|
244
|
-
label: '',
|
|
245
|
-
prop: '',
|
|
246
|
-
width: 120,
|
|
247
|
-
isNew: true,
|
|
248
|
-
children: []
|
|
249
|
-
},
|
|
250
|
-
userNo: sessionStorage.getItem('userNo'),
|
|
251
|
-
configVisibleN: false,
|
|
252
|
-
dragListN: []
|
|
253
|
-
}
|
|
254
|
-
},
|
|
255
|
-
computed: {
|
|
256
|
-
title() {
|
|
257
|
-
if (this.isExport) {
|
|
258
|
-
return $lc('导出')
|
|
259
|
-
} else if (this.isFilter) {
|
|
260
|
-
return $lc('筛选')
|
|
261
|
-
} else {
|
|
262
|
-
return $lc('设置显示列')
|
|
263
|
-
}
|
|
264
|
-
},
|
|
265
|
-
header() {
|
|
266
|
-
if (this.isExport) {
|
|
267
|
-
return $lc('导出')
|
|
268
|
-
} else if (this.isFilter) {
|
|
269
|
-
return $lc('筛选')
|
|
270
|
-
} else {
|
|
271
|
-
return $lc('显示列')
|
|
272
|
-
}
|
|
273
|
-
},
|
|
274
|
-
visible: {
|
|
275
|
-
get() {
|
|
276
|
-
return this.dialogVisible
|
|
277
|
-
},
|
|
278
|
-
set(val) {
|
|
279
|
-
this.$emit('update:dialogVisible', val)
|
|
280
|
-
}
|
|
281
|
-
},
|
|
282
|
-
setState() {
|
|
283
|
-
const columnsAs = []
|
|
284
|
-
forEachs(this.columnsAs, (item) => {
|
|
285
|
-
columnsAs.push(item)
|
|
286
|
-
})
|
|
287
|
-
return columnsAs.length && columnsAs.length === this.dragListN.length
|
|
288
|
-
// return this.columnsAs.length && this.columnsAs.length === this.dragListN.length
|
|
289
|
-
},
|
|
290
|
-
columnsAs: {
|
|
291
|
-
get() {
|
|
292
|
-
return this.columns.filter((col) => !col.static)
|
|
293
|
-
},
|
|
294
|
-
set(val) {
|
|
295
|
-
return val
|
|
296
|
-
}
|
|
297
|
-
},
|
|
298
|
-
columnsN() {
|
|
299
|
-
return this.columns || []
|
|
300
|
-
}
|
|
301
|
-
},
|
|
302
|
-
watch: {
|
|
303
|
-
dragList: {
|
|
304
|
-
handler() {
|
|
305
|
-
let arr = []
|
|
306
|
-
forEachs(this.dragList, (item) => {
|
|
307
|
-
arr.push(item)
|
|
308
|
-
})
|
|
309
|
-
this.dragListN = arr
|
|
310
|
-
/* const newArr = arr.filter((item) => {
|
|
311
|
-
return item.isNew
|
|
312
|
-
})
|
|
313
|
-
newArr.forEach((item) => {
|
|
314
|
-
const index = this.columns.findIndex((col) => col.prop === item.prop || col.label === item.label)
|
|
315
|
-
if (index === -1) {
|
|
316
|
-
this.columns.push(item)
|
|
317
|
-
}
|
|
318
|
-
}) */
|
|
319
|
-
},
|
|
320
|
-
immediate: true,
|
|
321
|
-
deep: true
|
|
322
|
-
}
|
|
323
|
-
},
|
|
324
|
-
methods: {
|
|
325
|
-
validator(rule, value, callback) {
|
|
326
|
-
if (value) {
|
|
327
|
-
if (value > 300) {
|
|
328
|
-
return callback(new Error($lc('输入最大宽度不能大于300')))
|
|
329
|
-
} else if (!/^[1-9]\d*$/.test(value)) {
|
|
330
|
-
return callback(new Error($lc('表头宽度只能输入正整数')))
|
|
331
|
-
}
|
|
332
|
-
}
|
|
333
|
-
callback()
|
|
334
|
-
},
|
|
335
|
-
add() {
|
|
336
|
-
this.configVisibleN = true
|
|
337
|
-
this.configModelN.prop = `prop${Date.now()}`
|
|
338
|
-
},
|
|
339
|
-
configSaveN() {
|
|
340
|
-
if (!this.configModelN.label) {
|
|
341
|
-
return this.$message.warning($lc('请填写名称'))
|
|
342
|
-
}
|
|
343
|
-
const hasLabel = this.dragListN.find((item) => {
|
|
344
|
-
return item.label === this.configModelN.label
|
|
345
|
-
})
|
|
346
|
-
if (hasLabel) {
|
|
347
|
-
return this.$message.warning($lc('已有重名字段,请修改'))
|
|
348
|
-
}
|
|
349
|
-
this.dragList.unshift(this.configModelN)
|
|
350
|
-
// this.columns = [this.configModelN, ...this.columns]
|
|
351
|
-
this.$message.success($lc('添加成功'))
|
|
352
|
-
this.configVisibleN = false
|
|
353
|
-
this.configModelN = {
|
|
354
|
-
label: '',
|
|
355
|
-
prop: '',
|
|
356
|
-
width: 120,
|
|
357
|
-
isNew: true,
|
|
358
|
-
children: []
|
|
359
|
-
}
|
|
360
|
-
},
|
|
361
|
-
removeMenu(node, data) {
|
|
362
|
-
const parent = node.parent
|
|
363
|
-
const children = parent.data.children || parent.data
|
|
364
|
-
const index = children.findIndex((d) => d.prop === data.prop)
|
|
365
|
-
children.splice(index, 1)
|
|
366
|
-
},
|
|
367
|
-
allowDrop(draggingNode, dropNode, type) {
|
|
368
|
-
if (type === 'inner' && draggingNode.data.isNew) {
|
|
369
|
-
return !(draggingNode.level <= dropNode.level)
|
|
370
|
-
} else if (type === 'inner' && !draggingNode.data.isNew) {
|
|
371
|
-
return !(draggingNode.level <= dropNode.level && !dropNode.data.isNew)
|
|
372
|
-
} else {
|
|
373
|
-
return true
|
|
374
|
-
}
|
|
375
|
-
},
|
|
376
|
-
clickItem(item) {
|
|
377
|
-
this.configModel = item
|
|
378
|
-
this.configVisible = true
|
|
379
|
-
},
|
|
380
|
-
configSave() {
|
|
381
|
-
this.configVisible = false
|
|
382
|
-
},
|
|
383
|
-
popOpen() {
|
|
384
|
-
this.dragList = this.checkColumns.filter((col) => !col.static)
|
|
385
|
-
},
|
|
386
|
-
setAll() {
|
|
387
|
-
if (this.setState) {
|
|
388
|
-
this.dragList = this.dragList.filter((c) => c.checked)
|
|
389
|
-
} else {
|
|
390
|
-
this.dragList = [...this.columnsAs]
|
|
391
|
-
}
|
|
392
|
-
},
|
|
393
|
-
checkChange(val, column) {
|
|
394
|
-
if (val === false) {
|
|
395
|
-
let index = this.dragList.findIndex((d) => d[this.labelKey] === column[this.labelKey])
|
|
396
|
-
index !== -1 && this.dragList.splice(index, 1)
|
|
397
|
-
} else {
|
|
398
|
-
let index = this.dragListN.findIndex((d) => d[this.labelKey] === column[this.labelKey])
|
|
399
|
-
if (index !== -1) {
|
|
400
|
-
Message.warning($lc(`子级请在右侧删除!`))
|
|
401
|
-
return false
|
|
402
|
-
}
|
|
403
|
-
this.dragList.push(column)
|
|
404
|
-
}
|
|
405
|
-
},
|
|
406
|
-
reset() {
|
|
407
|
-
let dragList = this.columns.filter((col) => col.isDefault)
|
|
408
|
-
this.dragList = dragList.length ? dragList : this.checkColumns.filter((col) => !col.static)
|
|
409
|
-
},
|
|
410
|
-
setChange() {
|
|
411
|
-
if (this.dragList.length < 1) {
|
|
412
|
-
this.$message.error(
|
|
413
|
-
`${$lc(`至少设置`)}${
|
|
414
|
-
this.isExport ? $lc('一列导出数据') : this.isFilter ? $lc('一个筛选条件') : $lc('一列显示列')
|
|
415
|
-
}!`
|
|
416
|
-
)
|
|
417
|
-
return
|
|
418
|
-
}
|
|
419
|
-
|
|
420
|
-
let list = []
|
|
421
|
-
let preCols = this.columns.filter((col) => col.static === 'pre')
|
|
422
|
-
let nextCols = this.columns.filter((col) => col.static === 'next')
|
|
423
|
-
list.push(...preCols, ...this.dragList, ...nextCols)
|
|
424
|
-
// 新增校验
|
|
425
|
-
if (!this.isExport) {
|
|
426
|
-
let state = list.findIndex((c) => c.isNew && c.children && c.children.length === 0)
|
|
427
|
-
if (state !== -1) {
|
|
428
|
-
Message.warning($lc(`新增字段必须包含子级!`))
|
|
429
|
-
return false
|
|
430
|
-
}
|
|
431
|
-
}
|
|
432
|
-
// 自动保存设置的显示列
|
|
433
|
-
this.userNo = sessionStorage.getItem('userNo')
|
|
434
|
-
!this.isExport && this.autoSave && this.saveColumns(list)
|
|
435
|
-
|
|
436
|
-
this.$emit('setColumns', list)
|
|
437
|
-
if (this.isExport) {
|
|
438
|
-
this.visible = false
|
|
439
|
-
}
|
|
440
|
-
},
|
|
441
|
-
saveColumns(list) {
|
|
442
|
-
let columns = saveTransform(list, this.labelKey, this.isFilter)
|
|
443
|
-
axios.post(
|
|
444
|
-
'/bems/prod_1.0/user/pageHabit',
|
|
445
|
-
{
|
|
446
|
-
userNo: this.userNo,
|
|
447
|
-
pageId: this.pageId,
|
|
448
|
-
showStructure: JSON.stringify(columns)
|
|
449
|
-
},
|
|
450
|
-
{ loading: false }
|
|
451
|
-
)
|
|
452
|
-
this.visible = false
|
|
453
|
-
},
|
|
454
|
-
getColumns(pageId) {
|
|
455
|
-
return getColumns(pageId || this.pageId, this.userNo, this.columnsN, this.labelKey)
|
|
456
|
-
}
|
|
457
|
-
}
|
|
458
|
-
}
|
|
459
|
-
|
|
460
|
-
function saveTransform(list, labelKey, isFilter) {
|
|
461
|
-
let listN = []
|
|
462
|
-
if (!isFilter) {
|
|
463
|
-
list.forEach((c) => {
|
|
464
|
-
if (c.prop && !c.children && !c.isNew && !c.width & !c.isNew) {
|
|
465
|
-
listN.push({ _colKey: 'prop', _colVal: c.prop })
|
|
466
|
-
} else if (c.type && ['selection', 'index', 'expand'].includes(c.type)) {
|
|
467
|
-
listN.push({ _colKey: 'type', _colVal: c.type })
|
|
468
|
-
} else {
|
|
469
|
-
listN.push(c)
|
|
470
|
-
}
|
|
471
|
-
})
|
|
472
|
-
} else {
|
|
473
|
-
list.forEach((c) => {
|
|
474
|
-
if (c.value) {
|
|
475
|
-
listN.push({ _colKey: 'value', _colVal: c.value })
|
|
476
|
-
} else if (c.startValue) {
|
|
477
|
-
listN.push({ _colKey: 'startValue', _colVal: c.startValue })
|
|
478
|
-
} else if (c.startDate) {
|
|
479
|
-
listN.push({ _colKey: 'startDate', _colVal: c.startDate })
|
|
480
|
-
} else if (c.slotName) {
|
|
481
|
-
listN.push({ _colKey: 'slotName', _colVal: c.slotName })
|
|
482
|
-
} else {
|
|
483
|
-
listN.push(c)
|
|
484
|
-
}
|
|
485
|
-
})
|
|
486
|
-
}
|
|
487
|
-
return listN
|
|
488
|
-
}
|
|
489
|
-
|
|
490
|
-
function getTransform(list, columnsT, labelKey = 'label') {
|
|
491
|
-
let columns = []
|
|
492
|
-
list.forEach((d) => {
|
|
493
|
-
// 如果list中的每一项是字符串
|
|
494
|
-
if (typeof d === 'string') {
|
|
495
|
-
// 从columnsT中找到label等于d的项
|
|
496
|
-
let column = columnsT.find((c) => c[labelKey] === d)
|
|
497
|
-
// 如果找到,则将其添加到columns中
|
|
498
|
-
column && columns.push(column)
|
|
499
|
-
// 如果list中的每一项是对象
|
|
500
|
-
} else if (typeof d === 'object') {
|
|
501
|
-
// 如果d中有_colKey属性
|
|
502
|
-
if (d._colKey) {
|
|
503
|
-
// 从columnsT中找到d._colKey等于d._colVal的项
|
|
504
|
-
let column = columnsT.find((c) => c[d._colKey] === d._colVal)
|
|
505
|
-
// 如果找到,则将其添加到columns中
|
|
506
|
-
column && columns.push(column)
|
|
507
|
-
// 如果d中没有_colKey属性
|
|
508
|
-
} else {
|
|
509
|
-
// 将d添加到columns中
|
|
510
|
-
columns.push(d)
|
|
511
|
-
}
|
|
512
|
-
}
|
|
513
|
-
})
|
|
514
|
-
// 返回columns
|
|
515
|
-
return columns
|
|
516
|
-
}
|
|
517
|
-
|
|
518
|
-
// 这段代码在筛选组件中复用
|
|
519
|
-
export function getColumns(pageId, userNo, columnsT, labelKey = 'label') {
|
|
520
|
-
return new Promise((resolve, reject) => {
|
|
521
|
-
axios
|
|
522
|
-
.post(
|
|
523
|
-
'/bems/prod_1.0/user/pageHabit/list',
|
|
524
|
-
{
|
|
525
|
-
userNo: userNo,
|
|
526
|
-
pageId: pageId
|
|
527
|
-
},
|
|
528
|
-
{ loading: false }
|
|
529
|
-
)
|
|
530
|
-
.then(({ data }) => {
|
|
531
|
-
if (data) {
|
|
532
|
-
let _data = JSON.parse(data)
|
|
533
|
-
if (_data && _data.length > 0) {
|
|
534
|
-
let columns = getTransform(_data, columnsT, labelKey)
|
|
535
|
-
return resolve(columns)
|
|
536
|
-
}
|
|
537
|
-
}
|
|
538
|
-
return resolve(null)
|
|
539
|
-
})
|
|
540
|
-
.catch((err) => {
|
|
541
|
-
reject(err)
|
|
542
|
-
})
|
|
543
|
-
})
|
|
544
|
-
}
|
|
545
|
-
</script>
|