Remotecontrol.vue 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967
  1. <template>
  2. <view>
  3. <!-- <view class="position">
  4. <picker mode="multiSelector" @columnchange="bindMultiPickerColumnChange"
  5. @change="(val)=>confirmHandle(val,'position')" :range="positionList" style="width:100%;height: 100%;"
  6. range-key="orgName">
  7. <u-icon name="map-fill" color="#fff" class="inline"></u-icon>
  8. <view class="uni-input inline positionName">{{name}}</view>
  9. <u-icon name="arrow-rightward" class="inline" color="#fff"></u-icon>
  10. </picker>
  11. </view> -->
  12. <u-cell-group class="toptemplate">
  13. <u-cell :title="mytitle" @click="floorchange" :border="false">
  14. <u-icon slot="icon" size="40" color="#fff" name="map"></u-icon>
  15. <u-icon slot="right-icon" size="40" color="#fff" name="search"></u-icon>
  16. </u-cell>
  17. </u-cell-group>
  18. <view class="form">
  19. <view class="drawdownMenu">
  20. <picker @change="(val)=>confirmHandle(val,'deviceType')" :value="deviceTypeIndex"
  21. :range="deviceTypeList" style="width:100%;height: 100%;" range-key="dictLabel">
  22. <view class="uni-input">{{deviceTypeList[deviceTypeIndex].dictLabel}}</view>
  23. <u-icon name="arrow-down-fill" color="#666" size="16" class="inline"></u-icon>
  24. </picker>
  25. </view>
  26. <!-- <view class="drawdownMenu">
  27. <picker @change="(val)=>confirmHandle(val,'deviceStatus')" :value="deviceStatusIndex"
  28. :range="deviceStatusList" style="width:100%;height: 100%;" range-key="text">
  29. <view class="uni-input">{{deviceStatusList[deviceStatusIndex].text}}</view>
  30. <u-icon name="arrow-down-fill" color="#666" size="16" class="inline"></u-icon>
  31. </picker>
  32. </view> -->
  33. </view>
  34. <view class="total">
  35. 共有<text style="color: #f44;">{{total}}</text>条记录
  36. </view>
  37. <!-- 列表 -->
  38. <view class="list">
  39. <template v-if="deviceType == 'AirConditioner'">
  40. <view class="each c" v-for="(item,index) in dataList"
  41. :class="'bg'+(item.attributeList.length==0?'':item.attributeList[2].value)">
  42. <div class="top1">
  43. <template v-if="item.attributeList.length!=0">
  44. <image v-if="item.attributeList[2].value == '1'"
  45. src="../../../static/management/taiyang.png"></image>
  46. <image v-if="item.attributeList[2].value == '2'||item.attributeList[2].value == '0'"
  47. src="../../../static/management/zl.png"></image>
  48. <image v-if="item.attributeList[2].value == '4'" src="../../../static/management/auto.png"
  49. </image>
  50. <image v-if="item.attributeList[2].value == '8'" src="../../../static/management/cs.png"
  51. </image>
  52. </template>
  53. <view class="l1">{{item.airConditionerName}}</view>
  54. <view class="l2">{{ item.installSite }}{{ item.roomNumbers }}</view>
  55. <view class="l3">{{item.attributeList.length==0?'--':item.attributeList[5].value}}℃</view>
  56. <view class="l4">室温:{{ item.attributeList.length==0?'--':item.attributeList[4].value }}℃
  57. </view>
  58. </div>
  59. </div>
  60. <view class="operation" v-if="item.attributeList&&item.attributeList.length!=0">
  61. <picker
  62. @change="(val)=>confirmHandle(val,'modeType',item.deviceId,item.attributeList[2].sensorAddress)"
  63. :value="item.attributeList[2].value|findInd(modeTypeList)" :range="modeTypeList"
  64. style="width:100%;height: 100%;" range-key="dictLabel">
  65. <view class="uni-input">{{findInd2(item.attributeList[2].value,modeTypeList)}}</view>
  66. <u-icon name="arrow-down" color="#999" size="16" class="inline"></u-icon>
  67. </picker>
  68. <picker
  69. @change="(val)=>confirmHandle(val,'temp',item.deviceId,item.attributeList[5].sensorAddress)"
  70. :value="item.attributeList[5].value|findInd(temperatureList)" :range="temperatureList"
  71. style="width:100%;height: 100%;">
  72. <view class="uni-input">{{item.attributeList[5].value}}</view>
  73. <u-icon name="arrow-down" color="#999" size="16" class="inline"></u-icon>
  74. </picker>
  75. <picker
  76. @change="(val)=>confirmHandle(val,'speedType',item.deviceId,item.attributeList[0].sensorAddress)"
  77. :value="item.attributeList[0].value|findInd(speedTypeList)" :range="speedTypeList"
  78. style="width:100%;height: 100%;" range-key="dictLabel">
  79. <view class="uni-input">{{findInd2(item.attributeList[0].value,speedTypeList)}}</view>
  80. <u-icon name="arrow-down" color="#999" size="16" class="inline"></u-icon>
  81. </picker>
  82. </view>
  83. <view class="operation" v-else>
  84. <picker style="width:100%;height: 100%;">
  85. <view class="uni-input">--</view>
  86. <u-icon name="arrow-down" color="#999" size="16" class="inline"></u-icon>
  87. </picker>
  88. <picker style="width:100%;height: 100%;">
  89. <view class="uni-input">--</view>
  90. <u-icon name="arrow-down" color="#999" size="16" class="inline"></u-icon>
  91. </picker>
  92. <picker style="width:100%;height: 100%;">
  93. <view class="uni-input">--</view>
  94. <u-icon name="arrow-down" color="#999" size="16" class="inline"></u-icon>
  95. </picker>
  96. </view>
  97. <switch :checked="item.attributeList[3].value==1?true:false" v-if="item.attributeList.length!=0"
  98. @click="(val)=>changeSwitch('AirConditioner', item.attributeList[3].value, item.deviceId, index,item.attributeList[3].sensorAddress)"
  99. style="transform:scale(0.7)" class="switch" disabled />
  100. </view>
  101. </template>
  102. <template v-if="deviceType == 'Relay'">
  103. <view :class="item.status==0?'each':'each on2'" v-for="(item,index) in dataList">
  104. <div class="top">
  105. <view class="l1">{{item.controlName}}</view>
  106. <view class="l2">空间信息:{{ item.installSite }}</view>
  107. <div class="open">
  108. <image src="../../../static/management/kg.png" @click="control(item.deviceId, item.status)">
  109. </image>
  110. <p>{{ item | delStatus }}</p>
  111. </div>
  112. </div>
  113. <div class="operation2" v-if="item.attributeList && item.attributeList.length > 0">
  114. <div v-for="(ope, index2) in item.relayNames" :key="index2" class="s">
  115. <p>{{ ope.name }}</p>
  116. <u-switch :value="item.attributeList[index2].value | delTimestamp" active-value="a"
  117. inactive-value="b" @change="handleChange(
  118. 'switch',
  119. $event,
  120. index,
  121. item.attributeList[index2].sensorAddress
  122. )
  123. " style="margin: 0 auto;height: 16px;"></u-switch>
  124. </div>
  125. </div>
  126. </view>
  127. </template>
  128. </view>
  129. <u-picker :show="showfloor" ref="uPicker" @confirm="confirmfloor" @cancel='cancelfloor' :columns="columns"
  130. keyName="orgName" @change="changeHandler" visibleItemCount="7" itemHeight="70"></u-picker>
  131. </view>
  132. </template>
  133. <script>
  134. import {
  135. isEmpty,
  136. getDictDataList,
  137. getUrlKey
  138. } from "@/utils/index";
  139. import Api from "./@/http/Api.js";
  140. export default {
  141. data() {
  142. return {
  143. showfloor: false,
  144. showtype: false,
  145. modeTypeList: [],
  146. modeTypeIndex: 0,
  147. temperatureList: [],
  148. columns: [],
  149. speedTypeList: [],
  150. speedTypeIndex: 0,
  151. dataForm: {
  152. page: 1,
  153. limit: 10,
  154. opStatus: '',
  155. buildingId: "",
  156. storeyId: "",
  157. status: "",
  158. controlCategory: "CommonLighting",
  159. },
  160. mytitle: '',
  161. total: 0,
  162. refreshing: false,
  163. finished: false,
  164. deviceTypeIndex: 0,
  165. deviceStatusIndex: 0,
  166. name: '跨境电商',
  167. projectName: '',
  168. p1: 0,
  169. p2: 0,
  170. positionList: [
  171. [],
  172. []
  173. ],
  174. columnData: [],
  175. deviceType: "AirConditioner",
  176. deviceStatus: '',
  177. deviceTypeList: [],
  178. dataList: [],
  179. deviceStatusList: [{
  180. text: "全部",
  181. value: ""
  182. },
  183. {
  184. text: "开启",
  185. value: 1
  186. },
  187. {
  188. text: "关闭",
  189. value: 0
  190. },
  191. ],
  192. }
  193. },
  194. onPullDownRefresh() {
  195. this.onRefresh();
  196. },
  197. onReachBottom() {
  198. if (!this.finished) {
  199. this.dataForm.page++;
  200. this.getDataList();
  201. }
  202. },
  203. onLoad(v) {
  204. uni.setNavigationBarTitle({
  205. title: v.type == 1 ? '空调控制' : '照明控制'
  206. })
  207. if (v.type == 1) {
  208. this.deviceType = "AirConditioner";
  209. this.deviceTypeIndex = 0;
  210. } else {
  211. this.deviceType = 'Relay';
  212. this.deviceTypeIndex = 1;
  213. }
  214. let getDictDataList = uni.getStorageSync('getDictDataList');
  215. for (let i = 0; i < getDictDataList.length; i++) {
  216. if (getDictDataList[i].dictType == 'ModeType') {
  217. this.modeTypeList = getDictDataList[i].dataList
  218. this.modeTypeList.push({
  219. dictLabel: "制冷",
  220. dictTypeId: "1610183082852225025",
  221. dictValue: "0"
  222. })
  223. }
  224. if (getDictDataList[i].dictType == 'SpeedType') {
  225. this.speedTypeList = getDictDataList[i].dataList
  226. }
  227. if (getDictDataList[i].dictType == 'DeviceCategory') {
  228. this.deviceTypeList = getDictDataList[i].dataList;
  229. this.deviceTypeList.forEach((item) => {
  230. item.text = item.dictLabel;
  231. item.value = item.dictValue;
  232. });
  233. this.deviceTypeList = this.deviceTypeList.filter(
  234. (item) => item.value != "WaterMeter" && item.value != "Ammeter"
  235. );
  236. }
  237. }
  238. this.getBuildList();
  239. // this.getDeviceTypeList();
  240. this.setTemperatureList();
  241. this.getDataList()
  242. },
  243. watch: {
  244. "dataForm.buildingId"(newval, oldval) {
  245. if (newval != oldval) {
  246. this.onRefresh();
  247. }
  248. },
  249. "dataForm.storeyId"(newval, oldval) {
  250. if (newval != oldval) {
  251. this.onRefresh();
  252. }
  253. },
  254. },
  255. filters: {
  256. delTimestamp(val) {
  257. if (!val) return "b";
  258. if (val.indexOf("n") > -1) {
  259. return 'a'; //开a
  260. } else {
  261. return 'b'; //关b
  262. }
  263. },
  264. delStatus(item) {
  265. let status = 0;
  266. if (item.attributeList && item.attributeList.length > 0) {
  267. for (let i = 0; i < item.relayNames.length; i++) {
  268. if (
  269. item.attributeList[i].value &&
  270. item.attributeList[i].value.indexOf("n") > -1
  271. ) {
  272. status++;
  273. } else {
  274. status--;
  275. }
  276. }
  277. if (status == item.relayNames.length) {
  278. item.status = 1;
  279. return "全关";
  280. }
  281. if (status == 0 - item.relayNames.length) {
  282. item.status = 0;
  283. return "全开";
  284. }
  285. return "全关";
  286. } else {
  287. return "全关";
  288. }
  289. },
  290. findInd(val, list) {
  291. if (isEmpty(val)) {
  292. return 0;
  293. }
  294. if (list.length > 5) {
  295. return list.findIndex((item) => item == val);
  296. } else {
  297. return list.findIndex((item) => parseFloat(item.dictValue) == val);
  298. }
  299. }
  300. },
  301. methods: {
  302. handleChange(type, val, index, identifier) {
  303. let that = this;
  304. if (type == "switch") {
  305. let msg = "";
  306. let deviceId = this.dataList[index].deviceId;
  307. let params = {
  308. // keyword: "setRelay",
  309. value: val,
  310. deviceId: deviceId,
  311. identifier: identifier,
  312. action: 0,
  313. };
  314. if (val == "a") {
  315. msg = "开启";
  316. }
  317. if (val == "b") {
  318. msg = "关闭";
  319. }
  320. uni.showModal({
  321. title: '提示',
  322. content: `确定执行${msg}操作`,
  323. success(res) {
  324. if (res.confirm) {
  325. that.switchLighting(type, params, index, msg, identifier);
  326. } else {
  327. uni.showToast({
  328. icon: 'none',
  329. title: '已取消'
  330. })
  331. }
  332. },
  333. })
  334. }
  335. },
  336. switchLighting(type, val, index, msg, identifier) {
  337. uni.showLoading({
  338. title: `正在${msg},请稍后`
  339. });
  340. if (type == "switch") {
  341. Api.setControlElec(val).then((res) => {
  342. uni.hideLoading()
  343. if (res.data.code == 0) {
  344. this.dataForm.page = 1;
  345. this.getDataList();
  346. uni.showToast({
  347. title: '操作成功'
  348. })
  349. }
  350. });
  351. }
  352. },
  353. findInd2(val, list) {
  354. if (isEmpty(val)) {
  355. return 0;
  356. }
  357. if (list.find((item) => parseFloat(item.dictValue) == val)) {
  358. return list.find((item) => parseFloat(item.dictValue) == val).dictLabel;
  359. } else {
  360. return list[0].dictLabel
  361. }
  362. },
  363. floorchange() {
  364. this.showfloor = true;
  365. },
  366. confirmfloor(e) {
  367. let a = "";
  368. let b = "";
  369. if (e.value[0]) {
  370. a = e.value[0].orgName == '全部' ? '跨境电商' : e.value[0].orgName;
  371. this.dataForm.buildingId = e.value[0].orgId;
  372. this.dataForm.storeyId = "";
  373. }
  374. if (e.value[1]) {
  375. b = e.value[1].orgName == '全部' ? '' : e.value[1].orgName;
  376. this.dataForm.storeyId = e.value[1].orgId ? e.value[1].orgId : '';
  377. }
  378. this.mytitle = a + b;
  379. this.showfloor = false;
  380. this.dataList = []; // 清空数组
  381. this.dataForm.page = 1;
  382. this.getDataList()
  383. },
  384. cancelfloor() {
  385. this.showfloor = false;
  386. },
  387. changeHandler(e) {
  388. const {
  389. columnIndex,
  390. index,
  391. // 微信小程序无法将picker实例传出来,只能通过ref操作
  392. picker = this.$refs.uPicker
  393. } = e
  394. if (columnIndex === 0) {
  395. this.loading = true
  396. picker.setColumnValues(1, this.columnData[index])
  397. this.loading = false
  398. }
  399. // this.dataList = []; // 清空数组
  400. // this.dataForm.page = 1;
  401. // this.getDataList()
  402. },
  403. //获取楼栋
  404. getBuildList() {
  405. this.$api.get('/control/getOrgStructureTree/', {})
  406. .then(res => {
  407. if (res.data.code == 0) {
  408. let json = [{
  409. category: "s",
  410. childrenList: null,
  411. orgId: "",
  412. orgName: "全部",
  413. }];
  414. this.dataForm.projectId = res.data.data[0].orgId;
  415. this.mytitle = res.data.data[0].orgName;
  416. this.alldata = res.data.data[0].childrenList;
  417. this.columns = [
  418. json.concat(res.data.data[0].childrenList),
  419. []
  420. ]
  421. let allfloor = [
  422. []
  423. ];
  424. for (let i = 0; i < res.data.data[0].childrenList.length; i++) {
  425. allfloor.push(json.concat(res.data.data[0].childrenList[i].childrenList));
  426. }
  427. this.columnData = allfloor;
  428. this.dataList = []; // 清空数组
  429. this.dataForm.page = 1;
  430. //this.getDataList()
  431. } else {
  432. this.showdct = true
  433. }
  434. })
  435. },
  436. control(deviceId, status) {
  437. let msg = status == 0 ? '全开' : '全关';
  438. let that = this;
  439. uni.showModal({
  440. title: '提示',
  441. content: `确定执行${msg}操作`,
  442. success(res) {
  443. if (res.confirm) {
  444. uni.showLoading({
  445. title: "正在操作,请稍后。。。",
  446. })
  447. Api.setControlElec({
  448. action: 0,
  449. identifier: "",
  450. deviceId: deviceId,
  451. value: status == 0 ? "qk" : "qg",
  452. }).then((res) => {
  453. uni.hideLoading()
  454. if (res.data.code == 0) {
  455. this.dataForm.page = 1;
  456. that.getDataList();
  457. uni.showLoading({
  458. title: "操作成功",
  459. })
  460. }
  461. });
  462. } else {
  463. uni.showToast({
  464. icon: 'none',
  465. title: '已取消'
  466. })
  467. }
  468. },
  469. })
  470. },
  471. setTemperatureList() {
  472. this.temperatureList = [];
  473. for (let i = 16; i < 33; i++) {
  474. this.temperatureList.push(i);
  475. }
  476. },
  477. confirmHandle(e, type, deviceId, identifier) {
  478. this.dataForm.page = 1;
  479. if (type == 'position') {
  480. // this.p1 = e.detail.value[0];
  481. // this.p2 = e.detail.value[1];
  482. // this.dataForm.buildingId = this.p1 == 0 ? '' : this.positionList[0][this.p1].orgId;
  483. // this.dataForm.storeyId = this.p2 == 0 ? "" : this.positionList[1][this.p2].orgId;
  484. // let buildName = this.p1 == 0 ? "" : '-' + this.positionList[0][this.p1].orgName;
  485. // let storeyName = this.p2 == 0 ? "" : '-' + this.positionList[1][this.p2].orgName;
  486. // this.name = this.projectName + buildName + storeyName;
  487. } else {
  488. let index = type + "Index";
  489. this[index] = e.detail.value;
  490. if (type == "deviceType") {
  491. this.deviceType = this.deviceTypeList[e.detail.value].value;
  492. this.onRefresh();
  493. }
  494. if (type == "deviceStatus") {
  495. this.deviceStatus = this.deviceStatusList[e.detail.value].value;
  496. this.dataForm.status = this.deviceStatus;
  497. this.dataForm.opStatus = this.deviceStatus;
  498. this.onRefresh();
  499. }
  500. if (type == "modeType" || type == "speedType" || type == "temp") {
  501. let data = "";
  502. if (type == 'modeType') {
  503. data = this.modeTypeList[e.detail.value].dictValue;
  504. }
  505. if (type == 'speedType') {
  506. data = this.speedTypeList[e.detail.value].dictValue;
  507. }
  508. if (type == 'temp') {
  509. data = this.temperatureList[e.detail.value];
  510. }
  511. this.onConfirmMode(data, deviceId, identifier);
  512. }
  513. }
  514. },
  515. //刷新
  516. onRefresh() {
  517. this.finished = false;
  518. // 重新加载数据
  519. this.dataList = [];
  520. // 将 loading 设置为 true,表示处于加载状态
  521. this.total = 0;
  522. this.loading = true;
  523. this.dataForm.page = 1; // 分页数赋值为1
  524. this.loadData();
  525. },
  526. //加载数据
  527. loadData() {
  528. setTimeout(async () => {
  529. if (this.refreshing) {
  530. this.dataList = [];
  531. this.refreshing = false;
  532. }
  533. await this.getDataList();
  534. //this.dataForm.page++; // 分页数加一
  535. }, 100);
  536. },
  537. getDataList() {
  538. if (this.deviceType == "AirConditioner") {
  539. this.getAircond();
  540. }
  541. if (this.deviceType == "Relay") {
  542. this.getElec();
  543. }
  544. },
  545. // getDeviceTypeList() {
  546. // this.deviceTypeList = JSON.parse(
  547. // JSON.stringify(getDictDataList("DeviceCategory"))
  548. // );
  549. // this.deviceTypeList.forEach((item) => {
  550. // item.text = item.dictLabel;
  551. // item.value = item.dictValue;
  552. // });
  553. // this.deviceTypeList = this.deviceTypeList.filter(
  554. // (item) => item.value != "WaterMeter" && item.value != "Ammeter"
  555. // );
  556. // },
  557. getAircond() {
  558. this.dataForm.status = "";
  559. Api.airconditioner(this.dataForm).then((res) => {
  560. uni.stopPullDownRefresh();//停止刷新
  561. if (res.data.code == 0) {
  562. if (res.data.data) {
  563. if (res.data.data.list.length == 0) {
  564. // 判断获取数据条数若等于0
  565. this.dataList = []; // 清空数组
  566. this.finished = true; // 停止加载
  567. }
  568. // 若数据条数不等于0
  569. if (this.dataForm.page == 1) {
  570. this.dataList = res.data.data.list;
  571. } else {
  572. this.dataList.push(...res.data.data.list); // 将数据放入list中
  573. }
  574. this.loading = false; // 加载状态结束
  575. this.total = res.data.data.total;
  576. // 如果list长度大于等于总数据条数,数据全部加载完成
  577. if (this.dataList.length >= res.data.data.total) {
  578. this.finished = true; // 结束加载状态
  579. }
  580. } else {
  581. // 判断获取数据条数若等于0
  582. this.dataList = []; // 清空数组
  583. this.finished = true; // 停止加载
  584. }
  585. } else {
  586. this.loading = false; // 加载状态结束
  587. this.finished = true; // 停止加载
  588. }
  589. });
  590. },
  591. getElec() {
  592. Api.getElec(this.dataForm).then((res) => {
  593. uni.stopPullDownRefresh();//停止刷新
  594. if (res.data.code == 0) {
  595. if (res.data.data) {
  596. if (res.data.data.list.length == 0) {
  597. // 判断获取数据条数若等于0
  598. this.dataList = []; // 清空数组
  599. this.finished = true; // 停止加载
  600. }
  601. // 若数据条数不等于0
  602. if (this.dataForm.page == 1) {
  603. this.dataList = res.data.data.list;
  604. } else {
  605. this.dataList.push(...res.data.data.list); // 将数据放入list中
  606. }
  607. this.loading = false; // 加载状态结束
  608. this.total = res.data.data.total;
  609. // 如果list长度大于等于总数据条数,数据全部加载完成
  610. if (this.dataList.length >= res.data.data.total) {
  611. this.finished = true; // 结束加载状态
  612. }
  613. } else {
  614. // 判断获取数据条数若等于0
  615. this.dataList = []; // 清空数组
  616. this.finished = true; // 停止加载
  617. }
  618. } else {
  619. this.loading = false; // 加载状态结束
  620. this.finished = true; // 停止加载
  621. }
  622. });
  623. },
  624. //下发指令开关
  625. changeSwitch(type, val, deviceId, index, identifier) {
  626. let that=this;
  627. let msg = "";
  628. if (!val) {
  629. msg = "开启";
  630. } else {
  631. msg = "关闭";
  632. }
  633. uni.showModal({
  634. title: '提示',
  635. content: `请确认是否【${msg}】此设备`,
  636. success: function(res) {
  637. if (res.confirm) {
  638. if (type == "AirConditioner") {
  639. Api.setControl({
  640. identifier: identifier,
  641. action: 0,
  642. value: val? 0 : 1,
  643. deviceId: deviceId,
  644. }).then((res) => {
  645. if (res.data.code == 0) {
  646. that.dataList[index].attributeList[3].value = val?0:1;
  647. uni.showToast({
  648. title: '操作成功',
  649. duration: 2000
  650. });
  651. } else {
  652. uni.showToast({
  653. title: '操作失败',
  654. duration: 2000
  655. });
  656. }
  657. });
  658. }
  659. if (type == "Relay") {
  660. Api.setControlElec({
  661. identifier: identifier,
  662. action: 0,
  663. value: val.detail.value ? 1 : 0,
  664. deviceId: deviceId,
  665. }).then((res) => {
  666. if (res.data.code == 0) {
  667. this.dataList[index].status = val;
  668. uni.showToast({
  669. title: '操作成功',
  670. duration: 2000
  671. });
  672. } else {
  673. uni.showToast({
  674. title: '操作失败',
  675. duration: 2000
  676. });
  677. }
  678. });
  679. }
  680. } else if (res.cancel) {
  681. console.log('用户点击取消');
  682. }
  683. }
  684. });
  685. },
  686. onConfirmMode(data, deviceId, identifier) {
  687. let deviceCommandDTO = {
  688. action: 0,
  689. identifier: identifier,
  690. value: data,
  691. deviceId: deviceId,
  692. };
  693. // switch (module) {
  694. // case "modeTypeList":
  695. // deviceCommandDTO = {
  696. // action: 0,
  697. // identifier:identifier,
  698. // value: data,
  699. // deviceId: deviceId,
  700. // };
  701. // break;
  702. // case "temperatureList":
  703. // deviceCommandDTO = {
  704. // keyword: "setTemp",
  705. // param: data,
  706. // deviceId: deviceId,
  707. // };
  708. // break;
  709. // case "speedTypeList":
  710. // deviceCommandDTO = {
  711. // keyword: "setFan",
  712. // param: data,
  713. // deviceId: deviceId,
  714. // };
  715. // break;
  716. // }
  717. Api.setControl(deviceCommandDTO).then((res) => {
  718. //this.$toast.clear();
  719. if (res.data.code == 0) {
  720. uni.showToast({
  721. title: '操作成功',
  722. duration: 2000
  723. });
  724. this.onRefresh();
  725. }
  726. });
  727. },
  728. }
  729. }
  730. </script>
  731. <style lang="scss" scoped>
  732. .uni-input {
  733. margin-right: 4px;
  734. }
  735. .uni-input,
  736. .inline {
  737. display: inline-block;
  738. }
  739. .form {
  740. display: flex;
  741. height: 48px;
  742. align-items: center;
  743. background-color: #fff;
  744. .drawdownMenu {
  745. display: flex;
  746. text-align: center;
  747. min-width: 50%;
  748. flex: 1;
  749. }
  750. }
  751. .header {
  752. background-color: #5c8fff;
  753. height: 25px;
  754. }
  755. .position {
  756. font-size: 16px;
  757. color: #fff;
  758. padding: 10px 16px;
  759. background: #5c8fff;
  760. .positionName {
  761. margin: 0 5px;
  762. }
  763. }
  764. .total {
  765. padding: 0 16px;
  766. margin: 8px 0;
  767. line-height: 15px;
  768. display: flex;
  769. text-align: left;
  770. text {
  771. font-size: 15px;
  772. vertical-align: middle;
  773. }
  774. }
  775. .list {
  776. padding: 0 16px;
  777. .each {
  778. background: #ffffff;
  779. box-shadow: 0px 0px 10px 0px rgba(153, 153, 153, 0.15);
  780. border-radius: 4px;
  781. margin-bottom: 12px;
  782. position: relative;
  783. box-shadow: 0px 0px 2px 4px rgba(87, 134, 238, 0.03);
  784. &.on2 {
  785. background: linear-gradient(to bottom,
  786. rgba(255, 155, 37, 0.25),
  787. rgba(255, 234, 200, 0.13),
  788. rgba(255, 255, 255, 0.04));
  789. }
  790. &.c {
  791. display: flex;
  792. flex-direction: column;
  793. .top1 {
  794. padding: 16px 20px;
  795. border-bottom: 1px solid #E6E7EA;
  796. image {
  797. width: 54px;
  798. height: 56px;
  799. position: absolute;
  800. left: 0;
  801. top: 0;
  802. z-index: 1;
  803. }
  804. }
  805. }
  806. &.bg0,
  807. &.bg2 {
  808. background: linear-gradient(to bottom, #D2F0FF, #FFFFFF)
  809. }
  810. &.bg1 {
  811. background: linear-gradient(to bottom, #FFE2DF, #FFFFFF)
  812. }
  813. &.bg4 {
  814. background: linear-gradient(to bottom, #DDF8DC, #FFFFFF)
  815. }
  816. &.bg8 {
  817. background: linear-gradient(to bottom, #DEE4FE, #FFFFFF)
  818. }
  819. .top {
  820. padding: 16px 20px;
  821. border-bottom: 1px solid #ddd;
  822. position: relative;
  823. .open {
  824. position: absolute;
  825. right: 0;
  826. top: 0;
  827. height: 100%;
  828. width: 60px;
  829. display: flex;
  830. flex-direction: column;
  831. justify-content: space-between;
  832. align-items: center;
  833. color: #2e69eb;
  834. font-size: 14px;
  835. padding: 12px 0;
  836. border-left: 1px solid #e6e7ea;
  837. box-sizing: border-box;
  838. image {
  839. width: 28px;
  840. height: 26px;
  841. cursor: pointer;
  842. }
  843. }
  844. }
  845. .l1 {
  846. height: 22px;
  847. font-size: 16px;
  848. color: #0c1935;
  849. line-height: 22px;
  850. margin-bottom: 2px;
  851. }
  852. .l2 {
  853. font-size: 12px;
  854. color: #697081;
  855. }
  856. .l3 {
  857. text-align: center;
  858. font-size: 32px;
  859. }
  860. .l4 {
  861. text-align: right;
  862. font-size: 14px;
  863. color: #0C1935;
  864. }
  865. .operation {
  866. display: flex;
  867. width: 100%;
  868. position: relative;
  869. font-size: 14px;
  870. padding: 18px;
  871. text-align: center;
  872. box-sizing: border-box;
  873. .uni-input {
  874. color: #2e69eb;
  875. }
  876. }
  877. .switch {
  878. position: absolute;
  879. right: 10px;
  880. font-size: 18px;
  881. top: auto;
  882. z-index: 1;
  883. }
  884. .operation2 {
  885. width: 100%;
  886. display: flex;
  887. align-items: center;
  888. justify-content: center;
  889. box-sizing: border-box;
  890. .s {
  891. flex: 1;
  892. width: 200px;
  893. text-align: center;
  894. line-height: 26px;
  895. padding: 10px 0;
  896. font-size: 14px;
  897. color: #697081;
  898. border-right: 1px solid #ddd;
  899. &:last-child {
  900. border-right: none;
  901. }
  902. }
  903. }
  904. }
  905. }
  906. </style>