SyncPaperDialog.vue 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. <template>
  2. <el-dialog
  3. :visible.sync="modalIsShow"
  4. title="同步成绩"
  5. top="10vh"
  6. width="500px"
  7. :close-on-click-modal="false"
  8. :close-on-press-escape="false"
  9. append-to-body
  10. @open="visibleChange"
  11. >
  12. <el-form ref="modalFormComp" :model="modalForm" label-width="60px">
  13. <el-form-item
  14. prop="paperNumber"
  15. label="试卷:"
  16. :rules="{
  17. required: true,
  18. message: '请选择试卷',
  19. trigger: 'change',
  20. }"
  21. >
  22. <el-select
  23. v-model="modalForm.paperNumber"
  24. placeholder="选择试卷"
  25. clearable
  26. class="width-full"
  27. >
  28. <el-option
  29. v-for="paper in papers"
  30. :key="paper.paperNumber"
  31. :value="paper.paperNumber"
  32. :label="paper.paperNumber"
  33. ></el-option>
  34. </el-select>
  35. </el-form-item>
  36. </el-form>
  37. <div slot="footer">
  38. <el-button type="primary" :disabled="isSubmit" @click="submit"
  39. >确认</el-button
  40. >
  41. <el-button @click="cancel">取消</el-button>
  42. </div>
  43. </el-dialog>
  44. </template>
  45. <script>
  46. import { endScoreSyncPaperList, endScoreSync } from "../../api";
  47. export default {
  48. name: "SyncPaperDialog",
  49. props: {
  50. course: {
  51. type: Object,
  52. default() {
  53. return {};
  54. },
  55. },
  56. },
  57. data() {
  58. return {
  59. modalIsShow: false,
  60. isSubmit: false,
  61. modalForm: { paperNumber: "" },
  62. papers: [],
  63. };
  64. },
  65. methods: {
  66. async getPapers() {
  67. if (this.papers.length) return;
  68. const res = await endScoreSyncPaperList(this.course);
  69. this.papers = res || [];
  70. },
  71. visibleChange() {
  72. this.getPapers();
  73. this.modalForm = { paperNumber: "" };
  74. },
  75. cancel() {
  76. this.modalIsShow = false;
  77. },
  78. open() {
  79. this.modalIsShow = true;
  80. },
  81. async submit() {
  82. const valid = await this.$refs.modalFormComp.validate().catch(() => {});
  83. if (!valid) return;
  84. if (this.isSubmit) return;
  85. this.isSubmit = true;
  86. const datas = {
  87. cultureProgramId: this.course.cultureProgramId,
  88. courseId: this.course.courseId,
  89. teachCourseId: this.course.teachCourseId,
  90. paperNumber: this.modalForm.paperNumber,
  91. };
  92. const res = await endScoreSync(datas).catch(() => {});
  93. this.isSubmit = false;
  94. if (!res) return;
  95. this.$message.success(`${res.success},错误:${res.error}`);
  96. this.$emit("modified");
  97. this.cancel();
  98. },
  99. },
  100. };
  101. </script>