Skip to content

Commit 0f72bc8

Browse files
committed
修复 网格自动计算高度未考虑是否隐藏分页 #48
支持laravel8.x版本
1 parent 65c8e4b commit 0f72bc8

File tree

14 files changed

+74
-124
lines changed

14 files changed

+74
-124
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"Vue"
1616
],
1717
"require": {
18-
"illuminate/support": "~5|~6|~7"
18+
"illuminate/support": "~5|~6|~7|~8"
1919
},
2020
"require-dev": {
2121
"phpunit/phpunit": "^8.0",

config/admin.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
'login_background_image' => 'https://gw.alipayobjects.com/zos/rmsportal/TVYTbAXWheQpRcWDaDMu.svg',
2222
//登录框默认用户
2323
'auto_user' => [
24-
'username' => 'demo',
25-
'password' => 'demo'
24+
'username' => '',
25+
'password' => ''
2626
],
2727
//底部菜单
2828
'footerLinks' => [
@@ -109,7 +109,7 @@
109109
],
110110
//操作日志
111111
'operation_log' => [
112-
'enable' => true,
112+
'enable' => env('ADMIN_OPERATION_LOG', false),
113113
/*
114114
* Only logging allowed methods in the list
115115
*/

public/0.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/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=77438fd426d416cb6e8f",
2+
"/app.js": "/app.js?id=d686e3c8b0aaf5de7960",
33
"/manifest.js": "/manifest.js?id=8991394a854ee5cdffc3",
44
"/vendor.js": "/vendor.js?id=df0be4950fcb717193ba"
55
}

resources/js/components/Root.vue

Lines changed: 15 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -53,19 +53,10 @@
5353
<span slot="title">{{ menu.title }}</span>
5454
</template>
5555
<template v-for="children in menu.children">
56-
<MenuItem
57-
:menu="children"
58-
:key="children.id"
59-
:is_collapsed="isCollapsed"
60-
/>
56+
<MenuItem :menu="children" :key="children.id" :is_collapsed="isCollapsed" />
6157
</template>
6258
</el-submenu>
63-
<el-menu-item
64-
:index="menu.route"
65-
:key="menu.id"
66-
:route="menu.route"
67-
v-else
68-
>
59+
<el-menu-item :index="menu.route" :key="menu.id" :route="menu.route" v-else>
6960
<i :class="menu.icon" v-if="menu.icon" size="16"></i>
7061
<span slot="title">{{ menu.title }}</span>
7162
</el-menu-item>
@@ -91,22 +82,13 @@
9182
>
9283
<div class="layout-header-l">
9384
<div class="layout-header-trigger hover" @click="collapsedSide">
94-
<i
95-
class="el-icon-s-fold fs-20 menu-icon"
96-
:class="{ 'rotate-icon': isCollapsed }"
97-
/>
85+
<i class="el-icon-s-fold fs-20 menu-icon" :class="{ 'rotate-icon': isCollapsed }" />
9886
</div>
9987
<div class="layout-header-breadcrumb">
10088
<el-breadcrumb separator="/">
101-
<el-breadcrumb-item :to="{ path: '/' }"
102-
>首页</el-breadcrumb-item
103-
>
89+
<el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
10490
<template v-for="menu in pageData.menuList">
105-
<el-breadcrumb-item
106-
v-if="menu.route == route"
107-
:key="menu.route"
108-
>{{ menu.title }}</el-breadcrumb-item
109-
>
91+
<el-breadcrumb-item v-if="menu.route == route" :key="menu.route">{{ menu.title }}</el-breadcrumb-item>
11092
</template>
11193
</el-breadcrumb>
11294
</div>
@@ -125,9 +107,11 @@
125107
<el-dropdown>
126108
<div class="layout-header-user">
127109
<el-avatar :src="pageData.user.avatar" :size="25" />
128-
<span class="layout-header-user-name">{{
110+
<span class="layout-header-user-name">
111+
{{
129112
pageData.user.name
130-
}}</span>
113+
}}
114+
</span>
131115
</div>
132116
<el-dropdown-menu slot="dropdown">
133117
<a @click="onLogout">
@@ -147,7 +131,7 @@
147131
</div>
148132
</div>
149133
</el-header>
150-
<el-main :class="{ 'el-main-fixed': fixedHeader }">
134+
<el-main :class="{ 'el-main-fixed': fixedHeader }" ref="mainView">
151135
<div class="layout-content-main">
152136
<router-view></router-view>
153137
</div>
@@ -156,15 +140,13 @@
156140
<div ref="rootFooter">
157141
<div class="footer-links">
158142
<el-link
159-
160143
v-for="(item, index) in pageData.footerLinks"
161144
:key="index"
162145
type="text"
163146
:href="item.href"
164147
target="_blank"
165148
:underline="false"
166-
>{{ item.title }}</el-link
167-
>
149+
>{{ item.title }}</el-link>
168150
</div>
169151
<div v-html="pageData.copyright"></div>
170152
</div>
@@ -179,22 +161,14 @@
179161
<el-badge type="success" is-dot :hidden="isDark">
180162
<div>
181163
<el-tooltip content="亮色菜单风格" placement="top">
182-
<img
183-
@click="isDark = false"
184-
class="hover"
185-
src="../assets/menu-light.svg"
186-
/>
164+
<img @click="isDark = false" class="hover" src="../assets/menu-light.svg" />
187165
</el-tooltip>
188166
</div>
189167
</el-badge>
190168
<el-badge type="success" is-dot :hidden="!isDark">
191169
<div class="ml-20">
192170
<el-tooltip content="暗色菜单风格" placement="top">
193-
<img
194-
@click="isDark = true"
195-
class="hover"
196-
src="../assets/menu-dark.svg"
197-
/>
171+
<img @click="isDark = true" class="hover" src="../assets/menu-dark.svg" />
198172
</el-tooltip>
199173
</div>
200174
</el-badge>
@@ -270,7 +244,7 @@ export default {
270244
this.route = to.path;
271245
this.query = to.query;
272246
let queryKey = [];
273-
_.forEach(this.query, function(value, key) {
247+
_.forEach(this.query, function (value, key) {
274248
queryKey.push(key + "=" + value);
275249
});
276250
this.route =
@@ -291,7 +265,7 @@ export default {
291265
this.$message[type](message);
292266
});
293267
this.$nextTick(() => {
294-
window.rootFooterHeight = this.$refs.rootFooter.offsetHeight + 60;
268+
window.rootFooterHeight = this.$refs.rootFooter.offsetHeight +20;
295269
});
296270
},
297271
destroyed() {

resources/js/components/grid/Table.vue

Lines changed: 37 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
<template>
22
<div class="grid-container">
33
<div ref="topView">
4-
<component
5-
v-if="attrs.top"
6-
:is="attrs.top.componentName"
7-
:attrs="attrs.top"
8-
/>
4+
<component v-if="attrs.top" :is="attrs.top.componentName" :attrs="attrs.top" />
95
<el-card
106
shadow="never"
117
:body-style="{ padding: 0 }"
@@ -66,9 +62,7 @@
6662
@clear="getData"
6763
@keyup.enter.native="getData"
6864
>
69-
<el-button @click="getData" :loading="loading" slot="append"
70-
>搜索</el-button
71-
>
65+
<el-button @click="getData" :loading="loading" slot="append">搜索</el-button>
7266
</el-input>
7367
</div>
7468
<div class="flex-c">
@@ -87,18 +81,10 @@
8781
:is="component.componentName"
8882
:attrs="component"
8983
/>
90-
<el-divider
91-
direction="vertical"
92-
v-if="!attrs.attributes.hideCreateButton"
93-
></el-divider>
84+
<el-divider direction="vertical" v-if="!attrs.attributes.hideCreateButton"></el-divider>
9485
<div class="icon-actions">
9586
<el-dropdown trigger="click">
96-
<el-tooltip
97-
class="item"
98-
effect="dark"
99-
content="密度"
100-
placement="top"
101-
>
87+
<el-tooltip class="item" effect="dark" content="密度" placement="top">
10288
<i class="el-icon-rank hover"></i>
10389
</el-tooltip>
10490
<el-dropdown-menu slot="dropdown">
@@ -117,12 +103,7 @@
117103
</el-dropdown-menu>
118104
</el-dropdown>
119105

120-
<el-tooltip
121-
class="item"
122-
effect="dark"
123-
content="刷新"
124-
placement="top"
125-
>
106+
<el-tooltip class="item" effect="dark" content="刷新" placement="top">
126107
<i class="el-icon-refresh hover" @click="getData"></i>
127108
</el-tooltip>
128109
</div>
@@ -149,16 +130,8 @@
149130
@sort-change="onTableSortChange"
150131
@selection-change="onTableselectionChange"
151132
>
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>
133+
<el-table-column v-if="attrs.attributes.selection" align="center" type="selection"></el-table-column>
134+
<el-table-column v-if="attrs.tree" align="center" width="50"></el-table-column>
162135
<template v-for="column in attrs.columnAttributes">
163136
<el-table-column
164137
:type="column.type"
@@ -175,19 +148,12 @@
175148
>
176149
<template slot="header" slot-scope="scope">
177150
<span>{{ scope.column.label }}</span>
178-
<el-tooltip
179-
placement="top"
180-
v-if="column.help"
181-
:content="column.help"
182-
>
151+
<el-tooltip placement="top" v-if="column.help" :content="column.help">
183152
<i class="el-icon-question hover"></i>
184153
</el-tooltip>
185154
</template>
186155
<template slot-scope="scope">
187-
<ColumnDisplay
188-
:scope="scope"
189-
:columns="attrs.columnAttributes"
190-
/>
156+
<ColumnDisplay :scope="scope" :columns="attrs.columnAttributes" />
191157
</template>
192158
</el-table-column>
193159
</template>
@@ -211,7 +177,7 @@
211177
</el-table-column>
212178
</el-table>
213179
</div>
214-
<div class="table-page padding-xs" v-if="!attrs.hidePage">
180+
<div ref="pageView" class="table-page padding-xs" v-if="!attrs.hidePage">
215181
<el-pagination
216182
:layout="attrs.pageLayout"
217183
:hide-on-single-page="false"
@@ -225,11 +191,10 @@
225191
/>
226192
</div>
227193
</el-card>
228-
<component
229-
v-if="attrs.bottom"
230-
:is="attrs.bottom.componentName"
231-
:attrs="attrs.bottom"
232-
/>
194+
<div ref="bottomComponentView">
195+
<component v-if="attrs.bottom" :is="attrs.bottom.componentName" :attrs="attrs.bottom" />
196+
</div>
197+
233198
<DialogForm
234199
ref="DialogGridFrom"
235200
v-if="attrs.dialogForm"
@@ -279,6 +244,8 @@ export default {
279244
tabsActiveName: "all",
280245
topViewHeight: 0,
281246
toolbarsViewHeight: 0,
247+
pageViewHeight: 0,
248+
bottomComponentViewHeight: 0,
282249
};
283250
},
284251
@@ -332,7 +299,11 @@ export default {
332299
333300
this.$nextTick(() => {
334301
this.topViewHeight = this.$refs.topView.offsetHeight;
302+
335303
this.toolbarsViewHeight = this.$refs.toolbarsView.offsetHeight;
304+
305+
this.pageViewHeight = this.$refs.pageView.offsetHeight;
306+
this.bottomComponentViewHeight = this.$refs.bottomComponentView.offsetHeight;
336307
});
337308
},
338309
destroyed() {
@@ -363,19 +334,18 @@ export default {
363334
//获取数据
364335
getData() {
365336
this.loading = true;
366-
this.$http
367-
[this.attrs.method](this.attrs.dataUrl, {
368-
params: {
369-
get_data: true,
370-
page: this.page,
371-
per_page: this.pageData.pageSize,
372-
...this.sort,
373-
...this.q_search,
374-
...this.filterFormData,
375-
...this.tabsSelectdata,
376-
...this.$route.query,
377-
},
378-
})
337+
this.$http[this.attrs.method](this.attrs.dataUrl, {
338+
params: {
339+
get_data: true,
340+
page: this.page,
341+
per_page: this.pageData.pageSize,
342+
...this.sort,
343+
...this.q_search,
344+
...this.filterFormData,
345+
...this.tabsSelectdata,
346+
...this.$route.query,
347+
},
348+
})
379349
.then(({ data }) => {
380350
if (!this.attrs.hidePage) {
381351
this.tableData = data.data;
@@ -486,10 +456,12 @@ export default {
486456
return (
487457
window.innerHeight -
488458
55 -
459+
20 -
489460
window.rootFooterHeight -
490-
(this.topViewHeight > 0 ? this.topViewHeight + 10 : 0) -
491-
25 -
492-
this.toolbarsViewHeight
461+
this.topViewHeight -
462+
(this.toolbarsViewHeight > 0 ? this.toolbarsViewHeight + 12 : 0) -
463+
this.pageViewHeight -
464+
this.bottomComponentViewHeight
493465
);
494466
}
495467
return this.attrs.attributes.height;

src/Auth/Database/Administrator.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ class Administrator extends Model implements AuthenticatableContract
2323

2424
protected $casts = [
2525
'images' => 'array',
26-
'created_at' => "Y-m-d H:i:s",
27-
'updated_at' => "Y-m-d H:i:s",
26+
'created_at' => "timestamp:Y-m-d H:i:s",
27+
'updated_at' => "timestamp:Y-m-d H:i:s",
2828
];
2929

3030
/**

src/Auth/Database/Menu.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ class Menu extends Model
3030

3131
protected $casts = [
3232
'permission' => 'array',
33-
'created_at' => "Y-m-d H:i:s",
34-
'updated_at' => "Y-m-d H:i:s",
33+
'created_at' => "timestamp:Y-m-d H:i:s",
34+
'updated_at' => "timestamp:Y-m-d H:i:s",
3535
];
3636

3737
/**

src/Auth/Database/OperationLog.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ class OperationLog extends Model
2222
];
2323

2424
protected $casts = [
25-
'created_at'=>"Y-m-d H:i:s",
26-
'updated_at'=>"Y-m-d H:i:s",
25+
'created_at'=>"timestamp:Y-m-d H:i:s",
26+
'updated_at'=>"timestamp:Y-m-d H:i:s",
2727
];
2828

2929
/**

0 commit comments

Comments
 (0)