wuhongyu пре 5 година
родитељ
комит
39601030f7
3 измењених фајлова са 61 додато и 3 уклоњено
  1. 2 1
      src/store/index.js
  2. 45 0
      src/store/news.js
  3. 14 2
      src/views/index.vue

+ 2 - 1
src/store/index.js

@@ -9,7 +9,7 @@ import staff from './staff';
 import expert from './expert';
 import login from './login';
 import user from './user';
-
+import news from './news';
 Vue.use(Vuex);
 
 export default new Vuex.Store({
@@ -24,5 +24,6 @@ export default new Vuex.Store({
     staff,
     expert,
     user,
+    news,
   },
 });

+ 45 - 0
src/store/news.js

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

+ 14 - 2
src/views/index.vue

@@ -41,6 +41,7 @@
 </template>
 
 <script>
+const { mapActions: login } = createNamespacedHelpers('login');
 import top from '@/layout/common/top.vue';
 import menus from '@/layout/common/menus.vue';
 import dynamic from '@/layout/index/dynamic.vue';
@@ -173,9 +174,20 @@ export default {
       },
     ],
   }),
-  created() {},
+  created() {
+    this.search();
+  },
   computed: {},
-  methods: {},
+  methods: {
+    ...{ departmentQuery: 'query', departmentFetch: 'fetch' },
+    async search() {
+      let res = await this.toLogin({ col_name: '工作动态' });
+      if (this.$checkRes(res)) {
+        this.$set(this, `jobsList`, res.data);
+      }
+      jobsList;
+    },
+  },
 };
 </script>