MarkSettingMain.vue 14 KB

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