MarkSettingMain.vue 14 KB

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