dispatch-table.vue 5.0 KB

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