Browse Source

重点实验室

lrf 3 years ago
parent
commit
a8f24a48cb
5 changed files with 29 additions and 48 deletions
  1. 16 2
      src/App.vue
  2. 2 2
      src/plugins/check-res.js
  3. 2 1
      src/store/index.js
  4. 2 16
      src/views/index.vue
  5. 7 27
      src/views/infoview/laboratory/index.vue

+ 16 - 2
src/App.vue

@@ -5,9 +5,23 @@
 </template>
 
 <script>
+import { mapState, createNamespacedHelpers } from 'vuex';
+const { mapActions } = createNamespacedHelpers('login');
 export default {
-  created() {},
-  methods: {},
+  created() {
+    this.toLogin();
+  },
+  methods: {
+    ...mapActions(['login']),
+    async toLogin() {
+      const obj = { username: 'wxyk', password: 'wxyk' };
+      const res = await this.login(obj);
+      if (res.code === 200) {
+        const token = res.token;
+        sessionStorage.setItem('token', token);
+      }
+    },
+  },
 };
 </script>
 

+ 2 - 2
src/plugins/check-res.js

@@ -15,8 +15,8 @@ const Plugin = {
       if (!_.isFunction(okText) && _.isObject(okText) && okText != null) {
         ({ okText: _okText, errText: _errText } = okText);
       }
-      const { errcode = 0, errmsg } = res || {};
-      if (errcode === 0) {
+      const { errcode = 200, errmsg } = res || {};
+      if (errcode === 200) {
         if (_.isFunction(_okText)) {
           return _okText();
         }

+ 2 - 1
src/store/index.js

@@ -4,7 +4,7 @@ import * as ustate from '@common/src/store/user/state';
 import * as umutations from '@common/src/store/user/mutations';
 import test from '@common/src/store/test';
 import login from '@common/src/store/login';
-
+import laboratory from '@common/src/store/laboratory';
 Vue.use(Vuex);
 
 export default new Vuex.Store({
@@ -14,5 +14,6 @@ export default new Vuex.Store({
   modules: {
     test,
     login,
+    laboratory,
   },
 });

+ 2 - 16
src/views/index.vue

@@ -12,8 +12,6 @@
 
 <script>
 import adminFrame from '@common/src/components/mobile-frame/mobile-main.vue';
-import { mapState, createNamespacedHelpers } from 'vuex';
-const { mapActions } = createNamespacedHelpers('login');
 export default {
   name: 'index',
   props: {},
@@ -80,20 +78,8 @@ export default {
       ],
     };
   },
-  async created() {
-    this.toLogin();
-  },
-  methods: {
-    ...mapActions(['login']),
-    async toLogin() {
-      const obj = { username: 'wxyk', password: 'wxyk' };
-      const res = await this.login(obj);
-      if (res.code === 200) {
-        const token = res.token;
-        sessionStorage.setItem('token', token);
-      }
-    },
-  },
+  async created() {},
+  methods: {},
   computed: {
     ...mapState(['user']),
   },

+ 7 - 27
src/views/infoview/laboratory/index.vue

@@ -16,6 +16,7 @@ import list1 from '@/layout/infoview/laboratory/list-1.vue';
 import info1 from '@/layout/infoview/laboratory/info-1.vue';
 import adminFrame from '@common/src/components/mobile-frame/mobile-main.vue';
 import { mapState, createNamespacedHelpers } from 'vuex';
+const { mapActions } = createNamespacedHelpers('laboratory');
 export default {
   name: 'index',
   props: {},
@@ -39,35 +40,14 @@ export default {
     await this.search();
   },
   methods: {
+    ...mapActions(['query']),
     async search({ skip = 0, limit = this.limit, searchName, ...info } = {}) {
       if (searchName) info.name = searchName;
-      let data = [
-        {
-          buildTime: null,
-          chiefName: '梁建民',
-          createBy: '1',
-          createTime: '2021-09-16 00:00:00',
-          delFlag: '0',
-          englishName: '',
-          id: '1',
-          labAcreage: '',
-          labAddress: '',
-          labEmail: 'jackyliangjm@163.com',
-          labPerson: '梁建民',
-          labPhone: '13578652528',
-          name: '儿科神经吉林省重点实验室',
-          numb: '0',
-          params: {},
-          remark: null,
-          searchValue: null,
-          unitName: '吉林大学白求恩第一医院',
-          unitPerson: '孙宇飞 ',
-          unitPhone: '13944843792',
-          updateBy: 'userid001',
-          updateTime: '2021-09-30 14:09:43',
-        },
-      ];
-      this.$set(this, `list`, data);
+      const res = await this.query({ skip, limit, ...info });
+      if (this.$checkRes(res)) {
+        this.$set(this, `list`, res.rows);
+        this.$set(this, `total`, res.total);
+      }
     },
     // 查看信息
     async toView(data) {