Skip to content

Commit 20910b0

Browse files
committed
Grid page加入vuex状态保存
1 parent f5b64c6 commit 20910b0

File tree

10 files changed

+75
-49
lines changed

10 files changed

+75
-49
lines changed

public/app.js

Lines changed: 37 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -530,32 +530,21 @@ __webpack_require__.r(__webpack_exports__);
530530
};
531531
},
532532
mounted: function mounted() {
533-
var _this = this;
534-
535-
this.$Loading.start();
536-
this.$nextTick(function () {
537-
_this.$Loading.finish();
538-
});
533+
this.$nextTick(function () {});
539534
},
540535
methods: {
541536
onForgetPassword: function onForgetPassword() {
542537
this.$Message.info("忘记密码请联系管理员");
543538
},
544539
handleSubmit: function handleSubmit(name) {
545-
var _this2 = this;
540+
var _this = this;
546541

547542
this.$refs[name].validate(function (valid) {
548543
if (valid) {
549-
_this2.loading = true;
550-
551-
_this2.$Loading.start();
552-
553-
_this2.$http.post(_this2.page_data.url.postLogin, _this2.form).then(function () {})["catch"](function () {
554-
_this2.$Loading.error();
555-
})["finally"](function () {
556-
_this2.loading = false;
544+
_this.loading = true;
557545

558-
_this2.$Loading.finish();
546+
_this.$http.post(_this.page_data.url.postLogin, _this.form).then(function () {})["catch"](function () {})["finally"](function () {
547+
_this.loading = false;
559548
});
560549
}
561550
});
@@ -1722,7 +1711,6 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
17221711
data: function data() {
17231712
return {
17241713
loading: false,
1725-
page: 1,
17261714
sort: {},
17271715
tableData: [],
17281716
pageData: {
@@ -1733,8 +1721,7 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
17331721
},
17341722
selectionRows: [],
17351723
quickSearch: null,
1736-
filterFormData: null,
1737-
path: "/"
1724+
filterFormData: null
17381725
};
17391726
},
17401727
mounted: function mounted() {
@@ -1745,7 +1732,6 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
17451732
this.$bus.on("tableReload", function () {
17461733
_this.getData();
17471734
});
1748-
this.path = this.$route.path;
17491735
},
17501736
destroyed: function destroyed() {
17511737
try {
@@ -1757,7 +1743,6 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
17571743
this.getData();
17581744
},
17591745
onFilterReset: function onFilterReset() {
1760-
console.log(this.attrs.filter.filterFormData);
17611746
this.filterFormData = this._.cloneDeep(this.attrs.filter.filterFormData);
17621747
this.getData();
17631748
},
@@ -1820,6 +1805,9 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
18201805
}
18211806
},
18221807
computed: {
1808+
path: function path() {
1809+
return this.$route.path;
1810+
},
18231811
columns: function columns() {
18241812
return this.column_attributes.map(function (attributes) {
18251813
return attributes;
@@ -1835,6 +1823,18 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
18351823
var q_search = new Object();
18361824
this.attrs.quickSearch && (q_search[this.attrs.quickSearch.searchKey] = this.quickSearch);
18371825
return q_search;
1826+
},
1827+
page: {
1828+
get: function get() {
1829+
return this._.get(this.$store.state.grids[this.$route.path], "page", 1);
1830+
},
1831+
set: function set(value) {
1832+
this.$store.commit("setGrids", {
1833+
key: "page",
1834+
path: this.$route.path,
1835+
data: value
1836+
});
1837+
}
18381838
}
18391839
}
18401840
});
@@ -6285,7 +6285,7 @@ exports = module.exports = __webpack_require__(/*! ../../../../node_modules/css-
62856285

62866286

62876287
// module
6288-
exports.push([module.i, ".upload-component {\n display: flex;\n flex-wrap: wrap;\n}\n.upload-component .upload-images {\n display: flex;\n flex-wrap: wrap;\n}\n.upload-component .upload-images .upload-images-item + .upload-images-item {\n margin-left: 10px;\n}\n.upload-component .upload-images .upload-images-item {\n position: relative;\n line-height: 1;\n}\n.upload-component .upload-images .upload-images-item img {\n line-height: 1;\n vertical-align: middle;\n}\n.upload-component .upload-images .upload-images-item .el-image {\n cursor: zoom-in;\n}\n.upload-component .upload-images .upload-images-item .el-icon-document-checked {\n font-size: 30px;\n}\n.upload-component .upload-images .upload-images-item .mask {\n position: absolute;\n transition: all 0.3s ease-in-out;\n opacity: 0;\n background: rgba(0, 0, 0, 0.3);\n color: white;\n font-size: 20px;\n padding: 5px;\n top: 50%;\n left: 50%;\n cursor: pointer;\n transform: translate(-50%, -50%);\n}\n.upload-component .upload-images .upload-images-item:hover .mask {\n opacity: 1;\n}\n.upload-component .upload-images .upload-show-image {\n border: 1px solid #dcdfe6;\n padding: 2px;\n}\n.upload-component .upload-block .el-upload-dragger {\n width: unset;\n height: unset;\n border: none;\n border-radius: 0;\n}\n.upload-component .upload-block .avatar {\n border-radius: 50%;\n}\n.upload-component .upload-block .image,\n.upload-component .upload-block .file {\n border-radius: 0;\n}", ""]);
6288+
exports.push([module.i, ".upload-component {\n display: flex;\n flex-wrap: wrap;\n}\n.upload-component .upload-images {\n display: flex;\n flex-wrap: wrap;\n}\n.upload-component .upload-images .upload-images-item + .upload-images-item {\n margin-left: 10px;\n}\n.upload-component .upload-images .upload-images-item {\n position: relative;\n line-height: 1;\n}\n.upload-component .upload-images .upload-images-item img {\n line-height: 1;\n vertical-align: middle;\n}\n.upload-component .upload-images .upload-images-item .el-image {\n cursor: zoom-in;\n}\n.upload-component .upload-images .upload-images-item .el-icon-document-checked {\n font-size: 30px;\n}\n.upload-component .upload-images .upload-images-item .mask {\n position: absolute;\n transition: all 0.3s ease-in-out;\n opacity: 0;\n background: rgba(0, 0, 0, 0.3);\n color: white;\n font-size: 20px;\n padding: 5px;\n top: 50%;\n left: 50%;\n cursor: pointer;\n transform: translate(-50%, -50%);\n}\n.upload-component .upload-images .upload-images-item:hover .mask {\n opacity: 1;\n}\n.upload-component .upload-images .upload-show-image {\n border: 1px solid #dcdfe6;\n padding: 2px;\n box-sizing: border-box;\n border-radius: 3px;\n}\n.upload-component .upload-block .el-upload-dragger {\n width: unset;\n height: unset;\n border: none;\n border-radius: 0;\n}\n.upload-component .upload-block .avatar {\n border-radius: 50%;\n}", ""]);
62896289

62906290
// exports
62916291

@@ -28165,7 +28165,7 @@ var render = function() {
2816528165
}
2816628166
],
2816728167
staticClass: "form-card",
28168-
attrs: { shadow: "never" }
28168+
attrs: { shadow: "never", title: "创建" }
2816928169
},
2817028170
[
2817128171
_vm.formData
@@ -31133,7 +31133,7 @@ var render = function() {
3113331133
"div",
3113431134
{
3113531135
staticClass: "upload-block",
31136-
class: { "ml-10": _vm.attrs.multiple }
31136+
class: { "ml-10": _vm.list.length > 0 }
3113731137
},
3113831138
[
3113931139
_c(
@@ -41172,7 +41172,8 @@ vue__WEBPACK_IMPORTED_MODULE_0___default.a.use(vuex__WEBPACK_IMPORTED_MODULE_1__
4117241172

4117341173
var store = new vuex__WEBPACK_IMPORTED_MODULE_1__["default"].Store({
4117441174
state: {
41175-
contents: {}
41175+
contents: {},
41176+
grids: {}
4117641177
},
4117741178
mutations: {
4117841179
registerCentent: function registerCentent(state, path) {
@@ -41182,13 +41183,20 @@ var store = new vuex__WEBPACK_IMPORTED_MODULE_1__["default"].Store({
4118241183
var data = _ref.data,
4118341184
path = _ref.path;
4118441185
state.contents[path] = data;
41186+
},
41187+
setGrids: function setGrids(state, _ref2) {
41188+
var key = _ref2.key,
41189+
path = _ref2.path,
41190+
data = _ref2.data;
41191+
41192+
window._.set(state.grids, path + '.' + key, data);
4118541193
}
4118641194
},
4118741195
actions: {
41188-
getCenten: function getCenten(context, _ref2) {
41189-
var path = _ref2.path,
41190-
contentUrl = _ref2.contentUrl,
41191-
params = _ref2.params;
41196+
getCenten: function getCenten(context, _ref3) {
41197+
var path = _ref3.path,
41198+
contentUrl = _ref3.contentUrl,
41199+
params = _ref3.params;
4119241200
return _util_axios__WEBPACK_IMPORTED_MODULE_2__["default"].get(contentUrl, {
4119341201
params: params
4119441202
}).then(function (data) {

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=ba2dae2a5507cab7b802",
2+
"/app.js": "/app.js?id=2a011ad9533d9e63ae56",
33
"/manifest.js": "/manifest.js?id=d9708e48a6c10ccee4bb",
44
"/vendor.js": "/vendor.js?id=736997e66e11f6db997a"
55
}

resources/js/components/Login.vue

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,9 @@ export default {
7979
};
8080
},
8181
mounted() {
82-
this.$Loading.start();
82+
8383
this.$nextTick(() => {
84-
this.$Loading.finish();
84+
8585
});
8686
},
8787
methods: {
@@ -92,16 +92,16 @@ export default {
9292
this.$refs[name].validate(valid => {
9393
if (valid) {
9494
this.loading = true;
95-
this.$Loading.start();
95+
9696
this.$http
9797
.post(this.page_data.url.postLogin, this.form)
9898
.then(() => {})
9999
.catch(() => {
100-
this.$Loading.error();
100+
101101
})
102102
.finally(() => {
103103
this.loading = false;
104-
this.$Loading.finish();
104+
105105
});
106106
}
107107
});

resources/js/components/form/BaseForm.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<template>
22
<div class="form-page">
3-
<el-card shadow="never" class="form-card" v-loading="loading">
3+
<el-card shadow="never" class="form-card" v-loading="loading" title="创建">
44
<el-form
55
v-if="formData"
66
ref="ruleForm"

resources/js/components/grid/Table.vue

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,6 @@ export default {
226226
data() {
227227
return {
228228
loading: false,
229-
page: 1,
230229
sort: {},
231230
tableData: [],
232231
pageData: {
@@ -237,8 +236,7 @@ export default {
237236
},
238237
selectionRows: [],
239238
quickSearch: null,
240-
filterFormData: null,
241-
path: "/"
239+
filterFormData: null
242240
};
243241
},
244242
mounted() {
@@ -249,7 +247,6 @@ export default {
249247
this.$bus.on("tableReload", () => {
250248
this.getData();
251249
});
252-
this.path = this.$route.path;
253250
},
254251
destroyed() {
255252
try {
@@ -261,8 +258,6 @@ export default {
261258
this.getData();
262259
},
263260
onFilterReset() {
264-
console.log(this.attrs.filter.filterFormData);
265-
266261
this.filterFormData = this._.cloneDeep(this.attrs.filter.filterFormData);
267262
this.getData();
268263
},
@@ -320,6 +315,9 @@ export default {
320315
}
321316
},
322317
computed: {
318+
path() {
319+
return this.$route.path;
320+
},
323321
columns() {
324322
return this.column_attributes.map(attributes => {
325323
return attributes;
@@ -336,6 +334,18 @@ export default {
336334
this.attrs.quickSearch &&
337335
(q_search[this.attrs.quickSearch.searchKey] = this.quickSearch);
338336
return q_search;
337+
},
338+
page: {
339+
get() {
340+
return this._.get(this.$store.state.grids[this.$route.path], "page", 1);
341+
},
342+
set(value) {
343+
this.$store.commit("setGrids", {
344+
key: "page",
345+
path: this.$route.path,
346+
data: value
347+
});
348+
}
339349
}
340350
}
341351
};

resources/js/components/widgets/Upload.vue

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
</div>
3636
<div
3737
class="upload-block"
38-
:class="{ 'ml-10': attrs.multiple }"
38+
:class="{ 'ml-10': list.length > 0 }"
3939
v-if="list.length < attrs.limit"
4040
>
4141
<el-upload
@@ -235,6 +235,8 @@ export default {
235235
.upload-show-image {
236236
border: 1px solid #dcdfe6;
237237
padding: 2px;
238+
box-sizing: border-box;
239+
border-radius: 3px;
238240
}
239241
}
240242
.upload-block {
@@ -249,7 +251,7 @@ export default {
249251
}
250252
.image,
251253
.file {
252-
border-radius: 0;
254+
253255
}
254256
}
255257
}

resources/js/store/index.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,18 @@ import http from '@/util/axios'
66

77
const store = new Vuex.Store({
88
state: {
9-
contents: {}
9+
contents: {},
10+
grids: {}
1011
},
1112
mutations: {
1213
registerCentent(state, path) {
1314
state.contents[path] = {}
1415
},
1516
setCenten(state, { data, path }) {
1617
state.contents[path] = data
18+
},
19+
setGrids(state, { key, path, data }) {
20+
window._.set(state.grids, path + '.' + key, data)
1721
}
1822
},
1923
actions: {

resources/views/root.blade.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,2 @@
11
@extends('admin::layouts.base')
2-
@section('content')
3-
<root :page_data='@json($data)'></root>
4-
@endsection
2+
@section('content')<root :page_data='@json($data)'></root>@endsection

src/Auth/Database/Menu.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ public function allNodes(): array
9292
$query = static::query();
9393

9494
if (config('admin.check_menu_roles') !== false) {
95-
$query->with('roles');
95+
$query->with('roles:id,name,slug');
9696
}
9797

9898
$all_list = $query->selectRaw('*, ' . $orderColumn . ' ROOT')->orderByRaw($byOrder)->get()->toArray();

src/helpers.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,10 @@ function admin_url($path = '', $parameters = [], $secure = null)
6565
if (!function_exists('admin_file_url')) {
6666
function admin_file_url($path)
6767
{
68+
if (\Illuminate\Support\Str::contains($path,"//")){
69+
return $path;
70+
}
71+
6872
return \Storage::disk(config('admin.upload.disk'))->url($path);
6973
}
7074
};

0 commit comments

Comments
 (0)