region.vue 28 KB

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