markPaperClass.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. <template>
  2. <div class="mark-paper-class">
  3. <div class="box-justify mb-2">
  4. <div>
  5. <span>分班阅卷:</span>
  6. <el-switch
  7. v-model="openClassReading"
  8. @change="openClassReadingChange"
  9. ></el-switch>
  10. </div>
  11. <mark-status class="mr-4" field="markerClass"></mark-status>
  12. </div>
  13. <div v-if="openClassReading" class="part-box part-box-pad">
  14. <el-table :data="markerClassList" border>
  15. <el-table-column type="index" width="50"> </el-table-column>
  16. <el-table-column label="评卷员" width="200">
  17. <template slot-scope="scope">
  18. <el-tag class="tag-spin" size="medium">
  19. {{ scope.row.name }}({{ scope.row.orgName }})
  20. </el-tag>
  21. </template>
  22. </el-table-column>
  23. <el-table-column label="评卷班级">
  24. <template slot-scope="scope">
  25. <el-tag
  26. v-for="item in scope.row.className"
  27. :key="item"
  28. size="medium"
  29. type="info"
  30. class="mb-1 mr-1"
  31. >
  32. {{ item }}
  33. </el-tag>
  34. </template>
  35. </el-table-column>
  36. <el-table-column class-name="action-column" label="操作" width="100">
  37. <template slot-scope="scope">
  38. <el-button
  39. class="btn-primary"
  40. type="text"
  41. @click="toEditClass(scope.row)"
  42. >选择班级</el-button
  43. >
  44. </template>
  45. </el-table-column>
  46. </el-table>
  47. </div>
  48. <!-- SelectClassByCourse -->
  49. <select-class-by-course
  50. ref="SelectClassByCourse"
  51. :filter-data="{
  52. examId: datas.basicPaperInfo.examId,
  53. paperNumber: datas.basicPaperInfo.paperNumber,
  54. }"
  55. :selected-ids="selectedClassIds"
  56. :disable-ids="disabledClassIds"
  57. @confirm="classSelected"
  58. ></select-class-by-course>
  59. </div>
  60. </template>
  61. <script>
  62. import SelectClassByCourse from "../SelectClassByCourse.vue";
  63. import MarkStatus from "./MarkStatus.vue";
  64. export default {
  65. name: "mark-paper-class",
  66. components: {
  67. SelectClassByCourse,
  68. MarkStatus,
  69. },
  70. props: {
  71. datas: {
  72. type: Object,
  73. default() {
  74. return {
  75. classInfo: [],
  76. groupInfo: [],
  77. basicPaperInfo: {},
  78. };
  79. },
  80. },
  81. },
  82. data() {
  83. return {
  84. openClassReading: false,
  85. markerClassList: [],
  86. curMarkClass: {},
  87. selectedClassIds: [],
  88. disabledClassIds: [],
  89. casheMarkerClass: {},
  90. };
  91. },
  92. mounted() {
  93. this.initData();
  94. },
  95. methods: {
  96. initData() {
  97. this.openClassReading = this.datas.basicPaperInfo.openClassReading;
  98. if (!this.openClassReading) return;
  99. this.markerClassList = this.datas.classInfo.map((item) => {
  100. let nitem = { ...item };
  101. nitem.className = nitem.className ? nitem.className.split(",") : [];
  102. return nitem;
  103. });
  104. this.updateCasheMarkerClass();
  105. this.initMarkerClassList();
  106. },
  107. groupChange() {
  108. if (!this.openClassReading) return;
  109. this.updateCasheMarkerClass();
  110. this.initMarkerClassList();
  111. },
  112. openClassReadingChange(val) {
  113. if (val) {
  114. this.initMarkerClassList();
  115. } else {
  116. this.updateCasheMarkerClass();
  117. this.markerClassList = [];
  118. }
  119. },
  120. initMarkerClassList() {
  121. let markerClassList = [];
  122. let markIds = [];
  123. this.datas.groupInfo.forEach((group) => {
  124. group.markerList.forEach((marker) => {
  125. if (markIds.includes(marker.id)) return;
  126. markIds.push(marker.id);
  127. markerClassList.push({
  128. id: marker.id,
  129. loginName: marker.loginName,
  130. name: marker.name,
  131. orgName: marker.orgName,
  132. className: this.casheMarkerClass[marker.id] || [],
  133. });
  134. });
  135. });
  136. this.markerClassList = markerClassList;
  137. },
  138. updateCasheMarkerClass() {
  139. let casheMarkerClass = {};
  140. this.markerClassList.forEach((item) => {
  141. casheMarkerClass[item.id] = item.className;
  142. });
  143. this.casheMarkerClass = casheMarkerClass;
  144. },
  145. toEditClass(row) {
  146. this.curMarkClass = row;
  147. this.selectedClassIds = row.className;
  148. this.$refs.SelectClassByCourse.open();
  149. },
  150. classSelected(className) {
  151. this.curMarkClass.className = className;
  152. },
  153. checkData() {
  154. let errorMessages = [];
  155. if (!this.openClassReading) return errorMessages;
  156. this.markerClassList.forEach((item) => {
  157. if (!item.className.length) {
  158. errorMessages.push(`评卷员${item.name}的阅卷班级没有设置`);
  159. }
  160. });
  161. return errorMessages;
  162. },
  163. getData() {
  164. return {
  165. openClassReading: this.openClassReading,
  166. classInfo: this.markerClassList.map((item) => {
  167. let nitem = { ...item };
  168. nitem.className = item.className.join();
  169. return nitem;
  170. }),
  171. };
  172. },
  173. },
  174. };
  175. </script>