Skip to content

Commit f594bd5

Browse files
committed
优化内置 Action
添加 vuex 功能,保存页面组件数据状态(没有保存grid数据状态)
1 parent 0bd9035 commit f594bd5

File tree

22 files changed

+169052
-42
lines changed

22 files changed

+169052
-42
lines changed

docs/grid.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -684,6 +684,17 @@ $actions->hideEditAction()
684684
$actions->hideDeleteAction()
685685
```
686686

687+
#### 编辑/删除操作
688+
689+
基于el-button实现
690+
691+
```php
692+
$actions->editAction()->disabled(true);//获取编辑操作实例,并置属性
693+
$actions->deleteAction()->message("确定要删除吗,删除不可恢复?");//获取删除操作实例
694+
```
695+
696+
697+
687698
#### 添加自定义操作
688699

689700
创建自定义操作请查看 [如何创建自定义操作](https://smallruraldog.github.io/laravel-vue-admin/#/custom?id=%e8%a1%a8%e6%a0%bc%e6%93%8d%e4%bd%9c%e7%bb%84%e4%bb%b6)

package-lock.json

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
},
3636
"dependencies": {
3737
"awe-dnd": "^0.3.4",
38-
"url-loader": "^3.0.0"
38+
"url-loader": "^3.0.0",
39+
"vuex": "^3.1.3"
3940
}
4041
}

public/app.js

Lines changed: 41333 additions & 1 deletion
Large diffs are not rendered by default.

public/manifest.js

Lines changed: 154 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,154 @@
1-
!function(e){function r(r){for(var n,l,f=r[0],i=r[1],a=r[2],c=0,s=[];c<f.length;c++)l=f[c],Object.prototype.hasOwnProperty.call(o,l)&&o[l]&&s.push(o[l][0]),o[l]=0;for(n in i)Object.prototype.hasOwnProperty.call(i,n)&&(e[n]=i[n]);for(p&&p(r);s.length;)s.shift()();return u.push.apply(u,a||[]),t()}function t(){for(var e,r=0;r<u.length;r++){for(var t=u[r],n=!0,f=1;f<t.length;f++){var i=t[f];0!==o[i]&&(n=!1)}n&&(u.splice(r--,1),e=l(l.s=t[0]))}return e}var n={},o={1:0},u=[];function l(r){if(n[r])return n[r].exports;var t=n[r]={i:r,l:!1,exports:{}};return e[r].call(t.exports,t,t.exports,l),t.l=!0,t.exports}l.m=e,l.c=n,l.d=function(e,r,t){l.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:t})},l.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},l.t=function(e,r){if(1&r&&(e=l(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var t=Object.create(null);if(l.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var n in e)l.d(t,n,function(r){return e[r]}.bind(null,n));return t},l.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return l.d(r,"a",r),r},l.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},l.p="/";var f=window.webpackJsonp=window.webpackJsonp||[],i=f.push.bind(f);f.push=r,f=f.slice();for(var a=0;a<f.length;a++)r(f[a]);var p=i;t()}([]);
1+
/******/ (function(modules) { // webpackBootstrap
2+
/******/ // install a JSONP callback for chunk loading
3+
/******/ function webpackJsonpCallback(data) {
4+
/******/ var chunkIds = data[0];
5+
/******/ var moreModules = data[1];
6+
/******/ var executeModules = data[2];
7+
/******/
8+
/******/ // add "moreModules" to the modules object,
9+
/******/ // then flag all "chunkIds" as loaded and fire callback
10+
/******/ var moduleId, chunkId, i = 0, resolves = [];
11+
/******/ for(;i < chunkIds.length; i++) {
12+
/******/ chunkId = chunkIds[i];
13+
/******/ if(Object.prototype.hasOwnProperty.call(installedChunks, chunkId) && installedChunks[chunkId]) {
14+
/******/ resolves.push(installedChunks[chunkId][0]);
15+
/******/ }
16+
/******/ installedChunks[chunkId] = 0;
17+
/******/ }
18+
/******/ for(moduleId in moreModules) {
19+
/******/ if(Object.prototype.hasOwnProperty.call(moreModules, moduleId)) {
20+
/******/ modules[moduleId] = moreModules[moduleId];
21+
/******/ }
22+
/******/ }
23+
/******/ if(parentJsonpFunction) parentJsonpFunction(data);
24+
/******/
25+
/******/ while(resolves.length) {
26+
/******/ resolves.shift()();
27+
/******/ }
28+
/******/
29+
/******/ // add entry modules from loaded chunk to deferred list
30+
/******/ deferredModules.push.apply(deferredModules, executeModules || []);
31+
/******/
32+
/******/ // run deferred modules when all chunks ready
33+
/******/ return checkDeferredModules();
34+
/******/ };
35+
/******/ function checkDeferredModules() {
36+
/******/ var result;
37+
/******/ for(var i = 0; i < deferredModules.length; i++) {
38+
/******/ var deferredModule = deferredModules[i];
39+
/******/ var fulfilled = true;
40+
/******/ for(var j = 1; j < deferredModule.length; j++) {
41+
/******/ var depId = deferredModule[j];
42+
/******/ if(installedChunks[depId] !== 0) fulfilled = false;
43+
/******/ }
44+
/******/ if(fulfilled) {
45+
/******/ deferredModules.splice(i--, 1);
46+
/******/ result = __webpack_require__(__webpack_require__.s = deferredModule[0]);
47+
/******/ }
48+
/******/ }
49+
/******/
50+
/******/ return result;
51+
/******/ }
52+
/******/
53+
/******/ // The module cache
54+
/******/ var installedModules = {};
55+
/******/
56+
/******/ // object to store loaded and loading chunks
57+
/******/ // undefined = chunk not loaded, null = chunk preloaded/prefetched
58+
/******/ // Promise = chunk loading, 0 = chunk loaded
59+
/******/ var installedChunks = {
60+
/******/ "/manifest": 0
61+
/******/ };
62+
/******/
63+
/******/ var deferredModules = [];
64+
/******/
65+
/******/ // The require function
66+
/******/ function __webpack_require__(moduleId) {
67+
/******/
68+
/******/ // Check if module is in cache
69+
/******/ if(installedModules[moduleId]) {
70+
/******/ return installedModules[moduleId].exports;
71+
/******/ }
72+
/******/ // Create a new module (and put it into the cache)
73+
/******/ var module = installedModules[moduleId] = {
74+
/******/ i: moduleId,
75+
/******/ l: false,
76+
/******/ exports: {}
77+
/******/ };
78+
/******/
79+
/******/ // Execute the module function
80+
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
81+
/******/
82+
/******/ // Flag the module as loaded
83+
/******/ module.l = true;
84+
/******/
85+
/******/ // Return the exports of the module
86+
/******/ return module.exports;
87+
/******/ }
88+
/******/
89+
/******/
90+
/******/ // expose the modules object (__webpack_modules__)
91+
/******/ __webpack_require__.m = modules;
92+
/******/
93+
/******/ // expose the module cache
94+
/******/ __webpack_require__.c = installedModules;
95+
/******/
96+
/******/ // define getter function for harmony exports
97+
/******/ __webpack_require__.d = function(exports, name, getter) {
98+
/******/ if(!__webpack_require__.o(exports, name)) {
99+
/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
100+
/******/ }
101+
/******/ };
102+
/******/
103+
/******/ // define __esModule on exports
104+
/******/ __webpack_require__.r = function(exports) {
105+
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
106+
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
107+
/******/ }
108+
/******/ Object.defineProperty(exports, '__esModule', { value: true });
109+
/******/ };
110+
/******/
111+
/******/ // create a fake namespace object
112+
/******/ // mode & 1: value is a module id, require it
113+
/******/ // mode & 2: merge all properties of value into the ns
114+
/******/ // mode & 4: return value when already ns object
115+
/******/ // mode & 8|1: behave like require
116+
/******/ __webpack_require__.t = function(value, mode) {
117+
/******/ if(mode & 1) value = __webpack_require__(value);
118+
/******/ if(mode & 8) return value;
119+
/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
120+
/******/ var ns = Object.create(null);
121+
/******/ __webpack_require__.r(ns);
122+
/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
123+
/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
124+
/******/ return ns;
125+
/******/ };
126+
/******/
127+
/******/ // getDefaultExport function for compatibility with non-harmony modules
128+
/******/ __webpack_require__.n = function(module) {
129+
/******/ var getter = module && module.__esModule ?
130+
/******/ function getDefault() { return module['default']; } :
131+
/******/ function getModuleExports() { return module; };
132+
/******/ __webpack_require__.d(getter, 'a', getter);
133+
/******/ return getter;
134+
/******/ };
135+
/******/
136+
/******/ // Object.prototype.hasOwnProperty.call
137+
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
138+
/******/
139+
/******/ // __webpack_public_path__
140+
/******/ __webpack_require__.p = "/";
141+
/******/
142+
/******/ var jsonpArray = window["webpackJsonp"] = window["webpackJsonp"] || [];
143+
/******/ var oldJsonpFunction = jsonpArray.push.bind(jsonpArray);
144+
/******/ jsonpArray.push = webpackJsonpCallback;
145+
/******/ jsonpArray = jsonpArray.slice();
146+
/******/ for(var i = 0; i < jsonpArray.length; i++) webpackJsonpCallback(jsonpArray[i]);
147+
/******/ var parentJsonpFunction = oldJsonpFunction;
148+
/******/
149+
/******/
150+
/******/ // run deferred modules from other chunks
151+
/******/ checkDeferredModules();
152+
/******/ })
153+
/************************************************************************/
154+
/******/ ([]);

public/mix-manifest.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"/app.js": "/app.js?id=d8f330d4af66dfc8e804",
3-
"/manifest.js": "/manifest.js?id=3c768977c2574a34506e",
4-
"/vendor.js": "/vendor.js?id=5a30bc9bc2e005aa1c33"
2+
"/app.js": "/app.js?id=bfd0d0adc70a3b997342",
3+
"/manifest.js": "/manifest.js?id=d9708e48a6c10ccee4bb",
4+
"/vendor.js": "/vendor.js?id=f4679ac178c0e413cb28"
55
}

public/vendor.js

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

resources/js/Admin.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import VueBus from 'vue-bus';
33
import axios from './util/axios'
44
import lodash from 'lodash'
55
import router from '@/router'
6+
import store from '@/store'
67
import {
78
LoadingBar,
89
Message,
@@ -22,6 +23,8 @@ Vue.prototype.$http = axios;
2223
Vue.prototype._ = lodash;
2324
window._ = lodash;
2425
Vue.use(VueBus);
26+
27+
2528
import './styles/admin.scss';
2629

2730
export default class VueAdmin {
@@ -44,6 +47,7 @@ export default class VueAdmin {
4447
this.boot();
4548
this.app = new Vue({
4649
el: '#vue-admin',
50+
store,
4751
router
4852
});
4953
}

resources/js/components/grid/Table.vue

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
<template>
22
<div class="grid-container">
33
<el-card shadow="never" :body-style="{ padding: 0 }">
4-
54
<div class="grid-top-container">
65
<div class="grid-top-container-left">
76
<BatchActions
@@ -10,14 +9,13 @@
109
:rows="selectionRows"
1110
v-if="attrs.selection"
1211
/>
13-
<div class="search-view mr-10" v-if="attrs.quickSearch">
12+
<div class="search-view mr-10" v-if="attrs.quickSearch">
1413
<el-input
1514
v-model="quickSearch"
1615
:placeholder="attrs.quickSearch.placeholder"
1716
:clearable="true"
1817
@clear="getData"
1918
@keyup.enter.native="getData"
20-
2119
>
2220
<el-button @click="getData" :loading="loading" slot="append"
2321
>搜索</el-button
@@ -88,15 +86,15 @@
8886
:body-style="{ padding: 0 }"
8987
v-loading="loading"
9088
>
91-
<el-tabs v-if="false">
89+
<el-tabs v-if="false">
9290
<el-tab-pane label="全部" name="first"></el-tab-pane>
9391
<el-tab-pane label="代付款" name="second"></el-tab-pane>
9492
<el-tab-pane label="代发货" name="third"></el-tab-pane>
9593
<el-tab-pane label="待收货" name="third2"></el-tab-pane>
9694
<el-tab-pane label="已完成" name="third3"></el-tab-pane>
9795
<el-tab-pane label="已关闭" name="third4"></el-tab-pane>
9896
</el-tabs>
99-
<div class="filter-form" v-if="attrs.filter.filters.length > 0">
97+
<div class="filter-form" v-if="attrs.filter.filters.length > 0">
10098
<el-form
10199
:inline="true"
102100
label-suffix=""
@@ -121,7 +119,7 @@
121119
</el-form-item>
122120
</el-form>
123121
</div>
124-
122+
125123
<div>
126124
<el-table
127125
:data="tableData"
@@ -181,10 +179,7 @@
181179
</template>
182180
</el-table-column>
183181
</template>
184-
<el-table-column
185-
v-if="attrs.actions && !attrs.actions.hide"
186-
label=""
187-
>
182+
<el-table-column v-if="attrs.actions && !attrs.actions.hide" label="">
188183
<template slot="header"></template>
189184
<template slot-scope="scope">
190185
<Actions
@@ -250,6 +245,7 @@ export default {
250245
this.filterFormData = this._.cloneDeep(this.attrs.filter.filterFormData);
251246
252247
this.getData();
248+
253249
this.$bus.on("tableReload", () => {
254250
this.getData();
255251
});
@@ -266,7 +262,7 @@ export default {
266262
},
267263
onFilterReset() {
268264
console.log(this.attrs.filter.filterFormData);
269-
265+
270266
this.filterFormData = this._.cloneDeep(this.attrs.filter.filterFormData);
271267
this.getData();
272268
},
@@ -394,9 +390,9 @@ export default {
394390
.filter-form {
395391
padding: 10px;
396392
border-bottom: 1px solid #ebeef5;
397-
.el-form-item{
393+
.el-form-item {
398394
margin-bottom: 0px;
399-
.el-form-item__label{
395+
.el-form-item__label {
400396
padding: 0;
401397
}
402398
}

resources/js/components/layout/Base.vue

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<div
33
style="min-height:150px;"
44
v-loading="loading"
5-
element-loading-spinner="el-icon-loading"
5+
element-loading-spinner="el-icon-loading"
66
element-loading-background="rgba(0, 0, 0, 0)"
77
>
88
<component
@@ -28,6 +28,7 @@ export default {
2828
this.$bus.on("route-after", to => {
2929
this.path = to.path;
3030
this.query = to.query;
31+
this.loading = true;
3132
this.$nextTick(() => {
3233
this.getContent();
3334
});
@@ -38,7 +39,29 @@ export default {
3839
},
3940
methods: {
4041
getContent() {
41-
this.loading = true;
42+
let componentData = this._.get(this.$store.state.contents, this.path);
43+
if (componentData) {
44+
this.componentData = componentData;
45+
this.loading = false;
46+
} else {
47+
this.$store
48+
.dispatch("getCenten", {
49+
path: this.path,
50+
contentUrl: window.config.apiRoot + this.path,
51+
params: {
52+
...this.query
53+
}
54+
})
55+
.then(data => {
56+
this.componentData = data;
57+
this.loading = false;
58+
})
59+
.catch(() => {
60+
this.loading = false;
61+
});
62+
}
63+
64+
/*this.loading = true;
4265
let contentUrl = window.config.apiRoot + this.path;
4366
this.$http
4467
.get(contentUrl, {
@@ -50,7 +73,7 @@ export default {
5073
this.componentData = data;
5174
this.loading = false;
5275
})
53-
.catch(() => {});
76+
.catch(() => {});*/
5477
}
5578
}
5679
};

0 commit comments

Comments
 (0)