improvementClass.vue 15 KB

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