dict.ts 798 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. import {
  2. VuexModule,
  3. Module,
  4. getModule,
  5. Mutation,
  6. Action
  7. } from "vuex-module-decorators";
  8. import store from "../index";
  9. import { getDict } from "@/api/dict";
  10. import i18n from "@/lang";
  11. import vue from "vue";
  12. @Module({ dynamic: true, store, name: "dict", namespaced: true })
  13. class Dict extends VuexModule {
  14. private data: {
  15. [index: string]: IDicts;
  16. } = {};
  17. @Action
  18. public async getList() {
  19. const list = await getDict();
  20. this.setList(list);
  21. }
  22. @Mutation
  23. private setList(list: IDicts) {
  24. vue.set(this.data, i18n.locale, list);
  25. }
  26. get list() {
  27. return this.data[i18n.locale] || {};
  28. }
  29. get companyType() {
  30. return this.list.company_type || [];
  31. }
  32. get examineStatus() {
  33. return this.list.examine_status || [];
  34. }
  35. }
  36. export default getModule(Dict);