Skip to content

Commit 72f0155

Browse files
committed
优化Grid布局
1 parent 09c5a52 commit 72f0155

File tree

6 files changed

+118
-78
lines changed

6 files changed

+118
-78
lines changed

public/app.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public/mix-manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"/app.js": "/app.js?id=56b921be10395873e06e",
2+
"/app.js": "/app.js?id=3254437a2f9d7ac84e92",
33
"/manifest.js": "/manifest.js?id=8991394a854ee5cdffc3",
44
"/vendor.js": "/vendor.js?id=df0be4950fcb717193ba"
55
}

resources/js/components/Root.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@
128128
</div>
129129
</div>
130130
</el-header>
131-
<el-main :class="{ 'el-main-fixed': fixedHeader }" style="position: relative;">
131+
<el-main :class="{ 'el-main-fixed': fixedHeader }">
132132

133133
<div class="layout-content-main">
134134
<router-view></router-view>

resources/js/components/form/Form.vue

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -316,9 +316,6 @@ export default {
316316
.form-card {
317317
min-height: 200px;
318318
}
319-
.el-form-item__content {
320-
//line-height: unset;
321-
}
322319
.form-bottom-actions {
323320
display: flex;
324321
align-items: center;
@@ -329,7 +326,7 @@ export default {
329326
padding: 6px;
330327
background: #ffffff;
331328
border-radius: 4px;
332-
border: 1px solid #EBEEF5;
329+
border: 1px solid #ebeef5;
333330
}
334331
}
335332

resources/js/components/grid/Table.vue

Lines changed: 114 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,51 @@
11
<template>
22
<div class="grid-container">
33
<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>
526

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">
749
<div class="grid-top-container">
850
<div class="grid-top-container-left">
951
<BatchActions
@@ -24,7 +66,9 @@
2466
@clear="getData"
2567
@keyup.enter.native="getData"
2668
>
27-
<el-button @click="getData" :loading="loading" slot="append">搜索</el-button>
69+
<el-button @click="getData" :loading="loading" slot="append"
70+
>搜索</el-button
71+
>
2872
</el-input>
2973
</div>
3074
<div class="flex-c">
@@ -43,10 +87,18 @@
4387
:is="component.componentName"
4488
:attrs="component"
4589
/>
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>
4794
<div class="icon-actions">
4895
<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+
>
50102
<i class="el-icon-rank hover"></i>
51103
</el-tooltip>
52104
<el-dropdown-menu slot="dropdown">
@@ -65,52 +117,18 @@
65117
</el-dropdown-menu>
66118
</el-dropdown>
67119

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+
>
69126
<i class="el-icon-refresh hover" @click="getData"></i>
70127
</el-tooltip>
71128
</div>
72129
</div>
73130
</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>
114132
<div>
115133
<el-table
116134
:ref="attrs.ref || 'table'"
@@ -131,8 +149,16 @@
131149
@sort-change="onTableSortChange"
132150
@selection-change="onTableselectionChange"
133151
>
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>
136162
<template v-for="column in attrs.columnAttributes">
137163
<el-table-column
138164
:type="column.type"
@@ -149,12 +175,19 @@
149175
>
150176
<template slot="header" slot-scope="scope">
151177
<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+
>
153183
<i class="el-icon-question hover"></i>
154184
</el-tooltip>
155185
</template>
156186
<template slot-scope="scope">
157-
<ColumnDisplay :scope="scope" :columns="attrs.columnAttributes" />
187+
<ColumnDisplay
188+
:scope="scope"
189+
:columns="attrs.columnAttributes"
190+
/>
158191
</template>
159192
</el-table-column>
160193
</template>
@@ -192,7 +225,11 @@
192225
/>
193226
</div>
194227
</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+
/>
196233
<DialogForm
197234
ref="DialogGridFrom"
198235
v-if="attrs.dialogForm"
@@ -218,10 +255,10 @@ export default {
218255
Actions,
219256
ItemDiaplsy,
220257
BatchActions,
221-
DialogForm
258+
DialogForm,
222259
},
223260
props: {
224-
attrs: Object
261+
attrs: Object,
225262
},
226263
data() {
227264
return {
@@ -232,15 +269,16 @@ export default {
232269
pageSize: this.attrs.perPage,
233270
total: 0,
234271
currentPage: 1,
235-
lastPage: 1
272+
lastPage: 1,
236273
},
237274
page: 1, //当前页
238275
quickSearch: null, //快捷搜索内容
239276
selectionRows: [], //已选择的row
240277
filterFormData: null, //表单搜索数据
241278
tabsSelectdata: {},
242279
tabsActiveName: "all",
243-
topViewHeight: 0
280+
topViewHeight: 0,
281+
toolbarsViewHeight: 0,
244282
};
245283
},
246284
@@ -283,7 +321,7 @@ export default {
283321
this.$bus.on("tableReload", () => {
284322
this.getData();
285323
});
286-
this.$bus.on("tableSetLoading", status => {
324+
this.$bus.on("tableSetLoading", (status) => {
287325
this.loading = status;
288326
});
289327
@@ -294,6 +332,7 @@ export default {
294332
295333
this.$nextTick(() => {
296334
this.topViewHeight = this.$refs.topView.offsetHeight;
335+
this.toolbarsViewHeight = this.$refs.toolbarsView.offsetHeight;
297336
});
298337
},
299338
destroyed() {
@@ -333,8 +372,8 @@ export default {
333372
...this.sort,
334373
...this.q_search,
335374
...this.filterFormData,
336-
...this.tabsSelectdata
337-
}
375+
...this.tabsSelectdata,
376+
},
338377
})
339378
.then(
340379
({ data: { data, current_page, per_page, total, last_page } }) => {
@@ -349,24 +388,24 @@ export default {
349388
if (this.attrs.attributes.dataVuex) {
350389
this.$store.commit("setGridData", {
351390
key: "tableData",
352-
data: this.tableData
391+
data: this.tableData,
353392
});
354393
}
355394
356395
this.$store.commit("setGridData", { key: "sort", data: this.sort });
357396
this.$store.commit("setGridData", { key: "page", data: this.page });
358397
this.$store.commit("setGridData", {
359398
key: "pageData",
360-
data: this.pageData
399+
data: this.pageData,
361400
});
362401
363402
this.$store.commit("setGridData", {
364403
key: "quickSearch",
365-
data: this.quickSearch
404+
data: this.quickSearch,
366405
});
367406
this.$store.commit("setGridData", {
368407
key: "filterFormData",
369-
data: this.filterFormData
408+
data: this.filterFormData,
370409
});
371410
/** */
372411
}
@@ -391,7 +430,7 @@ export default {
391430
this.selectionRows = selection;
392431
this.$store.commit("setGridData", {
393432
key: "selectionKeys",
394-
data: this.keys
433+
data: this.keys,
395434
});
396435
},
397436
//每页大小改变时
@@ -404,12 +443,12 @@ export default {
404443
onPageCurrentChange(page) {
405444
this.page = page;
406445
this.getData();
407-
}
446+
},
408447
},
409448
computed: {
410449
keys() {
411450
return this.selectionRows
412-
.map(item => {
451+
.map((item) => {
413452
return item[this.attrs.keyName];
414453
})
415454
.join(",");
@@ -420,7 +459,7 @@ export default {
420459
},
421460
//
422461
columns() {
423-
return this.column_attributes.map(attributes => {
462+
return this.column_attributes.map((attributes) => {
424463
return attributes;
425464
});
426465
},
@@ -429,7 +468,7 @@ export default {
429468
return this.sort
430469
? {
431470
prop: this.sort.sort_prop,
432-
order: this.sort.sort_order == "asc" ? "ascending" : "descending"
471+
order: this.sort.sort_order == "asc" ? "ascending" : "descending",
433472
}
434473
: {};
435474
},
@@ -447,21 +486,26 @@ export default {
447486
55 -
448487
window.rootFooterHeight -
449488
this.topViewHeight -
450-
40
489+
40 -
490+
this.toolbarsViewHeight
451491
);
452492
}
453493
return this.attrs.attributes.height;
454-
}
455-
}
494+
},
495+
},
456496
};
457497
</script>
458498

459499
<style lang="scss">
460500
.grid-container {
501+
.bottom-border {
502+
border-bottom: 1px solid #ebeef5;
503+
}
461504
.grid-top-container {
462505
padding: 8px;
463506
display: flex;
464507
justify-content: space-between;
508+
min-height: 32px;
465509
.grid-top-container-left {
466510
display: flex;
467511
align-items: center;

0 commit comments

Comments
 (0)