MarkParamClass.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. <template>
  2. <div class="mark-param-class">
  3. <div class="box-justify part-box part-box-pad">
  4. <div></div>
  5. <div>
  6. <el-button type="primary" @click="toImport">导入</el-button>
  7. </div>
  8. </div>
  9. <div class="part-box part-box-pad">
  10. <el-table :data="classList" border>
  11. <el-table-column type="index" width="50"> </el-table-column>
  12. <el-table-column label="班级">
  13. <template slot-scope="scope">
  14. <el-tag size="medium" type="info">
  15. {{ scope.row.className }}
  16. </el-tag>
  17. </template>
  18. </el-table-column>
  19. <el-table-column label="评阅题目" prop="groupQuestions" width="200">
  20. </el-table-column>
  21. <el-table-column label="评卷员" width="200">
  22. <template slot-scope="scope">
  23. <el-tag
  24. v-for="item in scope.row.classMarkerList"
  25. :key="item"
  26. size="medium"
  27. type="info"
  28. class="mb-1 mr-1"
  29. >
  30. {{ scope.row.name }}({{ scope.row.orgName }})
  31. </el-tag>
  32. </template>
  33. </el-table-column>
  34. <el-table-column class-name="action-column" label="操作" width="120">
  35. <template slot-scope="scope">
  36. <el-button
  37. class="btn-primary"
  38. type="text"
  39. @click="toSelectMarker(scope.row)"
  40. >选择评卷员</el-button
  41. >
  42. </template>
  43. </el-table-column>
  44. </el-table>
  45. </div>
  46. <!-- 选择评卷员 -->
  47. <el-dialog
  48. :visible.sync="modalIsShow"
  49. title="选择评卷员"
  50. top="10px"
  51. width="600px"
  52. :close-on-click-modal="false"
  53. :close-on-press-escape="false"
  54. append-to-body
  55. >
  56. <el-form ref="modalFormComp" :model="modalForm" :rules="rules">
  57. <el-form-item prop="selectedMarkerIds">
  58. <el-checkbox-group v-model="modalForm.selectedMarkerIds">
  59. <el-checkbox
  60. v-for="mark in curClass.markerList"
  61. :key="mark.userId"
  62. :label="mark.userId"
  63. >
  64. {{ mark.name }}({{ mark.orgName }})
  65. </el-checkbox>
  66. </el-checkbox-group>
  67. </el-form-item>
  68. </el-form>
  69. <div slot="footer">
  70. <el-button type="primary" :disabled="isSubmit" @click="conform"
  71. >确认</el-button
  72. >
  73. <el-button @click="modalIsShow = false">取消</el-button>
  74. </div>
  75. </el-dialog>
  76. </div>
  77. </template>
  78. <script>
  79. import { markClassList, markClassSave } from "../../api";
  80. import { mapState } from "vuex";
  81. export default {
  82. name: "mark-param-class",
  83. components: {},
  84. data() {
  85. return {
  86. classList: [],
  87. curClass: {},
  88. // modify
  89. modalIsShow: false,
  90. isSubmit: false,
  91. modalForm: { selectedMarkerIds: [] },
  92. rules: {
  93. selectedMarkerIds: [
  94. {
  95. required: true,
  96. validator: (rule, value, callback) => {
  97. if (!value.length) {
  98. callback(new Error("请选择评卷员"));
  99. } else {
  100. callback();
  101. }
  102. },
  103. trigger: "change",
  104. },
  105. ],
  106. },
  107. };
  108. },
  109. computed: {
  110. ...mapState("markParam", ["basicInfo", "paperStructureInfo"]),
  111. },
  112. mounted() {
  113. this.initData();
  114. },
  115. methods: {
  116. async initData() {
  117. const params = {
  118. examId: this.basicInfo.examId,
  119. paperNumber: this.basicInfo.paperNumber,
  120. };
  121. const res = await markClassList(params);
  122. this.classList = res || [];
  123. },
  124. toSelectMarker(row) {
  125. this.curClass = row;
  126. this.modalIsShow = true;
  127. },
  128. toImport() {
  129. // TODO:
  130. },
  131. async conform() {
  132. const valid = await this.$refs.modalFormComp.validate().catch(() => {});
  133. if (!valid) return;
  134. this.isSubmit = true;
  135. const classMarkerList = this.curClass.markerList.filter((item) =>
  136. this.modalForm.selectedMarkerIds.includes(item.userId)
  137. );
  138. const res = await markClassSave({
  139. examId: this.basicInfo.examId,
  140. paperNumber: this.basicInfo.paperNumber,
  141. className: this.curClass.className,
  142. groupNumber: this.curClass.groupNumber,
  143. classMarkerList,
  144. }).catch(() => {});
  145. this.isSubmit = false;
  146. if (!res) return;
  147. this.$message.success("操作成功!");
  148. this.curClass.classMarkerList = classMarkerList;
  149. this.modalIsShow = false;
  150. },
  151. getData() {
  152. return {
  153. openClassReading: this.openClassReading,
  154. classInfo: this.markerClassList.map((item) => {
  155. let nitem = { ...item };
  156. nitem.className = item.className.join();
  157. return nitem;
  158. }),
  159. };
  160. },
  161. },
  162. };
  163. </script>