|
@@ -36,7 +36,7 @@ export default { |
|
@@ -36,7 +36,7 @@ export default { |
36
|
// 分页页码设置
|
36
|
// 分页页码设置
|
37
|
pageSizes: {
|
37
|
pageSizes: {
|
38
|
type: Array,
|
38
|
type: Array,
|
39
|
- default: [10, 50, 100, 200, 300, 400]
|
39
|
+ default: [10,50,100, 200, 300, 400]
|
40
|
},
|
40
|
},
|
41
|
// 默认展示
|
41
|
// 默认展示
|
42
|
pageSize: {
|
42
|
pageSize: {
|
|
@@ -67,46 +67,50 @@ export default { |
|
@@ -67,46 +67,50 @@ export default { |
67
|
default: []
|
67
|
default: []
|
68
|
},
|
68
|
},
|
69
|
// 是否展示加载
|
69
|
// 是否展示加载
|
70
|
- loading: {
|
70
|
+ loading:{
|
71
|
type: Boolean,
|
71
|
type: Boolean,
|
72
|
default: false
|
72
|
default: false
|
73
|
},
|
73
|
},
|
74
|
- maxWidth: {
|
74
|
+ maxWidth:{
|
75
|
type: Number,
|
75
|
type: Number,
|
76
|
default: window.innerWidth
|
76
|
default: window.innerWidth
|
77
|
},
|
77
|
},
|
78
|
- showTools: {
|
78
|
+ showTools:{
|
79
|
type: Boolean,
|
79
|
type: Boolean,
|
80
|
default: false
|
80
|
default: false
|
81
|
},
|
81
|
},
|
|
|
82
|
+ toolsWith:{
|
|
|
83
|
+ type: Number,
|
|
|
84
|
+ default: 80
|
|
|
85
|
+ },
|
82
|
// medium / small / mini
|
86
|
// medium / small / mini
|
83
|
- size: {
|
87
|
+ size:{
|
84
|
type: String,
|
88
|
type: String,
|
85
|
default: 'small'
|
89
|
default: 'small'
|
86
|
},
|
90
|
},
|
87
|
- multipleSelection: {
|
|
|
88
|
- type: Array,
|
|
|
89
|
- default: []
|
91
|
+ multipleSelection:{
|
|
|
92
|
+ type:Array,
|
|
|
93
|
+ default:[]
|
90
|
},
|
94
|
},
|
91
|
//展开行
|
95
|
//展开行
|
92
|
- showExpand: {
|
96
|
+ showExpand:{
|
93
|
type: Boolean,
|
97
|
type: Boolean,
|
94
|
default: false
|
98
|
default: false
|
95
|
},
|
99
|
},
|
96
|
//行数据的key
|
100
|
//行数据的key
|
97
|
- getRowKeys: {
|
101
|
+ getRowKeys:{
|
98
|
type: String,
|
102
|
type: String,
|
99
|
default: 'id'
|
103
|
default: 'id'
|
100
|
},
|
104
|
},
|
101
|
//默认展开哪行
|
105
|
//默认展开哪行
|
102
|
- expands: {
|
106
|
+ expands:{
|
103
|
type: Array,
|
107
|
type: Array,
|
104
|
default: []
|
108
|
default: []
|
105
|
},
|
109
|
},
|
106
|
//是否默认展开所有行
|
110
|
//是否默认展开所有行
|
107
|
- defaultExpand: {
|
|
|
108
|
- type: Boolean,
|
|
|
109
|
- default: false
|
111
|
+ defaultExpand:{
|
|
|
112
|
+ type:Boolean,
|
|
|
113
|
+ default:false
|
110
|
}
|
114
|
}
|
111
|
},
|
115
|
},
|
112
|
data() {
|
116
|
data() {
|
|
@@ -125,22 +129,22 @@ export default { |
|
@@ -125,22 +129,22 @@ export default { |
125
|
* 时间:2021/11/16 16:19
|
129
|
* 时间:2021/11/16 16:19
|
126
|
*/
|
130
|
*/
|
127
|
|
131
|
|
128
|
- let getWidth = (width) => {
|
|
|
129
|
- let maxWidth = (function () {
|
132
|
+ let getWidth = (width) =>{
|
|
|
133
|
+ let maxWidth = (function (){
|
130
|
let cols = props.columns;
|
134
|
let cols = props.columns;
|
131
|
- if (cols && cols.length > 0) {
|
135
|
+ if(cols && cols.length > 0){
|
132
|
// 求和
|
136
|
// 求和
|
133
|
let w = 0;
|
137
|
let w = 0;
|
134
|
cols.forEach(function (v) {
|
138
|
cols.forEach(function (v) {
|
135
|
- w += parseFloat(v.width);
|
139
|
+ w += parseFloat(v.width) ;
|
136
|
})
|
140
|
})
|
137
|
|
141
|
|
138
|
let max = props.maxWidth;
|
142
|
let max = props.maxWidth;
|
139
|
- if (props.showTools) {
|
143
|
+ if(props.showTools){
|
140
|
max -= 80;
|
144
|
max -= 80;
|
141
|
}
|
145
|
}
|
142
|
|
146
|
|
143
|
- if (w < max) {
|
147
|
+ if(w < max){
|
144
|
return max / w * width;
|
148
|
return max / w * width;
|
145
|
}
|
149
|
}
|
146
|
}
|
150
|
}
|
|
@@ -151,7 +155,7 @@ export default { |
|
@@ -151,7 +155,7 @@ export default { |
151
|
}
|
155
|
}
|
152
|
|
156
|
|
153
|
|
157
|
|
154
|
- let callback = () => {
|
158
|
+ let callback = () =>{
|
155
|
let params = {
|
159
|
let params = {
|
156
|
page: currentPage.value, limit: pageSize.value
|
160
|
page: currentPage.value, limit: pageSize.value
|
157
|
}
|
161
|
}
|
|
@@ -183,7 +187,7 @@ export default { |
|
@@ -183,7 +187,7 @@ export default { |
183
|
let prePage = (val) => {
|
187
|
let prePage = (val) => {
|
184
|
// console.log(`当前页: ${val}`)
|
188
|
// console.log(`当前页: ${val}`)
|
185
|
// props.currentPage = val - 1;
|
189
|
// props.currentPage = val - 1;
|
186
|
- currentPage.value = val - 1;
|
190
|
+ currentPage.value = val-1;
|
187
|
callback();
|
191
|
callback();
|
188
|
}
|
192
|
}
|
189
|
|
193
|
|
|
@@ -191,7 +195,7 @@ export default { |
|
@@ -191,7 +195,7 @@ export default { |
191
|
let nextPage = (val) => {
|
195
|
let nextPage = (val) => {
|
192
|
// console.log(`当前页: ${val}`)
|
196
|
// console.log(`当前页: ${val}`)
|
193
|
// props.currentPage = val + 1;
|
197
|
// props.currentPage = val + 1;
|
194
|
- currentPage.value = val + 1;
|
198
|
+ currentPage.value = val+1;
|
195
|
callback();
|
199
|
callback();
|
196
|
}
|
200
|
}
|
197
|
|
201
|
|
|
@@ -201,13 +205,13 @@ export default { |
|
@@ -201,13 +205,13 @@ export default { |
201
|
// });
|
205
|
// });
|
202
|
|
206
|
|
203
|
//全选事件
|
207
|
//全选事件
|
204
|
- let handleSelectionChange = (val) => {
|
208
|
+ let handleSelectionChange=(val)=>{
|
205
|
// multipleSelection.value = val
|
209
|
// multipleSelection.value = val
|
206
|
emit('selectionChange', val)
|
210
|
emit('selectionChange', val)
|
207
|
|
211
|
|
208
|
}
|
212
|
}
|
209
|
//设置默认选中
|
213
|
//设置默认选中
|
210
|
- let toggleSelection = (rows) => {
|
214
|
+ let toggleSelection=(rows)=> {
|
211
|
//console.log("rows",rows)
|
215
|
//console.log("rows",rows)
|
212
|
proxy.$nextTick(function () {
|
216
|
proxy.$nextTick(function () {
|
213
|
//console.log("set",props.dataList,props.multipleSelection)
|
217
|
//console.log("set",props.dataList,props.multipleSelection)
|
|
@@ -223,18 +227,18 @@ export default { |
|
@@ -223,18 +227,18 @@ export default { |
223
|
})
|
227
|
})
|
224
|
}
|
228
|
}
|
225
|
|
229
|
|
226
|
- let getTextContent = (val) => {
|
|
|
227
|
- if (val && val != '' && val != null) {
|
|
|
228
|
- val = val + ''.replace(/[^\x00-\xff]/g, "$&\x01").replace(/.{50}\x01?/g, "$&<br/>").replace(/\x01/g, "");
|
230
|
+ let getTextContent = (val) =>{
|
|
|
231
|
+ if(val && val != '' && val != null){
|
|
|
232
|
+ val = val+''.replace(/[^\x00-\xff]/g,"$&\x01").replace(/.{50}\x01?/g,"$&<br/>").replace(/\x01/g,"");
|
229
|
}
|
233
|
}
|
230
|
- return val;
|
234
|
+ return `<pre>${val}</pre>`;
|
231
|
|
235
|
|
232
|
}
|
236
|
}
|
233
|
//设置父节点选中后children也选中
|
237
|
//设置父节点选中后children也选中
|
234
|
- let setChecked = (row) => {
|
|
|
235
|
- let arr = [];
|
|
|
236
|
- if (row.children) {
|
|
|
237
|
- row.children.map(j => {
|
238
|
+ let setChecked=(row)=>{
|
|
|
239
|
+ let arr=[];
|
|
|
240
|
+ if(row.children){
|
|
|
241
|
+ row.children.map(j=>{
|
238
|
arr.push(j)
|
242
|
arr.push(j)
|
239
|
setChecked(j)
|
243
|
setChecked(j)
|
240
|
})
|
244
|
})
|
|
@@ -242,43 +246,67 @@ export default { |
|
@@ -242,43 +246,67 @@ export default { |
242
|
toggleSelection(arr)
|
246
|
toggleSelection(arr)
|
243
|
}
|
247
|
}
|
244
|
//勾选数据行的Checkbox事件
|
248
|
//勾选数据行的Checkbox事件
|
245
|
- let handleSelect = (selection, row) => {
|
249
|
+ let handleSelect=(selection, row)=>{
|
|
|
250
|
+ /* if(selection.some(el=>{ return row[props.getRowKeys] ===el[props.getRowKeys]})){
|
|
|
251
|
+ setChecked(row);
|
|
|
252
|
+ }else{
|
|
|
253
|
+ setChecked(row);
|
|
|
254
|
+ }*/
|
246
|
setChecked(row);
|
255
|
setChecked(row);
|
247
|
|
256
|
|
248
|
- emit('handleSelect', selection)
|
257
|
+ emit('handleSelect',selection)
|
249
|
}
|
258
|
}
|
250
|
//勾选全选checkbox事件
|
259
|
//勾选全选checkbox事件
|
251
|
- let handleSelectAll = (selection) => {
|
|
|
252
|
- const isSelect = selection.some(el => {
|
|
|
253
|
- const tableDataIds = props.dataList.map(j => j[props.getRowKeys])
|
260
|
+ let handleSelectAll=(selection)=>{
|
|
|
261
|
+ const isSelect=selection.some(el=>{
|
|
|
262
|
+ const tableDataIds=props.dataList.map(j=>j[props.getRowKeys])
|
254
|
return tableDataIds.includes(el.id)
|
263
|
return tableDataIds.includes(el.id)
|
255
|
})
|
264
|
})
|
256
|
- const isCancel = !props.dataList.every(el => {
|
|
|
257
|
- const selectIds = selection.map(j => j[props.getRowKeys])
|
265
|
+ const isCancel=!props.dataList.every(el=>{
|
|
|
266
|
+ const selectIds=selection.map(j=>j[props.getRowKeys])
|
258
|
return selectIds.includes(el.id)
|
267
|
return selectIds.includes(el.id)
|
259
|
})
|
268
|
})
|
260
|
- if (isSelect) {
|
269
|
+ if(isSelect){
|
261
|
setChecked(selection);
|
270
|
setChecked(selection);
|
262
|
}
|
271
|
}
|
263
|
- if (isCancel) {
|
|
|
264
|
- props.dataList.map(el => {
|
272
|
+ if(isCancel){
|
|
|
273
|
+ props.dataList.map(el=>{
|
265
|
setChecked(el);
|
274
|
setChecked(el);
|
266
|
})
|
275
|
})
|
267
|
}
|
276
|
}
|
268
|
|
277
|
|
269
|
- emit('handleSelectAll', selection)
|
278
|
+ emit('handleSelectAll',selection)
|
270
|
}
|
279
|
}
|
|
|
280
|
+
|
|
|
281
|
+ /**
|
|
|
282
|
+ * 表格组件,超过2行展示tooltip
|
|
|
283
|
+ * @param e
|
|
|
284
|
+ * @param item
|
|
|
285
|
+ */
|
|
|
286
|
+ const tableColMouseenter = (e, item) => {
|
|
|
287
|
+ const ev = e.target;
|
|
|
288
|
+ var height = $(ev).scroll().height()
|
|
|
289
|
+ // 超过2行 46
|
|
|
290
|
+ if (height > 45) {
|
|
|
291
|
+ // 实际高度 > 可视高度 文字溢出
|
|
|
292
|
+ item.isShowTooltip = true;
|
|
|
293
|
+ } else {
|
|
|
294
|
+ // 否则为不溢出
|
|
|
295
|
+ item.isShowTooltip = false;
|
|
|
296
|
+ }
|
|
|
297
|
+ }
|
|
|
298
|
+
|
271
|
// 挂载完
|
299
|
// 挂载完
|
272
|
Vue.onMounted(() => {
|
300
|
Vue.onMounted(() => {
|
273
|
//callback();
|
301
|
//callback();
|
274
|
|
302
|
|
275
|
})
|
303
|
})
|
276
|
- Vue.watch(() => props.dataList, (newValue, oldValue) => {
|
|
|
277
|
- setTimeout(function () {
|
|
|
278
|
- if (props.showSelection) {
|
304
|
+ Vue.watch(()=>props.dataList,(newValue, oldValue)=>{
|
|
|
305
|
+ setTimeout(function (){
|
|
|
306
|
+ if(props.showSelection){
|
279
|
toggleSelection(props.multipleSelection)
|
307
|
toggleSelection(props.multipleSelection)
|
280
|
}
|
308
|
}
|
281
|
- }, 100)
|
309
|
+ },100)
|
282
|
|
310
|
|
283
|
|
311
|
|
284
|
})
|
312
|
})
|
|
@@ -296,7 +324,8 @@ export default { |
|
@@ -296,7 +324,8 @@ export default { |
296
|
prePage,
|
324
|
prePage,
|
297
|
nextPage,
|
325
|
nextPage,
|
298
|
getWidth,
|
326
|
getWidth,
|
299
|
- getTextContent
|
327
|
+ getTextContent,
|
|
|
328
|
+ tableColMouseenter
|
300
|
}
|
329
|
}
|
301
|
}
|
330
|
}
|
302
|
} |
331
|
} |