YY 2 éve
szülő
commit
0133c3bfc7
3 módosított fájl, 53 hozzáadás és 6 törlés
  1. 2 0
      src/store/index.js
  2. 44 0
      src/store/module/dev/menus.js
  3. 7 6
      src/views/dev/menu/index.vue

+ 2 - 0
src/store/index.js

@@ -11,6 +11,7 @@ import outBill from './module/statistics/outBill';
 
 import dictIndex from './module/dev/dictIndex';
 import dictData from './module/dev/dictData';
+import menus from './module/dev/menus';
 
 import goodsTags from './module/system/goodsTags';
 import banner from './module/system/banner';
@@ -46,6 +47,7 @@ export default new Vuex.Store({
     goods,
     dictIndex,
     dictData,
+    menus,
     goodsTags,
     banner,
     indexModule,

+ 44 - 0
src/store/module/dev/menus.js

@@ -0,0 +1,44 @@
+import Vue from 'vue';
+import Vuex from 'vuex';
+const _ = require('lodash');
+Vue.use(Vuex);
+const api = {
+  url: '/point/v1/api/menus',
+};
+
+const state = () => ({});
+const mutations = {};
+
+const actions = {
+  async query({ commit }, { skip = 0, limit, ...info } = {}) {
+    const res = await this.$axios.$get(`${api.url}`, {
+      skip,
+      limit,
+      ...info,
+    });
+    return res;
+  },
+  async create({ commit }, payload) {
+    const res = await this.$axios.$post(`${api.url}`, payload);
+    return res;
+  },
+  async fetch({ commit }, payload) {
+    const res = await this.$axios.$get(`${api.url}/${payload}`);
+    return res;
+  },
+  async update({ commit }, payload) {
+    const id = _.get(payload, 'id', _.get(payload, '_id'));
+    const res = await this.$axios.$post(`${api.url}/${id}`, payload);
+    return res;
+  },
+  async delete({ commit }, payload) {
+    const res = await this.$axios.$delete(`${api.url}/${payload}`);
+    return res;
+  },
+};
+export default {
+  namespaced: true,
+  state,
+  mutations,
+  actions,
+};

+ 7 - 6
src/views/dev/menu/index.vue

@@ -120,7 +120,7 @@
 <script>
 const _ = require('lodash');
 import { mapState, createNamespacedHelpers } from 'vuex';
-// const { mapActions: maM } = createNamespacedHelpers('menus');
+const { mapActions: maM } = createNamespacedHelpers('menus');
 // const { mapActions: sysdictdata } = createNamespacedHelpers('dictData');
 
 export default {
@@ -149,12 +149,13 @@ export default {
   },
   methods: {
     // ...sysdictdata({ sQuery: 'query' }),
-    // ...maM(['query', 'create', 'update', 'delete']),
+    ...maM(['query', 'create', 'update', 'delete']),
     async search() {
-      // let res = await this.query();
-      // if (this.$checkRes(res)) {
-      //   this.$set(this, `list`, res.data);
-      // }
+      let res = await this.query();
+      if (this.$checkRes(res)) {
+        console.log(res.data);
+        this.$set(this, `list`, res.data);
+      }
     },
     toAdd() {
       this.dialog = true;