MarkAction.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560
  1. <template>
  2. <div class="mark-action grade-action">
  3. <!-- 头部信息 ------ -->
  4. <!-- 试卷状态 -->
  5. <!-- 状态:已评,待评,改档,改档打分 -->
  6. <div class="action-paper-state">
  7. <p class="paper-state-cont">{{ stepLabel }}</p>
  8. </div>
  9. <!-- 试卷信息 -->
  10. <div class="action-paper-info">
  11. <!-- <p v-if="IS_ADMIN">
  12. <span>试卷考号:</span><span>{{ curPaperOrTask.examNumber }}</span>
  13. </p> -->
  14. <p>
  15. <span v-if="IS_MARKER">任务密号:</span>
  16. <span v-else>试卷密号:</span>
  17. <span>NO.{{ curPaperOrTask.sn }}</span>
  18. </p>
  19. </div>
  20. <!-- 改档信息 -->
  21. <div class="action-grade-change" v-if="rights.gradeChange">
  22. <p>
  23. <span>原始档位:</span><span>{{ curPaperOrTask.originLevel }}</span>
  24. </p>
  25. <p>
  26. <span v-if="IS_MARKER">建议档位:</span>
  27. <span v-else>申请档位:</span>
  28. <span>{{ curPaperOrTask.redoLevel }}</span>
  29. </p>
  30. </div>
  31. <div
  32. :class="[
  33. 'action-grade-change-status',
  34. { 'action-grade-change-status-error': curPaperOrTask.auditStatus === 0 }
  35. ]"
  36. v-if="rights.gradeChange && IS_ADMIN"
  37. >
  38. <p>{{ curPaperOrTask.auditStatus === 1 ? "同意改档" : "不同意改档" }}</p>
  39. </div>
  40. <!-- 档位信息 -->
  41. <!-- 已评/待评(已评档位),改档打分(已评档位) -->
  42. <div class="action-grade-info" v-if="rights.gradeInfo">
  43. <h3 class="grade-info-name">
  44. {{ curPaperLevel }}
  45. </h3>
  46. <!-- <div class="grade-info-range">
  47. <p>分数范围</p>
  48. <p>
  49. <span>{{ curLevel.minScore }}</span>
  50. <span>~</span>
  51. <span>{{ curLevel.maxScore }}</span>
  52. </p>
  53. </div> -->
  54. </div>
  55. <!-- 打分信息 -->
  56. <div class="action-grade-info action-mark-info" v-if="rights.markInfo">
  57. <p class="grade-info-name" v-if="curPaperScore">
  58. {{ curPaperScore }}
  59. </p>
  60. <p class="grade-info-name grade-info-none" v-else>未打分</p>
  61. </div>
  62. <!-- 选择档位 -->
  63. <div class="action-grade-list" v-if="rights.gradeList">
  64. <div
  65. class="action-grade-item"
  66. v-for="(level, index) in levels"
  67. :key="index"
  68. >
  69. <div
  70. :class="[
  71. 'action-grade-item-content',
  72. {
  73. 'action-item-content-disabled': btnClicked,
  74. 'is-active': keyInput == level.name
  75. }
  76. ]"
  77. @click="selectLevel(level)"
  78. >
  79. <p>{{ level.name }}</p>
  80. <p>{{ level.minScore }}~{{ level.maxScore }}</p>
  81. </div>
  82. </div>
  83. </div>
  84. <!-- 选择分数 -->
  85. <div class="action-mark-list" v-if="rights.levelList">
  86. <div
  87. class="action-mark-item"
  88. v-for="(score, index) in scores"
  89. :key="index"
  90. >
  91. <div
  92. :class="[
  93. 'action-mark-item-content',
  94. {
  95. 'action-item-content-disabled': btnClicked,
  96. 'is-active': keyInput == score
  97. }
  98. ]"
  99. @click="selectScore(score)"
  100. >
  101. <p>{{ score }}</p>
  102. </div>
  103. </div>
  104. </div>
  105. <div class="action-grade-pass" v-if="rights.levelPass" @click="toPass">
  106. 跳过
  107. </div>
  108. <!-- mark confirm grade change -->
  109. <div
  110. class="action-grade-change-confirm"
  111. v-if="IS_MARKER && stepType === 'shift'"
  112. >
  113. <Button type="primary" @click="gradeChangeConfirm">确认改档</Button>
  114. </div>
  115. <!-- 评卷记录 -->
  116. <div class="action-grade-history" v-if="rights.markHis">
  117. <h3>评卷记录</h3>
  118. <div class="grade-history-list">
  119. <div
  120. class="grade-history-item"
  121. v-for="(his, hindex) in gradingHistory"
  122. :key="hindex"
  123. >
  124. <p>{{ his.loginName }}</p>
  125. <p>{{ his.value }}</p>
  126. </div>
  127. </div>
  128. </div>
  129. <!-- 查询 -->
  130. <div class="action-search" v-if="rights.search">
  131. <Select
  132. class="search-select"
  133. v-model="filter.codeType"
  134. placeholder="密号类型"
  135. >
  136. <Option
  137. v-for="item in codeTypes"
  138. :key="item.key"
  139. :value="item.key"
  140. :label="item.val"
  141. ></Option>
  142. </Select>
  143. <Input
  144. class="search-input"
  145. v-model.trim="filter.code"
  146. placeholder="输入密号"
  147. clearable
  148. >
  149. </Input>
  150. <Button size="small" type="primary" class="search-btn" @click="searchCode"
  151. >查询</Button
  152. >
  153. </div>
  154. <!-- 改档处理状态查询 -->
  155. <div class="action-search" v-if="rights.gradeChangeSearch">
  156. <Select
  157. class="search-input"
  158. v-model="applyChangeLevelStatus"
  159. placeholder="类型"
  160. >
  161. <Option
  162. v-for="(val, key) in CHANGE_LEVEL_STATUS"
  163. :key="key"
  164. :value="key * 1"
  165. :label="val"
  166. ></Option>
  167. </Select>
  168. <Button
  169. size="small"
  170. type="primary"
  171. class="search-btn"
  172. @click="searchGradeChange"
  173. >查询</Button
  174. >
  175. </div>
  176. </div>
  177. </template>
  178. <script>
  179. import { markHistoryList } from "@/api";
  180. import { CODE_TYPE, CHANGE_LEVEL_STATUS } from "@/constants/enumerate";
  181. import { mapState } from "vuex";
  182. // 三种情况:
  183. // 管理员(ADMIN),科组长(MARK_LEADER),评卷员(MARKER)
  184. // 管理员:查询,头部信息,评卷记录
  185. // 科组长:查询,头部信息,选择档位,评卷记录
  186. // 评卷员:头部信息,选择分数
  187. /*
  188. [paper template]
  189. {
  190. "id": 42,
  191. "sn": "5314987744",
  192. "redoLevel": null,
  193. "level": "B",
  194. "score": null,
  195. "result": "88",
  196. "originLevel": null,
  197. "markerId": 52,
  198. "marker": "zj-pj-01",
  199. "updatedOn": 1595812145000,
  200. "imgSrc": "http://192.168.10.145:9000/images/34/SC/1/1901130046.jpg?random=f5549bb0-ba58-4cd3-a88e-0559be4e06e5",
  201. "thumbSrc": "http://192.168.10.145:9000/thumbs/34/SC/1/1901130046.jpg?random=e7f880b8-4cb6-4963-8e66-532f0f8bdeb0",
  202. "markByLeader": false,
  203. "oldRejected": false,
  204. "paperId": 116,
  205. "randomSeqNew": 4987744,
  206. "randomSeq": null,
  207. "serialNumber": "B1",
  208. "displayNumber": true,
  209. "shift": false,
  210. "shiftScore": false,
  211. "rejected": false,
  212. "sample": false
  213. }
  214. [marktask template]
  215. {
  216. "id": 38,
  217. "sn": "5314266469",
  218. "redoLevel": null,
  219. "level": "A",
  220. "score": null,
  221. "result": "96",
  222. "originLevel": null,
  223. "markerId": 52,
  224. "marker": "zj-pj-01",
  225. "updatedOn": 1595812012000,
  226. "imgSrc": "http://192.168.10.145:9000/images/34/SC/1/1901130043.jpg?random=bffc061c-7a80-42a4-ad56-36ec6eba0d45",
  227. "thumbSrc": "http://192.168.10.145:9000/thumbs/34/SC/1/1901130043.jpg?random=da743f9d-8d46-4499-bb6f-b9c26e003ba2",
  228. "markByLeader": true,
  229. "oldRejected": false,
  230. "paperId": 113,
  231. "randomSeqNew": 4266469,
  232. "randomSeq": null,
  233. "serialNumber": "A1",
  234. "displayNumber": true,
  235. "shift": false,
  236. "shiftScore": false,
  237. "rejected": false,
  238. "sample": true
  239. }
  240. */
  241. const initRights = {
  242. search: false,
  243. gradeChangeSearch: false,
  244. gradeChange: false,
  245. gradeInfo: false,
  246. markInfo: false,
  247. gradeList: false,
  248. levelList: false,
  249. levelPass: false,
  250. markHis: false
  251. };
  252. export default {
  253. name: "mark-action",
  254. props: {
  255. curPaperOrTask: {
  256. type: Object,
  257. default() {
  258. return {};
  259. }
  260. },
  261. levels: {
  262. type: Array,
  263. default() {
  264. return [];
  265. }
  266. }
  267. },
  268. data() {
  269. return {
  270. curUserRoleType: this.$ls.get("user", { role: "" }).role,
  271. rights: {
  272. ...initRights
  273. },
  274. roleRight: {
  275. ADMIN: {
  276. done: ["search", "markHis", "gradeInfo", "markInfo"],
  277. shift: ["search", "gradeChangeSearch", "gradeChange"]
  278. },
  279. MARK_LEADER: {
  280. undo: ["gradeList", "gradeInfo", "markInfo"],
  281. done: ["gradeList", "markHis", "gradeInfo", "markInfo"],
  282. shift: ["gradeList", "gradeChange"]
  283. },
  284. MARKER: {
  285. done: ["levelList", "gradeInfo", "markInfo"],
  286. undo: ["levelList", "levelPass", "gradeInfo"],
  287. shift: ["gradeChange"],
  288. shiftScore: ["levelList", "levelPass", "gradeInfo"]
  289. }
  290. },
  291. filter: {
  292. codeType: "examNumber",
  293. code: ""
  294. },
  295. codeTypes: [],
  296. CHANGE_LEVEL_STATUS,
  297. applyChangeLevelStatus: null,
  298. stepDict: {
  299. undo: "待评",
  300. done: "已评",
  301. shift: "改档",
  302. shiftScore: "改档打分"
  303. },
  304. stepType: "",
  305. stepLabel: "",
  306. curPaperLevel: "",
  307. curPaperScore: "",
  308. scores: [],
  309. gradingHistory: [],
  310. curLevel: {},
  311. setT: null,
  312. btnClicked: false,
  313. keyInput: null
  314. };
  315. },
  316. computed: {
  317. ...mapState("marker", ["ribbonSet"]),
  318. IS_ADMIN() {
  319. return this.curUserRoleType === "ADMIN";
  320. },
  321. IS_MARKER() {
  322. return this.curUserRoleType === "MARKER";
  323. },
  324. IS_MARK_LEADER() {
  325. return this.curUserRoleType === "MARK_LEADER";
  326. }
  327. },
  328. watch: {
  329. curPaperOrTask(val) {
  330. this.rebuildRight();
  331. },
  332. "ribbonSet.keyboardMark": {
  333. immediate: true,
  334. handler(val) {
  335. if (val) {
  336. document.addEventListener("keydown", this.keyEvent);
  337. } else {
  338. this.keyInput = null;
  339. document.removeEventListener("keydown", this.keyEvent);
  340. }
  341. }
  342. }
  343. },
  344. mounted() {
  345. this.codeTypes = Object.entries(CODE_TYPE)
  346. .map(([key, val]) => {
  347. return {
  348. key,
  349. val
  350. };
  351. })
  352. .filter(item => item.key !== "examNumber");
  353. // .filter(item => this.IS_ADMIN || item.key !== "examNumber");
  354. this.rebuildRight();
  355. },
  356. methods: {
  357. getStepType() {
  358. const paper = this.curPaperOrTask;
  359. if (paper.shift && paper.shiftScore && !paper.level && !paper.result)
  360. return "shift";
  361. if (!paper.shift && paper.shiftScore && !paper.result)
  362. return "shiftScore";
  363. if (this.IS_MARKER) {
  364. if (!paper.result) return "undo";
  365. if (paper.result) return "done";
  366. } else {
  367. if (paper.score !== null) return "done";
  368. if (paper.score === null) return "undo";
  369. }
  370. },
  371. rebuildRight() {
  372. const curPaperScore = this.IS_MARKER
  373. ? this.curPaperOrTask.result
  374. : this.curPaperOrTask.score;
  375. this.curPaperScore = curPaperScore !== null ? curPaperScore + "" : "";
  376. this.stepType = this.getStepType();
  377. this.stepLabel = this.stepDict[this.stepType];
  378. this.rights = { ...initRights };
  379. const roleRights =
  380. this.roleRight[this.curUserRoleType][this.stepType] || [];
  381. roleRights.map(key => {
  382. this.rights[key] = true;
  383. });
  384. if (this.curPaperOrTask.level) {
  385. this.curLevel = this.levels.find(
  386. level => level.name === this.curPaperOrTask.level
  387. );
  388. this.curPaperLevel =
  389. this.curPaperOrTask["displayNumber"] && this.stepType !== "shiftScore"
  390. ? this.curPaperOrTask["serialNumber"]
  391. : this.curLevel.name;
  392. this.updateScoreList();
  393. }
  394. if (this.rights.markHis) {
  395. this.getMarkHistory();
  396. }
  397. this.btnClicked = false;
  398. this.keyInput = null;
  399. },
  400. updateScoreList() {
  401. let scores = [];
  402. if (this.curLevel.levelType === "ADMITED") {
  403. const { minScore, maxScore, intervalScore } = this.curLevel;
  404. for (let i = minScore; i <= maxScore; i += intervalScore) {
  405. scores.push(i);
  406. }
  407. } else {
  408. scores = this.curLevel.scoreList.split(",").map(item => item * 1);
  409. }
  410. this.scores = scores;
  411. },
  412. async getMarkHistory() {
  413. const data = await markHistoryList(this.curPaperOrTask.id, "SCORE");
  414. this.gradingHistory = data.map(item => {
  415. return {
  416. id: item.markerId,
  417. name: item.marker,
  418. loginName: item.loginName,
  419. value: item.result || "未评"
  420. };
  421. });
  422. },
  423. selectLevel(level) {
  424. if (this.curPaperOrTask.level === level.name) return;
  425. if (this.btnClicked) return;
  426. this.btnClicked = true;
  427. this.setT = setTimeout(() => {
  428. this.btnClicked = false;
  429. }, 500);
  430. // 科组长改档 / 评卷同意改档:只使用selectedLevel
  431. this.$emit("on-leader-level", {
  432. paperId: this.curPaperOrTask.paperId,
  433. curLevel:
  434. this.stepType === "shift"
  435. ? this.curPaperOrTask.redoLevel
  436. : this.curPaperOrTask.level,
  437. selectedLevel: level.name
  438. });
  439. },
  440. gradeChangeConfirm() {
  441. this.selectLevel({ name: this.curPaperOrTask.redoLevel });
  442. },
  443. selectScore(score) {
  444. if (this.btnClicked) return;
  445. this.btnClicked = true;
  446. this.setT = setTimeout(() => {
  447. this.btnClicked = false;
  448. }, 500);
  449. // 评卷员打分
  450. this.$emit("on-select-score", score * 1);
  451. },
  452. toPass() {
  453. this.$emit("on-pass");
  454. },
  455. searchCode() {
  456. if (!this.filter.code || !this.filter.codeType) {
  457. this.$Message.error("请设置密号类型和密号!");
  458. return;
  459. }
  460. this.$emit("on-code-search", this.filter);
  461. },
  462. searchGradeChange() {
  463. this.$emit("on-grade-change-search", this.applyChangeLevelStatus);
  464. },
  465. // keyboard submit
  466. keyEvent(e) {
  467. if (this.btnClicked) return;
  468. // if (!this.ribbonSet.keyboardMark) return;
  469. if (!e.altKey && !e.shiftKey && !e.ctrlKey) {
  470. if (e.key === "F5") return;
  471. this.$Message.destroy();
  472. // 打分
  473. if (this.rights.levelList) {
  474. if (e.key === "Enter" && this.ribbonSet.needEnterSubmit) {
  475. e.preventDefault();
  476. this.toKeySubmitScore();
  477. return;
  478. }
  479. if (this.checkKeyCodeValid(e.keyCode)) {
  480. e.preventDefault();
  481. this.keyInput += e.key;
  482. this.keyInput = this.keyInput.slice(-3);
  483. if (!this.ribbonSet.needEnterSubmit) {
  484. this.toKeySubmitScore();
  485. }
  486. } else {
  487. this.$Message.error("按键无效");
  488. }
  489. return;
  490. }
  491. // 改档
  492. if (this.rights.gradeList) {
  493. if (e.key === "Enter" && this.ribbonSet.needEnterSubmit) {
  494. e.preventDefault();
  495. this.toKeySubmitLevel();
  496. return;
  497. }
  498. const keyInput = e.key.toUpperCase();
  499. if (this.getKeyInputLevel(keyInput)) {
  500. e.preventDefault();
  501. this.keyInput = keyInput;
  502. if (!this.ribbonSet.needEnterSubmit) {
  503. this.toKeySubmitLevel();
  504. }
  505. } else {
  506. this.$Message.error("按键无效");
  507. }
  508. }
  509. }
  510. },
  511. checkKeyCodeValid(keyCode) {
  512. return keyCode >= 49 && keyCode <= 58;
  513. },
  514. checkScoreValid(score) {
  515. const minScore = this.scores[0];
  516. const maxScore = this.scores.slice(-1)[0];
  517. return score >= minScore && score <= maxScore;
  518. },
  519. toKeySubmitScore() {
  520. if (!this.keyInput) return;
  521. if (!this.checkScoreValid(this.keyInput * 1)) {
  522. this.$Message.destroy();
  523. this.$Message.error("输入分数无效");
  524. return;
  525. }
  526. this.selectScore(this.keyInput);
  527. },
  528. getKeyInputLevel(key) {
  529. return this.levels.find(item => item.name === key);
  530. },
  531. toKeySubmitLevel() {
  532. if (!this.keyInput) return;
  533. const level = this.getKeyInputLevel(this.keyInput);
  534. this.selectLevel(level);
  535. },
  536. clearKeyInput() {
  537. this.keyInput = null;
  538. }
  539. },
  540. beforeDestroy() {
  541. if (this.setT) clearTimeout(this.setT);
  542. if (this.ribbonSet.keyboardMark)
  543. document.removeEventListener("click", this.keyEvent);
  544. }
  545. };
  546. </script>