lrf402788946 4 年之前
父節點
當前提交
9a13984d63
共有 3 個文件被更改,包括 46 次插入6 次删除
  1. 2 2
      src/views/questionnaire/detail.vue
  2. 22 3
      src/views/techolchat/index.vue
  3. 22 1
      src/views/techolchat/index/question.vue

+ 2 - 2
src/views/questionnaire/detail.vue

@@ -85,12 +85,12 @@ export default {
       this.getAnswer();
     },
     async getAnswer() {
-      if (!this.user.id) return;
+      if (!this.user || !this.user.id) return;
       const res = await this.findAnswer({ user_id: this.user.id, questionnaire_id: this.id });
       if (this.$checkRes(res)) {
         if (res.data) {
           this.disabled = true;
-          // TODO还原数据
+          // 还原数据
           const { answer } = res.data;
           const questions = this.question.questions;
           const reply = {};

+ 22 - 3
src/views/techolchat/index.vue

@@ -5,7 +5,7 @@
         <div class="w_1200">
           <el-col :span="24" class="one">
             <el-col :span="12" class="left">
-              <question :questionList="questionList"></question>
+              <question :questionList="questionList" :questionnaireList="questionnaireList"></question>
             </el-col>
             <el-col :span="12" class="right">
               <work :workList="hyyjList"></work>
@@ -59,6 +59,7 @@ import { mapState, createNamespacedHelpers } from 'vuex';
 const { mapActions: column } = createNamespacedHelpers('column');
 const { mapActions: news } = createNamespacedHelpers('news');
 const { mapActions: mapQuestion } = createNamespacedHelpers('question');
+const { mapActions: questionnaire } = createNamespacedHelpers('questionnaire');
 export default {
   metaInfo() {
     return { title: this.$route.meta.title };
@@ -113,6 +114,8 @@ export default {
       questionList: [],
       // 行业研究
       hyyjList: [],
+      // 问卷调查
+      questionnaireList: [],
     };
   },
   async created() {
@@ -120,6 +123,7 @@ export default {
     await this.search();
   },
   methods: {
+    ...questionnaire({ getQuest: 'query' }),
     ...column({ columnQuery: 'query' }),
     ...news(['query']),
     ...mapQuestion({ questionQuery: 'query' }),
@@ -131,10 +135,25 @@ export default {
         this.$set(this, `${column.site}List`, res.data);
       }
       // 调研调查
-      res = await this.questionQuery({ skip, limit, ...info });
+      res = await this.questionQuery({ skip, limit: 2, ...info });
       if (this.$checkRes(res)) {
-        this.$set(this, `questionList`, res.data);
+        const data = this.toLimit(res.data);
+        this.$set(this, `questionList`, data);
       }
+      // 问卷调查
+      res = await this.getQuest({ skip, limit: 2 });
+      if (this.$checkRes(res)) {
+        const data = this.toLimit(res.data);
+        this.$set(this, `questionnaireList`, data);
+      }
+    },
+
+    toLimit(data) {
+      if (data.length < 2) {
+        data = [...data, data[0]];
+        return this.toLimit(data);
+      }
+      return data;
     },
     async searchOther() {
       let res = await this.columnQuery();

+ 22 - 1
src/views/techolchat/index/question.vue

@@ -5,6 +5,7 @@
         <el-col :span="24" class="top">
           <top :topInfo="topInfo" @moreBtn="moreBtn"></top>
         </el-col>
+        <el-col :span="24">项目征集</el-col>
         <el-col :span="24" class="down">
           <el-col :span="24" class="list" v-for="(item, index) in questionList" :key="index" @click.native="detailBtn(item)">
             <el-col :span="20" class="title textOver">
@@ -16,6 +17,18 @@
             <el-col :span="24" class="orgin"> 信息来源:{{ item.origin || '暂无' }} </el-col>
           </el-col>
         </el-col>
+        <el-col :span="24">问卷调查</el-col>
+        <el-col :span="24" class="down">
+          <el-col :span="24" class="list" v-for="(item, index) in questionnaireList" :key="index" @click.native="toQuestionnaire(item)">
+            <el-col :span="20" class="title textOver">
+              {{ item.title }}
+            </el-col>
+            <el-col :span="4" class="date">
+              {{ getDate(item.create_time) || '暂无' }}
+            </el-col>
+            <el-col :span="24" class="orgin textOver"> 简介:{{ item.brief || '暂无' }} </el-col>
+          </el-col>
+        </el-col>
       </el-col>
     </el-row>
   </div>
@@ -32,6 +45,7 @@ export default {
   name: 'question',
   props: {
     questionList: { type: Array },
+    questionnaireList: { type: Array },
   },
   components: {
     top,
@@ -54,6 +68,10 @@ export default {
     detailBtn(data) {
       this.$router.push({ path: './list', query: { index: 0, id: data._id } });
     },
+    // 填写问卷
+    toQuestionnaire(data) {
+      this.$router.push({ path: '/questionnaire/answer', query: { id: data._id } });
+    },
     // 整理时间
     getDate(date) {
       let newsDate = moment(date).format('YYYY-MM-DD');
@@ -73,7 +91,7 @@ export default {
     height: 50px;
   }
   .down {
-    height: 450px;
+    height: 200px; //450px
     position: relative;
     .list {
       border-bottom: 1px dashed #000;
@@ -97,6 +115,9 @@ export default {
         color: #409eff;
       }
     }
+    .list:last-child {
+      border: none;
+    }
   }
 }
 </style>