Equip.vue 38 KB

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