courses.vue 26 KB

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