heartLog.vue 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664
  1. <template>
  2. <div class="context">
  3. <el-page-header @back="goBack" content="所属设备"></el-page-header>
  4. <div class="panel">
  5. <br>
  6. <h5> {{regionName}}</h5>
  7. </div>
  8. <div class="change">
  9. <el-button @click="addMember" type="primary">新增区域设备</el-button>
  10. <el-button @click="editList">编辑区域设备</el-button>
  11. <!--<el-button @click="delList" type="danger">删除区域设备</el-button>-->
  12. </div>
  13. <div class="table">
  14. <el-table
  15. :data="tableData"
  16. border
  17. is-horizontal-resize
  18. :default-sort="{prop: 'date', order: 'descending'}"
  19. element-loading-background="rgba(0, 0, 0, 0.8)"
  20. class=""
  21. @selection-change="handleSelectionChange" @current-change="clickChange"
  22. >
  23. <el-table-column label="选择" width="55">
  24. <template slot-scope="scope">
  25. <el-radio v-model="tableRadio" :label="scope.row"><i></i></el-radio>
  26. </template>
  27. </el-table-column>
  28. <el-table-column
  29. type="index"
  30. label="序号"
  31. align="center"
  32. width="50">
  33. </el-table-column>
  34. <el-table-column
  35. prop="EqSn"
  36. label="序列号"
  37. >
  38. </el-table-column>
  39. <el-table-column
  40. prop="Version"
  41. label="版本"
  42. sortable
  43. >
  44. </el-table-column>
  45. <el-table-column
  46. prop="EquipType"
  47. label="类型"
  48. sortable
  49. >
  50. <template slot-scope="scope">
  51. <span v-if="scope.row.EquipType == 1">TVBox</span>
  52. <span v-if="scope.row.EquipType == 2">BLEHub</span>
  53. <span v-if="scope.row.EquipType == 3">演示设备</span>
  54. </template>
  55. </el-table-column>
  56. <el-table-column
  57. prop="Status"
  58. label="状态"
  59. sortable
  60. >
  61. <!--1:启用 8:暂停 9:删除-->
  62. <template slot-scope="scope">
  63. <span v-if="scope.row.Status == 1" style="color: yellowgreen">启用</span>
  64. <span v-if="scope.row.Status == 8" style="color: yellow">暂停</span>
  65. <span v-if="scope.row.Status == 9" style="color: red">删除</span>
  66. </template>
  67. </el-table-column>
  68. <el-table-column
  69. prop="address"
  70. label="操作">
  71. <template slot-scope="scope">
  72. <!--<el-button type="success" @click="run(scope.row)" v-if="scope.row.Status == 8">开启</el-button>-->
  73. <!--<el-button type="danger" @click="pause(scope.row)" v-if="scope.row.Status == 1">暂停</el-button>-->
  74. <span v-if="scope.row.EquipType != 3" style="color: red">
  75. <el-button type="danger" size="mini"
  76. @click="pauseRowDel(scope.row)">
  77. 删除
  78. </el-button>
  79. </span>
  80. </template>
  81. </el-table-column>
  82. </el-table>
  83. <br>
  84. <el-pagination
  85. background
  86. :total="pageination.total"
  87. :page-size="pageination.pageItem"
  88. @current-change="pageChange"
  89. ></el-pagination>
  90. </div>
  91. <el-dialog :title="dialogTitle" :visible.sync="dialogMemberVisible" width="650px">
  92. <div class="dialogContent">
  93. <div class="">
  94. <el-form ref="form" :model="form" label-width="160px">
  95. <el-form-item label="设备序列号">
  96. <el-input v-model="form.eqSn "></el-input>
  97. </el-form-item>
  98. <el-form-item label="版本号">
  99. <el-input v-model="form.version"></el-input>
  100. </el-form-item>
  101. <el-form-item label="设备类型">
  102. <el-select v-model="form.equipType " placeholder="请选择">
  103. <el-option
  104. v-for="item in options"
  105. :key="item.value"
  106. :label="item.label"
  107. :value="item.value">
  108. </el-option>
  109. </el-select>
  110. </el-form-item>
  111. </el-form>
  112. </div>
  113. </div>
  114. <div class="dialogFooter">
  115. <el-button type="primary" size="small" v-if="form.btnType == 0" @click="confirmMember">确定</el-button>
  116. <el-button type="primary" size="small" v-if="form.btnType == 1" @click="confirmEditMember">确定
  117. </el-button>
  118. <el-button size="small" @click="dialogMemberVisible = false">取消</el-button>
  119. </div>
  120. </el-dialog>
  121. </div>
  122. </template>
  123. <script>
  124. import Global from '../Global.js'
  125. import {
  126. testTable,
  127. ShopManagerStatusEdit,
  128. QueryVenueEquip,
  129. AddShopVenueEquip,
  130. EditShopVenueEquip,
  131. ShopVenueEquipEditStatus
  132. } from "../api/getApiRes";
  133. let qs = require('qs');
  134. export default {
  135. data() {
  136. return {
  137. regionName: '',
  138. dialogVisible: false,
  139. dialogMemberVisible: false,
  140. dialogTitle: '新增区域设备',
  141. // panel 配置项目
  142. multipleSelection: [],
  143. tableRadio: [],
  144. pageination: {
  145. pageItem: 100,
  146. pageoptions: pageOptions(),
  147. total: 100,
  148. pageIndex: 1,
  149. },
  150. form: {
  151. eqId: '',
  152. eqSn: '',
  153. name: '',
  154. version: '',
  155. userCode: '',
  156. shopId: '',
  157. btnType: 0,
  158. equipType: 1,
  159. },
  160. options: [
  161. {value: 1, label: 'TVBox'},
  162. {value: 2, label: 'BLEHub'},
  163. {value: 3, label: '演示设备'},
  164. ],
  165. shops: [],
  166. tableData: [],
  167. serachBtnStatus: false,
  168. }
  169. },
  170. mounted() {
  171. this.regionName = this.$route.query.name;
  172. this.getTableQuery();
  173. },
  174. methods: {
  175. goBack() {
  176. this.$router.push({
  177. path: '/region', query: {}
  178. });
  179. },
  180. // 删除
  181. pauseRowDel(row) {
  182. let that = this;
  183. let param = {
  184. key: localStorage.ServiceKey,
  185. shopId: localStorage.ServiceId,
  186. svId: row.SvId,
  187. eqId: row.EqId,
  188. status: 9,//1:启用 8:暂停 9:删除
  189. };
  190. let postdata = qs.stringify(param);
  191. this.$confirm('此操作将永久删除该区域设备, 是否继续?', '提示', {
  192. confirmButtonText: '确定',
  193. cancelButtonText: '取消',
  194. type: 'warning'
  195. }).then(() => {
  196. ShopVenueEquipEditStatus(postdata).then(res => {
  197. let json = res;
  198. if (json.Code == 0) {
  199. that.$message({
  200. showClose: true,
  201. message: '选中的区域设备已删除!',
  202. type: 'success'
  203. });
  204. // 重载列表
  205. that.getTableQuery();
  206. } else {
  207. that.$message.error(json.Memo + ' 错误码:' + json.Code);
  208. }
  209. });
  210. }).catch(() => {
  211. this.$message({
  212. type: 'info',
  213. message: '已取消删除'
  214. });
  215. });
  216. },
  217. clearForm() {
  218. // clear
  219. this.form.name = '';
  220. this.form.userCode = '';
  221. this.form.shopId = '';
  222. this.form.eqSn = '';
  223. this.form.version = '';
  224. this.form.equipType = 1;
  225. },
  226. handleSelectionChange(val) {
  227. this.multipleSelection = val;
  228. },
  229. // 新增区域设备
  230. addMember() {
  231. this.clearForm();
  232. this.dialogMemberVisible = true;
  233. this.btnType = 0;
  234. this.dialogTitle = '新增区域设备'
  235. },
  236. clickChange(item) {
  237. this.tableRadio = item
  238. },
  239. // 删除
  240. delList() {
  241. let that = this;
  242. if (this.tableRadio.length == 0) {
  243. this.$message.error("请先选中一条记录");
  244. return false
  245. }
  246. let userId = this.tableRadio.Id;
  247. let param = {
  248. key: localStorage.ServiceKey,
  249. shopId: localStorage.ServiceId,
  250. svId: this.$route.query.svId,
  251. eqId: this.tableRadio.EqId,
  252. status: 9,//1:启用 8:暂停 9:删除
  253. };
  254. let postdata = qs.stringify(param);
  255. this.$confirm('此操作将永久删除该区域设备, 是否继续?', '提示', {
  256. confirmButtonText: '确定',
  257. cancelButtonText: '取消',
  258. type: 'warning'
  259. }).then(() => {
  260. ShopVenueEquipEditStatus(postdata).then(res => {
  261. let json = res;
  262. if (json.Code == 0) {
  263. that.$message({
  264. showClose: true,
  265. message: '选中的区域设备已删除!',
  266. type: 'success'
  267. });
  268. // 重载列表
  269. that.getTableQuery();
  270. } else {
  271. that.$message.error(json.Memo + ' 错误码:' + json.Code);
  272. }
  273. });
  274. }).catch(() => {
  275. this.$message({
  276. type: 'info',
  277. message: '已取消删除'
  278. });
  279. });
  280. },
  281. // 编辑
  282. editList() {
  283. let that = this;
  284. this.clearForm();
  285. if (this.tableRadio.length == 0) {
  286. this.$message.error("请先选中一条记录");
  287. return false
  288. }
  289. let row = this.tableRadio;
  290. this.form.shopid = row.ShopId;
  291. this.form.userId = row.Id;
  292. this.form.name = row.Name;
  293. this.form.userCode = row.Usercode;
  294. this.form.password = '';
  295. this.form.phone = row.Phone;
  296. this.form.eqId = row.EqId;
  297. this.form.eqSn = row.EqSn.trim();
  298. this.form.version = row.Version.trim();
  299. this.form.equipType = row.EquipType;
  300. this.form.memo = row.Memo;
  301. this.form.adminType = row.AdminType;
  302. this.dialogVisible = true;
  303. this.dialogTitle = '编辑区域设备';
  304. this.form.btnType = 1;
  305. this.dialogMemberVisible = true
  306. },
  307. // 确认提交新增区域设备
  308. confirmMember() {
  309. let that = this;
  310. // checkNum
  311. if (!that.form.eqSn) {
  312. this.$message.error('错了哦,设备序列号不能为空');
  313. return false
  314. }
  315. if (that.form.version.length > 10) {
  316. this.$message.error('错了哦,版本号字符不能超过10位');
  317. return false
  318. }
  319. let param = {
  320. key: localStorage.ServiceKey,
  321. shopId: localStorage.ServiceId,
  322. svId: this.$route.query.svId,
  323. eqSn: this.form.eqSn,
  324. version: this.form.version,
  325. equipType: this.form.equipType,
  326. };
  327. let postdata = qs.stringify(param);
  328. AddShopVenueEquip(postdata).then(res => {
  329. let json = res;
  330. if (json.Code == 0) {
  331. // 关闭弹窗
  332. that.dialogMemberVisible = false;
  333. // 重载列表
  334. that.getTableQuery();
  335. that.$message({
  336. showClose: true,
  337. message: '所属设备添加成功!',
  338. type: 'success'
  339. });
  340. } else {
  341. that.$message.error(json.Memo + ' 错误码:' + json.Code);
  342. }
  343. })
  344. },
  345. confirmEditMember() {
  346. let that = this;
  347. console.log(that.form.version.length);
  348. // checkNum
  349. if (!that.form.eqSn) {
  350. this.$message.error('错了哦,设备序列号不能为空');
  351. return false
  352. }
  353. if (that.form.version.length > 10) {
  354. this.$message.error('错了哦,版本号字符不能超过10位');
  355. return false
  356. }
  357. let param = {
  358. key: localStorage.ServiceKey,
  359. shopId: localStorage.ServiceId,
  360. svId: this.$route.query.svId,
  361. eqId: this.form.eqId,
  362. eqSn: this.form.eqSn,
  363. version: this.form.version,
  364. equipType: this.form.equipType,
  365. };
  366. let postdata = qs.stringify(param);
  367. EditShopVenueEquip(postdata).then(res => {
  368. let json = res;
  369. if (json.Code == 0) {
  370. // 关闭弹窗
  371. that.dialogMemberVisible = false;
  372. // 重载列表
  373. that.getTableQuery();
  374. that.$message({
  375. showClose: true,
  376. message: '区域设备信息编辑成功!',
  377. type: 'success'
  378. });
  379. } else {
  380. that.$message.error(json.Memo + ' 错误码:' + json.Code);
  381. }
  382. })
  383. },
  384. // 查询按钮
  385. query() {
  386. // 按钮倒计时
  387. let that = this;
  388. that.serachBtnStatus = true;
  389. let totalTime = 2;
  390. let clock = window.setInterval(() => {
  391. totalTime--;
  392. if (totalTime < 0) {
  393. totalTime = 2;
  394. that.serachBtnStatus = false;
  395. }
  396. }, 1000);
  397. this.getTableQuery();
  398. this.$message.success('查询完毕');
  399. },
  400. // 页面数据查询
  401. getTableQuery() {
  402. let that = this;
  403. that.loading = true;
  404. let param = {
  405. key: localStorage.ServiceKey,
  406. shopId: localStorage.ServiceId,
  407. svId: this.$route.query.svId,
  408. };
  409. let postdata = qs.stringify(param);
  410. QueryVenueEquip(postdata).then(res => {
  411. let json = res;
  412. if (json.Code == 0) {
  413. that.loading = false;
  414. if (json.Rs) {
  415. that.allTableData = json.Rs;
  416. that.recordsTotal = json.Rs.length;
  417. } else {
  418. that.allTableData = [];
  419. that.recordsTotal = 0;
  420. }
  421. // 设置分页数据
  422. that.setPaginations();
  423. } else {
  424. that.$message.error(json.Memo + ' 错误码:' + json.Code);
  425. }
  426. })
  427. },
  428. // 设置分页数据
  429. setPaginations() {
  430. // 分页属性
  431. let that = this;
  432. that.pageination.total = that.recordsTotal;
  433. // 默认分页
  434. that.tableData = that.allTableData.filter((item, index) => {
  435. return index < that.pageination.pageItem;
  436. });
  437. },
  438. // 每页显示数量
  439. handleSizeChange() {
  440. let that = this;
  441. that.tableData = that.allTableData.filter((item, index) => {
  442. return index < that.pageination.pageItem;
  443. });
  444. that.draw = that.pageination.pageItem;
  445. that.getTableQuery();
  446. },
  447. // 翻页
  448. pageChange(pageIndex) {
  449. let that = this;
  450. // 获取当前页
  451. let index = that.pageination.pageItem * (pageIndex - 1);
  452. // 数据总数
  453. let nums = that.pageination.pageItem * pageIndex;
  454. // 容器
  455. let tables = [];
  456. for (var i = index; i < nums; i++) {
  457. if (that.allTableData[i]) {
  458. tables.push(that.allTableData[i])
  459. }
  460. this.tableData = tables;
  461. }
  462. that.start = index * that.draw;
  463. // that.getTableQuery();
  464. },
  465. // 自动排序
  466. sortChange(params) {
  467. console.log(params)
  468. },
  469. // 过滤时间
  470. filterFmtDate(value, row, column) {
  471. let that = this;
  472. return nonTfmtDate(column, 11);
  473. },
  474. // 暂停
  475. pause(row) {
  476. let that = this;
  477. console.log(row);
  478. this.$confirm('是否暂停设备' + row.EqSn + '?', '暂停操作', {
  479. confirmButtonText: '确定',
  480. cancelButtonText: '取消',
  481. type: 'warning'
  482. }).then(() => {
  483. let param = {
  484. key: localStorage.ServiceKey,
  485. shopId: localStorage.ServiceId,
  486. svId: this.$route.query.svId,
  487. eqId: row.EqId,
  488. status: 8,//1:启用 8:暂停 9:删除
  489. };
  490. let postdata = qs.stringify(param);
  491. ShopVenueEquipEditStatus(postdata).then(res => {
  492. let json = res;
  493. if (json.Code == 0) {
  494. that.$message({
  495. showClose: true,
  496. message: row.EqSn + '暂停成功!',
  497. type: 'success'
  498. });
  499. // table 重载
  500. that.getTableQuery();
  501. } else {
  502. that.$message.error(json.Memo + ' 错误码:' + json.Code);
  503. }
  504. })
  505. }).catch(() => {
  506. this.$message({
  507. type: 'info',
  508. message: '已取消暂停'
  509. });
  510. });
  511. },
  512. // 开启
  513. run(row) {
  514. let that = this;
  515. this.$confirm('是否开启设备' + row.EqSn + '?', '开启操作', {
  516. confirmButtonText: '确定',
  517. cancelButtonText: '取消',
  518. type: 'warning'
  519. }).then(() => {
  520. let param = {
  521. key: localStorage.ServiceKey,
  522. shopId: localStorage.ServiceId,
  523. svId: this.$route.query.svId,
  524. eqId: row.EqId,
  525. status: 1,//1:启用 8:暂停 9:删除
  526. };
  527. let postdata = qs.stringify(param);
  528. ShopVenueEquipEditStatus(postdata).then(res => {
  529. let json = res;
  530. if (json.Code == 0) {
  531. that.$message({
  532. showClose: true,
  533. message: row.EqSn + '开启成功!',
  534. type: 'success'
  535. });
  536. // table 重载
  537. that.getTableQuery();
  538. } else {
  539. that.$message.error(json.Memo + ' 错误码:' + json.Code);
  540. }
  541. })
  542. }).catch(() => {
  543. this.$message({
  544. type: 'info',
  545. message: '已取消开启'
  546. });
  547. });
  548. },
  549. },
  550. watch: {
  551. $route(to) {
  552. if (to.name == 'heartLog') {
  553. this.regionName = this.$route.query.name;
  554. this.getTableQuery();
  555. }
  556. },
  557. },
  558. }
  559. </script>
  560. <style scoped>
  561. @import "../assets/css/panel.css";
  562. .context {
  563. height: 770px;
  564. overflow-y: scroll;
  565. display: block;
  566. margin: 0 auto;
  567. background-color: #fff !important;
  568. padding: 30px;
  569. padding-bottom: 60px;
  570. }
  571. .panel-body {
  572. padding: 20px;
  573. background: #F0F2F5;
  574. }
  575. .change {
  576. width: 100%;
  577. overflow: hidden;
  578. display: block;
  579. margin: 0 auto;
  580. padding-top: 10px;
  581. padding-bottom: 10px;
  582. }
  583. .change button {
  584. float: left;
  585. }
  586. .change button.pull-right {
  587. float: right;
  588. }
  589. .dialogTitle {
  590. width: 100%;
  591. overflow: hidden;
  592. display: block;
  593. margin: 0 auto;
  594. color: #000000;
  595. font-size: 18px;
  596. text-align: center;
  597. }
  598. .dialogTitle em {
  599. float: none;
  600. font-style: normal;
  601. color: #3799FF;
  602. margin: 0;
  603. }
  604. /deep/ .el-transfer-panel__item .el-checkbox__input {
  605. left: 40px;
  606. }
  607. .dialogFooter {
  608. width: 90%;
  609. overflow: hidden;
  610. display: block;
  611. margin: 0 auto;
  612. margin-top: 10px;
  613. }
  614. .dialogFooter button {
  615. float: right;
  616. margin-left: 10px;
  617. }
  618. /deep/ .el-date-editor .el-range__icon {
  619. line-height: 22px;
  620. }
  621. .panel /deep/ .el-date-editor .el-range-separator {
  622. line-height: 22px;
  623. }
  624. /deep/ .el-select {
  625. width: 100%;
  626. }
  627. .panel h5 {
  628. font-size: 24px;
  629. }
  630. /*ipad only*/
  631. @media only screen and (max-width: 1366px) {
  632. .panel /deep/ .el-date-editor--daterange {
  633. width: 100%;
  634. }
  635. }
  636. </style>