vipReset.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391
  1. <template>
  2. <div class="m-container">
  3. <h2>
  4. <el-page-header @back="goBack"
  5. content='vip修改'>
  6. </el-page-header>
  7. </h2>
  8. <div class='newBand'
  9. @click="addCourse">vip加课</div>
  10. <div class="tableWrap">
  11. <el-table :data='tableList'
  12. :header-cell-style="{background:'#EDEEF0',color:'#444'}">
  13. <el-table-column label="课程名称"
  14. width="150"
  15. align="center"
  16. prop="name">
  17. </el-table-column>
  18. <el-table-column label="班级id"
  19. width="150"
  20. align="center"
  21. prop="classGroupId">
  22. </el-table-column>
  23. <el-table-column label="上课日期"
  24. align="center"
  25. width="150"
  26. prop="classDate">
  27. <template slot-scope="scope">
  28. <div>
  29. {{ scope.row.classDate | formatTimer}}
  30. </div>
  31. </template>
  32. </el-table-column>
  33. <el-table-column label="课程状态"
  34. align="center"
  35. width="150"
  36. prop="status">
  37. <template slot-scope="scope">
  38. <div>
  39. {{ scope.row.status | coursesStatus }}
  40. </div>
  41. </template>
  42. </el-table-column>
  43. <el-table-column label="上课开始时间"
  44. align="center"
  45. width="150"
  46. prop="startClassTimeStr">
  47. </el-table-column>
  48. <el-table-column label="上课结束时间"
  49. align="center"
  50. width="150"
  51. prop="endClassTimeStr">
  52. </el-table-column>
  53. <el-table-column label="课程类型"
  54. width="150"
  55. align="center">
  56. <template slot-scope="scope">
  57. <div>
  58. {{ scope.row.teachMode | teachMode }}
  59. </div>
  60. </template>
  61. </el-table-column>
  62. <el-table-column label="教学点"
  63. align="center"
  64. width="300"
  65. prop="schoolName">
  66. </el-table-column>
  67. <el-table-column label="操作">
  68. <template slot-scope="scope">
  69. <div>
  70. <el-button type="text"
  71. @click="resetClass(scope.row)">调整</el-button>
  72. <el-button type="text"
  73. @click="removeClass(scope.row)">删除</el-button>
  74. </div>
  75. </template>
  76. </el-table-column>
  77. </el-table>
  78. <pagination :total="rules.total"
  79. :page.sync="rules.page"
  80. :limit.sync="rules.limit"
  81. :page-sizes="rules.page_size"
  82. @pagination="getList" />
  83. </div>
  84. <el-dialog title="课程调整"
  85. width="400px"
  86. :before-close="handleClose"
  87. :visible.sync="courseVisible">
  88. <el-form :model="maskForm"
  89. ref="maskForm"
  90. :rules="maskRules"
  91. label-position="right"
  92. label-width="80px;"
  93. :inline="true">
  94. <el-form-item label="上课日期"
  95. prop="date">
  96. <el-date-picker v-model="maskForm.date"
  97. type="date"
  98. value-format="yyyy-MM-dd"
  99. placeholder="选择日期">
  100. </el-date-picker>
  101. </el-form-item>
  102. <el-form-item label="开始时间"
  103. prop="startTime">
  104. <el-time-select placeholder="起始时间"
  105. v-model="maskForm.startTime"
  106. :picker-options="{
  107. start: '06:30',
  108. step: '00:05',
  109. end: '23:30'
  110. }">
  111. </el-time-select>
  112. </el-form-item>
  113. <el-form-item label="结束时间"
  114. prop="endTime">
  115. <el-time-select placeholder="结束时间"
  116. v-model="maskForm.endTime"
  117. :picker-options="{
  118. start: '06:30',
  119. step: '00:05',
  120. end: '23:30',
  121. minTime: maskForm.startTime
  122. }">
  123. </el-time-select>
  124. </el-form-item>
  125. <el-form-item label="教学地点"
  126. v-if='maskForm.teachMode == "OFFLINE"'>
  127. <el-select v-model="maskForm.address">
  128. <el-option v-for="(item,index) in schoolList"
  129. :key="index"
  130. :value="item.id"
  131. :label="item.name"></el-option>
  132. </el-select>
  133. </el-form-item>
  134. </el-form>
  135. <div slot="footer"
  136. class="dialog-footer">
  137. <el-button @click="courseVisible = false">取 消</el-button>
  138. <el-button type="primary"
  139. @click="submitResetClass">确 定</el-button>
  140. </div>
  141. </el-dialog>
  142. <el-dialog title="课程调整"
  143. :visible.sync="addCourseVisible">
  144. <el-button type="text"
  145. @click="addOneChiose">添加</el-button>
  146. <el-table :data='addTable'>
  147. <el-table-column label="上课日期"
  148. align="center"
  149. prop="name">
  150. <template slot-scope="scope">
  151. <div>
  152. <el-date-picker v-model="scope.row.classDate"
  153. type="date"
  154. placeholder="选择日期">
  155. </el-date-picker>
  156. </div>
  157. </template>
  158. </el-table-column>
  159. <el-table-column label="课程开始时间"
  160. align="center"
  161. prop="startClassTimeStr">
  162. <template slot-scope="scope">
  163. <div>
  164. <el-time-select v-model="scope.row.startClassTimeStr"
  165. :picker-options="{
  166. start: '06:30',
  167. step: '00:05',
  168. end: '23:30'
  169. }"
  170. placeholder="选择时间">
  171. </el-time-select>
  172. </div>
  173. </template>
  174. </el-table-column>
  175. <el-table-column label="课程形态"
  176. align="center"
  177. prop="name">
  178. <template slot-scope="scope">
  179. <div>
  180. <el-select v-model="scope.row.teachMode">
  181. <el-option label="线上课"
  182. value="ONLINE"></el-option>
  183. <el-option label="线下课"
  184. value="OFFLINE"></el-option>
  185. </el-select>
  186. </div>
  187. </template>
  188. </el-table-column>
  189. <el-table-column label="操作"
  190. align="center">
  191. <template slot-scope="scope">
  192. <div>
  193. <el-button type="text"
  194. @click="removeMarkCourse(scope.row)">删除</el-button>
  195. </div>
  196. </template>
  197. </el-table-column>
  198. </el-table>
  199. <span slot="footer"
  200. class="dialog-footer">
  201. <el-button @click="addCourseVisible = false">取 消</el-button>
  202. <el-button type="primary"
  203. @click="submitAdd">确 定</el-button>
  204. </span>
  205. </el-dialog>
  206. </div>
  207. </template>
  208. <script>
  209. import { resetCourse } from '@/api/buildTeam'
  210. import { getSchool } from '@/api/systemManage'
  211. import pagination from '@/components/Pagination/index'
  212. import { findVipGroupCourseSchedules, bathDelete, appendVipGroupCourseSchedules } from '@/api/vipSeting'
  213. export default {
  214. components: {
  215. pagination
  216. },
  217. data () {
  218. return {
  219. addCourseVisible: false,
  220. courseVisible: false,
  221. tableList: [],
  222. addTable: [],
  223. courseTime: '',
  224. vipid: '',
  225. maskForm: {
  226. date: '',
  227. startTime: '',
  228. endTime: '',
  229. id: '',
  230. address: '',
  231. teachMode: ''
  232. },
  233. rules: {
  234. // 分页规则
  235. limit: 10, // 限制显示条数
  236. page: 1, // 当前页
  237. total: 0, // 总条数
  238. page_size: [10, 20, 30, 40] // 选择限制显示条数
  239. },
  240. maskRules: {
  241. date: [{ required: true, message: '请选择上课时间', trigger: 'blur' },],
  242. startTime: [{ required: true, message: '请选择上课开始时间', trigger: 'blur' },],
  243. endTime: [{ required: true, message: '请选择上课结束时间', trigger: 'blur' },],
  244. },
  245. schoolList: [],
  246. Frules: null,
  247. FsearchForm: null
  248. }
  249. },
  250. created () {
  251. this.vipid = this.$route.query.id;
  252. if (this.$route.query.rules) {
  253. this.Frules = this.$route.query.rules
  254. }
  255. if (this.$route.query.searchForm) {
  256. this.FsearchForm = this.$route.query.searchForm
  257. }
  258. },
  259. mounted () {
  260. this.getList();
  261. getSchool({ organId: this.$store.getters.organ }).then(res => {
  262. if (res.code == 200) {
  263. this.schoolList = res.data;
  264. }
  265. })
  266. },
  267. methods: {
  268. getList () {
  269. findVipGroupCourseSchedules({ vipGroupId: this.vipid, rows: this.rules.limit, page: this.rules.page }).then(
  270. res => {
  271. if (res.code == 200) {
  272. this.tableList = res.data.pageInfo.rows;
  273. this.rules.total = res.data.pageInfo.total;
  274. this.courseTime = res.data.singleClassMinutes;
  275. }
  276. }
  277. )
  278. },
  279. goBack () {
  280. this.$router.push({ path: '/business/vipList', query: { rules: this.Frules, searchForm: this.FsearchForm } })
  281. },
  282. resetClass (row) {
  283. this.maskForm.date = row.classDate;
  284. this.maskForm.startTime = row.startClassTimeStr;
  285. this.maskForm.endTime = row.endClassTimeStr;
  286. this.maskForm.id = row.id;
  287. this.maskForm.address = row.schoolId
  288. this.maskForm.teachMode = row.teachMode
  289. // 修改课时
  290. this.courseVisible = true;
  291. },
  292. handleClose () {
  293. this.courseVisible = false;
  294. this.$refs['maskForm'].resetFields()
  295. },
  296. submitResetClass () {
  297. let obj = {
  298. startClassTimeStr: this.maskForm.startTime,
  299. endClassTimeStr: this.maskForm.endTime,
  300. id: this.maskForm.id,
  301. classDate: this.maskForm.date,
  302. schoolId: this.maskForm.address || null
  303. }
  304. resetCourse(obj).then(res => {
  305. if (res.code == 200) {
  306. this.$message.success('修改成功')
  307. this.courseVisible = false;
  308. this.getList();
  309. }
  310. })
  311. },
  312. removeClass (row) {
  313. this.$confirm('是否删除该vip课程?', '提示', {
  314. confirmButtonText: '确定',
  315. cancelButtonText: '取消',
  316. type: 'warning'
  317. }).then(() => {
  318. bathDelete({ courseScheduleIds: row.id }).then(res => {
  319. if (res.code == 200) {
  320. this.$message.success('删除成功')
  321. this.getList();
  322. }
  323. })
  324. })
  325. },
  326. // vip 家课
  327. addCourse () {
  328. this.addCourseVisible = true;
  329. },
  330. addOneChiose () {
  331. this.addTable.push({
  332. classDate: '',
  333. startClassTimeStr: '',
  334. endClassTimeStr: '',
  335. teachMode: '',
  336. moid: new Date().getTime()
  337. })
  338. },
  339. removeMarkCourse (row) {
  340. for (let i in this.addTable) {
  341. if (this.addTable[i].moid == row.moid) {
  342. this.addTable.splice(i, 1);
  343. }
  344. }
  345. },
  346. submitAdd () {
  347. let endClassTimeStr = this.MinutesTest(this.addTable[0].startClassTimeStr, 90);
  348. let some = {
  349. vipGroupApplyBaseInfo: {
  350. id: this.vipid
  351. }, courseSchedules: []
  352. }
  353. for (let i in this.addTable) {
  354. let obj = {
  355. classDate: this.addTable[i].classDate,
  356. startClassTimeStr: this.addTable[i].startClassTimeStr,
  357. endClassTimeStr: this.MinutesTest(this.addTable[i].startClassTimeStr, this.courseTime),
  358. teachMode: this.addTable[i].teachMode
  359. }
  360. some.courseSchedules.push(obj);
  361. }
  362. // 发请求干活
  363. appendVipGroupCourseSchedules(some).then(res => {
  364. if (res.code == 200) {
  365. this.addCourseVisible = false;
  366. this.rules.page = 1;
  367. this.getList();
  368. }
  369. })
  370. },
  371. // 分钟小时相加减
  372. MinutesTest (str, interval) {
  373. let houer = str.split(':')[0];
  374. let min = str.split(':')[1];
  375. let sdate1 = new Date(1900, 1, 1, houer, min);
  376. sdate1.setMinutes(sdate1.getMinutes() + parseInt(interval));
  377. let H = sdate1.getHours();
  378. let M = sdate1.getMinutes();
  379. if (H < 10) H = '0' + H;
  380. if (M < 10) M = '0' + M;
  381. return H + ':' + M
  382. },
  383. },
  384. }
  385. </script>
  386. <style lang="scss">
  387. </style>