guhongwei 4 years ago
parent
commit
a01f30df53
2 changed files with 85 additions and 0 deletions
  1. 7 0
      src/router/index.js
  2. 78 0
      src/views/school/index.vue

+ 7 - 0
src/router/index.js

@@ -169,6 +169,13 @@ const routes = [
         meta: { title: '学生信息', sub: '管理' },
         component: () => import('@/views/student/createStu.vue'),
       },
+      // 09-16
+      {
+        path: '/school/index',
+        name: 'school_index',
+        meta: { title: '学校', sub: '管理' },
+        component: () => import('@/views/school/index.vue'),
+      },
     ],
   },
   {

+ 78 - 0
src/views/school/index.vue

@@ -0,0 +1,78 @@
+<template>
+  <div id="index">
+    <list-frame :title="pageTitle" :needFilter="false" :needPag="false" :needAdd="false">
+      <data-table :fields="fields" :data="list" :opera="opera" @query="search" :total="total"></data-table>
+    </list-frame>
+  </div>
+</template>
+
+<script>
+import _ from 'lodash';
+import listFrame from '@frame/layout/admin/list-frame';
+import dataTable from '@frame/components/filter-page-table';
+import { mapState, createNamespacedHelpers } from 'vuex';
+const { mapActions: school } = createNamespacedHelpers('school');
+const { mapActions: login } = createNamespacedHelpers('login');
+export default {
+  name: 'index',
+  props: {},
+  components: { listFrame, dataTable },
+  data: () => {
+    return {
+      opera: [],
+      fields: [
+        { label: '学校名称', prop: 'name', filter: true },
+        { label: '学校负责人', prop: 'userName' },
+        { label: '学校负责人电话', prop: 'userMobile' },
+        { label: '学校代码', prop: 'code', filter: true },
+        { label: '学校地点', prop: 'address' },
+        { label: '学校简称', prop: 'shortname' },
+      ],
+      list: [],
+      userList: [],
+      total: 0,
+    };
+  },
+  async created() {
+    await this.getOtherList();
+    this.search();
+  },
+  methods: {
+    ...login({ getUserList: 'userList' }),
+    ...school(['query', 'delete']),
+    async search({ skip = 0, limit = 10, ...info } = {}) {
+      const res = await this.query({ skip, limit, ...info });
+      if (this.$checkRes(res)) {
+        let { data } = res;
+        data = data.map(i => {
+          const r = this.userList.find(f => f.uid == i.id);
+          if (r) {
+            i.userName = r.name;
+            i.userMobile = r.mobile;
+          }
+          return i;
+        });
+        this.$set(this, `list`, data);
+        this.$set(this, `total`, res.total);
+      }
+    },
+    async getOtherList() {
+      const res = await this.getUserList({ type: '2' });
+      if (this.$checkRes(res)) {
+        this.$set(this, `userList`, res.data);
+      }
+    },
+  },
+  computed: {
+    ...mapState(['user']),
+    pageTitle() {
+      return `${this.$route.meta.title}`;
+    },
+  },
+  metaInfo() {
+    return { title: this.$route.meta.title };
+  },
+};
+</script>
+
+<style lang="less" scoped></style>