WifiSign.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446
  1. <template>
  2. <div class="content">
  3. <div class="tabs">
  4. <ul>
  5. <li v-for="(tab,i) in tabs" @click="goTab(tab.url)" :class="{'active':tabIndex == i}">
  6. {{tab.name}}
  7. </li>
  8. </ul>
  9. </div>
  10. <div class="panel">
  11. <div class="panel-body">
  12. <div class=" panel_control">
  13. <el-row :gutter="20">
  14. <el-col :span="4">
  15. <em>探测器:</em>
  16. <el-select v-model="panel.detidstr">
  17. <el-option
  18. v-for="item in panel.detOptions"
  19. :key="item.Id"
  20. :label="item.Name"
  21. :value="item.Id">
  22. </el-option>
  23. </el-select>
  24. </el-col>
  25. <el-col :span="4">
  26. <em>信号类型:</em>
  27. <el-select v-model="panel.detectedType">
  28. <el-option
  29. v-for="item in panel.detectedoptions"
  30. :key="item.value"
  31. :label="item.label"
  32. :value="item.value">
  33. </el-option>
  34. </el-select>
  35. </el-col>
  36. <el-col :span="4">
  37. <em>被检Mac:</em>
  38. <el-input v-model="panel.detectedmac" placeholder="请输入被检测设备Mac"></el-input>
  39. </el-col>
  40. <el-col :span="6">
  41. <em>检测时间:</em>
  42. <el-date-picker
  43. v-model="panel.time1"
  44. type="daterange"
  45. range-separator="至"
  46. start-placeholder="开始日期"
  47. end-placeholder="结束日期">
  48. </el-date-picker>
  49. </el-col>
  50. <el-col :span="4">
  51. <el-button size="small" type="primary" @click="query">查询</el-button>
  52. </el-col>
  53. </el-row>
  54. </div>
  55. </div>
  56. </div>
  57. <el-table
  58. :data="tableData"
  59. is-horizontal-resize
  60. :default-sort="{prop: 'date', order: 'descending'}"
  61. v-loading="loading" element-loading-background="rgba(0, 0, 0, 0.8)"
  62. class=""
  63. stripe
  64. >
  65. <el-table-column
  66. type="index"
  67. label="序号"
  68. width="60"
  69. sortable
  70. >
  71. </el-table-column>
  72. <!--<el-table-column-->
  73. <!--prop="DetectorId"-->
  74. <!--label="探测设备ID"-->
  75. <!--width="120"-->
  76. <!--&gt;-->
  77. <!--</el-table-column>-->
  78. <el-table-column
  79. prop="Macstr"
  80. label="Mac地址"
  81. width="160"
  82. >
  83. </el-table-column>
  84. <el-table-column
  85. prop="ProduceCom"
  86. label="品牌"
  87. >
  88. </el-table-column>
  89. <el-table-column
  90. prop="Path"
  91. label="位置"
  92. width="260"
  93. >
  94. <template slot-scope="scope">
  95. <el-tooltip class="item" effect="dark" :content="scope.row.Path" placement="top-start">
  96. <span>
  97. {{ scope.row.Path.length > 20 ? scope.row.Path.substr(0,20)+'...' : scope.row.Path }}
  98. </span>
  99. </el-tooltip>
  100. </template>
  101. </el-table-column>
  102. <el-table-column
  103. prop="SignalIntensity"
  104. label="信号强度"
  105. :formatter="filterSignal"
  106. sortable
  107. width="120"
  108. >
  109. </el-table-column>
  110. <el-table-column
  111. prop="BeginTime"
  112. label="运行时间"
  113. >
  114. <template slot-scope="scope">
  115. {{scope.row.BeginTime|filterFmtDate}} --- {{scope.row.EndTime|filterFmtDate}}
  116. </template>
  117. </el-table-column>
  118. <el-table-column
  119. prop="DeviceType"
  120. label="信号类型"
  121. width="120"
  122. sortable
  123. :formatter="filterDeviceType"
  124. >
  125. </el-table-column>
  126. <el-table-column
  127. prop="DangerLevel"
  128. label="危险等级"
  129. width="120"
  130. sortable
  131. >
  132. <template slot-scope="scope">
  133. <span v-if="scope.row.DangerLevel == -1">正常</span>
  134. <span v-if="scope.row.DangerLevel == 1">可信设备</span>
  135. <span v-if="scope.row.DangerLevel == 2">已处理</span>
  136. <span class="yellow" v-if="scope.row.DangerLevel == 3">危险</span>
  137. <span class="yellow" v-if="scope.row.DangerLevel == 4">危险</span>
  138. </template>
  139. </el-table-column>
  140. <el-table-column
  141. prop="Id"
  142. label="操作"
  143. width="120"
  144. >
  145. <template slot-scope="scope">
  146. <el-button size="small" type="primary" @click="addWhite(scope.row)" v-if="scope.row.DangerLevel != 1">
  147. 加入可信设备
  148. </el-button>
  149. </template>
  150. </el-table-column>
  151. </el-table>
  152. <br>
  153. <el-pagination
  154. background
  155. :total="pageination.total"
  156. :page-size="pageination.pageItem"
  157. @current-change="pageChange"
  158. ></el-pagination>
  159. </div>
  160. </template>
  161. <script>
  162. import Global from '../Global.js'
  163. import {
  164. LogWifiDetectedQueryByDetector,
  165. GetRegionAndDectorSelect,
  166. WhiteListAdd
  167. } from '../api/getApiRes.js'
  168. let qs = require('qs');
  169. export default {
  170. data() {
  171. return {
  172. tabIndex: 1,
  173. tabs: [
  174. {name: '手机信号记录', url: 'phoneSign'},
  175. {name: 'WiFi信号记录', url: 'wifiSign'},
  176. {name: '可信设备', url: 'white'},
  177. ],
  178. // panel 配置项目
  179. panel: {
  180. usercode: '',
  181. username: '',
  182. compname: '',
  183. keyword: '',
  184. USERCODE: '',
  185. detectedType: 99,
  186. detectedoptions: [
  187. {value: 99, label: '全部'},
  188. {value: 1, label: '无线摄像头'},
  189. {value: 2, label: '无线热点'},
  190. {value: 0, label: '其他无线设备'},
  191. ],
  192. detectedmac: '',
  193. taskstatus: 99,
  194. options: [
  195. {value: 99, label: '全部'},
  196. {value: 1, label: '进行中'},
  197. {value: 2, label: '已完成'},
  198. ],
  199. detOptions: [],
  200. detidstr: 0,
  201. time1: globalBt3(1),
  202. },
  203. pageination: {
  204. pageItem: 10,
  205. pageoptions: pageOptions(),
  206. total: 300,
  207. pageIndex: 1,
  208. },
  209. draw: 1,
  210. start: 0,
  211. recordsTotal: 0,
  212. tableData: [],
  213. allTableData: [],
  214. limit: '10',
  215. multipleSort: false,
  216. loading: true,
  217. fileList: [],
  218. multipleSelection: [],
  219. detectedmac: '',
  220. }
  221. },
  222. mounted() {
  223. this.getTableQuery();
  224. },
  225. methods: {
  226. getDetOption() {
  227. let that = this;
  228. let param = {
  229. 'token': localStorage.token,
  230. };
  231. let postdata = qs.stringify(param);
  232. GetRegionAndDectorSelect(postdata).then(res => {
  233. let json = res;
  234. if (json.Code == 0) {
  235. if (!json.DectectorRs) {
  236. that.$message.error('设备列表为空,请先添加有效探测设备');
  237. return false
  238. }
  239. this.panel.detOptions = json.DectectorRs;//所有设备
  240. this.panel.detOptions.unshift({Id: 0, Name: '全部'});
  241. if (this.$route.query.detectorid) {
  242. this.panel.detidstr = parseInt(this.$route.query.detectorid)
  243. } else {
  244. this.panel.detidstr = 0;
  245. }
  246. } else {
  247. that.$message.error(json.Memo + ',错误代码:' + json.Code);
  248. }
  249. })
  250. },
  251. // 跳转tab页面
  252. goTab(url) {
  253. this.$router.push({path: url});
  254. },
  255. // 查询按钮
  256. query() {
  257. this.getTableQuery();
  258. this.$message.success('查询完毕');
  259. },
  260. // 页面数据查询
  261. getTableQuery() {
  262. // 获取探测器列表
  263. this.getDetOption();
  264. let that = this;
  265. that.loading = true;
  266. if (this.$route.query.detectorid) {
  267. this.panel.detidstr = parseInt(this.$route.query.detectorid)
  268. } else {
  269. this.panel.detidstr = 0;
  270. }
  271. let param = {
  272. token: localStorage.token,
  273. detectorId: that.panel.detidstr,//探测器id列表
  274. detectedmac: that.panel.detectedmac,//被检测设备Mac
  275. detectedtype: that.panel.detectedType,//被检测设备类型
  276. bt: globaltime2String(that.panel.time1[0]) + ' 00:00:01',//开始时间
  277. et: globaltime2String(that.panel.time1[1]) + ' 23:59:59',//结束时间
  278. start: 1,//
  279. tableMax: 5000,//
  280. };
  281. let postdata = qs.stringify(param);
  282. LogWifiDetectedQueryByDetector(postdata).then(res => {
  283. let json = res;
  284. if (json.Code == 0) {
  285. that.loading = false;
  286. if (json.Rs) {
  287. that.allTableData = json.Rs;
  288. that.recordsTotal = json.Rs.length;
  289. } else {
  290. that.allTableData = [];
  291. that.recordsTotal = 0;
  292. }
  293. // 设置分页数据
  294. that.setPaginations();
  295. } else {
  296. that.$message.error(json.Memo + ',错误代码:' + json.Code);
  297. }
  298. })
  299. },
  300. // 设置分页数据
  301. setPaginations() {
  302. // 分页属性
  303. let that = this;
  304. that.pageination.total = that.recordsTotal;
  305. // 默认分页
  306. that.tableData = that.allTableData.filter((item, index) => {
  307. return index < that.pageination.pageItem;
  308. });
  309. },
  310. // 每页显示数量
  311. handleSizeChange() {
  312. let that = this;
  313. that.tableData = that.allTableData.filter((item, index) => {
  314. return index < that.pageination.pageItem;
  315. });
  316. that.draw = that.pageination.pageItem;
  317. that.getTableQuery();
  318. },
  319. // 翻页
  320. pageChange(pageIndex) {
  321. let that = this;
  322. // 获取当前页
  323. let index = that.pageination.pageItem * (pageIndex - 1);
  324. // 数据总数
  325. let nums = that.pageination.pageItem * pageIndex;
  326. // 容器
  327. let tables = [];
  328. for (var i = index; i < nums; i++) {
  329. if (that.allTableData[i]) {
  330. tables.push(that.allTableData[i])
  331. }
  332. this.tableData = tables;
  333. }
  334. that.start = index * that.draw;
  335. // that.getTableQuery();
  336. },
  337. // 自动排序
  338. sortChange(params) {
  339. console.log(params)
  340. },
  341. // 过滤金额
  342. filterMoney(value, row, column) {
  343. return parseFloat(column).toFixed(2);
  344. },
  345. filterSignal(val, row, column) {
  346. //127信号是无效强度状态
  347. return column = column == 127 ? '- -' : column;
  348. },
  349. filterDeviceType(val, row, column) {
  350. switch (parseInt(column)) {
  351. case 0:
  352. return '其他无线设备';
  353. break;
  354. case 1:
  355. return '无线摄像头';
  356. break;
  357. case 2:
  358. return '无线热点';
  359. break;
  360. }
  361. },
  362. // 加入可信设备
  363. addWhite(row) {
  364. let that = this;
  365. this.$prompt('请输入备注', '提示', {
  366. confirmButtonText: '确定',
  367. cancelButtonText: '取消',
  368. inputPlaceholder: '备注内容',
  369. inputPattern: /[\u4e00-\u9fa5_a-zA-Z0-9_]{0,10}/,
  370. inputErrorMessage: '备注长度最多10个字'
  371. }).then(({value}) => {
  372. let param = {
  373. token: localStorage.token,
  374. mac: row.Macstr,
  375. regionId: row.RegionId,
  376. dangerLevelUserOwn: 2,//危险类型 1:已处理 2:可信设备
  377. deviceType: row.DeviceType,
  378. name: row.ProduceCom,
  379. memo: value,
  380. };
  381. let postdata = qs.stringify(param);
  382. WhiteListAdd(postdata).then(res => {
  383. let json = res;
  384. if (json.Code == 0) {
  385. this.getTableQuery();
  386. that.$message({
  387. showClose: true,
  388. type: 'success',
  389. message: '当前设备已加入可信设备中'
  390. });
  391. } else {
  392. that.$message.error(json.Memo + ',错误代码:' + json.Code);
  393. }
  394. });
  395. return false
  396. }).catch((e) => {
  397. console.log(e);
  398. that.$message({
  399. type: 'info',
  400. message: '取消加入可信设备'
  401. });
  402. });
  403. }
  404. },
  405. watch: {
  406. // call again the method if the route changes
  407. '$route': function () {
  408. this.getDetOption();
  409. this.getTableQuery();
  410. }
  411. },
  412. filters: {
  413. // 过滤时间
  414. filterFmtDate(column) {
  415. return nonTfmtDate(column, 16);
  416. },
  417. }
  418. }
  419. </script>
  420. <style scoped>
  421. @import "../assets/css/panel.css";
  422. .tabs ul {
  423. width: 492px;
  424. overflow: hidden;
  425. display: block;
  426. margin: 5px auto;
  427. list-style: none;
  428. padding-left: 0;
  429. }
  430. .content {
  431. width: 98%;
  432. overflow: hidden;
  433. display: block;
  434. margin: 0 auto;
  435. padding-left: 20px;
  436. }
  437. </style>