CardAudit.vue 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  1. <template>
  2. <div class="card-check">
  3. <div style="margin-bottom: 20px;">
  4. <el-button
  5. v-for="(val, key) in auditingStatus"
  6. :key="key"
  7. :type="key == filter.auditingStatus ? 'primary' : 'default'"
  8. @click="selectAuditStatus(key)"
  9. >{{ val }}</el-button
  10. >
  11. </div>
  12. <div class="part-box part-box-filter">
  13. <el-form ref="FilterForm" label-position="left" label-width="85px" inline>
  14. <el-form-item label="学校名称:">
  15. <el-select
  16. v-model="filter.schId"
  17. style="width: 142px;"
  18. placeholder="请选择"
  19. clearable
  20. >
  21. <el-option
  22. v-for="item in schools"
  23. :key="item.id"
  24. :value="item.id"
  25. :label="item.name"
  26. ></el-option>
  27. </el-select>
  28. </el-form-item>
  29. <!-- <el-form-item label="学院:" v-if="filter.auditingStatus == 0">
  30. <el-select
  31. v-model="filter.collegeId"
  32. style="width: 142px;"
  33. placeholder="请选择"
  34. clearable
  35. >
  36. <el-option
  37. v-for="item in colleges"
  38. :key="item.id"
  39. :value="item.id"
  40. :label="item.name"
  41. ></el-option>
  42. </el-select>
  43. </el-form-item> -->
  44. <el-form-item label="题卡ID:" label-width="70px">
  45. <el-input
  46. style="width: 210px;"
  47. v-model.trim="filter.cardCode"
  48. placeholder="请输入内容"
  49. clearable
  50. ></el-input>
  51. </el-form-item>
  52. <el-form-item label-width="0px">
  53. <el-button type="primary" icon="icon icon-search" @click="toPage(1)"
  54. >查询</el-button
  55. >
  56. <el-button
  57. type="warning"
  58. icon="icon icon-download"
  59. @click="toDownloadAll"
  60. v-if="filter.auditingStatus == 0"
  61. >批量下载试卷文件</el-button
  62. >
  63. </el-form-item>
  64. </el-form>
  65. </div>
  66. <div class="part-box">
  67. <el-table ref="TableList" :data="cards" border stripe>
  68. <el-table-column prop="schoolName" label="学校名称"></el-table-column>
  69. <!-- <el-table-column prop="title" label="学院"></el-table-column> -->
  70. <el-table-column prop="cardCode" label="题卡ID"></el-table-column>
  71. <el-table-column prop="createTime" label="申请时间"></el-table-column>
  72. <el-table-column prop="userName" label="申请人"></el-table-column>
  73. <el-table-column prop="title" label="标题">
  74. <template slot-scope="scope">
  75. <p
  76. v-if="filter.auditingStatus == 0"
  77. class="cont-link"
  78. @click="downloadPaper(scope.row)"
  79. title="点击下载试卷文件"
  80. >
  81. {{ scope.row.title }}
  82. </p>
  83. <p v-else>{{ scope.row.title }}</p>
  84. </template>
  85. </el-table-column>
  86. <el-table-column label="操作" align="center">
  87. <template slot-scope="scope">
  88. <el-button
  89. class="btn-table-icon"
  90. type="text"
  91. icon="icon icon-modify"
  92. @click="toEdit(scope.row)"
  93. title="设计题卡"
  94. v-if="filter.auditingStatus == 0"
  95. ></el-button>
  96. <el-button
  97. class="btn-table-icon"
  98. type="text"
  99. icon="icon icon-circle-right"
  100. @click="toPreview(scope.row)"
  101. title="查看"
  102. v-else
  103. ></el-button>
  104. </template>
  105. </el-table-column>
  106. </el-table>
  107. <div class="part-page">
  108. <el-pagination
  109. background
  110. layout="prev, pager, next"
  111. :current-page="current"
  112. :total="total"
  113. :page-size="size"
  114. @current-change="toPage"
  115. >
  116. </el-pagination>
  117. </div>
  118. </div>
  119. </div>
  120. </template>
  121. <script>
  122. import { AUDITING_STATUS } from "@/constants/enumerate";
  123. import { download } from "@/plugins/utils";
  124. import { auditListPage, schoolList } from "../api";
  125. export default {
  126. name: "card-audit",
  127. data() {
  128. return {
  129. filter: {
  130. auditingStatus: "0",
  131. cardCode: "",
  132. schId: ""
  133. },
  134. current: 1,
  135. size: this.GLOBAL.pageSize,
  136. total: 0,
  137. visible: false,
  138. auditingStatus: {},
  139. AUDITING_STATUS,
  140. schools: [],
  141. colleges: [],
  142. cards: [],
  143. curExam: {}
  144. };
  145. },
  146. created() {
  147. let auditingStatus = {};
  148. Object.keys(AUDITING_STATUS)
  149. .filter(key => key !== "9")
  150. .map(key => {
  151. auditingStatus[key] = AUDITING_STATUS[key];
  152. });
  153. this.auditingStatus = auditingStatus;
  154. this.getList();
  155. this.getSchoolList();
  156. },
  157. methods: {
  158. async getSchoolList() {
  159. this.schools = await schoolList();
  160. this.filter.schId = this.$ls.get("schoolId");
  161. },
  162. async getList() {
  163. const datas = {
  164. ...this.filter,
  165. pageNumber: this.current,
  166. pageSize: this.size
  167. };
  168. const data = await auditListPage(datas);
  169. this.cards = data.records;
  170. this.total = data.total;
  171. },
  172. toPage(page) {
  173. this.current = page;
  174. this.getList();
  175. },
  176. async downloadPaper(row) {
  177. let load = this.$message({
  178. iconClass: "el-message__icon el-icon-loading",
  179. message: "Loading...",
  180. duration: 0
  181. });
  182. const data = await download({
  183. type: "get",
  184. url: `/api/print/card/card/downloadSimplePaper?cardId=${row.cardId}`,
  185. fileName: `${row.schoolName}_${row.cardId}${row.attachentType}`,
  186. header: {
  187. token: this.$ls.get("token")
  188. }
  189. }).catch(error => {
  190. this.$message.error(error);
  191. });
  192. load.close();
  193. if (!data) return;
  194. this.$message.success("文件已开始下载!");
  195. },
  196. async toDownloadAll() {
  197. let load = this.$message({
  198. iconClass: "el-message__icon el-icon-loading",
  199. message: "Loading...",
  200. duration: 0
  201. });
  202. let filterNams = [AUDITING_STATUS[this.filter.auditingStatus]];
  203. if (this.filter.cardCode) filterNams.push(this.filter.cardCode);
  204. filterNams.push(`page-${this.current}.zip`);
  205. const cardIds = this.cards.map(item => item.cardId).join(",");
  206. const data = await download({
  207. type: "get",
  208. url: `/api/print/card/card/downloadPapers?cardIds=${cardIds}`,
  209. fileName: filterNams.join("-"),
  210. header: {
  211. token: this.$ls.get("token")
  212. }
  213. }).catch(error => {
  214. this.$message.error(error);
  215. });
  216. load.close();
  217. if (!data) return;
  218. this.$message.success("文件已开始下载!");
  219. },
  220. selectAuditStatus(val) {
  221. this.filter.auditingStatus = val * 1;
  222. this.toPage(1);
  223. },
  224. toEdit(row) {
  225. this.$router.push({
  226. name: "CardDesign",
  227. params: {
  228. cardId: row.cardId
  229. }
  230. });
  231. },
  232. toPreview(row) {
  233. window.open(
  234. this.getRouterPath({
  235. name: "CardPreview",
  236. params: {
  237. cardId: row.cardId,
  238. viewType: "view"
  239. }
  240. })
  241. );
  242. }
  243. }
  244. };
  245. </script>