improvementClass.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421
  1. <template>
  2. <div class='imc'>
  3. <el-form :inline="true"
  4. :model="topForm"
  5. ref='topForm'
  6. :rules="topFormRules">
  7. <el-form-item>
  8. <div class="addBtn"
  9. @click="addClass">添加班级</div>
  10. </el-form-item>
  11. <el-form-item label="基础技能班参考数量">
  12. <el-input disabled
  13. v-model="topForm.improventClassesNum"></el-input>
  14. </el-form-item>
  15. <el-form-item label="排课数量"
  16. prop="count">
  17. <el-input v-model="topForm.count"></el-input>
  18. </el-form-item>
  19. <el-form-item label="排课开始时间"
  20. prop="timer">
  21. <el-date-picker v-model="topForm.timer"
  22. align="right"
  23. style="width:220px!important;"
  24. type="date"
  25. placeholder="选择日期"
  26. value-format="yyyy-MM-dd">
  27. </el-date-picker>
  28. </el-form-item>
  29. </el-form>
  30. <div class="tableWrap">
  31. <el-table :data="tableList">
  32. <el-table-column prop="name"
  33. align="center"
  34. label="基础技能班名称">
  35. </el-table-column>
  36. <el-table-column prop="subjectIdList"
  37. align="center"
  38. label="声部">
  39. <template slot-scope="scope">
  40. <div>
  41. {{ scope.row.subjectIdList | fitterSound }}
  42. </div>
  43. </template>
  44. </el-table-column>
  45. <el-table-column prop="userId"
  46. align="center"
  47. label="主教老师">
  48. <template slot-scope="scope">
  49. <div>
  50. {{ scope.row.userId | fitterTeacher }}
  51. </div>
  52. </template>
  53. </el-table-column>
  54. <el-table-column prop="expectStudentNum"
  55. align="center"
  56. label="班级人数">
  57. </el-table-column>
  58. <el-table-column prop="date"
  59. align="center"
  60. label="上课时间">
  61. <template slot-scope="scope">
  62. <div>
  63. <p>{{scope.row.startClassTime+'-'+scope.row.endClassTime}}</p>
  64. </div>
  65. </template>
  66. </el-table-column>
  67. <el-table-column prop="date"
  68. align="center"
  69. label="操作">
  70. <template slot-scope="scope">
  71. <div>
  72. <el-button type="text"
  73. @click="removeClass(scope.row)">删除</el-button>
  74. </div>
  75. </template>
  76. </el-table-column>
  77. </el-table>
  78. </div>
  79. <!-- 确认取消 -->
  80. <div class="btnWrap"
  81. style="margin-top:40px;">
  82. <div class="nextBtn"
  83. @click='gotoNext'>{{ permission('/teamSetting/salarySet') ? '确定' : '下一步' }}</div>
  84. <!-- <div class="okBtn">返回</div> -->
  85. </div>
  86. <el-dialog title="基础技能班"
  87. :visible.sync="raiseVisible"
  88. width="40%">
  89. <el-form :model="maskForm"
  90. ref='maskForm'
  91. :rules="maskRules"
  92. :label-position="labelPosition"
  93. label-width="100px">
  94. <el-form-item label="名称"
  95. prop="name">
  96. <el-input v-model="maskForm.name"
  97. style='width:180px;'></el-input>
  98. </el-form-item>
  99. <el-form-item label="声部"
  100. prop="sound">
  101. <el-select v-model="maskForm.sound"
  102. multiple>
  103. <el-option v-for="(item,index) in soundList"
  104. :key='index'
  105. :label="item.name"
  106. :value="item.id"></el-option>
  107. </el-select>
  108. </el-form-item>
  109. <el-form-item label="主教老师"
  110. prop="teacher">
  111. <el-select v-model="maskForm.teacher"
  112. filterable>
  113. <el-option v-for="(item,index) in teacherList"
  114. :key="index"
  115. :label="item.realName"
  116. :value="item.id"></el-option>
  117. </el-select>
  118. </el-form-item>
  119. <el-form-item label="班级人数"
  120. prop="studentNum">
  121. <el-input v-model="maskForm.count"
  122. type="number"
  123. style='width:180px;'></el-input>
  124. </el-form-item>
  125. <el-form-item label="星期几"
  126. prop="week">
  127. <el-select v-model="maskForm.week">
  128. <el-option value="1"
  129. label="星期一"></el-option>
  130. <el-option value="2"
  131. label="星期二"></el-option>
  132. <el-option value="3"
  133. label="星期三"></el-option>
  134. <el-option value="4"
  135. label="星期四"></el-option>
  136. <el-option value="5"
  137. label="星期五"></el-option>
  138. <el-option value="6"
  139. label="星期六"></el-option>
  140. <el-option value="7"
  141. label="星期天"></el-option>
  142. </el-select>
  143. </el-form-item>
  144. <el-form-item label="时间段"
  145. prop="startTime">
  146. <el-time-select placeholder="起始时间"
  147. value-format='HH:mm:ss'
  148. v-model="maskForm.startTime"
  149. :picker-options="{
  150. start: '06:30',
  151. step: '00:05',
  152. end: '23:30'
  153. }">
  154. </el-time-select>
  155. <el-time-select placeholder="结束时间"
  156. v-model="maskForm.endTime"
  157. value-format='HH:mm:ss'
  158. :picker-options="{
  159. start: '06:30',
  160. step: '00:05',
  161. end: '23:30',
  162. minTime: maskForm.startTime
  163. }">
  164. </el-time-select>
  165. </el-form-item>
  166. </el-form>
  167. <span slot="footer"
  168. class="dialog-footer">
  169. <el-button @click="raiseVisible = false">取 消</el-button>
  170. <el-button type="primary"
  171. @click="addraiseClass">确 定</el-button>
  172. </span>
  173. </el-dialog>
  174. </div>
  175. </template>
  176. <script>
  177. import { findSound, findMusicGroupClassTeacher, getTeacher, getTeamDetail, addHighClass, highClassGroups } from '@/api/buildTeam'
  178. let that;
  179. import { permission } from '@/utils/directivePage'
  180. export default {
  181. props: {
  182. teamid: {
  183. type: String,
  184. required: true
  185. },
  186. isSetSalary: {
  187. type: Boolean,
  188. required: true
  189. }
  190. },
  191. beforeCreate () {
  192. that = this;
  193. },
  194. data () {
  195. return {
  196. labelPosition: 'right',
  197. topForm: {
  198. count: '',
  199. improventClassesNum: '',
  200. timer: ''
  201. },
  202. maskForm: {
  203. name: '',
  204. sound: [],
  205. count: '',
  206. teacher: '',
  207. startTime: '',
  208. endTime: '',
  209. week: ''
  210. },
  211. raiseVisible: false,
  212. tableList: [],
  213. soundList: [],
  214. teacherList: [],
  215. maskRules: {
  216. name: [{ required: true, message: '请输入姓名', trigger: 'blur' },
  217. { min: 1, max: 20, message: '长度在 1 到 20 个字符', trigger: 'blur' }],
  218. sound: [{ required: true, message: '请选择声部', trigger: 'blur' },],
  219. count: [{ required: true, message: '请输入学生数', trigger: 'blur' }],
  220. teacher: [{ required: true, message: '请选择老师', trigger: 'blur' }],
  221. startTime: [{ required: true, message: '请选择开始时间', trigger: 'blur' }],
  222. endTime: '',
  223. week: [{ required: true, message: '请选择星期几', trigger: 'blur' }]
  224. },
  225. topFormRules: {
  226. count: [{ required: true, message: '请输入排课数量', trigger: 'blur' }],
  227. timer: [{ required: true, message: '请选择开课时间', trigger: 'blur' }]
  228. },
  229. organId: ''
  230. }
  231. },
  232. created () {
  233. this.organId = sessionStorage.getItem('createTeamOrgnId') || null
  234. },
  235. mounted () {
  236. // 获取乐团声部
  237. findSound({ musicGroupId: this.teamid }).then(res => {
  238. if (res.code == 200) {
  239. this.soundList = res.data;
  240. }
  241. })
  242. // findMusicGroupClassTeacher({ musicGroupId: this.teamid }).then(res => {
  243. // if (res.code == 200) {
  244. // this.teacherList = res.data
  245. // // console.log(res.data);
  246. // }
  247. // })
  248. getTeacher({ organId: this.organId }).then(res => {
  249. if (res.code == 200) {
  250. this.teacherList = res.data
  251. }
  252. })
  253. // 获取乐团老师
  254. // findMusicGroupClassTeacher({ musicGroupId: this.teamid }).then()
  255. getTeamDetail({ musicGroupId: this.teamid }).then(res => {
  256. if (res.code == 200) {
  257. this.topForm.improventClassesNum = res.data.improventClassesNum;
  258. }
  259. });
  260. // 获取提高班列表
  261. highClassGroups({ musicGroupId: this.teamid }).then(res => {
  262. if (res.code == 200) {
  263. this.tableList = res.data;
  264. // for (let i in this.tableList) {
  265. // this.tableList[i].endClassTime = this.tableList[i].endClassTime.substring(0, this.tableList[i].endClassTime.length - 3);
  266. // this.tableList[i].startClassTime = this.tableList[i].startClassTime.substring(0, this.tableList[i].startClassTime.length - 3);
  267. // }
  268. }
  269. })
  270. },
  271. methods: {
  272. permission (str) {
  273. return permission(str)
  274. },
  275. addraiseClass () {
  276. this.$refs['maskForm'].validate(res => {
  277. if (res) {
  278. // 验证成功组成数组
  279. let obj = {
  280. 'userId': this.maskForm.teacher, // 老师id
  281. 'dayOfWeek': this.maskForm.week, // 周几
  282. 'startClassTime': this.maskForm.startTime,
  283. 'endClassTime': this.maskForm.endTime,
  284. 'courseTimes': this.topForm.count,
  285. 'type': 'HIGH',
  286. 'expectStudentNum': this.maskForm.count,
  287. 'musicGroupId': this.teamid,
  288. 'teachMode': 'OFFLINE',
  289. 'name': this.maskForm.name,
  290. 'subjectIdList': this.maskForm.sound.join(','),
  291. 'moid': new Date().getTime(),
  292. 'startDate': this.topForm.timer
  293. }
  294. this.tableList.push(obj);
  295. console.log(this.tableList)
  296. this.raiseVisible = false;
  297. this.$refs['maskForm'].resetFields();
  298. this.maskForm.endTime = '';
  299. } else {
  300. this.$message.error('请填写必要信息')
  301. }
  302. })
  303. },
  304. removeClass (row) {
  305. console.log(row.moid)
  306. if (row.moid) {
  307. for (let i in this.tableList) {
  308. if (this.tableList[i].moid == row.moid) {
  309. this.tableList.splice(i, 1);
  310. return
  311. }
  312. }
  313. } else {
  314. for (let i in this.tableList) {
  315. if (this.tableList[i].id == row.id) {
  316. this.tableList.splice(i, 1);
  317. return
  318. }
  319. }
  320. }
  321. },
  322. addClass () {
  323. if (this.isSetSalary) {
  324. this.$message.error('课酬确认后无法编辑')
  325. return;
  326. }
  327. this.raiseVisible = true;
  328. },
  329. gotoNext () {
  330. if (this.isSetSalary) {
  331. this.$message.error('课酬确认后无法编辑')
  332. return;
  333. }
  334. this.$refs['topForm'].validate(res => {
  335. if (res) {
  336. for (let i in this.tableList) {
  337. this.tableList[i].startDate = this.topForm.timer;
  338. this.tableList[i].courseTimes = this.topForm.count;
  339. }
  340. let count = this.tableList.length;
  341. if (count > this.topForm.improventClassesNum) {
  342. this.$message.error(`基础技能班不能超过${this.topForm.improventClassesNum}个`)
  343. return
  344. }
  345. addHighClass(this.tableList).then(res => {
  346. if (res.code == 200) {
  347. this.$message.success('恭喜您创建成功')
  348. if (this.permission('/teamSetting/salarySet')) {
  349. this.$router.push({ path: '/business/teamDetail' })
  350. } else {
  351. this.$emit('gotoNav', 4)
  352. }
  353. }
  354. })
  355. } else {
  356. this.$message.error('请先输入排课数量和开始时间')
  357. }
  358. })
  359. }
  360. },
  361. filters: {
  362. fitterSound (val) {
  363. let arr = val.split(',');
  364. if (that.soundList) {
  365. let str = ''
  366. for (let i in that.soundList) {
  367. for (let j in arr) {
  368. if (that.soundList[i].id == arr[j]) {
  369. str += that.soundList[i].name + ','
  370. }
  371. }
  372. }
  373. return str.substring(0, str.length - 1);
  374. } else {
  375. return ''
  376. }
  377. },
  378. fitterTeacher (val) {
  379. // console.log(that.teacherList)
  380. if (that.teacherList) {
  381. for (let i in that.teacherList) {
  382. if (that.teacherList[i].id == val) {
  383. return that.teacherList[i].realName
  384. }
  385. }
  386. } else {
  387. return ''
  388. }
  389. }
  390. }
  391. }
  392. </script>
  393. <style lang="scss" scoped>
  394. .imc {
  395. box-sizing: border-box;
  396. padding: 30px 42px;
  397. background-color: #fff;
  398. min-height: 80vh;
  399. .addBtn {
  400. line-height: 40px;
  401. text-align: center;
  402. color: #fff;
  403. border-radius: 4px;
  404. margin-right: 20px;
  405. cursor: pointer;
  406. width: 120px;
  407. height: 40px;
  408. background-color: #4eada7;
  409. }
  410. }
  411. </style>