Equip.vue 38 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010
  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="24">
  14. <el-col :span="5">
  15. <em>标签名:</em>
  16. <el-input v-model="panel.tagname" placeholder="请输入标签名"></el-input>
  17. </el-col>
  18. <el-col :span="5">
  19. <em>所属区域:</em>
  20. <el-select v-model="panel.regionid">
  21. <el-option
  22. v-for="item in panel.regionidOptions"
  23. :key="item.Id"
  24. :label="item.DisplayName"
  25. :value="item.Id">
  26. </el-option>
  27. </el-select>
  28. </el-col>
  29. <el-col :span="4">
  30. <el-button size="small" type="primary" @click="query">查询</el-button>
  31. </el-col>
  32. </el-row>
  33. </div>
  34. </div>
  35. </div>
  36. <div class="contorl">
  37. <el-button size="small" type="primary" @click="addList">添加</el-button>
  38. <el-button size="small" type="primary" @click="editList">编辑</el-button>
  39. <el-button size="small" type="primary" @click="delList">删除</el-button>
  40. </div>
  41. <el-table
  42. :data="tableData"
  43. is-horizontal-resize
  44. :default-sort="{prop: 'date', order: 'descending'}"
  45. v-loading="loading"
  46. element-loading-background="rgba(0, 0, 0, 0.8)"
  47. class=""
  48. @selection-change="handleSelectionChange"
  49. stripe
  50. >
  51. <el-table-column
  52. type="selection"
  53. width="55">
  54. </el-table-column>
  55. <el-table-column
  56. type="index"
  57. label="序号"
  58. width="60"
  59. sortable
  60. >
  61. </el-table-column>
  62. <el-table-column
  63. prop="Mac"
  64. label="Mac"
  65. >
  66. </el-table-column>
  67. <el-table-column
  68. prop="TagName"
  69. label="标签名"
  70. >
  71. </el-table-column>
  72. <el-table-column
  73. prop="Location"
  74. label="位置"
  75. width="260"
  76. >
  77. <template slot-scope="scope">
  78. <el-tooltip class="item" effect="dark" :content="scope.row.Location" placement="top-start">
  79. <span>
  80. {{ scope.row.Location.length > 22 ? scope.row.Location.substr(0,22)+'...' : scope.row.Location }}
  81. </span>
  82. </el-tooltip>
  83. </template>
  84. </el-table-column>
  85. <el-table-column
  86. prop="FirmwareVersion"
  87. label="软件版本"
  88. >
  89. </el-table-column>
  90. <el-table-column
  91. prop="HardwareVersion"
  92. label="硬件版本"
  93. >
  94. </el-table-column>
  95. <el-table-column
  96. prop="LastOnline"
  97. label="最近上线"
  98. >
  99. </el-table-column>
  100. <el-table-column
  101. prop="Dayfind"
  102. label="当日报警"
  103. >
  104. </el-table-column>
  105. <el-table-column
  106. prop="Memo"
  107. label="备注"
  108. >
  109. </el-table-column>
  110. <el-table-column
  111. prop="Status"
  112. label="状态"
  113. >
  114. <template slot-scope="scope">
  115. <span v-if="scope.row.Status == 0">已禁用</span>
  116. <span v-if="scope.row.Status == 1">已启用</span>
  117. <span v-if="scope.row.Status == 2">已离线</span>
  118. <span v-if="scope.row.Status == 3">已返厂</span>
  119. <span v-if="scope.row.Status == 4">已离线</span>
  120. </template>
  121. </el-table-column>
  122. <el-table-column
  123. prop="address"
  124. label="操作记录"
  125. width="220"
  126. >
  127. <template slot-scope="scope">
  128. <el-button class="" type="text" @click="goPhoneRecord(scope.row)">手机信号记录</el-button>
  129. <el-button class="" type="text" @click="goWifiRecord(scope.row)">WiFi记录</el-button>
  130. <!--<el-button class="" type="text" @click="goPoster(scope.row)">时间轴</el-button> 这个需要先不做-->
  131. <el-button v-if="scope.row.Status == 1" class="yellow" type="text" @click="pauseRow(scope.row)">禁用
  132. </el-button>
  133. <el-button v-if="scope.row.Status == 0" class="green" type="text" @click="runRow(scope.row)">启用
  134. </el-button>
  135. </template>
  136. </el-table-column>
  137. </el-table>
  138. <br>
  139. <el-pagination
  140. background
  141. :total="pageination.total"
  142. :page-size="pageination.pageItem"
  143. @current-change="pageChange"
  144. ></el-pagination>
  145. <!--<el-button class="down_btn" type="primary" @click="goPoster(scope.row)">下载驱动器todo</el-button>-->
  146. <dialog_referrer_list
  147. :show="dialog_state"
  148. :title="dialog_title"
  149. :large="true"
  150. @dialog_cancel="dialog_cancel"
  151. @dialog_ok="dialog_ok"
  152. >
  153. <div class="dialogContent">
  154. <el-row :gutter="24">
  155. <el-col :span="12">
  156. <label>
  157. MAC地址*
  158. </label>
  159. <el-input v-model="dialog.mac" @keyup.native="autoCompleteMac"
  160. :disabled="dialog_type == 2"></el-input>
  161. </el-col>
  162. <el-col :span="12">
  163. <label>
  164. 标签名*
  165. </label>
  166. <el-input v-model="dialog.tagname"></el-input>
  167. </el-col>
  168. <!--<el-col :span="12">-->
  169. <!--<label>-->
  170. <!--硬件版本-->
  171. <!--</label>-->
  172. <!--<el-input v-model="dialog.HardwareVersion"></el-input>-->
  173. <!--</el-col>-->
  174. <!--<el-col :span="12">-->
  175. <!--<label>-->
  176. <!--esp固件版本-->
  177. <!--</label>-->
  178. <!--<el-input v-model="dialog.FirmwareVersion"></el-input>-->
  179. <!--</el-col>-->
  180. <!--<el-col :span="12">-->
  181. <!--<label>-->
  182. <!--M4固件版本-->
  183. <!--</label>-->
  184. <!--<el-input v-model="dialog.FirmwareScanM4Version"></el-input>-->
  185. <!--</el-col>-->
  186. <!--<el-col :span="12">-->
  187. <!--<label>-->
  188. <!--M0固件版本-->
  189. <!--</label>-->
  190. <!--<el-input v-model="dialog.FirmwareScanM0Version"></el-input>-->
  191. <!--</el-col>-->
  192. <el-col :span="12">
  193. <label>
  194. 购买来源
  195. </label>
  196. <el-input v-model="dialog.purchasesrc"></el-input>
  197. </el-col>
  198. <el-col :span="12">
  199. <label>
  200. 设备所属区域
  201. </label>
  202. <el-select class="selectStyle" ref="regionlevelOne" v-model="dialog.regionId"
  203. placeholder="请选择所属区域">
  204. <el-option
  205. v-for="item in dialog.regionlevelOneIdOptions"
  206. :key="item.Id"
  207. :label="item.Name"
  208. :value="item.Id"
  209. >
  210. </el-option>
  211. </el-select>
  212. </el-col>
  213. <el-col :span="12">
  214. <label>
  215. 坐标说明
  216. </label>
  217. <el-input v-model="dialog.coords_memo "></el-input>
  218. </el-col>
  219. <el-col :span="12">
  220. <label>
  221. 备注
  222. </label>
  223. <el-input v-model="dialog.memo"></el-input>
  224. </el-col>
  225. <el-col :span="24">
  226. <label>
  227. 位置标注
  228. </label>
  229. <div class="imgContianer">
  230. <img :src="dialog.plateImgSrc" alt="">
  231. <div class="pointers" @click="addPoint">
  232. <i v-for="point in dialog.points"
  233. :style="{left:point.x*1+'px',top:point.y * 1+'px'}"></i>
  234. </div>
  235. </div>
  236. </el-col>
  237. </el-row>
  238. </div>
  239. </dialog_referrer_list>
  240. </div>
  241. </template>
  242. <script>
  243. import Global from '../Global.js'
  244. import dialog_referrer_list from '../components/dialog_referrer_list'
  245. import {
  246. DetectorQuery,
  247. GetChildRegionSelect,
  248. DetectorEditStatus,
  249. RegionPictureGetByRegionId,
  250. DetectorAdd,
  251. DetectorEdit,
  252. GetDetectorCoords,
  253. GeFullRegionSelect,
  254. } from '../api/getApiRes.js'
  255. let qs = require('qs');
  256. export default {
  257. data() {
  258. return {
  259. // dialog
  260. dialog_state: false,
  261. dialog_title: '',
  262. dialog_type: '',//类型,1是添加,2是编辑
  263. dialog: {
  264. mac: '',
  265. comId: 1,
  266. regionlevelOneId: 0,
  267. regionId: 0,
  268. tagname: '',
  269. longitude: 0,
  270. latitude: 0,
  271. HardwareVersion: '',
  272. FirmwareVersion: '',
  273. FirmwareScanM4Version: '',
  274. FirmwareScanM0Version: '',
  275. purchasesrc: '',
  276. location: '',
  277. coords_memo: '',
  278. memo: '',
  279. plateImgSrc: '',
  280. regionlevelOneIdOptions: [],
  281. regionIdRoomOptions: [],
  282. points: [],
  283. CoordsId: 0,
  284. },
  285. tabIndex: 0,
  286. tabs: [
  287. {name: '设备管理', url: 'equip'},
  288. ],
  289. // panel 配置项目
  290. panel: {
  291. usercode: '',
  292. username: '',
  293. compname: '',
  294. keyword: '',
  295. USERCODE: '',
  296. taskstatus: 99,
  297. regionid: 0,
  298. regionid2: '',
  299. regionidOptions: [],
  300. regionidOptions2: [],
  301. options: [
  302. {value: 99, label: '全部'},
  303. {value: 1, label: '进行中'},
  304. {value: 2, label: '已完成'},
  305. ],
  306. time1: globalBt2(),
  307. },
  308. pageination: {
  309. pageItem: 10,
  310. pageoptions: pageOptions(),
  311. total: 300,
  312. pageIndex: 1,
  313. },
  314. draw: 1,
  315. start: 0,
  316. recordsTotal: 0,
  317. tableData: [],
  318. allTableData: [],
  319. limit: '10',
  320. multipleSort: false,
  321. loading: true,
  322. fileList: [],
  323. multipleSelection: [],
  324. detectedmac: '',
  325. }
  326. },
  327. mounted() {
  328. if (this.$route.query.RegionId) {
  329. this.panel.regionid = this.$route.query.RegionId;
  330. this.panel.tagname = this.$route.query.TagName;
  331. }
  332. this.getTableQuery();
  333. },
  334. methods: {
  335. // 页面数据查询
  336. getTableQuery() {
  337. let that = this;
  338. // this.getGetChildRegionSelect(0, 1);
  339. this.getGeFullRegionSelect();
  340. that.loading = true;
  341. // 查询检测设备。上级区域id,区域id必传。regionid传0,查询supregionid对应所有子区域的检测设备。 如果supregionid,regionid都传0,默认查询企业ID下所有检测设备
  342. let param = {
  343. token: localStorage.token,
  344. supregionid: 0,//
  345. regionid: this.panel.regionid,//
  346. comid: 1,//
  347. tagname: that.panel.tagname,//标签名
  348. start: 1,//
  349. tableMax: 9999,//
  350. };
  351. let postdata = qs.stringify(param);
  352. DetectorQuery(postdata).then(res => {
  353. let json = res;
  354. if (json.Code == 0) {
  355. that.loading = false;
  356. if (json.Rs) {
  357. that.allTableData = json.Rs;
  358. that.recordsTotal = json.Rs.length;
  359. } else {
  360. that.allTableData = [];
  361. that.recordsTotal = 0;
  362. }
  363. // 设置分页数据
  364. that.setPaginations();
  365. } else {
  366. that.$message.error(json.Memo);
  367. }
  368. })
  369. },
  370. // 获取下级列表
  371. getGeFullRegionSelect() {
  372. let that = this;
  373. let param = {
  374. token: localStorage.token,
  375. };
  376. let postdata = qs.stringify(param);
  377. GeFullRegionSelect(postdata).then(res => {
  378. let json = res;
  379. if (json.Code == 0) {
  380. if (!json.Rs) {
  381. that.$message.error('区域列表为空,请先添加有效区域');
  382. return false
  383. }
  384. that.panel.regionidOptions = json.Rs;
  385. that.panel.regionidOptions.unshift({Id: 0, Name: "全部", DisplayName: "全部"});
  386. } else {
  387. that.$message.error(json.Memo);
  388. }
  389. })
  390. },
  391. // dialog获取下级列表
  392. dialoggetGeFullRegionSelect() {
  393. let that = this;
  394. let param = {
  395. token: localStorage.token,
  396. };
  397. let postdata = qs.stringify(param);
  398. GeFullRegionSelect(postdata).then(res => {
  399. let json = res;
  400. if (json.Code == 0) {
  401. that.dialog.regionlevelOneIdOptions = json.Rs;
  402. that.dialog.regionId = json.Rs[0].Id;
  403. } else {
  404. that.$message.error(json.Memo);
  405. }
  406. })
  407. },
  408. // dialog获取区域下级菜单
  409. dialogGetGetChildRegionSelect(regionId, level) {
  410. let that = this;
  411. let param = {
  412. token: localStorage.token,
  413. regionId: regionId,
  414. };
  415. let postdata = qs.stringify(param);
  416. GetChildRegionSelect(postdata).then(res => {
  417. let json = res;
  418. if (json.Code == 0) {
  419. if (level == 1) {
  420. that.dialog.regionlevelOneIdOptions = json.Rs;
  421. that.dialog.regionlevelOneId = json.Rs[0].Id;
  422. } else {
  423. if (json.Rs) {
  424. that.dialog.regionIdRoomOptions = json.Rs;
  425. that.dialog.regionId = json.Rs[0].Id;
  426. } else {
  427. that.dialog.regionIdRoomOptions = [];
  428. that.dialog.regionId = '';
  429. }
  430. }
  431. } else {
  432. that.$message.error(json.Memo);
  433. }
  434. })
  435. },
  436. // 跳转tab页面
  437. goTab(url) {
  438. this.$router.push({path: url});
  439. },
  440. // 查询按钮
  441. query() {
  442. this.getTableQuery();
  443. this.$message.success('查询完毕');
  444. },
  445. handleSelectionChange(val) {
  446. this.multipleSelection = val;
  447. },
  448. // 设置分页数据
  449. setPaginations() {
  450. // 分页属性
  451. let that = this;
  452. that.pageination.total = that.recordsTotal;
  453. // 默认分页
  454. that.tableData = that.allTableData.filter((item, index) => {
  455. return index < that.pageination.pageItem;
  456. });
  457. },
  458. // 每页显示数量
  459. handleSizeChange() {
  460. let that = this;
  461. that.tableData = that.allTableData.filter((item, index) => {
  462. return index < that.pageination.pageItem;
  463. });
  464. that.draw = that.pageination.pageItem;
  465. that.getTableQuery();
  466. },
  467. // 翻页
  468. pageChange(pageIndex) {
  469. let that = this;
  470. // 获取当前页
  471. let index = that.pageination.pageItem * (pageIndex - 1);
  472. // 数据总数
  473. let nums = that.pageination.pageItem * pageIndex;
  474. // 容器
  475. let tables = [];
  476. for (var i = index; i < nums; i++) {
  477. if (that.allTableData[i]) {
  478. tables.push(that.allTableData[i])
  479. }
  480. this.tableData = tables;
  481. }
  482. that.start = index * that.draw;
  483. that.getTableQuery();
  484. },
  485. // 自动排序
  486. sortChange(params) {
  487. console.log(params)
  488. },
  489. // 过滤时间
  490. filterFmtDate(value, row, column) {
  491. return globalfmtDate(column, 11);
  492. },
  493. addList() {
  494. this.dialog_state = true;
  495. this.dialog_title = '添加设备';
  496. this.dialog_type = 1;
  497. // 重载地区列表
  498. this.getGeFullRegionSelect();
  499. // clear dialog
  500. this.dialog.mac = '';
  501. this.dialog.regionId = '';
  502. this.dialog.tagname = '';
  503. this.dialog.HardwareVersion = '';
  504. this.dialog.FirmwareVersion = '';
  505. this.dialog.FirmwareScanM4Version = '';
  506. this.dialog.FirmwareScanM0Version = '';
  507. this.dialog.location = '';
  508. this.dialog.purchasesrc = '';
  509. this.dialog.memo = '';
  510. this.dialog.coords_memo = '';
  511. this.dialog.points = [{}];
  512. // 加载默认的平面图
  513. // this.dialogGetGetChildRegionSelect(0, 1);
  514. this.dialoggetGeFullRegionSelect()
  515. },
  516. delList() {
  517. let that = this;
  518. // checkNum
  519. if (!this.multipleSelection.length) {
  520. that.$message({
  521. showClose: true,
  522. message: '错了哦,需要先选中至少一条记录',
  523. type: 'error'
  524. });
  525. return false
  526. }
  527. if (this.multipleSelection.length != 1) {
  528. that.$message({
  529. showClose: true,
  530. message: '错了哦,只能选中一条记录',
  531. type: 'error'
  532. });
  533. return false
  534. }
  535. let detectorid = that.multipleSelection[0].Id;
  536. let param = {
  537. token: localStorage.token,
  538. detectorid: detectorid,
  539. status: 9,//0禁用1启用9删除
  540. };
  541. let postdata = qs.stringify(param);
  542. this.$confirm('此操作将永久删除该设备, 是否继续?', '提示', {
  543. confirmButtonText: '确定',
  544. cancelButtonText: '取消',
  545. type: 'warning'
  546. }).then(() => {
  547. DetectorEditStatus(postdata).then(res => {
  548. let json = res;
  549. if (json.Code == 0) {
  550. that.$message({
  551. showClose: true,
  552. message: '选中的设备已删除!',
  553. type: 'success'
  554. });
  555. // 重载列表
  556. that.getTableQuery();
  557. that.dialog_state = false;
  558. } else {
  559. that.$message.error(json.Memo);
  560. }
  561. });
  562. }).catch(() => {
  563. this.$message({
  564. type: 'info',
  565. message: '已取消删除'
  566. });
  567. });
  568. },
  569. editList() {
  570. let that = this;
  571. // checkNum
  572. if (!this.multipleSelection.length) {
  573. this.$message({
  574. showClose: true,
  575. message: '错了哦,需要先选中一条记录',
  576. type: 'error'
  577. });
  578. return false
  579. }
  580. if (this.multipleSelection.length > 1) {
  581. this.$message({
  582. showClose: true,
  583. message: '错了哦,只能选中一条记录',
  584. type: 'error'
  585. });
  586. return false
  587. }
  588. this.dialog_state = true;
  589. this.dialog_title = '编辑设备信息';
  590. this.dialog_type = 2;
  591. // 读取本条记录
  592. let row = this.multipleSelection[0];
  593. this.dialog.eqId = row.Id;
  594. this.dialog.mac = row.Mac;
  595. this.dialog.regionId = row.RegionId;
  596. this.dialog.tagname = row.TagName;
  597. this.dialog.HardwareVersion = row.HardwareVersion;
  598. this.dialog.FirmwareVersion = row.FirmwareVersion;
  599. this.dialog.FirmwareScanM4Version = row.FirmwareScanM4Version;
  600. this.dialog.FirmwareScanM0Version = row.FirmwareScanM0Version;
  601. this.dialog.location = row.Location;
  602. this.dialog.purchasesrc = row.PurchaseSrc;
  603. this.dialog.memo = row.Memo;
  604. // this.dialog.coords_memo = row.coords_memo;
  605. // 重载地区列表
  606. this.getGeFullRegionSelect();
  607. let param = {
  608. token: localStorage.token,
  609. detectorId: row.Id,
  610. };
  611. let postdata = qs.stringify(param);
  612. GetDetectorCoords(postdata).then(res => {
  613. let json = res;
  614. if (json.Code == 0) {
  615. if (json.Rs.length != 0) {
  616. console.log(json.Rs[0]);
  617. that.dialog.points = [{x: json.Rs[0].Width, y: json.Rs[0].Height}];
  618. that.dialog.CoordsId = json.Rs[0].CoordsId;
  619. that.dialog.coords_memo = json.Rs[0].Memo;
  620. } else {
  621. that.dialog.points = [{x: 0, y: 0}];
  622. that.dialog.CoordsId = 0;
  623. }
  624. } else {
  625. that.$message.error(json.Memo);
  626. }
  627. })
  628. },
  629. // 自动补全MAC
  630. autoCompleteMac() {
  631. let text = this.dialog.mac;
  632. if (text.length == 2 || text.length == 5 || text.length == 8 || text.length == 11 || text.length == 14) {
  633. this.dialog.mac = this.dialog.mac.toUpperCase() + ":"
  634. }
  635. if (text.length > 14) {
  636. this.dialog.mac = this.dialog.mac.toUpperCase()
  637. }
  638. },
  639. // 探测记录
  640. goPhoneRecord(row) {
  641. this.$router.push({
  642. path: '/phoneSign',
  643. query:
  644. {
  645. detectorid: row.Id,
  646. comId: 1,
  647. regionId: row.RegionId,
  648. }
  649. });
  650. },
  651. // 探测记录
  652. goWifiRecord(row) {
  653. this.$router.push({
  654. path: '/wifiSign',
  655. query:
  656. {
  657. detectorid: row.Id,
  658. comId: 1,
  659. regionId: row.RegionId,
  660. }
  661. });
  662. },
  663. dialog_cancel() {
  664. let that = this;
  665. that.dialog_state = false;
  666. },
  667. dialog_ok() {
  668. if (this.dialog_type == 1) {
  669. this.confirmAddEquip();
  670. } else {
  671. this.confirmEditEquip();
  672. }
  673. },
  674. // 提交增加新设备
  675. confirmAddEquip() {
  676. let that = this;
  677. // checkVal
  678. if (!that.dialog.mac) {
  679. this.$message.error('错了哦,mac不能为空');
  680. return false
  681. }
  682. if (!checkMac(that.dialog.mac)) {
  683. this.$message.error('错了哦,mac格式不正确');
  684. return false
  685. }
  686. if (!that.dialog.regionId) {
  687. this.$message.error('错了哦,所属区域不能为空');
  688. return false
  689. }
  690. if (!that.dialog.tagname) {
  691. this.$message.error('错了哦,标签名不能为空');
  692. return false
  693. }
  694. if (that.dialog.tagname.length > 20) {
  695. this.$message.error('错了哦,标签名不能超过20个字符');
  696. return false
  697. }
  698. this.selectRegionLabel(that.dialog.regionId);
  699. let param = {
  700. token: localStorage.token,
  701. mac: that.dialog.mac,
  702. comId: 1,
  703. regionId: that.dialog.regionId,
  704. tagname: that.dialog.tagname,
  705. HardwareVersion: that.dialog.HardwareVersion,
  706. FirmwareVersion: that.dialog.FirmwareVersion,
  707. FirmwareScanM4Version: that.dialog.FirmwareScanM4Version,
  708. FirmwareScanM0Version: that.dialog.FirmwareScanM0Version,
  709. location: that.dialog.location,
  710. purchasesrc: that.dialog.purchasesrc,
  711. x: that.dialog.points[0].x,
  712. y: that.dialog.points[0].y,
  713. coords_memo: that.dialog.coords_memo,
  714. memo: that.dialog.memo,
  715. };
  716. let postdata = qs.stringify(param);
  717. DetectorAdd(postdata).then(res => {
  718. let json = res;
  719. if (json.Code == 0) {
  720. that.$message({
  721. showClose: true,
  722. message: '设备添加成功!',
  723. type: 'success'
  724. });
  725. // 重载列表
  726. that.getTableQuery();
  727. that.dialog_state = false;
  728. } else {
  729. that.$message.error(json.Memo);
  730. }
  731. });
  732. },
  733. // 提交编辑设备信息
  734. confirmEditEquip() {
  735. let that = this;
  736. // checkVal
  737. if (!that.dialog.mac) {
  738. this.$message.error('错了哦,mac不能为空');
  739. return false
  740. }
  741. if (!checkMac(that.dialog.mac)) {
  742. this.$message.error('错了哦,mac格式不正确');
  743. return false
  744. }
  745. if (!that.dialog.regionId) {
  746. this.$message.error('错了哦,所属区域不能为空');
  747. return false
  748. }
  749. if (!that.dialog.tagname) {
  750. this.$message.error('错了哦,标签名不能为空');
  751. return false
  752. }
  753. if (that.dialog.tagname.length > 20) {
  754. this.$message.error('错了哦,标签名不能超过20个字符');
  755. return false
  756. }
  757. this.selectRegionLabel(that.dialog.regionId);
  758. let param = {
  759. token: localStorage.token,
  760. detectorid: that.dialog.eqId,
  761. mac: that.dialog.mac,
  762. comId: 1,
  763. regionId: that.dialog.regionId,
  764. tagname: that.dialog.tagname,
  765. HardwareVersion: that.dialog.HardwareVersion,
  766. FirmwareVersion: that.dialog.FirmwareVersion,
  767. FirmwareScanM4Version: that.dialog.FirmwareScanM4Version,
  768. FirmwareScanM0Version: that.dialog.FirmwareScanM0Version,
  769. location: that.dialog.location,
  770. purchasesrc: that.dialog.purchasesrc,
  771. x: that.dialog.points[0].x,
  772. y: that.dialog.points[0].y,
  773. coords_memo: that.dialog.coords_memo,
  774. memo: that.dialog.memo,
  775. coordsType: 1,//坐标状态 0:禁用, 1:启用, 9:删除,没有就传0
  776. coordsID: that.dialog.CoordsId,
  777. };
  778. let postdata = qs.stringify(param);
  779. DetectorEdit(postdata).then(res => {
  780. let json = res;
  781. if (json.Code == 0) {
  782. that.$message({
  783. showClose: true,
  784. message: '设备添加成功!',
  785. type: 'success'
  786. });
  787. // 重载列表
  788. that.getTableQuery();
  789. that.dialog_state = false;
  790. } else {
  791. that.$message.error(json.Memo);
  792. }
  793. });
  794. },
  795. // 编辑设备状态
  796. getDetectorEditStatus(detectorid, status, text) {
  797. let that = this;
  798. let param = {
  799. token: localStorage.token,
  800. detectorid: detectorid,
  801. status: status,
  802. };
  803. let postdata = qs.stringify(param);
  804. DetectorEditStatus(postdata).then(res => {
  805. let json = res;
  806. if (json.Code == 0) {
  807. that.$message({
  808. showClose: true,
  809. message: text + '成功!',
  810. type: 'success'
  811. });
  812. // table 重载
  813. that.getTableQuery();
  814. } else {
  815. that.$message.error(json.Memo);
  816. }
  817. })
  818. },
  819. // 禁用
  820. pauseRow(row) {
  821. let that = this;
  822. this.$confirm('是否禁用' + row.TagName + '设备?', '禁用操作', {
  823. confirmButtonText: '确定',
  824. cancelButtonText: '取消',
  825. type: 'warning'
  826. }).then(() => {
  827. that.getDetectorEditStatus(row.Id, 0, '禁用');
  828. }).catch(() => {
  829. this.$message({
  830. type: 'info',
  831. message: '已取消禁用'
  832. });
  833. });
  834. },
  835. // 获取区域位置的平面图
  836. getRegionPictureGetByRegionId(regionID) {
  837. let that = this;
  838. let param = {
  839. token: localStorage.token,
  840. regionID: regionID,
  841. regionId: regionID,
  842. };
  843. let postdata = qs.stringify(param);
  844. RegionPictureGetByRegionId(postdata).then(res => {
  845. let json = res;
  846. that.dialog.plateImgSrc = '';
  847. if (json.Code == 0) {
  848. that.dialog.plateImgSrc = json.EncodeString;
  849. } else {
  850. that.$message.error(json.Memo);
  851. }
  852. })
  853. },
  854. // 启用
  855. runRow(row) {
  856. console.log(row);
  857. let that = this;
  858. this.$confirm('是否启用' + row.TagName + '设备?', '启用操作', {
  859. confirmButtonText: '确定',
  860. cancelButtonText: '取消',
  861. type: 'warning'
  862. }).then(() => {
  863. that.getDetectorEditStatus(row.Id, 1, '启用');
  864. }).catch(() => {
  865. this.$message({
  866. type: 'info',
  867. message: '已取消启用'
  868. });
  869. });
  870. },
  871. // 添加探测器位置的点坐标
  872. addPoint(e) {
  873. let x = e.offsetX;
  874. let y = e.offsetY;
  875. this.dialog.points = [{x: x, y: y}];
  876. },
  877. // 获取位置的文字内容
  878. selectRegionLabel(id) {
  879. let that = this;
  880. let selectedWorkName = {};
  881. selectedWorkName = this.dialog.regionIdRoomOptions.filter(item => {
  882. if (item.Id === id) {
  883. that.dialog.location = item.Name;
  884. }
  885. });
  886. }
  887. },
  888. watch: {
  889. // 'dialog.regionlevelOneId': function (val) {
  890. // this.dialogGetGetChildRegionSelect(val, 2)
  891. // },
  892. 'dialog.regionId': function (val) {
  893. if (val) {
  894. this.getRegionPictureGetByRegionId(val);
  895. }
  896. },
  897. },
  898. components: {
  899. dialog_referrer_list
  900. }
  901. }
  902. </script>
  903. <style scoped>
  904. @import "../assets/css/panel.css";
  905. @import "../assets/css/dialog.css";
  906. .tabs ul {
  907. width: 168px;
  908. }
  909. table span {
  910. cursor: pointer;
  911. }
  912. .down_btn {
  913. float: left;
  914. }
  915. .content {
  916. width: 98%;
  917. overflow: hidden;
  918. display: block;
  919. margin: 0 auto;
  920. padding-left: 20px;
  921. }
  922. .selectStyle {
  923. width: 100%;
  924. color: #005EA2;
  925. }
  926. .selectStyle ::placeholder {
  927. color: #005EA2;
  928. }
  929. /deep/ .modal .el-select .el-input .el-select__caret {
  930. position: relative;
  931. top: 35px;
  932. }
  933. .imgContianer {
  934. width: 100%;
  935. height: 340px;
  936. overflow: hidden;
  937. display: block;
  938. margin: 0 auto;
  939. }
  940. .imgContianer img {
  941. width: 100%;
  942. height: 100%;
  943. overflow: hidden;
  944. display: block;
  945. margin: 0 auto;
  946. }
  947. .pointers {
  948. position: relative;
  949. bottom: 340px;
  950. width: 100%;
  951. height: 100%;
  952. overflow: hidden;
  953. display: block;
  954. margin: 0 auto;
  955. }
  956. .imgContianer i {
  957. position: relative;
  958. width: 10px;
  959. height: 10px;
  960. float: left;
  961. border-radius: 250px;
  962. background: #FFDD00;
  963. }
  964. /deep/ .modal-dialog {
  965. height: 680px;
  966. margin-top: 20px;
  967. }
  968. /deep/ textarea {
  969. color: #6DC1FF;
  970. }
  971. /deep/ .el-table__empty-text {
  972. color: #015B9E;
  973. }
  974. /deep/ .el-input.is-disabled .el-input__inner {
  975. background-color: #015B9E;
  976. }
  977. </style>