Commit 61ab6382 authored by yyh's avatar yyh

系统模板vuex化

parent e6ef3384
...@@ -2,6 +2,7 @@ import { Component, Vue } from 'vue-property-decorator'; ...@@ -2,6 +2,7 @@ import { Component, Vue } from 'vue-property-decorator';
import { State, Action } from 'vuex-class'; import { State, Action } from 'vuex-class';
@Component @Component
export default class Index extends Vue { export default class Index extends Vue {
@State('sysTemplateList', { namespace: 'template'}) protected systemList!: [];
protected ActionList: any = { protected ActionList: any = {
rename: { rename: {
key: 'rename', key: 'rename',
...@@ -16,7 +17,7 @@ export default class Index extends Vue { ...@@ -16,7 +17,7 @@ export default class Index extends Vue {
callback: this.delFolder, callback: this.delFolder,
}, },
}; };
@Action('getSysTemplateList') private getSysTemplateList!: () => void; @Action('getSysTemplateList', { namespace: 'template'}) private getSysTemplateList!: () => void;
protected mounted() { protected mounted() {
this.getSysTemplateList(); this.getSysTemplateList();
} }
......
import Vue from 'vue'; import Vue from 'vue';
import Vuex from 'vuex'; import Vuex from 'vuex';
Vue.use(Vuex); Vue.use(Vuex);
import { proof } from './modules/proof';
import { template } from './modules/template';
export default new Vuex.Store({ export default new Vuex.Store({
state: { state: {
isLogin: false, isLogin: false,
...@@ -14,7 +16,6 @@ export default new Vuex.Store({ ...@@ -14,7 +16,6 @@ export default new Vuex.Store({
authInfo: {}, // 个人认证信息 authInfo: {}, // 个人认证信息
companyAuthInfo: {}, // 企业认证信息 companyAuthInfo: {}, // 企业认证信息
proofCount: 0, proofCount: 0,
sysTemplateList: [],
}, },
getters: { getters: {
isPhone( { userInfo }) { isPhone( { userInfo }) {
...@@ -49,9 +50,6 @@ export default new Vuex.Store({ ...@@ -49,9 +50,6 @@ export default new Vuex.Store({
updateProofCount(state: any, payload: any) { updateProofCount(state: any, payload: any) {
state.proofCount = payload; state.proofCount = payload;
}, },
updateSysTemplateList(state: any, payload: any) {
state.sysTemplateList = payload || [];
},
}, },
actions: { actions: {
getUserInfo({ commit }) { getUserInfo({ commit }) {
...@@ -91,14 +89,9 @@ export default new Vuex.Store({ ...@@ -91,14 +89,9 @@ export default new Vuex.Store({
commit('updateCompanyAuthInfo', res); commit('updateCompanyAuthInfo', res);
}); });
}, },
getSysTemplateList({ commit, state }) {
if (state.sysTemplateList.length <= 0) {
Vue.prototype.$api.template.systemList().then(({results = []}) => {
commit('updateSysTemplateList', results || []);
});
}
},
}, },
modules: { modules: {
proof,
template,
}, },
}); });
import Vue from 'vue';
const $api = Vue.prototype.$api;
const state = {
};
const getters = {
};
const mutations = {
};
const actions = {
getProofList() {
$api.list();
},
};
const namespaced: boolean = true;
export const proof = {
namespaced,
state,
getters,
mutations,
actions,
};
import Vue from 'vue';
const state = {
sysTemplateList: [] = [],
};
const getters = {
};
const mutations = {
updateSysTemplateList(state: any, payload: any) {
state.sysTemplateList = payload || [];
},
};
const actions = {
getSysTemplateList({ commit, state }: any) {
if (state.sysTemplateList.length <= 0) {
Vue.prototype.$api.template.systemList().then(({results = []}) => {
commit('updateSysTemplateList', results || []);
});
}
},
};
const namespaced: boolean = true;
export const template = {
namespaced,
state,
getters,
mutations,
actions,
};
...@@ -29,7 +29,6 @@ import IndexMixin from '@/mixins/Index'; ...@@ -29,7 +29,6 @@ import IndexMixin from '@/mixins/Index';
}, },
}) })
export default class IndexCs extends Mixins(IndexMixin) { export default class IndexCs extends Mixins(IndexMixin) {
@State('sysTemplateList') private systemList!: [];
private charityType: any[] = []; private charityType: any[] = [];
@Watch('systemList', { immediate: true, deep: true }) @Watch('systemList', { immediate: true, deep: true })
private async onChange(newVal: any[], oldVal: any[]) { private async onChange(newVal: any[], oldVal: any[]) {
......
...@@ -81,7 +81,6 @@ export default class IndexSy extends Mixins(IndexMixin) { ...@@ -81,7 +81,6 @@ export default class IndexSy extends Mixins(IndexMixin) {
@Inject('APP-NAME') private APP_NAME!: string; @Inject('APP-NAME') private APP_NAME!: string;
@State('isLogin') private isLogin!: boolean; @State('isLogin') private isLogin!: boolean;
@State('proofCount') private proofCount!: number; @State('proofCount') private proofCount!: number;
@State('sysTemplateList') private systemList!: [];
@Action('getProofCount') private getProofCount!: any; @Action('getProofCount') private getProofCount!: any;
private list: any[] = []; private list: any[] = [];
private currentFolder: object = {}; private currentFolder: object = {};
......
...@@ -48,7 +48,7 @@ ...@@ -48,7 +48,7 @@
<van-tabs v-model="active" > <van-tabs v-model="active" >
<van-tab title="系统模板"> <van-tab title="系统模板">
<div <div
v-for="(folder,index) in systemFolderList" v-for="(folder,index) in systemList"
:key="index" :key="index"
class="item" class="item"
@click="selectFolder(folder)"> @click="selectFolder(folder)">
...@@ -129,8 +129,6 @@ import PreviewTemplate from './PreviewTemplate.vue'; ...@@ -129,8 +129,6 @@ import PreviewTemplate from './PreviewTemplate.vue';
export default class SelectTemplate extends Mixins(IndexMixin) { export default class SelectTemplate extends Mixins(IndexMixin) {
@Inject('isSy') private isSy!: boolean; @Inject('isSy') private isSy!: boolean;
private active: number = 0; private active: number = 0;
@State('sysTemplateList')
private systemFolderList!: [];
private userFolderList: any[] = []; private userFolderList: any[] = [];
private currentFolder: any = {}; private currentFolder: any = {};
private currentTemplate: any = {}; private currentTemplate: any = {};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment