heartEquip.vue 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762
  1. <template>
  2. <div class="context">
  3. <div class="panel">
  4. <h5>心率设备</h5>
  5. <div class="panel-body">
  6. <div class="panel_control">
  7. <el-row :gutter="20">
  8. <el-col :span="4">
  9. <em>心率设备:</em>
  10. <el-input v-model="panel.str" placeholder="请输入编号" type="number"></el-input>
  11. </el-col>
  12. <el-col :span="4">
  13. <em>设备状态:</em>
  14. <!--status-->
  15. <el-select v-model="panel.status" placeholder="请选择">
  16. <el-option
  17. v-for="item in panel.statusOptions"
  18. :key="item.value"
  19. :label="item.label"
  20. :value="item.value">
  21. </el-option>
  22. </el-select>
  23. </el-col>
  24. <el-col :span="4">
  25. <el-button size="" type="primary" @click="query" plain>查询</el-button>
  26. </el-col>
  27. </el-row>
  28. </div>
  29. </div>
  30. </div>
  31. <div class="change">
  32. <el-button @click="addMember" type="primary">新增心率设备</el-button>
  33. <el-button @click="editList">编辑心率设备</el-button>
  34. <el-button @click="delList" type="danger">删除心率设备</el-button>
  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. @selection-change="handleSelectionChange" @current-change="clickChange"
  45. >
  46. >
  47. <el-table-column label="选择" width="55">
  48. <template slot-scope="scope">
  49. <el-radio v-model="tableRadio" :label="scope.row"><i></i></el-radio>
  50. </template>
  51. </el-table-column>
  52. <el-table-column
  53. type="index"
  54. label="序号"
  55. align="center"
  56. width="50">
  57. </el-table-column>
  58. <el-table-column
  59. prop="Sn"
  60. label="序列号"
  61. align="center"
  62. >
  63. </el-table-column>
  64. <el-table-column
  65. prop="Sn"
  66. label="实体编号"
  67. align="InVenueNo"
  68. >
  69. </el-table-column>
  70. <el-table-column
  71. prop="UserName"
  72. label="用户"
  73. align="center"
  74. sortable
  75. >
  76. <template slot-scope="scope">
  77. {{scope.row.UserName}}
  78. <!--<el-select v-model="scope.row.BindUserId" @change="getRowTop(scope.row)" filterable v-if="scope.row.BindUserId">-->
  79. <!--<el-option-->
  80. <!--v-for="item in panel.options"-->
  81. <!--:key="item.value"-->
  82. <!--:label="item.label"-->
  83. <!--:value="item.value">-->
  84. <!--</el-option>-->
  85. <!--</el-select>-->
  86. <!--<el-button @click="takeBack(scope.row)" type="danger" v-if="!scope.row.BindUserId">{{scope.row.UserName}} 设备收回</el-button>-->
  87. </template>
  88. </el-table-column>
  89. <el-table-column
  90. prop="Status"
  91. label="状态"
  92. align="center"
  93. >
  94. <template slot-scope="scope">
  95. <!--1:启用 8:暂停 9:删除-->
  96. <span v-if="scope.row.Status == 1" style="color: #67c23a">已启用</span>
  97. <span v-if="scope.row.Status == 8" style="color: yellow">已暂停</span>
  98. <span v-if="scope.row.Status == 9" style="color: red">已删除</span>
  99. </template>
  100. </el-table-column>
  101. <el-table-column
  102. prop="id"
  103. label="操作"
  104. >
  105. <template slot-scope="scope">
  106. <el-button type="text" @click="goPage(scope.row)">记录</el-button>
  107. </template>
  108. </el-table-column>
  109. </el-table>
  110. <br>
  111. <el-pagination
  112. background
  113. :total="pageination.total"
  114. :page-size="pageination.pageItem"
  115. @current-change="pageChange"
  116. ></el-pagination>
  117. </div>
  118. <el-dialog :title="dialogTitle" :visible.sync="dialogMemberVisible" width="650px">
  119. <div class="dialogContent">
  120. <div class="">
  121. <el-form ref="form" :model="form" label-width="160px">
  122. <el-form-item label="编号" :required="true">
  123. <el-input v-model="form.sn"></el-input>
  124. </el-form-item>
  125. <el-form-item label="实体编号">
  126. <el-input v-model="form.venueNo"></el-input>
  127. </el-form-item>
  128. </el-form>
  129. </div>
  130. </div>
  131. <div class="dialogFooter">
  132. <el-button type="primary" size="small" v-if="form.btnType == 0" @click="confirmMember">确定</el-button>
  133. <el-button type="primary" size="small" v-if="form.btnType == 1" @click="confirmEditMember">确定
  134. </el-button>
  135. <el-button size="small" @click="dialogMemberVisible = false">取消</el-button>
  136. </div>
  137. </el-dialog>
  138. </div>
  139. </template>
  140. <script>
  141. import Global from '../Global.js'
  142. import {
  143. testTable,
  144. testSelect,
  145. ShopManagerStatusEdit,
  146. ClassDetailOne,
  147. QueryHrSensors,
  148. AddHrSensors,
  149. HrSensorsStatusEdit,
  150. EditHrSensors,
  151. UnBindHrSensorsToUser,
  152. } from "../api/getApiRes";
  153. let qs = require('qs');
  154. export default {
  155. data() {
  156. return {
  157. dialogVisible: false,//其他dialog
  158. dialogMemberVisible: false,//新增心率设备dialog
  159. dialogLesson: false,//课时调整
  160. dialogGift: false,//赠送课时调整
  161. dialogExpTime: false,//有效期调整
  162. dialogLessonTable: false,//心率设备课程
  163. dialogTitle: '新增心率设备',
  164. dialogValue: [],
  165. tableRadio: [],
  166. // panel 配置项目
  167. panel: {
  168. str: '',
  169. phone: '',
  170. compname: '',
  171. keyword: '',
  172. USERCODE: '',
  173. endType: '',
  174. taskstatus: 99,
  175. status: 1,
  176. draw: 1,
  177. start: 0,
  178. recordsTotal: 0,
  179. tableData: [],
  180. allTableData: [],
  181. limit: '10',
  182. multipleSort: false,
  183. loading: false,
  184. fileList: [],
  185. multipleSelection: [],
  186. detectedmac: '',
  187. statusOptions: [
  188. {value: 1, label: '启用'},
  189. {value: 8, label: '暂停'},
  190. {value: 9, label: '删除'},
  191. ], options: [
  192. {value: 99, label: '全部'},
  193. {value: 1, label: '进行中'},
  194. {value: 2, label: '已完成'},
  195. ],
  196. endTypeOptions: [
  197. {value: 99, label: '全部'},
  198. {value: 30, label: '近一个月'},
  199. {value: 7, label: '近一周'},
  200. {value: 1, label: '当日'},
  201. ],
  202. time1: globalBt(),
  203. },
  204. multipleSelection: [],
  205. pageination: {
  206. pageItem: 100,
  207. pageoptions: pageOptions(),
  208. total: 100,
  209. pageIndex: 1,
  210. },
  211. form: {
  212. name: '',
  213. userCode: '',
  214. sn: '',
  215. venueNo: '',
  216. shopId: '',
  217. teacherId: 0,
  218. memberType: 1,
  219. lesson: 1,
  220. gift: 1,
  221. btnType: 0,//0新建,1编辑编辑
  222. memo: '',
  223. phone: '',
  224. expTime: '',
  225. dialogdata: [],//穿梭待选
  226. dialogValue: [],//穿梭已选
  227. },
  228. memberTypes: [
  229. {value: 1, label: '年心率设备'},
  230. {value: 2, label: '充值心率设备'},
  231. ],
  232. tableData: []
  233. }
  234. },
  235. mounted() {
  236. this.getTableQuery();
  237. },
  238. methods: {
  239. // 设备回收
  240. takeBack(row) {
  241. let that = this;
  242. this.$confirm('是否回收用户' + row.name + '的心率设备?', '回收操作', {
  243. confirmButtonText: '确定',
  244. cancelButtonText: '取消',
  245. type: 'warning'
  246. }).then(() => {
  247. let param = {
  248. token: localStorage.token,
  249. Id: row.Id,
  250. status: 0,
  251. };
  252. let postdata = qs.stringify(param);
  253. UnBindHrSensorsToUser(postdata).then(res => {
  254. let json = res;
  255. if (json.Code == 0) {
  256. that.$message({
  257. showClose: true,
  258. message: row.name + '回收成功!',
  259. type: 'success'
  260. });
  261. // table 重载
  262. that.getTableQuery();
  263. } else {
  264. that.$message.error(json.Memo);
  265. }
  266. })
  267. }).catch(() => {
  268. this.$message({
  269. type: 'info',
  270. message: '已取消回收'
  271. });
  272. });
  273. },
  274. goPage(row) {
  275. // 查看绑定记录
  276. this.$router.push({path: '/bindRecord', id: row.id});
  277. },
  278. // 编辑
  279. editList() {
  280. let that = this;
  281. this.clearForm();
  282. console.log(this.tableRadio);
  283. if (this.tableRadio.length == 0) {
  284. this.$message.error("请先选中一条记录");
  285. return false
  286. }
  287. let row = this.tableRadio;
  288. this.form.shopid = row.ShopId;
  289. this.form.userId = row.Id;
  290. this.form.name = row.Name;
  291. this.form.userCode = row.Usercode;
  292. this.form.password = '';
  293. this.form.hrId = row.HrId;
  294. this.form.sn = row.Sn;
  295. this.form.venueNo = row.InVenueNo;
  296. this.dialogVisible = true;
  297. this.dialogTitle = '编辑心率设备';
  298. this.form.btnType = 1;
  299. this.dialogMemberVisible = true
  300. },
  301. clickChange(item) {
  302. this.tableRadio = item
  303. },
  304. // 选择课程后,获取当前课程的建议上课人数和课时消耗
  305. getRowTop(row) {
  306. let that = this;
  307. console.log(row);
  308. let param = {
  309. token: localStorage.token,
  310. classId: row.ClassId,
  311. };
  312. let postdata = qs.stringify(param);
  313. ClassDetailOne(postdata).then(res => {
  314. let json = res;
  315. if (json.Code == 0) {
  316. row.TopLimit = json.Rs.TopLimit;
  317. row.ConsumeHour = json.Rs.ConsumeHour;
  318. } else {
  319. that.$message.error(json.Memo);
  320. }
  321. })
  322. },
  323. // 编辑
  324. editMember(row) {
  325. this.clearForm();
  326. this.form.name = row.Name;
  327. this.form.phone = row.Phone;
  328. this.form.shopId = row.ShopId;
  329. this.form.teacherId = row.TeacherId;
  330. this.form.btnType = 1;
  331. this.dialogMemberVisible = true
  332. this.dialogTitle = '编辑心率设备'
  333. },
  334. // 禁用
  335. pauseRow(row) {
  336. let that = this;
  337. this.$confirm('是否禁用用户' + row.name + '?', '禁用操作', {
  338. confirmButtonText: '确定',
  339. cancelButtonText: '取消',
  340. type: 'warning'
  341. }).then(() => {
  342. let param = {
  343. token: localStorage.token,
  344. Id: row.Id,
  345. status: 0,
  346. };
  347. let postdata = qs.stringify(param);
  348. testTable(postdata).then(res => {
  349. let json = res;
  350. if (json.Code == 0) {
  351. that.$message({
  352. showClose: true,
  353. message: row.name + '禁用成功!',
  354. type: 'success'
  355. });
  356. // table 重载
  357. that.getTableQuery();
  358. } else {
  359. that.$message.error(json.Memo);
  360. }
  361. })
  362. }).catch(() => {
  363. this.$message({
  364. type: 'info',
  365. message: '已取消禁用'
  366. });
  367. });
  368. },
  369. // 启用
  370. runRow(row) {
  371. let that = this;
  372. this.$confirm('是否启用用户' + row.name + '?', '启用操作', {
  373. confirmButtonText: '确定',
  374. cancelButtonText: '取消',
  375. type: 'warning'
  376. }).then(() => {
  377. let param = {
  378. token: localStorage.token,
  379. Id: row.Id,
  380. status: 1,
  381. };
  382. let postdata = qs.stringify(param);
  383. testTable(postdata).then(res => {
  384. let json = res;
  385. if (json.Code == 0) {
  386. that.$message({
  387. showClose: true,
  388. message: row.name + '启用成功!',
  389. type: 'success'
  390. });
  391. // table 重载
  392. that.getTableQuery();
  393. } else {
  394. that.$message.error(json.Memo);
  395. }
  396. })
  397. }).catch(() => {
  398. this.$message({
  399. type: 'info',
  400. message: '已取消启用'
  401. });
  402. });
  403. },
  404. // 关闭所有
  405. allDialogClose() {
  406. this.dialogVisible = false;
  407. this.dialogGift = false;
  408. this.dialogLesson = false;
  409. this.dialogExpTime = false;
  410. this.dialogLessonTable = false;
  411. },
  412. // 确认提交新增心率设备
  413. confirmMember() {
  414. let that = this;
  415. // checkNum
  416. if (!that.form.sn) {
  417. this.$message.error('错了哦,编号不能为空');
  418. return false
  419. }
  420. if (that.form.sn.length > 20) {
  421. this.$message.error('错了哦,编号不能超过20个字符');
  422. return false
  423. }
  424. if (!that.form.venueNo) {
  425. this.$message.error('错了哦,实体序列号不能为空');
  426. return false
  427. }
  428. if (that.form.venueNo.length > 30) {
  429. this.$message.error('错了哦,实体序列号不能超过30个字符');
  430. return false
  431. }
  432. let param = {
  433. token: localStorage.token,
  434. shopId: localStorage.shopId,
  435. sn: that.form.sn,
  436. venueNo: that.form.venueNo,
  437. };
  438. let postdata = qs.stringify(param);
  439. AddHrSensors(postdata).then(res => {
  440. let json = res;
  441. if (json.Code == 0) {
  442. // 关闭弹窗
  443. that.dialogMemberVisible = false;
  444. // 重载列表
  445. that.getTableQuery();
  446. that.$message({
  447. showClose: true,
  448. message: '心率设备添加成功!',
  449. type: 'success'
  450. });
  451. } else {
  452. that.$message.error(json.Memo);
  453. }
  454. })
  455. },
  456. confirmEditMember() {
  457. let that = this;
  458. // checkNum
  459. if (!that.form.sn) {
  460. this.$message.error('错了哦,编号不能为空');
  461. return false
  462. }
  463. if (that.form.sn.length > 20) {
  464. this.$message.error('错了哦,编号不能超过20个字符');
  465. return false
  466. }
  467. if (!that.form.venueNo) {
  468. this.$message.error('错了哦,实体序列号不能为空');
  469. return false
  470. }
  471. if (that.form.venueNo.length > 30) {
  472. this.$message.error('错了哦,实体序列号不能超过30个字符');
  473. return false
  474. }
  475. let param = {
  476. token: localStorage.token,
  477. shopId: localStorage.shopId,
  478. hrId: that.form.hrId,
  479. sn: that.form.sn,
  480. venueNo: that.form.venueNo,
  481. };
  482. let postdata = qs.stringify(param);
  483. EditHrSensors(postdata).then(res => {
  484. let json = res;
  485. if (json.Code == 0) {
  486. // 关闭弹窗
  487. that.dialogMemberVisible = false;
  488. // 重载列表
  489. that.getTableQuery();
  490. that.$message({
  491. showClose: true,
  492. message: '心率设备信息编辑成功!',
  493. type: 'success'
  494. });
  495. } else {
  496. that.$message.error(json.Memo);
  497. }
  498. })
  499. },
  500. // 确认提交课时
  501. confirmLesson() {
  502. let that = this;
  503. // checkNum
  504. let param = {
  505. token: localStorage.token,
  506. userCode: that.form.userCode,
  507. lesson: that.form.lesson,
  508. };
  509. let postdata = qs.stringify(param);
  510. testSelect(postdata).then(res => {
  511. let json = res;
  512. if (json.Code == 0) {
  513. // 关闭弹窗
  514. that.dialogVisible = false;
  515. // 重载列表
  516. that.getTableQuery();
  517. that.$message({
  518. showClose: true,
  519. message: '课时调整成功!',
  520. type: 'success'
  521. });
  522. } else {
  523. that.$message.error(json.Memo);
  524. }
  525. })
  526. },
  527. // 新增心率设备
  528. addMember() {
  529. this.clearForm();
  530. this.dialogMemberVisible = true;
  531. this.btnType = 0;
  532. this.dialogTitle = '新增心率设备'
  533. },
  534. // 删除
  535. delList() {
  536. let that = this;
  537. if (this.tableRadio.length == 0) {
  538. this.$message.error("请先选中一条记录");
  539. return false
  540. }
  541. let hrId = this.tableRadio.HrId;
  542. let param = {
  543. token: localStorage.token,
  544. hrId: hrId,
  545. status: 9,//1:启用,8:暂停,9:删除
  546. };
  547. let postdata = qs.stringify(param);
  548. this.$confirm('此操作将永久删除该心率设备, 是否继续?', '提示', {
  549. confirmButtonText: '确定',
  550. cancelButtonText: '取消',
  551. type: 'warning'
  552. }).then(() => {
  553. HrSensorsStatusEdit(postdata).then(res => {
  554. let json = res;
  555. if (json.Code == 0) {
  556. that.$message({
  557. showClose: true,
  558. message: '选中的心率设备已删除!',
  559. type: 'success'
  560. });
  561. // 重载列表
  562. that.getTableQuery();
  563. } else {
  564. that.$message.error(json.Memo);
  565. }
  566. });
  567. }).catch(() => {
  568. this.$message({
  569. type: 'info',
  570. message: '已取消删除'
  571. });
  572. });
  573. },
  574. handleSelectionChange(val) {
  575. this.multipleSelection = val;
  576. },
  577. // 查询按钮
  578. query() {
  579. this.getTableQuery();
  580. this.$message.success('查询完毕');
  581. },
  582. clearForm() {
  583. // clear
  584. this.form.name = '';
  585. this.form.phone = '';
  586. this.form.userCode = '';
  587. this.form.shopId = '';
  588. },
  589. // 页面数据查询
  590. getTableQuery() {
  591. let that = this;
  592. that.loading = true;
  593. let param = {
  594. token: localStorage.token,
  595. str: this.panel.str,//
  596. status: this.panel.status,//
  597. shopId: localStorage.shopId,//
  598. };
  599. let postdata = qs.stringify(param);
  600. QueryHrSensors(postdata).then(res => {
  601. let json = res;
  602. if (json.Code == 0) {
  603. that.loading = false;
  604. if (json.Rs) {
  605. that.allTableData = json.Rs;
  606. that.recordsTotal = json.Rs.length;
  607. } else {
  608. that.allTableData = [];
  609. that.recordsTotal = 0;
  610. }
  611. // 设置分页数据
  612. that.setPaginations();
  613. } else {
  614. that.$message.error(json.Memo);
  615. }
  616. })
  617. },
  618. // 设置分页数据
  619. setPaginations() {
  620. // 分页属性
  621. let that = this;
  622. that.pageination.total = that.recordsTotal;
  623. // 默认分页
  624. that.tableData = that.allTableData.filter((item, index) => {
  625. return index < that.pageination.pageItem;
  626. });
  627. },
  628. // 每页显示数量
  629. handleSizeChange() {
  630. let that = this;
  631. that.tableData = that.allTableData.filter((item, index) => {
  632. return index < that.pageination.pageItem;
  633. });
  634. that.draw = that.pageination.pageItem;
  635. // that.getTableQuery();
  636. },
  637. // 翻页
  638. pageChange(pageIndex) {
  639. let that = this;
  640. // 获取当前页
  641. let index = that.pageination.pageItem * (pageIndex - 1);
  642. // 数据总数
  643. let nums = that.pageination.pageItem * pageIndex;
  644. // 容器
  645. let tables = [];
  646. for (var i = index; i < nums; i++) {
  647. if (that.allTableData[i]) {
  648. tables.push(that.allTableData[i])
  649. }
  650. this.tableData = tables;
  651. }
  652. that.start = index * that.draw;
  653. // that.getTableQuery();
  654. },
  655. // 自动排序
  656. sortChange(params) {
  657. console.log(params)
  658. },
  659. },
  660. }
  661. </script>
  662. <style scoped>
  663. @import "../assets/css/panel.css";
  664. .context {
  665. height: 770px;
  666. overflow-y: scroll;
  667. display: block;
  668. margin: 0 auto;
  669. background-color: #fff !important;
  670. padding: 30px;
  671. }
  672. .panel-body {
  673. padding: 20px;
  674. background: #F0F2F5;
  675. }
  676. .change {
  677. width: 100%;
  678. overflow: hidden;
  679. display: block;
  680. margin: 0 auto;
  681. padding-top: 10px;
  682. padding-bottom: 10px;
  683. }
  684. .change button {
  685. float: left;
  686. }
  687. .change button.pull-right {
  688. float: right;
  689. }
  690. .dialogTitle {
  691. width: 100%;
  692. overflow: hidden;
  693. display: block;
  694. margin: 0 auto;
  695. color: #000000;
  696. font-size: 18px;
  697. text-align: center;
  698. }
  699. .dialogTitle em {
  700. float: none;
  701. font-style: normal;
  702. color: #3799FF;
  703. margin: 0;
  704. }
  705. /deep/ .el-transfer-panel__item .el-checkbox__input {
  706. left: 40px;
  707. }
  708. .dialogFooter {
  709. width: 90%;
  710. overflow: hidden;
  711. display: block;
  712. margin: 0 auto;
  713. margin-top: 10px;
  714. }
  715. .dialogFooter button {
  716. float: right;
  717. margin-left: 10px;
  718. }
  719. .dialogContent {
  720. width: 100%;
  721. overflow: hidden;
  722. display: block;
  723. margin: 0 auto;
  724. }
  725. .dialogContent .pull-left {
  726. width: 30%;
  727. float: left;
  728. }
  729. .dialogContent .pull-right {
  730. width: 70%;
  731. float: right;
  732. }
  733. </style>