EditPaper.vue 70 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217
  1. <template>
  2. <div
  3. id="editPaperApp"
  4. v-loading="loading"
  5. class="paper"
  6. element-loading-text="拼命加载中。。。"
  7. >
  8. <!-- <ckeditor v-model="examRemark"></ckeditor> -->
  9. <div class="edit-paper-top">
  10. <div class="edit-paper-top-inline">
  11. <div class="paper-top-div">
  12. <span class="paper-top-title">课程代码:</span>
  13. <span class="paper-top-value">{{ paper.course.code }}</span>
  14. </div>
  15. <div class="paper-top-div">
  16. <span class="paper-top-title">课程名称:</span>
  17. <span class="paper-top-value">{{ paper.course.name }}</span>
  18. </div>
  19. <div class="paper-top-div">
  20. <span class="paper-top-title">试卷名称:</span>
  21. <el-tooltip class="item" effect="dark" placement="top-start">
  22. <div slot="content">{{ paper.name }}</div>
  23. <input
  24. v-model="paper.name"
  25. class="paperName-input font_length"
  26. placeholder="试卷名称"
  27. />
  28. </el-tooltip>
  29. </div>
  30. <div class="paper-top-div">
  31. <span class="paper-top-title">试卷难度:</span>
  32. <span class="paper-top-value">{{ paper.difficultyDegree }}</span>
  33. </div>
  34. <div>
  35. <el-button type="primary" size="small" @click="savePaper">
  36. 保存
  37. </el-button>
  38. <el-button
  39. v-show="parentView == 'import_paper'"
  40. type="danger"
  41. size="small"
  42. @click="deletePaper(paper.id)"
  43. >
  44. <i class="el-icon-delete"></i> 删除
  45. </el-button>
  46. <el-dropdown class="button_left">
  47. <el-button type="primary" size="small">
  48. 更多 <i class="el-icon-arrow-down el-icon--right"></i>
  49. </el-button>
  50. <el-dropdown-menu slot="dropdown">
  51. <el-dropdown-item>
  52. <el-button
  53. v-show="parentView == 'gen_paper'"
  54. type="danger"
  55. size="small"
  56. @click="recoveryPaper(paper.id)"
  57. ><i class="el-icon-delete"></i>回收
  58. </el-button>
  59. </el-dropdown-item>
  60. <el-dropdown-item>
  61. <el-button
  62. type="primary"
  63. :loading="duplicateLoading"
  64. size="small"
  65. @click="getreduplicateQuestions"
  66. ><i class="el-icon-zoom-in"></i>查重
  67. </el-button>
  68. </el-dropdown-item>
  69. <el-dropdown-item>
  70. <el-button
  71. v-show="parentView == 'import_paper'"
  72. type="primary"
  73. size="small"
  74. @click="openDialog"
  75. ><i class="el-icon-upload2"></i>上传音频
  76. </el-button>
  77. </el-dropdown-item>
  78. <el-dropdown-item>
  79. <el-button
  80. size="small"
  81. type="primary"
  82. @click="exportPaperAnswer()"
  83. ><i class="el-icon-download"></i>导出答案</el-button
  84. >
  85. </el-dropdown-item>
  86. <el-dropdown-item>
  87. <el-button
  88. v-show="parentView == 'import_paper'"
  89. type="primary"
  90. size="small"
  91. @click="openAnswerDialog"
  92. ><i class="el-icon-upload2"></i>导入答案
  93. </el-button>
  94. </el-dropdown-item>
  95. </el-dropdown-menu>
  96. </el-dropdown>
  97. <el-button
  98. size="small"
  99. type="primary"
  100. style="margin-left: 10px"
  101. @click="back"
  102. ><i class="el-icon-arrow-left"></i> 返回</el-button
  103. >
  104. </div>
  105. </div>
  106. </div>
  107. <div class="paperName">
  108. <div>
  109. <br />
  110. <h3 class="text-center">{{ paper.course.name }}&nbsp;试卷</h3>
  111. <h5 class="text-center">
  112. <span v-show="paper.hasAudio">(含音频试卷)</span>
  113. </h5>
  114. <br />
  115. <h4 class="text-center">(课程代码&nbsp;{{ paper.course.code }})</h4>
  116. <br />
  117. </div>
  118. <div class="text-left">
  119. <el-table :data="paper.paperDetails" border style="width: 100%">
  120. <el-table-column header-align="center" label="大题名称">
  121. <template slot-scope="scope">
  122. <span>{{ scope.row.name }}</span>
  123. </template>
  124. </el-table-column>
  125. <el-table-column header-align="center" label="大题总分">
  126. <template slot-scope="scope">
  127. <span>{{ scope.row.score }}</span>
  128. </template>
  129. </el-table-column>
  130. <el-table-column header-align="center" label="小题数量">
  131. <template slot-scope="scope">
  132. <span>{{ scope.row.unitCount }}</span>
  133. </template>
  134. </el-table-column>
  135. <el-table-column header-align="center" label="公开数量">
  136. <template slot-scope="scope">
  137. <span>{{ scope.row.pubCount }}</span>
  138. </template>
  139. </el-table-column>
  140. <el-table-column header-align="center" label="非公开数量">
  141. <template slot-scope="scope">
  142. <span>{{ scope.row.noPubCount }}</span>
  143. </template>
  144. </el-table-column>
  145. </el-table>
  146. <div class="mainQues" style="margin-top: 20px; margin-left: 0px">
  147. <div class="mainQuesTitle">
  148. <span>考试说明:</span>
  149. <span>
  150. <el-button size="small" @click="openEditExamPaperRemark"
  151. >编辑</el-button
  152. >
  153. </span>
  154. <div style="width: 550px; margin-left: 20px; margin-top: 20px">
  155. <span v-html="paper.examRemark"></span>
  156. </div>
  157. </div>
  158. </div>
  159. <!-- end by wwh -->
  160. <div>
  161. <h1>本试卷满分{{ paper.totalScore }}分。</h1>
  162. </div>
  163. <br />
  164. </div>
  165. </div>
  166. <div>
  167. <!-- 循环大题 -->
  168. <div
  169. v-for="(paperDetail, detailIndex) in paper.paperDetails"
  170. v-show="paperDetailShow(paperDetail)"
  171. :key="detailIndex"
  172. class="mainQues"
  173. >
  174. <div
  175. class="mainQuesTitle"
  176. @mouseover="quesMouseOver(paperDetail.id)"
  177. @mouseout="quesMouseOut(paperDetail.id)"
  178. >
  179. <span>{{ paperDetail.cnNum }}</span> <span>.</span>
  180. <span>{{ paperDetail.name }}</span>
  181. <span>
  182. ({{ !paperDetail.title ? "本大题" : paperDetail.title + "," }}共{{
  183. paperDetail.unitCount
  184. }}小题,满分{{ paperDetail.score }}分)
  185. </span>
  186. <span :id="paperDetail.id" class="btnDiv">
  187. <el-button
  188. v-show="parentView == 'gen_paper'"
  189. size="small"
  190. @click="selectQues(paperDetail.id)"
  191. >选题
  192. </el-button>
  193. <el-button size="small" @click="openEditPaperDetail(paperDetail)"
  194. >编辑
  195. </el-button>
  196. <el-button
  197. v-if="showUp(paperDetail)"
  198. size="small"
  199. @click="movePaperDetail(paperDetail, 'up')"
  200. >上移
  201. </el-button>
  202. <el-button
  203. v-if="showDown(paperDetail)"
  204. size="small"
  205. @click="movePaperDetail(paperDetail, 'down')"
  206. >下移
  207. </el-button>
  208. <el-button
  209. size="small"
  210. type="danger"
  211. @click="deletePaperDetail(paperDetail.id)"
  212. >删除
  213. </el-button>
  214. <el-button
  215. v-show="showButtons[detailIndex].up"
  216. size="small"
  217. icon="el-icon-arrow-up"
  218. @click.stop="hideContent(detailIndex)"
  219. ></el-button>
  220. <el-button
  221. v-show="!showButtons[detailIndex].up"
  222. size="small"
  223. icon="el-icon-arrow-down"
  224. @click.stop="showContent(detailIndex)"
  225. ></el-button>
  226. </span>
  227. </div>
  228. <!-- 循环小题 -->
  229. <div v-show="showQuestions[detailIndex].is_show">
  230. <div
  231. v-for="(paperDetailUnit, unitIndex) in paperDetail.paperDetailUnits"
  232. v-show="quesShow(paperDetailUnit.id)"
  233. :key="unitIndex"
  234. class="ques"
  235. >
  236. <reduplicate_mark
  237. :id="paperDetailUnit.id"
  238. :show="reduplicateMarkShow(paperDetailUnit.id)"
  239. :fill-color="reduplicateMarkColor(paperDetailUnit.id)"
  240. :checked="reduplicateMarkCheck(paperDetailUnit.id)"
  241. @reduplicate_mark_check="reduplicate_mark_check"
  242. >
  243. </reduplicate_mark>
  244. <div
  245. class="quesSelect"
  246. @mouseover="quesMouseOver(paperDetailUnit.id)"
  247. @mouseout="quesMouseOut(paperDetailUnit.id)"
  248. >
  249. <div :id="paperDetailUnit.id" class="btnDiv">
  250. <el-button
  251. size="small"
  252. @click="editQues(paperDetailUnit, paperDetailUnit.question)"
  253. >编辑
  254. </el-button>
  255. <el-button
  256. type="danger"
  257. size="small"
  258. @click="deleteQues(paperDetailUnit)"
  259. >删除
  260. </el-button>
  261. </div>
  262. <div class="quesBody">
  263. <span class="ques-title">{{ paperDetailUnit.number }}.</span>
  264. <span
  265. v-question-audio
  266. class="ques-body"
  267. :hasAudio="paperDetailUnit.question.hasAudio"
  268. :questionId="paperDetailUnit.question.id"
  269. v-html="paperDetailUnit.question.quesBody"
  270. ></span>
  271. <span class="score-span">
  272. ({{ paperDetailUnit.score }}分)
  273. </span>
  274. </div>
  275. <div
  276. v-for="(quesOption, optionIndex) in paperDetailUnit.question
  277. .quesOptions"
  278. :key="optionIndex"
  279. class="quesOption"
  280. >
  281. <span class="ques-title"
  282. >{{ optionIndex | optionOrderWordFilter }}.
  283. </span>
  284. <span
  285. v-question-audio
  286. class="ques-body"
  287. :hasAudio="paperDetailUnit.question.hasAudio"
  288. :questionId="paperDetailUnit.question.id"
  289. v-html="quesOption.optionBody"
  290. ></span>
  291. </div>
  292. </div>
  293. <br />
  294. <div
  295. v-for="(subQuestion, subIndex) in paperDetailUnit.question
  296. .subQuestions"
  297. v-show="quesShow(subQuestion.id)"
  298. :key="subIndex"
  299. class="subQues"
  300. >
  301. <reduplicate_mark
  302. :show="reduplicateMarkShow(subQuestion.id)"
  303. ></reduplicate_mark>
  304. <div
  305. class="quesSelect"
  306. @mouseover="
  307. quesMouseOver(getSubQuesEditId(paperDetailUnit, subQuestion))
  308. "
  309. @mouseout="
  310. quesMouseOut(getSubQuesEditId(paperDetailUnit, subQuestion))
  311. "
  312. >
  313. <div
  314. :id="getSubQuesEditId(paperDetailUnit, subQuestion)"
  315. class="btnDiv"
  316. >
  317. <el-button
  318. size="small"
  319. @click="editQues(paperDetailUnit, subQuestion)"
  320. >编辑
  321. </el-button>
  322. </div>
  323. <div class="quesBody">
  324. <span class="ques-title"
  325. >{{ subQuestion.quesParams.number }}.
  326. </span>
  327. <span v-html="subQuestion.quesBody"></span>
  328. <span
  329. >({{ paperDetailUnit.subScoreList[subIndex] }}分)</span
  330. >
  331. </div>
  332. <div
  333. v-for="(
  334. subQuesOption, subOptIndex
  335. ) in subQuestion.quesOptions"
  336. :key="subOptIndex"
  337. class="quesOption"
  338. >
  339. <span class="ques-title"
  340. >{{ subOptIndex | optionOrderWordFilter }}.
  341. </span>
  342. <span v-html="subQuesOption.optionBody"></span>
  343. </div>
  344. <br />
  345. </div>
  346. </div>
  347. </div>
  348. <br />
  349. </div>
  350. </div>
  351. </div>
  352. <div class="text-left">
  353. <!-- 编辑大题弹框 -->
  354. <el-dialog
  355. v-loading="detailLoading"
  356. width="360px"
  357. title="大题名称编辑"
  358. element-loading-text="保存中。。。"
  359. append-to-body
  360. :visible.sync="paperDatailDialog"
  361. @close="closeQuesDialog"
  362. >
  363. <el-form
  364. :model="editpaperDetail"
  365. label-position="right"
  366. label-width="80px"
  367. >
  368. <el-row :gutter="10">
  369. <el-col :xs="10" :sm="10" :md="10" :lg="10">
  370. <el-form-item label="大题名称" placeholder="大题名称">
  371. <el-input
  372. v-model="editpaperDetail.name"
  373. class="dialog_input_width"
  374. />
  375. </el-form-item>
  376. </el-col>
  377. </el-row>
  378. <el-row>
  379. <el-form-item>
  380. <el-button
  381. type="primary"
  382. :loading="detailLoading"
  383. @click="savePaperDatail(editpaperDetail)"
  384. >保存</el-button
  385. >
  386. <el-button @click="closePaperDatailDialog()">取消</el-button>
  387. </el-form-item>
  388. </el-row>
  389. </el-form>
  390. </el-dialog>
  391. <!-- 编辑试题弹框 -->
  392. <el-dialog
  393. v-loading="dialogLoading"
  394. title="试题编辑"
  395. element-loading-text="保存中。。。"
  396. :visible.sync="quesDialog"
  397. append-to-body
  398. @close="closeQuesDialog"
  399. >
  400. <el-form :model="quesModel" label-position="right" label-width="80px">
  401. <el-row :gutter="10">
  402. <el-col :xs="10" :sm="10" :md="10" :lg="10">
  403. <el-form-item label="题型">
  404. <el-select
  405. v-model="quesModel.questionType"
  406. :disabled="true"
  407. placeholder="请输入题型"
  408. >
  409. <el-option
  410. v-for="item in questionTypes"
  411. :key="item.value"
  412. :label="item.label"
  413. :value="item.value"
  414. >
  415. </el-option>
  416. </el-select>
  417. </el-form-item>
  418. </el-col>
  419. <el-col :xs="10" :sm="10" :md="10" :lg="10">
  420. <el-form-item label="分值">
  421. <el-input
  422. v-model="quesModel.score"
  423. placeholder="分值"
  424. :disabled="quesModel.questionType == 'NESTED_ANSWER_QUESTION'"
  425. ></el-input>
  426. </el-form-item>
  427. </el-col>
  428. </el-row>
  429. <!-- create by weiwenhai 添加难度,公开度,试题属性 -->
  430. <el-row :gutter="10">
  431. <el-col :xs="10" :sm="10" :md="10" :lg="10">
  432. <el-form-item label="难度">
  433. <el-select
  434. v-model="quesModel.difficultyDegree"
  435. placeholder="请输入难度"
  436. :disabled="
  437. quesModel.questionType == 'NESTED_ANSWER_QUESTION'
  438. ? true
  439. : updatePorperty
  440. "
  441. >
  442. <el-option
  443. v-for="item in difficultyDegreeList"
  444. :key="item.value"
  445. :label="item.label"
  446. :value="item.value"
  447. >
  448. </el-option>
  449. </el-select>
  450. </el-form-item>
  451. </el-col>
  452. <el-col :xs="10" :sm="10" :md="10" :lg="10">
  453. <el-form-item label="公开度">
  454. <el-select
  455. v-model="quesModel.publicity"
  456. placeholder="请输入公开度"
  457. :disabled="updatePorperty"
  458. >
  459. <el-option
  460. v-for="item in publicityList"
  461. :key="item.value"
  462. :label="item.label"
  463. :value="item.value"
  464. >
  465. </el-option>
  466. </el-select>
  467. </el-form-item>
  468. </el-col>
  469. <el-col
  470. v-if="quesModel.questionType == 'TEXT_ANSWER_QUESTION'"
  471. :xs="10"
  472. :sm="10"
  473. :md="10"
  474. :lg="10"
  475. >
  476. <el-form-item label="作答类型">
  477. <el-select
  478. v-model="quesModel.answerType"
  479. :disabled="updatePorperty"
  480. >
  481. <el-option
  482. v-for="item in answerTypes"
  483. :key="item.value"
  484. :label="item.label"
  485. :value="item.value"
  486. >
  487. </el-option>
  488. </el-select>
  489. </el-form-item>
  490. </el-col>
  491. </el-row>
  492. <el-row :gutter="10">
  493. <el-col :xs="20" :sm="20" :md="20" :lg="20">
  494. <el-form-item label="属性列表">
  495. <el-tooltip
  496. v-for="(content, propIndex) in quesModel.quesProperties"
  497. :key="propIndex"
  498. placement="top"
  499. >
  500. <div slot="content">
  501. <span v-if="content.firstProperty != null"
  502. >一级属性:{{ content.firstProperty.name }}({{
  503. content.firstProperty.code
  504. }})</span
  505. ><br />
  506. <span
  507. v-if="
  508. content.secondProperty != null &&
  509. content.secondProperty.code
  510. "
  511. >二级属性:{{ content.secondProperty.name }}({{
  512. content.secondProperty.code
  513. }})</span
  514. >
  515. </div>
  516. <span>
  517. <el-tag
  518. :key="content.id"
  519. style="margin-right: 5px"
  520. :closable="!updatePorperty"
  521. type="primary"
  522. @close="handleClose(content)"
  523. >
  524. {{ content.coursePropertyName }}
  525. </el-tag>
  526. </span>
  527. </el-tooltip>
  528. </el-form-item>
  529. </el-col>
  530. </el-row>
  531. <el-row>
  532. <el-col :span="6">
  533. <el-form-item label="属性名" label-width="60px">
  534. <el-select
  535. v-model="coursePropertyName"
  536. placeholder="属性名"
  537. class="property_with"
  538. :disabled="updatePorperty"
  539. @change="searchFirst"
  540. >
  541. <el-option label="请选择" value=""></el-option>
  542. <el-option
  543. v-for="item in coursePropertyList"
  544. :key="item.name"
  545. :label="item.name"
  546. :value="item.name"
  547. >
  548. </el-option>
  549. </el-select>
  550. </el-form-item>
  551. </el-col>
  552. <el-col :span="6">
  553. <el-form-item label="一级" label-width="48px">
  554. <el-select
  555. v-model="firstPropertyId"
  556. placeholder="一级"
  557. class="property_with"
  558. :disabled="updatePorperty"
  559. @change="searchSecond"
  560. >
  561. <el-option label="请选择" value=""></el-option>
  562. <el-option
  563. v-for="item in firstPropertyList"
  564. :key="item.id"
  565. :label="item.name + '(' + item.code + ')'"
  566. :value="item.id"
  567. >
  568. </el-option>
  569. </el-select>
  570. </el-form-item>
  571. </el-col>
  572. <el-col :span="6">
  573. <el-form-item label="二级" label-width="48px">
  574. <el-select
  575. v-model="secondPropertyId"
  576. placeholder="二级"
  577. class="property_with"
  578. :disabled="updatePorperty"
  579. >
  580. <el-option label="请选择" value=""></el-option>
  581. <el-option
  582. v-for="item in secondPropertyList"
  583. :key="item.id"
  584. :label="item.name + '(' + item.code + ')'"
  585. :value="item.id"
  586. >
  587. </el-option>
  588. </el-select>
  589. </el-form-item>
  590. </el-col>
  591. <el-col :span="6">
  592. <el-form-item>
  593. <el-button
  594. type="primary"
  595. style="margin-left: -50px"
  596. :disabled="updatePorperty"
  597. @click="insertProperty"
  598. ><i class="el-icon-plus"></i>新增属性
  599. </el-button>
  600. </el-form-item>
  601. </el-col>
  602. </el-row>
  603. <!-- end by weiwenhai -->
  604. <div>
  605. <el-row>
  606. <el-col>
  607. <el-form-item label="题目">
  608. <ckeditor v-model="quesModel.quesBody"></ckeditor>
  609. </el-form-item>
  610. </el-col>
  611. </el-row>
  612. <el-form-item
  613. v-for="(quesOption, optIndex) in quesModel.quesOptions"
  614. :key="optIndex"
  615. >
  616. <el-col :span="2">
  617. <el-radio
  618. v-if="quesModel.questionType === 'SINGLE_ANSWER_QUESTION'"
  619. v-model="singleRightAnswer"
  620. :label="optIndex | optionOrderWordFilter"
  621. ></el-radio>
  622. <el-checkbox
  623. v-if="quesModel.questionType === 'MULTIPLE_ANSWER_QUESTION'"
  624. v-model="multipleRightAnswer"
  625. :label="optIndex | optionOrderWordFilter"
  626. ></el-checkbox>
  627. </el-col>
  628. <el-col :span="20">
  629. <ckeditor v-model="quesOption.optionBody"></ckeditor>
  630. </el-col>
  631. <el-col :span="2">
  632. <i
  633. class="el-icon-delete"
  634. title="删除"
  635. @click.prevent="removeQuesOption(quesOption)"
  636. ></i>
  637. </el-col>
  638. </el-form-item>
  639. <div
  640. v-if="
  641. quesModel.questionType != 'NESTED_ANSWER_QUESTION' &&
  642. quesModel.questionType != 'SINGLE_ANSWER_QUESTION' &&
  643. quesModel.questionType != 'MULTIPLE_ANSWER_QUESTION' &&
  644. quesModel.questionType != 'BOOL_ANSWER_QUESTION'
  645. "
  646. >
  647. <el-form-item label="答案">
  648. <ckeditor v-model="quesModel.quesAnswer"></ckeditor>
  649. </el-form-item>
  650. </div>
  651. <!-- 单选或多选 -->
  652. <div
  653. v-if="
  654. quesModel.questionType == 'SINGLE_ANSWER_QUESTION' ||
  655. quesModel.questionType == 'MULTIPLE_ANSWER_QUESTION'
  656. "
  657. >
  658. <el-form-item label="答案">
  659. <span v-html="answer"></span>
  660. </el-form-item>
  661. </div>
  662. <div v-if="quesModel.questionType == 'BOOL_ANSWER_QUESTION'">
  663. <el-row>
  664. <el-col>
  665. <el-form-item label="答案" prop="quesAnswer">
  666. <el-select
  667. v-model="quesModel.quesAnswer"
  668. placeholder="请选择"
  669. >
  670. <el-option
  671. v-for="op in options"
  672. :key="op"
  673. :label="op"
  674. :value="op"
  675. >
  676. </el-option>
  677. </el-select>
  678. </el-form-item>
  679. </el-col>
  680. </el-row>
  681. </div>
  682. </div>
  683. <div
  684. :class="{
  685. margin_left_30:
  686. quesModel.questionType == 'SINGLE_ANSWER_QUESTION' ||
  687. quesModel.questionType == 'MULTIPLE_ANSWER_QUESTION',
  688. margin_left_40: !(
  689. quesModel.questionType == 'SINGLE_ANSWER_QUESTION' ||
  690. quesModel.questionType == 'MULTIPLE_ANSWER_QUESTION'
  691. ),
  692. }"
  693. >
  694. <el-button
  695. v-if="
  696. quesModel.questionType == 'SINGLE_ANSWER_QUESTION' ||
  697. quesModel.questionType == 'MULTIPLE_ANSWER_QUESTION'
  698. "
  699. type="primary"
  700. @click="addQuesOption"
  701. ><i class="el-icon-plus"></i> 新增选项
  702. </el-button>
  703. <el-button
  704. type="primary"
  705. :loading="dialogLoading"
  706. @click="savePaperDetailUnit()"
  707. >保存</el-button
  708. >
  709. <el-button @click="closeQuesDialog">取消</el-button>
  710. </div>
  711. </el-form>
  712. </el-dialog>
  713. <!-- 考试说明弹框 -->
  714. <el-dialog title="考试说明编辑" :visible.sync="paperRemarkDialog">
  715. <el-form label-position="right" label-width="80px">
  716. <el-row :gutter="10">
  717. <el-col :xs="10" :sm="10" :md="10" :lg="10">
  718. <el-form-item label="考试说明">
  719. <div style="width: 550px">
  720. <ckeditor
  721. v-model="examRemark"
  722. :display="display"
  723. :width="wValue"
  724. :height="hValue"
  725. ></ckeditor>
  726. </div>
  727. </el-form-item>
  728. </el-col>
  729. </el-row>
  730. <div style="margin-top: 20px; margin-left: 40%">
  731. <el-button type="primary" @click="savePaperRemark">保存</el-button>
  732. <el-button @click="closPaperRemark">取消</el-button>
  733. </div>
  734. </el-form>
  735. </el-dialog>
  736. <!-- 上传音频弹框 -->
  737. <el-dialog
  738. title="上传音频文件"
  739. :visible.sync="dialogRadioFile"
  740. :before-close="closeAudioDialog"
  741. >
  742. <form
  743. id="radioForm"
  744. method="post"
  745. action=""
  746. enctype="multipart/form-data"
  747. >
  748. <input
  749. id="radioFile"
  750. name="files"
  751. type="file"
  752. value="上传音频文件"
  753. webkitdirectory
  754. />
  755. <el-button type="warning" @click="checkFile">检查文件名</el-button>
  756. <el-button
  757. type="info"
  758. :loading="uploadAudioLoading"
  759. :disabled="isUpload || uploadAudioLoading"
  760. @click="uploadAudioFile"
  761. >
  762. <span v-show="!uploadAudioLoading">开始上传</span>
  763. <span v-show="uploadAudioLoading">正在上传中...</span>
  764. </el-button>
  765. </form>
  766. <div v-if="checkResult" style="margin-top: 20px">
  767. <span>检查结果:</span><br /><br />
  768. <span v-show="message == 'OK!'" style="color: #13ce66">OK!</span>
  769. <span v-show="message != 'OK!'" style="color: #ff4949">{{
  770. message
  771. }}</span>
  772. </div>
  773. </el-dialog>
  774. <el-dialog
  775. title="上传答案文件"
  776. :visible.sync="dialogAnswerFile"
  777. :before-close="closeAnswerDialog"
  778. >
  779. <form
  780. id="answerForm"
  781. method="post"
  782. action=""
  783. enctype="multipart/form-data"
  784. >
  785. <input
  786. id="answerFile"
  787. name="answerFiles"
  788. type="file"
  789. value="上传答案文件"
  790. accept="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
  791. />
  792. <el-button type="info" @click="downAnswerTemplate">
  793. <span>下载模板</span>
  794. </el-button>
  795. <el-button
  796. type="info"
  797. :loading="uploadAnswerLoading"
  798. :disabled="uploadAnswerLoading"
  799. @click="uploadAnswerFile"
  800. >
  801. <span v-show="!uploadAnswerLoading">开始上传</span>
  802. <span v-show="uploadAnswerLoading">正在上传中...</span>
  803. </el-button>
  804. </form>
  805. <div style="margin-top: 20px">
  806. <span v-show="answerMessage != ''" style="color: #ff4949">{{
  807. answerMessage
  808. }}</span>
  809. </div>
  810. </el-dialog>
  811. </div>
  812. </div>
  813. </template>
  814. <script>
  815. import { QUESTION_API } from "@/constants/constants";
  816. import { isEmptyStr, QUESTION_TYPES } from "../constants/constants";
  817. import { mapState } from "vuex";
  818. import reduplicate_mark from "../component/reduplicate_mark.vue";
  819. import randomColor from "randomcolor";
  820. import ckeditor from "../component/ckeditor.vue";
  821. export default {
  822. name: "EditPaperApp",
  823. components: {
  824. reduplicate_mark,
  825. ckeditor,
  826. },
  827. data() {
  828. return {
  829. hValue: "100px",
  830. wValue: "500px",
  831. display: "block",
  832. uploadAction: "",
  833. fileList: [],
  834. answerFileList: [],
  835. paperId: "",
  836. paperDetailId: "",
  837. editPaperDetailUnit: "",
  838. quesDialog: false,
  839. paperDatailDialog: false,
  840. paperRemarkDialog: false,
  841. parentView: "",
  842. paper: {
  843. course: {
  844. code: "",
  845. name: "",
  846. },
  847. examRemark: "",
  848. },
  849. loading: false,
  850. dialogLoading: false,
  851. detailLoading: false,
  852. uploadAudioLoading: false,
  853. uploadAnswerLoading: false,
  854. questionTypes: QUESTION_TYPES,
  855. questionType: "",
  856. quesModel: { quesProperties: [] },
  857. editpaperDetail: {},
  858. reduplicateQuestions: [],
  859. reduplicateGroup: [],
  860. reduplicateQuesColor: [],
  861. singleRightAnswer: "", //接收单选答案
  862. multipleRightAnswer: [], //接收多选答案
  863. options: ["正确", "错误"],
  864. duplicateLoading: false,
  865. dialogRadioFile: false,
  866. dialogAnswerFile: false,
  867. isUpload: true,
  868. isUploadAnswer: true,
  869. message: "",
  870. answerMessage: "",
  871. checkResult: false,
  872. checkResultAnswer: false,
  873. fileNameList: [],
  874. defaultColor: [
  875. "Red",
  876. "Blue",
  877. "LimeGreen",
  878. "GoldenRod",
  879. "Black",
  880. "BlueViolet",
  881. "Chocolate",
  882. "DarkCyan",
  883. "HotPink",
  884. "Orange",
  885. "IndianRed",
  886. "Indigo",
  887. "Green",
  888. "Aqua",
  889. "CadetBlue",
  890. "SkyBlue",
  891. "SlateBlue",
  892. "SlateGray",
  893. "Tomato",
  894. "VioletRed",
  895. ],
  896. difficultyDegreeList: [
  897. { label: 0.1, value: 0.1 },
  898. { label: 0.2, value: 0.2 },
  899. { label: 0.3, value: 0.3 },
  900. { label: 0.4, value: 0.4 },
  901. { label: 0.5, value: 0.5 },
  902. { label: 0.6, value: 0.6 },
  903. { label: 0.7, value: 0.7 },
  904. { label: 0.8, value: 0.8 },
  905. { label: 0.9, value: 0.9 },
  906. { label: 1.0, value: 1.0 },
  907. ],
  908. publicityList: [
  909. { label: "公开", value: true },
  910. { label: "非公开", value: false },
  911. ],
  912. answerTypes: [
  913. { label: "文本", value: "DIVERSIFIED_TEXT" },
  914. { label: "音频", value: "SINGLE_AUDIO" },
  915. ],
  916. coursePropertyList: [],
  917. coursePropertyName: "", //课程属性名
  918. firstPropertyList: [], //一级属性集合
  919. firstPropertyId: "", //一级属性id
  920. secondPropertyList: [], //二级属性集合
  921. secondPropertyId: "", //二级属性id
  922. examRemark: "",
  923. showQuestions: [],
  924. showButtons: [],
  925. };
  926. },
  927. computed: {
  928. ...mapState({
  929. user: (state) => state.user,
  930. }),
  931. updatePorperty() {
  932. return false;
  933. },
  934. answer() {
  935. if (this.quesModel.questionType == "SINGLE_ANSWER_QUESTION") {
  936. return this.singleRightAnswer;
  937. } else if (this.quesModel.questionType == "MULTIPLE_ANSWER_QUESTION") {
  938. var obj = this.multipleRightAnswer;
  939. return obj.sort().toString();
  940. }
  941. return this.quesModel.quesAnswer;
  942. },
  943. },
  944. created() {
  945. // $("body").attr("style", "");
  946. document.getElementsByTagName("body")[0].style = "";
  947. this.paperId = this.$route.params.id;
  948. this.parentView = this.$route.params.parentView;
  949. this.initPaper();
  950. // this.getreduplicateQuestions();
  951. this.uploadAction = QUESTION_API + "/uploadRadio/" + this.paperId;
  952. this.uploadHeaders = {
  953. key: this.user.key,
  954. token: this.user.token,
  955. };
  956. },
  957. methods: {
  958. recoveryPaper(paperid) {
  959. this.$confirm("确认回收试卷吗?", "提示", {
  960. type: "warning",
  961. }).then(() => {
  962. this.loading = true;
  963. this.$http
  964. .put(QUESTION_API + "/paper_storage/recovery/" + paperid)
  965. .then(
  966. () => {
  967. this.loading = false;
  968. this.$notify({
  969. message: "操作成功",
  970. type: "success",
  971. });
  972. this.back();
  973. },
  974. (response) => {
  975. this.loading = false;
  976. this.$notify({
  977. message: response.response.data.desc,
  978. type: "error",
  979. });
  980. }
  981. );
  982. });
  983. },
  984. movePaperDetail(detail, vector) {
  985. let vectorStr = vector == "up" ? "上移" : "下移";
  986. this.$alert("您确定" + vectorStr + "吗?", "提示", {
  987. confirmButtonText: "确定",
  988. callback: (action) => {
  989. if (action == "confirm") {
  990. this.loading = true;
  991. this.$httpWithMsg
  992. .put(
  993. QUESTION_API +
  994. "/paperDetail/" +
  995. this.paperId +
  996. "/" +
  997. detail.id +
  998. "/" +
  999. vector
  1000. )
  1001. .then(() => {
  1002. this.initPaper();
  1003. this.loading = true;
  1004. this.$notify({
  1005. message: vectorStr + "成功",
  1006. type: "success",
  1007. });
  1008. })
  1009. .finally(() => (this.loading = false));
  1010. }
  1011. },
  1012. });
  1013. },
  1014. showUp(detail) {
  1015. if (this.paper.paperDetails.length <= 1) {
  1016. return false;
  1017. }
  1018. if (detail.id != this.paper.paperDetails[0].id) {
  1019. return true;
  1020. } else {
  1021. return false;
  1022. }
  1023. },
  1024. showDown(detail) {
  1025. if (this.paper.paperDetails.length <= 1) {
  1026. return false;
  1027. }
  1028. if (
  1029. detail.id !=
  1030. this.paper.paperDetails[this.paper.paperDetails.length - 1].id
  1031. ) {
  1032. return true;
  1033. } else {
  1034. return false;
  1035. }
  1036. },
  1037. downAnswerTemplate() {
  1038. var key = this.user.key;
  1039. var token = this.user.token;
  1040. window.open(
  1041. QUESTION_API + "/paper/answer/template?$key=" + key + "&$token=" + token
  1042. );
  1043. },
  1044. openAnswerDialog() {
  1045. this.checkResultAnswer = false;
  1046. this.isUploadAnswer = true;
  1047. if (document.getElementById("answerFile")) {
  1048. document.getElementById("answerFile").value = "";
  1049. }
  1050. this.dialogAnswerFile = true;
  1051. this.answerFileList = [];
  1052. },
  1053. closeAnswerDialog() {
  1054. this.answerMessage = "";
  1055. this.dialogAnswerFile = this.uploadAnswerLoading;
  1056. },
  1057. uploadAnswerFile() {
  1058. this.answerMessage = "";
  1059. var fileList = document.getElementById("answerFile").files;
  1060. if (fileList.length == 0) {
  1061. this.answerMessage = "请选择文件!";
  1062. return;
  1063. }
  1064. let param = new FormData();
  1065. //循环添加到formData中
  1066. for (var i = 0; i < fileList.length; i++) {
  1067. var file = fileList[i];
  1068. param.append("dataFile", file, file.name);
  1069. }
  1070. let config = {
  1071. headers: { "Content-Type": "multipart/form-data" },
  1072. };
  1073. this.uploadAnswerLoading = true;
  1074. this.$http
  1075. .post(
  1076. QUESTION_API + "/paper/answer/import/" + this.paperId,
  1077. param,
  1078. config
  1079. )
  1080. .then(() => {
  1081. this.dialogAnswerFile = false;
  1082. this.uploadAnswerLoading = false;
  1083. this.checkResultAnswer = false;
  1084. this.isUploadAnswer = true;
  1085. document.getElementById("answerFile").value = "";
  1086. this.initPaper();
  1087. })
  1088. .catch((error) => {
  1089. this.answerMessage = error.response.data.desc;
  1090. document.getElementById("answerFile").value = "";
  1091. this.uploadAnswerLoading = false;
  1092. });
  1093. },
  1094. //隐藏大题下的所有小题
  1095. hideContent(index) {
  1096. console.log("up");
  1097. this.showQuestions[index].is_show = false;
  1098. this.showButtons[index].up = false;
  1099. },
  1100. //展开大题下所有小题
  1101. showContent(index) {
  1102. console.log("down");
  1103. this.showQuestions[index].is_show = true;
  1104. this.showButtons[index].up = true;
  1105. },
  1106. quesMouseOver(index) {
  1107. document.getElementById(index).style.visibility = "visible";
  1108. },
  1109. quesMouseOut(index) {
  1110. document.getElementById(index).style.visibility = "hidden";
  1111. },
  1112. selectQues(id) {
  1113. this.paperDetailId = id;
  1114. var courseCode = this.paper.course.code;
  1115. var courseName = this.paper.course.name;
  1116. this.$router.push({
  1117. path:
  1118. "/select_question/" +
  1119. this.paper.id +
  1120. "/" +
  1121. courseCode +
  1122. "/" +
  1123. encodeURIComponent(courseName) +
  1124. "/" +
  1125. this.paperDetailId +
  1126. "/" +
  1127. this.parentView,
  1128. });
  1129. },
  1130. //打开编辑大题题目弹窗
  1131. openEditPaperDetail(paperDetail) {
  1132. this.paperDatailDialog = true;
  1133. this.editpaperDetail = Object.assign({}, paperDetail); //浅拷贝
  1134. },
  1135. //关闭编辑大题题目弹窗
  1136. closePaperDatailDialog() {
  1137. this.paperDatailDialog = false;
  1138. this.editpaperDetail = {};
  1139. },
  1140. //保存大题题目信息
  1141. savePaperDatail(editpaperDetail) {
  1142. this.detailLoading = true;
  1143. var paperId = this.paper.id;
  1144. this.$http
  1145. .post(QUESTION_API + "/updatePaperDetail/" + paperId, editpaperDetail)
  1146. .then(() => {
  1147. this.$notify({
  1148. message: "保存成功",
  1149. type: "success",
  1150. });
  1151. this.detailLoading = false;
  1152. this.closePaperDatailDialog();
  1153. this.initPaper();
  1154. });
  1155. },
  1156. //初始化试卷
  1157. initPaper() {
  1158. const scrollPosition =
  1159. document.documentElement.scrollTop || document.body.scrollTop;
  1160. this.loading = true;
  1161. this.paper = {
  1162. course: {
  1163. code: "",
  1164. name: "",
  1165. },
  1166. };
  1167. this.$http
  1168. .get(QUESTION_API + "/paper/" + this.paperId)
  1169. .then((response) => {
  1170. this.paper = response.data;
  1171. //查询所有课程属性名
  1172. this.initCourseProperty(this.paper.course.code);
  1173. //将所有小题分为公开和非公开
  1174. if (this.paper.paperDetails && this.paper.paperDetails.length > 0) {
  1175. for (let paperDetil of this.paper.paperDetails) {
  1176. this.showQuestions.push({ is_show: true });
  1177. this.showButtons.push({ up: true });
  1178. paperDetil.pubCount = 0;
  1179. paperDetil.noPubCount = 0;
  1180. if (
  1181. paperDetil.paperDetailUnits &&
  1182. paperDetil.paperDetailUnits.length > 0
  1183. ) {
  1184. for (let paperDetilUt of paperDetil.paperDetailUnits) {
  1185. if (
  1186. paperDetilUt.question.questionType !=
  1187. "NESTED_ANSWER_QUESTION"
  1188. ) {
  1189. //非套题
  1190. if (paperDetilUt.question.publicity) {
  1191. paperDetil.pubCount = paperDetil.pubCount + 1;
  1192. } else {
  1193. paperDetil.noPubCount = paperDetil.noPubCount + 1;
  1194. }
  1195. } else {
  1196. //循环所有子题
  1197. for (let ques of paperDetilUt.question.subQuestions) {
  1198. if (ques.publicity) {
  1199. paperDetil.pubCount = paperDetil.pubCount + 1;
  1200. } else {
  1201. paperDetil.noPubCount = paperDetil.noPubCount + 1;
  1202. }
  1203. }
  1204. }
  1205. }
  1206. }
  1207. }
  1208. }
  1209. setTimeout(() => {
  1210. document.documentElement.scrollTop = document.body.scrollTop =
  1211. scrollPosition;
  1212. console.log(scrollPosition);
  1213. }, 1000);
  1214. this.loading = false;
  1215. });
  1216. },
  1217. //查询所有课程属性名
  1218. initCourseProperty(courseCode) {
  1219. this.$http
  1220. .get(QUESTION_API + "/courseProperty/enable/" + courseCode)
  1221. .then((response) => {
  1222. this.coursePropertyList = response.data;
  1223. });
  1224. },
  1225. //删除大题
  1226. deletePaperDetail(paperDetailsId) {
  1227. //先判断大题下面是否还有小题
  1228. var count = 0;
  1229. for (var i = 0, imax = this.paper.paperDetails.length; i < imax; i++) {
  1230. if (paperDetailsId == this.paper.paperDetails[i].id) {
  1231. if (this.paper.paperDetails[i].paperDetailUnits) {
  1232. count += this.paper.paperDetails[i].paperDetailUnits.length;
  1233. break;
  1234. }
  1235. }
  1236. }
  1237. if (count == 0) {
  1238. if (this.paper.paperType == "GENERATE") {
  1239. this.$alert(
  1240. "您确定删除吗?</br><span style='color:red'>保存后请注意检查试卷总分</span>",
  1241. "提示",
  1242. {
  1243. dangerouslyUseHTMLString: true,
  1244. confirmButtonText: "确定",
  1245. callback: (action) => {
  1246. if (action == "confirm") {
  1247. this.loading = true;
  1248. this.$httpWithMsg
  1249. .delete(
  1250. QUESTION_API +
  1251. "/paperDetail/" +
  1252. this.paperId +
  1253. "/" +
  1254. paperDetailsId
  1255. )
  1256. .then(() => {
  1257. this.initPaper();
  1258. this.loading = true;
  1259. this.$notify({
  1260. message: "删除成功",
  1261. type: "success",
  1262. });
  1263. })
  1264. .finally(() => (this.loading = false));
  1265. }
  1266. },
  1267. }
  1268. );
  1269. } else {
  1270. this.$alert("您确定删除吗?", "提示", {
  1271. dangerouslyUseHTMLString: true,
  1272. confirmButtonText: "确定",
  1273. callback: (action) => {
  1274. if (action == "confirm") {
  1275. this.loading = true;
  1276. this.$httpWithMsg
  1277. .delete(
  1278. QUESTION_API +
  1279. "/paperDetail/" +
  1280. this.paperId +
  1281. "/" +
  1282. paperDetailsId
  1283. )
  1284. .then(() => {
  1285. this.initPaper();
  1286. this.loading = true;
  1287. this.$notify({
  1288. message: "删除成功",
  1289. type: "success",
  1290. });
  1291. })
  1292. .finally(() => (this.loading = false));
  1293. }
  1294. },
  1295. });
  1296. }
  1297. } else {
  1298. this.$alert("大题下还有小题,不可删除!", "提示", {
  1299. confirmButtonText: "确定",
  1300. callback: () => {},
  1301. });
  1302. }
  1303. },
  1304. quesShow(id) {
  1305. if (this.reduplicateGroup.length < 1) {
  1306. return true;
  1307. }
  1308. for (var i = 0, imax = this.reduplicateGroup.length; i < imax; i++) {
  1309. if (id == this.reduplicateGroup[i]) {
  1310. return true;
  1311. }
  1312. }
  1313. return false;
  1314. },
  1315. reduplicateMarkShow(id) {
  1316. var found = false;
  1317. for (var i = 0, imax = this.reduplicateQuestions.length; i < imax; i++) {
  1318. for (
  1319. var j = 0, jmax = this.reduplicateQuestions[i].length;
  1320. j < jmax;
  1321. j++
  1322. ) {
  1323. if (this.reduplicateQuestions[i][j] == id) {
  1324. found = true;
  1325. break;
  1326. }
  1327. }
  1328. if (found) {
  1329. break;
  1330. }
  1331. }
  1332. return found;
  1333. },
  1334. reduplicateMarkColor(id) {
  1335. for (var i = 0, imax = this.reduplicateQuestions.length; i < imax; i++) {
  1336. for (
  1337. var j = 0, jmax = this.reduplicateQuestions[i].length;
  1338. j < jmax;
  1339. j++
  1340. ) {
  1341. if (this.reduplicateQuestions[i][j] == id) {
  1342. return this.reduplicateQuesColor[i];
  1343. }
  1344. }
  1345. }
  1346. },
  1347. reduplicateMarkCheck(id) {
  1348. for (var i = 0, imax = this.reduplicateGroup.length; i < imax; i++) {
  1349. if (id == this.reduplicateGroup[i]) {
  1350. return true;
  1351. }
  1352. }
  1353. return false;
  1354. },
  1355. reduplicate_mark_check(id, checked) {
  1356. console.log(checked);
  1357. console.log(this.reduplicateQuestions);
  1358. console.log(id);
  1359. if (!checked) {
  1360. for (
  1361. var i = 0, imax = this.reduplicateQuestions.length;
  1362. i < imax;
  1363. i++
  1364. ) {
  1365. for (
  1366. var j = 0, jmax = this.reduplicateQuestions[i].length;
  1367. j < jmax;
  1368. j++
  1369. ) {
  1370. if (this.reduplicateQuestions[i][j] == id) {
  1371. this.reduplicateGroup = [];
  1372. for (
  1373. var k = 0, kmax = this.reduplicateQuestions[i].length;
  1374. k < kmax;
  1375. k++
  1376. ) {
  1377. this.reduplicateGroup.push(this.reduplicateQuestions[i][k]);
  1378. }
  1379. return;
  1380. }
  1381. }
  1382. }
  1383. } else {
  1384. this.reduplicateGroup = [];
  1385. }
  1386. },
  1387. //编辑题目
  1388. editQues(paperDetailUnit, question) {
  1389. console.log("question:", question);
  1390. this.coursePropertyName = "";
  1391. this.firstPropertyId = "";
  1392. this.secondPropertyId = "";
  1393. this.editPaperDetailUnit = paperDetailUnit;
  1394. this.quesModel = JSON.parse(JSON.stringify(question)); //深拷贝
  1395. this.quesModel.score = paperDetailUnit.score;
  1396. //如果是套题下面的小题编辑 ( paperDetailUnit的类型是套题,question的类型不是套题)
  1397. if (
  1398. paperDetailUnit.questionType == "NESTED_ANSWER_QUESTION" &&
  1399. question.questionType != "NESTED_ANSWER_QUESTION"
  1400. ) {
  1401. for (var i = 0; i < paperDetailUnit.question.subQuestions.length; i++) {
  1402. if (
  1403. paperDetailUnit.question.subQuestions[i].id == this.quesModel.id
  1404. ) {
  1405. this.quesModel.score = paperDetailUnit.subScoreList[i];
  1406. break;
  1407. }
  1408. }
  1409. }
  1410. if (isEmptyStr(this.quesModel.answerType)) {
  1411. this.quesModel.answerType = "DIVERSIFIED_TEXT";
  1412. }
  1413. if (this.quesModel.questionType == "FILL_BLANK_QUESTION") {
  1414. this.quesModel.quesBody = this.quesModel.quesBody.replace(
  1415. /______/g,
  1416. "###"
  1417. );
  1418. }
  1419. this.assignAnswers(); //给singleRightAnswer或multipleRightAnswer赋值
  1420. this.openQuesDialog();
  1421. },
  1422. //给singleRightAnswer和multipleRightAnswer赋值
  1423. assignAnswers() {
  1424. if (this.quesModel.quesOptions && this.quesModel.quesOptions.length > 0) {
  1425. this.singleRightAnswer = "";
  1426. this.multipleRightAnswer = [];
  1427. for (let i = 0; i < this.quesModel.quesOptions.length; i++) {
  1428. let option = this.quesModel.quesOptions[i];
  1429. if (
  1430. this.quesModel.questionType == "SINGLE_ANSWER_QUESTION" &&
  1431. option.isCorrect == 1
  1432. ) {
  1433. this.singleRightAnswer = String.fromCharCode(65 + i);
  1434. }
  1435. if (
  1436. this.quesModel.questionType == "MULTIPLE_ANSWER_QUESTION" &&
  1437. option.isCorrect == 1
  1438. ) {
  1439. this.multipleRightAnswer.push(String.fromCharCode(65 + i));
  1440. }
  1441. }
  1442. }
  1443. },
  1444. //打开修改试题编辑框
  1445. openQuesDialog() {
  1446. this.quesDialog = true;
  1447. },
  1448. //关闭试题编辑框
  1449. closeQuesDialog() {
  1450. this.quesDialog = false;
  1451. this.quesModel = {};
  1452. },
  1453. //删除属性
  1454. handleClose(tag) {
  1455. this.quesModel.quesProperties.splice(
  1456. this.quesModel.quesProperties.indexOf(tag),
  1457. 1
  1458. );
  1459. },
  1460. //查询一级属性
  1461. searchFirst() {
  1462. this.firstPropertyId = "";
  1463. this.secondPropertyId = "";
  1464. this.secondPropertyList = [];
  1465. if (this.coursePropertyName) {
  1466. for (let courseProperty of this.coursePropertyList) {
  1467. if (courseProperty.name == this.coursePropertyName) {
  1468. this.$http
  1469. .get(QUESTION_API + "/property/first/" + courseProperty.id)
  1470. .then((response) => {
  1471. this.firstPropertyList = response.data;
  1472. });
  1473. }
  1474. }
  1475. }
  1476. },
  1477. //查询二级属性
  1478. searchSecond() {
  1479. this.secondPropertyId = "";
  1480. if (this.firstPropertyId) {
  1481. this.$http
  1482. .get(QUESTION_API + "/property/second/" + this.firstPropertyId)
  1483. .then((response) => {
  1484. this.secondPropertyList = response.data;
  1485. });
  1486. }
  1487. },
  1488. //新增属性
  1489. insertProperty() {
  1490. if (!this.checkInsertPro()) {
  1491. return false;
  1492. }
  1493. var quesProperty = {
  1494. id: "",
  1495. coursePropertyName: "",
  1496. firstProperty: {},
  1497. secondProperty: {},
  1498. };
  1499. if (
  1500. this.quesModel.quesProperties == null ||
  1501. this.quesModel.quesProperties.length == 0
  1502. ) {
  1503. this.quesModel.quesProperties = [];
  1504. }
  1505. if (this.secondPropertyId) {
  1506. quesProperty.id =
  1507. this.coursePropertyName +
  1508. "-" +
  1509. this.firstPropertyId +
  1510. "-" +
  1511. this.secondPropertyId;
  1512. } else {
  1513. quesProperty.id = this.coursePropertyName + "-" + this.firstPropertyId;
  1514. }
  1515. for (let quesPro of this.quesModel.quesProperties) {
  1516. if (quesPro.id == quesProperty.id) {
  1517. this.$notify({
  1518. message: "该属性已存在,请重新选择",
  1519. type: "error",
  1520. });
  1521. return false;
  1522. }
  1523. }
  1524. quesProperty.coursePropertyName = this.coursePropertyName;
  1525. //取到一级属性对象
  1526. for (let property of this.firstPropertyList) {
  1527. if (property.id == this.firstPropertyId) {
  1528. quesProperty.firstProperty = property;
  1529. }
  1530. }
  1531. //判断是否有二级属性
  1532. if (
  1533. this.secondPropertyList != undefined &&
  1534. this.secondPropertyList.length > 0
  1535. ) {
  1536. if (!this.secondPropertyId) {
  1537. this.$notify({
  1538. message: "请选择二级属性",
  1539. type: "error",
  1540. });
  1541. return false;
  1542. }
  1543. }
  1544. //取到二级属性对象
  1545. for (let property of this.secondPropertyList) {
  1546. if (property.id == this.secondPropertyId) {
  1547. quesProperty.secondProperty = property;
  1548. }
  1549. }
  1550. this.quesModel.quesProperties.push(quesProperty);
  1551. this.quesModel = Object.assign({}, this.quesModel);
  1552. //清空下拉框
  1553. this.coursePropertyName = "";
  1554. this.firstPropertyId = "";
  1555. this.secondPropertyId = "";
  1556. this.firstPropertyList = [];
  1557. this.secondPropertyList = [];
  1558. },
  1559. //新增属性验证
  1560. checkInsertPro() {
  1561. if (!this.coursePropertyName) {
  1562. this.$notify({
  1563. message: "请选择属性",
  1564. type: "error",
  1565. });
  1566. return false;
  1567. }
  1568. if (!this.firstPropertyId) {
  1569. this.$notify({
  1570. message: "请选择一级属性",
  1571. type: "error",
  1572. });
  1573. return false;
  1574. }
  1575. return true;
  1576. },
  1577. //删除选项
  1578. removeQuesOption(option) {
  1579. this.singleRightAnswer = "";
  1580. this.multipleRightAnswer = [];
  1581. let index = this.quesModel.quesOptions.indexOf(option);
  1582. if (index !== -1) {
  1583. this.quesModel.quesOptions.splice(index, 1);
  1584. }
  1585. if (this.quesModel.quesOptions.length > 0) {
  1586. for (var i = 0; i < this.quesModel.quesOptions.length; i++) {
  1587. var quesOption = this.quesModel.quesOptions[i];
  1588. quesOption["number"] = i + 1;
  1589. if (quesOption.isCorrect == 1) {
  1590. var answerOrderNum = String.fromCharCode(65 + i);
  1591. if (this.quesModel.questionType == "SINGLE_ANSWER_QUESTION") {
  1592. this.singleRightAnswer = answerOrderNum;
  1593. }
  1594. if (this.quesModel.questionType == "MULTIPLE_ANSWER_QUESTION") {
  1595. this.multipleRightAnswer.push(answerOrderNum);
  1596. }
  1597. }
  1598. }
  1599. }
  1600. },
  1601. //新增选项
  1602. addQuesOption() {
  1603. this.quesModel.quesOptions.push({
  1604. number: "",
  1605. optionBody: "",
  1606. isCorrect: "",
  1607. });
  1608. for (var i = 0; i < this.quesModel.quesOptions.length; i++) {
  1609. this.quesModel.quesOptions[i]["number"] = i + 1;
  1610. }
  1611. },
  1612. savePaperDetailUnit() {
  1613. //跟新难度值
  1614. if (this.quesModel.difficultyDegree < 0.4) {
  1615. this.quesModel.difficulty = "难";
  1616. } else if (
  1617. this.quesModel.difficultyDegree > 0.3 &&
  1618. this.quesModel.difficultyDegree < 0.8
  1619. ) {
  1620. this.quesModel.difficulty = "中";
  1621. } else {
  1622. this.quesModel.difficulty = "易";
  1623. }
  1624. this.setRightAnswer();
  1625. if (/^\d+(?=\.{0,1}\d+$|$)/.test(this.quesModel.score)) {
  1626. console.log("正确");
  1627. } else {
  1628. this.$notify({
  1629. message: "分数只能为正数",
  1630. type: "error",
  1631. });
  1632. return;
  1633. }
  1634. if (this.paper.paperType == "GENERATE") {
  1635. this.$confirm(
  1636. "试题内容修改,会影响所有关联试卷,是否确定进行?</br><span style='color:red'>保存后请注意检查试卷总分</span>",
  1637. "提示",
  1638. {
  1639. dangerouslyUseHTMLString: true,
  1640. confirmButtonText: "确定",
  1641. cancelButtonText: "取消",
  1642. type: "warning",
  1643. }
  1644. ).then(() => {
  1645. this.submitPaperDetailUnit();
  1646. });
  1647. } else {
  1648. this.submitPaperDetailUnit();
  1649. }
  1650. },
  1651. submitPaperDetailUnit() {
  1652. let paperDetailUnitExp = {
  1653. id: this.editPaperDetailUnit.id,
  1654. question: this.quesModel,
  1655. score: this.quesModel.score,
  1656. };
  1657. if (
  1658. this.quesModel.quesOptions &&
  1659. this.quesModel.quesOptions.length == 0
  1660. ) {
  1661. this.$confirm("无选项将删除该试题, 是否继续?", "提示", {
  1662. confirmButtonText: "确定",
  1663. cancelButtonText: "取消",
  1664. type: "warning",
  1665. }).then(() => {
  1666. this.dialogLoading = true;
  1667. this.$httpWithMsg
  1668. .delete(
  1669. QUESTION_API +
  1670. "/paper/deleteQuestion/" +
  1671. this.editPaperDetailUnit.id +
  1672. "/" +
  1673. this.quesModel.id
  1674. )
  1675. .then(() => {
  1676. this.$notify({
  1677. message: "保存成功",
  1678. type: "success",
  1679. });
  1680. })
  1681. .finally(() => (this.loading = false));
  1682. });
  1683. } else {
  1684. this.dialogLoading = true;
  1685. //校验音频重复
  1686. let audiomap = new Map();
  1687. let regex = new RegExp(
  1688. '<a id="[^<>]+" name="([^<>]+\\.mp3)"></a>',
  1689. "ig"
  1690. );
  1691. let ret = "";
  1692. let quesBodyStr = paperDetailUnitExp.question.quesBody;
  1693. if (quesBodyStr) {
  1694. while ((ret = regex.exec(quesBodyStr))) {
  1695. if (audiomap.get(ret[1])) {
  1696. this.dialogLoading = false;
  1697. this.$notify({
  1698. type: "error",
  1699. message: "题干中存在相同的音频文件",
  1700. });
  1701. return;
  1702. } else {
  1703. audiomap.set(ret[1], ret[1]);
  1704. }
  1705. }
  1706. }
  1707. let quesAnswerStr = paperDetailUnitExp.question.quesAnswer;
  1708. if (quesAnswerStr) {
  1709. while ((ret = regex.exec(quesAnswerStr))) {
  1710. if (audiomap.get(ret[1])) {
  1711. this.dialogLoading = false;
  1712. this.$notify({
  1713. type: "error",
  1714. message: "答案中存在相同的音频文件",
  1715. });
  1716. return;
  1717. } else {
  1718. audiomap.set(ret[1], ret[1]);
  1719. }
  1720. }
  1721. }
  1722. let quesOptions = paperDetailUnitExp.question.quesOptions;
  1723. if (quesOptions) {
  1724. for (let i = 0; i < quesOptions.length; i++) {
  1725. let quesOptionStr = quesOptions[i].optionBody;
  1726. while ((ret = regex.exec(quesOptionStr))) {
  1727. if (audiomap.get(ret[1])) {
  1728. this.dialogLoading = false;
  1729. this.$notify({
  1730. type: "error",
  1731. message: "选项中存在相同的音频文件",
  1732. });
  1733. return;
  1734. } else {
  1735. audiomap.set(ret[1], ret[1]);
  1736. }
  1737. }
  1738. }
  1739. }
  1740. paperDetailUnitExp.question.quesAnswer = this.answer;
  1741. this.$httpWithMsg
  1742. .put(QUESTION_API + "/paperDetailUnit", paperDetailUnitExp)
  1743. .then(() => {
  1744. this.$notify({
  1745. message: "保存成功",
  1746. type: "success",
  1747. });
  1748. this.dialogLoading = false;
  1749. this.closeQuesDialog();
  1750. this.initPaper();
  1751. })
  1752. .finally(() => (this.dialogLoading = false));
  1753. }
  1754. },
  1755. //在正确的option上设置isCorrect=1
  1756. setRightAnswer() {
  1757. if (
  1758. !this.quesModel.quesOptions ||
  1759. this.quesModel.quesOptions.length == 0
  1760. ) {
  1761. return false;
  1762. }
  1763. for (var i = 0; i < this.quesModel.quesOptions.length; i++) {
  1764. var option = this.quesModel.quesOptions[i];
  1765. var answerOrderNum = String.fromCharCode(65 + i);
  1766. if (this.quesModel.questionType == "SINGLE_ANSWER_QUESTION") {
  1767. option["isCorrect"] =
  1768. answerOrderNum == this.singleRightAnswer ? 1 : 0;
  1769. }
  1770. if (this.quesModel.questionType == "MULTIPLE_ANSWER_QUESTION") {
  1771. option["isCorrect"] =
  1772. this.multipleRightAnswer.indexOf(answerOrderNum) > -1 ? 1 : 0;
  1773. }
  1774. }
  1775. },
  1776. //删除试题
  1777. deleteQues(paperDetailUnit) {
  1778. let paperDetailUnitId = paperDetailUnit.id;
  1779. if (this.paper.paperType == "GENERATE") {
  1780. this.deleteQues01(paperDetailUnitId);
  1781. } else {
  1782. let questionId = paperDetailUnit.question.id;
  1783. this.deleteQues02(questionId, paperDetailUnitId);
  1784. }
  1785. },
  1786. deleteQues01(paperDetailUnitId) {
  1787. if (this.paper.paperType == "GENERATE") {
  1788. this.$alert(
  1789. "您确定删除吗?</br><span style='color:red'>保存后请注意检查试卷总分</span>",
  1790. "提示",
  1791. {
  1792. dangerouslyUseHTMLString: true,
  1793. confirmButtonText: "确定",
  1794. callback: (action) => {
  1795. if (action == "confirm") {
  1796. this.loading = true;
  1797. this.$httpWithMsg
  1798. .delete(
  1799. QUESTION_API + "/paperDetailUnit/" + paperDetailUnitId
  1800. )
  1801. .then(() => {
  1802. this.initPaper();
  1803. this.getreduplicateQuestions();
  1804. this.reduplicateGroup = [];
  1805. this.loading = true;
  1806. this.$notify({
  1807. message: "删除成功",
  1808. type: "success",
  1809. });
  1810. })
  1811. .finally(() => (this.loading = false));
  1812. }
  1813. },
  1814. }
  1815. );
  1816. } else {
  1817. this.$alert("您确定删除吗?", "提示", {
  1818. dangerouslyUseHTMLString: true,
  1819. confirmButtonText: "确定",
  1820. callback: (action) => {
  1821. if (action == "confirm") {
  1822. this.loading = true;
  1823. this.$httpWithMsg
  1824. .delete(QUESTION_API + "/paperDetailUnit/" + paperDetailUnitId)
  1825. .then(() => {
  1826. this.initPaper();
  1827. this.getreduplicateQuestions();
  1828. this.reduplicateGroup = [];
  1829. this.loading = true;
  1830. this.$notify({
  1831. message: "删除成功",
  1832. type: "success",
  1833. });
  1834. })
  1835. .finally(() => (this.loading = false));
  1836. }
  1837. },
  1838. });
  1839. }
  1840. },
  1841. deleteQues02(questionId, paperDetailUnitId) {
  1842. if (this.paper.paperType == "GENERATE") {
  1843. this.$alert(
  1844. "您确定删除吗?</br><span style='color:red'>保存后请注意检查试卷总分</span>",
  1845. "提示",
  1846. {
  1847. dangerouslyUseHTMLString: true,
  1848. confirmButtonText: "确定",
  1849. callback: (action) => {
  1850. if (action == "confirm") {
  1851. this.loading = true;
  1852. this.$httpWithMsg
  1853. .delete(
  1854. QUESTION_API +
  1855. "/paper/deleteQuestion/" +
  1856. paperDetailUnitId +
  1857. "/" +
  1858. questionId
  1859. )
  1860. .then(() => {
  1861. this.initPaper();
  1862. this.getreduplicateQuestions();
  1863. this.reduplicateGroup = [];
  1864. this.loading = true;
  1865. this.$notify({
  1866. message: "保存成功",
  1867. type: "success",
  1868. });
  1869. })
  1870. .finally(() => (this.loading = false));
  1871. }
  1872. },
  1873. }
  1874. );
  1875. } else {
  1876. this.$alert("您确定删除吗?", "提示", {
  1877. dangerouslyUseHTMLString: true,
  1878. confirmButtonText: "确定",
  1879. callback: (action) => {
  1880. if (action == "confirm") {
  1881. this.loading = true;
  1882. this.$httpWithMsg
  1883. .delete(
  1884. QUESTION_API +
  1885. "/paper/deleteQuestion/" +
  1886. paperDetailUnitId +
  1887. "/" +
  1888. questionId
  1889. )
  1890. .then(() => {
  1891. this.initPaper();
  1892. this.getreduplicateQuestions();
  1893. this.reduplicateGroup = [];
  1894. this.loading = true;
  1895. this.$notify({
  1896. message: "保存成功",
  1897. type: "success",
  1898. });
  1899. })
  1900. .finally(() => (this.loading = false));
  1901. }
  1902. },
  1903. });
  1904. }
  1905. },
  1906. //获取重复试题
  1907. getreduplicateQuestions() {
  1908. this.duplicateLoading = true;
  1909. this.$http
  1910. .get(QUESTION_API + "/paper/" + this.paperId + "/reduplicate-questions")
  1911. .then((response) => {
  1912. this.reduplicateQuestions = response.data;
  1913. this.duplicateLoading = false;
  1914. this.initReduplicateQuesColor();
  1915. // var ques = document.getElementsByClassName("ques")[0];
  1916. // ques.style.display = "inline";
  1917. });
  1918. },
  1919. exportPaperAnswer() {
  1920. var key = this.user.key;
  1921. var token = this.user.token;
  1922. window.open(
  1923. QUESTION_API +
  1924. "/paper/answer/export/" +
  1925. this.paperId +
  1926. "?$key=" +
  1927. key +
  1928. "&$token=" +
  1929. token
  1930. );
  1931. },
  1932. initReduplicateQuesColor() {
  1933. var colorCount = this.reduplicateQuestions.length;
  1934. if (colorCount > 20) {
  1935. this.reduplicateQuesColor = randomColor({
  1936. luminosity: "bright",
  1937. count: colorCount,
  1938. });
  1939. } else {
  1940. this.reduplicateQuesColor = this.defaultColor;
  1941. }
  1942. },
  1943. getSubQuesEditId(paperDetailUnit, subQuestion) {
  1944. return paperDetailUnit.question.id + "_" + subQuestion.quesParams.number;
  1945. },
  1946. //打开考试说明编辑框
  1947. openEditExamPaperRemark() {
  1948. if (this.paper.examRemark) {
  1949. this.examRemark = this.paper.examRemark;
  1950. } else {
  1951. this.examRemark = "";
  1952. }
  1953. this.paperRemarkDialog = true;
  1954. },
  1955. //保存考试说明
  1956. savePaperRemark() {
  1957. this.paper.examRemark = this.examRemark;
  1958. this.savePaper();
  1959. this.paperRemarkDialog = false;
  1960. },
  1961. //关闭考试说明编辑框
  1962. closPaperRemark() {
  1963. this.examRemark = "";
  1964. this.paperRemarkDialog = false;
  1965. },
  1966. //保存试卷
  1967. savePaper() {
  1968. if (this.paper.paperType == "GENERATE") {
  1969. this.$confirm(
  1970. "<span style='color:red'>当前试卷总分为" +
  1971. this.paper.totalScore +
  1972. ",是否保存?</span>",
  1973. "提示",
  1974. {
  1975. dangerouslyUseHTMLString: true,
  1976. confirmButtonText: "是",
  1977. cancelButtonText: "否",
  1978. type: "warning",
  1979. }
  1980. ).then(() => {
  1981. this.loading = true;
  1982. this.$http
  1983. .put(QUESTION_API + "/paper", this.paper)
  1984. .then(() => {
  1985. this.$notify({
  1986. message: "保存成功",
  1987. type: "success",
  1988. });
  1989. this.loading = false;
  1990. this.initPaper();
  1991. })
  1992. .catch((error) => {
  1993. this.loading = false;
  1994. this.$notify({
  1995. type: "error",
  1996. message: error.response.data.desc,
  1997. });
  1998. })
  1999. .finally(() => (this.loading = false));
  2000. });
  2001. } else {
  2002. this.loading = true;
  2003. this.$http
  2004. .put(QUESTION_API + "/paper", this.paper)
  2005. .then(() => {
  2006. this.$notify({
  2007. message: "保存成功",
  2008. type: "success",
  2009. });
  2010. this.loading = false;
  2011. this.initPaper();
  2012. })
  2013. .catch((error) => {
  2014. this.loading = false;
  2015. this.$notify({
  2016. type: "error",
  2017. message: error.response.data.desc,
  2018. });
  2019. })
  2020. .finally(() => (this.loading = false));
  2021. }
  2022. },
  2023. //删除试卷
  2024. deletePaper(id) {
  2025. this.$confirm("确认删除试卷吗?", "提示", {
  2026. type: "warning",
  2027. }).then(() => {
  2028. this.loading = true;
  2029. let param = new URLSearchParams({
  2030. paperIds: id,
  2031. });
  2032. this.$http.post(QUESTION_API + "/paper", param).then(
  2033. () => {
  2034. this.$notify({
  2035. message: "删除成功",
  2036. type: "success",
  2037. });
  2038. this.back();
  2039. },
  2040. (error) => {
  2041. this.$notify({
  2042. message: error.response.data.desc,
  2043. type: "error",
  2044. title: "错误",
  2045. });
  2046. this.loading = false;
  2047. }
  2048. );
  2049. });
  2050. },
  2051. //打开上传音频弹框
  2052. openDialog() {
  2053. this.checkResult = false;
  2054. this.isUpload = true;
  2055. if (document.getElementById("radioFile")) {
  2056. document.getElementById("radioFile").value = "";
  2057. }
  2058. this.dialogRadioFile = true;
  2059. this.fileList = [];
  2060. },
  2061. //关闭音频弹框
  2062. closeAudioDialog() {
  2063. this.dialogRadioFile = this.uploadAudioLoading;
  2064. },
  2065. //返回
  2066. back() {
  2067. if (sessionStorage.getItem("question_back") == "true") {
  2068. this.$router.push({
  2069. path: "/questions/" + this.parentView + "/0",
  2070. });
  2071. } else {
  2072. this.$router.push({
  2073. path: "/questions/" + this.parentView + "/1",
  2074. });
  2075. }
  2076. },
  2077. paperDetailShow(paperDetail) {
  2078. if (this.reduplicateGroup.length == 0) {
  2079. return true;
  2080. }
  2081. let paperDetailUnits = paperDetail.paperDetailUnits;
  2082. for (let i = 0, imax = paperDetailUnits.length; i < imax; i++) {
  2083. for (var j = 0, jmax = this.reduplicateGroup.length; j < jmax; j++) {
  2084. if (paperDetailUnits[i].id == this.reduplicateGroup[j]) {
  2085. return true;
  2086. }
  2087. }
  2088. }
  2089. return false;
  2090. },
  2091. //上传文件检查
  2092. checkFile() {
  2093. this.fileNameList = [];
  2094. //读取选取的文件夹里面的文件
  2095. this.checkResult = true;
  2096. var files = document.getElementById("radioFile").files;
  2097. if (files.length == 0) {
  2098. this.message = "请选择音频文件夹!";
  2099. return;
  2100. }
  2101. var size = 0;
  2102. var isGo = false;
  2103. //取到所有文件的文件名
  2104. for (var i = 0; i < files.length; i++) {
  2105. this.fileNameList.push(files[i].name);
  2106. if (files[i].size > 5 * 1024 * 1024) {
  2107. isGo = true;
  2108. break;
  2109. }
  2110. size = files[i].size + size;
  2111. }
  2112. if (isGo) {
  2113. this.message = "上传单个文件不能超过5M";
  2114. this.isUpload = true;
  2115. }
  2116. if (size > 50 * 1024 * 1024) {
  2117. this.message = "上传文件总和不能超过50M";
  2118. this.isUpload = true;
  2119. return;
  2120. }
  2121. this.$http
  2122. .post(
  2123. QUESTION_API + "/checkRadioFile/" + this.paperId,
  2124. this.fileNameList
  2125. )
  2126. .then((response) => {
  2127. console.log("response:", response);
  2128. this.message = response.data.errorMsg;
  2129. if (this.message == "OK") {
  2130. this.message = "OK!";
  2131. this.isUpload = false;
  2132. } else {
  2133. this.isUpload = true;
  2134. }
  2135. })
  2136. .catch((error) => {
  2137. console.log(error);
  2138. });
  2139. },
  2140. //读取文件
  2141. uploadAudioFile() {
  2142. let param = new FormData();
  2143. var fileList = document.getElementById("radioFile").files;
  2144. //循环添加到formData中
  2145. for (var i = 0; i < fileList.length; i++) {
  2146. var file = fileList[i];
  2147. param.append("files", file, file.name);
  2148. }
  2149. let config = {
  2150. headers: { "Content-Type": "multipart/form-data" },
  2151. };
  2152. this.$http
  2153. .post(QUESTION_API + "/uploadRadio/" + this.paperId, param, config)
  2154. .then(() => {
  2155. this.dialogRadioFile = false;
  2156. this.uploadAudioLoading = false;
  2157. this.checkResult = false;
  2158. this.isUpload = true;
  2159. document.getElementById("radioFile").value = "";
  2160. this.initPaper();
  2161. })
  2162. .catch((error) => {
  2163. this.message = error.response.data.desc;
  2164. this.uploadAudioLoading = false;
  2165. });
  2166. },
  2167. },
  2168. };
  2169. </script>
  2170. <style scoped src="../styles/EditPaper.css">
  2171. .property_with {
  2172. width: 100px;
  2173. }
  2174. .ck-toolbar {
  2175. z-index: 9999;
  2176. }
  2177. #app {
  2178. background-color: white !important;
  2179. }
  2180. </style>
  2181. <style scoped src="../styles/Common.css"></style>