dispatch-table.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. <template>
  2. <el-row>
  3. <mx-table :propDefines="propDefines" :rows="displayRows">
  4. <template #classCount="{row,$index}">
  5. <el-input-number size="small" v-model="row.classCount" @change="classCountChange(row,$index)" :min="0"
  6. :disabled="row.classCount != 0" label="label"
  7. ></el-input-number>
  8. </template>
  9. <!-- 人数设定 -->
  10. <template #countSet="{row}">
  11. <el-button
  12. type="success"
  13. plain
  14. icon="el-icon-edit"
  15. size="mini"
  16. @click="editCount(row)"
  17. >设定
  18. </el-button>
  19. </template>
  20. <!-- 分班编辑-->
  21. <template #edit="{row}">
  22. <el-button
  23. type="success"
  24. plain
  25. icon="el-icon-edit"
  26. size="mini"
  27. @click="editClass(row)"
  28. >编辑
  29. </el-button>
  30. </template>
  31. <!-- 班级调整 -->
  32. <template #adjust="{row}">
  33. <el-button
  34. type="success"
  35. plain
  36. icon="el-icon-edit"
  37. size="mini"
  38. @click="adjust"
  39. >调整
  40. </el-button>
  41. </template>
  42. </mx-table>
  43. <choose-class :year="round.year" :roundId="round.roundId" ref="editClassDialog"></choose-class>
  44. <set-classcount ref="setClassDialog"></set-classcount>
  45. <class-adjust ref="adjustDialog"></class-adjust>
  46. </el-row>
  47. </template>
  48. <script>
  49. import MxClassTreeTranslateMixin from '@/components/Cache/modules/mx-classTree-translate-mixin.js'
  50. import MxSelectTranslateMixin from '@/components/Cache/modules/mx-select-translate-mixin.js'
  51. import ChooseClass from './choose-class'
  52. import ClassAdjust from './class-adjust'
  53. import SetClasscount from './set-classcount'
  54. export default {
  55. components: {
  56. ChooseClass,
  57. SetClasscount,
  58. ClassAdjust,
  59. },
  60. mixins: [MxClassTreeTranslateMixin, MxSelectTranslateMixin],
  61. props: {
  62. round: {
  63. type: Object,
  64. default: {},
  65. },
  66. settings: {
  67. type: Array,
  68. default: [],
  69. }
  70. },
  71. data() {
  72. return {
  73. settingList: [],
  74. dataList: [],
  75. propDefines: {
  76. groupName: {
  77. label: '组合'
  78. },
  79. number: {
  80. label: '录取人数'
  81. },
  82. classCount: {
  83. label: '班级数',
  84. slot: 'classCount'
  85. },
  86. edit: {
  87. label: '分班编辑',
  88. slot: 'edit'
  89. },
  90. groupClass: {
  91. label: '班级名称'
  92. },
  93. countSet: {
  94. label: '人数设定',
  95. slot: 'countSet'
  96. },
  97. expectedCount: {
  98. label: '人数'
  99. },
  100. adjust: {
  101. label: '操作',
  102. slot: 'adjust'
  103. }
  104. }
  105. }
  106. },
  107. computed: {
  108. displayRows() {
  109. if (!this.classTree.length) return []
  110. if (!this.listGroupsOptions.length) return []
  111. // if (!this.settings.length) return []
  112. if (!this.round.groupList) return []
  113. const rows = this.round.groupList.map(rg => ({
  114. groupId: rg.groupId,
  115. roundId: this.round.roundId,
  116. groupName: rg.name,
  117. number: this.round.enrollGroupCount[rg.groupId] || 200, // 录取人数
  118. classCount: rg.classCount || 5, // 班级数
  119. expectedCount: this.settings.filter(item => item.groupId == rg.groupId).map(item => item.expectedCount).toString(),
  120. groupClass: this.settings
  121. .filter(item => item.groupId == rg.groupId)
  122. .map(item => this.getClassName(item.classId)).toString()
  123. }))
  124. console.log('displayRows computed:', rows)
  125. return rows
  126. }
  127. },
  128. created() {
  129. },
  130. methods: {
  131. adjust() {
  132. this.$refs.adjustDialog.open()
  133. },
  134. editCount(row) {
  135. // 设定分配人数
  136. const filter = this.settings.filter(item => item.groupId == row.groupId)
  137. if (filter.length == 0) {
  138. this.$message.warning('班级未编辑')
  139. return
  140. }
  141. // if(){
  142. // this.$message.warning('需要选择')
  143. // }
  144. this.$refs.setClassDialog.open(row, this.settings)
  145. },
  146. classCountChange(newVal, index) {
  147. this.round.groupList[index] = newVal
  148. },
  149. editClass(row) {
  150. // 分配班级
  151. if (!row.classCount) {
  152. this.$message.warning('班级数为0时不可分班')
  153. return
  154. }
  155. // 获取分班配置
  156. // getSettings({
  157. // roundId: row.roundId
  158. // }).then(res => {
  159. // this.$refs.editClassDialog.open(row, res.data)
  160. // })
  161. this.$refs.editClassDialog.open(row, this.settings)
  162. }
  163. }
  164. }
  165. </script>
  166. <style scoped>
  167. </style>