BusinessDataExport.vue 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302
  1. <template>
  2. <div class="business-data-export">
  3. <div class="part-box part-box-filter part-box-flex">
  4. <el-form ref="FilterForm" label-position="left" label-width="85px" inline>
  5. <template v-if="checkPrivilege('condition', 'condition')">
  6. <el-form-item label="印刷计划:">
  7. <print-plan-select
  8. v-model.trim="filter.printPlanId"
  9. placeholder="请选择"
  10. clearable
  11. @change="printPlanChange"
  12. ></print-plan-select>
  13. </el-form-item>
  14. <el-form-item label="课程(代码):" label-width="110px">
  15. <course-select
  16. v-model.trim="filter.courseCode"
  17. :print-plan-id="filter.printPlanId"
  18. placeholder="请选择"
  19. clearable
  20. ></course-select>
  21. </el-form-item>
  22. <el-form-item label="试卷编号:">
  23. <paper-number-select
  24. ref="PaperNumberSelect"
  25. v-model="filter.paperNumber"
  26. :print-plan-id="filter.printPlanId"
  27. placeholder="请选择"
  28. clearable
  29. ></paper-number-select>
  30. </el-form-item>
  31. <el-form-item label="考点:" label-width="55px">
  32. <place-select
  33. v-model.trim="filter.examPlace"
  34. :print-plan-id="filter.printPlanId"
  35. placeholder="请选择"
  36. clearable
  37. ></place-select>
  38. </el-form-item>
  39. <el-form-item label="考场:" label-width="55px">
  40. <room-select
  41. v-model.trim="filter.examRoom"
  42. :print-plan-id="filter.printPlanId"
  43. placeholder="请选择"
  44. clearable
  45. ></room-select>
  46. </el-form-item>
  47. <el-form-item label="卷袋号:" label-width="70px">
  48. <el-input
  49. v-model="filter.packageCode"
  50. placeholder="请输入"
  51. clearable
  52. ></el-input>
  53. </el-form-item>
  54. </template>
  55. <el-form-item label-width="0px">
  56. <el-button
  57. v-if="checkPrivilege('button', 'select')"
  58. type="primary"
  59. icon="el-icon-search"
  60. @click="search"
  61. >查询</el-button
  62. >
  63. </el-form-item>
  64. </el-form>
  65. <div class="part-box-action">
  66. <el-button
  67. v-if="checkPrivilege('button', 'TempleteDownload')"
  68. icon="el-icon-download"
  69. :loading="loading"
  70. @click="toDownloadTemplate"
  71. >
  72. 考务数据模板下载
  73. </el-button>
  74. <el-button
  75. v-if="checkPrivilege('button', 'export')"
  76. icon="el-icon-download"
  77. type="primary"
  78. :loading="loading"
  79. @click="toExport"
  80. >
  81. 导出查询结果
  82. </el-button>
  83. <el-button
  84. v-if="checkPrivilege('button', 'import')"
  85. icon="el-icon-upload2"
  86. type="warning"
  87. @click="toUpload"
  88. >
  89. 导入
  90. </el-button>
  91. </div>
  92. </div>
  93. <div class="part-box">
  94. <el-table ref="TableList" :data="dataList" border stripe>
  95. <el-table-column
  96. type="index"
  97. label="序号"
  98. width="70"
  99. align="center"
  100. :index="indexMethod"
  101. ></el-table-column>
  102. <el-table-column
  103. prop="printPlanName"
  104. label="印刷计划"
  105. ></el-table-column>
  106. <el-table-column prop="examDate" label="考试日期"> </el-table-column>
  107. <el-table-column prop="examTime" label="考试时间"> </el-table-column>
  108. <el-table-column prop="examPlace" label="考点"> </el-table-column>
  109. <el-table-column prop="examRoom" label="考场"> </el-table-column>
  110. <el-table-column prop="packageCode" label="卷袋号"> </el-table-column>
  111. <el-table-column prop="courseNameCode" label="课程(代码)">
  112. </el-table-column>
  113. <el-table-column prop="paperNumber" label="试卷编码"></el-table-column>
  114. <el-table-column prop="totalSubjects" label="科次" width="80">
  115. </el-table-column>
  116. <el-table-column
  117. class-name="action-column"
  118. label="操作"
  119. align="center"
  120. width="70"
  121. >
  122. <template slot-scope="scope">
  123. <el-button
  124. v-if="checkPrivilege('link', 'preview')"
  125. class="btn-table-icon"
  126. type="text"
  127. icon="icon icon-circle-right"
  128. @click="toPreview(scope.row)"
  129. title="查看详情"
  130. ></el-button>
  131. </template>
  132. </el-table-column>
  133. </el-table>
  134. </div>
  135. <div class="part-box-flex">
  136. <div>
  137. <span class="mr-2"
  138. >科次总计:<i class="color-primary">{{ totalData.totalSubjects }}</i>
  139. 科次</span
  140. >
  141. <span
  142. >卷袋数量总计:<i class="color-primary">{{
  143. totalData.packageCount
  144. }}</i>
  145. 个</span
  146. >
  147. </div>
  148. <el-pagination
  149. background
  150. layout="total,prev, pager, next"
  151. :current-page="current"
  152. :total="total"
  153. :page-size="size"
  154. @current-change="toPage"
  155. >
  156. </el-pagination>
  157. </div>
  158. <!-- PreviewBusinessDetail -->
  159. <preview-business-detail
  160. ref="PreviewBusinessDetail"
  161. :instance="curRow"
  162. ></preview-business-detail>
  163. <!-- UploadBusinessDataDialog -->
  164. <upload-business-data-dialog
  165. ref="UploadBusinessDataDialog"
  166. @modified="getList"
  167. ></upload-business-data-dialog>
  168. </div>
  169. </template>
  170. <script>
  171. import {
  172. businessDataListPage,
  173. businessTotalData,
  174. businessTemplateDownload,
  175. businessDataExport
  176. } from "../api";
  177. import PreviewBusinessDetail from "../components/PreviewBusinessDetail";
  178. import UploadBusinessDataDialog from "../components/UploadBusinessDataDialog";
  179. import { downloadBlob, parseTimeRangeDateAndTime } from "@/plugins/utils";
  180. export default {
  181. name: "business-data-export",
  182. components: { PreviewBusinessDetail, UploadBusinessDataDialog },
  183. data() {
  184. return {
  185. filter: {
  186. printPlanId: "",
  187. courseCode: "",
  188. paperNumber: "",
  189. examPlace: "",
  190. examRoom: "",
  191. packageCode: ""
  192. },
  193. current: 1,
  194. size: this.GLOBAL.pageSize,
  195. total: 0,
  196. dataList: [],
  197. curRow: {},
  198. totalData: {},
  199. curPrintPlan: {},
  200. loading: false,
  201. // import
  202. uploadUrl: "/api/admin/exam/print/data_import",
  203. uploadData: {
  204. type: "FILE",
  205. printPlanId: ""
  206. }
  207. };
  208. },
  209. computed: {
  210. canImport() {
  211. return (
  212. this.curPrintPlan && ["NEW", "READY"].includes(this.curPrintPlan.status)
  213. );
  214. }
  215. },
  216. mounted() {
  217. this.search();
  218. },
  219. methods: {
  220. async getList() {
  221. if (!this.checkPrivilege("list", "list")) return;
  222. const datas = {
  223. ...this.filter,
  224. pageNumber: this.current,
  225. pageSize: this.size
  226. };
  227. const data = await businessDataListPage(datas);
  228. this.dataList = data.records.map(item => {
  229. const { date, time } = parseTimeRangeDateAndTime(
  230. item.examStartTime,
  231. item.examEndTime
  232. );
  233. item.examDate = date;
  234. item.examTime = time;
  235. return item;
  236. });
  237. this.total = data.total;
  238. },
  239. async getTotalData() {
  240. this.totalData = await businessTotalData(this.filter);
  241. },
  242. toPage(page) {
  243. this.current = page;
  244. this.getList();
  245. },
  246. search() {
  247. this.toPage(1);
  248. this.getTotalData();
  249. },
  250. printPlanChange() {
  251. this.filter.paperNumber = "";
  252. this.filter.courseCode = "";
  253. this.filter.examRoom = "";
  254. this.filter.examPlace = "";
  255. },
  256. toUpload() {
  257. this.$refs.UploadBusinessDataDialog.open();
  258. },
  259. async toExport() {
  260. // 异步导出
  261. if (this.loading) return;
  262. this.loading = true;
  263. const res = await businessDataExport({ ...this.filter }).catch(() => {});
  264. this.loading = false;
  265. if (res) {
  266. this.$message.success(
  267. "导出任务已提交,请在数据管理-任务管理中下载文件!"
  268. );
  269. } else {
  270. this.$message.error("导出任务提交失败,请重新尝试!");
  271. }
  272. },
  273. async toDownloadTemplate() {
  274. if (this.loading) return;
  275. this.loading = true;
  276. const res = await downloadBlob(() => {
  277. return businessTemplateDownload();
  278. }, `考务数据模板.xlsx`).catch(() => {});
  279. this.loading = false;
  280. if (res) {
  281. this.$message.success("文件下载成功!");
  282. } else {
  283. this.$message.error("文件下载失败,请重新尝试!");
  284. }
  285. },
  286. toPreview(row) {
  287. this.curRow = { ...row };
  288. this.$refs.PreviewBusinessDetail.open();
  289. }
  290. }
  291. };
  292. </script>