lrf402788946 5 년 전
부모
커밋
b3a7d13fd8
6개의 변경된 파일68개의 추가작업 그리고 23개의 파일을 삭제
  1. 6 6
      src/router/index.js
  2. 2 0
      src/store/index.js
  3. 38 0
      src/store/location.js
  4. 3 4
      src/views/classes/index.vue
  5. 1 1
      src/views/place/detail.vue
  6. 18 12
      src/views/place/index.vue

+ 6 - 6
src/router/index.js

@@ -112,14 +112,14 @@ const routes = [
         component: () => import('@/views/dept/detail.vue'),
       },
       {
-        path: '/place/index',
-        name: 'place_index',
-        component: () => import('@/views/place/index.vue'),
+        path: '/location/index',
+        name: 'location_index',
+        component: () => import('@/views/location/index.vue'),
       },
       {
-        path: '/place/detail',
-        name: 'place_detail',
-        component: () => import('@/views/place/detail.vue'),
+        path: '/location/detail',
+        name: 'location_detail',
+        component: () => import('@/views/location/detail.vue'),
       },
       {
         path: '/bedroom/index',

+ 2 - 0
src/store/index.js

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

+ 38 - 0
src/store/location.js

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

+ 3 - 4
src/views/classes/index.vue

@@ -9,8 +9,8 @@
 <script>
 import listFrame from '@frame/layout/admin/list-frame';
 import dataTable from '@frame/components/data-table';
-import { mapActions, mapState, createNamespacedHelpers } from 'vuex';
-const { mapActions: mapClass } = createNamespacedHelpers('classes');
+import { createNamespacedHelpers } from 'vuex';
+const { mapActions } = createNamespacedHelpers('classes');
 export default {
   metaInfo: { title: '班级管理' },
   name: 'index',
@@ -47,11 +47,10 @@ export default {
   },
   computed: {},
   methods: {
-    ...mapClass(['query', 'delete']),
+    ...mapActions(['query', 'delete']),
     async search({ skip = 0, limit = 15, ...info } = {}) {
       const res = await this.query({ skip, limit, ...info });
       if (this.$checkRes(res)) {
-        console.log(res);
         this.$set(this, `list`, res.data);
         this.$set(this, `total`, res.total);
       }

+ 1 - 1
src/views/place/detail.vue

@@ -1,6 +1,6 @@
 <template>
   <div id="detail">
-    <detail-frame title="地点信息" returns="/dept/index">
+    <detail-frame title="地点信息" returns="/location/index">
       <data-form :data="info" :fields="fields" :rules="rules" @save="handleSave" :isNew="isNew"> </data-form>
     </detail-frame>
   </div>

+ 18 - 12
src/views/place/index.vue

@@ -1,6 +1,6 @@
 <template>
   <div id="index">
-    <list-frame title="地点管理" @query="search" :needFilter="false" @add="$router.push({ path: '/place/detail' })">
+    <list-frame title="地点管理" @query="search" :total="total" :needFilter="false" @add="$router.push({ path: '/location/detail' })">
       <data-table :fields="fields" :data="list" :opera="opera" @edit="toEdit" @deltet="toDelete"></data-table>
     </list-frame>
   </div>
@@ -9,6 +9,8 @@
 <script>
 import listFrame from '@frame/layout/admin/list-frame';
 import dataTable from '@frame/components/data-table';
+import { createNamespacedHelpers } from 'vuex';
+const { mapActions } = createNamespacedHelpers('location');
 export default {
   metaInfo: { title: '地点管理' },
   name: 'index',
@@ -30,22 +32,26 @@ export default {
         method: 'delete',
       },
     ],
-    fields: [{ label: '地点', prop: 'placename' }],
-    list: [
-      { id: 1, placename: '501' },
-      { id: 2, placename: '502' },
-    ],
+    fields: [{ label: '地点', prop: 'name' }],
+    list: [],
+    total: 0,
   }),
-  created() {},
+  created() {
+    this.search();
+  },
   computed: {},
   methods: {
-    search({ skip = 0, limit = 15, ...info } = {}) {
-      console.log(`in search`);
+    ...mapActions(['query', 'delete']),
+    async search({ skip = 0, limit = 15, ...info } = {}) {
+      const res = await this.query({ skip, limit, ...info });
+      if (this.$checkRes(res)) {
+        console.log(res);
+        this.$set(this, `list`, res.data);
+        this.$set(this, `total`, res.total);
+      }
     },
     toEdit(data) {
-      console.log(`in toEdit`);
-      console.log(data);
-      this.$router.push({ path: '/place/detail', query: { id: data.id } });
+      this.$router.push({ path: '/location/detail', query: { id: data.id } });
     },
     toDelete(data) {
       console.log(`in toDelete`);