summaryLineMixin.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. import { examPropCount } from "@/api/invigilation";
  2. const paramInfo = {
  3. all: {
  4. name: "全部应考",
  5. param: "allCount",
  6. desc: "参加考试的全部考生。",
  7. icon: "users",
  8. unit: "人",
  9. },
  10. finish: {
  11. name: "完成率",
  12. param: "completionRate",
  13. desc: "“已完成”科次数量占应考科次数量的百分比。",
  14. icon: "rate",
  15. unit: "%",
  16. },
  17. prepare: {
  18. name: "已待考",
  19. param: "prepareCount",
  20. desc: "已进入待考界面等待开考的考生。",
  21. unit: "人",
  22. },
  23. exam: {
  24. name: "考试中",
  25. param: "examCount",
  26. desc: "正在答题的考生。",
  27. unit: "人",
  28. },
  29. complete: {
  30. name: "已交卷",
  31. param: "alreadyComplete",
  32. desc: "某科次的某次考试已完成“交卷”。",
  33. unit: "人",
  34. },
  35. trouble: {
  36. name: "通讯故障",
  37. param: "clientWebsocketStatusCount",
  38. desc: "考生端出现断网、断电、软硬件故障等异常导致考生端与监考端无法正常连接的考生。",
  39. unit: "人",
  40. },
  41. unfinish: {
  42. name: "未参加考试",
  43. param: "notComplete",
  44. desc: "某科次完成“交卷”的考试次数为0。",
  45. unit: "人",
  46. },
  47. };
  48. const types = {
  49. trouble: ["all", "prepare", "exam", "complete", "unfinish"],
  50. complete: ["all", "prepare", "exam", "complete", "unfinish"],
  51. progress: ["all", "prepare", "exam", "complete", "unfinish"],
  52. };
  53. // const types = {
  54. // trouble: ["all", "prepare", "exam", "trouble", "unfinish"],
  55. // complete: ["all", "prepare", "exam", "complete", "unfinish"],
  56. // progress: ["all", "finish", "prepare", "unfinish"],
  57. // };
  58. export default {
  59. name: "summary-line",
  60. props: {
  61. examId: {
  62. type: String,
  63. },
  64. dataType: {
  65. type: String,
  66. required: true,
  67. validator: (val) => {
  68. return ["trouble", "complete", "progress"].includes(val);
  69. },
  70. },
  71. },
  72. // mounted() {
  73. // this.initData();
  74. // },
  75. watch: {
  76. examId: {
  77. immediate: true,
  78. handler() {
  79. this.initData();
  80. },
  81. },
  82. },
  83. data() {
  84. return {
  85. paramList: [],
  86. examPropData: {},
  87. };
  88. },
  89. methods: {
  90. async initData() {
  91. if (!this.examId) return;
  92. const res = await examPropCount(this.examId).catch(() => {});
  93. this.examPropData = (res && res.data && res.data.data) || {};
  94. if (this.examPropData["completionRate"])
  95. this.examPropData["completionRate"] = Math.round(
  96. this.examPropData["completionRate"] * 100
  97. );
  98. this.paramList = types[this.dataType].map((item) => {
  99. let info = paramInfo[item];
  100. return {
  101. ...info,
  102. content: `${info.name}:${info.desc}`,
  103. };
  104. });
  105. },
  106. },
  107. };