MarkWork.vue 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752
  1. <template>
  2. <div>
  3. <section class="content">
  4. <div>
  5. <div>
  6. <el-form
  7. :inline="true"
  8. :model="formSearch"
  9. label-position="right"
  10. label-width="100px"
  11. @submit.native.prevent
  12. >
  13. <el-form-item label="评卷工作名称" class="pull-left">
  14. <el-input
  15. placeholder="评卷工作名称"
  16. v-model="formSearch.name"
  17. @keyup.native="searchMarkWork"
  18. ></el-input>
  19. </el-form-item>
  20. <el-form-item>
  21. <span>
  22. <el-button
  23. size="small"
  24. type="primary"
  25. icon="el-icon-plus"
  26. @click="addMarkWorkModal"
  27. >新增</el-button
  28. >
  29. </span>
  30. </el-form-item>
  31. </el-form>
  32. <div class="block-seperator"></div>
  33. <el-table
  34. stripe
  35. v-loading="loading"
  36. element-loading-text="拼命加载中"
  37. :data="tableData"
  38. border
  39. style="width: 100%;"
  40. >
  41. <el-table-column label="评卷工作名称" width="150">
  42. <template slot-scope="scope">
  43. <div>
  44. <span>{{ scope.row.name }}</span>
  45. </div>
  46. </template>
  47. </el-table-column>
  48. <el-table-column label="考试名称-类型" width="300">
  49. <template slot-scope="scope">
  50. <div>
  51. <span
  52. style="display: block;"
  53. v-for="item in scope.row.examNameAndType"
  54. :key="item.index"
  55. >{{ item }}</span
  56. >
  57. </div>
  58. </template>
  59. </el-table-column>
  60. <el-table-column
  61. label="进度(%)"
  62. width="100"
  63. prop="progress"
  64. sortable
  65. >
  66. </el-table-column>
  67. <el-table-column label="备注" width="100">
  68. <template slot-scope="scope">
  69. <div>
  70. <span>{{ scope.row.remark }}</span>
  71. </div>
  72. </template>
  73. </el-table-column>
  74. <el-table-column label="状态" width="100">
  75. <template slot-scope="scope">
  76. <div>
  77. <span>{{ getStatus(scope.row.status) }}</span>
  78. </div>
  79. </template>
  80. </el-table-column>
  81. <el-table-column label="评卷是否结束" width="130">
  82. <template slot-scope="scope">
  83. <div>
  84. <span>{{ getIsEndText(scope.row.isEnd) }}</span>
  85. </div>
  86. </template>
  87. </el-table-column>
  88. <el-table-column label="操作">
  89. <template slot-scope="scope">
  90. <div class="pull-left">
  91. <el-button
  92. @click="settingMarkWork(scope.row)"
  93. type="primary"
  94. size="mini"
  95. plain
  96. >评卷设置</el-button
  97. >
  98. <el-dropdown
  99. style="margin-left: 10px;"
  100. placement="bottom-start"
  101. >
  102. <el-button size="mini" type="primary" plain>
  103. 更多 <i class="el-icon-arrow-down el-icon--right"></i>
  104. </el-button>
  105. <el-dropdown-menu slot="dropdown">
  106. <el-dropdown-item v-if="scope.row.status == 2">
  107. <el-button
  108. @click="recreate(scope.row)"
  109. type="primary"
  110. size="mini"
  111. plain
  112. >重新创建</el-button
  113. >
  114. </el-dropdown-item>
  115. <el-dropdown-item>
  116. <el-button
  117. @click="editMarkWorkModal(scope.row)"
  118. type="primary"
  119. size="mini"
  120. icon="el-icon-edit"
  121. plain
  122. >编辑</el-button
  123. >
  124. </el-dropdown-item>
  125. <el-dropdown-item>
  126. <el-button
  127. @click="delMarkWork(scope.row)"
  128. type="danger"
  129. size="mini"
  130. icon="el-icon-delete"
  131. >删除</el-button
  132. >
  133. </el-dropdown-item>
  134. <el-dropdown-item>
  135. <el-button
  136. @click="pubGrade(scope.row)"
  137. size="mini"
  138. icon="el-icon-bell"
  139. >成绩发布</el-button
  140. >
  141. </el-dropdown-item>
  142. <el-dropdown-item
  143. v-if="!scope.row.isEnd && scope.row.status == 1"
  144. >
  145. <el-button
  146. @click="endMarkWork(scope.row)"
  147. type="primary"
  148. size="mini"
  149. plain
  150. >结束评卷</el-button
  151. >
  152. </el-dropdown-item>
  153. <el-dropdown-item
  154. v-if="scope.row.isEnd && scope.row.status == 1"
  155. >
  156. <el-button
  157. @click="disendMarkWork(scope.row)"
  158. type="primary"
  159. size="mini"
  160. plain
  161. >开启评卷</el-button
  162. >
  163. </el-dropdown-item>
  164. </el-dropdown-menu>
  165. </el-dropdown>
  166. </div>
  167. </template>
  168. </el-table-column>
  169. </el-table>
  170. <div class="page pull-right">
  171. <el-pagination
  172. background
  173. @current-change="handleCurrentChange"
  174. @size-change="handleSizeChange"
  175. :current-page="currentPage"
  176. :page-size="pageSize"
  177. :page-sizes="[10, 20, 50, 100, 200, 300]"
  178. layout="total, sizes, prev, pager, next, jumper"
  179. :total="total"
  180. ></el-pagination>
  181. </div>
  182. <el-dialog
  183. @open="openModal"
  184. @close="closeModal"
  185. :title="examTitle"
  186. v-loading="loading"
  187. element-loading-text="拼命加载中"
  188. :visible.sync="markWorkDialog"
  189. width="500px"
  190. >
  191. <el-form
  192. :model="formMarkWork"
  193. label-width="120px"
  194. :rules="rules"
  195. ref="formMarkWork"
  196. inline
  197. inline-message
  198. >
  199. <el-form-item label="评卷工作名称" prop="name">
  200. <el-input
  201. placeholder="评卷工作名称"
  202. v-model="formMarkWork.name"
  203. style="width: 200px;"
  204. ></el-input>
  205. </el-form-item>
  206. <el-form-item
  207. label="考试类型"
  208. prop="examType"
  209. v-if="!examDisabled"
  210. >
  211. <el-select
  212. v-model="formMarkWork.examType"
  213. style="width: 200px;"
  214. @change="examTypeChange()"
  215. >
  216. <el-option label="在线考试" value="ONLINE"> </el-option>
  217. <el-option label="离线考试" value="OFFLINE"> </el-option>
  218. <el-option label="在线作业" value="ONLINE_HOMEWORK">
  219. </el-option>
  220. </el-select>
  221. </el-form-item>
  222. <el-form-item label="考试" prop="examIds">
  223. <el-select
  224. :disabled="examDisabled"
  225. v-model="formMarkWork.examIds"
  226. filterable
  227. multiple
  228. placeholder="考试"
  229. style="width: 200px;"
  230. >
  231. <el-option
  232. v-for="item in examSelect"
  233. :label="item.label"
  234. :value="item.value"
  235. :key="item.value"
  236. ></el-option>
  237. </el-select>
  238. </el-form-item>
  239. <el-form-item label="备注" prop="remark">
  240. <el-input
  241. style="width: 200px;"
  242. type="textarea"
  243. :rows="3"
  244. placeholder="备注"
  245. v-model="formMarkWork.remark"
  246. ></el-input>
  247. </el-form-item>
  248. <el-form-item style="margin-top: 10px; margin-left: 100px;">
  249. <el-button
  250. :loading="saveLoading"
  251. type="primary"
  252. @click="saveMarkWork"
  253. >保存</el-button
  254. >
  255. <el-button @click="closeMarkWork">取消</el-button>
  256. <el-button @click="resetForm">重置</el-button>
  257. </el-form-item>
  258. </el-form>
  259. </el-dialog>
  260. </div>
  261. </div>
  262. </section>
  263. </div>
  264. </template>
  265. <script>
  266. import { mapState } from "vuex";
  267. import { MARKING_API, DATA_PROCESS_API } from "@/constants/constants";
  268. export default {
  269. data() {
  270. return {
  271. formSearch: {
  272. name: ""
  273. },
  274. formMarkWork: {
  275. examType: "",
  276. name: "",
  277. examIds: [],
  278. remark: ""
  279. },
  280. rules: {
  281. name: [{ required: true, message: "请输入名称", trigger: "blur" }],
  282. examIds: [
  283. {
  284. required: true,
  285. message: "请选择考试",
  286. trigger: "change",
  287. type: "array"
  288. }
  289. ],
  290. examType: [
  291. {
  292. required: true,
  293. message: "请选择考试类型",
  294. trigger: "change",
  295. type: "string"
  296. }
  297. ]
  298. },
  299. statusList: [
  300. { code: 0, name: "创建中" },
  301. { code: 1, name: "创建成功" },
  302. { code: 2, name: "创建失败" },
  303. { code: 3, name: "追加中" }
  304. ],
  305. examSelect: [],
  306. tableData: [],
  307. totalTableData: [],
  308. currentPage: 1,
  309. pageSize: 10,
  310. total: 0,
  311. markWorkDialog: false,
  312. markWorkId: "",
  313. examDisabled: false,
  314. examTitle: "",
  315. loading: false,
  316. closeClickModal: false,
  317. saveLoading: false,
  318. oldWorkName: ""
  319. };
  320. },
  321. computed: {
  322. ...mapState({ user: state => state.user })
  323. },
  324. methods: {
  325. settingMarkWork(row) {
  326. if (Number.parseInt(row.status) != 1) {
  327. this.$notify({
  328. message: "该评卷工作未完成,不能进行设置.",
  329. type: "warning"
  330. });
  331. return;
  332. }
  333. var url =
  334. "/marking/mark_setting_main/" +
  335. row.id +
  336. "/" +
  337. encodeURIComponent(row.name);
  338. this.$router.push({
  339. path: url
  340. });
  341. },
  342. getStatus(code) {
  343. for (let status of this.statusList) {
  344. if (status.code == code) {
  345. return status.name;
  346. }
  347. }
  348. },
  349. getIsEndText(isEnd) {
  350. if (isEnd) {
  351. return "已结束";
  352. } else {
  353. return "未结束";
  354. }
  355. },
  356. appendPaper(row) {
  357. this.loading = true;
  358. this.$http
  359. .put(DATA_PROCESS_API + "/markWorks/append-paper/" + row.id)
  360. .then(() => {
  361. this.$notify({
  362. message: "操作成功",
  363. type: "success"
  364. });
  365. this.initMarkWorkData();
  366. this.loading = false;
  367. });
  368. },
  369. recreate(row) {
  370. this.loading = true;
  371. this.$http.put(DATA_PROCESS_API + "/markWorks/" + row.id).then(() => {
  372. this.$notify({
  373. message: "操作成功",
  374. type: "success"
  375. });
  376. this.initMarkWorkData();
  377. this.loading = false;
  378. });
  379. },
  380. examTypeChange() {
  381. this.examSelect = [];
  382. this.formMarkWork.examIds = [];
  383. if (this.formMarkWork.examType) {
  384. this.getExamSelect();
  385. }
  386. },
  387. getExamSelect() {
  388. var orgId = this.user.rootOrgId;
  389. var examIds = this.formMarkWork.examIds;
  390. var tempSelect = [];
  391. //this.loading = true;
  392. var params = "?orgId=" + orgId;
  393. if (examIds) {
  394. params = params + "&examIds=" + examIds;
  395. }
  396. if (this.formMarkWork.examType) {
  397. params = params + "&examType=" + this.formMarkWork.examType;
  398. }
  399. this.$http.get(DATA_PROCESS_API + "/exam/all" + params).then(response => {
  400. response.data.forEach((element, index) => {
  401. tempSelect[index] = {
  402. value: element.id,
  403. label: element.name
  404. };
  405. });
  406. this.examSelect = tempSelect;
  407. //this.loading = false;
  408. });
  409. },
  410. initMarkWorkData() {
  411. var orgId = this.user.rootOrgId;
  412. this.loading = true;
  413. this.$http
  414. .get(DATA_PROCESS_API + "/markWorks?orgId=" + orgId)
  415. .then(response => {
  416. console.log(response);
  417. this.totalTableData = response.data;
  418. this.total = response.data.length;
  419. this.filterMarkWork();
  420. this.paging();
  421. this.loading = false;
  422. this.getWorkStatus();
  423. });
  424. },
  425. getWorkStatus() {
  426. let creatingWorkIds = this.getCreatingWorkId();
  427. if (creatingWorkIds != "") {
  428. this.$httpWithoutBar
  429. .get(
  430. MARKING_API + "/markWorks/getWorkList?workIds=" + creatingWorkIds
  431. )
  432. .then(response => {
  433. response.data.forEach(element => {
  434. if (element.status != 0) {
  435. this.tableData.forEach(e => {
  436. if (e.id == element.id) {
  437. e.status = element.status;
  438. }
  439. });
  440. }
  441. });
  442. setTimeout(() => {
  443. this.getWorkStatus();
  444. }, 30000);
  445. });
  446. }
  447. },
  448. getCreatingWorkId() {
  449. var tempData = [];
  450. this.tableData.forEach(element => {
  451. if (element.status == 0) {
  452. tempData.push(element.id);
  453. }
  454. });
  455. return tempData.join(",");
  456. },
  457. searchMarkWork() {
  458. this.filterMarkWork();
  459. this.paging();
  460. },
  461. filterMarkWork() {
  462. var tempData = this.totalTableData.filter(element => {
  463. if (this.formSearch.name) {
  464. return element.name.includes(this.formSearch.name);
  465. } else {
  466. return true;
  467. }
  468. });
  469. this.tableData = tempData;
  470. this.total = tempData.length;
  471. },
  472. paging() {
  473. var start = (this.currentPage - 1) * this.pageSize;
  474. var end =
  475. this.currentPage * this.pageSize < this.total
  476. ? this.currentPage * this.pageSize
  477. : this.total;
  478. var tempData = [];
  479. console.log(`当前页: ${this.currentPage},开始:${start},结束:${end}`);
  480. for (let i = start; i < end; i++) {
  481. tempData.push(this.tableData[i]);
  482. }
  483. this.tableData = tempData;
  484. },
  485. openModal() {
  486. console.log("open");
  487. },
  488. closeModal() {
  489. console.log("close");
  490. },
  491. addMarkWorkModal() {
  492. this.formMarkWork = { name: "", remark: "", examType: "", examIds: [] };
  493. this.examSelect = [];
  494. this.markWorkId = "";
  495. this.examDisabled = false;
  496. this.examTitle = "新增评卷工作";
  497. this.oldWorkName = "";
  498. if (this.$refs["formMarkWork"] !== undefined) {
  499. this.$refs["formMarkWork"].resetFields();
  500. }
  501. this.markWorkDialog = true;
  502. },
  503. editMarkWorkModal(row) {
  504. this.examTitle = "编辑评卷工作";
  505. this.formMarkWork = Object.assign({}, row);
  506. this.oldWorkName = this.formMarkWork.name;
  507. this.markWorkId = row.id;
  508. this.getExamSelect();
  509. this.loading = false;
  510. this.examDisabled = true;
  511. this.markWorkDialog = true;
  512. },
  513. delMarkWork(row) {
  514. if (Number.parseInt(row.status) == 0) {
  515. this.$notify({
  516. message: "创建中的评卷工作不能删除!",
  517. type: "error"
  518. });
  519. return;
  520. }
  521. this.$confirm("确认删除评卷工作?", "提示", {
  522. confirmButtonText: "确定",
  523. cancelButtonText: "取消",
  524. type: "warning"
  525. }).then(() => {
  526. this.loading = true;
  527. this.$http
  528. .delete(MARKING_API + "/markWorks/" + row.id)
  529. .then(() => {
  530. this.$notify({
  531. message: "删除成功",
  532. type: "success"
  533. });
  534. this.initMarkWorkData();
  535. })
  536. .catch(e => {
  537. this.$notify({
  538. message: e.response.data.desc,
  539. type: "error"
  540. });
  541. });
  542. this.loading = false;
  543. });
  544. },
  545. endMarkWork(row) {
  546. this.$confirm("确认结束评卷工作?", "提示", {
  547. confirmButtonText: "确定",
  548. cancelButtonText: "取消",
  549. type: "warning"
  550. }).then(() => {
  551. this.loading = true;
  552. this.$http
  553. .put(MARKING_API + "/markWorks/end/" + row.id)
  554. .then(() => {
  555. this.$notify({
  556. message: "操作成功",
  557. type: "success"
  558. });
  559. this.initMarkWorkData();
  560. })
  561. .catch(e => {
  562. this.$notify({
  563. message: e.response.data.desc,
  564. type: "error"
  565. });
  566. });
  567. this.loading = false;
  568. });
  569. },
  570. disendMarkWork(row) {
  571. this.$confirm("确认开启评卷工作?", "提示", {
  572. confirmButtonText: "确定",
  573. cancelButtonText: "取消",
  574. type: "warning"
  575. }).then(() => {
  576. this.loading = true;
  577. this.$http
  578. .put(MARKING_API + "/markWorks/disend/" + row.id)
  579. .then(() => {
  580. this.$notify({
  581. message: "操作成功",
  582. type: "success"
  583. });
  584. this.initMarkWorkData();
  585. })
  586. .catch(e => {
  587. this.$notify({
  588. message: e.response.data.desc,
  589. type: "error"
  590. });
  591. });
  592. this.loading = false;
  593. });
  594. },
  595. pubGrade(row) {
  596. if (!(Number.parseInt(row.progress) == 100)) {
  597. this.$notify({
  598. message: "进度未达到100%,不能进行成绩发布",
  599. type: "error"
  600. });
  601. return;
  602. }
  603. this.$confirm("确认成绩发布?", "提示", {
  604. confirmButtonText: "确定",
  605. cancelButtonText: "取消",
  606. type: "warning"
  607. }).then(() => {
  608. this.loading = true;
  609. this.$http.post(MARKING_API + "/markWorks/" + row.id + "/publish").then(
  610. () => {
  611. this.$notify({
  612. message: "成绩发布成功",
  613. type: "success"
  614. });
  615. },
  616. () => {
  617. this.$notify({
  618. message: "成绩发布失败",
  619. type: "error"
  620. });
  621. }
  622. );
  623. this.initMarkWorkData();
  624. this.loading = false;
  625. });
  626. },
  627. checkWorkName(workName) {
  628. for (let workList of this.totalTableData) {
  629. if (workList.name == workName) {
  630. this.$notify({
  631. message: "评卷工作名称已存在,请重新输入!",
  632. type: "warning"
  633. });
  634. return true;
  635. }
  636. }
  637. return false;
  638. },
  639. saveMarkWork() {
  640. this.$refs.formMarkWork.validate(valid => {
  641. if (valid) {
  642. var newWorkName = this.formMarkWork.name;
  643. if (newWorkName != this.oldWorkName) {
  644. if (this.checkWorkName(newWorkName)) {
  645. return;
  646. }
  647. }
  648. this.saveLoading = true;
  649. this.oldWorkName = "";
  650. this.loading = true;
  651. if (this.markWorkId) {
  652. this.$http
  653. .put(
  654. MARKING_API + "/markWorks/" + this.markWorkId,
  655. this.formMarkWork
  656. )
  657. .then(
  658. () => {
  659. this.$notify({
  660. message: "评卷工作保存成功",
  661. type: "success"
  662. });
  663. this.closeMarkWork();
  664. this.initMarkWorkData();
  665. this.loading = false;
  666. this.saveLoading = false;
  667. },
  668. error => {
  669. this.$notify({
  670. message: error.response.data,
  671. type: "error"
  672. });
  673. this.loading = false;
  674. this.saveLoading = false;
  675. }
  676. );
  677. } else {
  678. this.$http
  679. .post(DATA_PROCESS_API + "/markWorks", this.formMarkWork)
  680. .then(
  681. () => {
  682. this.$notify({
  683. message: "评卷工作新增成功",
  684. type: "success"
  685. });
  686. this.closeMarkWork();
  687. this.initMarkWorkData();
  688. this.loading = false;
  689. this.saveLoading = false;
  690. },
  691. error => {
  692. this.$notify({
  693. message: error.response.data,
  694. type: "error"
  695. });
  696. this.loading = false;
  697. this.saveLoading = false;
  698. }
  699. );
  700. }
  701. } else {
  702. return false;
  703. }
  704. });
  705. },
  706. closeMarkWork() {
  707. this.markWorkDialog = false;
  708. },
  709. resetForm() {
  710. if (this.markWorkId) {
  711. //编辑
  712. this.formMarkWork = Object.assign(this.formMarkWork, {
  713. remark: "",
  714. name: ""
  715. });
  716. this.$refs["formMarkWork"].clearValidate();
  717. } else {
  718. //新增
  719. this.formMarkWork = Object.assign(this.formMarkWork, {
  720. remark: "",
  721. examName: "",
  722. name: ""
  723. });
  724. this.$refs["formMarkWork"].clearValidate();
  725. }
  726. },
  727. handleCurrentChange(val) {
  728. this.currentPage = val;
  729. this.filterMarkWork();
  730. this.paging();
  731. //this.searchMarkWork()
  732. },
  733. handleSizeChange(val) {
  734. this.pageSize = val;
  735. this.filterMarkWork();
  736. this.paging();
  737. }
  738. },
  739. created() {
  740. this.initMarkWorkData();
  741. }
  742. };
  743. </script>
  744. <style scoped>
  745. .el-button--mini {
  746. margin-left: 10px;
  747. }
  748. </style>