Browse Source

接口连接更新

guhongwei 5 năm trước cách đây
mục cha
commit
06ff4d2639
4 tập tin đã thay đổi với 57 bổ sung3 xóa
  1. 4 1
      src/store/index.js
  2. 38 0
      src/store/otheruser.js
  3. 10 2
      src/views/otheruser/index.vue
  4. 5 0
      vue.config.js

+ 4 - 1
src/store/index.js

@@ -1,11 +1,14 @@
 import Vue from 'vue';
 import Vuex from 'vuex';
+import otheruser from './otheruser';
 
 Vue.use(Vuex);
 
 export default new Vuex.Store({
+  modules: {
+    otheruser,
+  },
   state: {},
   mutations: {},
   actions: {},
-  modules: {},
 });

+ 38 - 0
src/store/otheruser.js

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

+ 10 - 2
src/views/otheruser/index.vue

@@ -18,7 +18,8 @@
 import topInfo from '@/layout/common/topInfo.vue';
 import searchInfo from '@/layout/common/searchInfo.vue';
 import otheruserList from '@/layout/otheruser/otheruserList.vue';
-
+import { createNamespacedHelpers, mapGetters } from 'vuex';
+const { mapActions: otheruser } = createNamespacedHelpers('otheruser');
 export default {
   name: 'index',
   props: {},
@@ -48,9 +49,16 @@ export default {
       },
     ],
   }),
-  created() {},
+  created() {
+    this.searchInfo();
+  },
   computed: {},
   methods: {
+    ...otheruser({ otheruserList: 'query' }),
+    async searchInfo({ skip = 10, limit = 10, ...info } = {}) {
+      const res = await this.otheruserList({ skip, limit, ...info });
+      console.log(res);
+    },
     // 添加
     clickBtn() {
       this.$router.push({ path: '/otheruser/detail' });

+ 5 - 0
vue.config.js

@@ -33,6 +33,11 @@ module.exports = {
         changeOrigin: true,
         ws: true,
       },
+      '/api': {
+        target: 'http://10.16.9.108:9001',
+        changeOrigin: true,
+        ws: true,
+      },
     },
   },
 };