Commit 61ab6382 authored by yyh's avatar yyh

系统模板vuex化

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