|
@@ -1,6 +1,6 @@
|
|
|
<template>
|
|
|
<div id="index">
|
|
|
- <list-frame :title="`${title}-作业题`" returns="/work/index" @query="search" :needPag="false" :needFilter="false" @add="toAdd">
|
|
|
+ <list-frame :title="`${title}-作业题`" :returns="toReturns" @query="search" :needPag="false" :needFilter="false" @add="toAdd">
|
|
|
<el-row type="flex" justify="end" style="padding-bottom:1.875rem;">
|
|
|
<el-col :span="3">
|
|
|
<el-button type="primary" @click="submit" size="small">保存作业</el-button>
|
|
@@ -11,7 +11,7 @@
|
|
|
<el-dialog title="作业题" :visible.sync="dialog" @close="toClose">
|
|
|
<el-form ref="infoForm" :model="info" :rules="rules" label-width="120px" size="small" @submit.native.prevent>
|
|
|
<el-form-item label="类型" :required="true" prop="type">
|
|
|
- <el-radio-group v-model="info.type">
|
|
|
+ <el-radio-group v-model="info.type" @change="changeAnswer">
|
|
|
<el-radio v-for="(item, index) in radios" :key="index" :label="item.code">{{ item.name }}</el-radio>
|
|
|
</el-radio-group>
|
|
|
</el-form-item>
|
|
@@ -42,12 +42,20 @@
|
|
|
</el-row>
|
|
|
</el-form-item>
|
|
|
<el-form-item label="答案" prop="answer" v-if="info.type === '0' || info.type === '1'">
|
|
|
- <el-input v-model="info.answer"></el-input>
|
|
|
+ <template v-if="info.type === '0'">
|
|
|
+ <el-radio-group v-model="answer">
|
|
|
+ <el-radio v-for="(i, index) in info.option" :key="index" :label="i.number">{{ i.number }}</el-radio>
|
|
|
+ </el-radio-group>
|
|
|
+ </template>
|
|
|
+ <template v-if="info.type === '1'">
|
|
|
+ <el-checkbox-group v-model="answer">
|
|
|
+ <el-checkbox v-for="(i, index) in info.option" :key="index" :label="i.number">{{ i.number }}</el-checkbox>
|
|
|
+ </el-checkbox-group>
|
|
|
+ </template>
|
|
|
+ <!-- <el-input v-model="info.answer"></el-input> -->
|
|
|
</el-form-item>
|
|
|
<el-form-item label="分数" prop="score">
|
|
|
- <el-tooltip effect="dark" content="请填写选项的内容,多选用 ; 隔开" placement="bottom">
|
|
|
- <el-input v-model="info.score"></el-input>
|
|
|
- </el-tooltip>
|
|
|
+ <el-input v-model="info.score"></el-input>
|
|
|
</el-form-item>
|
|
|
<el-form-item>
|
|
|
<el-row type="flex" justify="center">
|
|
@@ -94,6 +102,7 @@ export default {
|
|
|
oIsNew: true,
|
|
|
dialog: false,
|
|
|
drawer: false,
|
|
|
+ answer: '',
|
|
|
opera: [
|
|
|
{
|
|
|
label: '编辑',
|
|
@@ -126,7 +135,7 @@ export default {
|
|
|
list: [
|
|
|
{ label: '单选', value: 0 },
|
|
|
{ label: '多选', value: 1 },
|
|
|
- { label: '问答', value: 2 },
|
|
|
+ // { label: '问答', value: 2 },
|
|
|
],
|
|
|
},
|
|
|
{
|
|
@@ -157,7 +166,7 @@ export default {
|
|
|
radios: [
|
|
|
{ code: '0', name: '单选' },
|
|
|
{ code: '1', name: '多选' },
|
|
|
- { code: '2', name: '简答' },
|
|
|
+ // { code: '2', name: '简答' },
|
|
|
],
|
|
|
total: 0,
|
|
|
}),
|
|
@@ -193,10 +202,15 @@ export default {
|
|
|
handleSave() {
|
|
|
this.$refs['infoForm'].validate(valid => {
|
|
|
if (valid) {
|
|
|
+ let duplicate = _.cloneDeep(this.info);
|
|
|
+ if (duplicate.type == 0) duplicate.answer = _.clone(this.answer);
|
|
|
+ else {
|
|
|
+ duplicate.answer = _.join(_.clone(this.answer), ';');
|
|
|
+ }
|
|
|
if (this.isNew) {
|
|
|
- this.list.push(JSON.parse(JSON.stringify(this.info)));
|
|
|
+ this.list.push(duplicate);
|
|
|
} else {
|
|
|
- let { index, ...data } = JSON.parse(JSON.stringify(this.info));
|
|
|
+ let { index, ...data } = duplicate;
|
|
|
this.$set(this.list, index, data);
|
|
|
}
|
|
|
this.toClose();
|
|
@@ -208,6 +222,10 @@ export default {
|
|
|
toEdit({ data, index }) {
|
|
|
data.index = index;
|
|
|
this.info = JSON.parse(JSON.stringify(data));
|
|
|
+ let answer = _.get(this.info, `answer`);
|
|
|
+ let type = _.get(this.info, `type`);
|
|
|
+ if (type == 0) this.$set(this, `answer`, answer);
|
|
|
+ else this.$set(this, `answer`, answer.split(';'));
|
|
|
this.isNew = false;
|
|
|
this.dialog = true;
|
|
|
},
|
|
@@ -216,6 +234,7 @@ export default {
|
|
|
},
|
|
|
toClose() {
|
|
|
this.dialog = false;
|
|
|
+ this.answer = undefined;
|
|
|
this.info = {};
|
|
|
this.$refs.infoForm.resetFields();
|
|
|
},
|
|
@@ -253,6 +272,14 @@ export default {
|
|
|
this.$router.push({ path: '/work/index' });
|
|
|
}
|
|
|
},
|
|
|
+ //改变answer类型
|
|
|
+ changeAnswer(type) {
|
|
|
+ if (type == 0) this.answer = '';
|
|
|
+ if (type == 1) this.answer = [];
|
|
|
+ },
|
|
|
+ toReturns() {
|
|
|
+ window.history.go(-1);
|
|
|
+ },
|
|
|
},
|
|
|
};
|
|
|
</script>
|