From 38cdff1163573261e36f9d7f8920e1578e1172c8 Mon Sep 17 00:00:00 2001 From: 闫增涛 <1829501689@qq.com> Date: 星期五, 22 十一月 2024 10:55:33 +0800 Subject: [PATCH] 数学书收藏功能优化 --- src/components/examinations/index.vue | 180 ++++++++++++++++++++++++++++++++++++++++++++--------------- 1 files changed, 134 insertions(+), 46 deletions(-) diff --git a/src/components/examinations/index.vue b/src/components/examinations/index.vue index 550baa2..35925bb 100644 --- a/src/components/examinations/index.vue +++ b/src/components/examinations/index.vue @@ -7,14 +7,28 @@ v-show="item.infoList.length" > <p class="catalogName" :style="{ color: primaryColor }"> - <span v-if="nindex == 0">涓�銆�</span> - <span v-if="nindex == 1">浜屻��</span> - <span v-if="nindex == 2">涓夈��</span> - <span v-if="nindex == 3">鍥涖��</span> - <span v-if="nindex == 4">浜斻��</span> - <span v-html="item.catalogName" ></span> + <span class="catalogName-box" > + <span v-if="nindex == 0">涓�銆�</span> + <span v-if="nindex == 1">浜屻��</span> + <span v-if="nindex == 2">涓夈��</span> + <span v-if="nindex == 3">鍥涖��</span> + <span v-if="nindex == 4">浜斻��</span> + <span v-html="item.catalogName"></span> + </span> + <img + :src="item.isCollect ? isHeart : heart" + alt="" + class="collect-png" + @click="setCollect(nindex, index)" + v-if="!hideCollect && item.type == 'material'" + /> </p> - <el-image v-if="item.catalogImage" :src="item.catalogImage"></el-image> + <el-image + v-if="item.catalogImage" + :src="item.catalogImage" + :preview-src-list="[item.catalogImage]" + class="catalogImage" + ></el-image> <ul> <li v-for="(value, index) in item.infoList" @@ -33,17 +47,17 @@ </span> <!-- 鍚姏杩涘害鏉� --> <!-- <answerAudioPlayer :audioUrl="value.src" v-show="item.name == '鍚姏棰�'" /> --> - <!-- 浠呮枃瀛� --> <p class="titleText text-fl" v-if=" - value.stemStyle == 'Txt' && value.questionType != 'completion' + value.stemStyle == 'Txt' && + value.questionType != 'completion' && + value.questionType != 'dropdown' " :id="value.id" v-html="value.stem.stemTxt" - > - </p> + ></p> <!-- 浠呭浘鐗� --> <el-image class="stemImg" @@ -56,8 +70,7 @@ class="stemTxtAndImage titleText" v-else-if="value.stemStyle == 'TxtAndImage'" > - <span v-html="value.stem.stemTxt"> - </span> + <span v-html="value.stem.stemTxt"> </span> <el-image :src="getPublicImage(value.stem.stemImage, 150)" :preview-src-list="[getPublicImage(value.stem.stemImage)]" @@ -73,15 +86,24 @@ <span v-if="typeof itemText == 'string'" v-html="itemText" + class="input-txt" ></span> - <input + <!-- <input v-else type="text" class="input" v-model.trim="value.userAnswer[itemText.num]" :disabled="value.isComplete" :style="{ backgroundColor: inputBc }" - /> + /> --> + <math-field + v-else + class="mathField" + :menuItems="[]" + @input="onChangeInput($event,nindex,index,itemText.num)" + > + {{ value.userAnswer[itemText.num] }} + </math-field> </span> </p> <!-- 瀵屾枃鏈� --> @@ -91,13 +113,38 @@ v-html="value.stem.stemTxt" v-cloak ></p> + <!-- 涓嬫媺閫夋嫨棰� --> + <p class="titleText" v-if="value.questionType == 'dropdown'"> + <span + v-for="(itemText, indexText) in value.stem" + :key="indexText + 'questionType'" + > + <span + v-if="typeof itemText == 'string'" + v-html="itemText" + class="input-txt" + ></span> + <select + v-else + v-model="value.userAnswer" + :disabled="value.isComplete" + > + <option + v-for="(citem, cindex) in value.option" + :key="cindex + 'dropdown'" + :label="citem" + :value="citem" + ></option> + </select> + </span> + </p> </div> <img :src="value.isCollect ? isHeart : heart" alt="" class="collect-png" @click="setCollect(nindex, index)" - v-if="!(hideCollect && value.questionType == 'shortAnswer')" + v-if="!hideCollect && item.type != 'material'" /> <!-- 鏀惰棌 --> </div> @@ -212,17 +259,16 @@ </el-checkbox> </el-checkbox-group> <!-- 绠�绛� 缈昏瘧 --> - <!-- <TEditorVue - v-else-if="value.questionType == 'shortAnswer'" - :value="value.userAnswer" - :disabled="value.isComplete" - @getContent=" - (val) => { - value.userAnswer = val.trim(); - inputChange(); - } - " - ></TEditorVue> --> + <TEditorVue + v-else-if="value.questionType == 'formula'" + :value="value.userAnswer" + :disabled="value.isComplete" + @getContent=" + (val) => { + value.userAnswer = val; + } + " + /> <el-input :disabled="value.isComplete" style="width: 94%; margin: 0 auto" @@ -249,9 +295,11 @@ <div class="analysis" v-if="value.isComplete"> <el-collapse v-model="value.isUnfold" - @change="handleChange(value)" accordion - v-if="value.questionType != 'shortAnswer'" + v-if=" + value.questionType != 'shortAnswer' && + value.questionType != 'formula' + " > <el-collapse-item :name="value.id" class="objective"> <template #title> @@ -350,8 +398,8 @@ ></div> <div v-else>鏆傛棤鏁版嵁</div> </el-collapse-item> - <!-- 涓昏棰� --> </el-collapse> + <!-- 涓昏棰� --> <el-collapse v-else v-model="value.isUnfold" accordion> <el-collapse-item :name="value.id" class="objective"> <template #title> @@ -379,7 +427,6 @@ <div class="referBox" v-if="value.analysisCon"> <span>瑙f瀽锛�</span> <p - v-if="value.analysisCon" v-html="value.analysisCon" :class=" [ @@ -389,7 +436,6 @@ ].join(' ') " ></p> - <p v-else class="ti-2">鏆傛棤鏁版嵁</p> </div> </el-collapse-item> </el-collapse> @@ -486,9 +532,12 @@ </template> <script> +import { MathfieldElement } from "mathlive"; import { Message } from "element-ui"; +import TEditorVue from "../teditor/index.vue"; export default { name: "examination-option", + components: { TEditorVue }, props: { cardList: { type: Array, @@ -567,11 +616,18 @@ methods: { // 鑾峰彇涓嶅彈淇濇姢鐨勫浘鐗� getPublicImage(md5, width, height) { - if(md5.includes('http')) return md5 + if (!md5) return; + if (md5.includes("http")) { + if (width) { + return md5 + `?width=${width}`; + } else { + return md5; + } + } let src = null; if (md5) { src = process.env.VUE_APP_API_URL + `/file/GetPreViewImage?md5=${md5}`; - } + } if (width) src += `&width=${width}`; if (height) src += `&height=${height}`; return src; @@ -656,9 +712,9 @@ } } else if ( citem.questionType == "singleChoice" || - citem.questionType == "judge" + citem.questionType == "judge" || + citem.questionType == "dropdown" ) { - if (citem.id == "63825") console.log("i", item); citem.isRight = citem.answer == citem.userAnswer; } else if (citem.questionType == "shortAnswer") { // 绠�绛� 缈昏瘧 @@ -770,8 +826,15 @@ }, // 棰樼洰鏀惰棌鎸夐挳,鏀惰棌鍜屽彇娑堝悓涓�鎺ュ彛锛屽彇娑堟暟缁勫噺鍘昏椤筰d setCollect(num, number) { - const item = this.cardData[num].infoList[number]; + let item = null + if(number) { + item = this.cardData[num].infoList[number]; + + } else { + item = this.cardData[num] + } item.isCollect = !item.isCollect; + console.log(111,item); if (this.cardData.length == 0) { this.collectList.push(item.id); } else { @@ -789,7 +852,7 @@ const item = this.allCollect[index]; if (item.type == this.sourceType) item.collectList = this.collectList; } - // console.log(this.allCollect, this.collectList, list); + console.log('鐐瑰嚮鏀惰棌鎸夐挳',this.allCollect) this.MG.identity .setUserKey({ setKeyRequests: [ @@ -816,6 +879,7 @@ .then((res) => { try { const collect = JSON.parse(res[0].value); + console.log('鍏ㄩ儴鏀惰棌id',collect); if (collect.length) { this.collectList = collect.find( (citem) => citem.type == this.sourceType @@ -859,21 +923,35 @@ ).errorList; } } catch (error) {} - console.log("閿欓鍒楄〃", this.allError); }) .catch(() => {}); + }, + onChangeInput(e,index,cindex,num) { + this.cardData[index].infoList[cindex].userAnswer[num] = e.target.value }, }, }; </script> +<style lang="less"> +.titleText img { + max-width: 80%; +} +</style> <style lang="less" scoped> .catalogName { + display: flex; text-indent: 1em !important; font-size: 16px; + .catalogName-box { + display: inline-block; + width: 94%; + } } - +.catalogImage { + width: 50%; +} .examination { min-height: 100px; ul { @@ -1010,9 +1088,9 @@ font-weight: bold; } .text-fl { - display:flex; - align-items:center; - flex-wrap:wrap; + display: flex; + align-items: center; + flex-wrap: wrap; } .titleText { text-align: left; @@ -1020,16 +1098,22 @@ font-size: 16px; line-height: 32px; color: #000; - + .input-txt { + display: flex; + flex-wrap: wrap; + align-items: center; + } span { display: inline-block; font-size: 16px; - // line-height: 26px; color: #000; font-weight: 400; margin-top: 6px; } - + select { + outline: none; + min-width: 100px; + } input { width: 140px; height: 24px; @@ -1064,6 +1148,10 @@ width: 21px; height: 21px; } + .mathField { + min-width: 200px; + max-width: 518px; + } } /** 閫夐」 */ -- Gitblit v1.9.1