courseEdit.vue 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140
  1. <template>
  2. <div class="context">
  3. <div class="panel">
  4. <div class="panel-body">
  5. <br>
  6. <el-page-header @back="goBack" content="课程管理">
  7. <br>
  8. </el-page-header>
  9. <span class="classNames">
  10. {{ title }} {{ ClassStateText }}
  11. </span>
  12. <br>
  13. <div class="panel_control">
  14. <el-row :gutter="20">
  15. <el-col :span="4">
  16. <em>会员名:</em>
  17. <el-input v-model="panel.name" placeholder="请输入会员名"></el-input>
  18. </el-col>
  19. <el-col :span="4">
  20. <em>手机号:</em>
  21. <el-input v-model="panel.phone" placeholder="请输入手机号" type="number"></el-input>
  22. </el-col>
  23. <el-col :span="4">
  24. <el-button size="" type="primary" @click="query" plain :disabled="serachBtnStatus">查询
  25. </el-button>
  26. </el-col>
  27. </el-row>
  28. </div>
  29. </div>
  30. <div class="change">
  31. <el-button @click="confirmBegin" type="primary" :disabled="BeginState" v-if="FinishClass == 3">确认上课
  32. </el-button>
  33. <el-button @click="addFinish" type="primary" v-if="FinishClass == 2">确认下课</el-button>
  34. <el-button @click="addFinishMember">添加上课会员</el-button>
  35. </div>
  36. </div>
  37. <div class="table">
  38. <el-table
  39. :data="tableData"
  40. border
  41. is-horizontal-resize
  42. :default-sort="{prop: 'data', order: 'descending'}"
  43. element-loading-background="rgba(0, 0, 0, 0.8)"
  44. class=""
  45. :row-class-name="tableRowClassName"
  46. >
  47. >
  48. <el-table-column
  49. type="index"
  50. label="排名"
  51. align="center"
  52. width="50">
  53. </el-table-column>
  54. <el-table-column
  55. prop="head"
  56. label="头像"
  57. width="75"
  58. align="center"
  59. sortable
  60. >
  61. <template slot-scope="scope">
  62. <div class="demo-image__preview" v-if="scope.row.Head">
  63. <el-image
  64. style="width: 25px; height: 25px"
  65. :src="scope.row.Head"
  66. :preview-src-list="[scope.row.Head]"
  67. >
  68. </el-image>
  69. </div>
  70. <img src="../assets/img/nav/head.png" alt="" v-else width="25px" height="25px">
  71. <!--<img class="head" :src="scope.row.Head" alt="" height="51" width="51" v-if="scope.row.Head">-->
  72. <!--<img class="head" src="../assets/img/nav/head.png" height="51" width="51" v-else/>-->
  73. </template>
  74. </el-table-column>
  75. <el-table-column
  76. prop="Name"
  77. label="会员名"
  78. width="90"
  79. sortable
  80. >
  81. </el-table-column>
  82. <el-table-column
  83. prop="Phone"
  84. label="手机号"
  85. width="120"
  86. sortable
  87. >
  88. </el-table-column>
  89. <el-table-column
  90. prop="ClassName"
  91. label="课程"
  92. width="110"
  93. sortable
  94. >
  95. <template slot-scope="scope">
  96. <span class="lessons"
  97. :style="{ background:scope.row.ClassColor }">{{ scope.row.ClassName }}</span>
  98. </template>
  99. </el-table-column>
  100. <el-table-column
  101. prop="OrderTime"
  102. label="预约时间"
  103. :formatter="filterFmtDate"
  104. sortable
  105. >
  106. </el-table-column>
  107. <el-table-column
  108. prop="RemainTotalhour"
  109. label="剩余课时"
  110. width="110"
  111. sortable
  112. >
  113. </el-table-column>
  114. <el-table-column
  115. prop="group_no"
  116. label="队伍"
  117. width="140"
  118. v-if="ClassType == 2"
  119. sortable
  120. >
  121. <template slot-scope="scope">
  122. <el-select v-model="scope.row.group_no"
  123. filterable
  124. :disabled="FinishClass == 2 && scope.row.DpId != 0"
  125. placeholder="请选团队">
  126. <el-option
  127. v-for="item in panel.groupList"
  128. :key="item.value"
  129. :label="item.label"
  130. :value="item.value">
  131. </el-option>
  132. </el-select>
  133. </template>
  134. </el-table-column>
  135. <el-table-column
  136. prop="BindId"
  137. label="心率带"
  138. sortable
  139. >
  140. <template slot-scope="scope">
  141. <el-select v-model="scope.row.BindId"
  142. @change="bindSensorToUser(scope.row)"
  143. @focus="getSelectHrSensors(scope.row)"
  144. filterable
  145. v-if="!scope.row.BindId" placeholder="请选心率带">
  146. <el-option
  147. v-for="item in panel.bindList"
  148. :key="item.index"
  149. :label="item.label"
  150. :value="item.HrId">
  151. </el-option>
  152. </el-select>
  153. <el-button @click="takeBack(scope.row)" type="danger" v-if="scope.row.BindId"
  154. icon="el-icon-cpu">
  155. {{ scope.row.Sn }}
  156. 设备收回
  157. </el-button>
  158. </template>
  159. </el-table-column>
  160. <el-table-column
  161. prop="Status"
  162. label="状态"
  163. width="110"
  164. sortable
  165. >
  166. <template slot-scope="scope">
  167. <span v-if="scope.row.Status == 1">预约上课 </span>
  168. <span v-if="scope.row.Status == 2">预约未到</span>
  169. <span v-if="scope.row.Status == 3">上课未预约</span>
  170. </template>
  171. </el-table-column>
  172. <el-table-column
  173. prop="Status"
  174. label="操作"
  175. >
  176. <template slot-scope="scope">
  177. <div v-if="scope.row.DpId <= 0">
  178. <el-button type="primary" round v-if="scope.row.Status == 1 " size="mini"
  179. @click="pauseRow(scope.row,2)">
  180. 预约未到
  181. </el-button>
  182. <el-button type="warning" round v-if="scope.row.Status == 2" size="mini"
  183. @click="pauseRow(scope.row,1)">
  184. 上课
  185. </el-button>
  186. <el-button type="danger" round v-if="scope.row.Status == 3" size="mini"
  187. @click="getClassOverDetailDel(scope.row)">
  188. 删除
  189. </el-button>
  190. <em v-if="FinishClass != 3">
  191. <el-button type="warning" round
  192. v-if="scope.row.Status == 1 || scope.row.Status == 3 && FinishClass == 2 "
  193. size="mini"
  194. :disabled="scope.row.HrSubmitFlag == 1"
  195. @click="getClassDetailAndSnAdd(scope.row)">
  196. 提交
  197. </el-button>
  198. </em>
  199. </div>
  200. </template>
  201. </el-table-column>
  202. </el-table>
  203. <br>
  204. <el-pagination
  205. background
  206. :total="pageination.total"
  207. :page-size="pageination.pageItem"
  208. @current-change="pageChange"
  209. ></el-pagination>
  210. </div>
  211. <el-dialog title="添加上课会员" :visible.sync="dialogVisible" width="720px">
  212. <div class="dialogContent viplist">
  213. <span class="blueTitle">{{ ClassName }} {{ BeginTime }}</span>
  214. <div>
  215. <el-transfer filterable v-model="dialogValue" :data="form.dialogdata"
  216. :titles="['会员列表', '已添加会员']"></el-transfer>
  217. </div>
  218. </div>
  219. <div class="dialogFooter">
  220. <el-button type="primary" size="small" @click="confirmMember">确定</el-button>
  221. <el-button size="small" @click="dialogVisible = false">取消</el-button>
  222. </div>
  223. </el-dialog>
  224. <el-dialog title="确认下课" :visible.sync="dialogFinishVisible" width="650px">
  225. <div class="dialogContent">
  226. <span class="blueTitle">{{ ClassName }} {{ BeginTime }}</span>
  227. <div>
  228. <!--<el-transfer filterable v-model="dialogCoachValue" :data="form.dialogCoachdata"-->
  229. <!--:titles="['教练列表', '已添加教练']"></el-transfer>-->
  230. <p>
  231. 您是否确认下课?
  232. <br>
  233. <br>
  234. (确定后将不可再编辑上课学员的信息)
  235. </p>
  236. <br>
  237. </div>
  238. </div>
  239. <div class="dialogFooter">
  240. <el-button type="primary" size="small" @click="confirmClassFinish">确定</el-button>
  241. <el-button size="small" @click="dialogFinishVisible = false">取消</el-button>
  242. </div>
  243. </el-dialog>
  244. </div>
  245. </template>
  246. <script>
  247. import Global from '../Global.js'
  248. import {
  249. ClassDetailQuery,
  250. ClassOverDetailListQuery,
  251. VipUserSimpleQuery,
  252. ClassOverDetailAdd,
  253. ClassDetailAndSnAdd,
  254. ClassOverDetailStatusEdit,
  255. ClassOverDetailDel,
  256. SelectHrSensors,
  257. BindHrSensorsToUser,
  258. UnBindHrSensorsToUser,
  259. ClassStartConfirm,
  260. ShopManagerListQuery,
  261. ClassOverConfirm,
  262. } from "../api/getApiRes";
  263. let qs = require('qs');
  264. export default {
  265. data() {
  266. return {
  267. serachBtnStatus: false,
  268. BeginState: true,//确认上课
  269. tableData: [],
  270. title: '',
  271. ClassType: 0,
  272. PkNum: 0,
  273. ClassStateText: '',
  274. FinishClass: 0,//当前上课状态 1已下课 2已上课 3准备上课 FinishClass
  275. dialogVisible: false,//添加下课会员
  276. dialogFinishVisible: false,//确认下课dialog
  277. dialogLesson: false,//课时调整
  278. dialogGift: false,//赠送课时调整
  279. dialogExpTime: false,//有效期调整
  280. dialogLessonTable: false,//会员课程
  281. dialogTitle: '新增会员',
  282. current: getNowDate(),
  283. dialogValue: [],
  284. dialogCoachValue: [],
  285. BeginTime: '',
  286. ClassName: '',
  287. // panel 配置项目
  288. panel: {
  289. name: '',
  290. phone: '',
  291. usercode: '',
  292. username: '',
  293. compname: '',
  294. keyword: '',
  295. USERCODE: '',
  296. endType: '',
  297. taskstatus: 99,
  298. draw: 1,
  299. start: 0,
  300. recordsTotal: 0,
  301. tableData: [],
  302. allTableData: [],
  303. limit: '10',
  304. multipleSort: false,
  305. loading: false,
  306. fileList: [],
  307. bindList: [
  308. {
  309. value: 0,
  310. HrId: 0,
  311. label: "请选择心率带",
  312. InVenueNo: 0,
  313. index: 0
  314. }
  315. ],
  316. groupList: [
  317. {label: '红队', value: 1},
  318. {label: '蓝队', value: 2},
  319. {label: '黄队', value: 3}
  320. ],
  321. multipleSelection: [],
  322. detectedmac: '',
  323. BeginTime: '',
  324. ClassName: '',
  325. options: [
  326. {value: 99, label: '全部'},
  327. {value: 1, label: '进行中'},
  328. {value: 2, label: '已完成'},
  329. ],
  330. endTypeOptions: [
  331. {value: 99, label: '全部'},
  332. {value: 30, label: '近一个月'},
  333. {value: 7, label: '近一周'},
  334. {value: 1, label: '当日'},
  335. ],
  336. time1: globalBt(),
  337. },
  338. form: {
  339. name: '',
  340. userCode: '',
  341. coach: '',
  342. coachOptions: [],
  343. shopId: '',
  344. memberType: 1,
  345. lesson: 1,
  346. gift: 1,
  347. btnType: 0,//0新建,1编辑编辑
  348. memo: '',
  349. expTime: '',
  350. dialogdata: [],//穿梭待选
  351. dialogValue: [],//穿梭已选
  352. dialogCoachdata: [],//穿梭已选
  353. },
  354. memberTypes: [
  355. {value: 1, label: '年会员'},
  356. {value: 2, label: '充值会员'},
  357. ],
  358. pageination: {
  359. pageItem: 100,
  360. pageoptions: pageOptions(),
  361. total: 100,
  362. pageIndex: 1,
  363. },
  364. }
  365. },
  366. mounted() {
  367. this.getTableQuery();
  368. // this.getSelectHrSensors();
  369. this.ClassType = this.$route.query.ClassType;
  370. this.PkNum = this.$route.query.PkNum;
  371. this.FinishClass = this.$route.query.FinishClass;
  372. this.title = this.$route.query.ClassName + ' ' + this.$route.query.BeginStr + '-' + this.$route.query.EndStr;
  373. },
  374. methods: {
  375. // 请选心率带
  376. bindSensorToUser(row) {
  377. let that = this;
  378. let obj = {};
  379. // 未到用户不能绑心率带
  380. if (row.Status == 2) {
  381. row.BindId = 0;
  382. that.$message.error("会员未到不能绑定心率带");
  383. return false
  384. }
  385. obj = this.panel.bindList.find((item) => {
  386. return item.HrId === row.BindId;
  387. });
  388. // let oldSn = row.BindId == 0 ? row.Sn : '';
  389. let oldSn = "";
  390. let param = {
  391. token: localStorage.token,
  392. shopId: localStorage.shopId,
  393. cfId: row.CfId,
  394. userId: row.UserId,
  395. sn: obj.Sn,
  396. hrId: row.BindId,
  397. };
  398. let postdata = qs.stringify(param);
  399. BindHrSensorsToUser(postdata).then(res => {
  400. let json = res;
  401. if (json.Code == 0) {
  402. that.$message({
  403. showClose: true,
  404. message: '心率带绑定成功!',
  405. type: 'success'
  406. });
  407. // table 重载
  408. that.getTableQuery();
  409. // 重置心率带可选列表
  410. // that.getSelectHrSensors();
  411. } else {
  412. that.$message.error(json.Memo + '错误码:' + json.Code);
  413. }
  414. })
  415. },
  416. // 设备回收
  417. takeBack(row) {
  418. let that = this;
  419. let text = "";
  420. if (this.$route.query.FinishClass == 2) {
  421. text = '当前上课种是否回收用户' + row.Name + '的心率设备?(回收将重置用户的上课成绩)'
  422. } else {
  423. text = '是否回收用户' + row.Name + '的心率设备?'
  424. }
  425. this.$confirm(text, '回收操作', {
  426. confirmButtonText: '确定',
  427. cancelButtonText: '取消',
  428. type: 'warning'
  429. }).then(() => {
  430. let param = {
  431. token: localStorage.token,
  432. cfId: row.CfId,
  433. bindId: row.BindId,
  434. userId: row.UserId,
  435. sn: row.Sn,
  436. };
  437. let postdata = qs.stringify(param);
  438. UnBindHrSensorsToUser(postdata).then(res => {
  439. let json = res;
  440. if (json.Code == 0) {
  441. that.$message({
  442. showClose: true,
  443. message: '心率带' + row.Sn + '回收成功!',
  444. type: 'success'
  445. });
  446. // table 重载
  447. that.getTableQuery();
  448. // 重置心率带可选列表
  449. // that.getSelectHrSensors();
  450. } else {
  451. that.$message.error(json.Memo + '错误码:' + json.Code);
  452. }
  453. })
  454. }).catch(() => {
  455. this.$message({
  456. type: 'info',
  457. message: '已取消回收'
  458. });
  459. });
  460. },
  461. // 确认下课
  462. addFinish() {
  463. this.clearForm();
  464. // 重新获得教练名单
  465. this.getCoachOption();
  466. this.dialogFinishVisible = true;
  467. this.btnType = 0;
  468. this.dialogTitle = '确认下课'
  469. },
  470. // 获取教练选项
  471. getCoachOption() {
  472. let that = this;
  473. let param = {
  474. token: localStorage.token,
  475. name: this.panel.name,//
  476. phone: this.panel.phone,//
  477. shopId: localStorage.ShopId,//
  478. adminType: 4,//
  479. start: 1,//
  480. tableMax: 299,//
  481. };
  482. let postdata = qs.stringify(param);
  483. ShopManagerListQuery(postdata).then(res => {
  484. let json = res;
  485. if (json.Code == 0) {
  486. that.form.dialogCoachdata = turnResToOptionByUsers(json.Rs);
  487. } else {
  488. that.$message.error(json.Memo + '错误码:' + json.Code);
  489. }
  490. })
  491. },
  492. // 确认下课
  493. confirmClassFinish() {
  494. let that = this;
  495. // checkNum
  496. let userlist = that.dialogCoachValue.toString();
  497. let param = {
  498. token: localStorage.token,
  499. stdId: this.$route.query.StdId,
  500. teacherList: userlist
  501. };
  502. let postdata = qs.stringify(param);
  503. // 下课记录详情添加
  504. ClassOverConfirm(postdata).then(res => {
  505. let json = res;
  506. if (json.Code == 0) {
  507. // 关闭弹窗
  508. that.dialogFinishVisible = false;
  509. // 重载列表
  510. that.getTableQuery();
  511. that.$message({
  512. showClose: true,
  513. message: '当前课程已确认下课!',
  514. type: 'success'
  515. });
  516. // 返回下课列表
  517. // that.$router.push({path: '/finish'});
  518. this.$router.go(-1);
  519. } else {
  520. that.$message.error(json.Memo + '错误码:' + json.Code);
  521. }
  522. })
  523. },
  524. // 确认上课
  525. confirmBegin() {
  526. let that = this;
  527. // 没绑心率带不能开课,预约未到的不管他
  528. for (var i = 0; i < this.tableData.length; i++) {
  529. if (this.tableData[i].BindId == 0 && this.tableData[i].Status != 2) {
  530. that.$message.error("会员" + this.tableData[i].Name + '没绑心率带,不能开课');
  531. return false
  532. }
  533. }
  534. let duRs = [];
  535. // "sn":"10001",//心率带
  536. // "group_no":0,// 0不分队 1蓝队 2红队 3黄队
  537. // "begin_time":1605686788,//开始上课时间戳
  538. // "name":"张三",
  539. // "head":"http://192.168.0.2/lhs.png",
  540. // "static_hr":100,
  541. // "sex":1,//性别
  542. // "height":176,
  543. // "age":40,
  544. // "user_id":50,
  545. // "weight":1000
  546. let row;
  547. let begin_time = parseInt(new Date().valueOf() / 1000);
  548. // 过滤未到会员
  549. let curPeolle = this.tableData.filter(item => {
  550. if (item.Status != 2) {
  551. return item
  552. }
  553. });
  554. // 拼装上课人员信息
  555. for (var i = 0; i < curPeolle.length; i++) {
  556. row = curPeolle[i];
  557. // 过滤预约未到
  558. duRs[i] = {
  559. sn: row.Sn,
  560. group_no: row.group_no,//0不分队 1蓝队 2红队 3黄队
  561. begin_time: begin_time,
  562. name: row.Name,
  563. head: row.Head,
  564. static_hr: row.StaticHr,
  565. sex: row.Sex,
  566. height: row.Height,
  567. age: row.Age,
  568. user_id: row.UserId,
  569. weight: row.Weight,
  570. user_md5: row.UserMd5,
  571. birthday: row.Birthday,
  572. }
  573. }
  574. // 确认上课
  575. this.getClassStartConfirm(duRs);
  576. },
  577. // 确认上课
  578. getClassStartConfirm(duRs) {
  579. duRs = '{"Rs":' + JSON.stringify(duRs).toString() + '}';
  580. let that = this;
  581. let param = {
  582. token: localStorage.token,
  583. stdId: this.$route.query.StdId,
  584. duRs: duRs
  585. };
  586. let postdata = qs.stringify(param);
  587. ClassStartConfirm(postdata).then(res => {
  588. let json = res;
  589. if (json.Code == 0) {
  590. that.$message({
  591. showClose: true,
  592. message: '确认上课成功!',
  593. type: 'success'
  594. });
  595. // 返回课程管理
  596. that.$router.push({
  597. path: '/courses', query: {}
  598. });
  599. // that.FinishClass = 2;
  600. // that.getTableQuery();
  601. } else {
  602. that.$message.error(json.Memo + '错误码:' + json.Code);
  603. }
  604. })
  605. },
  606. // 添加下课会员
  607. addFinishMember() {
  608. let that = this;
  609. this.clearForm();
  610. this.getClassVipuserQuery();
  611. this.dialogValue = [];
  612. let std = [];
  613. if (this.tableData) {
  614. this.tableData.map(function (item) {
  615. std.push(item.UserId)
  616. })
  617. }
  618. that.dialogValue = std;
  619. this.dialogVisible = true
  620. },
  621. clearForm() {
  622. // clear
  623. this.form.name = '';
  624. this.form.userCode = '';
  625. this.form.shopId = '';
  626. this.dialogCoachValue = [];
  627. },
  628. // 获取本课程下的会员列表
  629. getClassVipuserQuery() {
  630. let that = this;
  631. let param = {
  632. token: localStorage.token,
  633. // classId: this.$route.query.classId,
  634. };
  635. let postdata = qs.stringify(param);
  636. // ClassVipuserQuery(postdata).then(res => {
  637. VipUserSimpleQuery(postdata).then(res => {
  638. let json = res;
  639. if (json.Code == 0) {
  640. // that.form.dialogdata = turnResToOptionByViper(json.Rs);
  641. that.form.dialogdata = turnResToOptionBySimViper(json.Rs);
  642. console.log(that.form.dialogdata);
  643. } else {
  644. that.$message.error(json.Memo + '错误码:' + json.Code);
  645. }
  646. })
  647. },
  648. // 确认提交下课会员
  649. confirmMember() {
  650. let that = this;
  651. // checkNum
  652. let userlist = that.dialogValue.toString();
  653. let param = {
  654. token: localStorage.token,
  655. stdId: this.$route.query.StdId,
  656. userlist: userlist
  657. };
  658. let postdata = qs.stringify(param);
  659. // 下课记录详情添加
  660. ClassOverDetailAdd(postdata).then(res => {
  661. let json = res;
  662. if (json.Code == 0) {
  663. // 关闭弹窗
  664. that.dialogVisible = false;
  665. // 重载列表
  666. that.getTableQuery();
  667. that.$message({
  668. showClose: true,
  669. message: '会员添加成功!',
  670. type: 'success'
  671. });
  672. } else {
  673. that.$message.error(json.Memo + '错误码:' + json.Code);
  674. }
  675. })
  676. },
  677. pauseRow(row, status) {
  678. let that = this;
  679. let param = {
  680. token: localStorage.token,
  681. stdId: this.$route.query.StdId,
  682. cfId: row.CfId,
  683. status: status,
  684. };
  685. let postdata = qs.stringify(param);
  686. ClassOverDetailStatusEdit(postdata).then(res => {
  687. let json = res;
  688. if (json.Code == 0) {
  689. that.$message({
  690. showClose: true,
  691. message: '执行成功!',
  692. type: 'success'
  693. });
  694. // table 重载
  695. that.getTableQuery();
  696. } else {
  697. that.$message.error(json.Memo + '错误码:' + json.Code);
  698. }
  699. })
  700. },
  701. // 下课记录详情删除
  702. getClassOverDetailDel(row) {
  703. let that = this;
  704. let param = {
  705. token: localStorage.token,
  706. stdId: row.StdId,
  707. cfId: row.CfId,
  708. };
  709. this.$confirm('是否删除用户 ' + row.Name + '?', '提示', {
  710. confirmButtonText: '确定',
  711. cancelButtonText: '取消',
  712. type: 'warning'
  713. }).then(() => {
  714. let postdata = qs.stringify(param);
  715. ClassOverDetailDel(postdata).then(res => {
  716. let json = res;
  717. if (json.Code == 0) {
  718. that.$message({
  719. showClose: true,
  720. message: '当前学生上课记录已删除!',
  721. type: 'success'
  722. });
  723. that.getTableQuery();
  724. } else {
  725. that.$message.error(json.Memo + '错误码:' + json.Code);
  726. }
  727. })
  728. }).catch(() => {
  729. this.$message({
  730. type: 'info',
  731. message: '已取消删除'
  732. });
  733. });
  734. },
  735. // 查询按钮
  736. query() {
  737. let that = this;
  738. that.serachBtnStatus = true;
  739. let totalTime = 2;
  740. let clock = window.setInterval(() => {
  741. totalTime--;
  742. if (totalTime < 0) {
  743. totalTime = 2;
  744. that.serachBtnStatus = false;
  745. }
  746. }, 1000);
  747. this.getTableQuery();
  748. this.$message.success('查询完毕');
  749. },
  750. goBack() {
  751. this.$router.push({
  752. path: '/courses', query: {}
  753. });
  754. },
  755. // 页面数据查询
  756. getTableQuery() {
  757. let that = this;
  758. that.loading = true;
  759. that.BeginState = true;
  760. let param = {
  761. token: localStorage.token,
  762. stdId: this.$route.query.StdId,
  763. start: 1,//
  764. tableMax: 9999,//
  765. };
  766. let postdata = qs.stringify(param);
  767. ClassOverDetailListQuery(postdata).then(res => {
  768. let json = res;
  769. if (json.Code == 0) {
  770. that.loading = false;
  771. if (json.Rs) {
  772. // 没人不允许开课
  773. if (json.Rs.length > 0) {
  774. // 全部预约 都是未到也不允许开课
  775. json.Rs.map(function (item) {
  776. // 只要有一个不是就放开
  777. if (item.Status != 2) {
  778. that.BeginState = false;
  779. }
  780. });
  781. }
  782. // 分队处理
  783. // 未上课的分队,已上课的旧的不处理,新人需要处理
  784. if (that.FinishClass == 3) {
  785. if (that.ClassType == 2) {
  786. that.TurnUnit(json.Rs);
  787. } else {
  788. json.Rs.map(function (item) {
  789. item.group_no = item.GroupNo;
  790. })
  791. }
  792. } else {
  793. // 已上课的状态
  794. json.Rs.map(function (item, i) {
  795. if (that.ClassType == 2) {
  796. if (item.GroupNo == 0) {
  797. item.group_no = i % that.PkNum + 1;
  798. } else {
  799. item.group_no = item.GroupNo;
  800. }
  801. } else {
  802. item.group_no = item.GroupNo;
  803. }
  804. });
  805. }
  806. that.allTableData = json.Rs;
  807. that.recordsTotal = json.Rs.length;
  808. } else {
  809. that.allTableData = [];
  810. that.recordsTotal = 0;
  811. }
  812. // 设置分页数据
  813. that.setPaginations();
  814. } else {
  815. that.$message.error(json.Memo + '错误码:' + json.Code);
  816. }
  817. })
  818. },
  819. // 分队
  820. TurnUnit(Rs) {
  821. let that = this;
  822. // 分拆2队
  823. if (that.PkNum == 2) {
  824. Rs.map(function (item, t) {
  825. item.group_no = t % 2 + 1;
  826. })
  827. }
  828. // 分拆3队
  829. if (that.PkNum == 3) {
  830. Rs.map(function (item, t) {
  831. item.group_no = t % 3 + 1;
  832. })
  833. }
  834. },
  835. // 获取心率带下拉菜单
  836. getSelectHrSensors(row) {
  837. let that = this;
  838. that.loading = true;
  839. let param = {
  840. token: localStorage.token,
  841. shopId: localStorage.shopId,
  842. userId: row.UserId,
  843. };
  844. let postdata = qs.stringify(param);
  845. SelectHrSensors(postdata).then(res => {
  846. let json = res;
  847. if (json.Code == 0) {
  848. that.loading = false;
  849. if (json.Rs) {
  850. that.panel.bindList = json.Rs;
  851. let HrTypeText = "";
  852. json.Rs.map(function (item, i) {
  853. HrTypeText = item.HrType == 1 ? "(私有)" : "";
  854. item.label = "Sn:" + item.Sn + HrTypeText;
  855. item.index = i + 1;
  856. });
  857. that.panel.bindList.push({
  858. value: 0,
  859. HrId: 0,
  860. label: "请选择心率带",
  861. InVenueNo: 0
  862. });
  863. } else {
  864. that.panel.bindList = [];
  865. }
  866. } else {
  867. that.$message.error(json.Memo + '错误码:' + json.Code);
  868. }
  869. })
  870. },
  871. // 设置分页数据
  872. setPaginations() {
  873. // 分页属性
  874. let that = this;
  875. that.pageination.total = that.recordsTotal;
  876. // 默认分页
  877. that.tableData = that.allTableData.filter((item, index) => {
  878. return index < that.pageination.pageItem;
  879. });
  880. },
  881. // 每页显示数量
  882. handleSizeChange() {
  883. let that = this;
  884. that.tableData = that.allTableData.filter((item, index) => {
  885. return index < that.pageination.pageItem;
  886. });
  887. that.draw = that.pageination.pageItem;
  888. // that.getTableQuery();
  889. },
  890. // 翻页
  891. pageChange(pageIndex) {
  892. let that = this;
  893. // 获取当前页
  894. let index = that.pageination.pageItem * (pageIndex - 1);
  895. // 数据总数
  896. let nums = that.pageination.pageItem * pageIndex;
  897. // 容器
  898. let tables = [];
  899. for (var i = index; i < nums; i++) {
  900. if (that.allTableData[i]) {
  901. tables.push(that.allTableData[i])
  902. }
  903. this.tableData = tables;
  904. }
  905. that.start = index * that.draw;
  906. // that.getTableQuery();
  907. },
  908. // 过滤时间
  909. filterFmtDate(value, row, column) {
  910. let that = this;
  911. if (column == "0001-01-01T08:05:43+08:05" || column == "0001-01-01T00:00:00Z") {
  912. return '未预约';
  913. } else {
  914. return nonTfmtDate(column, 11);
  915. }
  916. },
  917. // 提交单人
  918. getClassDetailAndSnAdd(row) {
  919. let begin_time = parseInt(new Date().valueOf() / 1000);
  920. let duRs = [];
  921. if (!row.Sn) {
  922. this.$message.error(row.Name + '没有绑定心率带');
  923. return false
  924. }
  925. // 拼装上课人员信息
  926. duRs[0] = {
  927. sn: row.Sn,
  928. group_no: row.group_no,//0不分队 1蓝队 2红队 3黄队
  929. begin_time: begin_time,
  930. name: row.Name,
  931. head: row.Head,
  932. static_hr: row.StaticHr,
  933. sex: row.Sex,
  934. height: row.Height,
  935. age: row.Age,
  936. user_id: row.UserId,
  937. weight: row.Weight,
  938. user_md5: row.UserMd5,
  939. birthday: row.Birthday,
  940. };
  941. duRs = '{"Rs":' + JSON.stringify(duRs).toString() + '}';
  942. let that = this;
  943. let param = {
  944. token: localStorage.token,
  945. stdId: this.$route.query.StdId,
  946. duRs: duRs
  947. };
  948. let postdata = qs.stringify(param);
  949. ClassDetailAndSnAdd(postdata).then(res => {
  950. let json = res;
  951. if (json.Code == 0) {
  952. that.$message({
  953. showClose: true,
  954. message: '提交成功!',
  955. type: 'success'
  956. });
  957. this.getTableQuery();
  958. } else {
  959. that.$message.error(json.Memo + '错误码:' + json.Code);
  960. }
  961. })
  962. },
  963. tableRowClassName({row, rowIndex}) {
  964. if (row.group_no == 1) {
  965. return 'red-row';
  966. } else if (row.group_no == 2) {
  967. return 'blue-row';
  968. } else if (row.group_no == 3) {
  969. return 'yellow-row';
  970. }
  971. return '';
  972. }
  973. },
  974. watch: {
  975. $route(to) {
  976. if (to.name == 'courseEdit') {
  977. this.getTableQuery();
  978. this.FinishClass = this.$route.query.FinishClass;
  979. this.ClassType = this.$route.query.ClassType;
  980. this.PkNum = this.$route.query.PkNum;
  981. this.title = this.$route.query.ClassName + ' ' + this.$route.query.BeginStr + '-' + this.$route.query.EndStr;
  982. }
  983. },
  984. FinishClass(to) {
  985. switch (parseInt(to)) {
  986. case 1:
  987. this.ClassStateText = "已下课";
  988. break;
  989. case 2:
  990. this.ClassStateText = "已上课";
  991. break;
  992. case 3:
  993. this.ClassStateText = "准备上课";
  994. break;
  995. }
  996. },
  997. PkNum(to) {
  998. let that = this;
  999. console.log(to);
  1000. if (to == 2) {
  1001. that.panel.groupList = [
  1002. {label: '红队', value: 1},
  1003. {label: '蓝队', value: 2},
  1004. ]
  1005. } else {
  1006. that.panel.groupList = [
  1007. {label: '红队', value: 1},
  1008. {label: '蓝队', value: 2},
  1009. {label: '黄队', value: 3}
  1010. ]
  1011. }
  1012. }
  1013. },
  1014. }
  1015. </script>
  1016. <style scoped>
  1017. @import "../assets/css/panel.css";
  1018. .context {
  1019. height: 770px;
  1020. overflow-y: scroll;
  1021. display: block;
  1022. margin: 0 auto;
  1023. background-color: #fff !important;
  1024. padding: 30px;
  1025. }
  1026. .classNames {
  1027. height: 25px;
  1028. background: #f0f2f5;
  1029. font-family: "Source Han Sans CN";
  1030. font-weight: normal;
  1031. font-size: 16px;
  1032. color: #3799ff;
  1033. border-radius: 250px;
  1034. text-align: center;
  1035. margin-top: 15px;
  1036. margin-bottom: 3px;
  1037. float: left;
  1038. padding-left: 10px;
  1039. padding-right: 10px;
  1040. }
  1041. .head {
  1042. overflow: hidden;
  1043. display: block;
  1044. margin: 0 auto;
  1045. border-radius: 250px;
  1046. }
  1047. .panel_control {
  1048. width: 100%;
  1049. overflow: hidden;
  1050. display: block;
  1051. margin: 0 auto;
  1052. }
  1053. /*.panel-body {*/
  1054. .panel_control {
  1055. padding: 20px;
  1056. background: #F0F2F5;
  1057. }
  1058. .change {
  1059. width: 100%;
  1060. overflow: hidden;
  1061. display: block;
  1062. margin: 0 auto;
  1063. padding-top: 10px;
  1064. padding-bottom: 10px;
  1065. }
  1066. .change button {
  1067. float: left;
  1068. }
  1069. .change button.pull-right {
  1070. float: right;
  1071. }
  1072. .lessons {
  1073. padding: 1px 7px;
  1074. border-radius: 250px;
  1075. float: left;
  1076. color: #000;
  1077. }
  1078. /deep/ .el-transfer-panel__item .el-checkbox__input {
  1079. /*float: left;*/
  1080. left: 10%;
  1081. }
  1082. /*/deep/ .el-checkbox .el-checkbox {*/
  1083. /*margin-right: 1px;*/
  1084. /*}*/
  1085. /deep/ .el-checkbox__label span {
  1086. width: 100%;
  1087. white-space: nowrap;
  1088. overflow: hidden;
  1089. text-overflow: ellipsis;
  1090. float: left;
  1091. }
  1092. .cell em {
  1093. margin-left: 5px;
  1094. margin-right: 5px;
  1095. }
  1096. /deep/ .el-transfer-panel .el-transfer-panel__header .el-checkbox .el-checkbox__label span {
  1097. width: 50px;
  1098. float: right;
  1099. right: 0;
  1100. }
  1101. /*/deep/ .el-table .red-row {*/
  1102. /*background: #fb88c1;*/
  1103. /*}*/
  1104. /*/deep/ .el-table .blue-row {*/
  1105. /*background: #7099d0;*/
  1106. /*}*/
  1107. /*/deep/ .el-table .yellow-row {*/
  1108. /*background: #fbe56e;*/
  1109. /*}*/
  1110. </style>