|
@@ -5,24 +5,33 @@ import {
|
|
Mutation,
|
|
Mutation,
|
|
Action
|
|
Action
|
|
} from "vuex-module-decorators";
|
|
} from "vuex-module-decorators";
|
|
-interface IAdd {
|
|
|
|
- k: string;
|
|
|
|
- v: IDict[];
|
|
|
|
-}
|
|
|
|
import store from "../index";
|
|
import store from "../index";
|
|
import { getDict } from "@/api/dict";
|
|
import { getDict } from "@/api/dict";
|
|
-@Module({ dynamic: true, store, name: "dict" })
|
|
|
|
|
|
+import i18n from "@/lang";
|
|
|
|
+import vue from "vue";
|
|
|
|
+@Module({ dynamic: true, store, name: "dict", namespaced: true })
|
|
class Dict extends VuexModule {
|
|
class Dict extends VuexModule {
|
|
- public companyType = getDict("company_type");
|
|
|
|
- public examineStatus = getDict("examine_status");
|
|
|
|
|
|
+ private data: {
|
|
|
|
+ [index: string]: IDicts;
|
|
|
|
+ } = {};
|
|
|
|
+
|
|
|
|
+ @Action
|
|
|
|
+ public async getList() {
|
|
|
|
+ const list = await getDict();
|
|
|
|
+ this.setList(list);
|
|
|
|
+ }
|
|
@Mutation
|
|
@Mutation
|
|
- public add({ k, v }: IAdd) {
|
|
|
|
- switch (k) {
|
|
|
|
- case "company_type":
|
|
|
|
- return (this.companyType = v);
|
|
|
|
- case "examine_status":
|
|
|
|
- return (this.examineStatus = v);
|
|
|
|
- }
|
|
|
|
|
|
+ private setList(list: IDicts) {
|
|
|
|
+ vue.set(this.data, i18n.locale, list);
|
|
|
|
+ }
|
|
|
|
+ get list() {
|
|
|
|
+ return this.data[i18n.locale] || {};
|
|
|
|
+ }
|
|
|
|
+ get companyType() {
|
|
|
|
+ return this.list.company_type || [];
|
|
|
|
+ }
|
|
|
|
+ get examineStatus() {
|
|
|
|
+ return this.list.examine_status || [];
|
|
}
|
|
}
|
|
}
|
|
}
|
|
export default getModule(Dict);
|
|
export default getModule(Dict);
|