Browse Source

Merge branch 'master' of http://git.cc-lotus.info/service-platform/web-test

guhongwei 4 years ago
parent
commit
30bd1bbe55

+ 6 - 0
src/store/index.js

@@ -58,6 +58,9 @@ import survey from './market/survey';
 // e专利
 import patent from './patent/patent';
 import patentImport from './patent/import';
+// 调研调查
+import question from './market/question';
+import projectsolic from './market/projectsolic';
 
 Vue.use(Vuex);
 
@@ -118,5 +121,8 @@ export default new Vuex.Store({
     // e专利
     patent,
     patentImport,
+    // 调研调查
+    question,
+    projectsolic,
   },
 });

+ 39 - 0
src/store/market/projectsolic.js

@@ -0,0 +1,39 @@
+import Vue from 'vue';
+import Vuex from 'vuex';
+import _ from 'lodash';
+Vue.use(Vuex);
+const api = {
+  interface: `/api/market/projectsolic`,
+};
+const state = () => ({});
+const mutations = {};
+
+const actions = {
+  async query({ commit }, { skip = 0, limit = undefined, ...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, ...info } = {}) {
+    const res = await this.$axios.$post(`${api.interface}/update/${id}`, { ...info });
+    return res;
+  },
+  async delete({ commit }, payload) {
+    const res = await this.$axios.$delete(`${api.interface}/${payload}`);
+    return res;
+  },
+};
+
+export default {
+  namespaced: true,
+  state,
+  mutations,
+  actions,
+};

+ 39 - 0
src/store/market/question.js

@@ -0,0 +1,39 @@
+import Vue from 'vue';
+import Vuex from 'vuex';
+import _ from 'lodash';
+Vue.use(Vuex);
+const api = {
+  interface: `/api/market/question`,
+};
+const state = () => ({});
+const mutations = {};
+
+const actions = {
+  async query({ commit }, { skip = 0, limit = undefined, ...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, ...info } = {}) {
+    const res = await this.$axios.$post(`${api.interface}/update/${id}`, { ...info });
+    return res;
+  },
+  async delete({ commit }, payload) {
+    const res = await this.$axios.$delete(`${api.interface}/${payload}`);
+    return res;
+  },
+};
+
+export default {
+  namespaced: true,
+  state,
+  mutations,
+  actions,
+};

+ 37 - 10
src/views/superAdminCenter/investigation/index.vue

@@ -63,6 +63,8 @@ import dataForm from '@/components/form.vue';
 import upload from '@/components/uploadone.vue';
 import uploadfile from '@/components/uploaddock.vue';
 import { mapState, createNamespacedHelpers } from 'vuex';
+const { mapActions: question } = createNamespacedHelpers('question');
+const { mapActions: projectsolic } = createNamespacedHelpers('projectsolic');
 export default {
   metaInfo() {
     return { title: this.$route.meta.title };
@@ -111,6 +113,7 @@ export default {
         { label: '信息内容', model: 'content', type: 'editor' },
       ],
       // 项目征集列表
+      proid: '',
       proopera: [],
       profields: [
         { label: '项目名称', prop: 'name' },
@@ -126,35 +129,59 @@ export default {
     await this.search();
   },
   methods: {
+    ...question(['query', 'create', 'update', 'delete']),
+    ...projectsolic({ solicQuery: 'query', solicFetch: 'fetch' }),
     async search({ skip = 0, limit = 10, ...info } = {}) {
-      console.log('查询');
+      const res = await this.query({ skip, limit, ...info });
+      if (this.$checkRes(res)) {
+        this.$set(this, `list`, res.data);
+        this.$set(this, `total`, res.total);
+      }
     },
     // 修改
     toEdit({ data }) {
-      console.log(data);
+      this.$set(this, 'form', _.cloneDeep(data));
+      this.display = 'detail';
     },
     // 删除
-    toDelete({ data }) {
-      console.log(data);
+    async toDelete({ data }) {
+      const res = await this.delete(data.id);
+      if (this.$checkRes(res, '删除成功', '删除失败' || res.errmsg)) {
+        this.search();
+      }
     },
     // 添加数据
     add() {
       this.display = 'detail';
     },
     // 添加,修改
-    toSave({ data }) {
-      console.log(data);
+    async toSave({ data }) {
+      const dup = _.cloneDeep(data);
+      let res;
+      if (dup.id) {
+        res = await this.update(dup);
+      } else {
+        res = await this.create(dup);
+      }
+      if (this.$checkRes(res, '保存成功', res.errmsg || '保存失败')) {
+        this.search();
+        this.back();
+      }
     },
     // 查看项目征集
     toView({ data }) {
       this.display = 'projectList';
-      console.log(data);
-      this.prosearch(data);
+      this.$set(this, `proid`, data._id);
+      this.prosearch();
     },
 
     // 查看调研调查中的项目征集数据
-    prosearch({ skip = 0, limit = 10, ...info } = {}) {
-      console.log('查询');
+    async prosearch({ skip = 0, limit = 10, ...info } = {}) {
+      const res = await this.solicQuery({ skip, limit, question_id: this.proid });
+      if (this.$checkRes(res)) {
+        this.$set(this, `prolist`, res.data);
+        this.$set(this, `prototal`, res.total);
+      }
     },
     // 返回列表
     back() {