BusinessDataExport.vue 9.7 KB

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