123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268 |
- <template>
- <QuestionBase>
- <template #content>
- <div class="stem">
- <RichText v-model="data.stem" :font-size="18" placeholder="输入题干" />
- <RichText
- v-if="isEnable(data.property.is_enable_description)"
- v-model="data.description"
- placeholder="输入提示"
- />
- </div>
- <div class="content">
- <ul>
- <li v-for="(item, i) in data.option_list" :key="i" class="content-item">
- <el-input v-if="isEnable(isEnableManualModify)" v-model="item.custom_number" class="manual-modify" />
- <span v-else class="question-number" title="双击切换序号类型" @dblclick="changeOptionType(data)">
- {{ computedQuestionNumber(i, data.option_number_show_mode) }}
- </span>
- <div class="option-content">
- <RichText v-model="item.content" placeholder="输入内容" :inline="true" />
- </div>
- <div class="option-type">
- <div
- v-for="option_type in data.property.option_type_list"
- :key="option_type"
- :class="[
- 'option-type-item',
- {
- active: data.answer.answer_list.find(
- (li) => li.mark === item.mark && li.option_type === option_type,
- ),
- },
- ]"
- @click="selectOptionAnswer(option_type, item.mark)"
- >
- <SvgIcon
- v-if="option_type === option_type_list[0].value"
- icon-class="check-mark"
- width="10"
- height="7"
- />
- <SvgIcon v-if="option_type === option_type_list[1].value" icon-class="cross" size="8" />
- <SvgIcon v-if="option_type === option_type_list[2].value" icon-class="circle" size="10" />
- </div>
- </div>
- <SvgIcon icon-class="delete" class="delete pointer" @click="deleteOption(i)" />
- </li>
- </ul>
- </div>
- <div class="footer">
- <span class="add-option" @click="addOption">
- <SvgIcon icon-class="add-circle" size="14" /> <span>增加选项</span>
- </span>
- </div>
- <div v-if="isEnable(data.property.is_enable_analysis)" class="analysis">
- <div class="analysis-title">解析:</div>
- <RichText v-model="data.analysis" :is-border="true" :font-size="14" placeholder="输入解析" />
- </div>
- </template>
- <template #property>
- <el-form :model="data.property" label-width="72px" label-position="left">
- <el-form-item label="题号">
- <el-input v-model="data.property.question_number" />
- </el-form-item>
- <el-form-item>
- <el-radio
- v-for="{ value, label } in questionNumberTypeList"
- :key="value"
- v-model="data.other.question_number_type"
- :label="value"
- >
- {{ label }}
- </el-radio>
- </el-form-item>
- <el-form-item label="提示">
- <el-radio
- v-for="{ value, label } in switchOption"
- :key="value"
- v-model="data.property.is_enable_description"
- :label="value"
- >
- {{ label }}
- </el-radio>
- </el-form-item>
- <el-form-item label="解析">
- <el-radio
- v-for="{ value, label } in switchOption"
- :key="value"
- v-model="data.property.is_enable_analysis"
- :label="value"
- >
- {{ label }}
- </el-radio>
- </el-form-item>
- <el-form-item label="题干题号">
- <el-select v-model="data.property.stem_question_number_font_size">
- <el-option v-for="item in fontSizeList" :key="item" :label="item" :value="item" />
- </el-select>
- </el-form-item>
- <el-form-item label="选项题号">
- <el-select v-model="data.property.option_question_number_font_size">
- <el-option v-for="item in fontSizeList" :key="item" :label="item" :value="item" />
- </el-select>
- </el-form-item>
- <el-form-item label="选项">
- <el-checkbox-group v-model="optionTypeList">
- <el-checkbox v-for="{ label, value } in option_type_list" :key="value" :label="label" />
- </el-checkbox-group>
- </el-form-item>
- <el-form-item label="分值">
- <el-radio
- v-for="{ value, label } in scoreTypeList"
- :key="value"
- v-model="data.property.score_type"
- :label="value"
- >
- {{ label }}
- </el-radio>
- </el-form-item>
- <el-form-item>
- <el-input-number
- v-model="data.property.score"
- :min="0"
- :step="data.property.score_type === scoreTypeList[0].value ? 1 : 0.1"
- />
- </el-form-item>
- </el-form>
- </template>
- </QuestionBase>
- </template>
- <script>
- import QuestionMixin from '../common/QuestionMixin.js';
- import { changeOptionType } from '@/views/exercise_questions/data/common';
- import {
- getJudgeData,
- option_type_list,
- option_type_value_list,
- getOption,
- analysisRecognitionJudgeData,
- } from '@/views/exercise_questions/data/judge';
- export default {
- name: 'JudgeQuestion',
- mixins: [QuestionMixin],
- props: {
- isEnableManualModify: {
- type: String,
- default: 'false',
- },
- },
- data() {
- return {
- option_type_list,
- changeOptionType,
- data: getJudgeData(),
- };
- },
- computed: {
- optionTypeList: {
- get() {
- if (!this.data.property.option_type_list) {
- return [];
- }
- return this.data.property.option_type_list
- .map((item) => {
- let type = this.option_type_list.find(({ value }) => value === item);
- return type ? type.label : '';
- })
- .filter((word) => word && word.length > 0);
- },
- set(val) {
- this.data.property.option_type_list = val
- .map((item) => {
- let type = this.option_type_list.find(({ label }) => label === item);
- return type ? type.value : '';
- })
- .filter((word) => word && word.length > 0)
- .sort((a, b) => option_type_value_list.indexOf(a) - option_type_value_list.indexOf(b));
- },
- },
- },
- watch: {
- isEnableManualModify: {
- handler(val) {
- if (val === 'false') return;
- this.data.option_list = this.data.option_list.map((item, i) => {
- return { ...item, custom_number: `${i + 1}` };
- });
- },
- },
- },
- methods: {
- addOption() {
- this.data.option_list.push(getOption());
- },
- /**
- * 智能识别
- * @param {String} text 识别数据
- */
- recognition(text) {
- let arr = this.recognitionCommon(text);
- let obj = analysisRecognitionJudgeData(arr);
- this.recognitionCommonSetObj(obj);
- this.data.answer.answer_list = [];
- },
- /**
- * 选择选项答案
- * @param {String} option_type 选项类型
- * @param {String} mark 选项标记
- */
- selectOptionAnswer(option_type, mark) {
- const index = this.data.answer.answer_list.findIndex((item) => item.mark === mark);
- if (index === -1) {
- this.data.answer.answer_list.push({ option_type, mark });
- } else {
- this.data.answer.answer_list[index].option_type = option_type;
- }
- },
- },
- };
- </script>
- <style lang="scss" scoped>
- .content {
- &-item {
- .manual-modify {
- width: 55px;
- :deep .el-input__inner {
- height: 36px;
- }
- }
- .option-type {
- display: flex;
- column-gap: 8px;
- align-items: center;
- height: 32px;
- padding: 8px 16px;
- background-color: $fill-color;
- &-item {
- display: flex;
- align-items: center;
- justify-content: center;
- width: 16px;
- height: 16px;
- color: $font-light-color;
- cursor: pointer;
- background-color: #d7d7d7;
- border-radius: 2px;
- &.active {
- color: #fff;
- background-color: $main-color;
- }
- }
- }
- }
- }
- </style>
|