MarkSettingMain.vue 14 KB

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