DialogueAnswerViewChs.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414
  1. <!-- -->
  2. <template>
  3. <div class="dialogue-answer-view NPC-zhedie" v-if="isShowTemp">
  4. <!-- 标题 -->
  5. <template v-if="curQue.title">
  6. <div class="topTitle">
  7. <div class="NPC-top-left">
  8. <span class="NPC-topTitle-text">{{ curQue.title }}</span>
  9. </div>
  10. <div class="NPC-top-right" @click="handleChangeTab">
  11. <span class="NPC-top-right-text">{{
  12. wordShow ? "收起" : "展开"
  13. }}</span>
  14. <img v-if="wordShow" src="../../../../assets/NPC/down.png" alt="" />
  15. <img
  16. v-else
  17. class="rotate"
  18. src="../../../../assets/NPC/down.png"
  19. alt=""
  20. />
  21. </div>
  22. </div>
  23. <el-collapse-transition>
  24. <div :class="['dialogue-answer-content']" v-show="wordShow">
  25. <div class="guide" v-if="curQue.guide">{{ curQue.guide }}</div>
  26. <div
  27. :class="[
  28. 'dialogue-answer-inner',
  29. curQue.option &&
  30. curQue.option.length > 0 &&
  31. curQue.option[index] &&
  32. curQue.option[index].detail &&
  33. curQue.option[index].detail.length > 0
  34. ? 'hasoption'
  35. : '',
  36. index == curQue.list.length - 1 ? 'haspadding' : '',
  37. ]"
  38. v-for="(item, index) in curQue.list"
  39. :key="'list' + index"
  40. >
  41. <span class="number" v-if="item.number">{{ item.number }}</span>
  42. <div
  43. class="dialogue-img"
  44. v-if="item.img_list && item.img_list.length > 0"
  45. >
  46. <el-image
  47. style="width: 196px; height: 164px"
  48. :src="item.img_list[0].id"
  49. fit="scale-down"
  50. ></el-image>
  51. </div>
  52. <div class="dialogue-answer-model">
  53. <AnswerModel
  54. :curQue="item"
  55. :Bookanswer="curQue.Bookanswer[index]"
  56. :pyPosition="curQue.pyPosition"
  57. :enPosition="curQue.enPosition"
  58. :colorBox="colorBox"
  59. :TaskModel="TaskModel"
  60. :listIndex="index"
  61. :judgeAnswer="judgeAnswer"
  62. :audioWidth="item.number?592:620"
  63. />
  64. </div>
  65. <template
  66. v-if="
  67. curQue.option &&
  68. curQue.option.length > 0 &&
  69. curQue.option[index] &&
  70. curQue.option[index].detail &&
  71. curQue.option[index].detail.length > 0
  72. "
  73. >
  74. <OptionModel :curOption="curQue.option[index]" :index="index" />
  75. </template>
  76. </div>
  77. </div>
  78. </el-collapse-transition>
  79. </template>
  80. <template v-else>
  81. <div class="dialogue-answer-content">
  82. <div class="guide" v-if="curQue.guide">{{ curQue.guide }}</div>
  83. <div
  84. class="dialogue-answer-inner"
  85. v-for="(item, index) in curQue.list"
  86. :key="'list' + index"
  87. >
  88. <template v-if="isShowQue(index)">
  89. <span class="number" v-if="item.number">{{ item.number }}</span>
  90. <div
  91. class="dialogue-img"
  92. v-if="item.img_list && item.img_list.length > 0"
  93. >
  94. <el-image
  95. style="width: 196px; height: 164px"
  96. :src="item.img_list[0].id"
  97. fit="scale-down"
  98. ></el-image>
  99. </div>
  100. <div class="dialogue-answer-model">
  101. <AnswerModel
  102. :curQue="item"
  103. :Bookanswer="curQue.Bookanswer[index]"
  104. :pyPosition="curQue.pyPosition"
  105. :enPosition="curQue.enPosition"
  106. :colorBox="colorBox"
  107. :listIndex="index"
  108. :TaskModel="TaskModel"
  109. :judgeAnswer="judgeAnswer"
  110. :audioWidth="item.number?592:620"
  111. />
  112. </div>
  113. <template
  114. v-if="
  115. curQue.option &&
  116. curQue.option.length > 0 &&
  117. curQue.option[index] &&
  118. curQue.option[index].detail &&
  119. curQue.option[index].detail.length > 0
  120. "
  121. >
  122. <OptionModel :curOption="curQue.option[index]" :index="index" />
  123. </template>
  124. <template
  125. v-if="
  126. curQue.wordcard &&
  127. curQue.wordcard.length > 0 &&
  128. curQue.wordcard[index]
  129. "
  130. >
  131. <WordcardModel
  132. :curWordcard="curQue.wordcard[index]"
  133. :index="index"
  134. :pyPosition="curQue.pyPosition"
  135. />
  136. </template>
  137. </template>
  138. </div>
  139. </div>
  140. </template>
  141. </div>
  142. </template>
  143. <script>
  144. import AudioLine from "../AudioLine.vue";
  145. import RoleChs from "./RoleChs.vue";
  146. import RemarkChs from "./RemarkChs.vue";
  147. import Soundrecord from "../Soundrecord.vue";
  148. import AnswerModel from "./AnswerModel.vue";
  149. import OptionModel from "./OptionModel.vue";
  150. import WordcardModel from "./WordcardModel.vue";
  151. export default {
  152. name: "DialogueAnswerViewChs",
  153. components: {
  154. AudioLine,
  155. RoleChs,
  156. RemarkChs,
  157. Soundrecord,
  158. AnswerModel,
  159. OptionModel,
  160. WordcardModel,
  161. },
  162. props: ["curQue", "colorBox", "TaskModel", "judgeAnswer"],
  163. data() {
  164. return {
  165. wordShow: true,
  166. noFont: ["~", "!", "@", "#", "$", "%", "^", "&", "*", "(", ")", "/"],
  167. userAnswer: {
  168. recordList: [],
  169. input: [],
  170. judge: [],
  171. },
  172. judgeAnswersList: [],
  173. userErrorNumberTotal: 0,
  174. };
  175. },
  176. computed: {
  177. isShowTemp() {
  178. let _this = this;
  179. let bool = false;
  180. if (_this.curQue && _this.curQue.Bookanswer) {
  181. if (_this.judgeAnswer == "standardAnswer") {
  182. if (_this.userErrorNumberTotal > 0) {
  183. bool = true;
  184. } else {
  185. bool = false;
  186. }
  187. } else {
  188. bool = true;
  189. }
  190. }
  191. return bool;
  192. },
  193. isShowQue() {
  194. return function (index) {
  195. let _this = this;
  196. let bool = false;
  197. let userErrorNumberTotal = 0;
  198. let Bookanswer = _this.curQue.Bookanswer;
  199. if (Bookanswer && Bookanswer.length > 0) {
  200. userErrorNumberTotal = _this.countUserErrorNumber(Bookanswer[index]);
  201. if (_this.judgeAnswer == "standardAnswer") {
  202. if (userErrorNumberTotal > 0) {
  203. bool = true;
  204. } else {
  205. bool = false;
  206. }
  207. } else {
  208. bool = true;
  209. }
  210. }
  211. return bool;
  212. };
  213. },
  214. },
  215. watch: {},
  216. //方法集合
  217. methods: {
  218. handleChangeTab() {
  219. this.wordShow = !this.wordShow;
  220. },
  221. handleData() {
  222. let list = JSON.parse(JSON.stringify(this.curQue.list));
  223. list.forEach((item) => {
  224. let answerArr = [];
  225. if (item.answer) {
  226. answerArr = item.answer.split("\n");
  227. }
  228. item.answerArr = answerArr;
  229. });
  230. this.$set(this.curQue, "list", list);
  231. },
  232. initAnswer() {
  233. let reg = /_{2,}/g;
  234. let BookAnswer = [];
  235. let list = JSON.parse(JSON.stringify(this.curQue.list));
  236. list.forEach((item, index) => {
  237. let answerArr = [];
  238. if (item.answer) {
  239. answerArr = item.answer.split("\n");
  240. }
  241. let arr = item.article.match(reg);
  242. let paraLeg = item.detail.length;
  243. let userAnswer = JSON.parse(JSON.stringify(this.userAnswer));
  244. if (arr) {
  245. arr.forEach((aItem, aIndex) => {
  246. let re = {
  247. value: "",
  248. userAnswerJudge:
  249. answerArr.length > 0 &&
  250. answerArr[aIndex] &&
  251. answerArr[aIndex] != "??" &&
  252. answerArr[aIndex] != "??"
  253. ? "[JUDGE##F##JUDGE]"
  254. : "",
  255. };
  256. userAnswer.input.push(JSON.parse(JSON.stringify(re)));
  257. });
  258. for (let i = 0; i < paraLeg; i++) {
  259. userAnswer.recordList.push(null);
  260. }
  261. } else if (item.checkList && item.checkList.indexOf("record") > -1) {
  262. for (let i = 0; i < paraLeg; i++) {
  263. userAnswer.recordList.push(null);
  264. }
  265. }
  266. if (item.checkList && item.checkList.indexOf("judge") > -1) {
  267. for (let i = 0; i < paraLeg; i++) {
  268. let judge_obj = {
  269. value: "",
  270. userAnswerJudge:
  271. item.judge[i].isJudge && item.judge[i].judge
  272. ? "[JUDGE##F##JUDGE]"
  273. : "",
  274. };
  275. userAnswer.judge.push(JSON.parse(JSON.stringify(judge_obj)));
  276. }
  277. }
  278. BookAnswer.push(userAnswer);
  279. });
  280. this.$set(this.curQue, "Bookanswer", BookAnswer);
  281. },
  282. countUserErrorNumber(data) {
  283. let BookanswerStr = JSON.stringify(data);
  284. let userErrorNumberTotal = 0;
  285. let errReg = /\[JUDGE##F##JUDGE\]/g;
  286. if (errReg.test(BookanswerStr)) {
  287. let errorArr = BookanswerStr.match(/\[JUDGE##F##JUDGE\]/g);
  288. userErrorNumberTotal = errorArr.length;
  289. }
  290. return userErrorNumberTotal;
  291. },
  292. },
  293. //生命周期 - 创建完成(可以访问当前this实例)
  294. created() {},
  295. //生命周期 - 挂载完成(可以访问DOM元素)
  296. mounted() {
  297. let _this = this;
  298. _this.userErrorNumberTotal = 0;
  299. if (_this.curQue) {
  300. _this.handleData();
  301. if (!_this.curQue.Bookanswer) {
  302. _this.initAnswer();
  303. } else {
  304. _this.userErrorNumberTotal = _this.countUserErrorNumber(
  305. _this.curQue.Bookanswer
  306. );
  307. }
  308. }
  309. },
  310. beforeCreate() {}, //生命周期 - 创建之前
  311. beforeMount() {}, //生命周期 - 挂载之前
  312. beforeUpdate() {}, //生命周期 - 更新之前
  313. updated() {}, //生命周期 - 更新之后
  314. beforeDestroy() {}, //生命周期 - 销毁之前
  315. destroyed() {}, //生命周期 - 销毁完成
  316. activated() {}, //如果页面有keep-alive缓存功能,这个函数会触发
  317. };
  318. </script>
  319. <style lang='scss' scoped>
  320. //@import url(); 引入公共css类
  321. .dialogue-answer-view {
  322. width: 100%;
  323. margin-bottom: 24px;
  324. .guide {
  325. width: 100%;
  326. font-size: 16px;
  327. line-height: 19px;
  328. font-family: "robot";
  329. padding-top: 24px;
  330. }
  331. .dialogue-answer-content {
  332. width: 100%;
  333. box-sizing: border-box;
  334. padding: 0px 24px 0 24px;
  335. &.nooption {
  336. padding-bottom: 40px;
  337. }
  338. }
  339. .dialogue-answer-inner {
  340. display: flex;
  341. justify-content: flex-start;
  342. align-items: flex-start;
  343. padding: 16px 0 0px 0;
  344. &.hasoption {
  345. border-bottom: 1px solid rgba(0, 0, 0, 0.1);
  346. padding-bottom: 24px;
  347. }
  348. &.haspadding {
  349. padding-bottom: 40px;
  350. }
  351. &:nth-last-child(1) {
  352. border: 0;
  353. }
  354. .number {
  355. width: 32px;
  356. height: 32px;
  357. background: #e35454;
  358. border-radius: 100%;
  359. display: flex;
  360. justify-content: center;
  361. align-items: center;
  362. font-weight: bold;
  363. font-size: 16px;
  364. line-height: 150%;
  365. color: #ffffff;
  366. font-family: "robot";
  367. margin-top: 4px;
  368. flex-shrink: 0;
  369. }
  370. }
  371. .dialogue-answer-model {
  372. flex: 1;
  373. }
  374. .dialogue-answer-article {
  375. width: 100%;
  376. display: flex;
  377. justify-content: flex-start;
  378. align-items: center;
  379. }
  380. .dialogue-img {
  381. width: 228px;
  382. height: 196px;
  383. background: #ffffff;
  384. border: 1px solid rgba(0, 0, 0, 0.1);
  385. box-sizing: border-box;
  386. border-radius: 8px;
  387. padding: 16px;
  388. overflow: hidden;
  389. margin-left: 24px;
  390. margin-top: 8px;
  391. > img {
  392. width: 100%;
  393. }
  394. }
  395. }
  396. .NPC-Big-Book-preview-green {
  397. .dialogue-answer-view {
  398. .number {
  399. background: #24b99e !important;
  400. }
  401. }
  402. }
  403. .NPC-Big-Book-preview-brown {
  404. .number {
  405. background: #bd8865 !important;
  406. }
  407. }
  408. </style>
  409. <style lang="scss">
  410. </style>