|
|
|
@ -1,7 +1,14 @@ |
|
|
|
|
<template> |
|
|
|
|
<el-dialog title="试题" :close-on-click-modal="false" append-to-body :visible.sync="visible" width="900px" @close="closeDialog"> |
|
|
|
|
<div> |
|
|
|
|
<el-form ref="dialogForm" :model="dialogForm" :rules="dataRule" label-position="left" @keyup.enter.native="dialogFormSubmit()"> |
|
|
|
|
<el-form |
|
|
|
|
ref="dialogForm" |
|
|
|
|
:model="dialogForm" |
|
|
|
|
:rules="dataRule" |
|
|
|
|
label-width="80px" |
|
|
|
|
label-position="left" |
|
|
|
|
@keyup.enter.native="dialogFormSubmit()" |
|
|
|
|
> |
|
|
|
|
<el-row> |
|
|
|
|
<el-col :span="24"> |
|
|
|
|
<el-form-item label="题目" prop="question"> |
|
|
|
@ -9,47 +16,47 @@ |
|
|
|
|
</el-form-item> |
|
|
|
|
</el-col> |
|
|
|
|
</el-row> |
|
|
|
|
<el-row> |
|
|
|
|
<el-row :gutter="20"> |
|
|
|
|
<el-col :span="12"> |
|
|
|
|
<el-form-item label="选项A" prop="question"> |
|
|
|
|
<el-input v-model="dialogForm.chooseA" maxlength="200" placeholder="请输入" clearable /> |
|
|
|
|
</el-form-item> |
|
|
|
|
</el-form-item> |
|
|
|
|
</el-col> |
|
|
|
|
<el-col :span="12"> |
|
|
|
|
<el-form-item label="选项B" prop="question"> |
|
|
|
|
<el-input v-model="dialogForm.chooseB" maxlength="200" placeholder="请输入" clearable /> |
|
|
|
|
</el-form-item> |
|
|
|
|
</el-form-item> |
|
|
|
|
</el-col> |
|
|
|
|
</el-row> |
|
|
|
|
<el-row> |
|
|
|
|
<el-row :gutter="20"> |
|
|
|
|
<el-col :span="12"> |
|
|
|
|
<el-form-item label="选项C" prop="question"> |
|
|
|
|
<el-input v-model="dialogForm.chooseC" maxlength="200" placeholder="请输入" clearable /> |
|
|
|
|
</el-form-item> |
|
|
|
|
</el-form-item> |
|
|
|
|
</el-col> |
|
|
|
|
<el-col :span="12"> |
|
|
|
|
<el-form-item label="选项D" prop="question"> |
|
|
|
|
<el-input v-model="dialogForm.chooseD" maxlength="200" placeholder="请输入" clearable /> |
|
|
|
|
</el-form-item> |
|
|
|
|
</el-form-item> |
|
|
|
|
</el-col> |
|
|
|
|
</el-row> |
|
|
|
|
<el-row> |
|
|
|
|
<el-row :gutter="20"> |
|
|
|
|
<el-col :span="12"> |
|
|
|
|
<el-form-item label="选项E" prop="question"> |
|
|
|
|
<el-input v-model="dialogForm.chooseE" maxlength="200" placeholder="请输入" clearable /> |
|
|
|
|
</el-form-item> |
|
|
|
|
</el-form-item> |
|
|
|
|
</el-col> |
|
|
|
|
<el-col :span="12"> |
|
|
|
|
<el-form-item label="选项F" prop="question"> |
|
|
|
|
<el-input v-model="dialogForm.chooseF" maxlength="200" placeholder="请输入" clearable /> |
|
|
|
|
</el-form-item> |
|
|
|
|
</el-form-item> |
|
|
|
|
</el-col> |
|
|
|
|
</el-row> |
|
|
|
|
<el-row> |
|
|
|
|
<el-row :gutter="20"> |
|
|
|
|
<el-col :span="12"> |
|
|
|
|
<el-form-item label="选项G" prop="question"> |
|
|
|
|
<el-input v-model="dialogForm.chooseG" maxlength="200" placeholder="请输入" clearable /> |
|
|
|
|
</el-form-item> |
|
|
|
|
</el-form-item> |
|
|
|
|
</el-col> |
|
|
|
|
</el-row> |
|
|
|
|
<el-row> |
|
|
|
@ -63,11 +70,11 @@ |
|
|
|
|
<el-col :span="24"> |
|
|
|
|
<el-form-item label="科目" prop="subject"> |
|
|
|
|
<span v-if="dialogForm.subject == 1">科一</span> |
|
|
|
|
<span v-if="dialogForm.subject == 4">科四</span> |
|
|
|
|
<span v-else-if="dialogForm.subject == 4">科四</span> |
|
|
|
|
</el-form-item> |
|
|
|
|
</el-col> |
|
|
|
|
</el-row> |
|
|
|
|
<el-row> |
|
|
|
|
<el-row :gutter="20"> |
|
|
|
|
<el-col :span="8"> |
|
|
|
|
<el-form-item label="精选500题" prop="isVip"> |
|
|
|
|
<el-radio-group v-model="dialogForm.isVip" size="small"> |
|
|
|
@ -132,11 +139,25 @@ |
|
|
|
|
</el-form-item> |
|
|
|
|
</el-col> |
|
|
|
|
</el-row> |
|
|
|
|
<el-row :gutter="20"> |
|
|
|
|
<el-form-item label="题目图片" prop="imageUrl"> |
|
|
|
|
<el-upload |
|
|
|
|
action="#" |
|
|
|
|
accept=".png,.jpg,.jpeg,.gif" |
|
|
|
|
:limit="1" |
|
|
|
|
:http-request="handleImport" |
|
|
|
|
:on-exceed="handleExceed" |
|
|
|
|
:show-file-list="false" |
|
|
|
|
> |
|
|
|
|
<img v-if="dialogForm.imageUrl" :src="dialogForm.imageUrl" style="width: 200px;"> |
|
|
|
|
<i v-else class="el-icon-plus" /> |
|
|
|
|
</el-upload> |
|
|
|
|
</el-form-item> |
|
|
|
|
</el-row> |
|
|
|
|
</el-form> |
|
|
|
|
|
|
|
|
|
</div> |
|
|
|
|
<span slot="footer" class="dialog-footer"> |
|
|
|
|
<el-button plain @click="(visible=false)">取消</el-button> |
|
|
|
|
<el-button plain @click="visible = false">取消</el-button> |
|
|
|
|
<el-button v-jclick type="primary" :disabled="!canSubmit" @click="dialogFormSubmit()">确定</el-button> |
|
|
|
|
</span> |
|
|
|
|
</el-dialog> |
|
|
|
@ -146,7 +167,7 @@ |
|
|
|
|
import { addQuestion } from '@/api/question'; |
|
|
|
|
|
|
|
|
|
export default { |
|
|
|
|
data () { |
|
|
|
|
data() { |
|
|
|
|
return { |
|
|
|
|
visible: false, |
|
|
|
|
canSubmit: true, |
|
|
|
@ -167,7 +188,7 @@ export default { |
|
|
|
|
}; |
|
|
|
|
}, |
|
|
|
|
methods: { |
|
|
|
|
init (info = undefined) { |
|
|
|
|
init(info = undefined) { |
|
|
|
|
// debugger |
|
|
|
|
this.visible = true; |
|
|
|
|
this.$nextTick(() => { |
|
|
|
@ -178,7 +199,7 @@ export default { |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
}, |
|
|
|
|
resetDialogForm () { |
|
|
|
|
resetDialogForm() { |
|
|
|
|
this.dialogForm = { |
|
|
|
|
questionId: undefined, |
|
|
|
|
isVip: 0, |
|
|
|
@ -190,14 +211,14 @@ export default { |
|
|
|
|
examKeys: undefined |
|
|
|
|
}; |
|
|
|
|
}, |
|
|
|
|
closeDialog () { |
|
|
|
|
closeDialog() { |
|
|
|
|
this.$emit('update:dialogVisible', false); |
|
|
|
|
}, |
|
|
|
|
// 表单提交 |
|
|
|
|
dialogFormSubmit () { |
|
|
|
|
dialogFormSubmit() { |
|
|
|
|
this.$refs.dialogForm.validate((valid) => { |
|
|
|
|
if (valid) { |
|
|
|
|
updateQuestion(this.dialogForm).then(response => { |
|
|
|
|
addQuestion(this.dialogForm).then((response) => { |
|
|
|
|
if (response.code == 200) { |
|
|
|
|
this.$modal.msgSuccess('修改成功'); |
|
|
|
|
// this.visible = true; |
|
|
|
@ -205,6 +226,20 @@ export default { |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
}, |
|
|
|
|
handleImport(opt) { |
|
|
|
|
const data = new FormData(); |
|
|
|
|
data.append('file', opt.file); |
|
|
|
|
// 上传 |
|
|
|
|
// api.upload(data).then(resp => { |
|
|
|
|
// if (resp.code == 200) { |
|
|
|
|
// this.$modal.msgSuccess('文件上传成功'); |
|
|
|
|
// this.dialogForm.imageUrl = resp.data; |
|
|
|
|
// } |
|
|
|
|
// }); |
|
|
|
|
}, |
|
|
|
|
handleExceed(files) { |
|
|
|
|
this.handleImport({ file: files[0] }); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|