Remotecontrol.vue 24 KB

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