MarkSettingMain.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486
  1. <template>
  2. <div>
  3. <section class="content">
  4. <div
  5. class="box box-info"
  6. v-loading="fileLoading"
  7. element-loading-text="导入需要较长时间,请耐心等候"
  8. >
  9. <div class="box-header with-border">
  10. <h3 class="box-title">
  11. <span>评卷设置</span> <span>({{ $route.params.name }})</span>
  12. </h3>
  13. <div class="box-tools pull-right"></div>
  14. </div>
  15. <div class="box-body">
  16. <el-form
  17. :inline="true"
  18. :model="formSearch"
  19. label-position="right"
  20. label-width="80px"
  21. >
  22. <el-form-item label="课程" class="pull-left">
  23. <el-select
  24. clearable
  25. filterable
  26. class="input"
  27. v-model="formSearch.courseCode"
  28. placeholder="请选择"
  29. >
  30. <el-option value="">请选择</el-option>
  31. <el-option
  32. v-for="item in courseAllListSelect"
  33. :label="item.courseInfo"
  34. :value="item.code"
  35. :key="item.code"
  36. >
  37. </el-option>
  38. </el-select>
  39. </el-form-item>
  40. <el-form-item class="pull-right">
  41. <el-button
  42. size="small"
  43. type="primary"
  44. icon="search"
  45. @click="initSetting"
  46. >查询</el-button
  47. >
  48. <el-button
  49. size="small"
  50. type="primary"
  51. icon="caret-left"
  52. @click="back"
  53. >返回</el-button
  54. >
  55. <el-button size="small" type="primary" icon="upload2" @click="imp"
  56. >导入</el-button
  57. >
  58. <el-button
  59. size="small"
  60. type="primary"
  61. icon="download"
  62. @click="exportCourse"
  63. >导出</el-button
  64. >
  65. </el-form-item>
  66. </el-form>
  67. <!-- 导入弹窗 -->
  68. <el-dialog title="导入窗口" size="tiny" :visible.sync="impDialog">
  69. <el-form>
  70. <el-row>
  71. <el-form-item>
  72. <el-upload
  73. class="form_left"
  74. ref="upload"
  75. accept="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
  76. :action="uploadAction"
  77. :headers="uploadHeaders"
  78. :data="uploadData"
  79. :before-upload="beforeUpload"
  80. :on-progress="uploadProgress"
  81. :on-success="uploadSuccess"
  82. :on-error="uploadError"
  83. :file-list="fileList"
  84. :auto-upload="false"
  85. :multiple="false"
  86. >
  87. <el-button slot="trigger" type="primary" size="small"
  88. >选择文件</el-button
  89. >
  90. <el-button
  91. size="small"
  92. style="margin-left:5px;"
  93. type="success"
  94. @click="submitUpload"
  95. >确认上传
  96. </el-button>
  97. <el-button
  98. size="small"
  99. style="margin-left:5px;"
  100. type="danger"
  101. @click="removeFile"
  102. >清空文件
  103. </el-button>
  104. <el-button
  105. size="small"
  106. style="margin-left:5px;"
  107. type="info"
  108. @click="exportFile"
  109. >下载模板
  110. </el-button>
  111. <div slot="tip" class="el-upload__tip">
  112. 只能上传xlsx文件
  113. </div>
  114. </el-upload>
  115. </el-form-item>
  116. </el-row>
  117. </el-form>
  118. </el-dialog>
  119. <!-- 导入错误信息列表 -->
  120. <el-dialog title="错误提示" :visible.sync="errDialog">
  121. <div
  122. class="text-danger"
  123. v-for="errMessage in errMessages"
  124. :key="errMessage.row"
  125. >
  126. 第{{ errMessage.row }}行:{{ errMessage.excelErrorType }}
  127. </div>
  128. <span slot="footer" class="dialog-footer">
  129. <el-button @click="errDialog = false;">确定</el-button>
  130. </span>
  131. </el-dialog>
  132. <!-- 页面列表 -->
  133. <el-table
  134. v-loading="loading"
  135. element-loading-text="拼命加载中"
  136. :data="tableData"
  137. border
  138. style="width: 100%"
  139. >
  140. <el-table-column label="课程名称" width="200" prop="name">
  141. </el-table-column>
  142. <el-table-column label="课程代码" min-width="100" prop="code">
  143. </el-table-column>
  144. <el-table-column label="试卷数" min-width="100" prop="totalCount">
  145. </el-table-column>
  146. <el-table-column
  147. label="评卷员数"
  148. min-width="100"
  149. prop="markerCount"
  150. >
  151. </el-table-column>
  152. <el-table-column :context="_self" label="操作">
  153. <template slot-scope="scope">
  154. <div class="pull-left" v-if="scope.row.totalCount > 0">
  155. <el-button
  156. @click="fastSetting(scope.$index, scope.row);"
  157. type="success"
  158. size="mini"
  159. >快速设置</el-button
  160. >
  161. </div>
  162. </template>
  163. </el-table-column>
  164. </el-table>
  165. <div class="page pull-right">
  166. <el-pagination
  167. background
  168. @current-change="handleSettingCurrentChange"
  169. :current-page="currentPage"
  170. :page-size="10"
  171. layout="total, prev, pager, next, jumper"
  172. :total="total"
  173. >
  174. </el-pagination>
  175. </div>
  176. </div>
  177. </div>
  178. </section>
  179. </div>
  180. </template>
  181. <script>
  182. import { MARKING_API, DATA_PROCESS_API } from "../constants/constants";
  183. import { mapState } from "vuex";
  184. export default {
  185. data() {
  186. return {
  187. formSearch: {
  188. courseCode: "",
  189. courseName: "",
  190. specialtyLevel: "",
  191. specialtyName: "",
  192. leader: ""
  193. },
  194. courseList: [],
  195. tableData: [],
  196. oldData: [],
  197. currentPage: 1,
  198. pageSize: 10,
  199. total: 10,
  200. loading: true,
  201. workId: "",
  202. examId: "",
  203. examName: "",
  204. markTasks: {
  205. workId: "",
  206. userId: [],
  207. paperId: ""
  208. },
  209. paperId: "",
  210. impDialog: false,
  211. uploadAction: DATA_PROCESS_API + "/markTasks/import",
  212. uploadHeaders: {},
  213. uploadData: { workId: "" },
  214. errMessages: [],
  215. errDialog: false,
  216. fileLoading: false,
  217. fileList: []
  218. };
  219. },
  220. methods: {
  221. //查询课程
  222. getCourses() {
  223. this.$http
  224. .get(
  225. MARKING_API +
  226. "/markResults/queryExamCourseList?workId=" +
  227. this.$route.params.workId
  228. )
  229. .then(response => {
  230. this.courseList = response.data;
  231. });
  232. },
  233. fastSetting(index, row) {
  234. this.paperId = row.pk;
  235. var url =
  236. "/marking/mark_setting_fast/" +
  237. this.$route.params.workId +
  238. "/" +
  239. this.$route.params.examId +
  240. "/" +
  241. this.$route.params.name +
  242. "/" +
  243. row.code +
  244. "/" +
  245. row.name;
  246. this.$router.push({
  247. path: url
  248. });
  249. },
  250. filterSetting() {
  251. if (!this.formSearch.courseCode && !this.formSearch.courseName) {
  252. return;
  253. }
  254. var tempData = this.tableData.filter(element => {
  255. var flag = true;
  256. if (this.formSearch.courseCode || this.formSearch.courseName) {
  257. if (this.formSearch.courseCode) {
  258. flag =
  259. flag && element.courseCode.includes(this.formSearch.courseCode);
  260. }
  261. if (this.formSearch.courseName) {
  262. flag =
  263. flag && element.courseName.includes(this.formSearch.courseName);
  264. }
  265. return flag;
  266. } else {
  267. return true;
  268. }
  269. });
  270. this.tableData = tempData;
  271. this.total = tempData.length;
  272. },
  273. handleSettingCurrentChange(val) {
  274. this.currentPage = val;
  275. this.initSetting();
  276. },
  277. pagingSetting() {
  278. var start = (this.currentPage - 1) * this.pageSize;
  279. var end =
  280. this.currentPage * this.pageSize < this.total
  281. ? this.currentPage * this.pageSize
  282. : this.total;
  283. var tempData = [];
  284. console.log(`当前页: ${this.currentPage},开始:${start},结束:${end}`);
  285. for (let i = start; i < end; i++) {
  286. tempData.push(this.tableData[i]);
  287. }
  288. console.log(tempData);
  289. this.tableData = tempData;
  290. },
  291. handleCommand(command) {
  292. if (command == "importSub") {
  293. console.log("导入主观题");
  294. } else if (command == "importOb") {
  295. console.log("导入客观题");
  296. } else if (command == "importMarker") {
  297. console.log("导入评卷员");
  298. }
  299. },
  300. initSetting() {
  301. this.loading = true;
  302. this.$http
  303. .get(
  304. MARKING_API +
  305. "/markCourses/all/" +
  306. (this.currentPage - 1) +
  307. "/" +
  308. this.pageSize +
  309. "?workId=" +
  310. this.workId,
  311. { params: this.formSearch }
  312. )
  313. .then(response => {
  314. console.log(response.data);
  315. this.tableData = response.data.content;
  316. this.total = response.data.totalElements;
  317. this.oldData = this.tableData.slice(0);
  318. this.loading = false;
  319. });
  320. },
  321. searchSetting() {
  322. this.loading = true;
  323. this.tableData = this.oldData.slice(0);
  324. this.total = this.tableData.length;
  325. this.filterSetting();
  326. this.pagingSetting();
  327. this.loading = false;
  328. },
  329. back() {
  330. this.$router.push({
  331. path: "/marking/mark_setting_work/setting"
  332. });
  333. },
  334. //导入
  335. imp() {
  336. this.impDialog = true;
  337. this.initUpload();
  338. },
  339. initUpload() {
  340. this.fileList = [];
  341. },
  342. beforeUpload(file) {
  343. console.log(file);
  344. },
  345. uploadProgress() {
  346. console.log("uploadProgress");
  347. },
  348. uploadSuccess(response) {
  349. console.log("uploadSuccess");
  350. console.log(response);
  351. if (!response || response.length == 0) {
  352. this.$notify({
  353. message: "上传成功",
  354. type: "success"
  355. });
  356. this.fileLoading = false;
  357. this.impDialog = false;
  358. window.location.reload();
  359. } else {
  360. this.errMessages = response;
  361. this.errDialog = true;
  362. this.fileLoading = false;
  363. this.impDialog = false;
  364. }
  365. },
  366. uploadError(err) {
  367. var result = err.message.match(/\{.+}/);
  368. var errMessage = JSON.parse(result[0]).desc;
  369. this.$notify({
  370. message: errMessage,
  371. type: "error"
  372. });
  373. this.fileLoading = false;
  374. },
  375. //确定上传
  376. submitUpload() {
  377. if (!this.checkUpload()) {
  378. return false;
  379. }
  380. this.$refs.upload.submit();
  381. this.fileLoading = true;
  382. },
  383. checkUpload() {
  384. var fileList = this.$refs.upload.uploadFiles;
  385. if (fileList.length == 0) {
  386. this.$notify({
  387. message: "上传文件不能为空",
  388. type: "error"
  389. });
  390. return false;
  391. }
  392. if (fileList.length > 1) {
  393. this.$notify({
  394. message: "每次只能上传一个文件",
  395. type: "error"
  396. });
  397. return false;
  398. }
  399. for (let file of fileList) {
  400. if (!file.name.endsWith(".xlsx")) {
  401. this.$notify({
  402. message: "上传文件必须为xlsx格式",
  403. type: "error"
  404. });
  405. this.initUpload();
  406. return false;
  407. }
  408. }
  409. return true;
  410. },
  411. //清空文件
  412. removeFile() {
  413. this.fileList = [];
  414. },
  415. //下载模板
  416. exportFile() {
  417. var key = this.user.key;
  418. var token = this.user.token;
  419. window.location.href =
  420. "/api/ecs_data_process/markTasks/export?$key=" +
  421. key +
  422. "&$token=" +
  423. token;
  424. },
  425. //下载课程列表
  426. exportCourse() {
  427. var key = this.user.key;
  428. var token = this.user.token;
  429. window.location.href =
  430. "/api/ecs_marking/markCourses/export?workId=" +
  431. this.workId +
  432. "&$key=" +
  433. key +
  434. "&$token=" +
  435. token;
  436. }
  437. },
  438. computed: {
  439. ...mapState({ user: state => state.user }),
  440. courseAllListSelect() {
  441. let courseSelect = [];
  442. for (let course of this.courseList) {
  443. let courseInfo = course.name + "(" + course.code + ")";
  444. courseSelect.push({ code: course.code, courseInfo: courseInfo });
  445. }
  446. return courseSelect;
  447. }
  448. },
  449. created() {
  450. this.workId = this.$route.params.workId;
  451. this.examId = this.$route.params.examId;
  452. this.examName = this.$route.params.name;
  453. this.uploadData.workId = this.workId;
  454. this.uploadHeaders = {
  455. key: this.user.key,
  456. token: this.user.token
  457. };
  458. this.initSetting();
  459. this.getCourses();
  460. }
  461. };
  462. </script>
  463. <style lang="css" scoped>
  464. li {
  465. list-style-type: none;
  466. }
  467. .searchFrame {
  468. margin-right: 10px;
  469. margin-bottom: 10px;
  470. }
  471. .page{
  472. margin-top: 10px;
  473. }
  474. .f_button{
  475. display:block;
  476. width:57px;
  477. height:20px;
  478. border:1px solid #CCC;
  479. background:#FFF;
  480. font-size: small;
  481. }
  482. </style>