onlineHomework.vue 43 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253
  1. <template>
  2. <div>
  3. <LinkTitlesCustom
  4. :current-paths="['考试管理', '考试信息', '在线作业设置']"
  5. />
  6. <section class="content">
  7. <div class="box box-info">
  8. <!-- 正文信息 -->
  9. <div class="box-body">
  10. <el-form
  11. ref="form"
  12. :inline="true"
  13. :rules="rules"
  14. :model="form"
  15. inline-message
  16. label-position="right"
  17. >
  18. <div style="margin-bottom: 10px">
  19. <el-button type="primary" size="small" @click="saveExam"
  20. >保 存</el-button
  21. >
  22. <el-button
  23. type="primary"
  24. size="small"
  25. icon="el-icon-arrow-left"
  26. @click="back"
  27. >返 回</el-button
  28. >
  29. </div>
  30. <el-tabs ref="tabs" v-model="activeName" type="border-card">
  31. <!-- 基础信息 -->
  32. <el-tab-pane label="基础信息" name="tab1">
  33. <el-row v-if="examId != 'add'">
  34. <el-form-item
  35. label="ID"
  36. prop="id"
  37. :label-width="style.label_width_tab1"
  38. >
  39. <el-input
  40. v-model="form.id"
  41. class="input"
  42. :disabled="true"
  43. maxlength="20"
  44. ></el-input>
  45. </el-form-item>
  46. </el-row>
  47. <el-row v-if="examId != 'add'">
  48. <el-form-item
  49. label="考试编码"
  50. placeholder="请输入考试编码"
  51. prop="code"
  52. :label-width="style.label_width_tab1"
  53. >
  54. <el-input
  55. v-model="form.code"
  56. class="input"
  57. :disabled="true"
  58. maxlength="20"
  59. ></el-input>
  60. </el-form-item>
  61. </el-row>
  62. <el-row v-else>
  63. <el-form-item
  64. label="考试编码"
  65. placeholder="请输入考试编码"
  66. prop="code"
  67. :label-width="style.label_width_tab1"
  68. >
  69. <el-input
  70. v-model="form.name"
  71. class="input"
  72. :disabled="true"
  73. maxlength="20"
  74. ></el-input>
  75. </el-form-item>
  76. </el-row>
  77. <el-row>
  78. <el-form-item
  79. label="考试名称"
  80. placeholder="请输入考试名称"
  81. prop="name"
  82. :label-width="style.label_width_tab1"
  83. >
  84. <el-input
  85. v-model="form.name"
  86. class="input"
  87. maxlength="20"
  88. ></el-input>
  89. </el-form-item>
  90. </el-row>
  91. <el-row>
  92. <el-form-item
  93. label="考试类型"
  94. :label-width="style.label_width_tab1"
  95. >
  96. <el-select
  97. v-model="form.examType"
  98. class="input"
  99. :disabled="true"
  100. placeholder="请选择"
  101. >
  102. <el-option
  103. v-for="item in examTypeList"
  104. :key="item.value"
  105. :label="item.label"
  106. :value="item.value"
  107. ></el-option>
  108. </el-select>
  109. </el-form-item>
  110. </el-row>
  111. <el-row>
  112. <el-form-item
  113. label="状态"
  114. :label-width="style.label_width_tab1"
  115. >
  116. <el-radio-group v-model="form.enable" class="input">
  117. <el-radio label="true">启用</el-radio>
  118. <el-radio label="false">禁用</el-radio>
  119. </el-radio-group>
  120. </el-form-item>
  121. </el-row>
  122. <el-row v-if="1 == 2">
  123. <el-form-item
  124. label="是否可以考试"
  125. :label-width="style.label_width_tab1"
  126. >
  127. <el-radio-group v-model="form.examLimit" class="input">
  128. <el-radio label="true">否</el-radio>
  129. <el-radio label="false">是</el-radio>
  130. </el-radio-group>
  131. </el-form-item>
  132. </el-row>
  133. <el-row>
  134. <el-form-item
  135. label="考试时间"
  136. prop="examDatetimeRange"
  137. :label-width="style.label_width_tab1"
  138. >
  139. <el-date-picker
  140. v-model="examDatetimeRange"
  141. class="input"
  142. type="datetimerange"
  143. range-separator="至"
  144. start-placeholder="开始日期"
  145. end-placeholder="结束日期"
  146. value-format="yyyy-MM-dd HH:mm:ss"
  147. :clearable="false"
  148. ></el-date-picker>
  149. </el-form-item>
  150. </el-row>
  151. <el-row>
  152. <el-form-item
  153. label="开启环境检测"
  154. :label-width="style.label_width_tab1"
  155. >
  156. <el-switch
  157. v-model="form.properties.CHECK_ENVIRONMENT"
  158. on-text="是"
  159. off-text="否"
  160. ></el-switch>
  161. </el-form-item>
  162. </el-row>
  163. <el-row>
  164. <el-form-item
  165. label="开放微信小程序作答"
  166. :label-width="style.label_width_tab1"
  167. >
  168. <el-switch
  169. v-model="form.properties.WEIXIN_ANSWER_ENABLED"
  170. :disabled="!rootOrgWenXinAnswerEnabled"
  171. on-text="是"
  172. off-text="否"
  173. ></el-switch>
  174. </el-form-item>
  175. </el-row>
  176. <el-row v-show="false">
  177. <el-form-item
  178. label="开启特殊设置"
  179. :label-width="style.label_width_tab1"
  180. >
  181. <el-switch
  182. v-model="form.specialSettingsEnabled"
  183. on-text="是"
  184. off-text="否"
  185. ></el-switch>
  186. </el-form-item>
  187. </el-row>
  188. <el-row>
  189. <el-form-item
  190. v-show="form.specialSettingsEnabled"
  191. label="特殊设置方式"
  192. :label-width="style.label_width_tab1"
  193. >
  194. <el-radio-group
  195. v-model="form.specialSettingsType"
  196. class="input"
  197. >
  198. <el-radio label="ORG_BASED">机构特殊设置</el-radio>
  199. <el-radio label="STAGE_BASED">场次特殊设置</el-radio>
  200. </el-radio-group>
  201. </el-form-item>
  202. </el-row>
  203. <el-row>
  204. <el-form-item
  205. v-show="form.specialSettingsEnabled"
  206. label="无特殊设置时禁止考试"
  207. :label-width="style.label_width_tab1"
  208. >
  209. <el-switch
  210. v-model="form.properties.LIMITED_IF_NO_SPECIAL_SETTINGS"
  211. on-text="是"
  212. off-text="否"
  213. ></el-switch>
  214. </el-form-item>
  215. </el-row>
  216. </el-tab-pane>
  217. <!-- 周期设置 -->
  218. <el-tab-pane label="周期设置" name="tab8">
  219. <el-row>
  220. <el-form-item
  221. label="是否开启周期设置"
  222. :label-width="style.label_width_tab4"
  223. >
  224. <el-radio-group
  225. v-model="form.properties.EXAM_CYCLE_ENABLED"
  226. class="input"
  227. @change="examCycleEnabledChange"
  228. >
  229. <el-radio label="true">开启</el-radio>
  230. <el-radio label="false">不开启</el-radio>
  231. </el-radio-group></el-form-item
  232. >
  233. </el-row>
  234. <el-row v-if="form.properties.EXAM_CYCLE_ENABLED == 'true'">
  235. <el-form-item
  236. label="日期循环设置"
  237. prop="examCycleWeekArr"
  238. :label-width="style.label_width_tab4"
  239. >
  240. <el-checkbox-group
  241. v-model="examCycleWeekArr"
  242. style="width: 680px; display: -webkit-inline-box"
  243. >
  244. <el-checkbox :label="1">星期一</el-checkbox>
  245. <el-checkbox :label="2">星期二</el-checkbox>
  246. <el-checkbox :label="3">星期三</el-checkbox>
  247. <el-checkbox :label="4">星期四</el-checkbox>
  248. <el-checkbox :label="5">星期五</el-checkbox>
  249. <el-checkbox :label="6">星期六</el-checkbox>
  250. <el-checkbox :label="7">星期日</el-checkbox>
  251. </el-checkbox-group></el-form-item
  252. >
  253. </el-row>
  254. <template v-if="form.properties.EXAM_CYCLE_ENABLED == 'true'">
  255. <el-row>
  256. <el-col :span="14">
  257. <el-form-item
  258. label="时间分段设置"
  259. :label-width="style.label_width_tab4"
  260. prop="examCycleTimeRangeArr"
  261. >
  262. </el-form-item>
  263. </el-col>
  264. <el-col :span="10" style="line-height: 48px; height: 40px">
  265. <i
  266. class="el-icon-circle-plus"
  267. style="color: #00a4ff; font-size: 24px"
  268. @click="addCycleTimeRange"
  269. ></i>
  270. </el-col>
  271. </el-row>
  272. <el-row
  273. v-for="(item, index) in examCycleTimeRangeArr"
  274. :key="'tr' + index"
  275. >
  276. <el-col :span="14">
  277. <el-form-item
  278. :label-width="style.label_width_tab4"
  279. :label="index + 1 + '.'"
  280. >
  281. <el-time-picker
  282. v-model="item.timeRange"
  283. class="input"
  284. style="width: 100%"
  285. is-range
  286. start-placeholder="开始时间"
  287. range-separator="至"
  288. end-placeholder="结束时间"
  289. format="HH:mm"
  290. value-format="HH:mm"
  291. :clearable="false"
  292. size="small"
  293. ></el-time-picker>
  294. </el-form-item>
  295. </el-col>
  296. <el-col :span="10" style="line-height: 48px; height: 40px">
  297. <i
  298. class="el-icon-remove"
  299. style="color: #00a4ff; font-size: 24px"
  300. @click="removeExamCycleTimeRange(index)"
  301. ></i>
  302. </el-col>
  303. </el-row>
  304. </template>
  305. </el-tab-pane>
  306. <!-- 控制设置 -->
  307. <el-tab-pane label="控制设置" name="tab2">
  308. <el-row>
  309. <el-form-item
  310. label="考试时长"
  311. prop="duration"
  312. :label-width="style.label_width_tab2"
  313. >
  314. <el-input
  315. v-model.trim.number="form.duration"
  316. maxlength="5"
  317. auto-complete="off"
  318. class="input"
  319. >
  320. <template slot="append">分钟</template>
  321. </el-input>
  322. </el-form-item>
  323. </el-row>
  324. <el-row>
  325. <el-form-item
  326. label="考试次数"
  327. prop="examTimes"
  328. :label-width="style.label_width_tab2"
  329. >
  330. <el-input
  331. v-model.trim.number="form.examTimes"
  332. maxlength="5"
  333. auto-complete="off"
  334. class="input"
  335. >
  336. <template slot="append">次</template>
  337. </el-input>
  338. </el-form-item>
  339. </el-row>
  340. <el-row>
  341. <el-form-item
  342. label="交卷冻结时间"
  343. prop="FREEZE_TIME"
  344. :label-width="style.label_width_tab2"
  345. >
  346. <el-input
  347. v-model.trim.number="form.properties.FREEZE_TIME"
  348. maxlength="5"
  349. auto-complete="off"
  350. class="input"
  351. >
  352. <template slot="append">分钟</template>
  353. </el-input>
  354. </el-form-item>
  355. </el-row>
  356. <el-row>
  357. <el-form-item
  358. label="断点续考时间"
  359. prop="EXAM_RECONNECT_TIME"
  360. :label-width="style.label_width_tab2"
  361. >
  362. <el-input
  363. v-model.trim.number="form.properties.EXAM_RECONNECT_TIME"
  364. maxlength="5"
  365. auto-complete="off"
  366. class="input"
  367. >
  368. <template slot="append">分钟</template>
  369. </el-input>
  370. </el-form-item>
  371. </el-row>
  372. <el-row>
  373. <el-form-item
  374. label="断点续考次数"
  375. prop="MAX_INTERRUPT_NUM"
  376. :label-width="style.label_width_tab2"
  377. >
  378. <el-input
  379. v-model.trim.number="form.properties.MAX_INTERRUPT_NUM"
  380. maxlength="5"
  381. auto-complete="off"
  382. class="input"
  383. >
  384. <template slot="append">次</template>
  385. </el-input>
  386. </el-form-item>
  387. </el-row>
  388. <el-row>
  389. <el-form-item
  390. label="切屏次数限制"
  391. prop="MAX_SWITCH_SCREEN_COUNT"
  392. :label-width="style.label_width_tab2"
  393. >
  394. <el-tooltip
  395. :disabled="!maxSwitchScreenCountDisabled"
  396. placement="top"
  397. >
  398. <div slot="content">
  399. 此设置不可用。考生端配置-防作弊设置中计算切屏次数未开启
  400. </div>
  401. <el-input
  402. v-model.trim.number="
  403. form.properties.MAX_SWITCH_SCREEN_COUNT
  404. "
  405. maxlength="5"
  406. auto-complete="off"
  407. class="input"
  408. :disabled="maxSwitchScreenCountDisabled"
  409. >
  410. <template slot="append">次</template>
  411. </el-input>
  412. </el-tooltip>
  413. </el-form-item>
  414. </el-row>
  415. </el-tab-pane>
  416. <el-tab-pane label="显示设置" name="tab3">
  417. <el-row>
  418. <el-form-item
  419. label="考生承诺书"
  420. :label-width="style.label_width_tab3"
  421. >
  422. <el-radio-group
  423. v-model="form.properties.SHOW_UNDERTAKING"
  424. class="input"
  425. >
  426. <el-radio label="true">开启</el-radio>
  427. <el-radio label="false">关闭</el-radio>
  428. </el-radio-group>
  429. </el-form-item>
  430. </el-row>
  431. <el-row v-if="show_ckeditor">
  432. <el-form-item
  433. label="承诺书说明"
  434. :label-width="style.label_width_tab3"
  435. >
  436. <ckeditor
  437. v-model="form.properties.UNDERTAKING"
  438. extrabuttons="Font,FontSize,TextColor"
  439. ></ckeditor>
  440. </el-form-item>
  441. </el-row>
  442. <el-row v-if="show_ckeditor">
  443. <el-form-item
  444. label="考前说明"
  445. :label-width="style.label_width_tab3"
  446. >
  447. <ckeditor
  448. v-model="form.properties.BEFORE_EXAM_REMARK"
  449. extrabuttons="Font,FontSize,TextColor"
  450. ></ckeditor>
  451. </el-form-item>
  452. </el-row>
  453. <el-row v-if="show_ckeditor">
  454. <el-form-item
  455. label="考后说明"
  456. :label-width="style.label_width_tab3"
  457. >
  458. <ckeditor
  459. v-model="form.properties.AFTER_EXAM_REMARK"
  460. extrabuttons="Font,FontSize,TextColor"
  461. ></ckeditor>
  462. </el-form-item>
  463. </el-row>
  464. <el-row>
  465. <el-form-item
  466. label="展示作弊说明"
  467. :label-width="style.label_width_tab3"
  468. >
  469. <el-radio-group
  470. v-model="form.properties.SHOW_CHEATING_REMARK"
  471. class="input"
  472. >
  473. <el-radio label="true">开启</el-radio>
  474. <el-radio label="false">关闭</el-radio>
  475. </el-radio-group>
  476. </el-form-item>
  477. </el-row>
  478. <el-row v-if="show_ckeditor">
  479. <el-form-item
  480. label="作弊说明"
  481. :label-width="style.label_width_tab3"
  482. >
  483. <ckeditor
  484. v-model="form.properties.CHEATING_REMARK"
  485. extrabuttons="Font,FontSize,TextColor"
  486. ></ckeditor>
  487. </el-form-item>
  488. </el-row>
  489. <el-row>
  490. <el-form-item
  491. label="单选题补充说明"
  492. :label-width="style.label_width_tab3"
  493. >
  494. <el-input
  495. v-model="form.properties.SINGLE_ANSWER_REMARK"
  496. maxlength="20"
  497. :disabled="!form.properties.SINGLE_EDIT"
  498. auto-complete="off"
  499. class="input"
  500. ></el-input>
  501. </el-form-item>
  502. <el-form-item label>
  503. <el-switch
  504. v-model="form.properties.SINGLE_EDIT"
  505. on-text="启用"
  506. off-text="禁用"
  507. ></el-switch>
  508. </el-form-item>
  509. </el-row>
  510. <el-row>
  511. <el-form-item
  512. label="多选题补充说明"
  513. :label-width="style.label_width_tab3"
  514. >
  515. <el-input
  516. v-model="form.properties.MUTIPLE_ANSWER_REMARK"
  517. maxlength="20"
  518. :disabled="!form.properties.MUTIPLE_EDIT"
  519. auto-complete="off"
  520. class="input"
  521. ></el-input>
  522. </el-form-item>
  523. <el-form-item label>
  524. <el-switch
  525. v-model="form.properties.MUTIPLE_EDIT"
  526. on-text="启用"
  527. off-text="禁用"
  528. ></el-switch>
  529. </el-form-item>
  530. </el-row>
  531. <el-row>
  532. <el-form-item
  533. label="判断题补充说明"
  534. :label-width="style.label_width_tab3"
  535. >
  536. <el-input
  537. v-model="form.properties.BOOL_ANSWER_REMARK"
  538. maxlength="20"
  539. :disabled="!form.properties.BOOL_EDIT"
  540. class="input"
  541. auto-complete="off"
  542. ></el-input>
  543. </el-form-item>
  544. <el-form-item label>
  545. <el-switch
  546. v-model="form.properties.BOOL_EDIT"
  547. on-text="启用"
  548. off-text="禁用"
  549. ></el-switch>
  550. </el-form-item>
  551. </el-row>
  552. <el-row>
  553. <el-form-item
  554. label="填空题补充说明"
  555. :label-width="style.label_width_tab3"
  556. >
  557. <el-input
  558. v-model="form.properties.FILL_BLANK_REMARK"
  559. maxlength="20"
  560. :disabled="!form.properties.FILL_BLANK_EDIT"
  561. class="input"
  562. auto-complete="off"
  563. ></el-input>
  564. </el-form-item>
  565. <el-form-item label>
  566. <el-switch
  567. v-model="form.properties.FILL_BLANK_EDIT"
  568. on-text="启用"
  569. off-text="禁用"
  570. ></el-switch>
  571. </el-form-item>
  572. </el-row>
  573. <el-row>
  574. <el-form-item
  575. label="客观题成绩显示"
  576. :label-width="style.label_width_tab3"
  577. >
  578. <el-radio-group
  579. v-model="form.properties.IS_OBJ_SCORE_VIEW"
  580. class="input"
  581. >
  582. <el-radio label="true">开启</el-radio>
  583. <el-radio label="false">关闭</el-radio>
  584. </el-radio-group>
  585. </el-form-item>
  586. </el-row>
  587. </el-tab-pane>
  588. <el-tab-pane label="阅卷设置" name="tab5">
  589. <el-row>
  590. <el-form-item
  591. label="阅卷方式"
  592. :label-width="style.label_width_tab5"
  593. >
  594. <el-radio-group
  595. v-model="form.properties.MARKING_TYPE"
  596. :disabled="form.started"
  597. class="input"
  598. >
  599. <el-radio label="ALL">全部评阅</el-radio>
  600. <el-radio label="OBJECT_SCORE_MAX">客观分最高</el-radio>
  601. <el-radio label="LAST_SUBMIT">最后一次提交</el-radio>
  602. </el-radio-group>
  603. </el-form-item>
  604. </el-row>
  605. </el-tab-pane>
  606. <el-tab-pane label="网络设置" name="tab6">
  607. <el-row>
  608. <el-form-item
  609. label="IP限制"
  610. :label-width="style.label_width_tab6"
  611. >
  612. <el-radio-group v-model="form.properties.IP_LIMIT">
  613. <el-radio label="true">开启</el-radio>
  614. <el-radio label="false">关闭</el-radio>
  615. </el-radio-group>
  616. </el-form-item>
  617. </el-row>
  618. <el-row>
  619. <el-form-item
  620. label="IP段( *表示任意 )"
  621. :label-width="style.label_width_tab6"
  622. >
  623. <el-input
  624. v-model="form.properties.IP_ADDRESSES"
  625. maxlength="2000"
  626. class="input"
  627. type="textarea"
  628. rows="6"
  629. ></el-input>
  630. </el-form-item>
  631. </el-row>
  632. </el-tab-pane>
  633. <el-tab-pane label="其它" name="tab7">
  634. <el-row>
  635. <el-form-item
  636. label="是否推送成绩"
  637. :label-width="style.label_width_tab7"
  638. >
  639. <el-radio-group v-model="form.properties.PUSH_SCORE">
  640. <el-radio label="true">是</el-radio>
  641. <el-radio label="false">否</el-radio>
  642. </el-radio-group>
  643. </el-form-item>
  644. </el-row>
  645. </el-tab-pane>
  646. </el-tabs>
  647. </el-form>
  648. </div>
  649. </div>
  650. </section>
  651. </div>
  652. </template>
  653. <script>
  654. import { mapState } from "vuex";
  655. import { EXAM_TYPE, EXAM_WORK_API, CORE_API } from "@/constants/constants.js";
  656. import moment from "moment";
  657. import ckeditor from "@/components/ckeditor.vue";
  658. import LinkTitlesCustom from "@/components/LinkTitlesCustom.vue";
  659. let _this = null;
  660. let validateExamCycleTimeRange = (rule, value, callback) => {
  661. if (_this.examCycleTimeRangeArr.length == 0) {
  662. callback(new Error("请至少设置一个时间段"));
  663. } else {
  664. callback();
  665. }
  666. };
  667. let validateExamCycleWeek = (rule, value, callback) => {
  668. if (_this.examCycleWeekArr.length == 0) {
  669. callback(new Error("请至少勾选一个日期"));
  670. } else {
  671. callback();
  672. }
  673. };
  674. let validateCode = (rule, value, callback) => {
  675. if (_this.examId == "add") {
  676. _this.form.code = _this.form.name;
  677. }
  678. let code = _this.form.code;
  679. if (code == "") {
  680. callback(new Error("请输入考试编码"));
  681. if (!_this.toActiveName) {
  682. _this.toActiveName = "tab1";
  683. _this.activeName = "tab1";
  684. }
  685. } else {
  686. callback();
  687. }
  688. };
  689. let validateName = (rule, value, callback) => {
  690. let name = _this.form.name;
  691. if (name == "") {
  692. callback(new Error("请输入考试名称"));
  693. if (!_this.toActiveName) {
  694. _this.toActiveName = "tab1";
  695. _this.activeName = "tab1";
  696. }
  697. } else {
  698. callback();
  699. }
  700. };
  701. let validateExamDatetimeRange = (rule, value, callback) => {
  702. let examDatetimeRange = _this.examDatetimeRange;
  703. if (!examDatetimeRange) {
  704. callback(new Error("请输入考试时间"));
  705. if (!_this.toActiveName) {
  706. _this.toActiveName = "tab1";
  707. _this.activeName = "tab1";
  708. }
  709. } else {
  710. callback();
  711. }
  712. };
  713. let validateDuration = (rule, value, callback) => {
  714. let duration = _this.form.duration;
  715. if (duration === "") {
  716. callback(new Error("请输入考试时长"));
  717. if (!_this.toActiveName) {
  718. _this.toActiveName = "tab2";
  719. _this.activeName = "tab2";
  720. }
  721. } else if (!duration.toString().match(/^[1-9]\d*|0$/)) {
  722. callback(new Error("只能是非负整数"));
  723. if (!_this.toActiveName) {
  724. _this.toActiveName = "tab2";
  725. _this.activeName = "tab2";
  726. }
  727. } else {
  728. callback();
  729. }
  730. };
  731. let validateExamTimes = (rule, value, callback) => {
  732. let examTimes = _this.form.examTimes;
  733. if (examTimes === "") {
  734. callback(new Error("请输入考试次数"));
  735. if (!_this.toActiveName) {
  736. _this.toActiveName = "tab2";
  737. _this.activeName = "tab2";
  738. }
  739. } else if (!examTimes.toString().match(/^[1-9]\d*$/)) {
  740. callback(new Error("只能是正整数"));
  741. if (!_this.toActiveName) {
  742. _this.toActiveName = "tab2";
  743. _this.activeName = "tab2";
  744. }
  745. } else {
  746. callback();
  747. }
  748. };
  749. let validateFreezeTime = (rule, value, callback) => {
  750. let freezeTime = _this.form.properties.FREEZE_TIME;
  751. let duration = _this.form.duration;
  752. if (freezeTime === "") {
  753. callback(new Error("请输入交卷冻结时长"));
  754. if (!_this.toActiveName) {
  755. _this.toActiveName = "tab2";
  756. _this.activeName = "tab2";
  757. }
  758. } else if (!freezeTime.toString().match(/^[1-9]\d*|0$/)) {
  759. callback(new Error("只能是非负整数"));
  760. if (!_this.toActiveName) {
  761. _this.toActiveName = "tab2";
  762. _this.activeName = "tab2";
  763. }
  764. } else if (duration != "" && parseInt(freezeTime) > parseInt(duration)) {
  765. callback(new Error("交卷冻结时长不能大于考试时长"));
  766. if (!_this.toActiveName) {
  767. _this.toActiveName = "tab2";
  768. _this.activeName = "tab2";
  769. }
  770. } else {
  771. callback();
  772. }
  773. };
  774. let validateExamReconnectTime = (rule, value, callback) => {
  775. let examReconnectTime = _this.form.properties.EXAM_RECONNECT_TIME;
  776. if (examReconnectTime === "") {
  777. callback(new Error("请输入断点续考时间"));
  778. if (!_this.toActiveName) {
  779. _this.toActiveName = "tab2";
  780. _this.activeName = "tab2";
  781. }
  782. } else if (!examReconnectTime.toString().match(/^[1-9]\d*$/)) {
  783. callback(new Error("只能是正整数"));
  784. if (!_this.toActiveName) {
  785. _this.toActiveName = "tab2";
  786. _this.activeName = "tab2";
  787. }
  788. } else if (examReconnectTime < 3) {
  789. callback(new Error("最小设置值为3"));
  790. if (!_this.toActiveName) {
  791. _this.toActiveName = "tab2";
  792. _this.activeName = "tab2";
  793. }
  794. } else {
  795. callback();
  796. }
  797. };
  798. let validateMaxInterruptNum = (rule, value, callback) => {
  799. let examReconnectTime = _this.form.properties.MAX_INTERRUPT_NUM;
  800. if (examReconnectTime === "") {
  801. callback();
  802. } else if (!examReconnectTime.toString().match(/^[0-9]\d*$/)) {
  803. callback(new Error("只能是非负整数"));
  804. if (!_this.toActiveName) {
  805. _this.toActiveName = "tab2";
  806. _this.activeName = "tab2";
  807. }
  808. } else {
  809. callback();
  810. }
  811. };
  812. let validateMaxSwitchScreenCount = (rule, value, callback) => {
  813. let examReconnectTime = _this.form.properties.MAX_SWITCH_SCREEN_COUNT;
  814. if (examReconnectTime === "") {
  815. callback();
  816. } else if (!examReconnectTime.toString().match(/^[0-9]\d*$/)) {
  817. callback(new Error("只能是非负整数"));
  818. if (!_this.toActiveName) {
  819. _this.toActiveName = "tab2";
  820. _this.activeName = "tab2";
  821. }
  822. } else {
  823. callback();
  824. }
  825. };
  826. export default {
  827. components: {
  828. ckeditor,
  829. LinkTitlesCustom,
  830. },
  831. data() {
  832. return {
  833. style: {
  834. label_width_tab1: "160px",
  835. label_width_tab2: "110px",
  836. label_width_tab3: "120px",
  837. label_width_tab4: "170px",
  838. label_width_tab5: "80px",
  839. label_width_tab6: "120px",
  840. label_width_tab7: "150px",
  841. },
  842. examCycleTimeRangeArr: [],
  843. examCycleWeekArr: [1, 2, 3, 4, 5, 6, 7],
  844. activeName: "tab1",
  845. toActiveName: null,
  846. examDatetimeRange: [],
  847. show_ckeditor: false,
  848. is_face_verify_diabled: true,
  849. is_face_enable_diabled: true,
  850. rootOrgWenXinAnswerEnabled: false,
  851. IDENTIFICATION_OF_LIVING_BODY_SCHEME: "S1",
  852. maxSwitchScreenCountDisabled: true,
  853. form: {
  854. started: false,
  855. name: "",
  856. code: "",
  857. examType: "ONLINE_HOMEWORK",
  858. examTimes: 1,
  859. beginTime: null,
  860. endTime: null,
  861. duration: 120,
  862. enable: "true",
  863. examLimit: "false",
  864. specialSettingsEnabled: false,
  865. specialSettingsType: "ORG_BASED",
  866. properties: {
  867. IS_OBJ_SCORE_VIEW: "true",
  868. IS_STRANGER_ENABLE: "false",
  869. MAX_INTERRUPT_NUM: "",
  870. MAX_SWITCH_SCREEN_COUNT: "",
  871. EXAM_RECONNECT_TIME: 30,
  872. FREEZE_TIME: 0,
  873. BEFORE_EXAM_REMARK: "",
  874. AFTER_EXAM_REMARK: "",
  875. SHOW_CHEATING_REMARK: "true",
  876. CHEATING_REMARK: "",
  877. SINGLE_EDIT: "false",
  878. MUTIPLE_EDIT: "false",
  879. BOOL_EDIT: "false",
  880. FILL_BLANK_EDIT: "false",
  881. SINGLE_ANSWER_REMARK: "",
  882. MUTIPLE_ANSWER_REMARK: "",
  883. FILL_BLANK_REMARK: "",
  884. BOOL_ANSWER_REMARK: "",
  885. IS_FACE_ENABLE: "false",
  886. IS_FACE_CHECK: "false",
  887. SNAPSHOT_INTERVAL: 30,
  888. WARN_THRESHOLD: 50,
  889. MARKING_TYPE: "ALL",
  890. IP_LIMIT: "false",
  891. IP_ADDRESSES: null,
  892. LIVING_WARN_THRESHOLD: 50,
  893. IS_FACE_VERIFY: "false",
  894. FACE_VERIFY_START_MINUTE: 5,
  895. FACE_VERIFY_END_MINUTE: 10,
  896. PUSH_SCORE: "false",
  897. CHECK_ENVIRONMENT: "false",
  898. WEIXIN_ANSWER_ENABLED: "false",
  899. ADD_FACE_VERIFY_OUT_FREEZE_TIME: "false",
  900. OUT_FREEZE_TIME_FACE_VERIFY_START_MINUTE: 10,
  901. OUT_FREEZE_TIME_FACE_VERIFY_END_MINUTE: 30,
  902. LIMITED_IF_NO_SPECIAL_SETTINGS: "false",
  903. EXAM_CYCLE_ENABLED: "false",
  904. EXAM_CYCLE_WEEK: "",
  905. EXAM_CYCLE_TIME_RANGE: "",
  906. SHOW_UNDERTAKING: "false",
  907. UNDERTAKING: "",
  908. },
  909. },
  910. examTypeList: EXAM_TYPE,
  911. examId: "",
  912. rootOrgId: null,
  913. rules: {
  914. code: [{ required: true, validator: validateCode, trigger: "blur" }],
  915. name: [{ required: true, validator: validateName, trigger: "blur" }],
  916. examDatetimeRange: [
  917. {
  918. required: true,
  919. validator: validateExamDatetimeRange,
  920. trigger: "blur",
  921. },
  922. ],
  923. duration: [
  924. { required: true, validator: validateDuration, trigger: "blur" },
  925. ],
  926. examTimes: [
  927. { required: true, validator: validateExamTimes, trigger: "blur" },
  928. ],
  929. FREEZE_TIME: [
  930. { required: true, validator: validateFreezeTime, trigger: "blur" },
  931. ],
  932. EXAM_RECONNECT_TIME: [
  933. {
  934. required: true,
  935. validator: validateExamReconnectTime,
  936. trigger: "blur",
  937. },
  938. ],
  939. MAX_INTERRUPT_NUM: [
  940. {
  941. required: false,
  942. validator: validateMaxInterruptNum,
  943. trigger: "blur",
  944. },
  945. ],
  946. MAX_SWITCH_SCREEN_COUNT: [
  947. {
  948. required: false,
  949. validator: validateMaxSwitchScreenCount,
  950. trigger: "blur",
  951. },
  952. ],
  953. examCycleWeekArr: [
  954. {
  955. required: true,
  956. validator: validateExamCycleWeek,
  957. trigger: "change",
  958. },
  959. ],
  960. examCycleTimeRangeArr: [
  961. {
  962. required: true,
  963. validator: validateExamCycleTimeRange,
  964. trigger: "change",
  965. },
  966. ],
  967. },
  968. };
  969. },
  970. computed: {
  971. ...mapState({ user: (state) => state.user }),
  972. },
  973. created() {
  974. _this = this;
  975. this.examId = this.$route.params.id;
  976. this.init();
  977. },
  978. methods: {
  979. examCycleEnabledChange(val) {
  980. if (val == "true") {
  981. this.examCycleWeekArr = [1, 2, 3, 4, 5, 6, 7];
  982. this.addCycleTimeRange();
  983. } else {
  984. this.examCycleTimeRangeArr = [];
  985. this.examCycleWeekArr = [];
  986. }
  987. },
  988. getEndTimeStr() {
  989. return "23:59";
  990. },
  991. getNowTimeStr() {
  992. let now = new Date();
  993. let hour = now.getHours();
  994. if (hour < 10) {
  995. hour = "0" + hour;
  996. }
  997. let minute = now.getMinutes();
  998. if (minute < 10) {
  999. minute = "0" + minute;
  1000. }
  1001. return hour + ":" + minute;
  1002. },
  1003. removeExamCycleTimeRange(index) {
  1004. if (this.examCycleTimeRangeArr.length == 1) {
  1005. this.$notify({
  1006. type: "warning",
  1007. message: "不能删除最后一个分段",
  1008. });
  1009. return;
  1010. }
  1011. this.examCycleTimeRangeArr.splice(index, 1);
  1012. this.$refs.form.validateField("examCycleTimeRangeArr");
  1013. },
  1014. addCycleTimeRange() {
  1015. if (this.examCycleTimeRangeArr.length >= 12) {
  1016. this.$notify({
  1017. type: "warning",
  1018. message: "时间分段不得超过12条",
  1019. });
  1020. return;
  1021. }
  1022. this.examCycleTimeRangeArr.push({
  1023. timeRange: [this.getNowTimeStr(), this.getEndTimeStr()],
  1024. });
  1025. this.$refs.form.validateField("examCycleTimeRangeArr");
  1026. },
  1027. faceEnableChange() {
  1028. if (this.form.properties.IS_FACE_ENABLE == "false") {
  1029. this.form.properties.IS_STRANGER_ENABLE = "false";
  1030. this.form.properties.IS_FACE_CHECK = "false";
  1031. this.form.properties.IS_FACE_VERIFY = "false";
  1032. this.form.properties.ADD_FACE_VERIFY_OUT_FREEZE_TIME = "false";
  1033. }
  1034. },
  1035. init() {
  1036. if (this.examId != "add") {
  1037. let url = EXAM_WORK_API + "/exam/" + this.examId;
  1038. this.$httpWithMsg.get(url).then((response) => {
  1039. let body = response.data;
  1040. this.rootOrgId = body.rootOrgId;
  1041. body.properties = this.form.properties;
  1042. this.form = Object.assign(this.form, response.data);
  1043. this.form.enable = this.form.enable ? "true" : "false";
  1044. this.form.examLimit = this.form.examLimit ? "true" : "false";
  1045. this.examDatetimeRange = [this.form.beginTime, this.form.endTime];
  1046. console.log("getOnlineHomework(); form: ", this.form);
  1047. let url = EXAM_WORK_API + "/exam/allProperties/" + this.examId;
  1048. this.$httpWithMsg.get(url).then((response) => {
  1049. this.form.properties = Object.assign(
  1050. this.form.properties,
  1051. response.data
  1052. );
  1053. this.form.properties.SINGLE_EDIT =
  1054. this.form.properties.SINGLE_EDIT === "true";
  1055. this.form.properties.MUTIPLE_EDIT =
  1056. this.form.properties.MUTIPLE_EDIT === "true";
  1057. this.form.properties.BOOL_EDIT =
  1058. this.form.properties.BOOL_EDIT === "true";
  1059. this.form.properties.FILL_BLANK_EDIT =
  1060. this.form.properties.FILL_BLANK_EDIT === "true";
  1061. this.form.properties.CHECK_ENVIRONMENT =
  1062. this.form.properties.CHECK_ENVIRONMENT === "true";
  1063. this.form.properties.WEIXIN_ANSWER_ENABLED =
  1064. this.form.properties.WEIXIN_ANSWER_ENABLED === "true";
  1065. this.form.properties.LIMITED_IF_NO_SPECIAL_SETTINGS =
  1066. this.form.properties.LIMITED_IF_NO_SPECIAL_SETTINGS === "true";
  1067. if (this.form.properties.EXAM_CYCLE_TIME_RANGE) {
  1068. this.examCycleTimeRangeArr = JSON.parse(
  1069. this.form.properties.EXAM_CYCLE_TIME_RANGE
  1070. );
  1071. }
  1072. if (this.form.properties.EXAM_CYCLE_WEEK) {
  1073. this.examCycleWeekArr = JSON.parse(
  1074. this.form.properties.EXAM_CYCLE_WEEK
  1075. );
  1076. }
  1077. this.show_ckeditor = true;
  1078. this.checkRootOrgPrivileges();
  1079. });
  1080. });
  1081. } else {
  1082. let now = moment().format("YYYY-MM-DD HH:mm:ss");
  1083. this.examDatetimeRange = [now, now];
  1084. this.show_ckeditor = true;
  1085. this.checkRootOrgPrivileges();
  1086. }
  1087. },
  1088. checkRootOrgPrivileges: function () {
  1089. let url =
  1090. CORE_API +
  1091. "/rolePrivilege/checkRootOrgPrivileges?privilegeCodes=FACE_CHECK,IDENTIFICATION_OF_LIVING_BODY";
  1092. this.$httpWithMsg.post(url).then((response) => {
  1093. let res = response.data;
  1094. if (!res.FACE_CHECK) {
  1095. this.form.properties.IS_FACE_ENABLE = "false";
  1096. this.form.properties.IS_STRANGER_ENABLE = "false";
  1097. this.form.properties.IS_FACE_CHECK = "false";
  1098. this.form.properties.IS_FACE_VERIFY = "false";
  1099. this.form.properties.ADD_FACE_VERIFY_OUT_FREEZE_TIME = "false";
  1100. this.is_face_enable_diabled = true;
  1101. } else {
  1102. this.is_face_enable_diabled = false;
  1103. }
  1104. if (!res.IDENTIFICATION_OF_LIVING_BODY) {
  1105. this.is_face_verify_diabled = true;
  1106. this.form.properties.IS_FACE_VERIFY = "false";
  1107. this.form.properties.ADD_FACE_VERIFY_OUT_FREEZE_TIME = "false";
  1108. } else {
  1109. this.is_face_verify_diabled = false;
  1110. }
  1111. });
  1112. let url2 =
  1113. CORE_API +
  1114. "/org/property/" +
  1115. this.user.rootOrgId +
  1116. "/WEIXIN_ANSWER_ENABLED";
  1117. this.$httpWithMsg.get(url2).then((response) => {
  1118. let res = response.data;
  1119. this.rootOrgWenXinAnswerEnabled = res == true;
  1120. if (!this.rootOrgWenXinAnswerEnabled) {
  1121. this.form.properties.WEIXIN_ANSWER_ENABLED = false;
  1122. }
  1123. });
  1124. let that = this;
  1125. this.getOrgProperty(
  1126. "IDENTIFICATION_OF_LIVING_BODY_SCHEME",
  1127. function (res) {
  1128. that.form.IDENTIFICATION_OF_LIVING_BODY_SCHEME = res;
  1129. }
  1130. );
  1131. this.getOrgProperty("PREVENT_CHEATING_CONFIG", function (res) {
  1132. if (res && res.indexOf("RECORD_SWITCH_SCREEN") != -1) {
  1133. that.maxSwitchScreenCountDisabled = false;
  1134. }
  1135. });
  1136. },
  1137. getOrgProperty: function (propkey, callback) {
  1138. let url =
  1139. CORE_API + "/org/property/" + this.user.rootOrgId + "/" + propkey;
  1140. this.$httpWithMsg.get(url).then((response) => {
  1141. let res = response.data;
  1142. callback(res);
  1143. });
  1144. },
  1145. compare: function (x, y) {
  1146. if (x < y) {
  1147. return -1;
  1148. } else if (x > y) {
  1149. return 1;
  1150. } else {
  1151. return 0;
  1152. }
  1153. },
  1154. saveExam: function () {
  1155. this.toActiveName = null;
  1156. this.form.beginTime = this.examDatetimeRange[0];
  1157. this.form.endTime = this.examDatetimeRange[1];
  1158. this.form.properties.EXAM_CYCLE_TIME_RANGE = JSON.stringify(
  1159. this.examCycleTimeRangeArr
  1160. );
  1161. this.examCycleWeekArr.sort(this.compare);
  1162. this.form.properties.EXAM_CYCLE_WEEK = JSON.stringify(
  1163. this.examCycleWeekArr
  1164. );
  1165. if (!this.checkCkeditorVals()) {
  1166. return false;
  1167. }
  1168. let url = EXAM_WORK_API + "/exam";
  1169. this.$refs.form.validate((valid) => {
  1170. if (valid) {
  1171. if (this.examId != "add") {
  1172. this.$httpWithMsg.put(url, this.form).then((response) => {
  1173. if (200 != response.status) {
  1174. this.$notify({
  1175. type: "error",
  1176. message: response.body.desc,
  1177. });
  1178. return;
  1179. }
  1180. this.$notify({
  1181. type: "success",
  1182. message: "保存成功",
  1183. });
  1184. });
  1185. } else {
  1186. this.form.code = this.form.name;
  1187. this.$httpWithMsg.post(url, this.form).then((response) => {
  1188. console.log(response);
  1189. this.$notify({
  1190. type: "success",
  1191. message: "新增成功",
  1192. });
  1193. this.examId = response.data.id;
  1194. this.form.id = this.examId;
  1195. this.$router.push({
  1196. path: "/examwork/onlineHomework/" + response.data.id,
  1197. });
  1198. });
  1199. }
  1200. } else {
  1201. return false;
  1202. }
  1203. });
  1204. },
  1205. checkCkeditorVals() {
  1206. if (
  1207. this.form.properties.SHOW_UNDERTAKING == "true" &&
  1208. !this.form.properties.UNDERTAKING
  1209. ) {
  1210. this.$notify({
  1211. type: "warning",
  1212. message: "请输入承诺书说明",
  1213. });
  1214. this.activeName = "tab3";
  1215. return false;
  1216. }
  1217. return true;
  1218. },
  1219. back() {
  1220. this.$router.push({ path: "/examwork/examInfo" });
  1221. },
  1222. },
  1223. };
  1224. </script>
  1225. <style scoped>
  1226. .input {
  1227. width: 440px;
  1228. }
  1229. .input >>> .el-input__inner {
  1230. -webkit-appearance: button;
  1231. }
  1232. </style>