InsertPaperStructureInfo.vue 39 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145
  1. <template>
  2. <div>
  3. <section class="content">
  4. <div>
  5. <!-- 头信息 -->
  6. <div>
  7. <h3 class="box-title">题型创建->{{ detailName }}</h3>
  8. </div>
  9. <!-- 正文信息 -->
  10. <div class="box-body">
  11. <el-form
  12. :inline="true"
  13. :model="paperUnitForm"
  14. :rules="rules"
  15. ref="paperUnitForm"
  16. label-position="right"
  17. label-width="90px"
  18. >
  19. <el-form-item
  20. label="题型结构"
  21. class="pull-left"
  22. prop="questionType"
  23. >
  24. <el-select
  25. @change="getQuesNameList"
  26. v-model="paperUnitForm.questionType"
  27. placeholder="请选择"
  28. >
  29. <el-option
  30. v-for="item in quesTypes"
  31. :label="item.label"
  32. :value="item.value"
  33. :key="item.value"
  34. ></el-option>
  35. </el-select>
  36. </el-form-item>
  37. <el-form-item label="题目数量" prop="count">
  38. <el-button @click="propertyDialog = true;">
  39. {{ paperUnitForm.count }}
  40. </el-button>
  41. </el-form-item>
  42. <el-form-item label="每题分值" class="pull-left" prop="score">
  43. <el-input
  44. v-model.number="paperUnitForm.score"
  45. @change="muli"
  46. placeholder="请输入"
  47. ></el-input>
  48. </el-form-item>
  49. <el-form-item label="题型总分" class="pull-left" prop="totalScore">
  50. <el-input
  51. v-model="paperUnitForm.totalScore"
  52. :disabled="true"
  53. ></el-input>
  54. </el-form-item>
  55. <el-form-item label="来源大题" class="pull-left" prop="quesNames">
  56. <el-select
  57. multiple
  58. v-model="paperUnitForm.quesNames"
  59. placeholder="请选择"
  60. >
  61. <el-option
  62. v-for="item in quesNameList"
  63. :label="item.name"
  64. :value="item.code"
  65. :key="item.code"
  66. ></el-option>
  67. </el-select>
  68. </el-form-item>
  69. <el-form-item class="pull-right">
  70. <el-button
  71. size="small"
  72. type="primary"
  73. @click="submitForm('paperUnitForm');"
  74. >保 存</el-button
  75. >
  76. <el-button
  77. size="small"
  78. type="danger"
  79. @click="resetForm('paperUnitForm');"
  80. >重 置</el-button
  81. >
  82. <el-button
  83. size="small"
  84. type="primary"
  85. icon="caret-left"
  86. @click="back"
  87. >返 回</el-button
  88. >
  89. </el-form-item>
  90. </el-form>
  91. <!-- 页面列表 -->
  92. <el-table
  93. :data="unitStructs"
  94. border
  95. style="width: 100%;text-align:center;"
  96. >
  97. <el-table-column label="大题名称" width="100">
  98. <template slot-scope="scope">
  99. <div>
  100. <span>{{ scope.detailName }}</span>
  101. </div>
  102. </template>
  103. </el-table-column>
  104. <el-table-column label="题型结构" width="100">
  105. <template slot-scope="scope">
  106. <div>
  107. <span>{{ getQuesTypeName(scope.row.questionType) }}</span>
  108. </div>
  109. </template>
  110. </el-table-column>
  111. <el-table-column label="题目总数" width="100">
  112. <template slot-scope="scope">
  113. <div>
  114. <span>{{ scope.row.count }}</span>
  115. </div>
  116. </template>
  117. </el-table-column>
  118. <el-table-column label="公开(简单)" width="130">
  119. <template slot-scope="scope">
  120. <div>
  121. <span>{{ scope.row.publicSimple }}</span>
  122. </div>
  123. </template>
  124. </el-table-column>
  125. <el-table-column label="公开(中等)" width="130">
  126. <template slot-scope="scope">
  127. <div>
  128. <span>{{ scope.row.publicMedium }}</span>
  129. </div>
  130. </template>
  131. </el-table-column>
  132. <el-table-column label="公开(困难)" width="130">
  133. <template slot-scope="scope">
  134. <div>
  135. <span>{{ scope.row.publicDifficulty }}</span>
  136. </div>
  137. </template>
  138. </el-table-column>
  139. <el-table-column label="非公开(简单)" width="140">
  140. <template slot-scope="scope">
  141. <div>
  142. <span>{{ scope.row.noPublicSimple }}</span>
  143. </div>
  144. </template>
  145. </el-table-column>
  146. <el-table-column label="非公开(中等)" width="140">
  147. <template slot-scope="scope">
  148. <div>
  149. <span>{{ scope.row.noPublicMedium }}</span>
  150. </div>
  151. </template>
  152. </el-table-column>
  153. <el-table-column label="非公开(困难)" width="140">
  154. <template slot-scope="scope">
  155. <div>
  156. <span>{{ scope.row.noPublicDifficulty }}</span>
  157. </div>
  158. </template>
  159. </el-table-column>
  160. <el-table-column label="每题分值" width="100">
  161. <template slot-scope="scope">
  162. <div>
  163. <span>{{ scope.row.score }}</span>
  164. </div>
  165. </template>
  166. </el-table-column>
  167. <el-table-column label="题型总分" width="100">
  168. <template slot-scope="scope">
  169. <div>
  170. <span>{{ scope.row.totalScore }}</span>
  171. </div>
  172. </template>
  173. </el-table-column>
  174. <el-table-column label="来源大题" width="150">
  175. <template slot-scope="scope">
  176. <div>
  177. <span>{{ getQuesNames(scope.row.quesNames) }}</span>
  178. </div>
  179. </template>
  180. </el-table-column>
  181. <el-table-column label="操作" width="140">
  182. <template slot-scope="scope">
  183. <div>
  184. <el-button
  185. size="mini"
  186. type="info"
  187. @click="openPaperDetailUnitStructDialog(scope.row.id);"
  188. >编辑</el-button
  189. >
  190. <el-button
  191. size="mini"
  192. type="danger"
  193. @click="deleteUnit(scope.row.id);"
  194. >删除</el-button
  195. >
  196. </div>
  197. </template>
  198. </el-table-column>
  199. </el-table>
  200. <!-- 小题信息 -->
  201. <el-dialog
  202. title="小题信息"
  203. :visible.sync="paperDetailUnitStructDialog"
  204. >
  205. <div>
  206. <el-form
  207. :inline="true"
  208. :model="paperUnitForm2"
  209. :rules="rules"
  210. ref="paperUnitForm2"
  211. >
  212. <el-row :gutter="45">
  213. <el-col :span="12">
  214. <el-form-item label="题型结构" prop="questionType">
  215. <el-select
  216. @change="getQuesNameList"
  217. v-model="paperUnitForm2.questionType"
  218. placeholder="请选择"
  219. >
  220. <el-option
  221. v-for="item in quesTypes"
  222. :label="item.label"
  223. :value="item.value"
  224. :key="item.value"
  225. ></el-option>
  226. </el-select>
  227. </el-form-item>
  228. </el-col>
  229. <el-col :span="12">
  230. <el-form-item
  231. label="每题分值"
  232. class="pull-left"
  233. prop="score"
  234. >
  235. <el-input
  236. v-model.number="paperUnitForm2.score"
  237. @change="muli2"
  238. placeholder="请输入"
  239. ></el-input>
  240. </el-form-item>
  241. </el-col>
  242. </el-row>
  243. <el-row :gutter="45">
  244. <el-col :span="12">
  245. <el-form-item label="题型总分" prop="totalScore">
  246. <el-input
  247. v-model="paperUnitForm2.totalScore"
  248. :disabled="true"
  249. ></el-input>
  250. </el-form-item>
  251. </el-col>
  252. <el-col :span="12">
  253. <el-form-item label="来源大题" prop="quesNames">
  254. <el-select
  255. multiple
  256. v-model="paperUnitForm2.quesNames"
  257. placeholder="请选择"
  258. >
  259. <el-option
  260. v-for="item in quesNameList"
  261. :label="item.name"
  262. :value="item.code"
  263. :key="item.code"
  264. ></el-option>
  265. </el-select>
  266. </el-form-item>
  267. </el-col>
  268. </el-row>
  269. <el-row :gutter="20">
  270. <el-col :span="6">
  271. <div class="grid-content bg-purple">公开(简单)</div>
  272. </el-col>
  273. <el-col :span="6">
  274. <div class="grid-content bg-purple">公开(中等)</div>
  275. </el-col>
  276. <el-col :span="6">
  277. <div class="grid-content bg-purple">公开(困难)</div>
  278. </el-col>
  279. <el-col :span="6">
  280. <div class="grid-content bg-purple">公开总数</div>
  281. </el-col>
  282. </el-row>
  283. <!-- 第二列 -->
  284. <el-row :gutter="20">
  285. <el-col :span="6">
  286. <div class="grid-content bg-purple">
  287. <el-input
  288. v-model="paperUnitForm2.publicSimple"
  289. @change="
  290. unitCount(
  291. paperUnitForm2.publicSimple,
  292. 'publicSimple',
  293. paperUnitForm2
  294. );
  295. "
  296. ></el-input>
  297. </div>
  298. </el-col>
  299. <el-col :span="6">
  300. <div class="grid-content bg-purple">
  301. <el-input
  302. v-model="paperUnitForm2.publicMedium"
  303. @change="
  304. unitCount(
  305. paperUnitForm2.publicMedium,
  306. 'publicMedium',
  307. paperUnitForm2
  308. );
  309. "
  310. ></el-input>
  311. </div>
  312. </el-col>
  313. <el-col :span="6">
  314. <div class="grid-content bg-purple">
  315. <el-input
  316. v-model="paperUnitForm2.publicDifficulty"
  317. @change="
  318. unitCount(
  319. paperUnitForm2.publicDifficulty,
  320. 'publicDifficulty',
  321. paperUnitForm2
  322. );
  323. "
  324. ></el-input>
  325. </div>
  326. </el-col>
  327. <el-col :span="6">
  328. <div class="grid-content bg-purple">
  329. <el-input
  330. v-model="paperUnitForm2.publicSum"
  331. :disabled="true"
  332. ></el-input>
  333. </div>
  334. </el-col>
  335. </el-row>
  336. <el-row :gutter="20">
  337. <el-col :span="6">
  338. <div class="grid-content bg-purple">非公开(简单)</div>
  339. </el-col>
  340. <el-col :span="6">
  341. <div class="grid-content bg-purple">非公开(中等)</div>
  342. </el-col>
  343. <el-col :span="6">
  344. <div class="grid-content bg-purple">非公开(困难)</div>
  345. </el-col>
  346. <el-col :span="6">
  347. <div class="grid-content bg-purple">非公开总数</div>
  348. </el-col>
  349. </el-row>
  350. <!-- 第四列 -->
  351. <el-row :gutter="20">
  352. <el-col :span="6">
  353. <div class="grid-content bg-purple">
  354. <el-input
  355. v-model="paperUnitForm2.noPublicSimple"
  356. @change="
  357. unitCount(
  358. paperUnitForm2.noPublicSimple,
  359. 'noPublicSimple',
  360. paperUnitForm2
  361. );
  362. "
  363. ></el-input>
  364. </div>
  365. </el-col>
  366. <el-col :span="6">
  367. <div class="grid-content bg-purple">
  368. <el-input
  369. v-model="paperUnitForm2.noPublicMedium"
  370. @change="
  371. unitCount(
  372. paperUnitForm2.noPublicMedium,
  373. 'noPublicMedium',
  374. paperUnitForm2
  375. );
  376. "
  377. ></el-input>
  378. </div>
  379. </el-col>
  380. <el-col :span="6">
  381. <div class="grid-content bg-purple">
  382. <el-input
  383. v-model="paperUnitForm2.noPublicDifficulty"
  384. @change="
  385. unitCount(
  386. paperUnitForm2.noPublicDifficulty,
  387. 'noPublicDifficulty',
  388. paperUnitForm2
  389. );
  390. "
  391. ></el-input>
  392. </div>
  393. </el-col>
  394. <el-col :span="6">
  395. <div class="grid-content bg-purple">
  396. <el-input
  397. v-model="paperUnitForm2.noPublicSum"
  398. :disabled="true"
  399. ></el-input>
  400. </div>
  401. </el-col>
  402. </el-row>
  403. <el-row :gutter="20">
  404. <el-col :span="6">
  405. <div class="grid-content bg-purple">简单总数</div>
  406. </el-col>
  407. <el-col :span="6">
  408. <div class="grid-content bg-purple">中等总数</div>
  409. </el-col>
  410. <el-col :span="6">
  411. <div class="grid-content bg-purple">困难总数</div>
  412. </el-col>
  413. <el-col :span="6">
  414. <div class="grid-content bg-purple">总数</div>
  415. </el-col>
  416. </el-row>
  417. <!-- 第六列 -->
  418. <el-row :gutter="20">
  419. <el-col :span="6">
  420. <div class="grid-content bg-purple">
  421. <el-input
  422. v-model="paperUnitForm2.simpleSum"
  423. :disabled="true"
  424. ></el-input>
  425. </div>
  426. </el-col>
  427. <el-col :span="6">
  428. <div class="grid-content bg-purple">
  429. <el-input
  430. v-model="paperUnitForm2.mediumSum"
  431. :disabled="true"
  432. ></el-input>
  433. </div>
  434. </el-col>
  435. <el-col :span="6">
  436. <div class="grid-content bg-purple">
  437. <el-input
  438. v-model="paperUnitForm2.difficultySum"
  439. :disabled="true"
  440. ></el-input>
  441. </div>
  442. </el-col>
  443. <el-col :span="6">
  444. <div class="grid-content bg-purple">
  445. <el-input
  446. v-model="paperUnitForm2.count"
  447. :disabled="true"
  448. ></el-input>
  449. </div>
  450. </el-col>
  451. </el-row>
  452. <el-row>
  453. <div>
  454. <el-button
  455. type="primary"
  456. @click="editSubmitForm('paperUnitForm2');"
  457. >保 存</el-button
  458. >
  459. </div>
  460. </el-row>
  461. </el-form>
  462. </div>
  463. </el-dialog>
  464. <!-- 设置题目数量弹框 -->
  465. <el-dialog title="题目数量" :visible.sync="propertyDialog">
  466. <el-row :gutter="20">
  467. <el-col :span="6">
  468. <div class="grid-content bg-purple">公开(简单)</div>
  469. </el-col>
  470. <el-col :span="6">
  471. <div class="grid-content bg-purple">公开(中等)</div>
  472. </el-col>
  473. <el-col :span="6">
  474. <div class="grid-content bg-purple">公开(困难)</div>
  475. </el-col>
  476. <el-col :span="6">
  477. <div class="grid-content bg-purple">公开总数</div>
  478. </el-col>
  479. </el-row>
  480. <!-- 第二列 -->
  481. <el-row :gutter="20">
  482. <el-col :span="6">
  483. <div class="grid-content bg-purple">
  484. <el-input
  485. v-model="paperUnitForm.publicSimple"
  486. @change="
  487. unitCount(
  488. paperUnitForm.publicSimple,
  489. 'publicSimple',
  490. paperUnitForm
  491. );
  492. "
  493. ></el-input>
  494. </div>
  495. </el-col>
  496. <el-col :span="6">
  497. <div class="grid-content bg-purple">
  498. <el-input
  499. v-model="paperUnitForm.publicMedium"
  500. @change="
  501. unitCount(
  502. paperUnitForm.publicMedium,
  503. 'publicMedium',
  504. paperUnitForm
  505. );
  506. "
  507. ></el-input>
  508. </div>
  509. </el-col>
  510. <el-col :span="6">
  511. <div class="grid-content bg-purple">
  512. <el-input
  513. v-model="paperUnitForm.publicDifficulty"
  514. @change="
  515. unitCount(
  516. paperUnitForm.publicDifficulty,
  517. 'publicDifficulty',
  518. paperUnitForm
  519. );
  520. "
  521. ></el-input>
  522. </div>
  523. </el-col>
  524. <el-col :span="6">
  525. <div class="grid-content bg-purple">
  526. <el-input
  527. v-model="paperUnitForm.publicSum"
  528. :disabled="true"
  529. ></el-input>
  530. </div>
  531. </el-col>
  532. </el-row>
  533. <el-row :gutter="20">
  534. <el-col :span="6">
  535. <div class="grid-content bg-purple">非公开(简单)</div>
  536. </el-col>
  537. <el-col :span="6">
  538. <div class="grid-content bg-purple">非公开(中等)</div>
  539. </el-col>
  540. <el-col :span="6">
  541. <div class="grid-content bg-purple">非公开(困难)</div>
  542. </el-col>
  543. <el-col :span="6">
  544. <div class="grid-content bg-purple">非公开总数</div>
  545. </el-col>
  546. </el-row>
  547. <!-- 第四列 -->
  548. <el-row :gutter="20">
  549. <el-col :span="6">
  550. <div class="grid-content bg-purple">
  551. <el-input
  552. v-model="paperUnitForm.noPublicSimple"
  553. @change="
  554. unitCount(
  555. paperUnitForm.noPublicSimple,
  556. 'noPublicSimple',
  557. paperUnitForm
  558. );
  559. "
  560. ></el-input>
  561. </div>
  562. </el-col>
  563. <el-col :span="6">
  564. <div class="grid-content bg-purple">
  565. <el-input
  566. v-model="paperUnitForm.noPublicMedium"
  567. @change="
  568. unitCount(
  569. paperUnitForm.noPublicMedium,
  570. 'noPublicMedium',
  571. paperUnitForm
  572. );
  573. "
  574. ></el-input>
  575. </div>
  576. </el-col>
  577. <el-col :span="6">
  578. <div class="grid-content bg-purple">
  579. <el-input
  580. v-model="paperUnitForm.noPublicDifficulty"
  581. @change="
  582. unitCount(
  583. paperUnitForm.noPublicDifficulty,
  584. 'noPublicDifficulty',
  585. paperUnitForm
  586. );
  587. "
  588. ></el-input>
  589. </div>
  590. </el-col>
  591. <el-col :span="6">
  592. <div class="grid-content bg-purple">
  593. <el-input
  594. v-model="paperUnitForm.noPublicSum"
  595. :disabled="true"
  596. ></el-input>
  597. </div>
  598. </el-col>
  599. </el-row>
  600. <el-row :gutter="20">
  601. <el-col :span="6">
  602. <div class="grid-content bg-purple">简单总数</div>
  603. </el-col>
  604. <el-col :span="6">
  605. <div class="grid-content bg-purple">中等总数</div>
  606. </el-col>
  607. <el-col :span="6">
  608. <div class="grid-content bg-purple">困难总数</div>
  609. </el-col>
  610. <el-col :span="6">
  611. <div class="grid-content bg-purple">总数</div>
  612. </el-col>
  613. </el-row>
  614. <!-- 第六列 -->
  615. <el-row :gutter="20">
  616. <el-col :span="6">
  617. <div class="grid-content bg-purple">
  618. <el-input
  619. v-model="paperUnitForm.simpleSum"
  620. :disabled="true"
  621. ></el-input>
  622. </div>
  623. </el-col>
  624. <el-col :span="6">
  625. <div class="grid-content bg-purple">
  626. <el-input
  627. v-model="paperUnitForm.mediumSum"
  628. :disabled="true"
  629. ></el-input>
  630. </div>
  631. </el-col>
  632. <el-col :span="6">
  633. <div class="grid-content bg-purple">
  634. <el-input
  635. v-model="paperUnitForm.difficultySum"
  636. :disabled="true"
  637. ></el-input>
  638. </div>
  639. </el-col>
  640. <el-col :span="6">
  641. <div class="grid-content bg-purple">
  642. <el-input
  643. v-model="paperUnitForm.count"
  644. :disabled="true"
  645. ></el-input>
  646. </div>
  647. </el-col>
  648. </el-row>
  649. <div style="margin-top:20px;margin-left:42%">
  650. <el-button type="primary" @click="propertyDialog = false;"
  651. >保 存</el-button
  652. >
  653. <el-button type="primary" @click="propertyDialog = false;"
  654. >返 回</el-button
  655. >
  656. </div>
  657. </el-dialog>
  658. </div>
  659. </div>
  660. </section>
  661. </div>
  662. </template>
  663. <script>
  664. import { QUESTION_API } from "@/constants/constants";
  665. import { QUESTION_TYPES } from "../constants/constants";
  666. import _ from "lodash";
  667. export default {
  668. data() {
  669. var checkIntegerNumber = (rule, value, callback) => {
  670. if (!value) {
  671. return callback(new Error("数值不能为空"));
  672. }
  673. setTimeout(() => {
  674. if (!Number.isInteger(value)) {
  675. callback(new Error("请输入整数"));
  676. } else {
  677. if (value < 0) {
  678. callback(new Error("必须大于0"));
  679. } else {
  680. callback();
  681. }
  682. }
  683. }, 100);
  684. };
  685. var checkDoubleNumber = (rule, value, callback) => {
  686. //var reg = /^[-\+]?\d+(\.\d+)?$/;
  687. var reg = /^\d+(?=\.{0,1}\d+$|$)/;
  688. if (!value) {
  689. return callback(new Error("数值不能为空"));
  690. }
  691. setTimeout(() => {
  692. if (!reg.test(value)) {
  693. callback(new Error("请输入数值"));
  694. } else {
  695. if (value < 0) {
  696. callback(new Error("必须大于等于0"));
  697. } else {
  698. callback();
  699. }
  700. }
  701. }, 100);
  702. };
  703. var validateQuesNames = (rule, value, callback) => {
  704. if (Array.isArray(value) && value.length == 0) {
  705. callback(new Error("请选择来源大题"));
  706. } else {
  707. callback();
  708. }
  709. };
  710. return {
  711. quesTypes: QUESTION_TYPES,
  712. courseNo: "",
  713. quesNameList: [],
  714. paperUnitForm: {
  715. id: "",
  716. questionType: "",
  717. count: 0,
  718. score: "",
  719. totalScore: "",
  720. quesNames: [],
  721. publicSimple: 0,
  722. publicMedium: 0,
  723. publicDifficulty: 0,
  724. noPublicSimple: 0,
  725. noPublicMedium: 0,
  726. noPublicDifficulty: 0,
  727. publicSum: 0,
  728. noPublicSum: 0,
  729. simpleSum: 0,
  730. mediumSum: 0,
  731. difficultySum: 0
  732. },
  733. paperUnitForm2: {
  734. id: "",
  735. questionType: "",
  736. count: "",
  737. score: "",
  738. totalScore: "",
  739. quesNames: [],
  740. publicSimple: 0,
  741. publicMedium: 0,
  742. publicDifficulty: 0,
  743. noPublicSimple: 0,
  744. noPublicMedium: 0,
  745. noPublicDifficulty: 0,
  746. publicSum: 0,
  747. noPublicSum: 0,
  748. simpleSum: 0,
  749. mediumSum: 0,
  750. difficultySum: 0
  751. },
  752. unitId: "",
  753. detailName: "",
  754. detailId: "",
  755. paperStructId: "",
  756. paperStruct: {},
  757. unitStructs: [],
  758. paperDetailUnitStructDialog: false,
  759. propertyDialog: false,
  760. rules: {
  761. questionType: [
  762. { required: true, message: "题型不能为空", trigger: "change" }
  763. ],
  764. count: [
  765. { validator: checkIntegerNumber, required: true, trigger: "blur" }
  766. ],
  767. score: [
  768. { required: true, validator: checkDoubleNumber, trigger: "blur" }
  769. ],
  770. quesNames: [{ validator: validateQuesNames, trigger: "change" }]
  771. }
  772. };
  773. },
  774. methods: {
  775. //查询来源大题名称
  776. getQuesNameList(quesType) {
  777. if (quesType && quesType.length > 0) {
  778. var quesTypeObj = {};
  779. var url = QUESTION_API + "/paperStruct/quesNames";
  780. if (this.courseNo !== "all") {
  781. quesTypeObj = {
  782. quesType: quesType,
  783. courseNo: this.courseNo
  784. };
  785. } else {
  786. quesTypeObj = {
  787. quesType: quesType
  788. };
  789. }
  790. this.$http.get(url, { params: quesTypeObj }).then(response => {
  791. console.log(response);
  792. this.quesNameList = response.data;
  793. this.initQuesNames();
  794. });
  795. }
  796. },
  797. initQuesNames() {
  798. var arr1 = _.difference(this.paperUnitForm.quesNames, this.quesNames);
  799. if (arr1.length > 0) {
  800. this.paperUnitForm.quesNames = [];
  801. }
  802. var arr2 = _.difference(this.paperUnitForm2.quesNames, this.quesNames);
  803. if (arr2.length > 0) {
  804. this.paperUnitForm2.quesNames = [];
  805. }
  806. },
  807. getQuesNames(quesNameList) {
  808. var quesNameStr = "";
  809. if (!Array.isArray(quesNameList)) {
  810. return quesNameStr;
  811. }
  812. for (let quesName of quesNameList) {
  813. if (quesNameStr === "") {
  814. quesNameStr += quesName;
  815. } else {
  816. quesNameStr += "," + quesName;
  817. }
  818. }
  819. return quesNameStr;
  820. },
  821. //查询列表集合
  822. searchForm() {
  823. this.loading = true;
  824. var paperStructStorge = sessionStorage.getItem("paperStruct");
  825. if (typeof paperStructStorge === "string") {
  826. var paperStruct = JSON.parse(paperStructStorge);
  827. this.paperStruct = paperStruct;
  828. this.unitStructs = this.getUnits();
  829. }
  830. },
  831. //保存
  832. submitForm(formData) {
  833. this.loading = true;
  834. this.$refs[formData].validate(valid => {
  835. if (valid) {
  836. var unitStruct = Object.assign({}, this.paperUnitForm);
  837. var ids = [];
  838. for (let unitStruct of this.unitStructs) {
  839. ids.push(unitStruct.id);
  840. }
  841. ids.sort();
  842. var maxId;
  843. if (ids.length == 0) {
  844. maxId = 1;
  845. } else {
  846. maxId = ids[ids.length - 1];
  847. }
  848. unitStruct.id = maxId + 1;
  849. this.unitStructs.push(unitStruct);
  850. this.resetForm();
  851. this.setUnits();
  852. sessionStorage.setItem(
  853. "paperStruct",
  854. JSON.stringify(this.paperStruct)
  855. );
  856. } else {
  857. return false;
  858. }
  859. });
  860. },
  861. editSubmitForm(formData) {
  862. this.$refs[formData].validate(valid => {
  863. if (valid) {
  864. for (let unitStruct of this.unitStructs) {
  865. if (unitStruct.id == this.paperUnitForm2.id) {
  866. unitStruct.questionType = this.paperUnitForm2.questionType;
  867. unitStruct.count = this.paperUnitForm2.count;
  868. unitStruct.score = this.paperUnitForm2.score;
  869. unitStruct.totalScore = this.paperUnitForm2.totalScore;
  870. unitStruct.quesNames = this.paperUnitForm2.quesNames;
  871. unitStruct.publicSimple = this.paperUnitForm2.publicSimple;
  872. unitStruct.publicMedium = this.paperUnitForm2.publicMedium;
  873. unitStruct.publicDifficulty = this.paperUnitForm2.publicDifficulty;
  874. unitStruct.noPublicSimple = this.paperUnitForm2.noPublicSimple;
  875. unitStruct.noPublicMedium = this.paperUnitForm2.noPublicMedium;
  876. unitStruct.noPublicDifficulty = this.paperUnitForm2.noPublicDifficulty;
  877. unitStruct.publicSum = this.paperUnitForm2.publicSum;
  878. unitStruct.noPublicSum = this.paperUnitForm2.noPublicSum;
  879. unitStruct.simpleSum = this.paperUnitForm2.simpleSum;
  880. unitStruct.mediumSum = this.paperUnitForm2.mediumSum;
  881. unitStruct.difficultySum = this.paperUnitForm2.difficultySum;
  882. this.setUnits();
  883. this.paperDetailUnitStructDialog = false;
  884. sessionStorage.setItem(
  885. "paperStruct",
  886. JSON.stringify(this.paperStruct)
  887. );
  888. }
  889. }
  890. }
  891. });
  892. },
  893. //重置
  894. resetForm() {
  895. this.paperUnitForm = {
  896. id: "",
  897. questionType: "",
  898. count: 0,
  899. score: "",
  900. totalScore: "",
  901. quesNames: [],
  902. publicSimple: 0,
  903. publicMedium: 0,
  904. publicDifficulty: 0,
  905. noPublicSimple: 0,
  906. noPublicMedium: 0,
  907. noPublicDifficulty: 0,
  908. publicSum: 0,
  909. noPublicSum: 0,
  910. simpleSum: 0,
  911. mediumSum: 0,
  912. difficultySum: 0
  913. };
  914. },
  915. //返回
  916. back() {
  917. this.$router.push({
  918. path: "/questions/insert_paper_structure/" + this.paperStructId
  919. });
  920. },
  921. muli() {
  922. this.paperUnitForm.totalScore =
  923. this.paperUnitForm.count * this.paperUnitForm.score;
  924. },
  925. muli2() {
  926. this.paperUnitForm2.totalScore =
  927. this.paperUnitForm2.count * this.paperUnitForm2.score;
  928. },
  929. getUnits() {
  930. var unitStructs = [];
  931. for (let paperDetailStruct of this.paperStruct.paperDetailStructs) {
  932. if (parseInt(paperDetailStruct.id) == this.detailId) {
  933. if (paperDetailStruct.unitStructs) {
  934. return paperDetailStruct.unitStructs;
  935. }
  936. }
  937. }
  938. return unitStructs;
  939. },
  940. setUnits() {
  941. for (let paperDetailStruct of this.paperStruct.paperDetailStructs) {
  942. if (parseInt(paperDetailStruct.id) == this.detailId) {
  943. paperDetailStruct.unitStructs = this.unitStructs;
  944. paperDetailStruct.totalScore = this.totalScore;
  945. paperDetailStruct.detailCount = this.detailCount;
  946. }
  947. }
  948. },
  949. getQuesTypeName(value) {
  950. for (let quesType of this.quesTypes) {
  951. if (value == quesType.value) {
  952. return quesType.label;
  953. }
  954. }
  955. },
  956. openPaperDetailUnitStructDialog(id) {
  957. this.unitId = id;
  958. for (let unitStruct of this.unitStructs) {
  959. if (unitStruct.id == id) {
  960. this.paperUnitForm2.id = id;
  961. this.paperUnitForm2.questionType = unitStruct.questionType;
  962. this.paperUnitForm2.count = unitStruct.count;
  963. this.paperUnitForm2.score = unitStruct.score;
  964. this.paperUnitForm2.totalScore = unitStruct.totalScore;
  965. this.paperUnitForm2.quesNames = unitStruct.quesNames;
  966. this.paperUnitForm2.publicSimple = unitStruct.publicSimple;
  967. this.paperUnitForm2.publicMedium = unitStruct.publicMedium;
  968. this.paperUnitForm2.publicDifficulty = unitStruct.publicDifficulty;
  969. this.paperUnitForm2.noPublicSimple = unitStruct.noPublicSimple;
  970. this.paperUnitForm2.noPublicMedium = unitStruct.noPublicMedium;
  971. this.paperUnitForm2.noPublicDifficulty =
  972. unitStruct.noPublicDifficulty;
  973. //实时计算,不存数据库
  974. this.paperUnitForm2.publicSum =
  975. this.paperUnitForm2.publicSimple +
  976. this.paperUnitForm2.publicMedium +
  977. this.paperUnitForm2.publicDifficulty;
  978. this.paperUnitForm2.noPublicSum =
  979. this.paperUnitForm2.noPublicSimple +
  980. this.paperUnitForm2.noPublicMedium +
  981. this.paperUnitForm2.noPublicDifficulty;
  982. this.paperUnitForm2.simpleSum =
  983. this.paperUnitForm2.publicSimple +
  984. this.paperUnitForm2.noPublicSimple;
  985. this.paperUnitForm2.mediumSum =
  986. this.paperUnitForm2.publicMedium +
  987. this.paperUnitForm2.noPublicMedium;
  988. this.paperUnitForm2.difficultySum =
  989. this.paperUnitForm2.publicDifficulty +
  990. this.paperUnitForm2.noPublicDifficulty;
  991. }
  992. }
  993. this.getQuesNameList(this.paperUnitForm2.questionType);
  994. this.paperDetailUnitStructDialog = true;
  995. },
  996. deleteUnit(id) {
  997. var unitStructs = this.unitStructs;
  998. for (let i = unitStructs.length - 1; i >= 0; i--) {
  999. if (unitStructs[i].id == id) {
  1000. unitStructs.splice(i, 1);
  1001. }
  1002. }
  1003. this.unitStructs = unitStructs;
  1004. this.setUnits();
  1005. sessionStorage.setItem("paperStruct", JSON.stringify(this.paperStruct));
  1006. console.log(sessionStorage.getItem("paperStruct"));
  1007. },
  1008. //判断是否为正整数
  1009. isPositiveInteger(s) {
  1010. //是否为正整数
  1011. var re = /^[0-9]+$/;
  1012. return re.test(s);
  1013. },
  1014. //计算数量
  1015. unitCount(data, rowType, paperUnitForm) {
  1016. //计算前校验正整数
  1017. if (!this.isPositiveInteger(data)) {
  1018. if (rowType === "publicSimple") {
  1019. setTimeout(function() {
  1020. paperUnitForm.publicSimple = 0;
  1021. }, 1);
  1022. } else if (rowType === "publicMedium") {
  1023. setTimeout(function() {
  1024. paperUnitForm.publicMedium = 0;
  1025. }, 1);
  1026. } else if (rowType === "publicDifficulty") {
  1027. setTimeout(function() {
  1028. paperUnitForm.publicDifficulty = 0;
  1029. }, 1);
  1030. } else if (rowType === "noPublicSimple") {
  1031. setTimeout(function() {
  1032. paperUnitForm.noPublicSimple = 0;
  1033. }, 1);
  1034. } else if (rowType === "noPublicMedium") {
  1035. setTimeout(function() {
  1036. paperUnitForm.noPublicMedium = 0;
  1037. }, 1);
  1038. } else if (rowType === "noPublicDifficulty") {
  1039. setTimeout(function() {
  1040. paperUnitForm.noPublicDifficulty = 0;
  1041. }, 1);
  1042. }
  1043. }
  1044. setTimeout(function() {
  1045. paperUnitForm.publicSimple = parseInt(paperUnitForm.publicSimple);
  1046. paperUnitForm.publicMedium = parseInt(paperUnitForm.publicMedium);
  1047. paperUnitForm.publicDifficulty = parseInt(
  1048. paperUnitForm.publicDifficulty
  1049. );
  1050. paperUnitForm.noPublicSimple = parseInt(paperUnitForm.noPublicSimple);
  1051. paperUnitForm.noPublicMedium = parseInt(paperUnitForm.noPublicMedium);
  1052. paperUnitForm.noPublicDifficulty = parseInt(
  1053. paperUnitForm.noPublicDifficulty
  1054. );
  1055. //公开总数
  1056. paperUnitForm.publicSum =
  1057. parseInt(paperUnitForm.publicSimple) +
  1058. parseInt(paperUnitForm.publicMedium) +
  1059. parseInt(paperUnitForm.publicDifficulty);
  1060. //非公开总数
  1061. paperUnitForm.noPublicSum =
  1062. parseInt(paperUnitForm.noPublicSimple) +
  1063. parseInt(paperUnitForm.noPublicMedium) +
  1064. parseInt(paperUnitForm.noPublicDifficulty);
  1065. //简单总数
  1066. paperUnitForm.simpleSum =
  1067. parseInt(paperUnitForm.publicSimple) +
  1068. parseInt(paperUnitForm.noPublicSimple);
  1069. //中等总数
  1070. paperUnitForm.mediumSum =
  1071. parseInt(paperUnitForm.publicMedium) +
  1072. parseInt(paperUnitForm.noPublicMedium);
  1073. //困难总数
  1074. paperUnitForm.difficultySum =
  1075. parseInt(paperUnitForm.publicDifficulty) +
  1076. parseInt(paperUnitForm.noPublicDifficulty);
  1077. //总数
  1078. paperUnitForm.count =
  1079. paperUnitForm.publicSum + paperUnitForm.noPublicSum;
  1080. //分数
  1081. paperUnitForm.totalScore = paperUnitForm.count * paperUnitForm.score;
  1082. }, 5);
  1083. }
  1084. },
  1085. computed: {
  1086. totalScore() {
  1087. var sum = 0.0;
  1088. for (let unitStruct of this.unitStructs) {
  1089. sum += unitStruct.totalScore;
  1090. }
  1091. return sum;
  1092. },
  1093. detailCount() {
  1094. var count = 0.0;
  1095. for (let unitStruct of this.unitStructs) {
  1096. count += unitStruct.count;
  1097. }
  1098. return count;
  1099. },
  1100. quesNames() {
  1101. var quesNames = [];
  1102. for (let quesName of this.quesNameList) {
  1103. quesNames.push(quesName.code);
  1104. }
  1105. return quesNames;
  1106. }
  1107. },
  1108. //初始化查询
  1109. created() {
  1110. this.paperStructId = this.$route.params.id;
  1111. this.detailName = this.$route.params.name;
  1112. this.detailId = this.$route.params.detailId;
  1113. this.courseNo = this.$route.params.courseNo;
  1114. this.searchForm();
  1115. }
  1116. };
  1117. </script>
  1118. <style scoped>
  1119. .el-row {
  1120. margin-bottom: 20px;
  1121. }
  1122. .el-col {
  1123. border-radius: 4px;
  1124. }
  1125. .bg-purple-dark {
  1126. background: #dcdfe6;
  1127. }
  1128. .bg-purple {
  1129. background: #dcdfe6;
  1130. }
  1131. .bg-purple-light {
  1132. background: #f9fafc;
  1133. }
  1134. .grid-content {
  1135. border-radius: 4px;
  1136. min-height: 36px;
  1137. }
  1138. .row-bg {
  1139. padding: 10px 0;
  1140. background-color: #f9fafc;
  1141. }
  1142. </style>