lrf402788946 4 years ago
parent
commit
d3ccc79b4f

+ 5 - 4
src/components/list/list-model/model-5.vue

@@ -1,13 +1,13 @@
 <template>
   <div id="model-5">
-    <el-col :span="24" class="infoLeftList" v-for="(item, index) in list" :key="index" @click.native="clickDetail(item.id)">
+    <el-col :span="24" class="infoLeftList" v-for="(item, index) in list" :key="index" @click.native="clickDetail(item)">
       <el-col :span="20" class="title textOver">
         {{ item.p1 }}
       </el-col>
       <el-col :span="4" class="date">
         {{ item.p2 || '暂无' }}
       </el-col>
-      <el-col :span="24" class="orgin"> 信息来源:{{ item.p3 || '暂无' }} </el-col>
+      <el-col :span="24" class="orgin textOver"> {{ item.p3title || '信息来源' }}:{{ item.p3 || '暂无' }} </el-col>
     </el-col>
   </div>
 </template>
@@ -25,9 +25,10 @@ export default {
   },
   created() {},
   methods: {
-    clickDetail(id) {
+    clickDetail(data) {
       // TODO:打开指定详情
-      this.$router.push({ path: './list', query: { index: this.index, id } });
+      if (!data.custom) this.$router.push({ path: './list', query: { index: this.index, id: data.id } });
+      else this.$emit('detail', data);
     },
   },
   computed: {

+ 16 - 1
src/views/questionnaire/detail.vue

@@ -15,6 +15,15 @@
               </el-col>
               <el-col :span="24" class="form">
                 <el-form :model="answer" label-position="top" ref="form">
+                  <el-form-item v-if="!user || !user.id" label="您是否注册成为平台用户">
+                    <el-radio-group v-model="userForm.user">
+                      <el-radio :label="true">是</el-radio>
+                      <el-radio :label="false">否</el-radio>
+                    </el-radio-group>
+                  </el-form-item>
+                  <el-form-item v-if="userForm.user" label="手机号">
+                    <el-input v-model="userForm.phone" placeholder="请填写手机号"></el-input>
+                  </el-form-item>
                   <!-- 0单选,1多选,2简答 -->
                   <template v-for="(i, index) in question.questions">
                     <el-form-item
@@ -71,6 +80,7 @@ export default {
       answer: {},
       test: [],
       disabled: false,
+      userForm: {},
     };
   },
   created() {
@@ -144,8 +154,13 @@ export default {
       const data = {
         questionnaire_id: this.id,
         answer,
-        user_id: this.user.id,
       };
+      if (this.user && this.user.id) {
+        data.user_id = this.user.id;
+      } else {
+        const userForm = this.userForm;
+        if (userForm.user) data.phone = userForm.phone;
+      }
       const res = await this.create(data);
       if (this.$checkRes(res, '提交成功', '提交失败')) {
         // 返回列表

+ 2 - 2
src/views/techolchat/index/question.vue

@@ -62,11 +62,11 @@ export default {
   methods: {
     // 更多
     moreBtn() {
-      this.$router.push({ path: '/techolchat/list', query: { index: 0 } });
+      this.$router.push({ path: '/techolchat/list', query: { index: 1 } });
     },
     // 详情
     detailBtn(data) {
-      this.$router.push({ path: './list', query: { index: 0, id: data._id } });
+      this.$router.push({ path: './list', query: { index: 1, id: data._id } });
     },
     // 填写问卷
     toQuestionnaire(data) {

+ 4 - 3
src/views/techolchat/list.vue

@@ -35,16 +35,17 @@ export default {
     work: () => import('./list/work.vue'),
     serve: () => import('./list/serve.vue'),
     result: () => import('./list/result.vue'),
+    questionnaire: () => import('./list/questionnaire.vue'),
   },
   data: function() {
     return {
       component: '',
       menuList: [
-        { name: '调研调查', component: 'question', options: { useTab: false, useSearch: false, listModel: 5 } },
+        { name: '调研调查' },
+        { name: '项目征集', component: 'question', options: { useTab: false, useSearch: false, listModel: 5 }, indent: 1 },
+        { name: '问卷调查', component: 'questionnaire', options: { useTab: false, useSearch: false, listModel: 5 }, indent: 1, custom: true },
         { name: '行业研究', component: 'work', options: { useTab: false, useSearch: false, listModel: 6 } },
         // { name: '科技服务', options: { useTab: false, useSearch: false, listModel: 2 } },
-        // { name: '会展服务', component: 'serve', options: { useTab: false, useSearch: false, listModel: 2 }, indent: 1 },
-        // { name: '成果评价', component: 'result', options: { useTab: false, useSearch: false, listModel: 2 }, indent: 1 },
       ],
       squareImage: require('@p/live/square_big.png'),
       column_name: '',

+ 1 - 0
src/views/techolchat/list/question.vue

@@ -30,6 +30,7 @@ export default {
       detail: {},
       // 栏目信息
       column: {},
+      pageSize: 5,
     };
   },
   async created() {

+ 100 - 0
src/views/techolchat/list/questionnaire.vue

@@ -0,0 +1,100 @@
+<template>
+  <div id="questionnaire">
+    <list-page v-bind="$attrs" :total="total" v-if="!id" @toSearch="search" :pageSize="pageSize">
+      <component :is="model" :list="list" @detail="searchInfo"></component>
+    </list-page>
+    <template v-else>
+      <dmodel :displayBtn="true" :data="detail" v-if="detail">
+        <el-button size="mini" type="primary" @click="$router.push({ path: './list', query: { index: $route.query.index } })"> 返回</el-button>
+      </dmodel>
+    </template>
+  </div>
+</template>
+
+<script>
+const moment = require('moment');
+import listPage from '@c/list/list-page.vue';
+import { mapState, createNamespacedHelpers } from 'vuex';
+const { mapActions: questionnaire } = createNamespacedHelpers('questionnaire');
+export default {
+  name: 'questionnaire',
+  props: ['listModel'],
+  components: {
+    listPage,
+    model5: () => import('@c/list/list-model/model-5.vue'),
+    // 没用,详情跳走了
+    dmodel: () => import('./detail-model/model-1.vue'),
+  },
+  data: function() {
+    return {
+      list: [],
+      total: 0,
+      detail: {},
+      // 栏目信息
+      column: {},
+      pageSize: 5,
+    };
+  },
+  async created() {
+    await this.search();
+  },
+  methods: {
+    ...questionnaire(['query', 'fetch']),
+    async search({ skip = 0, limit = this.pageSize, ...info } = {}) {
+      // 查询
+      let res = await this.query({ skip, limit, ...info });
+      if (this.$checkRes(res)) {
+        this.$set(this, `list`, res.data);
+        this.$set(this, `total`, res.total);
+        // 最后结果处理方式,将显示的信息转换成固定的字段去显示
+        this.$set(this, 'list', this.translate(this.list));
+      }
+    },
+    translate(data) {
+      const list = data.map(i => {
+        const obj = { id: i.id || i._id };
+        obj.p1 = _.get(i, 'title');
+        let date = _.get(i, 'create_time');
+        if (date) date = moment(date).format('YYYY-MM-DD');
+        obj.p2 = date;
+        obj.p3 = _.get(i, 'brief');
+        obj.p3title = '简介';
+        // 点击事件自定义
+        obj.custom = true;
+        return obj;
+      });
+      return list;
+    },
+    // 查询详情
+    async searchInfo(data) {
+      this.$router.push({ path: '/questionnaire/answer', query: { id: data.id } });
+    },
+  },
+  computed: {
+    ...mapState(['user', 'menuParams']),
+    pageTitle() {
+      return `${this.$route.meta.title}`;
+    },
+    model() {
+      const moduleNumber = this.listModel || 1;
+      return `model${moduleNumber}`;
+    },
+    id() {
+      return this.$route.query.id;
+    },
+  },
+  metaInfo() {
+    return { title: this.$route.meta.title };
+  },
+  watch: {
+    id: {
+      handler(ne) {
+        if (ne) this.searchInfo();
+      },
+      immediate: true,
+    },
+  },
+};
+</script>
+
+<style lang="less" scoped></style>

+ 1 - 0
src/views/techolchat/list/work.vue

@@ -31,6 +31,7 @@ export default {
       detail: {},
       // 栏目信息
       column: {},
+      pageSize: 5,
     };
   },
   async created() {