PrintManage.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. <template>
  2. <div class="exam-manage">
  3. <div class="part-box part-box-filter">
  4. <el-form ref="FilterForm" label-position="left" label-width="85px" inline>
  5. <el-form-item label="考试名称:">
  6. <el-select
  7. v-model="filter.examId"
  8. style="width: 193px;"
  9. placeholder="请选择"
  10. clearable
  11. >
  12. <el-option
  13. v-for="item in exams"
  14. :key="item.id"
  15. :value="item.id"
  16. :label="item.name"
  17. ></el-option>
  18. </el-select>
  19. </el-form-item>
  20. <el-form-item label="打印时间:">
  21. <el-date-picker
  22. v-model="filter.printTime"
  23. value-format="yyyy-MM-dd"
  24. format="yyyy-MM-dd"
  25. type="date"
  26. placeholder="请选择日期"
  27. >
  28. </el-date-picker>
  29. </el-form-item>
  30. <el-form-item label="撤回申请:">
  31. <el-select
  32. v-model="filter.revokeStatus"
  33. style="width: 142px;"
  34. placeholder="请选择"
  35. clearable
  36. >
  37. <el-option
  38. v-for="(val, key) in REVOKE_STATUS"
  39. :key="key"
  40. :value="key"
  41. :label="val"
  42. ></el-option>
  43. </el-select>
  44. </el-form-item>
  45. <el-form-item label-width="0px">
  46. <el-button type="primary" icon="icon icon-search" @click="toPage(1)"
  47. >查询</el-button
  48. >
  49. </el-form-item>
  50. </el-form>
  51. </div>
  52. <div class="part-box">
  53. <el-table ref="TableList" :data="dataList" border stripe>
  54. <el-table-column prop="examCode" label="考试ID"></el-table-column>
  55. <el-table-column prop="examName" label="考试名称"></el-table-column>
  56. <el-table-column prop="totalCourse" label="总科次"></el-table-column>
  57. <el-table-column prop="printTime" label="打印时间"></el-table-column>
  58. <el-table-column prop="printProgress" label="打印进度">
  59. <template slot-scope="scope">{{ scope.row.printProgress }}%</template>
  60. </el-table-column>
  61. <el-table-column
  62. prop="revokeStatusName"
  63. label="撤回申请"
  64. ></el-table-column>
  65. <el-table-column label="操作" align="center" v-if="!IS_PRINTER">
  66. <template slot-scope="scope">
  67. <el-button
  68. class="btn-table-icon"
  69. type="text"
  70. icon="icon icon-confirm"
  71. @click="toConfirm(scope.row)"
  72. title="确认"
  73. v-if="scope.row.revokeStatus === '0'"
  74. ></el-button>
  75. </template>
  76. </el-table-column>
  77. </el-table>
  78. <div class="part-page">
  79. <el-pagination
  80. background
  81. layout="prev, pager, next"
  82. :current-page="current"
  83. :total="total"
  84. :page-size="size"
  85. @current-change="toPage"
  86. >
  87. </el-pagination>
  88. </div>
  89. </div>
  90. </div>
  91. </template>
  92. <script>
  93. import { REVOKE_STATUS } from "@/constants/enumerate";
  94. import { printTaskListPage, examList, printRevokeAudit } from "../api";
  95. export default {
  96. name: "print-manage",
  97. data() {
  98. return {
  99. filter: {
  100. examId: "",
  101. revokeStatus: "",
  102. printTime: ""
  103. },
  104. current: 1,
  105. size: this.GLOBAL.pageSize,
  106. total: 0,
  107. visible: false,
  108. REVOKE_STATUS,
  109. exams: [],
  110. dataList: [],
  111. IS_PRINTER: false,
  112. loopRunning: false,
  113. loopSetTs: []
  114. };
  115. },
  116. created() {
  117. this.init();
  118. },
  119. methods: {
  120. init() {
  121. this.IS_PRINTER = this.$ls
  122. .get("user", { roleCode: "" })
  123. .roleCode.includes("PRINT");
  124. this.getExamList();
  125. this.loopRunning = true;
  126. this.timerUpdatePage();
  127. },
  128. clearLoopSetTs() {
  129. if (!this.loopSetTs.length) return;
  130. this.loopSetTs.forEach(sett => {
  131. clearTimeout(sett);
  132. });
  133. this.loopSetTs = [];
  134. },
  135. async timerUpdatePage() {
  136. this.clearLoopSetTs();
  137. if (!this.loopRunning) return;
  138. await this.getList().catch(() => {});
  139. this.loopSetTs.push(
  140. setTimeout(() => {
  141. this.timerUpdatePage();
  142. }, 30 * 1000)
  143. );
  144. },
  145. async getList() {
  146. const datas = {
  147. ...this.filter,
  148. pageNumber: this.current,
  149. pageSize: this.size
  150. };
  151. const data = await printTaskListPage(datas);
  152. this.dataList = data.records;
  153. this.total = data.total;
  154. },
  155. toPage(page) {
  156. this.current = page;
  157. this.getList();
  158. },
  159. async getExamList() {
  160. const data = await examList();
  161. this.exams = data.map(item => {
  162. return {
  163. id: item.id,
  164. name: item.examName
  165. };
  166. });
  167. },
  168. async toConfirm(row) {
  169. await printRevokeAudit(row.id);
  170. this.$message.success("确认成功!");
  171. this.getList();
  172. }
  173. },
  174. beforeDestroy() {
  175. this.loopRunning = false;
  176. this.clearLoopSetTs();
  177. }
  178. };
  179. </script>