GradeActionRough.vue 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746
  1. <template>
  2. <div class="grade-action">
  3. <!-- 头部信息 ------ -->
  4. <!-- 试卷状态 -->
  5. <!-- 状态:已评,待评,打回,仲裁,改大裆,改大裆打小档 -->
  6. <div class="action-paper-state" v-if="stepType === 'reject'">
  7. <p class="paper-state-cont">
  8. {{ curPaperOrTask.isRejectedByLeader ? "科组长打回" : "自动打回" }}
  9. </p>
  10. <p class="paper-state-intro">
  11. <span v-if="curPaperOrTask.rejectedCount"
  12. >共打回{{ curPaperOrTask.rejectedCount }}次</span
  13. >
  14. </p>
  15. </div>
  16. <div class="action-paper-state" v-else>
  17. <p class="paper-state-cont">{{ stepLabel }}</p>
  18. </div>
  19. <!-- 试卷信息 -->
  20. <div class="action-paper-info">
  21. <p>
  22. <span v-if="IS_MARKER">任务密号:</span>
  23. <span v-else>试卷密号:</span>
  24. <span v-if="curPaperOrTask.sn && !isBatchAction">
  25. NO.{{ curPaperOrTask.sn }}
  26. </span>
  27. <span v-else>--</span>
  28. </p>
  29. </div>
  30. <!-- 改档信息 -->
  31. <div class="action-grade-change" v-if="rights.gradeChange">
  32. <p>
  33. <span>原始粗档位:</span
  34. ><span>{{ curPaperOrTask.originLevel | levelNameFilter }}</span>
  35. </p>
  36. <p>
  37. <span v-if="IS_MARKER">建议粗档位:</span>
  38. <span v-else>申请粗档位:</span>
  39. <span>{{ curPaperOrTask.redoLevel | levelNameFilter }}</span>
  40. </p>
  41. </div>
  42. <div
  43. :class="[
  44. 'action-grade-change-status',
  45. { 'action-grade-change-status-error': curPaperOrTask.auditStatus === 0 }
  46. ]"
  47. v-if="rights.gradeChange && IS_ADMIN"
  48. >
  49. <p>{{ curPaperOrTask.auditStatus === 1 ? "同意改档" : "不同意改档" }}</p>
  50. </div>
  51. <!-- 大档位信息 -->
  52. <!-- 已评/待评(已评档位),改大裆打小档(已评档位) -->
  53. <div
  54. class="action-grade-info"
  55. v-if="rights.roughGradeInfo && curRoughLevel.name"
  56. >
  57. <h3 class="grade-info-name">
  58. {{ curRoughLevel.name | levelNameFilter }}
  59. </h3>
  60. <div class="grade-info-range">
  61. <p>档位范围</p>
  62. <p>
  63. <span>{{ curRoughLevel.minScore }}</span>
  64. <span>~</span>
  65. <span>{{ curRoughLevel.maxScore }}</span>
  66. </p>
  67. </div>
  68. </div>
  69. <!-- 小档位信息 -->
  70. <!-- 已评(已评档位),打回(建议档位) -->
  71. <h3
  72. class="action-grade-info-title"
  73. v-if="IS_MARKER && stepType === 'reject'"
  74. >
  75. <span>原细分档档位:{{ curPaperOrTask.originLevel || "" }}</span>
  76. <span
  77. v-if="
  78. paramsSet.levelConfig &&
  79. paramsSet.levelConfig.autoCallbackShowDeviation &&
  80. curPaperOrTask.deviationDirection &&
  81. curPaperOrTask.deviationDirection !== '0'
  82. "
  83. :class="[
  84. 'grade-info-deviation',
  85. {
  86. 'grade-info-deviation-error':
  87. curPaperOrTask.deviationDirection * 1 > 0
  88. }
  89. ]"
  90. >{{ curPaperOrTask.deviationDirection * 1 > 0 ? "偏高" : "偏低" }}</span
  91. >
  92. </h3>
  93. <h3
  94. class="action-grade-info-title"
  95. v-if="curPaperOrTask.rejected && curPaperOrTask.isRejectedByLeader"
  96. >
  97. 建议细分档位:
  98. </h3>
  99. <div class="action-grade-info" v-if="rights.gradeInfo && curLevel.name">
  100. <h3 class="grade-info-name">{{ curLevel.name }}</h3>
  101. <div class="grade-info-range">
  102. <p>分数范围</p>
  103. <p>
  104. <span>{{ curLevel.minScore }}</span>
  105. <span>~</span>
  106. <span>{{ curLevel.maxScore }}</span>
  107. </p>
  108. </div>
  109. </div>
  110. <!-- 小档位信息 -->
  111. <div
  112. class="action-grade-info action-mark-info"
  113. v-if="rights.gradeInfo && !curLevel.name"
  114. >
  115. <p class="grade-info-name grade-info-none">未分档</p>
  116. </div>
  117. <!-- 选择小档位 -->
  118. <div class="action-grade-list" v-if="rights.levelList">
  119. <div
  120. class="action-grade-item"
  121. v-for="(level, index) in levelList"
  122. :key="index"
  123. >
  124. <div
  125. :class="[
  126. 'action-grade-item-content',
  127. {
  128. 'action-item-content-disabled': btnClicked,
  129. 'is-active': keyInput == level.name
  130. }
  131. ]"
  132. @click="selectLevel(level)"
  133. >
  134. <p>{{ level.name }}</p>
  135. <p>{{ level.minScore }}~{{ level.maxScore }}</p>
  136. </div>
  137. </div>
  138. </div>
  139. <!-- 选择大档位 -->
  140. <h3
  141. class="action-grade-info-title"
  142. v-if="IS_MARK_LEADER && markLeaderOnlyRight && rights.roughLevelList"
  143. >
  144. 当前操作:{{ markLeaderOnlyRight.name }}
  145. </h3>
  146. <div class="action-grade-list" v-if="rights.roughLevelList">
  147. <div
  148. class="action-grade-item"
  149. v-for="(level, index) in roughLevelList"
  150. :key="index"
  151. >
  152. <div
  153. :class="[
  154. 'action-grade-item-content',
  155. {
  156. 'action-item-content-disabled': btnClicked,
  157. 'is-active': keyInput == level.name
  158. }
  159. ]"
  160. @click="selectRoughLevel(level)"
  161. >
  162. <p>{{ level.name | levelNameFilter }}</p>
  163. <p>{{ level.minScore }}~{{ level.maxScore }}</p>
  164. <p v-if="level.minSubScore || level.maxSubScore">
  165. {{ level.minSubScore }}~{{ level.maxSubScore }}
  166. </p>
  167. </div>
  168. </div>
  169. </div>
  170. <div
  171. v-if="
  172. ribbonSet.keyboardMark && (rights.roughLevelList || rights.levelList)
  173. "
  174. class="action-grade-keyboard"
  175. >
  176. <div class="keyboard-input">{{ keyInput }}</div>
  177. <div class="keyboard-clear" @click="clearKeyInput">
  178. <Icon type="md-trash" />
  179. </div>
  180. </div>
  181. <!-- 跳过 -->
  182. <div
  183. class="action-grade-pass"
  184. v-if="rights.gradePass && IS_MARKER"
  185. @click="toPass"
  186. >
  187. 跳过
  188. </div>
  189. <!-- marker confirm grade change -->
  190. <div
  191. class="action-grade-change-confirm"
  192. v-if="IS_MARKER && rights.gradeChange"
  193. >
  194. <Button type="primary" @click="gradeChangeConfirm">确认改档</Button>
  195. </div>
  196. <!-- 评卷记录 -->
  197. <div class="action-grade-history" v-if="rights.gradeHis">
  198. <h3>评卷记录</h3>
  199. <div class="grade-history-list">
  200. <div
  201. class="grade-history-item"
  202. v-for="his in gradingHistory"
  203. :key="his.id"
  204. >
  205. <p>{{ his.loginName }}</p>
  206. <p>{{ his.value }}</p>
  207. </div>
  208. </div>
  209. </div>
  210. <!-- 查询 -->
  211. <div class="action-search" v-if="rights.search">
  212. <Select
  213. class="search-select"
  214. v-model="filter.codeType"
  215. placeholder="密号类型"
  216. >
  217. <Option
  218. v-for="item in codeTypes"
  219. :key="item.key"
  220. :value="item.key"
  221. :label="item.val"
  222. ></Option>
  223. </Select>
  224. <Input
  225. class="search-input"
  226. v-model.trim="filter.code"
  227. placeholder="输入密号"
  228. clearable
  229. >
  230. </Input>
  231. <Button size="small" type="primary" class="search-btn" @click="searchCode"
  232. >查询</Button
  233. >
  234. </div>
  235. </div>
  236. </template>
  237. <script>
  238. import { markHistoryList } from "@/api";
  239. import { CODE_TYPE } from "@/constants/enumerate";
  240. import { mapState, mapMutations } from "vuex";
  241. import { levelNameTransform } from "@/plugins/utils";
  242. // 三种情况:
  243. // 管理员(ADMIN),科组长(MARK_LEADER),评卷员(MARKER)
  244. // MARK_LEADER / ADMIN: curPaperOrTask => paper
  245. // MARKER: curPaperOrTask => task
  246. //
  247. /*
  248. [paper template]
  249. {
  250. "id": 165,
  251. "sn": "029947536",
  252. "examNumber": "1901040084",
  253. "level": "A",
  254. "score": null,
  255. "redoLevel": null,
  256. "updatedOn": 1591767742000,
  257. "imgSrc": "",
  258. "thumbSrc": "",
  259. "markByLeader": false,
  260. "markedLogic": true,
  261. "areaCode": "2",
  262. "inspectScore": null,
  263. "inspectLevel": null,
  264. "inspector": null,
  265. "sheetSrc": null,
  266. "stage": "LEVEL",
  267. "test": 0,
  268. "paperTest": 0,
  269. "markResults": [],
  270. "rejected": false,
  271. "arbitrated": false,
  272. "sample": false,
  273. "tagged": false,
  274. "missing": false,
  275. "manual": false
  276. }
  277. [marktask template]
  278. {
  279. id: 58,
  280. sn: "18111595446",
  281. redoLevel: null,
  282. level: null,
  283. roughLevel: "5",
  284. score: null,
  285. result: null,
  286. originLevel: "",
  287. markerId: 16,
  288. loginName: "sm1",
  289. marker: "sm1",
  290. updatedOn: null,
  291. imgSrc: "",
  292. thumbSrc: "",
  293. markByLeader: false,
  294. oldRejected: false,
  295. paperId: 107,
  296. randomSeqNew: 11595446,
  297. randomSeq: null,
  298. serialNumber: null,
  299. displayNumber: false,
  300. shift: false,
  301. shiftScore: false,
  302. isRejectedByLeader: false,
  303. rejectedCount: 0,
  304. dateMineResult: null,
  305. deviationDirection: null,
  306. sample: false,
  307. rejected: false,
  308. mark: false,
  309. key: "i9k7nqr8s2kb60uo",
  310. title: "NO.18111595446",
  311. selected: false
  312. };
  313. */
  314. const initRights = {
  315. roughGradeInfo: false,
  316. gradeInfo: false,
  317. levelList: false,
  318. roughLevelList: false,
  319. gradePass: false,
  320. gradeHis: false,
  321. search: false
  322. };
  323. export default {
  324. name: "grade-action-rough",
  325. props: {
  326. curPaperOrTask: {
  327. type: Object,
  328. default() {
  329. return {};
  330. }
  331. },
  332. levels: {
  333. type: Array,
  334. default() {
  335. return [];
  336. }
  337. },
  338. paramsSet: {
  339. type: Object,
  340. default() {
  341. return {};
  342. }
  343. },
  344. isBatchAction: {
  345. type: Boolean,
  346. default: false
  347. },
  348. // 是否处于粗分档
  349. isRoughLevel: {
  350. type: Boolean,
  351. default: false
  352. }
  353. },
  354. data() {
  355. return {
  356. curUserRoleType: this.$ls.get("user", { role: "" }).role,
  357. curPaperOrTaskLevel: "",
  358. rights: {
  359. ...initRights
  360. },
  361. cacheRights: null,
  362. roleRight: {
  363. ADMIN: {
  364. done: ["roughGradeInfo", "gradeInfo", "gradeHis", "search"],
  365. reject: ["roughGradeInfo", "gradeInfo", "gradeHis", "search"],
  366. arbitrate: ["gradeHis", "search"],
  367. shift: [
  368. "roughGradeInfo",
  369. "gradeInfo",
  370. "search",
  371. "gradeChangeSearch",
  372. "gradeChange"
  373. ]
  374. },
  375. MARK_LEADER: {
  376. undo: ["roughGradeInfo", "gradeInfo", "levelList", "roughLevelList"],
  377. done: [
  378. "roughGradeInfo",
  379. "gradeInfo",
  380. "levelList",
  381. "roughLevelList",
  382. "gradeHis"
  383. ],
  384. reject: [
  385. "roughGradeInfo",
  386. "gradeInfo",
  387. "levelList",
  388. "roughLevelList",
  389. "gradeHis"
  390. ],
  391. arbitrate: ["roughGradeInfo", "gradeInfo", "levelList", "gradeHis"],
  392. shift: ["gradeChange", "roughLevelList"],
  393. batch: ["levelList"]
  394. },
  395. MARKER: {
  396. done: ["roughGradeInfo", "gradeInfo", "levelList"],
  397. undo: ["roughGradeInfo", "gradeInfo", "levelList", "gradePass"],
  398. reject: ["gradeInfo", "levelList", "gradePass"],
  399. shift: ["gradeChange"],
  400. shiftScore: ["roughGradeInfo", "gradeInfo", "levelList", "levelPass"],
  401. batch: ["levelList"]
  402. },
  403. STANDARD: ["gradeInfo"]
  404. },
  405. filter: {
  406. codeType: "examNumber",
  407. code: ""
  408. },
  409. codeTypes: [],
  410. stepDict: {
  411. undo: "待评",
  412. done: "已评",
  413. reject: "打回",
  414. arbitrate: "待仲裁",
  415. shift: "改大档",
  416. shiftScore: "改大档打小档",
  417. sample: "标准卷",
  418. batch: "批量操作"
  419. },
  420. stepType: "",
  421. stepLabel: "",
  422. gradingHistory: [],
  423. levelList: [],
  424. curLevel: {},
  425. roughLevelList: [],
  426. curRoughLevel: {},
  427. setT: null,
  428. btnClicked: false,
  429. keyInput: null,
  430. // 科组长权限
  431. markLeaderOnlyRight: null
  432. };
  433. },
  434. computed: {
  435. ...mapState("marker", ["ribbonSet", "shortcutKeyStatus", "curSubject"]),
  436. IS_ADMIN() {
  437. return this.curUserRoleType === "ADMIN";
  438. },
  439. IS_MARKER() {
  440. return this.curUserRoleType === "MARKER";
  441. },
  442. IS_MARK_LEADER() {
  443. return this.curUserRoleType === "MARK_LEADER";
  444. }
  445. },
  446. watch: {
  447. curPaperOrTask() {
  448. this.rebuildRight();
  449. },
  450. isBatchAction(val) {
  451. if (val) {
  452. this.stepType = "batch";
  453. this.stepLabel = this.stepDict[this.stepType];
  454. const roleRights =
  455. this.roleRight[this.curUserRoleType][this.stepType] || [];
  456. this.rights = { ...initRights };
  457. roleRights.map(key => {
  458. this.rights[key] = true;
  459. });
  460. } else {
  461. this.rebuildRight();
  462. }
  463. this.keyInput = null;
  464. },
  465. "ribbonSet.keyboardMark": {
  466. immediate: true,
  467. handler(val) {
  468. this.setShortcutStatus({ action: val });
  469. }
  470. },
  471. "shortcutKeyStatus.action": {
  472. immediate: true,
  473. handler(val, oldval) {
  474. // console.log(val, oldval);
  475. if (val === oldval) return;
  476. if (val) {
  477. document.addEventListener("keydown", this.keyEvent);
  478. } else {
  479. document.removeEventListener("keydown", this.keyEvent);
  480. }
  481. }
  482. }
  483. },
  484. mounted() {
  485. this.markLeaderOnlyRight = this.$ls.get("user", {
  486. markLeaderOnlyRight: null
  487. }).markLeaderOnlyRight;
  488. this.codeTypes = Object.entries(CODE_TYPE)
  489. .map(([key, val]) => {
  490. return {
  491. key,
  492. val
  493. };
  494. })
  495. .filter(item => item.key !== "examNumber");
  496. // .filter(item => this.IS_ADMIN || item.key !== "examNumber");
  497. this.rebuildRight();
  498. },
  499. methods: {
  500. ...mapMutations("marker", ["setShortcutStatus"]),
  501. getStepType() {
  502. const info = this.curPaperOrTask;
  503. if (info.sample) return "sample";
  504. if (info.shift && info.shiftScore && !info.level && !info.result)
  505. return "shift";
  506. if (!info.shift && info.shiftScore && !info.result) return "shiftScore";
  507. if (this.curPaperOrTaskLevel) return "done";
  508. if (info.arbitrated) return "arbitrate";
  509. if (info.rejected) return "reject";
  510. if (!info.rejected && !info.arbitrated && !info.level) return "undo";
  511. return;
  512. },
  513. rebuildRight() {
  514. if (this.setT) clearTimeout(this.setT);
  515. this.curPaperOrTaskLevel =
  516. this.curSubject.stage === "LEVEL"
  517. ? this.curPaperOrTask.level
  518. : this.curPaperOrTask.roughLevel || this.curPaperOrTask.level;
  519. let roleRights = [];
  520. this.stepType = this.getStepType();
  521. this.stepLabel = this.stepDict[this.stepType];
  522. if (this.stepType === "sample") {
  523. roleRights = this.roleRight.STANDARD;
  524. } else {
  525. roleRights = this.roleRight[this.curUserRoleType][this.stepType] || [];
  526. }
  527. this.rights = { ...initRights };
  528. roleRights.map(key => {
  529. this.rights[key] = true;
  530. });
  531. this.initLevels();
  532. if (this.rights.gradeHis) {
  533. this.getMarkHistory();
  534. }
  535. this.btnClicked = false;
  536. this.keyInput = null;
  537. },
  538. initLevels() {
  539. this.levelList = this.levels.filter(
  540. item => item.roughCode === this.curPaperOrTask.roughLevel
  541. );
  542. this.roughLevelList = this.parseRoughLevels(this.levels);
  543. const curRoughLevel = this.roughLevelList.find(
  544. item => item.name === this.curPaperOrTask.roughLevel
  545. );
  546. this.curRoughLevel = curRoughLevel || {};
  547. const levelName = this.curPaperOrTask.rejected
  548. ? this.curPaperOrTask.redoLevel
  549. : this.curPaperOrTaskLevel;
  550. if (levelName) {
  551. this.curLevel =
  552. this.levelList.find(item => item.name === levelName) || {};
  553. } else {
  554. this.curLevel = {};
  555. }
  556. },
  557. parseRoughLevels(levelList) {
  558. const levelMap = {};
  559. levelList.forEach(item => {
  560. const ind = item.roughCode;
  561. if (!levelMap[ind]) levelMap[ind] = [];
  562. levelMap[ind].push(item);
  563. });
  564. let roughLevelList = Object.keys(levelMap).map((roughCode, ind) => {
  565. const group = levelMap[roughCode];
  566. const levels = group.map(item => item.code);
  567. const minSs = group.map(item => item.minScore);
  568. const maxSs = group.map(item => item.maxScore);
  569. return {
  570. id: ind + 1,
  571. name: roughCode,
  572. minScore: levels[0],
  573. maxScore: levels.slice(-1)[0],
  574. minSubScore: Math.min.apply(null, minSs),
  575. maxSubScore: Math.max.apply(null, maxSs)
  576. };
  577. });
  578. roughLevelList.sort((a, b) => (a.name < b.name ? -1 : 1));
  579. return roughLevelList;
  580. },
  581. async getMarkHistory() {
  582. // 只有科组长和超管才会展示评卷记录
  583. const data = await markHistoryList(
  584. this.curPaperOrTask.id,
  585. this.curSubject.stage
  586. );
  587. this.gradingHistory = data.map(item => {
  588. let level = item.result || "未评";
  589. if (this.stepType === "reject" && !item.result) {
  590. level = `${levelNameTransform(level)}(${levelNameTransform(
  591. item.originLevel
  592. )})`;
  593. }
  594. return {
  595. id: item.id,
  596. markerId: item.markerId,
  597. name: item.marker,
  598. loginName: item.loginName,
  599. value: level
  600. };
  601. });
  602. },
  603. selectLevel(level) {
  604. if (this.isBatchAction) {
  605. if (this.btnClicked) return;
  606. this.btnClicked = true;
  607. this.setT = setTimeout(() => {
  608. this.btnClicked = false;
  609. }, 500);
  610. this.$emit("on-batch-level", level);
  611. return;
  612. }
  613. if (this.IS_MARKER && this.curPaperOrTaskLevel === level.name) return;
  614. if (this.btnClicked) return;
  615. this.btnClicked = true;
  616. if (this.IS_MARK_LEADER) {
  617. this.setT = setTimeout(() => {
  618. this.btnClicked = false;
  619. }, 500);
  620. this.$emit(
  621. "on-leader-level",
  622. {
  623. paperIds: this.curPaperOrTask.id + "",
  624. curLevel: this.curPaperOrTaskLevel,
  625. selectedLevel: level.name,
  626. markLeaderOnlyRight: this.markLeaderOnlyRight
  627. },
  628. this.gradingHistory.map(item => {
  629. return {
  630. id: item.markerId,
  631. name: item.loginName
  632. };
  633. })
  634. );
  635. return;
  636. }
  637. this.$emit("on-select-level", level);
  638. },
  639. selectRoughLevel(level) {
  640. if (this.curPaperOrTask.roughLevel === level.name) return;
  641. if (this.btnClicked) return;
  642. this.btnClicked = true;
  643. this.setT = setTimeout(() => {
  644. this.btnClicked = false;
  645. }, 500);
  646. // 科组长改档 / 评卷同意改档:只使用selectedLevel
  647. const curLevel =
  648. this.stepType === "shift"
  649. ? this.curPaperOrTask.redoLevel
  650. : this.curPaperOrTask.roughLevel;
  651. this.$emit("on-leader-change-level", {
  652. paperId: this.curPaperOrTask.paperId,
  653. curLevel,
  654. selectedLevel: level.name
  655. });
  656. },
  657. gradeChangeConfirm() {
  658. this.selectRoughLevel({ name: this.curPaperOrTask.redoLevel });
  659. },
  660. toPass() {
  661. this.$emit("on-pass");
  662. },
  663. searchCode() {
  664. if (!this.filter.code || !this.filter.codeType) {
  665. this.$Message.error("请设置密号类型和密号!");
  666. return;
  667. }
  668. this.$emit("on-code-search", this.filter);
  669. },
  670. // keyboard submit
  671. keyEvent(e) {
  672. this.$Message.destroy();
  673. if (this.btnClicked) return;
  674. // if (!this.ribbonSet.keyboardMark) return;
  675. if (!e.altKey && !e.shiftKey && !e.ctrlKey) {
  676. if (e.key === "Enter" && this.ribbonSet.needEnterSubmit) {
  677. e.preventDefault();
  678. this.toKeySubmit();
  679. return;
  680. }
  681. if (!/^[a-z0-9]$/.test(e.key)) return;
  682. const keyInput = e.key.toUpperCase();
  683. if (this.getKeyInputLevel(keyInput)) {
  684. e.preventDefault();
  685. this.keyInput = keyInput;
  686. if (!this.ribbonSet.needEnterSubmit) {
  687. this.toKeySubmit();
  688. }
  689. } else {
  690. this.$Message.error("按键无效");
  691. }
  692. }
  693. },
  694. getKeyInputLevel(key) {
  695. return (
  696. this.levelList.find(item => item.name === key) ||
  697. this.roughLevelList.find(item => item.name === key)
  698. );
  699. },
  700. toKeySubmit() {
  701. if (!this.keyInput) {
  702. this.$Message.error("请选择档位");
  703. return;
  704. }
  705. const level = this.getKeyInputLevel(this.keyInput);
  706. if (/^[a-z]$/.test(level.name)) {
  707. this.selectLevel(level);
  708. } else {
  709. this.selectRoughLevel(level);
  710. }
  711. },
  712. clearKeyInput() {
  713. this.keyInput = null;
  714. }
  715. },
  716. beforeDestroy() {
  717. if (this.setT) clearTimeout(this.setT);
  718. if (this.ribbonSet.keyboardMark)
  719. document.removeEventListener("click", this.keyEvent);
  720. }
  721. };
  722. </script>