1
1
<template >
2
2
<div >
3
3
<a-input-group compact >
4
- <a-input read-only style =" width : calc (100% - 92px );" class =" lov-data"
5
- v-if =" !multiple" :value =" selectValue" />
6
- <a-select read-only style =" width : calc (100% - 92px );" class =" lov-data" mode =" tags" v-if =" multiple"
7
- :value =" selectValue" :open =" false" @deselect =" multipleDeselect" />
4
+ <a-spin :spinning =" loading" size =" small" >
5
+ <a-input read-only style =" width : calc (100% - 92px );" class =" lov-data"
6
+ v-if =" !multiple" :value =" selectValue" />
7
+ <a-select read-only style =" width : calc (100% - 92px );" class =" lov-data" mode =" tags" v-if =" multiple"
8
+ :value =" selectValue" :open =" false" @deselect =" multipleDeselect" />
8
9
9
- <a-button :disabled =" disabled" title =" 单击以选择数据"
10
- @click =" showModal" >
11
- <a-icon type =" select" />
12
- </a-button >
13
- <a-button :disabled =" disabled" title =" 单击以清除选中内容" @click =" cleanAll" >
14
- <a-icon style =" color : red ;" type =" close-circle" />
15
- </a-button >
10
+ <a-button :disabled =" disabled" title =" 单击以选择数据"
11
+ @click =" showModal" >
12
+ <a-icon type =" select" />
13
+ </a-button >
14
+ <a-button :disabled =" disabled" title =" 单击以清除选中内容" @click =" cleanAll" >
15
+ <a-icon style =" color : red ;" type =" close-circle" />
16
+ </a-button >
17
+ </a-spin >
16
18
</a-input-group >
17
19
18
20
<a-modal class =" lov-model" width =" 800px" @cancel =" cancel" @ok =" selectData" :visible =" visible"
19
21
:confirmLoading =" loading"
20
22
:footer =" ret?undefined:null" :bodyStyle =" {paddingBottom:'0'}" :closable =" title.length>0" :title =" title" >
21
- <div v-if =" search" class =" table-page-search-wrapper" style =" text-align : left " >
22
- <a-form layout =" inline" >
23
- <a-row :gutter =" 12" >
24
- <a-col :span =" 6" v-for =" item in searchList" :key =" item.id" >
25
- <a-form-item :label =" item.label" >
26
- <a-input v-if =" item.tag==='INPUT_TEXT'" v-model =" queryParam[item.field]"
27
- :placeholder =" item.placeholder" />
28
- <a-input-number style =" width : 100% " v-if =" item.tag==='INPUT_NUMBER'" v-model =" queryParam[item.field]"
29
- :placeholder =" item.placeholder"
30
- :min =" item.min" :max =" item.max" />
31
- <a-select allowClear v-if =" item.tag==='SELECT'" v-model =" queryParam[item.field]"
32
- :placeholder =" item.placeholder"
33
- :options =" item.options" />
34
- <dict-select v-if =" item.tag==='DICT_SELECT'" :placeholder =" item.placeholder" :dict-code =" item.dictCode"
35
- v-model =" queryParam[item.field]" />
36
- </a-form-item >
37
- </a-col >
38
- </a-row >
39
- </a-form >
40
- </div >
41
23
42
- <!-- 搜索控制按钮 -->
43
- <div v-if =" search" class =" table-operator" >
44
- <a-button @click =" reloadTable" type =" primary" >查询</a-button >
45
- <a-button @click =" resetSearchForm" style =" margin-left : 8px " >重置</a-button >
46
- </div >
24
+ <a-spin :spinning =" loading" >
25
+ <div v-if =" search" class =" table-page-search-wrapper" style =" text-align : left " >
26
+ <a-form layout =" inline" >
27
+ <a-row :gutter =" 12" >
28
+ <a-col :span =" 6" v-for =" item in searchList" :key =" item.id" >
29
+ <a-form-item :label =" item.label" >
30
+ <a-input v-if =" item.tag==='INPUT_TEXT'" v-model =" queryParam[item.field]"
31
+ :placeholder =" item.placeholder" />
32
+ <a-input-number style =" width : 100% " v-if =" item.tag==='INPUT_NUMBER'" v-model =" queryParam[item.field]"
33
+ :placeholder =" item.placeholder"
34
+ :min =" item.min" :max =" item.max" />
35
+ <a-select allowClear v-if =" item.tag==='SELECT'" v-model =" queryParam[item.field]"
36
+ :placeholder =" item.placeholder"
37
+ :options =" item.options" />
38
+ <dict-select v-if =" item.tag==='DICT_SELECT'" :placeholder =" item.placeholder"
39
+ :dict-code =" item.dictCode"
40
+ v-model =" queryParam[item.field]" />
41
+ </a-form-item >
42
+ </a-col >
43
+ </a-row >
44
+ </a-form >
45
+ </div >
47
46
48
- <div v-if =" showSelectAll" >
49
- <a-form >
50
- <a-form-item read-only label =" 已选中数据 " >
51
- <a-select v-if =" multiple" :value =" selectValue" @deselect =" multipleDeselect" :open =" false" read-only
52
- mode =" tags" />
53
- <a-select v-if =" !multiple" :value =" selectValue?[selectValue]:[]" @deselect =" singleDeselect" :open =" false"
54
- read-only mode =" tags" />
55
- </a-form-item >
56
- </a-form >
57
- </div >
47
+ <!-- 搜索控制按钮 -->
48
+ <div v-if =" search" class =" table-operator" >
49
+ <a-button @click =" reloadTable" type =" primary" >查询</a-button >
50
+ <a-button @click =" resetSearchForm" style =" margin-left : 8px " >重置</a-button >
51
+ </div >
58
52
59
- <a-table
60
- ref =" table"
61
- size =" middle"
62
- :rowKey =" rowKey"
63
- :columns =" columns"
64
- :dataSource =" dataSource"
65
- :pagination =" pagination"
66
- :loading =" loading"
67
- :rowSelection =" ret?{onSelect,onSelectAll,selectedRows,selectedRowKeys, type: multiple?'checkbox':'radio'}:undefined"
68
- :customRow =" customRow"
69
- @change =" handleTableChange"
70
- />
53
+ <div v-if =" showSelectAll" >
54
+ <a-form >
55
+ <a-form-item read-only label =" 已选中数据 " >
56
+ <a-select v-if =" multiple" :value =" selectValue" @deselect =" multipleDeselect" :open =" false" read-only
57
+ mode =" tags" />
58
+ <a-select v-if =" !multiple" :value =" selectValue?[selectValue]:[]" @deselect =" singleDeselect" :open =" false"
59
+ read-only mode =" tags" />
60
+ </a-form-item >
61
+ </a-form >
62
+ </div >
63
+
64
+ <a-table
65
+ ref =" table"
66
+ size =" middle"
67
+ :rowKey =" rowKey"
68
+ :columns =" columns"
69
+ :dataSource =" dataSource"
70
+ :pagination =" pagination"
71
+ :loading =" loading"
72
+ :rowSelection =" ret?{onSelect,onSelectAll,selectedRows,selectedRowKeys, type: multiple?'checkbox':'radio'}:undefined"
73
+ :customRow =" customRow"
74
+ @change =" handleTableChange"
75
+ />
76
+ </a-spin >
71
77
</a-modal >
72
78
</div >
73
79
</template >
74
80
75
81
<script >
76
- import {TablePageMixin } from ' @/mixins'
82
+ import { TablePageMixin } from ' @/mixins'
77
83
import Vue from ' vue'
78
- import {axios } from ' @/utils/request'
79
- import {getData } from ' @/api/sys/lov'
84
+ import { axios } from ' @/utils/request'
85
+ import { getData } from ' @/api/sys/lov'
80
86
81
87
export default {
82
88
name: ' Lov' ,
@@ -86,7 +92,7 @@ export default {
86
92
keyword: String ,
87
93
showSelectAll: {
88
94
type: Boolean ,
89
- default : function () {
95
+ default : function () {
90
96
return true
91
97
}
92
98
},
@@ -95,13 +101,13 @@ export default {
95
101
},
96
102
lazy: {
97
103
type: Boolean ,
98
- default : function () {
104
+ default : function () {
99
105
return false
100
106
}
101
107
},
102
108
disabled: {
103
109
type: Boolean ,
104
- default : function () {
110
+ default : function () {
105
111
return false
106
112
}
107
113
},
@@ -110,7 +116,7 @@ export default {
110
116
*/
111
117
selectRow: {
112
118
type: Function ,
113
- default : function (record , selectedRows , nativeEvent ) {
119
+ default : function (record , selectedRows , nativeEvent ) {
114
120
if (! this .multiple ) {
115
121
// 单选处理
116
122
this .selectedRowKeys = [].concat (record[this .rowKey ])
@@ -129,7 +135,7 @@ export default {
129
135
*/
130
136
backValIndexOfRow: {
131
137
type: Function ,
132
- default : function (value , row ) {
138
+ default : function (value , row ) {
133
139
return value .indexOf (this .retHandlerBySelectRow (row))
134
140
}
135
141
},
@@ -138,7 +144,7 @@ export default {
138
144
*/
139
145
unselectRow: {
140
146
type: Function ,
141
- default : function (record , selectedRows , nativeEvent ) {
147
+ default : function (record , selectedRows , nativeEvent ) {
142
148
// 移除key
143
149
this .selectedRowKeys .splice (this .selectedRowKeys .indexOf (record[this .rowKey ]), 1 )
144
150
// 移除行数据
@@ -158,7 +164,7 @@ export default {
158
164
*/
159
165
showHandlerBySelectRow: {
160
166
type: Function ,
161
- default : function (row ) {
167
+ default : function (row ) {
162
168
return ` ${ row[this .retField ]} `
163
169
}
164
170
},
@@ -167,7 +173,7 @@ export default {
167
173
*/
168
174
putValueShowHandler: {
169
175
type: Function ,
170
- default : function (data ) {
176
+ default : function (data ) {
171
177
return ` ${ data} `
172
178
}
173
179
},
@@ -176,7 +182,7 @@ export default {
176
182
*/
177
183
retHandlerBySelectRow: {
178
184
type: Function ,
179
- default : function (row ) {
185
+ default : function (row ) {
180
186
return row[this .retField ]
181
187
}
182
188
}
@@ -279,7 +285,7 @@ export default {
279
285
url: json .url ,
280
286
method: json .method
281
287
}
282
- req[this .position ] = {... this .fixedParams , ... query}
288
+ req[this .position ] = { ... this .fixedParams , ... query }
283
289
return axios (req)
284
290
}
285
291
@@ -311,6 +317,7 @@ export default {
311
317
312
318
// 复制传入参数
313
319
this .copyValue ()
320
+ this .loading = false
314
321
})
315
322
},
316
323
getCacheKey () {
@@ -359,7 +366,7 @@ export default {
359
366
}, {
360
367
sortField: this .sortField ,
361
368
sortAsc: this .sortAsc
362
- }, {... this .filters })
369
+ }, { ... this .filters })
363
370
364
371
this .loading = true
365
372
this .getPage (params)
@@ -412,6 +419,7 @@ export default {
412
419
this .$emit (' input' , val)
413
420
},
414
421
copyValue () {
422
+ this .loading = true
415
423
if (this .multiple ) {
416
424
let selectValue = []
417
425
let backVal = []
@@ -428,9 +436,11 @@ export default {
428
436
this .selectValue = this .value
429
437
this .backVal = this .value
430
438
}
439
+ this .loading = false
431
440
},
432
441
// select 取消选中时
433
442
multipleDeselect (value , option ) {
443
+ this .loading = true
434
444
// 查询移除值在选中数据的位置
435
445
const index = this .selectValue .indexOf (value)
436
446
// 移除数据
@@ -445,8 +455,8 @@ export default {
445
455
for (let i = 0 ; i < this .selectedRows .length ; i++ ) {
446
456
row = this .selectedRows [i]
447
457
// 寻找当前被删除数据所属行
448
- if (bv === this .retHandlerBySelectRow ( row)) {
449
- // 找到被移除的返回值
458
+ if (this .backValIndexOfRow ( this . backVal , row) === index ) {
459
+ // 如果当前行在 backVal 中的索引值等于index 则找到被移除的返回值
450
460
si = i
451
461
break
452
462
}
@@ -459,12 +469,15 @@ export default {
459
469
this .selectedRows .splice (si, 1 )
460
470
this .selectedRowKeys .splice (this .selectedRowKeys .indexOf (row[this .rowKey ]), 1 )
461
471
}
472
+ this .loading = false
462
473
},
463
474
singleDeselect () {
475
+ this .loading = true
464
476
this .selectedRows = []
465
477
this .selectedRowKeys = []
466
478
this .selectValue = undefined
467
479
this .backVal = undefined
480
+ this .loading = false
468
481
},
469
482
cleanAll () {
470
483
this .emit (this .multiple ? [] : ' ' )
0 commit comments