courseEdit.vue 42 KB

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