lw-cdp-ui 1.3.22 → 1.3.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/dist/components/lwTableSelect/index.vue +59 -60
- package/dist/lw-cdp-ui.esm.js +1808 -1795
- package/dist/lw-cdp-ui.umd.js +4 -4
- package/dist/style.css +1 -1
- package/package.json +1 -1
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
:max-height="245"
|
|
28
28
|
:highlight-current-row="!multiple"
|
|
29
29
|
:reserve-selection="true"
|
|
30
|
-
@row-click="
|
|
30
|
+
@row-click="clickRow"
|
|
31
31
|
@select="select"
|
|
32
32
|
@select-all="selectAll">
|
|
33
33
|
<el-table-column v-if="multiple"
|
|
@@ -36,8 +36,7 @@
|
|
|
36
36
|
<el-table-column v-else
|
|
37
37
|
type="index"
|
|
38
38
|
width="45">
|
|
39
|
-
<template
|
|
40
|
-
#default="scope"><span>{{scope.$index+(currentPage - 1) * pageSize + 1}}</span></template>
|
|
39
|
+
<template #default="scope"><span>{{scope.$index+(currentPage - 1) * pageSize + 1}}</span></template>
|
|
41
40
|
</el-table-column>
|
|
42
41
|
<slot></slot>
|
|
43
42
|
</el-table>
|
|
@@ -56,27 +55,27 @@
|
|
|
56
55
|
</template>
|
|
57
56
|
|
|
58
57
|
<script>
|
|
59
|
-
import config from
|
|
58
|
+
import config from './tableSelect'
|
|
60
59
|
|
|
61
60
|
export default {
|
|
62
61
|
name: 'lwTableSelect',
|
|
63
62
|
props: {
|
|
64
63
|
modelValue: null,
|
|
65
|
-
apiObj: {
|
|
66
|
-
params: {
|
|
67
|
-
placeholder: {
|
|
68
|
-
size: {
|
|
69
|
-
clearable: {
|
|
70
|
-
multiple: {
|
|
71
|
-
filterable: {
|
|
72
|
-
collapseTags: {
|
|
73
|
-
collapseTagsTooltip: {
|
|
74
|
-
disabled: {
|
|
75
|
-
tableWidth: {
|
|
76
|
-
mode: {
|
|
77
|
-
valueKey: {
|
|
64
|
+
apiObj: {type: [Object, Function], default: () => {}},
|
|
65
|
+
params: {type: Object, default: () => {}},
|
|
66
|
+
placeholder: {type: String, default: '请选择'},
|
|
67
|
+
size: {type: String, default: 'default'},
|
|
68
|
+
clearable: {type: Boolean, default: false},
|
|
69
|
+
multiple: {type: Boolean, default: false},
|
|
70
|
+
filterable: {type: Boolean, default: false},
|
|
71
|
+
collapseTags: {type: Boolean, default: false},
|
|
72
|
+
collapseTagsTooltip: {type: Boolean, default: false},
|
|
73
|
+
disabled: {type: Boolean, default: false},
|
|
74
|
+
tableWidth: {type: Number, default: 400},
|
|
75
|
+
mode: {type: String, default: 'popover'},
|
|
76
|
+
valueKey: {type: String, default: ''},
|
|
78
77
|
// 定义什么参数就返回什么 value label 为 必须字段
|
|
79
|
-
props: {
|
|
78
|
+
props: {type: Object, default: () => {}}
|
|
80
79
|
},
|
|
81
80
|
data() {
|
|
82
81
|
return {
|
|
@@ -100,9 +99,7 @@ export default {
|
|
|
100
99
|
formData: {}
|
|
101
100
|
}
|
|
102
101
|
},
|
|
103
|
-
computed: {
|
|
104
|
-
|
|
105
|
-
},
|
|
102
|
+
computed: {},
|
|
106
103
|
watch: {
|
|
107
104
|
modelValue: {
|
|
108
105
|
handler(val) {
|
|
@@ -115,7 +112,7 @@ export default {
|
|
|
115
112
|
}
|
|
116
113
|
},
|
|
117
114
|
mounted() {
|
|
118
|
-
this.defaultProps = Object.assign(this.defaultProps, this.props)
|
|
115
|
+
this.defaultProps = Object.assign(this.defaultProps, this.props)
|
|
119
116
|
this.defaultValue = this.modelValue
|
|
120
117
|
},
|
|
121
118
|
methods: {
|
|
@@ -130,7 +127,7 @@ export default {
|
|
|
130
127
|
},
|
|
131
128
|
//获取表格数据
|
|
132
129
|
async getData(pageSize = this.pageSize) {
|
|
133
|
-
this.loading = true
|
|
130
|
+
this.loading = true
|
|
134
131
|
var reqData = {
|
|
135
132
|
[this.defaultProps.page]: this.currentPage - 1,
|
|
136
133
|
[this.defaultProps.pageSize]: pageSize,
|
|
@@ -148,16 +145,18 @@ export default {
|
|
|
148
145
|
}
|
|
149
146
|
|
|
150
147
|
if (this.idExpression) {
|
|
151
|
-
this.formData.expression = this.formData.expression
|
|
148
|
+
this.formData.expression = this.formData.expression
|
|
149
|
+
? `${this.formData.expression} AND ${this.idExpression}`
|
|
150
|
+
: this.idExpression
|
|
152
151
|
}
|
|
153
152
|
|
|
154
153
|
Object.assign(reqData, this.params, this.formData)
|
|
155
154
|
|
|
156
|
-
var res = await this.apiObj(reqData)
|
|
155
|
+
var res = await this.apiObj(reqData)
|
|
157
156
|
var parseData = config.parseData(res)
|
|
158
|
-
this.tableData = parseData.rows
|
|
159
|
-
this.total = parseData.total
|
|
160
|
-
this.loading = false
|
|
157
|
+
this.tableData = parseData.rows
|
|
158
|
+
this.total = parseData.total
|
|
159
|
+
this.loading = false
|
|
161
160
|
//表格默认赋值 10000的时候是回显数据
|
|
162
161
|
if (pageSize != 10000) {
|
|
163
162
|
this.$nextTick(() => {
|
|
@@ -165,12 +164,12 @@ export default {
|
|
|
165
164
|
this.defaultValue.forEach(row => {
|
|
166
165
|
var setrow = this.tableData.filter(item => item[this.defaultProps.value] === row['value'])
|
|
167
166
|
if (setrow.length > 0) {
|
|
168
|
-
this.$refs.table.toggleRowSelection(setrow[0], true)
|
|
167
|
+
this.$refs.table.toggleRowSelection(setrow[0], true)
|
|
169
168
|
}
|
|
170
169
|
})
|
|
171
170
|
} else {
|
|
172
171
|
var setrow = this.tableData.filter(item => item[this.defaultProps.value] === this.defaultValue?.value)
|
|
173
|
-
this.$refs.table.setCurrentRow(setrow[0])
|
|
172
|
+
this.$refs.table.setCurrentRow(setrow[0])
|
|
174
173
|
}
|
|
175
174
|
this.$refs.table.setScrollTop(0)
|
|
176
175
|
})
|
|
@@ -187,7 +186,6 @@ export default {
|
|
|
187
186
|
}
|
|
188
187
|
this.idExpression = ''
|
|
189
188
|
}
|
|
190
|
-
|
|
191
189
|
},
|
|
192
190
|
//插糟表单提交
|
|
193
191
|
formSubmit() {
|
|
@@ -201,24 +199,26 @@ export default {
|
|
|
201
199
|
},
|
|
202
200
|
// 处理选中值
|
|
203
201
|
getCurVlaue(row) {
|
|
204
|
-
const filteredRow = {}
|
|
202
|
+
const filteredRow = {}
|
|
205
203
|
// 遍历 this.defaultProps 中定义的字段并保留对应的值
|
|
206
204
|
Object.entries(this.defaultProps).forEach(([key, propKey]) => {
|
|
207
|
-
|
|
208
205
|
if (row[propKey]) {
|
|
209
206
|
filteredRow[key] = row[propKey]
|
|
210
207
|
}
|
|
211
|
-
|
|
212
|
-
});
|
|
208
|
+
})
|
|
213
209
|
return filteredRow
|
|
214
210
|
},
|
|
215
211
|
//表格勾选事件
|
|
216
212
|
select(rows, row) {
|
|
213
|
+
console.log(rows, row, this.defaultValue)
|
|
217
214
|
var isSelect = rows.length && rows.indexOf(row) !== -1
|
|
218
215
|
if (isSelect) {
|
|
219
216
|
this.defaultValue.push(this.getCurVlaue(row))
|
|
220
217
|
} else {
|
|
221
|
-
this.defaultValue.splice(
|
|
218
|
+
this.defaultValue.splice(
|
|
219
|
+
this.defaultValue.findIndex(item => item['value'] == row[this.defaultProps.value]),
|
|
220
|
+
1
|
|
221
|
+
)
|
|
222
222
|
}
|
|
223
223
|
this.lock()
|
|
224
224
|
},
|
|
@@ -231,14 +231,13 @@ export default {
|
|
|
231
231
|
if (!isHas) {
|
|
232
232
|
this.defaultValue.push(this.getCurVlaue(row))
|
|
233
233
|
}
|
|
234
|
-
|
|
235
234
|
})
|
|
236
235
|
} else {
|
|
237
236
|
this.defaultValue = []
|
|
238
237
|
}
|
|
239
238
|
this.lock()
|
|
240
239
|
},
|
|
241
|
-
|
|
240
|
+
clickRow(row) {
|
|
242
241
|
if (this.multiple) {
|
|
243
242
|
//处理多选点击行
|
|
244
243
|
} else {
|
|
@@ -250,7 +249,7 @@ export default {
|
|
|
250
249
|
//tags删除后回调
|
|
251
250
|
removeTag(tag) {
|
|
252
251
|
var row = this.findRowByKey(tag.value)
|
|
253
|
-
this.$refs.table.toggleRowSelection(row, false)
|
|
252
|
+
this.$refs.table.toggleRowSelection(row, false)
|
|
254
253
|
this.lock()
|
|
255
254
|
},
|
|
256
255
|
//清空后的回调
|
|
@@ -263,38 +262,38 @@ export default {
|
|
|
263
262
|
setTimeout(() => {
|
|
264
263
|
this.isLock = false
|
|
265
264
|
}, 1000)
|
|
266
|
-
this.$emit('update:modelValue',
|
|
267
|
-
this.$emit('change',
|
|
265
|
+
this.$emit('update:modelValue', this.defaultValue)
|
|
266
|
+
this.$emit('change', this.defaultValue)
|
|
268
267
|
},
|
|
269
268
|
// 初始化回显
|
|
270
269
|
initValue(val = this.modelValue) {
|
|
271
|
-
if (!val || this.isLock) return
|
|
270
|
+
if (!val || this.isLock) return // 直接返回,避免执行无意义的逻辑
|
|
272
271
|
|
|
273
|
-
this.defaultProps = {
|
|
272
|
+
this.defaultProps = {...this.defaultProps, ...this.props} // 使用展开运算符简化 Object.assign
|
|
274
273
|
|
|
275
|
-
let list = []
|
|
274
|
+
let list = []
|
|
276
275
|
|
|
277
276
|
if (typeof val === 'string' && val.trim()) {
|
|
278
|
-
list.push(val)
|
|
277
|
+
list.push(val)
|
|
279
278
|
} else if (Array.isArray(val)) {
|
|
280
279
|
list = val
|
|
281
280
|
.map(item => {
|
|
282
|
-
if (typeof item === 'string' && item.trim()) return item
|
|
283
|
-
if (typeof item === 'object' && item) return item[this.valueKey || this.defaultProps.value]
|
|
284
|
-
return null
|
|
281
|
+
if (typeof item === 'string' && item.trim()) return item
|
|
282
|
+
if (typeof item === 'object' && item) return item[this.valueKey || this.defaultProps.value]
|
|
283
|
+
return null
|
|
285
284
|
})
|
|
286
|
-
.filter(Boolean)
|
|
285
|
+
.filter(Boolean) // 过滤掉 null、undefined、空字符串
|
|
287
286
|
} else if (typeof val === 'object' && val) {
|
|
288
|
-
const value = val[this.valueKey || this.defaultProps.value]
|
|
289
|
-
if (value) list.push(value)
|
|
287
|
+
const value = val[this.valueKey || this.defaultProps.value]
|
|
288
|
+
if (value) list.push(value)
|
|
290
289
|
}
|
|
291
290
|
|
|
292
|
-
if (!list.length) return
|
|
291
|
+
if (!list.length) return // 如果最终 list 为空,则不进行后续操作
|
|
293
292
|
|
|
294
|
-
this.listIds = list
|
|
295
|
-
this.idExpression = this.$expression({
|
|
293
|
+
this.listIds = list
|
|
294
|
+
this.idExpression = this.$expression({[`${this.defaultProps.value}_in`]: list})
|
|
296
295
|
|
|
297
|
-
this.getData(10000)
|
|
296
|
+
this.getData(10000)
|
|
298
297
|
},
|
|
299
298
|
// 关键值查询表格数据行
|
|
300
299
|
findRowByKey(value) {
|
|
@@ -302,19 +301,19 @@ export default {
|
|
|
302
301
|
},
|
|
303
302
|
filterMethod(keyword) {
|
|
304
303
|
if (!keyword) {
|
|
305
|
-
this.keyword = null
|
|
306
|
-
return false
|
|
304
|
+
this.keyword = null
|
|
305
|
+
return false
|
|
307
306
|
}
|
|
308
|
-
this.keyword = keyword
|
|
307
|
+
this.keyword = keyword
|
|
309
308
|
this.getData()
|
|
310
309
|
},
|
|
311
310
|
// 触发select隐藏
|
|
312
311
|
blur() {
|
|
313
|
-
this.$refs.select.blur()
|
|
312
|
+
this.$refs.select.blur()
|
|
314
313
|
},
|
|
315
314
|
// 触发select显示
|
|
316
315
|
focus() {
|
|
317
|
-
this.$refs.select.focus()
|
|
316
|
+
this.$refs.select.focus()
|
|
318
317
|
}
|
|
319
318
|
}
|
|
320
319
|
}
|