完成试题库
This commit is contained in:
		| @@ -1,7 +1,7 @@ | |||||||
| <template> | <template> | ||||||
|   <ai-detail class="AppQuestionBank-add" v-loading="isLoading"> |   <ai-detail class="AppQuestionBank-add" v-loading="isLoading"> | ||||||
|     <template slot="title"> |     <template slot="title"> | ||||||
|       <ai-title :title="params.id ? '编辑' + '试题库' : '添加' + '试题库'" isShowBack isShowBottomBorder @onBackClick="cancel(false)"></ai-title> |       <ai-title :title="params.id ? '编辑' + '试题' : '添加' + '试题'" isShowBack isShowBottomBorder @onBackClick="cancel(false)"></ai-title> | ||||||
|     </template> |     </template> | ||||||
|     <template slot="content"> |     <template slot="content"> | ||||||
|       <ai-card title="基本信息"> |       <ai-card title="基本信息"> | ||||||
| @@ -12,37 +12,35 @@ | |||||||
|             </el-form-item> |             </el-form-item> | ||||||
|             <el-form-item prop="type" label="题目类型" :rules="[{required: true, message: '请选择题目类型', trigger: 'change'}]"> |             <el-form-item prop="type" label="题目类型" :rules="[{required: true, message: '请选择题目类型', trigger: 'change'}]"> | ||||||
|               <el-radio-group v-model="form.type" @change="onTypeChange"> |               <el-radio-group v-model="form.type" @change="onTypeChange"> | ||||||
|                 <el-radio label="1">单选题</el-radio> |                 <el-radio :label="item.dictValue" :key="item.dictValue" v-for="item in dict.getDict('qjQBType')">{{ item.dictName }}</el-radio> | ||||||
|                 <el-radio label="2">多选题</el-radio> |  | ||||||
|                 <el-radio label="3">判断题</el-radio> |  | ||||||
|               </el-radio-group> |               </el-radio-group> | ||||||
|             </el-form-item> |             </el-form-item> | ||||||
|             <el-form-item prop="options" v-if="form.type !== '3'" style="width: 100%;" label="题目选项" :rules="[{required: true, message: '请输入题目选项', trigger: 'change'}]"> |             <el-form-item prop="items" v-if="form.type !== '2'" style="width: 100%;" label="题目选项" :rules="[{required: true, message: '请输入题目选项', trigger: 'change'}]"> | ||||||
|               <div class="options" v-for="(item, index) in form.options" :key="index"> |               <div class="options" v-for="(item, index) in form.items" :key="index"> | ||||||
|                 <span>选项{{ index + 1 }}</span> |                 <span>选项{{ index + 1 }}</span> | ||||||
|                 <el-input placeholder="请输入选项名" size="small" :maxlength="100" show-word-limit v-model="item.label"></el-input> |                 <el-input placeholder="请输入选项名" size="small" :maxlength="100" show-word-limit v-model="item.content"></el-input> | ||||||
|                 <i class="iconfont iconDelete" @click="removeOptions(index)"></i> |                 <i class="iconfont iconDelete" @click="removeOptions(index)"></i> | ||||||
|               </div> |               </div> | ||||||
|               <el-button type="text" class="add-select" @click="addOptions">添加选项</el-button> |               <el-button type="text" class="add-select" @click="addOptions">添加选项</el-button> | ||||||
|             </el-form-item> |             </el-form-item> | ||||||
|             <el-form-item style="width: 100%;" v-if="form.options.length && form.type !== '3'" prop="answer" label="题目答案" :rules="[{required: true, message: '请选择题目答案', trigger: 'change'}]"> |             <el-form-item style="width: 100%;" v-if="form.items.length && form.type !== '2'" prop="answer" label="题目答案" :rules="[{required: true, message: '请选择题目答案', trigger: 'change'}]"> | ||||||
|               <el-select :multiple="form.type === '2'" v-model="form.answer" size="small" placeholder="请选择题目答案"> |               <el-select :multiple="form.type === '1'" v-model="form.answer" size="small" placeholder="请选择题目答案"> | ||||||
|                 <el-option |                 <el-option | ||||||
|                   v-for="(item, index) in form.options" |                   v-for="(item, index) in form.items" | ||||||
|                   :key="index" |                   :key="index" | ||||||
|                   :label="item.label" |                   :label="item.content" | ||||||
|                   :value="item.label"> |                   :value="item.content"> | ||||||
|                 </el-option> |                 </el-option> | ||||||
|               </el-select> |               </el-select> | ||||||
|             </el-form-item> |             </el-form-item> | ||||||
|             <el-form-item v-if="form.type === '3'" style="width: 100%;" prop="answer" label="题目答案" :rules="[{required: true, message: '请选择题目答案', trigger: 'change'}]"> |             <el-form-item v-if="form.type === '2'" style="width: 100%;" prop="answer" label="题目答案" :rules="[{required: true, message: '请选择题目答案', trigger: 'change'}]"> | ||||||
|               <el-radio-group v-model="form.answer"> |               <el-radio-group v-model="form.answer"> | ||||||
|                 <el-radio label="1">正确</el-radio> |                 <el-radio label="1">正确</el-radio> | ||||||
|                 <el-radio label="0">错误</el-radio> |                 <el-radio label="0">错误</el-radio> | ||||||
|               </el-radio-group> |               </el-radio-group> | ||||||
|             </el-form-item> |             </el-form-item> | ||||||
|             <el-form-item label="答案解析" prop="content" style="width: 100%;" :rules="[{required: true, message: '请输入内容', trigger: 'change'}]"> |             <el-form-item label="答案解析" prop="analysis" style="width: 100%;" :rules="[{required: true, message: '请输入内容', trigger: 'change'}]"> | ||||||
|               <ai-editor v-model="form.content" :instance="instance"/> |               <ai-editor v-model="form.analysis" :instance="instance"/> | ||||||
|             </el-form-item> |             </el-form-item> | ||||||
|           </el-form> |           </el-form> | ||||||
|         </template> |         </template> | ||||||
| @@ -71,13 +69,14 @@ | |||||||
|         info: {}, |         info: {}, | ||||||
|         form: { |         form: { | ||||||
|           title: '', |           title: '', | ||||||
|           content: '', |           analysis: '', | ||||||
|           type: '1', |           type: '0', | ||||||
|           answer: '', |           answer: '', | ||||||
|           options: [] |           items: [] | ||||||
|         }, |         }, | ||||||
|         isLoading: false, |         isLoading: false, | ||||||
|         id: '' |         id: '', | ||||||
|  |         sort: ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I'] | ||||||
|       } |       } | ||||||
|     }, |     }, | ||||||
|  |  | ||||||
| @@ -86,17 +85,28 @@ | |||||||
|     }, |     }, | ||||||
|  |  | ||||||
|     created () { |     created () { | ||||||
|  |       this.dict.load('qjQBType').then(() => { | ||||||
|         if (this.params && this.params.id) { |         if (this.params && this.params.id) { | ||||||
|           this.id = this.params.id |           this.id = this.params.id | ||||||
|           this.getInfo(this.params.id) |           this.getInfo(this.params.id) | ||||||
|         } |         } | ||||||
|  |       }) | ||||||
|     }, |     }, | ||||||
|  |  | ||||||
|     methods: { |     methods: { | ||||||
|       getInfo (id) { |       getInfo (id) { | ||||||
|         this.instance.post(`/app/appcontentinfo/queryDetailById?id=${id}`).then(res => { |         this.instance.post(`/app/appquestionbank/queryDetailById?id=${id}`).then(res => { | ||||||
|           if (res.code === 0) { |           if (res.code === 0) { | ||||||
|             this.form = res.data |             this.form = { | ||||||
|  |               ...res.data, | ||||||
|  |               answer: res.data.type === '1' ? | ||||||
|  |                 res.data.items.filter(v => v.checked === '1').map(v => v.content) | ||||||
|  |                 : res.data.items.filter(v => v.checked === '1')[0].content | ||||||
|  |             } | ||||||
|  |  | ||||||
|  |             if (res.data.type === '2') { | ||||||
|  |               this.form.answer = this.form.answer === '正确' ? '1' : '0' | ||||||
|  |             } | ||||||
|           } |           } | ||||||
|         }) |         }) | ||||||
|       }, |       }, | ||||||
| @@ -110,32 +120,45 @@ | |||||||
|       }, |       }, | ||||||
|  |  | ||||||
|       addOptions () { |       addOptions () { | ||||||
|         this.form.options.push({ |         this.form.items.push({ | ||||||
|           label: '' |           content: '' | ||||||
|         }) |         }) | ||||||
|       }, |       }, | ||||||
|  |  | ||||||
|       removeOptions (index) { |       removeOptions (index) { | ||||||
|         this.form.options.splice(index, 1) |         this.form.items.splice(index, 1) | ||||||
|       }, |       }, | ||||||
|  |  | ||||||
|       confirm () { |       confirm () { | ||||||
|         this.$refs.form.validate((valid) => { |         this.$refs.form.validate((valid) => { | ||||||
|           if (valid) { |           if (valid) { | ||||||
|             this.isLoading = true |             const items = this.form.type !== '2' ? this.form.items.map((v, index) => { | ||||||
|             this.instance.post(`/app/appcontentinfo/addOrUpdate`, { |               return { | ||||||
|               ...this.form |                 ...v, | ||||||
|  |                 sort: this.sort[index], | ||||||
|  |                 checked: this.form.type === '0' ? (this.form.answer === v.content ? '1' : '0') : (this.form.answer.indexOf(v.content) !== -1 ? '1' : 0) | ||||||
|  |               } | ||||||
|  |             }) : [{ | ||||||
|  |               content: '正确', | ||||||
|  |               sort: 'A', | ||||||
|  |               checked: this.form.answer === '1' ? 1 : 0 | ||||||
|  |             }, { | ||||||
|  |               content: '错误', | ||||||
|  |               sort: 'B', | ||||||
|  |               checked: this.form.answer === '0' ? 1 : 0 | ||||||
|  |             }] | ||||||
|  |  | ||||||
|  |             this.instance.post(`/app/appquestionbank/addOrUpdate`, { | ||||||
|  |               ...this.form, | ||||||
|  |               items, | ||||||
|  |               id: this.params.id || '' | ||||||
|             }).then(res => { |             }).then(res => { | ||||||
|               if (res.code == 0) { |               if (res.code == 0) { | ||||||
|                 this.$message.success('提交成功') |                 this.$message.success('提交成功') | ||||||
|                 setTimeout(() => { |                 setTimeout(() => { | ||||||
|                   this.cancel(true) |                   this.cancel(true) | ||||||
|                 }, 600) |                 }, 600) | ||||||
|               } else { |  | ||||||
|                 this.isLoading = false |  | ||||||
|               } |               } | ||||||
|             }).catch(() => { |  | ||||||
|               this.isLoading = false |  | ||||||
|             }) |             }) | ||||||
|           } |           } | ||||||
|         }) |         }) | ||||||
|   | |||||||
| @@ -10,11 +10,18 @@ | |||||||
|           <ai-wrapper |           <ai-wrapper | ||||||
|             label-width="120px"> |             label-width="120px"> | ||||||
|             <ai-info-item label="题目描述" isLine :value="info.title"></ai-info-item> |             <ai-info-item label="题目描述" isLine :value="info.title"></ai-info-item> | ||||||
|             <ai-info-item label="题目类型" isLine :value="info.title"></ai-info-item> |             <ai-info-item label="题目类型" :value="dict.getLabel('qjQBType', info.type)"></ai-info-item> | ||||||
|             <ai-info-item label="正确答案" isLine :value="info.areaName"></ai-info-item> |             <ai-info-item label="正确答案" :value="info.answer"></ai-info-item> | ||||||
|             <ai-info-item label="题目选项" isLine :value="info.contentType"></ai-info-item> |             <ai-info-item label="题目选项" isLine> | ||||||
|             <ai-info-item label="正文" isLine> |               <div class=""> | ||||||
|               <AiArticle :value="info.content"></AiArticle> |                 <div class="options" v-for="(item, index) in info.items" :key="index"> | ||||||
|  |                   <span>{{ item.sort }}:</span> | ||||||
|  |                   <span>{{ item.content }}</span> | ||||||
|  |                 </div> | ||||||
|  |               </div> | ||||||
|  |             </ai-info-item> | ||||||
|  |             <ai-info-item label="答案解析" isLine> | ||||||
|  |               <AiArticle :value="info.analysis"></AiArticle> | ||||||
|             </ai-info-item> |             </ai-info-item> | ||||||
|           </ai-wrapper> |           </ai-wrapper> | ||||||
|         </template> |         </template> | ||||||
| @@ -30,32 +37,29 @@ | |||||||
|     props: { |     props: { | ||||||
|       instance: Function, |       instance: Function, | ||||||
|       dict: Object, |       dict: Object, | ||||||
|       params: Object, |       params: Object | ||||||
|       moduleId: String |  | ||||||
|     }, |     }, | ||||||
|  |  | ||||||
|     data () { |     data () { | ||||||
|       return { |       return { | ||||||
|         info: {}, |         info: {} | ||||||
|         id: '' |  | ||||||
|       } |       } | ||||||
|     }, |     }, | ||||||
|  |  | ||||||
|     created () { |     created () { | ||||||
|       if (this.params && this.params.id) { |       this.dict.load('qjQBType').then(() => { | ||||||
|         this.id = this.params.id |  | ||||||
|         this.getInfo(this.params.id) |         this.getInfo(this.params.id) | ||||||
|       } |       }) | ||||||
|     }, |     }, | ||||||
|  |  | ||||||
|     methods: { |     methods: { | ||||||
|       getInfo (id) { |       getInfo (id) { | ||||||
|         this.instance.post(`/app/appcontentinfo/queryDetailById?id=${id}`).then(res => { |         this.instance.post(`/app/appquestionbank/queryDetailById?id=${id}`).then(res => { | ||||||
|           if (res.code === 0) { |           if (res.code === 0) { | ||||||
|             this.info = res.data |             this.info = { | ||||||
|             this.info.pictureUrl = res.data.pictureUrl ? [{ |               ...res.data, | ||||||
|               url: res.data.pictureUrl |               answer: res.data.items.filter(v => v.checked === '1').map(v => v.content).join(',') | ||||||
|             }] : [] |             } | ||||||
|           } |           } | ||||||
|         }) |         }) | ||||||
|       }, |       }, | ||||||
|   | |||||||
| @@ -29,7 +29,7 @@ | |||||||
|         :current.sync="search.current" |         :current.sync="search.current" | ||||||
|         :size.sync="search.size" |         :size.sync="search.size" | ||||||
|         @getList="getList"> |         @getList="getList"> | ||||||
|         <el-table-column slot="options" width="120px" fixed="right" label="操作" align="center"> |         <el-table-column slot="options" width="160px" fixed="right" label="操作" align="center"> | ||||||
|           <template slot-scope="{ row }"> |           <template slot-scope="{ row }"> | ||||||
|             <div class="table-options"> |             <div class="table-options"> | ||||||
|               <el-button type="text" @click="toAdd(row.id)">编辑</el-button> |               <el-button type="text" @click="toAdd(row.id)">编辑</el-button> | ||||||
| @@ -63,19 +63,21 @@ | |||||||
|         total: 10, |         total: 10, | ||||||
|         colConfigs: [ |         colConfigs: [ | ||||||
|           { prop: 'title',  label: '题目', align: 'left' }, |           { prop: 'title',  label: '题目', align: 'left' }, | ||||||
|           { prop: 'createUserName',  label: '题目类型', align: 'center' } |           { prop: 'type',  label: '题目类型', align: 'center', format: v => this.dict.getLabel('qjQBType', v) + '题' } | ||||||
|         ], |         ], | ||||||
|         tableData: [] |         tableData: [] | ||||||
|       } |       } | ||||||
|     }, |     }, | ||||||
|  |  | ||||||
|     created() { |     created() { | ||||||
|  |       this.dict.load('qjQBType').then(() => { | ||||||
|         this.getList() |         this.getList() | ||||||
|  |       }) | ||||||
|     }, |     }, | ||||||
|  |  | ||||||
|     methods: { |     methods: { | ||||||
|       getList() { |       getList() { | ||||||
|         this.instance.post(`/app/appmarketingactivityinfo/list`, null, { |         this.instance.post(`/app/appquestionbank/list`, null, { | ||||||
|           params: { |           params: { | ||||||
|             ...this.search |             ...this.search | ||||||
|           } |           } | ||||||
| @@ -88,8 +90,8 @@ | |||||||
|       }, |       }, | ||||||
|  |  | ||||||
|       remove (id) { |       remove (id) { | ||||||
|         this.$confirm('确定删除该活动?').then(() => { |         this.$confirm('确定删除该试题?').then(() => { | ||||||
|           this.instance.post(`/app/appmarketingactivityinfo/delete?id=${id}`).then(res => { |           this.instance.post(`/app/appquestionbank/delete?id=${id}`).then(res => { | ||||||
|             if (res.code == 0) { |             if (res.code == 0) { | ||||||
|               this.$message.success('删除成功!') |               this.$message.success('删除成功!') | ||||||
|               this.getList() |               this.getList() | ||||||
|   | |||||||
| @@ -175,7 +175,9 @@ | |||||||
|       margin-top: 18px; |       margin-top: 18px; | ||||||
|       margin-bottom: 18px |       margin-bottom: 18px | ||||||
|     } |     } | ||||||
|  |     :deep( p:first-child){ | ||||||
|  |       margin-top: 0!important; | ||||||
|  |     } | ||||||
|     :deep( img ){ |     :deep( img ){ | ||||||
|       max-height: none |       max-height: none | ||||||
|     } |     } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user