Commit e6ef3384 authored by yyh's avatar yyh

代码调整

parent 90cf08b7
...@@ -2,7 +2,6 @@ import { Component, Vue } from 'vue-property-decorator'; ...@@ -2,7 +2,6 @@ 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 {
@Action('getSysTemplateList') private getSysTemplateList!: () => void;
protected ActionList: any = { protected ActionList: any = {
rename: { rename: {
key: 'rename', key: 'rename',
...@@ -17,6 +16,7 @@ export default class Index extends Vue { ...@@ -17,6 +16,7 @@ export default class Index extends Vue {
callback: this.delFolder, callback: this.delFolder,
}, },
}; };
@Action('getSysTemplateList') private getSysTemplateList!: () => void;
protected mounted() { protected mounted() {
this.getSysTemplateList(); this.getSysTemplateList();
} }
......
...@@ -94,7 +94,7 @@ export default new Vuex.Store({ ...@@ -94,7 +94,7 @@ export default new Vuex.Store({
getSysTemplateList({ commit, state }) { getSysTemplateList({ commit, state }) {
if (state.sysTemplateList.length <= 0) { if (state.sysTemplateList.length <= 0) {
Vue.prototype.$api.template.systemList().then(({results = []}) => { Vue.prototype.$api.template.systemList().then(({results = []}) => {
commit('updateSysTemplateList', results); commit('updateSysTemplateList', results || []);
}); });
} }
}, },
......
...@@ -142,16 +142,13 @@ export default class SelectTemplate extends Mixins(IndexMixin) { ...@@ -142,16 +142,13 @@ export default class SelectTemplate extends Mixins(IndexMixin) {
private detail: any[] = []; private detail: any[] = [];
protected mounted() { protected mounted() {
this.$api.template.folderList({ this.getUserFolders();
template_type: 1, }
}).then((res: any) => { private async getUserFolders() {
const ids = (res.results || []).map((folder: any) => folder.id); const { results } = await this.$api.template.folderList({template_type: 1});
return this.$api.template.list({ const ids = (results || []).map((folder: any) => folder.id);
id: ids, const res = await this.$api.template.list({id: ids});
});
}).then((res: any) => {
this.userFolderList = res.results || []; this.userFolderList = res.results || [];
});
} }
private selectFolder(folder: any) { private selectFolder(folder: any) {
this.currentFolder = folder; this.currentFolder = folder;
......
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