Browse Source

Merge branch 'master' of http://git.cc-lotus.info/new_train/frame

lrf402788946 5 years ago
parent
commit
f81cdf958b
1 changed files with 33 additions and 0 deletions
  1. 33 0
      store/dictionary.js

+ 33 - 0
store/dictionary.js

@@ -0,0 +1,33 @@
+import Vue from 'vue';
+import Vuex from 'vuex';
+import _ from 'lodash';
+Vue.use(Vuex);
+const api = {
+  dictionary: type => `/api/code/${type}/items`, //type === xzqh:query:level(1/2);parent(无/code)
+};
+const state = () => ({});
+const mutations = {};
+
+const actions = {
+  // 字典表
+  async dicOperation({ state }, type) {
+    let result;
+    if (!_.isObject(type)) {
+      result = await this.$axios.$get(api.dictionary(type));
+    } else {
+      let { level, parent, name } = type;
+      if (name) {
+        result = await this.$axios.$get(api.findOne, {}, { name: name });
+      } else {
+        result = await this.$axios.$get(api.dictionary(type), { level: level, parent: parent });
+      }
+    }
+    return result;
+  },
+};
+export default {
+  namespaced: true,
+  state,
+  mutations,
+  actions,
+};