InsertPaperStructureInfo.vue 39 KB

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