tb-terminal-list.html 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>设备管理-列表</title>
  5. <meta charset="utf-8">
  6. <meta name="viewport"
  7. content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
  8. <!-- 所有的 css & js 资源 -->
  9. <link rel="stylesheet" href="../../static/kj/element-ui/theme-chalk/index.css">
  10. <link rel="stylesheet" href="../../static/sa.css">
  11. <script src="../../static/kj/vue.min.js"></script>
  12. <script src="../../static/kj/element-ui/index.js"></script>
  13. <script src="../../static/kj/httpVueLoader.js"></script>
  14. <script src="../../static/kj/jquery.min.js"></script>
  15. <script src="../../static/kj/layer/layer.js"></script>
  16. <script src="../../static/sa.js"></script>
  17. </head>
  18. <body>
  19. <div class="vue-box" style="display: none;" :style="'display: block;'">
  20. <div class="c-panel">
  21. <!-- ------------- 检索参数 ------------- -->
  22. <div class="c-title">检索参数</div>
  23. <sa-item type="text" name="名称" v-model="p.name"></sa-item>
  24. <div class="c-item">
  25. <label class="c-label">状态:</label>
  26. <el-select v-model="p.state" placeholder="请选择">
  27. <el-option label="全部" value=""></el-option>
  28. <el-option label="在线" value="在线"></el-option>
  29. <el-option label="离线" value="离线"></el-option>
  30. </el-select>
  31. </div>
  32. <el-button type="primary" icon="el-icon-search" @click="f5()">查询
  33. </el-button>
  34. <sa-item style="display: inline;" type="fast-btn" show="reset"></sa-item>
  35. <!-- ------------- 数据列表 ------------- -->
  36. <el-table class="data-table" ref="data-table" :data="dataList">
  37. <sa-td name="序号" type="index"></sa-td>
  38. <sa-td name="名称" prop="name"></sa-td>
  39. <sa-td name="所属场所" prop="venuesName"></sa-td>
  40. <sa-td name="所在通道" prop="channelName" width="170"></sa-td>
  41. <sa-td name="IP地址" prop="ipAddress" width="140"></sa-td>
  42. <sa-td name="方向" prop="direction" type="enum" :jv="{1: '入场', 2: '离场'}"></sa-td>
  43. <sa-td name="状态" prop="state"></sa-td>
  44. <sa-td name="人员数" prop="personNum"></sa-td>
  45. <sa-td name="创建时间" prop="createTime" width="160"></sa-td>
  46. <el-table-column label="操作" fixed="right" width="420px">
  47. <template slot-scope="s">
  48. <el-button v-if="sa.isAuth('tb-terminal-edit')" class="c-btn" type="primary"
  49. @click="update(s.row)">修改
  50. </el-button>
  51. <el-button v-if="sa.isAuth('tb-terminal-reboot')" class="c-btn" type="success"
  52. @click="restart(s.row)">重启
  53. </el-button>
  54. <el-button v-if="sa.isAuth('tb-terminal-open')" class="c-btn" type="success"
  55. @click="open(s.row)">开门
  56. </el-button>
  57. <el-button v-if="sa.isAuth('tb-terminal-sync-time')" class="c-btn" type="primary"
  58. @click="sync(s.row)">时钟同步
  59. </el-button>
  60. <el-button v-if="sa.isAuth('tb-terminal-down')" class="c-btn" type="primary"
  61. @click="down(s.row)">下发数据
  62. </el-button>
  63. <el-button v-if="sa.isAuth('tb-terminal-clear')" class="c-btn" type="danger"
  64. @click="clear(s.row)">清除
  65. </el-button>
  66. <el-button v-if="sa.isAuth('tb-terminal-unbind')&&s.row.channelId" class="c-btn"
  67. type="danger" @click="unbind(s.row)">解绑
  68. </el-button>
  69. <el-button v-if="sa.isAuth('tb-terminal-del')" class="c-btn" type="danger"
  70. @click="del(s.row)">删除
  71. </el-button>
  72. </template>
  73. </el-table-column>
  74. </el-table>
  75. <!-- ------------- 分页 ------------- -->
  76. <sa-item type="page" :curr.sync="p.pageNo" :size.sync="p.pageSize" :total="dataCount" @change="f5()">
  77. </sa-item>
  78. </div>
  79. </div>
  80. <script>
  81. var app = new Vue({
  82. components: {
  83. "sa-item": httpVueLoader('../../sa-frame/com/sa-item.vue'),
  84. "sa-td": httpVueLoader('../../sa-frame/com/sa-td.vue'),
  85. },
  86. el: '.vue-box',
  87. data: {
  88. p: { // 查询参数
  89. name: '', // 名称
  90. state: '', // 状态(0=离线,1=正常 no-add no-s)
  91. pageNo: 1, // 当前页
  92. pageSize: 15, // 页大小
  93. sortType: 0 // 排序方式
  94. },
  95. dataCount: 0,
  96. dataList: [], // 数据集合
  97. },
  98. methods: {
  99. sync(data) {
  100. sa.ajax('/TbTerminal/sync-time?id=' + data.id, function(res) {
  101. sa.ok('命令已下发');
  102. }.bind(this))
  103. },
  104. down(data) {
  105. sa.confirm('是否确定下发数据?', function() {
  106. sa.ajax('/TbTerminal/down?id=' + data.id, function(res) {
  107. sa.ok('命令已下发');
  108. }.bind(this))
  109. }.bind(this));
  110. },
  111. open(data) {
  112. sa.confirm('是否确定远程开门?', function() {
  113. sa.ajax('/TbTerminal/open?id=' + data.id, function(res) {
  114. sa.ok('命令已下发');
  115. }.bind(this))
  116. }.bind(this));
  117. },
  118. clear(data) {
  119. sa.confirm('是否清除设备所有数据?', function() {
  120. sa.ajax('/TbTerminal/clear?id=' + data.id, function(res) {
  121. sa.ok('命令已下发');
  122. }.bind(this))
  123. }.bind(this));
  124. },
  125. unbind(data) {
  126. sa.confirm('是否解除设备与场所关联?', function() {
  127. sa.ajax('/TbTerminal/unbind?id=' + data.id, function(res) {
  128. sa.ok('设备以解绑');
  129. this.f5();
  130. }.bind(this))
  131. }.bind(this));
  132. },
  133. restart(data) {
  134. sa.confirm('是否重启设备?', function() {
  135. sa.ajax('/TbTerminal/restart?sn=' + data.sn, function(res) {
  136. sa.ok('命令已下发');
  137. }.bind(this))
  138. }.bind(this));
  139. },
  140. // 刷新
  141. f5: function() {
  142. sa.ajax('/TbTerminal/getList', sa.removeNull(this.p), function(res) {
  143. this.dataList = res.data; // 数据
  144. this.dataCount = res.dataCount; // 数据总数
  145. sa.f5TableHeight(); // 刷新表格高度
  146. }.bind(this));
  147. },
  148. // 查看
  149. get: function(data) {
  150. sa.showIframe('数据详情', 'tb-terminal-info.html?id=' + data.id, '1050px', '90%');
  151. },
  152. // 查看 - 根据选中的
  153. getBySelect: function(data) {
  154. var selection = this.$refs['data-table'].selection;
  155. if (selection.length == 0) {
  156. return sa.msg('请选择一条数据')
  157. }
  158. this.get(selection[0]);
  159. },
  160. // 修改
  161. update: function(data) {
  162. sa.showIframe('修改数据', 'tb-terminal-add.html?id=' + data.id, '600px', '60%');
  163. },
  164. // 新增
  165. add: function(data) {
  166. sa.showIframe('新增数据', 'tb-terminal-add.html?id=-1', '1000px', '90%');
  167. },
  168. // 删除
  169. del: function(data) {
  170. sa.confirm('是否删除,此操作不可撤销', function() {
  171. sa.ajax('/TbTerminal/delete?id=' + data.id, function(res) {
  172. sa.arrayDelete(this.dataList, data);
  173. sa.ok('删除成功');
  174. sa.f5TableHeight(); // 刷新表格高度
  175. }.bind(this))
  176. }.bind(this));
  177. },
  178. // 批量删除
  179. deleteByIds: function() {
  180. // 获取选中元素的id列表
  181. let selection = this.$refs['data-table'].selection;
  182. let ids = sa.getArrayField(selection, 'id');
  183. if (selection.length == 0) {
  184. return sa.msg('请至少选择一条数据')
  185. }
  186. // 提交删除
  187. sa.confirm('是否批量删除选中数据?此操作不可撤销', function() {
  188. sa.ajax('/TbTerminal/deleteByIds', {
  189. ids: ids.join(',')
  190. }, function(res) {
  191. sa.arrayDelete(this.dataList, selection);
  192. sa.ok('删除成功');
  193. sa.f5TableHeight(); // 刷新表格高度
  194. }.bind(this))
  195. }.bind(this));
  196. },
  197. },
  198. created: function() {
  199. this.f5();
  200. sa.onInputEnter();
  201. }
  202. })
  203. </script>
  204. </body>
  205. </html>