|
@@ -7,6 +7,13 @@
|
|
|
:key="modalForm.id"
|
|
|
label-width="120px"
|
|
|
>
|
|
|
+ <el-form-item prop="topicType" label="题型:">
|
|
|
+ <el-radio-group v-model="topicType" @change="topicTypeChange">
|
|
|
+ <el-radio-button label="single">单选</el-radio-button>
|
|
|
+ <el-radio-button label="multiply">多选</el-radio-button>
|
|
|
+ <el-radio-button label="boolean">判断</el-radio-button>
|
|
|
+ </el-radio-group>
|
|
|
+ </el-form-item>
|
|
|
<el-form-item prop="topicName" label="题目名称:">
|
|
|
<el-input
|
|
|
v-model="modalForm.topicName"
|
|
@@ -60,24 +67,10 @@
|
|
|
>
|
|
|
</el-radio-group>
|
|
|
</el-form-item> -->
|
|
|
- <el-form-item>
|
|
|
- <el-checkbox
|
|
|
- v-model="modalForm.isMultiply"
|
|
|
- :disabled="modalForm.isBoolean"
|
|
|
- >多选</el-checkbox
|
|
|
- >
|
|
|
- </el-form-item>
|
|
|
- <el-form-item>
|
|
|
- <el-checkbox
|
|
|
- v-model="modalForm.isBoolean"
|
|
|
- @change="selectTypeChange"
|
|
|
- :disabled="modalForm.isMultiply"
|
|
|
- >判断题</el-checkbox
|
|
|
- >
|
|
|
+ <el-form-item v-if="modalForm.isBoolean" label="是否配置:">
|
|
|
<el-select
|
|
|
- v-if="modalForm.isBoolean"
|
|
|
v-model="modalForm.booleanType"
|
|
|
- style="margin-left: 20px;width:125px;"
|
|
|
+ style="width:125px;"
|
|
|
placeholder="请选择"
|
|
|
@change="booleanTypeChange"
|
|
|
>
|
|
@@ -88,13 +81,9 @@
|
|
|
:value="item"
|
|
|
></el-option>
|
|
|
</el-select>
|
|
|
- <span v-if="modalForm.isBoolean">(备选是否配置)</span>
|
|
|
+ <span>(备选是否配置)</span>
|
|
|
</el-form-item>
|
|
|
- <el-form-item
|
|
|
- v-if="modalForm.isBoolean"
|
|
|
- prop="booleanType"
|
|
|
- label="是否配置:"
|
|
|
- >
|
|
|
+ <el-form-item v-if="modalForm.isBoolean" prop="booleanType">
|
|
|
<span>是:</span>
|
|
|
<el-input
|
|
|
v-model.trim="booleanTypes.yes"
|
|
@@ -141,6 +130,13 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
data() {
|
|
|
+ const topicTypeValidater = (rule, value, callback) => {
|
|
|
+ if (!this.topicType) {
|
|
|
+ callback(new Error("请选择题型"));
|
|
|
+ } else {
|
|
|
+ callback();
|
|
|
+ }
|
|
|
+ };
|
|
|
const numberRangeValidater = (rule, value, callback) => {
|
|
|
if (!this.modalForm.startNumber || !this.modalForm.endNumber) {
|
|
|
return callback(new Error("请输入起止题号"));
|
|
@@ -171,6 +167,7 @@ export default {
|
|
|
|
|
|
return {
|
|
|
modalForm: { ...initModalForm },
|
|
|
+ topicType: null,
|
|
|
BOOLEAN_TYPE,
|
|
|
DIRECTION_TYPE,
|
|
|
booleanTypes: {
|
|
@@ -178,6 +175,13 @@ export default {
|
|
|
no: ""
|
|
|
},
|
|
|
rules: {
|
|
|
+ topicType: [
|
|
|
+ {
|
|
|
+ required: true,
|
|
|
+ validator: topicTypeValidater,
|
|
|
+ trigger: "change"
|
|
|
+ }
|
|
|
+ ],
|
|
|
topicName: [
|
|
|
{
|
|
|
required: true,
|
|
@@ -221,23 +225,38 @@ export default {
|
|
|
methods: {
|
|
|
initData(val) {
|
|
|
const valInfo = val.parent || val;
|
|
|
- this.modalForm = Object.assign({}, this.initModalForm, valInfo);
|
|
|
+ if (val["_edit"]) this.topicType = this.getTopicType(valInfo);
|
|
|
+ this.modalForm = Object.assign({}, initModalForm, valInfo);
|
|
|
this.modalForm.endNumber =
|
|
|
this.modalForm.startNumber + this.modalForm.questionsCount - 1;
|
|
|
this.booleanTypeChange();
|
|
|
},
|
|
|
- selectTypeChange(val) {
|
|
|
- if (val) {
|
|
|
- this.modalForm.optionCount = 2;
|
|
|
+ booleanTypeChange() {
|
|
|
+ const [yes, no] = this.modalForm.booleanType.split(",");
|
|
|
+ this.booleanTypes.yes = yes;
|
|
|
+ this.booleanTypes.no = no;
|
|
|
+ },
|
|
|
+ topicTypeChange() {
|
|
|
+ if (this.topicType === "single") {
|
|
|
this.modalForm.isMultiply = false;
|
|
|
+ this.modalForm.isBoolean = false;
|
|
|
+ this.modalForm.optionCount = 4;
|
|
|
+ } else if (this.topicType === "multiply") {
|
|
|
+ this.modalForm.isMultiply = true;
|
|
|
+ this.modalForm.isBoolean = false;
|
|
|
+ this.modalForm.optionCount = 4;
|
|
|
+ } else {
|
|
|
+ this.modalForm.isMultiply = false;
|
|
|
+ this.modalForm.isBoolean = true;
|
|
|
+ this.modalForm.optionCount = 2;
|
|
|
this.modalForm.booleanType = BOOLEAN_TYPE[0];
|
|
|
this.booleanTypeChange();
|
|
|
}
|
|
|
},
|
|
|
- booleanTypeChange() {
|
|
|
- const [yes, no] = this.modalForm.booleanType.split(",");
|
|
|
- this.booleanTypes.yes = yes;
|
|
|
- this.booleanTypes.no = no;
|
|
|
+ getTopicType(info) {
|
|
|
+ if (info.isMultiply) return "multiply";
|
|
|
+ if (info.isBoolean) return "boolean";
|
|
|
+ return "single";
|
|
|
},
|
|
|
async submit() {
|
|
|
const valid = await this.$refs.modalFormComp.validate().catch(() => {});
|