|
@@ -0,0 +1,134 @@
|
|
|
|
+<template>
|
|
|
|
+ <div id="quest">
|
|
|
|
+ <list-frame title="非常用问卷管理" @query="search" :needPag="false" :needFilter="false" :needAdd="false">
|
|
|
|
+ <el-card style="padding:10px">
|
|
|
|
+ <data-table :fields="listFields" :data="termList" :opera="opera" @edit="toOpen"></data-table>
|
|
|
|
+ </el-card>
|
|
|
|
+ </list-frame>
|
|
|
|
+ <el-dialog title="分配问卷" :visible.sync="dialog" @close="toClose">
|
|
|
|
+ <el-form :model="form" size="mini" label-width="80px">
|
|
|
|
+ <el-form-item label="期">
|
|
|
|
+ <el-select v-model="form.termid" placeholder="请选择期数">
|
|
|
|
+ <el-option v-for="(i, index) in termList" :key="index" :label="`第${i.term}期`" :value="i._id"></el-option>
|
|
|
|
+ </el-select>
|
|
|
|
+ </el-form-item>
|
|
|
|
+ <el-form-item label="问卷列表">
|
|
|
|
+ <data-table :fields="fields" :data="questList" :select="true" :selected="selected" @handleSelect="handleSelect"></data-table>
|
|
|
|
+ </el-form-item>
|
|
|
|
+ <el-form-item label="">
|
|
|
|
+ <el-button type="primary" @click="handleSave">保存</el-button>
|
|
|
|
+ </el-form-item>
|
|
|
|
+ </el-form>
|
|
|
|
+ </el-dialog>
|
|
|
|
+ </div>
|
|
|
|
+</template>
|
|
|
|
+
|
|
|
|
+<script>
|
|
|
|
+import _ from 'lodash';
|
|
|
|
+import listFrame from '@frame/layout/admin/list-frame';
|
|
|
|
+import dataTable from '@frame/components/data-table';
|
|
|
|
+import { mapState, createNamespacedHelpers } from 'vuex';
|
|
|
|
+const { mapActions: trainplan } = createNamespacedHelpers('trainplan');
|
|
|
|
+const { mapActions: questionnaire } = createNamespacedHelpers('questionnaire');
|
|
|
|
+const { mapActions: termquest } = createNamespacedHelpers('termquest');
|
|
|
|
+const { mapActions: util } = createNamespacedHelpers('util');
|
|
|
|
+export default {
|
|
|
|
+ name: 'quest',
|
|
|
|
+ props: {},
|
|
|
|
+ components: { listFrame, dataTable },
|
|
|
|
+ data: function() {
|
|
|
|
+ return {
|
|
|
|
+ dialog: false,
|
|
|
|
+ opera: [
|
|
|
|
+ {
|
|
|
|
+ label: '编辑',
|
|
|
|
+ icon: 'el-icon-edit',
|
|
|
|
+ method: 'edit',
|
|
|
|
+ },
|
|
|
|
+ ],
|
|
|
|
+ listFields: [{ label: '期', prop: 'term' }],
|
|
|
|
+ fields: [
|
|
|
|
+ { label: '问卷序号', prop: 'num' },
|
|
|
|
+ { label: '问卷标题', prop: 'name' },
|
|
|
|
+ ],
|
|
|
|
+ questList: [],
|
|
|
|
+ selectInfo: {},
|
|
|
|
+ termList: [],
|
|
|
|
+ list: [],
|
|
|
|
+ form: {},
|
|
|
|
+ selected: [],
|
|
|
|
+ };
|
|
|
|
+ },
|
|
|
|
+ created() {
|
|
|
|
+ this.search();
|
|
|
|
+ },
|
|
|
|
+ methods: {
|
|
|
|
+ ...util({ modelFetch: 'fetch' }),
|
|
|
|
+ ...trainplan(['fetch']),
|
|
|
|
+ ...termquest({ getList: 'fetch', createList: 'create', updateList: 'update' }),
|
|
|
|
+ ...questionnaire(['query', 'delete', 'mergeRequest']),
|
|
|
|
+ async search({ skip = 0, limit = 10, ...info } = {}) {
|
|
|
|
+ const res = await this.fetch(this.id);
|
|
|
|
+ if (this.$checkRes(res)) {
|
|
|
|
+ let { termnum } = res.data;
|
|
|
|
+ this.$set(this, `termList`, termnum);
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ async toOpen({ data } = {}) {
|
|
|
|
+ let res = await this.modelFetch({ model: 'termquest', termid: data._id });
|
|
|
|
+ let tsl = await this.query({ type: 1 });
|
|
|
|
+ if (this.$checkRes(tsl)) {
|
|
|
|
+ this.$set(this, `questList`, tsl.data);
|
|
|
|
+ }
|
|
|
|
+ if (this.$checkRes(res)) {
|
|
|
|
+ let ids = _.get(res.data, `questionnaireid`);
|
|
|
|
+ this.$set(this.form, `termid`, data._id);
|
|
|
|
+ this.$set(this.form, `id`, _.get(res.data, `_id`));
|
|
|
|
+ if (ids) {
|
|
|
|
+ let questList = await this.mergeRequest({ method: 'fetch', data: ids });
|
|
|
|
+ this.$set(this, `selected`, questList);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ this.dialog = true;
|
|
|
|
+ },
|
|
|
|
+ async handleSave() {
|
|
|
|
+ let duplicate = _.cloneDeep(this.form);
|
|
|
|
+ duplicate.questionnaireid = this.selected.map(i => i._id);
|
|
|
|
+ let res;
|
|
|
|
+ if (!duplicate.id) {
|
|
|
|
+ res = await this.createList(duplicate);
|
|
|
|
+ } else {
|
|
|
|
+ res = await this.updateList(duplicate);
|
|
|
|
+ }
|
|
|
|
+ if (this.$checkRes(res, '保存成功', res.errmsg || '保存失败')) {
|
|
|
|
+ this.toClose();
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ handleSelect(data) {
|
|
|
|
+ this.$set(this, `selected`, data);
|
|
|
|
+ },
|
|
|
|
+ toClose() {
|
|
|
|
+ this.selected = [];
|
|
|
|
+ this.form = {};
|
|
|
|
+ this.dialog = false;
|
|
|
|
+ },
|
|
|
|
+ async toDelete({ data }) {
|
|
|
|
+ console.log(data);
|
|
|
|
+ },
|
|
|
|
+ },
|
|
|
|
+ computed: {
|
|
|
|
+ ...mapState(['user']),
|
|
|
|
+ pageTitle() {
|
|
|
|
+ return `${this.$route.meta.title}`;
|
|
|
|
+ },
|
|
|
|
+ id() {
|
|
|
|
+ return this.$route.query.id;
|
|
|
|
+ },
|
|
|
|
+ },
|
|
|
|
+ metaInfo() {
|
|
|
|
+ return { title: this.$route.meta.title };
|
|
|
|
+ },
|
|
|
|
+};
|
|
|
|
+</script>
|
|
|
|
+
|
|
|
|
+<style lang="less" scoped></style>
|