setTeacher.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339
  1. <template>
  2. <div class='set-teacher'>
  3. <!-- <div class="allClassLis">
  4. <div class="allClassBtn"
  5. @click="getAllClassInfo(item.id)"
  6. :class="activeAllClass==item.id?'active':''"
  7. v-for="(item,index) in allList"
  8. :key='index'>
  9. {{ item.name }}
  10. </div>
  11. </div> -->
  12. <div class="tableWrap">
  13. <el-table :data='singinList'
  14. :header-cell-style="{background:'#EDEEF0',color:'#444'}">
  15. <el-table-column label="班级名称"
  16. prop='name'
  17. width="160px">
  18. </el-table-column>
  19. <el-table-column label="所属合奏班"
  20. prop='mixClassName'
  21. width="160px">
  22. </el-table-column>
  23. <el-table-column label="主教老师"
  24. width="200px">
  25. <template slot-scope="scope">
  26. <div>
  27. <el-select v-model="scope.row.coreTeacher"
  28. :disabled="isSetSalary"
  29. filterable
  30. clearable
  31. @change="setCoreTeacher"
  32. v-if='teacherList'>
  33. <el-option v-for='(item,index) in teacherList'
  34. :label="item.username"
  35. :key='index'
  36. :value="item.id"></el-option>
  37. </el-select>
  38. </div>
  39. </template>
  40. </el-table-column>
  41. <el-table-column label="
  42. 助教老师">
  43. <template slot-scope="scope">
  44. <div>
  45. <el-select class='tableClass'
  46. filterable
  47. @change="chioseAssistant(scope.row)"
  48. v-if='teacherList'
  49. :disabled="!scope.row.coreTeacher || isSetSalary"
  50. multiple
  51. v-model="scope.row.assistant">
  52. <el-option v-for='(item,index) in teacherList'
  53. :label="item.username"
  54. :key='index'
  55. :value="item.id"></el-option>
  56. </el-select>
  57. </div>
  58. </template>
  59. </el-table-column>
  60. </el-table>
  61. </div>
  62. <div class="tableWrap">
  63. <el-table :data='allList'
  64. :header-cell-style="{background:'#EDEEF0',color:'#444'}">
  65. <el-table-column label="合奏班名称"
  66. prop='name'
  67. width="160px">
  68. </el-table-column>
  69. <el-table-column label="主教老师"
  70. width="200px;">
  71. <template slot-scope="scope">
  72. <div>
  73. <el-select v-model="scope.row.coreTeacher"
  74. :disabled="isSetSalary"
  75. clearable
  76. filterable
  77. v-if='teacherList'>
  78. <el-option v-for='(item,index) in teacherList'
  79. :label="item.username"
  80. :key='index'
  81. :value="item.id"></el-option>
  82. </el-select>
  83. </div>
  84. </template>
  85. </el-table-column>
  86. <el-table-column label="
  87. 助教老师">
  88. <template slot-scope="scope">
  89. <div>
  90. <!-- v-if='scope.row.assistant' -->
  91. <el-select class='tableClass'
  92. @change="chioseAssistant(scope.row)"
  93. multiple
  94. filterable
  95. :disabled="!scope.row.coreTeacher || isSetSalary"
  96. v-model="scope.row.assistant">
  97. <el-option v-for='(item,index) in teacherList'
  98. :label="item.username"
  99. :key='index'
  100. :value="item.id"></el-option>
  101. </el-select>
  102. </div>
  103. </template>
  104. </el-table-column>
  105. </el-table>
  106. </div>
  107. <div class="footer">
  108. <!-- <div class="reset">返回修改</div> -->
  109. <div class="next"
  110. @click="gotoNext">下一步</div>
  111. </div>
  112. </div>
  113. </template>
  114. <script>
  115. import { getEveryClass, getTeacher, setTeamTeacher } from '@/api/buildTeam'
  116. export default {
  117. props: {
  118. teamid: {
  119. type: String,
  120. required: true
  121. },
  122. isSetSalary: {
  123. type: Boolean,
  124. required: true
  125. }
  126. },
  127. data () {
  128. return {
  129. singinList: [],
  130. allList: [],
  131. teacherList: [],
  132. classGroupTeacherMapperList: []
  133. // activeAllClass: ''
  134. }
  135. },
  136. mounted () {
  137. sessionStorage.setItem('setStep', 1)
  138. // 该乐团里所有的单技班与合奏班
  139. this.getEveryClass();
  140. // 获取所有的老师列表
  141. getTeacher().then(res => {
  142. if (res.code == 200) {
  143. this.teacherList = res.data;
  144. }
  145. })
  146. },
  147. methods: {
  148. // 根据合奏班id获取合奏班信息
  149. getEveryClass () {
  150. getEveryClass({ musicGroupId: this.teamid }).then(res => {
  151. let singinList = [];
  152. let allList = [];
  153. res.data.map(item => {
  154. // item.teacherList = {
  155. // coreTeacher: '',
  156. // assistant:[]
  157. // }
  158. item.coreTeacher = ''
  159. item.assistant = []
  160. if (item.classGroupTeacherMapperList && item.classGroupTeacherMapperList.length > 0) {
  161. //循环老师列表分配到不同的
  162. for (let i in item.classGroupTeacherMapperList) {
  163. if (item.classGroupTeacherMapperList[i].teacherRole == 'BISHOP') {
  164. item.coreTeacher = item.classGroupTeacherMapperList[i].userId
  165. } else if (item.classGroupTeacherMapperList[i].teacherRole == 'TEACHING') {
  166. item.assistant.push(item.classGroupTeacherMapperList[i].userId)
  167. }
  168. }
  169. }
  170. if (item.type == 'NORMAL') {
  171. singinList.push(item)
  172. }
  173. if (item.type == 'MIX') {
  174. allList.push(item)
  175. }
  176. })
  177. this.singinList = singinList;
  178. this.allList = allList;
  179. })
  180. },
  181. gotoNext () {
  182. // 点击下一步
  183. // console.log(this.singinList)
  184. if (this.isSetSalary) {
  185. this.$message.error('课酬确认后无法编辑')
  186. return;
  187. }
  188. let isTeacher = true;
  189. let isTeachers = []
  190. let singinListTeacher = []
  191. let allListTeacher = []
  192. // 验证单技班主教老师是否指认
  193. for (let i in this.singinList) {
  194. singinListTeacher.push(this.singinList[i].coreTeacher);
  195. singinListTeacher = singinListTeacher.concat(this.singinList[i].assistant)
  196. if (this.singinList[i].coreTeacher == '') {
  197. isTeachers.push(false)
  198. }
  199. }
  200. // if (singinListTeacher.length != [...new Set(singinListTeacher)].length) {
  201. // this.$message.error('存在老师设置冲突,请调整')
  202. // return
  203. // }
  204. for (let j in this.allList) {
  205. allListTeacher.push(this.allList[j].coreTeacher);
  206. allListTeacher = allListTeacher.concat(this.allList[j].assistant)
  207. if (this.allList[j].coreTeacher == '') {
  208. isTeachers.push(false)
  209. }
  210. }
  211. // if (allListTeacher.length != [...new Set(allListTeacher)].length) {
  212. // this.$message.error('存在老师设置冲突,请调整')
  213. // return
  214. // }
  215. isTeachers.filter(item => {
  216. isTeacher = isTeacher && item
  217. })
  218. if (!isTeacher) {
  219. this.$message.error('请确定每个班级都有主教老师')
  220. return;
  221. }
  222. // 开始拼接数据
  223. this.addDate(this.singinList);
  224. this.addDate(this.allList);
  225. setTeamTeacher(this.classGroupTeacherMapperList).then(res => {
  226. if (res.code == 200) {
  227. this.classGroupTeacherMapperList = [];
  228. this.$emit('gotoNav', 2);
  229. }
  230. })
  231. },
  232. addDate (arr) {
  233. for (let i in arr) {
  234. let obj = {}
  235. obj.classGroupId = arr[i].id;
  236. obj.musicGroupId = this.teamid;
  237. obj.teacherRole = 'BISHOP';
  238. obj.userId = arr[i].coreTeacher;
  239. this.classGroupTeacherMapperList.push(obj)
  240. for (let j in arr[i].assistant) {
  241. let obj = {}
  242. obj.classGroupId = arr[i].id;
  243. obj.musicGroupId = this.teamid;
  244. obj.teacherRole = 'TEACHING';
  245. obj.userId = arr[i].assistant[j];
  246. this.classGroupTeacherMapperList.push(obj)
  247. }
  248. }
  249. },
  250. setCoreTeacher (val) {
  251. },
  252. chioseAssistant (row) {
  253. for (let i in row.assistant) {
  254. if (row.assistant[i] == row.coreTeacher) {
  255. row.assistant = [];
  256. this.$message.error('同一个班主教助教不能相同')
  257. return
  258. }
  259. }
  260. }
  261. },
  262. }
  263. </script>
  264. <style lang="scss" scope>
  265. .set-teacher {
  266. box-sizing: border-box;
  267. padding: 30px 42px;
  268. background-color: #fff;
  269. min-height: 80vh;
  270. .allClassLis {
  271. display: inline-block;
  272. // flex-direction: row;
  273. // justify-content: flex-start;
  274. border: 4px solid #f97215;
  275. align-items: center;
  276. border-radius: 4px;
  277. margin-bottom: 24px;
  278. clear: both;
  279. .allClassBtn {
  280. width: 91px;
  281. height: 32px;
  282. line-height: 32px;
  283. background-color: #f97215;
  284. color: #fff;
  285. text-align: center;
  286. font-size: 14px;
  287. float: left;
  288. cursor: pointer;
  289. }
  290. .allClassBtn.active {
  291. width: 91px;
  292. height: 32px;
  293. line-height: 32px;
  294. background-color: #fff;
  295. color: #f97215;
  296. text-align: center;
  297. font-size: 14px;
  298. float: left;
  299. }
  300. }
  301. .tableClass {
  302. margin-right: 10px;
  303. }
  304. i {
  305. cursor: pointer;
  306. }
  307. .footer {
  308. margin-top: 50px;
  309. display: flex;
  310. flex-direction: row;
  311. justify-content: flex-end;
  312. > div {
  313. width: 120px;
  314. height: 40px;
  315. line-height: 40px;
  316. text-align: center;
  317. border-radius: 4px;
  318. color: #fff;
  319. cursor: pointer;
  320. }
  321. .reset {
  322. background-color: #14928a;
  323. margin-right: 20px;
  324. }
  325. .next {
  326. background-color: #444;
  327. }
  328. }
  329. }
  330. .tableClass.el-select {
  331. width: 100% !important;
  332. }
  333. </style>