|
@@ -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>
|