1
1
<template >
2
2
<div class =" grid-container" >
3
3
<div ref =" topView" >
4
- <component v-if =" attrs.top" :is =" attrs.top.componentName" :attrs =" attrs.top" />
4
+ <component
5
+ v-if =" attrs.top"
6
+ :is =" attrs.top.componentName"
7
+ :attrs =" attrs.top"
8
+ />
9
+ <el-card
10
+ shadow =" never"
11
+ :body-style =" { padding: 0 }"
12
+ class =" mb-10"
13
+ v-if =" attrs.filter.filters.length > 0"
14
+ >
15
+ <div class =" filter-form" >
16
+ <el-form :inline =" true" :model =" filterFormData" v-if =" filterFormData" >
17
+ <el-form-item v-if =" attrs.quickSearch" >
18
+ <el-input
19
+ v-model =" quickSearch"
20
+ :placeholder =" attrs.quickSearch.placeholder"
21
+ :clearable =" true"
22
+ @clear =" getData"
23
+ @keyup.enter.native =" getData"
24
+ ></el-input >
25
+ </el-form-item >
5
26
6
- <el-card shadow =" never" :body-style =" { padding: 0 }" v-if =" attrs.toolbars.show" >
27
+ <el-form-item
28
+ v-for =" (item, index) in attrs.filter.filters"
29
+ :key =" index"
30
+ :label =" item.label"
31
+ >
32
+ <ItemDiaplsy
33
+ v-model =" filterFormData[item.column]"
34
+ :form-item =" item"
35
+ :form-items =" attrs.filters"
36
+ :form-data =" filterFormData"
37
+ />
38
+ </el-form-item >
39
+ <el-form-item >
40
+ <el-button type =" primary" @click =" onFilterSubmit" >搜索</el-button >
41
+ <el-button @click =" onFilterReset" >重置</el-button >
42
+ </el-form-item >
43
+ </el-form >
44
+ </div >
45
+ </el-card >
46
+ </div >
47
+ <el-card shadow =" never" :body-style =" { padding: 0 }" v-loading =" loading" >
48
+ <div class =" bottom-border" ref =" toolbarsView" v-if =" attrs.toolbars.show" >
7
49
<div class =" grid-top-container" >
8
50
<div class =" grid-top-container-left" >
9
51
<BatchActions
24
66
@clear =" getData"
25
67
@keyup.enter.native =" getData"
26
68
>
27
- <el-button @click =" getData" :loading =" loading" slot =" append" >搜索</el-button >
69
+ <el-button @click =" getData" :loading =" loading" slot =" append"
70
+ >搜索</el-button
71
+ >
28
72
</el-input >
29
73
</div >
30
74
<div class =" flex-c" >
43
87
:is =" component.componentName"
44
88
:attrs =" component"
45
89
/>
46
- <el-divider direction =" vertical" v-if =" !attrs.attributes.hideCreateButton" ></el-divider >
90
+ <el-divider
91
+ direction =" vertical"
92
+ v-if =" !attrs.attributes.hideCreateButton"
93
+ ></el-divider >
47
94
<div class =" icon-actions" >
48
95
<el-dropdown trigger =" click" >
49
- <el-tooltip class =" item" effect =" dark" content =" 密度" placement =" top" >
96
+ <el-tooltip
97
+ class =" item"
98
+ effect =" dark"
99
+ content =" 密度"
100
+ placement =" top"
101
+ >
50
102
<i class =" el-icon-rank hover" ></i >
51
103
</el-tooltip >
52
104
<el-dropdown-menu slot =" dropdown" >
65
117
</el-dropdown-menu >
66
118
</el-dropdown >
67
119
68
- <el-tooltip class =" item" effect =" dark" content =" 刷新" placement =" top" >
120
+ <el-tooltip
121
+ class =" item"
122
+ effect =" dark"
123
+ content =" 刷新"
124
+ placement =" top"
125
+ >
69
126
<i class =" el-icon-refresh hover" @click =" getData" ></i >
70
127
</el-tooltip >
71
128
</div >
72
129
</div >
73
130
</div >
74
- </el-card >
75
- <el-card
76
- shadow =" never"
77
- class =" mt-10"
78
- :body-style =" { padding: 0 }"
79
- v-if =" attrs.filter.filters.length > 0"
80
- >
81
- <div class =" filter-form" >
82
- <el-form :inline =" true" :model =" filterFormData" v-if =" filterFormData" >
83
- <el-form-item v-if =" attrs.quickSearch" >
84
- <el-input
85
- v-model =" quickSearch"
86
- :placeholder =" attrs.quickSearch.placeholder"
87
- :clearable =" true"
88
- @clear =" getData"
89
- @keyup.enter.native =" getData"
90
- ></el-input >
91
- </el-form-item >
92
-
93
- <el-form-item
94
- v-for =" (item, index) in attrs.filter.filters"
95
- :key =" index"
96
- :label =" item.label"
97
- >
98
- <ItemDiaplsy
99
- v-model =" filterFormData[item.column]"
100
- :form-item =" item"
101
- :form-items =" attrs.filters"
102
- :form-data =" filterFormData"
103
- />
104
- </el-form-item >
105
- <el-form-item >
106
- <el-button type =" primary" @click =" onFilterSubmit" >搜索</el-button >
107
- <el-button @click =" onFilterReset" >重置</el-button >
108
- </el-form-item >
109
- </el-form >
110
- </div >
111
- </el-card >
112
- </div >
113
- <el-card class =" mt-10" shadow =" never" :body-style =" { padding: 0 }" v-loading =" loading" >
131
+ </div >
114
132
<div >
115
133
<el-table
116
134
:ref =" attrs.ref || 'table'"
131
149
@sort-change =" onTableSortChange"
132
150
@selection-change =" onTableselectionChange"
133
151
>
134
- <el-table-column v-if =" attrs.attributes.selection" align =" center" type =" selection" ></el-table-column >
135
- <el-table-column v-if =" attrs.tree" align =" center" width =" 50" ></el-table-column >
152
+ <el-table-column
153
+ v-if =" attrs.attributes.selection"
154
+ align =" center"
155
+ type =" selection"
156
+ ></el-table-column >
157
+ <el-table-column
158
+ v-if =" attrs.tree"
159
+ align =" center"
160
+ width =" 50"
161
+ ></el-table-column >
136
162
<template v-for =" column in attrs .columnAttributes " >
137
163
<el-table-column
138
164
:type =" column.type"
149
175
>
150
176
<template slot="header" slot-scope="scope">
151
177
<span >{{ scope.column.label }}</span >
152
- <el-tooltip placement =" top" v-if =" column.help" :content =" column.help" >
178
+ <el-tooltip
179
+ placement =" top"
180
+ v-if =" column.help"
181
+ :content =" column.help"
182
+ >
153
183
<i class =" el-icon-question hover" ></i >
154
184
</el-tooltip >
155
185
</template >
156
186
<template slot-scope="scope">
157
- <ColumnDisplay :scope =" scope" :columns =" attrs.columnAttributes" />
187
+ <ColumnDisplay
188
+ :scope =" scope"
189
+ :columns =" attrs.columnAttributes"
190
+ />
158
191
</template >
159
192
</el-table-column >
160
193
</template >
192
225
/>
193
226
</div >
194
227
</el-card >
195
- <component v-if =" attrs.bottom" :is =" attrs.bottom.componentName" :attrs =" attrs.bottom" />
228
+ <component
229
+ v-if =" attrs.bottom"
230
+ :is =" attrs.bottom.componentName"
231
+ :attrs =" attrs.bottom"
232
+ />
196
233
<DialogForm
197
234
ref =" DialogGridFrom"
198
235
v-if =" attrs.dialogForm"
@@ -218,10 +255,10 @@ export default {
218
255
Actions,
219
256
ItemDiaplsy,
220
257
BatchActions,
221
- DialogForm
258
+ DialogForm,
222
259
},
223
260
props: {
224
- attrs: Object
261
+ attrs: Object ,
225
262
},
226
263
data () {
227
264
return {
@@ -232,15 +269,16 @@ export default {
232
269
pageSize: this .attrs .perPage ,
233
270
total: 0 ,
234
271
currentPage: 1 ,
235
- lastPage: 1
272
+ lastPage: 1 ,
236
273
},
237
274
page: 1 , // 当前页
238
275
quickSearch: null , // 快捷搜索内容
239
276
selectionRows: [], // 已选择的row
240
277
filterFormData: null , // 表单搜索数据
241
278
tabsSelectdata: {},
242
279
tabsActiveName: " all" ,
243
- topViewHeight: 0
280
+ topViewHeight: 0 ,
281
+ toolbarsViewHeight: 0 ,
244
282
};
245
283
},
246
284
@@ -283,7 +321,7 @@ export default {
283
321
this .$bus .on (" tableReload" , () => {
284
322
this .getData ();
285
323
});
286
- this .$bus .on (" tableSetLoading" , status => {
324
+ this .$bus .on (" tableSetLoading" , ( status ) => {
287
325
this .loading = status;
288
326
});
289
327
@@ -294,6 +332,7 @@ export default {
294
332
295
333
this .$nextTick (() => {
296
334
this .topViewHeight = this .$refs .topView .offsetHeight ;
335
+ this .toolbarsViewHeight = this .$refs .toolbarsView .offsetHeight ;
297
336
});
298
337
},
299
338
destroyed () {
@@ -333,8 +372,8 @@ export default {
333
372
... this .sort ,
334
373
... this .q_search ,
335
374
... this .filterFormData ,
336
- ... this .tabsSelectdata
337
- }
375
+ ... this .tabsSelectdata ,
376
+ },
338
377
})
339
378
.then (
340
379
({ data: { data, current_page, per_page, total, last_page } }) => {
@@ -349,24 +388,24 @@ export default {
349
388
if (this .attrs .attributes .dataVuex ) {
350
389
this .$store .commit (" setGridData" , {
351
390
key: " tableData" ,
352
- data: this .tableData
391
+ data: this .tableData ,
353
392
});
354
393
}
355
394
356
395
this .$store .commit (" setGridData" , { key: " sort" , data: this .sort });
357
396
this .$store .commit (" setGridData" , { key: " page" , data: this .page });
358
397
this .$store .commit (" setGridData" , {
359
398
key: " pageData" ,
360
- data: this .pageData
399
+ data: this .pageData ,
361
400
});
362
401
363
402
this .$store .commit (" setGridData" , {
364
403
key: " quickSearch" ,
365
- data: this .quickSearch
404
+ data: this .quickSearch ,
366
405
});
367
406
this .$store .commit (" setGridData" , {
368
407
key: " filterFormData" ,
369
- data: this .filterFormData
408
+ data: this .filterFormData ,
370
409
});
371
410
/** */
372
411
}
@@ -391,7 +430,7 @@ export default {
391
430
this .selectionRows = selection;
392
431
this .$store .commit (" setGridData" , {
393
432
key: " selectionKeys" ,
394
- data: this .keys
433
+ data: this .keys ,
395
434
});
396
435
},
397
436
// 每页大小改变时
@@ -404,12 +443,12 @@ export default {
404
443
onPageCurrentChange (page ) {
405
444
this .page = page;
406
445
this .getData ();
407
- }
446
+ },
408
447
},
409
448
computed: {
410
449
keys () {
411
450
return this .selectionRows
412
- .map (item => {
451
+ .map (( item ) => {
413
452
return item[this .attrs .keyName ];
414
453
})
415
454
.join (" ," );
@@ -420,7 +459,7 @@ export default {
420
459
},
421
460
//
422
461
columns () {
423
- return this .column_attributes .map (attributes => {
462
+ return this .column_attributes .map (( attributes ) => {
424
463
return attributes;
425
464
});
426
465
},
@@ -429,7 +468,7 @@ export default {
429
468
return this .sort
430
469
? {
431
470
prop: this .sort .sort_prop ,
432
- order: this .sort .sort_order == " asc" ? " ascending" : " descending"
471
+ order: this .sort .sort_order == " asc" ? " ascending" : " descending" ,
433
472
}
434
473
: {};
435
474
},
@@ -447,21 +486,26 @@ export default {
447
486
55 -
448
487
window .rootFooterHeight -
449
488
this .topViewHeight -
450
- 40
489
+ 40 -
490
+ this .toolbarsViewHeight
451
491
);
452
492
}
453
493
return this .attrs .attributes .height ;
454
- }
455
- }
494
+ },
495
+ },
456
496
};
457
497
</script >
458
498
459
499
<style lang="scss">
460
500
.grid-container {
501
+ .bottom-border {
502
+ border-bottom : 1px solid #ebeef5 ;
503
+ }
461
504
.grid-top-container {
462
505
padding : 8px ;
463
506
display : flex ;
464
507
justify-content : space-between ;
508
+ min-height : 32px ;
465
509
.grid-top-container-left {
466
510
display : flex ;
467
511
align-items : center ;
0 commit comments