|
@@ -1,24 +1,19 @@
|
|
|
<template>
|
|
|
<div id="completion">
|
|
|
- <detail-frame :title="mainTitle" :returns="toreturn">
|
|
|
- <!-- <el-alert :title="`进度:${student.answertotal || 0}/${student.alltotal || 0}`" :closable="false"></el-alert> -->
|
|
|
- <self-cards title="问卷列表" v-if="views === `quest`">
|
|
|
- <dataTable :fields="questFields" :data="questList" :opera="opera" @view="data => toView(data, 'term')"></dataTable>
|
|
|
- </self-cards>
|
|
|
- <self-cards title="班级进度" :returns="toReturns" v-else>
|
|
|
- <el-alert :title="`进度:${student.answertotal || 0}/${student.alltotal || 0}`" :closable="false"></el-alert>
|
|
|
- <dataTable :fields="fields" :data="student.list" :opera="[]"></dataTable>
|
|
|
+ <detail-frame :title="pageTitle" :returns="toreturn">
|
|
|
+ <self-cards title="问卷列表">
|
|
|
+ <data-table :fields="fields" :data="list" :opera="opera" @data="toData" :usePage="false"></data-table>
|
|
|
</self-cards>
|
|
|
</detail-frame>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
-import dataTable from '@frame/components/data-table';
|
|
|
+import dataTable from '@frame/components/filter-page-table';
|
|
|
import detailFrame from '@frame/layout/admin/detail-frame';
|
|
|
import selfCards from '@frame/parts/cards';
|
|
|
import _ from 'lodash';
|
|
|
-import { createNamespacedHelpers } from 'vuex';
|
|
|
+import { mapState, createNamespacedHelpers } from 'vuex';
|
|
|
const { mapActions: completion } = createNamespacedHelpers('completion');
|
|
|
const { mapActions: classes } = createNamespacedHelpers('classes');
|
|
|
const { mapActions: termquest } = createNamespacedHelpers('termquest');
|
|
@@ -26,81 +21,52 @@ const { mapActions: questionnaire } = createNamespacedHelpers('questionnaire');
|
|
|
const { mapActions: util } = createNamespacedHelpers('util');
|
|
|
|
|
|
export default {
|
|
|
- metaInfo: { title: '问卷进度查看' },
|
|
|
+ metaInfo: { title: '问卷统计' },
|
|
|
name: 'completion',
|
|
|
props: {},
|
|
|
components: { detailFrame, dataTable, selfCards },
|
|
|
data: () => ({
|
|
|
- views: 'quest',
|
|
|
- fields: [
|
|
|
- { label: '姓名', prop: 'name' },
|
|
|
- { label: '进度', prop: 'completion' },
|
|
|
- ],
|
|
|
- classes: {},
|
|
|
- questFields: [
|
|
|
- { label: '标题', prop: 'name' },
|
|
|
- { label: '类型', prop: 'type', format: i => (i == 0 ? '常用问卷' : '非常用问卷') },
|
|
|
- ],
|
|
|
- questList: [],
|
|
|
- quest: [],
|
|
|
opera: [
|
|
|
{
|
|
|
- label: '查看',
|
|
|
- icon: 'el-icon-view',
|
|
|
- method: 'view',
|
|
|
+ label: '查看结果',
|
|
|
+ method: 'data',
|
|
|
},
|
|
|
],
|
|
|
- student: {
|
|
|
- list: [],
|
|
|
- },
|
|
|
+ fields: [
|
|
|
+ { label: '问卷标题', prop: 'name' },
|
|
|
+ { label: '问卷类型', prop: 'type', format: i => (i == '0' ? '常用问卷' : i == '1' ? '非常用问题' : '教师问卷') },
|
|
|
+ ],
|
|
|
+ filFields: [
|
|
|
+ { label: '问卷名', model: 'name' },
|
|
|
+ { label: '问卷序号', model: 'id' },
|
|
|
+ ],
|
|
|
+ list: [],
|
|
|
+ options: undefined,
|
|
|
+ total: 0,
|
|
|
}),
|
|
|
|
|
|
- created() {
|
|
|
- this.search();
|
|
|
- },
|
|
|
+ created() {},
|
|
|
methods: {
|
|
|
- ...completion({ getCompletion: 'query' }),
|
|
|
- ...classes({ getClass: 'fetch' }),
|
|
|
- ...termquest({ getTermQuestList: 'query' }),
|
|
|
- ...questionnaire({ getQuestionnaireList: 'query', allFetch: 'mergeRequest' }),
|
|
|
...util({ modelFetch: 'fetch' }),
|
|
|
- async search() {
|
|
|
- //查询班级信息,获得期,批次
|
|
|
- let res = await this.getClass(this.id);
|
|
|
+ ...questionnaire(['query', 'delete']),
|
|
|
+ async search({ skip = 0, limit = 10, ...info } = {}) {
|
|
|
+ let termid = _.get(this.defaultOption, 'termid');
|
|
|
+ if (!termid) return;
|
|
|
+ let unusaul = await this.modelFetch({ model: 'termquest', termid });
|
|
|
+ let uqlist = []; //非常用问卷
|
|
|
+ let usual = []; //常用问卷
|
|
|
+ if (this.$checkRes(unusaul)) uqlist = unusaul.data.questionnaireid;
|
|
|
+ let res = await this.query({ ...info });
|
|
|
if (this.$checkRes(res)) {
|
|
|
- this.$set(this, `classes`, res.data);
|
|
|
+ usual = res.data.filter(i => i.type == 0 && i.status == 1);
|
|
|
+ let nqulist = res.data.filter(i => i.status == 1 && _.includes(uqlist, i._id));
|
|
|
+ let rlist = [...nqulist, ...usual];
|
|
|
+ this.$set(this, `list`, rlist);
|
|
|
}
|
|
|
- let ql = [];
|
|
|
- //查询所有问卷
|
|
|
- const quest = await this.getQuestionnaireList({ type: 0 });
|
|
|
- if (this.$checkRes(quest)) {
|
|
|
- ql = ql.concat(quest.data);
|
|
|
- // this.$set(this, `quest`, quest.data);
|
|
|
- }
|
|
|
- //查询这期的所有问卷,id=>数据
|
|
|
- let rql = await this.modelFetch({ model: 'termquest', termid: this.classes.termid });
|
|
|
- if (this.$checkRes(rql)) {
|
|
|
- let ids = _.get(rql.data, `questionnaireid`);
|
|
|
- if (ids) {
|
|
|
- let questList = await this.allFetch({ method: 'fetch', data: ids });
|
|
|
- ql = ql.concat(questList);
|
|
|
- }
|
|
|
- }
|
|
|
- this.$set(this, `questList`, ql);
|
|
|
},
|
|
|
- async toView({ data }, type) {
|
|
|
- this.views = type;
|
|
|
- let { id: questionnaireid } = data;
|
|
|
- let { id: batch } = this.classes;
|
|
|
- let res = await this.getCompletion({ type: '2', typeid: batch, questionnaireid });
|
|
|
- if (this.$checkRes(res)) {
|
|
|
- let { data: completion, answertotal, alltotal, completiontotal } = res;
|
|
|
- completion = completion.map(i => {
|
|
|
- i.completion.includes('NaN') ? (i.completion = '-') : '';
|
|
|
- return i;
|
|
|
- });
|
|
|
- this.$set(this, `student`, { list: completion, answertotal, alltotal, completiontotal });
|
|
|
- }
|
|
|
+ toData({ data }) {
|
|
|
+ let classid = _.get(this.defaultOption, 'classid');
|
|
|
+ this.$router.push({ path: './detail', query: { questionnaireid: data.id, classid } });
|
|
|
},
|
|
|
toReturns() {
|
|
|
this.views = 'quest';
|
|
@@ -110,14 +76,31 @@ export default {
|
|
|
},
|
|
|
},
|
|
|
computed: {
|
|
|
+ ...mapState(['user', 'defaultOption']),
|
|
|
id() {
|
|
|
return this.$route.query.id;
|
|
|
},
|
|
|
- mainTitle() {
|
|
|
- let meta = this.$route.meta;
|
|
|
- let main = meta.title || '';
|
|
|
- let sub = meta.sub || '';
|
|
|
- return `${main}${sub}`;
|
|
|
+ pageTitle() {
|
|
|
+ return `${this.$route.meta.title}`;
|
|
|
+ },
|
|
|
+ },
|
|
|
+ watch: {
|
|
|
+ defaultOption: {
|
|
|
+ immediate: true,
|
|
|
+ deep: true,
|
|
|
+ handler(val) {
|
|
|
+ if (!_.get(this, 'options')) {
|
|
|
+ this.$set(this, `options`, _.cloneDeep(val));
|
|
|
+ this.search();
|
|
|
+ } else {
|
|
|
+ let ntermid = _.get(val, 'termid');
|
|
|
+ let otermid = _.get(this.options, 'termid');
|
|
|
+ if (ntermid && !_.isEqual(ntermid, otermid)) {
|
|
|
+ this.$set(this, `options`, _.cloneDeep(val));
|
|
|
+ this.search();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
},
|
|
|
},
|
|
|
};
|