iotdevice.vue 31 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090
  1. <template>
  2. <basic-container>
  3. <el-dialog :append-to-body="true" :close-on-click-modal="false" :modal-append-to-body="false" :visible.sync="alarmRecordVisible" title="历史告警记录"
  4. width="80%" height="50%">
  5. <alarmhistory :imei="imei" ref="alarmRecordRef"></alarmhistory>
  6. </el-dialog>
  7. <el-dialog :append-to-body="true" :close-on-click-modal="false" :modal-append-to-body="false" :visible.sync="editVisible" title="编辑"
  8. width="80%">
  9. <avue-form v-model="editForm" :option="option" @submit="submitSmartDevice">
  10. <template slot="mapSelect">
  11. <input class="el-input--small el-input__inner" placeholder="选择地址" @click="mapVisible2 = true">
  12. </template>
  13. </avue-form>
  14. </el-dialog>
  15. <el-dialog :append-to-body="true" :close-on-click-modal="false" :modal-append-to-body="false" :visible.sync="mapVisible2"
  16. title="编辑地址" width="80%">
  17. <customAvueMap v-if="mapVisible2" v-model="editForm.mapSelect"></customAvueMap>
  18. </el-dialog>
  19. <el-dialog :append-to-body="true" :close-on-click-modal="false" :modal-append-to-body="false" :visible.sync="viewVisible" title="详情"
  20. width="80%">
  21. <avue-form v-model="detailForm" :option="detailoption" disabled="false">
  22. </avue-form>
  23. </el-dialog>
  24. <el-container>
  25. <el-main>
  26. <template>
  27. <el-carousel :interval="5000" type="card" height="200px">
  28. <el-carousel-item v-for="item in deviceCount" :key="item">
  29. <el-container>
  30. <el-header style="background-color: rgb(29,67,58);height: 65px">
  31. <div class="titleLabel">
  32. <el-row :gutter="40">
  33. <div @click="deviceClick(item.deviceType)">
  34. <el-col :span="20"><div class="titleText">{{item.deviceTypeName}}</div></el-col>
  35. <el-col :span="4"><div class="titleCount">{{item.deviceCount}}</div></el-col>
  36. </div>
  37. </el-row>
  38. </div>
  39. </el-header>
  40. <el-main>
  41. <div style="margin-left: 100px">
  42. <avue-data-display :option="dataShow(item)"></avue-data-display>
  43. </div>
  44. </el-main>
  45. </el-container>
  46. </el-carousel-item>
  47. </el-carousel>
  48. </template>
  49. </el-main>
  50. </el-container>
  51. <el-divider class="divider-bottom"></el-divider>
  52. <avue-crud :option="option"
  53. :table-loading="loading"
  54. :data="data"
  55. :page="page"
  56. :permission="permissionList"
  57. :before-open="beforeOpen"
  58. v-model="form"
  59. ref="crud"
  60. @row-update="rowUpdate"
  61. @row-save="rowSave"
  62. @row-del="rowDel"
  63. @search-change="searchChange"
  64. @search-reset="searchReset"
  65. @selection-change="selectionChange"
  66. @current-change="currentChange"
  67. @size-change="sizeChange"
  68. @refresh-change="refreshChange"
  69. @on-load="onLoad"></avue-crud>
  70. <template slot="mapSelectForm" slot-scope="scope">
  71. <div>
  72. <el-button @click="mapVisible = true"> 选择地址</el-button>
  73. <el-dialog :append-to-body="true" :close-on-click-modal="false" :modal-append-to-body="false" :visible.sync="mapVisible"
  74. title="编辑地址" width="80%">
  75. <!-- <customAvueMap v-if="mapVisible" v-model="scope.row.mapSelect"></customAvueMap>-->
  76. <editPolygonMap v-if="mapVisible" v-model="scope.row.mapSelect" :visible.sync="mapVisible"></editPolygonMap>
  77. </el-dialog>
  78. </div>
  79. <!-- <avue-map v-model="scope.row.mapSelect"></avue-map> -->
  80. </template>
  81. <template slot="menu" slot-scope="scope">
  82. <!-- <el-button icon="el-icon-view" type="text" @click="viewDetail(scope.row)">查看</el-button>-->
  83. <el-button v-if="permission.bind_residential" icon="el-icon-paperclip" :class="{changeBind: !!scope.row.residentialId}" type="text" @click="showDeviceBind(scope.row)">{{!scope.row.residentialId ? '设备绑定' : '设备改绑'}}</el-button>
  84. <el-button type="text" size="small" icon="el-icon-setting">
  85. <el-dropdown @command="tip">
  86. <span class="el-dropdown-link">
  87. 操作<i class="el-icon-arrow-down el-icon--right"> </i>
  88. </span>
  89. <el-dropdown-menu slot="dropdown">
  90. <el-dropdown-item icon="el-icon-view" type="text" @click.native="viewDetail(scope.row)">查看</el-dropdown-item>
  91. <el-dropdown-item divided @click.native="edit(scope.row)" icon="el-icon-edit">编辑</el-dropdown-item>
  92. <el-dropdown-item icon="el-icon-paperclip" :class="{changeBind: !!scope.row.residentialId}" type="text" @click.native="showDeviceBind(scope.row)">{{!scope.row.residentialId ? '设备绑定' : '设备改绑'}}</el-dropdown-item>
  93. <el-dropdown-item icon="el-icon-office-building" type="text" @click.native="showEnterpriseSelect(scope.row)">绑定企业</el-dropdown-item>
  94. <el-dropdown-item divided v-if="scope.row.imei!=''" @click.native="viewAlarmRecord(scope.row)" icon="el-icon-bell">历史告警</el-dropdown-item>
  95. </el-dropdown-menu>
  96. </el-dropdown>
  97. </el-button>
  98. </template>
  99. <!-- 小区列表-->
  100. <el-dialog :modal-append-to-body="false" append-to-body :visible.sync="bindVisible" title="设备绑定" center width="20%">
  101. <div style="text-align: center;">
  102. <el-select v-model="selectValue" filterable placeholder="请选择">
  103. <el-option v-for="item in residentialList" :key="item.id" :label="item.name" :value="item.id">
  104. </el-option>
  105. </el-select>
  106. <p style="margin-top: 20px;">
  107. <el-button type="primary" icon="el-icon-paperclip" @click="bindDevice">绑定</el-button>
  108. </p>
  109. </div>
  110. </el-dialog>
  111. <!-- 企业列表-->
  112. <el-dialog :modal-append-to-body="true" append-to-body :visible.sync="enterpriseVisible" title="企业绑定" center width="20%">
  113. <div style="text-align: center;">
  114. <el-select v-model="enterpriseSelect" multiple filterable placeholder="请选择企业">
  115. <el-option v-for="item in enterpriseList" :key="item.id" :label="item.enterpriseName" :value="item.id">
  116. </el-option>
  117. </el-select>
  118. <p style="margin-top: 20px;">
  119. <el-button type="primary" icon="el-icon-office-building" @click="enterpriseBindDevice">绑定</el-button>
  120. </p>
  121. </div>
  122. </el-dialog>
  123. </basic-container>
  124. </template>
  125. <script>
  126. import {
  127. getList,
  128. getDetail,
  129. add,
  130. update,
  131. remove,
  132. deviceListCount
  133. } from "@/api/device/iotdevice";
  134. // import { getList as getUserList} from "@/api/system/user";
  135. import {
  136. mapGetters
  137. } from "vuex";
  138. import {getAllList} from "@/api/community/residential";
  139. import alarmhistory from "../../../components/device/alarmhistory.vue";
  140. import {dataDisplay} from "@/api/dataview/dataviewoption";
  141. import customAvueMap from "../../../components/residential/customAvueMap.vue"
  142. import editPolygonMap from "../../../components/residential/editPolygonMap.vue"
  143. import {getEnterpriseList} from "../../../api/device/iotdevice";
  144. export default {
  145. components:{
  146. alarmhistory,customAvueMap,editPolygonMap
  147. },
  148. data() {
  149. return {
  150. mapVisible:false,
  151. mapVisible2:false,
  152. // alarmRecordForm:{},
  153. // treeDateList:[],
  154. enterpriseVisible:false,
  155. enterpriseList:[],
  156. enterpriseSelect:[],
  157. imei:"",
  158. alarmRecordVisible: false,
  159. editForm: {},
  160. editVisible: false,
  161. residentialId : '',
  162. SmartDeviceStaticVo: {},
  163. deviceCount: {},
  164. allVisible: true,
  165. activeName: "first",
  166. detailVisible: false,
  167. bindVisible: false,
  168. residentialList: [],
  169. selectValue: '',
  170. form: {},
  171. detailForm:{
  172. },
  173. viewVisible:false,
  174. titleText: '',
  175. deviceDetail: {},
  176. alarmData: [],
  177. alarmSetData: [],
  178. homeUserData: [],
  179. bindedHomeUserData: [],
  180. query: {},
  181. loading: true,
  182. page: {
  183. pageSize: 10,
  184. currentPage: 1,
  185. total: 0
  186. },
  187. selectionList: [],
  188. dataShowOption: {},
  189. option: {
  190. height: 'auto',
  191. menuWidth: 300,
  192. calcHeight: 30,
  193. tip: false,
  194. searchShow: true,
  195. searchMenuSpan: 4,
  196. border: true,
  197. index: true,
  198. viewBtn:false,
  199. // addBtn: false,
  200. delBtn: false,
  201. editBtn: false,
  202. selection: true,
  203. dialogClickModal: false,
  204. column: [
  205. {
  206. label: "设备类型",
  207. prop: "deviceType",
  208. type: "select",
  209. searchSpan: 4,
  210. search: true,
  211. dicUrl: "/api/blade-system/dict-biz/dictionary?code=iot_device_type",
  212. props: {
  213. label: "dictValue",
  214. value: "dictKey"
  215. },
  216. rules: [{
  217. required: true,
  218. message: "请选择设备类型",
  219. trigger: "blur"
  220. }]
  221. },
  222. {
  223. label: "设备名称",
  224. prop: "deviceName",
  225. searchSpan: 4,
  226. search: true,
  227. overHidden:true,
  228. rules: [{
  229. required: true,
  230. message: "请输入设备名称",
  231. trigger: "blur"
  232. }]
  233. },
  234. {
  235. label: "IMEI",
  236. prop: "imei",
  237. rules: [{
  238. required: true,
  239. message: "请输入IMEI",
  240. trigger: "blur"
  241. }]
  242. },
  243. {
  244. label: "设备状态",
  245. prop: "deviceStatus",
  246. type: "select",
  247. searchSpan: 4,
  248. search: true,
  249. editDisplay: false,
  250. addDisplay: false,
  251. dicData:[
  252. {
  253. label: "已注册",
  254. value: 0
  255. },
  256. {
  257. label: "已激活",
  258. value: 1
  259. },
  260. {
  261. label: "已注销",
  262. value: 2
  263. }
  264. ]
  265. },
  266. {
  267. label: "在线状态",
  268. prop: "deviceNetStatus",
  269. type: "select",
  270. searchSpan: 4,
  271. search: true,
  272. editDisplay: false,
  273. addDisplay: false,
  274. dicData:[
  275. {
  276. label: "在线",
  277. value: 1
  278. },
  279. {
  280. label: "离线",
  281. value: 2
  282. },
  283. ]
  284. },
  285. /*{
  286. label: "所属园区",
  287. prop: "agencyId",
  288. searchSpan: 4,
  289. slot: true,
  290. search: true,
  291. cascaderItem: ['residentialId'],
  292. type: "select",
  293. remote: true,
  294. dicUrl: "/api/cyzh-community/agency/list",
  295. dicFormatter:(res)=>{
  296. return res.data.records;//返回字典的层级结构
  297. },
  298. props: {
  299. label: "name",
  300. value: "id"
  301. },
  302. rules: [{
  303. required: true,
  304. message: "请选择所属社区",
  305. trigger: "blur"
  306. }]
  307. },
  308. {
  309. label: "所属区域",
  310. prop: "residentialId",
  311. slot: true,
  312. type: "select",
  313. dicUrl: "/api/cyzh-community/residential/list?agencyId={{key}}",
  314. dicFormatter:(res)=>{
  315. return res.data.records;//返回字典的层级结构
  316. },
  317. filterable: true,
  318. props: {
  319. label: "name",
  320. value: "id"
  321. },
  322. rules: [{
  323. required: true,
  324. message: "请选择所属小区",
  325. trigger: "blur"
  326. }]
  327. },*/
  328. {
  329. label: "所属园区",
  330. prop: "agencyName",
  331. },
  332. {
  333. label: "所属区域",
  334. prop: "residentialName",
  335. },
  336. {
  337. label: "经度",
  338. prop: "longitude",
  339. hide: true,
  340. rules: [{
  341. required: false,
  342. message: "请输入经纬度",
  343. trigger: "blur"
  344. }]
  345. },
  346. {
  347. label: "纬度",
  348. prop: "latitude",
  349. hide: true,
  350. rules: [{
  351. required: false,
  352. message: "请输入经纬度",
  353. trigger: "blur"
  354. }]
  355. },
  356. {
  357. label: "安装位置",
  358. prop: "deviceInstallAddress",
  359. rules: [{
  360. required: false,
  361. message: "请输入安装位置",
  362. trigger: "blur"
  363. }]
  364. },
  365. {
  366. label: "最后上线时间",
  367. prop: "lastOnlineAt",
  368. hide: true,
  369. addDisplay: false,
  370. editDisplay: false,
  371. },
  372. {
  373. label: "最后上线时间",
  374. prop: "lastOfflineAt",
  375. hide: true,
  376. addDisplay: false,
  377. editDisplay: false,
  378. },
  379. ]
  380. },
  381. //详情字段
  382. detailoption: {
  383. submitBtn:false,
  384. emptyBtn:false,
  385. disabled: true,
  386. column: [{
  387. label: "设备编码",
  388. prop: "deviceId",
  389. width: 100,
  390. hide: true,
  391. // search:true,
  392. // display: false,
  393. rules: [{
  394. required: true,
  395. message: "请输入设备唯一标识",
  396. trigger: "blur"
  397. }]
  398. },
  399. {
  400. label: "IMEI号",
  401. prop: "imei",
  402. width: 130,
  403. hide: true,
  404. rules: [{
  405. required: true,
  406. message: "请输入IMEI号",
  407. trigger: "blur"
  408. }]
  409. },
  410. {
  411. label: "设备名称",
  412. prop: "deviceName",
  413. searchSpan: 4,
  414. search: true,
  415. // width:200,
  416. overHidden:true,
  417. rules: [{
  418. required: true,
  419. message: "请输入设备名称",
  420. trigger: "blur"
  421. }]
  422. },
  423. {
  424. label: "归属",
  425. prop: "residentialId",
  426. type:"select",
  427. searchSpan: 4,
  428. remote: true,
  429. dicUrl: "/api/cyzh-community/residential/list?name={{key}}",
  430. props:{
  431. label: "name",
  432. value: "id"
  433. },
  434. searchFilterable: true,
  435. search: true,
  436. rules: [{
  437. required: true,
  438. message: "请输入",
  439. trigger: "blur"
  440. }]
  441. },
  442. {
  443. label: "企业",
  444. prop: "enterpriseIds",
  445. type: "select",
  446. searchSpan: 4,
  447. display: false,
  448. hide: true,
  449. remote: true,
  450. dicUrl: "/api/cyzh-enterprise/enterprise/list?enterpriseName={{key}}",
  451. props:{
  452. label: "enterpriseName",
  453. value: "id"
  454. },
  455. searchFilterable: true,
  456. search: false,
  457. rules: [{
  458. required: true,
  459. message: "请输入",
  460. trigger: "blur"
  461. }]
  462. },
  463. {
  464. label: "设备注册平台标识",
  465. prop: "isAep",
  466. type: "select",
  467. width: 80,
  468. dicUrl: "/api/blade-system/dict-biz/dictionary?code=device_registry_label",
  469. props: {
  470. label: 'dictValue',
  471. value: 'dictKey'
  472. },
  473. dataType: "number",
  474. // search: true,
  475. searchLabelWidth: 140,
  476. searchSpan: 8,
  477. rules: [{
  478. required: true,
  479. message: "请输入设备注册平台标识,1:aep,2:华为,3:厂商",
  480. trigger: "blur"
  481. }]
  482. },
  483. {
  484. label: "经纬度",
  485. prop: "latitudeLongitude",
  486. hide: true,
  487. rules: [{
  488. required: true,
  489. message: "请输入经纬度",
  490. trigger: "blur"
  491. }]
  492. },
  493. {
  494. label: "操作者",
  495. prop: "operator",
  496. hide: true,
  497. addDisplay: false,
  498. display: false,
  499. rules: [{
  500. required: false,
  501. message: "请输入操作者",
  502. trigger: "blur"
  503. }]
  504. },
  505. {
  506. label: "产品ID",
  507. prop: "productId",
  508. hide: true,
  509. addDisplay: false,
  510. display: false,
  511. rules: [{
  512. required: false,
  513. message: "请输入产品ID",
  514. trigger: "blur"
  515. }]
  516. },
  517. {
  518. label: "订阅事件",
  519. prop: "autoObserver",
  520. type: "select",
  521. hide: true,
  522. addDisplay: false,
  523. display: false,
  524. dicUrl: "/api/blade-system/dict-biz/dictionary?code=auto_subscribe",
  525. props: {
  526. label: "dictValue",
  527. value: "dictKey"
  528. },
  529. dataType: "number",
  530. rules: [{
  531. required: false,
  532. message: "请输入0 自动订阅(默认),1 取消自动订阅 (LWM2M 协议选填,其他协议不填)",
  533. trigger: "blur"
  534. }]
  535. },
  536. {
  537. label: "设备类型",
  538. prop: "deviceType",
  539. type: "select",
  540. width: 70,
  541. searchSpan: 4,
  542. search: true,
  543. dicUrl: "/api/blade-system/dict-biz/dictionary?code=iot_device_type",
  544. props: {
  545. label: "dictValue",
  546. value: "dictKey"
  547. },
  548. dataType: "string",
  549. // display: false,
  550. rules: [{
  551. required: true,
  552. message: "请输入设备类型",
  553. trigger: "blur"
  554. }]
  555. },
  556. {
  557. label: "设备状态",
  558. prop: "deviceStatus",
  559. type: "select",
  560. search: true,
  561. searchSpan: 4,
  562. width: 70,
  563. display: false,
  564. addDisplay: false,
  565. dicUrl: "/api/blade-system/dict-biz/dictionary?code=device_status",
  566. props: {
  567. label: "dictValue",
  568. value: "dictKey"
  569. },
  570. dataType: "number",
  571. rules: [{
  572. required: true,
  573. message: "请输入设备状态",
  574. trigger: "blur"
  575. }]
  576. },
  577. {
  578. label: "电池电量",
  579. prop: "battery",
  580. slot: true,
  581. width: 100,
  582. display: false,
  583. addDisplay: false,
  584. rules: [{
  585. required: true,
  586. message: "请输入电池电量",
  587. trigger: "blur"
  588. }]
  589. },
  590. {
  591. label: "信号强度",
  592. prop: "signalIntensity",
  593. slot: true,
  594. display: false,
  595. width: 80,
  596. addDisplay: false,
  597. rules: [{
  598. required: true,
  599. message: "请输入信号强度",
  600. trigger: "blur"
  601. }]
  602. },
  603. {
  604. label: "厂家名称",
  605. prop: "manufacturers",
  606. hide: true,
  607. rules: [{
  608. required: false,
  609. message: "请输入厂家名称",
  610. trigger: "blur"
  611. }]
  612. },
  613. {
  614. label: "厂商编号(附录)",
  615. prop: "manufacturersNo",
  616. hide: true,
  617. display: false,
  618. addDisplay: false,
  619. rules: [{
  620. required: false,
  621. message: "请输入厂商编号(附录)",
  622. trigger: "blur"
  623. }]
  624. },
  625. {
  626. label: "设备型号",
  627. prop: "deviceSpecld",
  628. hide: true,
  629. rules: [{
  630. required: false,
  631. message: "请输入设备型号",
  632. trigger: "blur"
  633. }]
  634. },
  635. ]
  636. },
  637. data: []
  638. };
  639. },
  640. computed: {
  641. ...mapGetters(["permission"]),
  642. permissionList() {
  643. return {
  644. addBtn: this.vaildData(this.permission.smartdevice_add, false),
  645. viewBtn: this.vaildData(this.permission.smartdevice_view, false),
  646. delBtn: this.vaildData(this.permission.smartdevice_delete, false),
  647. editBtn: this.vaildData(this.permission.smartdevice_edit, false)
  648. };
  649. },
  650. ids() {
  651. let ids = [];
  652. this.selectionList.forEach(ele => {
  653. ids.push(ele.id);
  654. });
  655. return ids.join(",");
  656. }
  657. },
  658. watch: {
  659. 'form.mapSelect': {
  660. handler: function (value) {
  661. if (!value) {
  662. return
  663. } else {
  664. this.form.longitude = this.form.mapSelect.longitude;
  665. this.form.latitude = this.form.mapSelect.latitude;
  666. this.form.latitudeLongitude = this.form.mapSelect.longitude + ',' + this.form.mapSelect.latitude;
  667. this.form.deviceInstallAddress = this.form.mapSelect.formattedAddress;
  668. }
  669. },
  670. },
  671. 'editForm.mapSelect': {
  672. handler: function (value) {
  673. if (!value) {
  674. return
  675. } else {
  676. this.editForm.longitude = this.editForm.mapSelect.longitude;
  677. this.editForm.latitude = this.editForm.mapSelect.latitude;
  678. this.editForm.latitudeLongitude = this.editForm.mapSelect.longitude + ',' + this.editForm.mapSelect.latitude;
  679. // this.editForm.deviceInstallAddress = this.editForm.mapSelect.formattedAddress;
  680. }
  681. },
  682. },
  683. },
  684. created() {
  685. deviceListCount().then(res =>{
  686. this.deviceCount = res.data.data;
  687. })
  688. },
  689. mounted() {
  690. // this.option.column[4].search = this.permission.bind_enterprises;
  691. let tenantType = localStorage.getItem("tenantType");
  692. const residentialColumn = this.findObject(this.option.column, "residentialId");
  693. if (tenantType == 1) { //园区
  694. residentialColumn.label = "所属区域";
  695. } else { //社区
  696. residentialColumn.label = "所属小区";
  697. }
  698. },
  699. methods: {
  700. dataShow(obj){
  701. return dataDisplay(obj,this)
  702. },
  703. select(deviceType,deviceStatus,params={}) {
  704. this.$refs.crud.searchForm.deviceType = deviceType;
  705. this.query.deviceType = deviceType;
  706. this.$refs.crud.searchForm.deviceStatus = deviceStatus;
  707. this.query.deviceStatus = deviceStatus;
  708. this.onLoad(this.page,this.query);
  709. },
  710. enterpriseBindDevice(){
  711. let enterpriseSelectStr = '';
  712. for (let i = 0; i < this.enterpriseSelect.length; i++){
  713. enterpriseSelectStr += this.enterpriseSelect[i]+',';
  714. }
  715. this.form.enterpriseIds = enterpriseSelectStr;
  716. console.log(this.form.enterpriseIds);
  717. //保存
  718. update(this.form).then(() => {
  719. this.onLoad(this.page);
  720. this.enterpriseVisible = false;
  721. this.$message({
  722. type: "success",
  723. message: "操作成功!"
  724. });
  725. }, error => {
  726. console.log(error);
  727. });
  728. },
  729. showEnterpriseSelect(row){
  730. if (this.enterpriseList.length == 0){
  731. // 请求获取企业列表
  732. getEnterpriseList(5000).then(res => {
  733. console.log(res.data.data,"企业列表数据");
  734. this.enterpriseList = res.data.data.records;
  735. this.enterpriseVisible = true;
  736. console.log(res);
  737. })
  738. }else{
  739. this.enterpriseVisible = true;
  740. }
  741. this.form = row;
  742. },
  743. viewAlarmRecord(row,params={}){
  744. this.imei = row.imei;
  745. this.alarmRecordVisible = true;
  746. this.$nextTick(()=>{
  747. this.$refs.alarmRecordRef.init();
  748. })
  749. },
  750. submitSmartDevice(row,done,loading){
  751. update(this.editForm).then(() => {
  752. this.onLoad(this.page);
  753. this.editVisible = false;
  754. this.$message({
  755. type: "success",
  756. message: "操作成功!"
  757. });
  758. done();
  759. }, error => {
  760. loading();
  761. console.log(error);
  762. });
  763. },
  764. edit(row){
  765. this.editForm = row;
  766. this.editVisible = true;
  767. },
  768. deviceClick(type){
  769. this.$refs.crud.searchForm.deviceType = type;
  770. this.query.deviceType = type;
  771. this.onLoad(this.page);
  772. },
  773. handleClick(tab, event) {
  774. console.log(tab + " " + event)
  775. },
  776. showDeviceBind(row){
  777. this.selectValue = row.residentialId;
  778. if (this.residentialList.length == 0){
  779. // 请求获取小区列表
  780. getAllList(5000).then(res => {
  781. this.residentialList = res.data.data.records;
  782. this.bindVisible = true;
  783. })
  784. }else{
  785. this.bindVisible = true;
  786. }
  787. this.form = row;
  788. },
  789. bindDevice(){
  790. this.form.residentialId = this.selectValue;
  791. //保存
  792. update(this.form).then(() => {
  793. this.onLoad(this.page);
  794. this.bindVisible = false;
  795. this.$message({
  796. type: "success",
  797. message: "操作成功!"
  798. });
  799. }, error => {
  800. console.log(error);
  801. });
  802. },
  803. rowView(row){
  804. },
  805. viewDetail(row) {
  806. this.detailForm = row;
  807. this.viewVisible = true;
  808. // console.log("row" + JSON.stringify(row))
  809. // this.titleText = row.$deviceType
  810. // this.deviceDetail = row;
  811. // /*getUserList(this.page.currentPage, this.page.pageSize, {residential: row.residentialId}).then(res =>{
  812. // this.alarmData = res.data.data.records;
  813. // })*/
  814. // this.residentialId = row.residentialId
  815. // /*this.alarmData = [
  816. // {
  817. // name: "李德",
  818. // tel: "15089107336",
  819. // area: "阅海万家D区"
  820. // }, {
  821. // name: "黄俊豪",
  822. // tel: "15145867336",
  823. // area: "阅海万家D区"
  824. // }, {
  825. // name: "林旭光",
  826. // tel: "17899572954",
  827. // area: "阅海万家D区"
  828. // }, {
  829. // name: "蔡志彬",
  830. // tel: "17899584512",
  831. // area: "阅海万家D区"
  832. // }, {
  833. // name: "黄坚伟",
  834. // tel: "17899571256",
  835. // area: "阅海万家D区"
  836. // } ];*/
  837. // this.alarmSetData = [
  838. // {
  839. // name: "蔡志彬",
  840. // tel: "17899584512",
  841. // area: "阅海万家D区"
  842. // }, {
  843. // name: "黄坚伟",
  844. // tel: "17899571256",
  845. // area: "阅海万家D区"
  846. // }];
  847. // this.homeUserData = [
  848. // {
  849. // name: "李德",
  850. // tel: "15089107336",
  851. // area: "阅海万家D区"
  852. // }, {
  853. // name: "黄俊豪",
  854. // tel: "15145867336",
  855. // area: "阅海万家D区"
  856. // }, {
  857. // name: "林旭光",
  858. // tel: "17899572954",
  859. // area: "阅海万家D区"
  860. // }, {
  861. // name: "蔡志彬",
  862. // tel: "17899584512",
  863. // area: "阅海万家D区"
  864. // }, {
  865. // name: "黄坚伟",
  866. // tel: "17899571256",
  867. // area: "阅海万家D区"
  868. // }];
  869. // this.bindedHomeUserData = [];
  870. // this.detailVisible = true;
  871. },
  872. rowSave(row, done, loading) {
  873. add(row).then(() => {
  874. this.onLoad(this.page);
  875. this.$message({
  876. type: "success",
  877. message: "操作成功!"
  878. });
  879. done();
  880. }, error => {
  881. loading();
  882. window.console.log(error);
  883. });
  884. },
  885. rowUpdate(row, index, done, loading) {
  886. update(row).then(() => {
  887. this.onLoad(this.page);
  888. this.$message({
  889. type: "success",
  890. message: "操作成功!"
  891. });
  892. done();
  893. }, error => {
  894. loading();
  895. console.log(error);
  896. });
  897. },
  898. rowDel(row) {
  899. this.$confirm("确定将选择数据删除?", {
  900. confirmButtonText: "确定",
  901. cancelButtonText: "取消",
  902. type: "warning"
  903. })
  904. .then(() => {
  905. return remove(row.id);
  906. })
  907. .then(() => {
  908. this.onLoad(this.page);
  909. this.$message({
  910. type: "success",
  911. message: "操作成功!"
  912. });
  913. });
  914. },
  915. handleDelete() {
  916. if (this.selectionList.length === 0) {
  917. this.$message.warning("请选择至少一条数据");
  918. return;
  919. }
  920. this.$confirm("确定将选择数据删除?", {
  921. confirmButtonText: "确定",
  922. cancelButtonText: "取消",
  923. type: "warning"
  924. })
  925. .then(() => {
  926. return remove(this.ids);
  927. })
  928. .then(() => {
  929. this.onLoad(this.page);
  930. this.$message({
  931. type: "success",
  932. message: "操作成功!"
  933. });
  934. this.$refs.crud.toggleSelection();
  935. });
  936. },
  937. beforeOpen(done, type) {
  938. if (["edit", "view"].includes(type)) {
  939. getDetail(this.form.id).then(res => {
  940. this.form = res.data.data;
  941. });
  942. }
  943. done();
  944. },
  945. searchReset() {
  946. this.query = {};
  947. this.onLoad(this.page);
  948. },
  949. searchChange(params, done) {
  950. this.query = params;
  951. this.page.currentPage = 1;
  952. this.onLoad(this.page, params);
  953. done();
  954. },
  955. selectionChange(list) {
  956. this.selectionList = list;
  957. },
  958. selectionClear() {
  959. this.selectionList = [];
  960. this.$refs.crud.toggleSelection();
  961. },
  962. currentChange(currentPage) {
  963. this.page.currentPage = currentPage;
  964. },
  965. sizeChange(pageSize) {
  966. this.page.pageSize = pageSize;
  967. },
  968. refreshChange() {
  969. this.onLoad(this.page, this.query);
  970. },
  971. onLoad(page, params = {}) {
  972. this.loading = true;
  973. /*getSmartDeviceStaticVo(Object.assign(params, this.query)).then(res =>{
  974. this.SmartDeviceStaticVo = res.data.data;
  975. })*/
  976. getList(page.currentPage, page.pageSize, Object.assign(params, this.query)).then(res => {
  977. const data = res.data.data;
  978. this.page.total = data.total;
  979. this.data = data.records;
  980. this.loading = false;
  981. this.selectionClear();
  982. });
  983. }
  984. }
  985. };
  986. </script>
  987. <style scoped>
  988. .avue-crud{
  989. padding-bottom: 20px;
  990. /* height: 800px; */
  991. }
  992. >>> .el-pagination{
  993. position: absolute;
  994. top: 0px;
  995. bottom: 0px;
  996. /* height: 100px; */
  997. }
  998. .shadow{
  999. box-shadow: 0 2px 4px rgba(0, 0, 0, .12), 0 0 6px rgba(0, 0, 0, .04)
  1000. }
  1001. .titleLabel{
  1002. color: white;
  1003. height: 65px;
  1004. line-height: 65px;
  1005. }
  1006. .titleText{
  1007. font-size: 25px;
  1008. font-weight: bolder;
  1009. padding-left: 10px;
  1010. }
  1011. .titleCount{
  1012. font-size: 25px;
  1013. font-weight: bolder;
  1014. }
  1015. .colMarginBottom{
  1016. margin-bottom: 0px;
  1017. }
  1018. .statusText{
  1019. font-size: 14px;
  1020. font-weight: bolder;
  1021. color: green;
  1022. }
  1023. .statusCount{
  1024. font-size: 14px;
  1025. font-weight: 700;
  1026. color: red;
  1027. }
  1028. .el-divider--vertical {
  1029. /* height: 100%; */
  1030. }
  1031. >>> .el-divider--horizontal{
  1032. margin: 0px !important;
  1033. margin-bottom: 5px !important;
  1034. }
  1035. >>> .el-main{
  1036. overflow: hidden;
  1037. }
  1038. >>> .divider-bottom{
  1039. margin: 0 !important;
  1040. margin-bottom: 10px !important;
  1041. }
  1042. >>> aside font {
  1043. cursor: pointer;
  1044. }
  1045. >>> .changeBind {
  1046. color: orange;
  1047. }
  1048. .el-carousel__item:nth-child(2n) {
  1049. background-color: rgb(217,236,255);
  1050. }
  1051. .el-carousel__item:nth-child(2n+1) {
  1052. background-color: rgb(236,245,255);
  1053. }
  1054. </style>