courses.vue 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728
  1. <template>
  2. <div class="context">
  3. <div class="panel">
  4. <h5>课程管理
  5. </h5>
  6. <div class="panel-body">
  7. <div class="panel_control">
  8. <el-row :gutter="20">
  9. <el-date-picker
  10. v-model="panel.timeScope"
  11. type="daterange"
  12. range-separator="至"
  13. start-placeholder="开始日期"
  14. end-placeholder="结束日期">
  15. </el-date-picker>
  16. <el-col :span="4">
  17. <el-button size="" type="primary" @click="query" :disabled="serachBtnStatus" plain>查询
  18. </el-button>
  19. </el-col>
  20. </el-row>
  21. </div>
  22. </div>
  23. </div>
  24. <div class="table">
  25. <el-table
  26. :data="tableData"
  27. border
  28. is-horizontal-resize
  29. :default-sort="{prop: 'date', order: 'descending'}"
  30. element-loading-background="rgba(0, 0, 0, 0.8)"
  31. class=""
  32. @selection-change="handleSelectionChange"
  33. >
  34. >
  35. <el-table-column
  36. type="index"
  37. label="序号"
  38. align="center"
  39. width="50">
  40. </el-table-column>
  41. <el-table-column
  42. prop="BeginTime"
  43. label="上课时间"
  44. :formatter="filterFmtDate"
  45. >
  46. </el-table-column>
  47. <el-table-column
  48. prop="ClassName"
  49. label="课程"
  50. sortable
  51. >
  52. <template slot-scope="scope">
  53. <span class="lessonSpan"
  54. :style="{background:scope.row.ClassColor}">{{scope.row.ClassName}}</span>
  55. </template>
  56. </el-table-column>
  57. <el-table-column
  58. prop="ConsumeHour"
  59. label="消耗课时"
  60. sortable
  61. >
  62. </el-table-column>
  63. <el-table-column
  64. prop="OrderNum"
  65. label="实际预约人数"
  66. sortable
  67. >
  68. </el-table-column>
  69. <el-table-column
  70. prop="SvName"
  71. label="区域"
  72. sortable
  73. >
  74. </el-table-column>
  75. <el-table-column
  76. prop="FinishClass"
  77. label="当前状态"
  78. sortable
  79. >
  80. <template slot-scope="scope">
  81. <span v-if="scope.row.FinishClass == 0" style="color: red">未上课</span>
  82. <span v-if="scope.row.FinishClass == 1">已下课</span>
  83. <span v-if="scope.row.FinishClass == 2" style="color: yellowgreen">已上课</span>
  84. <span v-if="scope.row.FinishClass == 3">准备上课</span>
  85. </template>
  86. </el-table-column>
  87. <el-table-column
  88. prop="Status"
  89. label="操作"
  90. >
  91. <template slot-scope="scope">
  92. <!--<el-button type="primary" round size="mini" @click="checkClassOverPrepare(scope.row)">-->
  93. <!--下课-->
  94. <!--</el-button>-->
  95. <el-button type="primary" round size="mini" v-if="scope.row.FinishClass == 0"
  96. @click="showDialogMemberVisible(scope.row)">
  97. 上课
  98. </el-button>
  99. <el-button type="primary" round size="mini"
  100. v-if="scope.row.FinishClass == 3 || scope.row.FinishClass == 2"
  101. @click="seeEdit(scope.row)"
  102. >
  103. 管理
  104. </el-button>
  105. <!--修改区域 todo-->
  106. <el-button type="primary" round plain size="mini" v-if="scope.row.FinishClass == 3"
  107. @click="changeShopVenue(scope.row)"
  108. >
  109. 编辑
  110. </el-button>
  111. <el-button type="primary" round plain size="mini" v-if="scope.row.FinishClass == 1"
  112. @click="seeDetail(scope.row)"
  113. >
  114. 详情
  115. </el-button>
  116. </template>
  117. </el-table-column>
  118. </el-table>
  119. <br>
  120. <el-pagination
  121. background
  122. :total="pageination.total"
  123. :page-size="pageination.pageItem"
  124. @current-change="pageChange"
  125. ></el-pagination>
  126. </div>
  127. <el-dialog :title="dialogTitle" :visible.sync="dialogMemberVisible" width="650px">
  128. <div class="dialogContent">
  129. <h5 class="classNames">{{className}}</h5>
  130. <div class="">
  131. <el-form ref="form" :model="form" label-width="160px">
  132. <el-form-item label="区域" :required="true">
  133. <el-select v-model="form.svId" filterable placeholder="请选择" @change="changeLocationValue">
  134. <el-option
  135. v-for="item in form.svList"
  136. :key="item.SvId"
  137. :label="item.Name"
  138. :value="item.SvId">
  139. </el-option>
  140. </el-select>
  141. </el-form-item>
  142. <el-form-item label="类型" :required="true">
  143. <el-select v-model="form.classType" filterable placeholder="请选择">
  144. <el-option
  145. v-for="item in form.ClassTypeOptions"
  146. :key="item.value"
  147. :label="item.label"
  148. :value="item.value">
  149. </el-option>
  150. </el-select>
  151. </el-form-item>
  152. <el-form-item label="组队方式" v-if="form.classType == 2">
  153. <el-select v-model="form.pkNum" filterable placeholder="请选择">
  154. <el-option
  155. v-for="item in form.PKTypeOptions"
  156. :key="item.value"
  157. :label="item.label"
  158. :value="item.value">
  159. </el-option>
  160. </el-select>
  161. </el-form-item>
  162. </el-form>
  163. </div>
  164. </div>
  165. <div class="dialogFooter">
  166. <el-button type="primary" size="small" v-if="form.btnType == 0" @click="getClassStartPrepare()">确定
  167. </el-button>
  168. <el-button type="primary" size="small" v-if="form.btnType == 1" @click="getClassStartPrepareForEdit()">
  169. 确定
  170. </el-button>
  171. <el-button size="small" @click="dialogMemberVisible = false">取消</el-button>
  172. </div>
  173. </el-dialog>
  174. </div>
  175. </template>
  176. <script>
  177. import Global from '../Global.js'
  178. import {
  179. ClassPreFinishListQuery,
  180. ClassOverPrepare,
  181. ClassDetailQuery,
  182. QueryShopVenue,
  183. ClassStartPrepare,
  184. } from "../api/getApiRes";
  185. let qs = require('qs');
  186. export default {
  187. data() {
  188. return {
  189. dialogMemberVisible: false,
  190. serachBtnStatus: false,
  191. dialogVisible: false,//其他dialog
  192. dialogFinishVisible: false,//确认下课dialog
  193. dialogLesson: false,//课时调整
  194. dialogGift: false,//赠送课时调整
  195. dialogExpTime: false,//有效期调整
  196. dialogLessonTable: false,//会员课程
  197. dialogTitle: '上课准备',
  198. className: '',
  199. current: getNowDate(),
  200. dialogValue: [],
  201. // panel 配置项目
  202. panel: {
  203. usercode: '',
  204. username: '',
  205. compname: '',
  206. keyword: '',
  207. USERCODE: '',
  208. endType: '',
  209. taskstatus: 99,
  210. draw: 1,
  211. start: 0,
  212. recordsTotal: 0,
  213. tableData: [],
  214. allTableData: [],
  215. limit: '10',
  216. multipleSort: false,
  217. loading: false,
  218. fileList: [],
  219. multipleSelection: [],
  220. detectedmac: '',
  221. options: [
  222. {value: 99, label: '全部'},
  223. {value: 1, label: '进行中'},
  224. {value: 2, label: '已完成'},
  225. ],
  226. endTypeOptions: [
  227. {value: 99, label: '全部'},
  228. {value: 30, label: '近一个月'},
  229. {value: 7, label: '近一周'},
  230. {value: 1, label: '当日'},
  231. ],
  232. time1: globalBt(),
  233. timeScope: globalBt2(1),
  234. },
  235. multipleSelection: [],
  236. pageination: {
  237. pageItem: 100,
  238. pageoptions: pageOptions(),
  239. total: 100,
  240. pageIndex: 1,
  241. },
  242. form: {
  243. name: '',
  244. svId: '',
  245. svName: '',
  246. classType: 1,
  247. userCode: '',
  248. coach: '',
  249. coachOptions: [],
  250. shopId: '',
  251. memberType: 1,
  252. lesson: 1,
  253. gift: 1,
  254. pktype: 1,
  255. pkNum: 2,
  256. btnType: 0,//0新建,1编辑
  257. memo: '',
  258. expTime: '',
  259. StdId: '',
  260. svList: [],//区域列表
  261. dialogdata: [],//穿梭待选
  262. dialogValue: [],//穿梭已选
  263. ClassTypeOptions: [
  264. {value: 1, label: '团课'},
  265. {value: 2, label: '竞技PK'},
  266. {value: 3, label: '私教'},
  267. ],
  268. PKTypeOptions: [
  269. {value: 2, label: '2队PK'},
  270. {value: 3, label: '3队PK'},
  271. ],
  272. },
  273. memberTypes: [
  274. {value: 1, label: '年会员'},
  275. {value: 2, label: '充值会员'},
  276. ],
  277. tableData: []
  278. }
  279. },
  280. mounted() {
  281. this.getTableQuery();
  282. },
  283. methods: {
  284. // 更改上课区域
  285. changeShopVenue(row) {
  286. this.dialogMemberVisible = true;
  287. this.form.btnType = 1;//0新建,1编辑
  288. // 读取本行信息
  289. this.dialogMemberVisible = true;
  290. this.className = row.ClassName + ' ' + row.BeginStr + ' - ' + row.EndStr;
  291. this.form.StdId = row.StdId;
  292. this.getQueryShopVenue();
  293. this.form.svList = row.SvId;
  294. this.form.classType = row.ClassType;
  295. this.form.pkNum = row.PkNum;
  296. },
  297. // 准备上课
  298. getClassStartPrepare() {
  299. let that = this;
  300. if (!that.form.svId) {
  301. that.$message.error('上课区域不能为空');
  302. return false
  303. }
  304. // 不是竞技pk的时候为0
  305. let uppkNum = that.form.classType == 2 ? that.form.pkNum : 0;
  306. let param = {
  307. token: localStorage.token,
  308. stdId: that.form.StdId,
  309. svId: that.form.svId,
  310. svName: that.form.svName,
  311. classType: that.form.classType,
  312. pkNum: uppkNum,
  313. };
  314. let postdata = qs.stringify(param);
  315. console.log(that.form.BeginStr);
  316. return false
  317. ClassStartPrepare(postdata).then(res => {
  318. let json = res;
  319. if (json.Code == 0) {
  320. // NewId: 0
  321. that.dialogMemberVisible = false;
  322. this.getTableQuery();
  323. this.$router.push({
  324. path: '/courseEdit', query: {
  325. StdId: that.form.StdId,
  326. ClassName: that.form.ClassName,
  327. BeginStr: that.form.BeginStr,
  328. EndStr: that.form.EndStr,
  329. }
  330. });
  331. } else {
  332. that.$message.error(json.Memo);
  333. }
  334. })
  335. },
  336. // 编辑
  337. getClassStartPrepareForEdit() {
  338. let that = this;
  339. if (!that.form.svId) {
  340. that.$message.error('上课区域不能为空');
  341. return false
  342. }
  343. // 不是竞技pk的时候为0
  344. let uppkNum = that.form.classType == 2 ? that.form.pkNum : 0;
  345. let param = {
  346. token: localStorage.token,
  347. stdId: that.form.StdId,
  348. svId: that.form.svId,
  349. svName: that.form.svName,
  350. classType: that.form.classType,
  351. pkNum: uppkNum,
  352. };
  353. let postdata = qs.stringify(param);
  354. ClassStartPrepare(postdata).then(res => {
  355. let json = res;
  356. if (json.Code == 0) {
  357. // NewId: 0
  358. that.dialogMemberVisible = false;
  359. this.getTableQuery();
  360. } else {
  361. that.$message.error(json.Memo);
  362. }
  363. })
  364. },
  365. seeDetail(row) {
  366. this.$router.push({
  367. path: '/classInfoDetail', query: {
  368. StdId: row.StdId,
  369. ClassName: row.ClassName,
  370. BeginStr: row.BeginStr,
  371. EndStr: row.EndStr,
  372. }
  373. });
  374. },
  375. seeEdit(row) {
  376. this.$router.push({
  377. path: '/courseEdit', query: {
  378. StdId: row.StdId,
  379. ClassName: row.ClassName,
  380. BeginStr: row.BeginStr,
  381. EndStr: row.EndStr,
  382. }
  383. });
  384. },
  385. // 获取select的label
  386. changeLocationValue(val) {
  387. //locations是v-for里面的也是datas里面的值
  388. let obj = {};
  389. obj = this.form.svList.find((item) => {
  390. return item.SvId === val;
  391. });
  392. this.form.svName = obj.Name;
  393. },
  394. // 获取区域列表
  395. getQueryShopVenue() {
  396. let that = this;
  397. let param = {
  398. key: localStorage.ServiceKey,
  399. shopId: localStorage.ServiceId,
  400. };
  401. let postdata = qs.stringify(param);
  402. QueryShopVenue(postdata).then(res => {
  403. let json = res;
  404. if (json.Code == 0) {
  405. that.form.svList = json.Rs;
  406. } else {
  407. that.$message.error(json.Memo);
  408. }
  409. })
  410. },
  411. vipSelect(stdId) {
  412. let that = this;
  413. // 筛选相同的stdid的classId
  414. that.form.stdList.map(function (item) {
  415. if (item.value == stdId) {
  416. let param = {
  417. token: localStorage.token,
  418. // classId: item.classId
  419. };
  420. let postdata = qs.stringify(param);
  421. // VipUserListQuery
  422. VipUserSimpleQuery(postdata).then(res => {
  423. let json = res;
  424. if (json.Code == 0) {
  425. that.form.userId = '';
  426. that.form.userList = turnResToOptionBySimViper(json.Rs);
  427. } else {
  428. that.$message.error(json.Memo);
  429. }
  430. })
  431. }
  432. })
  433. },
  434. showDialogMemberVisible(row) {
  435. this.dialogMemberVisible = true;
  436. this.form.btnType = 0;//0新建,1编辑编辑
  437. // clear
  438. this.form.svList = "";
  439. this.form.classType = 1;
  440. this.form.pkNum = "";
  441. this.className = row.ClassName + ' ' + row.BeginStr + ' - ' + row.EndStr;
  442. this.form.StdId = row.StdId;
  443. this.getQueryShopVenue();
  444. },
  445. // 检测当前课是否处于可改变状态
  446. // 固定下当前已预约人数列表
  447. checkClassOverPrepare(row) {
  448. let that = this;
  449. let param = {
  450. token: localStorage.token,
  451. stdId: row.StdId,
  452. };
  453. let postdata = qs.stringify(param);
  454. ClassOverPrepare(postdata).then(res => {
  455. let json = res;
  456. if (json.Code == 0) {
  457. that.goFinish(row);
  458. } else {
  459. that.$message.error(json.Memo);
  460. }
  461. })
  462. },
  463. goFinish(row) {
  464. this.$router.push({
  465. path: '/finishDetail', query: {
  466. id: row.StdId,
  467. classId: row.ClassId,
  468. ClassName: row.ClassName,
  469. BeginTime: row.BeginTime,
  470. }
  471. });
  472. },
  473. handleSelectionChange(val) {
  474. this.multipleSelection = val;
  475. },
  476. // 查询按钮
  477. query() {
  478. let that = this;
  479. that.serachBtnStatus = true;
  480. let totalTime = 2;
  481. let clock = window.setInterval(() => {
  482. totalTime--;
  483. if (totalTime < 0) {
  484. totalTime = 2;
  485. that.serachBtnStatus = false;
  486. }
  487. }, 1000);
  488. this.getTableQuery();
  489. this.$message.success('查询完毕');
  490. },
  491. // 页面数据查询
  492. getTableQuery() {
  493. let that = this;
  494. that.loading = true;
  495. let param = {
  496. token: localStorage.token,
  497. tagname: that.panel.tagname,//标签名
  498. bt: nonTfmtDatetoLength(that.panel.timeScope[0], 10) + " 00:00:00",
  499. et: nonTfmtDatetoLength(that.panel.timeScope[1], 10) + " 23:59:59",
  500. start: 1,//
  501. tableMax: 9999,//
  502. };
  503. let postdata = qs.stringify(param);
  504. ClassDetailQuery(postdata).then(res => {
  505. let json = res;
  506. if (json.Code == 0) {
  507. that.loading = false;
  508. if (json.Rs) {
  509. that.allTableData = json.Rs;
  510. that.recordsTotal = json.Rs.length;
  511. } else {
  512. that.allTableData = [];
  513. that.recordsTotal = 0;
  514. }
  515. // 设置分页数据
  516. that.setPaginations();
  517. } else {
  518. that.$message.error(json.Memo);
  519. }
  520. })
  521. },
  522. // 设置分页数据
  523. setPaginations() {
  524. // 分页属性
  525. let that = this;
  526. that.pageination.total = that.recordsTotal;
  527. // 默认分页
  528. that.tableData = that.allTableData.filter((item, index) => {
  529. return index < that.pageination.pageItem;
  530. });
  531. },
  532. // 每页显示数量
  533. handleSizeChange() {
  534. let that = this;
  535. that.tableData = that.allTableData.filter((item, index) => {
  536. return index < that.pageination.pageItem;
  537. });
  538. that.draw = that.pageination.pageItem;
  539. // that.getTableQuery();
  540. },
  541. // 翻页
  542. pageChange(pageIndex) {
  543. let that = this;
  544. // 获取当前页
  545. let index = that.pageination.pageItem * (pageIndex - 1);
  546. // 数据总数
  547. let nums = that.pageination.pageItem * pageIndex;
  548. // 容器
  549. let tables = [];
  550. for (var i = index; i < nums; i++) {
  551. if (that.allTableData[i]) {
  552. tables.push(that.allTableData[i])
  553. }
  554. this.tableData = tables;
  555. }
  556. that.start = index * that.draw;
  557. // that.getTableQuery();
  558. },
  559. // 过滤时间
  560. filterFmtDate(value, row, column) {
  561. let that = this;
  562. return nonTfmtDate(column, 11);
  563. },
  564. },
  565. watch: {
  566. $route(to) {
  567. if (to.name == 'finish') {
  568. this.getTableQuery();
  569. }
  570. },
  571. },
  572. }
  573. </script>
  574. <style scoped>
  575. @import "../assets/css/panel.css";
  576. .context {
  577. height: 770px;
  578. overflow-y: scroll;
  579. display: block;
  580. margin: 0 auto;
  581. background-color: #fff !important;
  582. padding: 30px;
  583. }
  584. .panel-body {
  585. padding: 20px;
  586. background: #F0F2F5;
  587. }
  588. .change {
  589. width: 100%;
  590. overflow: hidden;
  591. display: block;
  592. margin: 0 auto;
  593. padding-top: 10px;
  594. padding-bottom: 10px;
  595. }
  596. .change button {
  597. float: left;
  598. }
  599. .change button.pull-right {
  600. float: right;
  601. }
  602. .dialogTitle {
  603. width: 100%;
  604. overflow: hidden;
  605. display: block;
  606. margin: 0 auto;
  607. color: #000000;
  608. font-size: 18px;
  609. text-align: center;
  610. }
  611. .dialogTitle em {
  612. float: none;
  613. font-style: normal;
  614. color: #3799FF;
  615. margin: 0;
  616. }
  617. /deep/ .el-transfer-panel__item .el-checkbox__input {
  618. left: 40px;
  619. }
  620. .dialogFooter {
  621. width: 90%;
  622. overflow: hidden;
  623. display: block;
  624. margin: 0 auto;
  625. margin-top: 10px;
  626. }
  627. .dialogFooter button {
  628. float: right;
  629. margin-left: 10px;
  630. }
  631. .dialogContent {
  632. width: 100%;
  633. overflow: hidden;
  634. display: block;
  635. margin: 0 auto;
  636. }
  637. .dialogContent .pull-left {
  638. width: 30%;
  639. float: left;
  640. }
  641. .dialogContent .pull-right {
  642. width: 70%;
  643. float: right;
  644. }
  645. .blueTitle {
  646. width: 200px;
  647. overflow: hidden;
  648. display: block;
  649. margin: 0 auto;
  650. margin-top: 10px;
  651. margin-bottom: 40px;
  652. background: #F0F2F5;
  653. border-radius: 19px;
  654. text-align: center;
  655. color: #3799FF;
  656. font-size: 16px;
  657. padding: 5px 24px;
  658. }
  659. .current {
  660. width: 158px;
  661. height: 23px;
  662. /*float: left;*/
  663. border-radius: 250px;
  664. text-align: center;
  665. background: #F0F2F5;
  666. color: #545454;
  667. font-size: 14px;
  668. padding: 3px 10px;
  669. margin-left: 20px;
  670. }
  671. .lessonSpan {
  672. width: 78px;
  673. height: 22px;
  674. border-radius: 11px;
  675. margin-right: 5px;
  676. float: left;
  677. margin-bottom: 3px;
  678. text-align: center;
  679. color: #000;
  680. font-size: 12px;
  681. }
  682. .classNames {
  683. width: 211px;
  684. height: 25px;
  685. background: #f0f2f5;
  686. font-family: "Source Han Sans CN";
  687. font-weight: normal;
  688. font-size: 16px;
  689. color: #3799ff;
  690. border-radius: 250px;
  691. text-align: center;
  692. margin: 0 auto;
  693. margin-bottom: 10px;
  694. }
  695. /deep/ .el-date-editor .el-range-separator {
  696. line-height: 25px;
  697. }
  698. </style>