details.vue 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047
  1. <template>
  2. <view class="box">
  3. <!-- 上面要素值 -->
  4. <view :class="`bigBox ${show ? 'bigOpen' : ''}`">
  5. <view class="topInfo">
  6. <u-row gutter="10">
  7. <u-col span="3" v-for="item in ElementList">
  8. <view class="item">
  9. <view>{{item.value}}</view>
  10. <view>{{item.unit}}</view>
  11. <view>{{item.name}}</view>
  12. </view>
  13. </u-col>
  14. </u-row>
  15. <view class="readmore" v-if="!show" @click="show=true;getHistoryData()">
  16. 查看详情<u-icon name="arrow-down" color="#93FFDE" size="28"></u-icon>
  17. </view>
  18. </view>
  19. <!-- 统计图 -->
  20. <view class="hisBox" v-show="show">
  21. <view class="axiosBox">
  22. <view class="title">
  23. 历史数据
  24. </view>
  25. <view class="histimeBox">
  26. <u-icon name="calendar" color="#C1C1C1" size="24"></u-icon>
  27. <view class="time" @click="calendarshow = true">
  28. {{historyTime.startDate ? historyTime.startDate : timestampToDateTime(new Date().getTime()/1000)}}
  29. </view>
  30. <view class="">至</view>
  31. <view class="time" @click="calendarshow = true">
  32. {{historyTime.endDate ? historyTime.endDate : timestampToDateTime(new Date().getTime()/1000)}}
  33. </view>
  34. <u-icon name="close-circle" color="#C1C1C1" size="28" @click="historyTime={};getHistoryData()"
  35. v-if="historyTime.startDate"></u-icon>
  36. </view>
  37. <u-calendar v-model="calendarshow" mode="range" @change="changeDate"></u-calendar>
  38. <view class="chartBox">
  39. <canvas canvas-id="canvasColumnA" id="canvasColumnA" class="charts"
  40. @touchstart="touchLineA($event)" @touchmove="moveLineA($event)"
  41. @touchend="touchEndLineA($event)"></canvas>
  42. </view>
  43. </view>
  44. <view class="readmore" @click="show=false">
  45. 收起详情<u-icon name="arrow-up" color="#14A478" size="28"></u-icon>
  46. </view>
  47. </view>
  48. </view>
  49. <!-- 历史记录弹框 -->
  50. <u-tabs :list="list" active-color="#14A478" bar-width="100" :is-scroll="false" :current="current"
  51. @change="change"></u-tabs>
  52. <!-- 设备图 -->
  53. <view class="devicePhoto" v-if="current == 0">
  54. <view class="titleBox">
  55. <u-alert-tips type="primary" :title-style="alertTipColor" title="点击按钮可对应控制阀门开关"
  56. :show-icon="true"></u-alert-tips>
  57. <view class="btn" @click="statusPanel=true">控制面板</view>
  58. <u-popup v-model="statusPanel" mode="bottom">
  59. <view class="consoleBox">
  60. <view class="swichBox">
  61. <u-row :gutter="16" justify="space-between">
  62. <u-col span="6" v-for="(item, index) in buttonList" v-if="(index + 1) % 2 == 1">
  63. <view class="preSwich">
  64. <view>肥料{{ (index + 1) / 2 > 1 ? (index + 2) / 2 : 1 }}</view>
  65. <u-switch v-model="item.off" active-color="#14A478" inactive-color="#AEB4C2"
  66. :loading="item.disabled"
  67. @change="switchchange($event, item.number, item, index, true)"></u-switch>
  68. </view>
  69. </u-col>
  70. <u-col span="6" v-for="(item, index) in facilityvalve"
  71. v-if="index > buttonList.length - 1">
  72. <view class="preSwich">
  73. <view>{{item.name}}</view>
  74. <u-switch v-model="item.off" active-color="#14A478" inactive-color="#AEB4C2"
  75. :loading="item.disabled"
  76. @change="switchchange($event, item.number, item, index)"></u-switch>
  77. </view>
  78. </u-col>
  79. </u-row>
  80. </view>
  81. <u-button type="success" @click="statusPanel=false">确定</u-button>
  82. </view>
  83. </u-popup>
  84. </view>
  85. <view class="main">
  86. <image class="mainContent" src="../../static/images/waterandfernew/main.png"></image>
  87. <view class="sourceBox">
  88. <view class="smallBox">
  89. 水源
  90. </view>
  91. </view>
  92. <!-- 桶 -->
  93. <view class="colList">
  94. <view class="preClo" v-for="(fei, index) in Array(feiNum / 2)" :key="`fei${index}`">
  95. <view>
  96. 肥料{{ index + 1 }}
  97. </view>
  98. <image src="../../static/images/waterandfernew/col.png"></image>
  99. </view>
  100. </view>
  101. <!-- 电风扇 -->
  102. <view class="fengBox">
  103. <view class="relativeBox">
  104. <image src="../../static/images/waterandfernew/fengmain.png"></image>
  105. <image :class="feiBeng ? 'circleAnm' : ''"
  106. src="../../static/images/waterandfernew/fengleafs.png"></image>
  107. </view>
  108. </view>
  109. <!-- 水管控制阀 -->
  110. <view class="benList">
  111. <view class="preBen" v-for="item, index in buttonList" v-if="(index + 1) % 2 == 1"
  112. @click="switchchange(!item.off, item.number, item, index, true)">
  113. <image class="daoguan" src="../../static/images/waterandfernew/bottom.png"
  114. v-if="(index + 1) % 2 < 4"></image>
  115. <view class="info">
  116. 肥料{{ (index + 1) / 2 > 1 ? (index + 2) / 2 : 1 }}开关
  117. </view>
  118. <image class="status" v-if="item.off" src="../../static/images/waterandfernew/open.png"></image>
  119. <image class="status" v-else src="../../static/images/waterandfernew/close.png"></image>
  120. </view>
  121. <view class="preBen" v-for="item, index in facilityvalve" v-if="index > buttonList.length - 1"
  122. @click="switchchange(!item.off, item.number, item, index)">
  123. <image class="daoguan" src="../../static/images/waterandfernew/bottom.png"
  124. v-if="(index-buttonList.length + buttonList.length/2) < 4"></image>
  125. <view class="info">
  126. {{item.name}}
  127. </view>
  128. <image class="status" v-if="item.off" src="../../static/images/waterandfernew/open.png"></image>
  129. <image class="status" v-else src="../../static/images/waterandfernew/close.png"></image>
  130. </view>
  131. </view>
  132. </view>
  133. </view>
  134. <!-- 操作记录 -->
  135. <view class="consoleList" v-else>
  136. <view class="histimeBox">
  137. <u-icon name="calendar" color="#C1C1C1" size="24"></u-icon>
  138. <view class="time" @click="consoleshow = true">{{consoleTime.startDate ? consoleTime.startDate : '开始'}}
  139. </view>
  140. <view class="">至</view>
  141. <view class="time" @click="consoleshow = true">{{consoleTime.endDate ? consoleTime.endDate : '结束'}}
  142. </view>
  143. <u-icon name="close-circle" color="#C1C1C1" size="28" @click="clearContime"
  144. v-if="consoleTime.startDate"></u-icon>
  145. </view>
  146. <u-calendar v-model="consoleshow" mode="range" @change="changeConsoleDate"></u-calendar>
  147. <view class="tableList tableTitle">
  148. <view>设备名称</view>
  149. <view>操作内容</view>
  150. <view>操作时间</view>
  151. </view>
  152. <view class="tableList" v-for="(item, index) in tableData" :key="item.uptime + index">
  153. <view>{{item.device_name}}</view>
  154. <view>{{item.operation_content}}</view>
  155. <view>{{item.uptime}}</view>
  156. </view>
  157. <u-loadmore :status="status" />
  158. </view>
  159. </view>
  160. </template>
  161. <script>
  162. import uCharts from '../../components/js_sdk/u-charts/u-charts/u-charts.js';
  163. var canvaColumnA = null;
  164. var canvasRing = null;
  165. export default {
  166. data() {
  167. return {
  168. alertTipColor: {
  169. color: '#1890FF',
  170. fontSize: "28rpx"
  171. },
  172. device_id: '',
  173. mainBeng: false,
  174. feiBeng: false,
  175. calendarshow: false,
  176. historyTime: {},
  177. cWidth: '350',
  178. cHeight: '350',
  179. pixelRatio: 1,
  180. facilityvalve: [],
  181. feiNum: 0, //肥料桶实际占据通道个数
  182. buttonList: [], // 肥料开关列表
  183. colomRoundList: ['j1', 'j2', 'j3', 'j4', 'j5', 'j6', 'j7', 'j8'], // 废料桶的通道
  184. ElementList: [],
  185. typename: [
  186. "-",
  187. "风机",
  188. "水泵",
  189. "增氧机",
  190. "湿帘",
  191. "遮阳",
  192. "开窗",
  193. "保温",
  194. "投食机",
  195. ],
  196. show: false,
  197. list: [{
  198. name: '设备控制'
  199. }, {
  200. name: '执行结果'
  201. }, {
  202. name: '操作记录'
  203. }],
  204. statusPanel: false,
  205. current: 0,
  206. consoleshow: false,
  207. consoleTime: {},
  208. tableData: [],
  209. page: 1,
  210. total: 0,
  211. status: 'loadmore'
  212. }
  213. },
  214. methods: {
  215. changeTimeStatus(item, changeIndex) {
  216. this.timer = setTimeout(() => {
  217. item.disabled = false; // 改变值
  218. this.facilityvalve[changeIndex].disabled = false;
  219. this.getEquipstatus()
  220. this.timer = null; // 清空定时器引用
  221. }, 15000);
  222. },
  223. // 选择日期
  224. changeDate(e) {
  225. console.log(e)
  226. this.historyTime = e;
  227. this.getHistoryData()
  228. },
  229. // 绘制折线图
  230. showColumn(id, xtitle, xinfo) {
  231. var _self = this
  232. canvaColumnA = new uCharts({
  233. canvasId: id,
  234. type: 'line',
  235. legend: {
  236. position: "top"
  237. },
  238. fontSize: 11,
  239. background: '#FFFFFF',
  240. pixelRatio: 1,
  241. animation: true,
  242. dataLabel: false,
  243. categories: xtitle,
  244. series: xinfo,
  245. enableScroll: true, //开启图表拖拽功能
  246. xAxis: {
  247. disabled: true,
  248. disableGrid: false,
  249. type: 'grid',
  250. gridType: 'dash',
  251. itemCount: 15, //x轴单屏显示数据的数量,默认为5个
  252. scrollShow: true, //新增是否显示滚动条,默认false
  253. scrollAlign: 'right', //滚动条初始位置
  254. scrollBackgroundColor: '#F7F7FF', //默认为 #EFEBEF
  255. scrollColor: '#DEE7F7', //默认为 #A6A6A6
  256. },
  257. yAxis: {},
  258. width: _self.cWidth * 1,
  259. height: _self.cHeight * 1,
  260. extra: {
  261. line: {
  262. type: 'curve'
  263. }
  264. }
  265. });
  266. },
  267. touchLineA(e) {
  268. // console.log(e)
  269. canvaColumnA.scrollStart(e);
  270. },
  271. moveLineA(e) {
  272. canvaColumnA.scroll(e);
  273. },
  274. touchEndLineA(e) {
  275. canvaColumnA.touchLegend(e);
  276. // canvaColumnA.showToolTip(e);
  277. canvaColumnA.scrollEnd(e);
  278. //下面是toolTip事件,如果滚动后不需要显示,可不填写
  279. canvaColumnA.showToolTip(e, {
  280. format: function(item, category) {
  281. return category + ' ' + item.name + ':' + item.data
  282. }
  283. });
  284. },
  285. // 时间戳转换
  286. timestampToDateTime(timestamp, isTime) {
  287. var date = new Date(timestamp * 1000); // 将时间戳转换为毫秒并创建一个日期对象
  288. var year = date.getFullYear(); // 获取年份
  289. var month = ('0' + (date.getMonth() + 1)).slice(-2); // 获取月份,并补零
  290. var day = ('0' + date.getDate()).slice(-2); // 获取日期,并补零
  291. var hours = ('0' + date.getHours()).slice(-2); // 获取小时,并补零
  292. var minutes = ('0' + date.getMinutes()).slice(-2); // 获取分钟,并补零
  293. var seconds = ('0' + date.getSeconds()).slice(-2); // 获取秒数,并补零
  294. if(isTime) {
  295. return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
  296. } else {
  297. return `${year}-${month}-${day}`;
  298. }
  299. },
  300. // 历史数据
  301. async getHistoryData() {
  302. uni.showLoading({
  303. title: '加载中'
  304. });
  305. const {
  306. historyTime
  307. } = this;
  308. // 获取当前日期
  309. var currentDate = new Date();
  310. // 设置时间为 0 点
  311. currentDate.setHours(0, 0, 0, 0);
  312. let begin = historyTime.startDate ? (new Date(historyTime.startDate).getTime() / 1000) - 8*3600 : (Math.floor(currentDate.getTime() / 1000));
  313. // 设置时间为 24 点
  314. currentDate.setHours(24, 0, 0, 0);
  315. let end = historyTime.endDate ? (new Date(historyTime.endDate).getTime() / 1000) - 8*3600 : (Math.floor(currentDate.getTime() / 1000));
  316. //折线图数据
  317. let res = await this.$myRequest({
  318. url: "/api/api_gateway?method=weather.weather.sf_data_chart",
  319. data: {
  320. device_id: this.device_id,
  321. begin: begin,
  322. end: end,
  323. },
  324. })
  325. uni.hideLoading();
  326. var conf = res.conf.eleName;
  327. var dat = res.dat.reverse();
  328. //console.log(dat);
  329. conf = conf.split("/");
  330. // var arr1 = [];
  331. var regroupData = []; //重组数据
  332. let options = [];
  333. var timeList = [];
  334. for (var i = 0; i < conf.length; i++) {
  335. // var arr = [];
  336. if (conf[i] != "-") {
  337. var optionobj = {};
  338. optionobj.value = i;
  339. optionobj.label = conf[i];
  340. options.push(optionobj);
  341. var reddata = [];
  342. dat.forEach((item, index) => {
  343. if (timeList.length < dat.length) {
  344. timeList.push(this.timestampToDateTime(item.uptime, true));
  345. }
  346. var status = item.device_status.split(",");
  347. // //console.log(status);
  348. var arr = [];
  349. for (var j = 0; j < status.length; j++) {
  350. if (status[j].indexOf("e") + 1) {
  351. arr.push(status[j]);
  352. }
  353. }
  354. // //console.log(arr)
  355. var dataobj = {};
  356. for (var k = 0; k < arr.length; k++) {
  357. var indexs = arr[k].indexOf(":");
  358. // //console.log(arr[k])
  359. if (k == 0) {
  360. dataobj[arr[k].slice(1, indexs).trim()] = arr[k]
  361. .substr(indexs + 1)
  362. .trim();
  363. } else {
  364. dataobj[arr[k].slice(0, indexs).trim()] = arr[k]
  365. .substr(indexs + 1)
  366. .trim();
  367. }
  368. }
  369. // //console.log(dataobj)
  370. for (var key in dataobj) {
  371. // //console.log(i)
  372. var str = "'e" + (i + 1) + "'";
  373. // //console.log(key,str);
  374. if (key == str) {
  375. if (Number(dataobj[key]) == 32767) {
  376. // reddata.push([]);
  377. } else {
  378. reddata.push(Number(dataobj[key]));
  379. }
  380. }
  381. }
  382. });
  383. regroupData.push({
  384. name: conf[i],
  385. type: "spline",
  386. fillColor: {
  387. linearGradient: [0, 0, 0, 300],
  388. },
  389. data: reddata,
  390. });
  391. }
  392. }
  393. // console.log(timeList);
  394. this.showColumn('canvasColumnA', timeList, regroupData)
  395. },
  396. // 切换选项卡
  397. change(index) {
  398. this.page = 1;
  399. this.total = 0;
  400. this.current = index;
  401. this.status = 'loadmore';
  402. this.tableData = [];
  403. this.getEquipcontroldata();
  404. },
  405. // 获取要素实时数据
  406. async getElmentInfo() {
  407. uni.showLoading({
  408. title: '加载中'
  409. });
  410. let res = await this.$myRequest({
  411. url: "/api/api_gateway?method=xphsp.views.device_elements",
  412. data: {
  413. device_id: this.device_id,
  414. },
  415. })
  416. uni.hideLoading();
  417. var conf = res.conf.eleName.split('/');
  418. var dataList = [res.data.device_data];
  419. if (dataList.length == 0) return
  420. this.ElementList = [];
  421. conf.forEach((item, index) => {
  422. let obj = {}
  423. if (item == '-') return
  424. obj.name = item;
  425. let valList = dataList[0][`e${index + 1}`].split('#');
  426. obj.value = valList[0];
  427. obj.unit = valList[1];
  428. obj.time = dataList[0].uptime;
  429. this.ElementList.push(obj)
  430. })
  431. // console.log(this.ElementList)
  432. },
  433. async getEquipstatus() {
  434. uni.showLoading({
  435. title: '加载中'
  436. });
  437. this.facilityvalve = [];
  438. let res = await this.$myRequest({
  439. url: "/api/api_gateway?method=xphsp.views.device_info",
  440. data: {
  441. device_id: this.device_id,
  442. },
  443. })
  444. uni.hideLoading();
  445. var conf = res.conf.relayName;
  446. var dataobj = res.device_status;
  447. var relayNum = res.conf.relayNum;
  448. var arr = [];
  449. function numberToArray(number) {
  450. // 将数字转换为字符串
  451. let numString = number.toString();
  452. // 创建一个空数组,用于存储结果
  453. let result = [];
  454. // 遍历字符串的每个字符,并将其转换为对应的数字
  455. for (let i = 0; i < numString.length; i++) {
  456. result.push(parseInt(numString.charAt(i)));
  457. }
  458. return result;
  459. }
  460. for (var i = 0; i < dataobj.length; i++) {
  461. // if (offobj[i].indexOf("j") + 1) {
  462. arr.push(offobj[i]);
  463. // }
  464. }
  465. conf = conf.split("/");
  466. relayNum = relayNum.split("/");
  467. var arr1 = [];
  468. var reg = /\d/;
  469. let totalP = Math.ceil((conf.length) / 32); //总圈数
  470. for (var i = 0; i < conf.length; i++) {
  471. var obj = {};
  472. obj.name = conf[i];
  473. // if (reg.test(conf[i])) {
  474. // obj.name2 = conf[i].slice(0, conf[i].length - 1);
  475. // } else {
  476. // obj.name2 = conf[i];
  477. // }
  478. obj.name2 = this.typename[relayNum[i]];
  479. obj.number = i;
  480. obj.type = `j${i + 1}`;
  481. obj.disabled = false;
  482. // "state": 1 继电器打开 ;"state": 0 继电器关闭
  483. // 处理开关值
  484. // J开头表示状态,总共只有32长度,超过32则从头赋值 位数多一位
  485. // 例:1和33是都在J1里面,返回值是一个二进制数 倒数第一位表示第一个 第二位表示33状态 以此类推
  486. // 根据总长度 为超过32的j赋值
  487. // 当前是循环的第几轮
  488. let baseP = Math.ceil((i + 1) / 32);
  489. if (i > 31) {
  490. dataobj[`j${i + 1}`] = dataobj[
  491. `j${(i + 1) % 32 == 0 ? 32 : (i + 1) % 32}`]; // 当前脚标/32取余 当恰好整除的时候 取32
  492. }
  493. dataobj[`j${i + 1}`] = dataobj[`j${i + 1}`].slice(-totalP); // 截取当前圈数的最后几位数字
  494. let baseOff = numberToArray(dataobj[`j${i + 1}`]); // 把当前值根据位数 转换为数组
  495. obj.off = baseOff[baseP - 1] == '0' ? false : true; // 根据当前圈数,取对应的数组的值
  496. arr1.push(obj);
  497. }
  498. for (var i = 0; i < arr1.length; i++) {
  499. if (arr1[i].name != "-") {
  500. this.facilityvalve.push(arr1[i]);
  501. }
  502. }
  503. this.facilityvalve.forEach(item => {
  504. if (item.type == 'j9' && item.off == true) {
  505. // 判断注水泵是否打开
  506. this.mainBeng = true;
  507. }
  508. if (item.type == 'j10' && item.off == true) {
  509. // 判断施肥阀是否打开
  510. this.feiBeng = true;
  511. }
  512. })
  513. let feiNum = 0; // 记录废料桶占据通道个数,两个通道为一个肥料桶
  514. this.buttonList = [];
  515. this.facilityvalve.forEach((item, index) => {
  516. if (this.colomRoundList.indexOf(item.type) > -1) {
  517. feiNum++;
  518. this.buttonList.push(item);
  519. }
  520. if (item.type == 'j10' && item.off == true) {
  521. // 判断注水泵是否打开
  522. this.mainBeng = true;
  523. }
  524. if (item.type == 'j9' && item.off == true) {
  525. // 判断施肥阀是否打开
  526. this.feiBeng = true;
  527. }
  528. })
  529. this.feiNum = feiNum;
  530. console.log(this.facilityvalve)
  531. },
  532. async getEquipcontrol(num, state, double_order) {
  533. //设备控制
  534. uni.showLoading({
  535. title: '正在下发指令'
  536. });
  537. let res = await this.$myRequest({
  538. url: "/api/api_gateway?method=xphsp.views.control_order",
  539. data: {
  540. device_id: this.device_id,
  541. relayNum: num,
  542. relayState: state,
  543. double_order
  544. },
  545. })
  546. uni.hideLoading();
  547. if (res.controlState) {
  548. uni.showToast({
  549. title: '指令下发成功',
  550. duration: 2000,
  551. icon: 'none'
  552. });
  553. } else {
  554. uni.showToast({
  555. title: res.message,
  556. duration: 2000,
  557. icon: 'none'
  558. })
  559. }
  560. },
  561. // sf_control_data
  562. // 操作记录日期
  563. changeConsoleDate(e) {
  564. this.consoleTime = e;
  565. this.tableData = [];
  566. this.page = 1;
  567. this.getEquipcontroldata()
  568. },
  569. clearContime() {
  570. this.consoleTime = {};
  571. this.tableData = [];
  572. this.page = 1;
  573. this.getEquipcontroldata()
  574. },
  575. //操作记录
  576. async getEquipcontroldata() {
  577. uni.showLoading({
  578. title: '加载中'
  579. });
  580. const {
  581. consoleTime
  582. } = this;
  583. let begin = consoleTime.startDate ? new Date(consoleTime.startDate).getTime() / 1000 : '';
  584. let end = consoleTime.endDate ? new Date(consoleTime.endDate).getTime() / 1000 : '';
  585. //操作记录
  586. let res = await this.$myRequest({
  587. method: "POST",
  588. url: "/api/api_gateway?method=xphsp.views.control_log",
  589. data: {
  590. device_id: this.device_id,
  591. page_num: this.page,
  592. page_size: 15,
  593. start: begin,
  594. end: end,
  595. sys_control: this.current - 1
  596. },
  597. })
  598. uni.hideLoading();
  599. // this.tableData = [];
  600. var record = res.result;
  601. this.tableData = [...this.tableData, ...record];
  602. this.total = res.count;
  603. if (this.page * 15 > this.total) {
  604. this.status = 'nomore'
  605. } else {
  606. this.status = 'loadmore'
  607. }
  608. console.log(this.tableData);
  609. },
  610. switchchange(e, state, item, index, isfeiButton) {
  611. // 是否是肥料开关,是的话 两个合并为一个
  612. if (isfeiButton) {
  613. item.off = e;
  614. item.disabled = true;
  615. this.changeTimeStatus(item, index);
  616. // 当前是打开
  617. if (e) {
  618. // 打开通道传1,关闭通道传0
  619. this.getEquipcontrol(state, 1, 1);
  620. // this.getEquipcontrol(state + 1, 0);
  621. } else {
  622. // this.getEquipcontrol(state + 1, 0);
  623. this.getEquipcontrol(state, 0, 1);
  624. }
  625. return
  626. }
  627. item.off = e;
  628. if (item.type == 'j10') {
  629. // 判断注水泵是否打开
  630. this.mainBeng = e;
  631. }
  632. if (item.type == 'j9') {
  633. // 判断施肥阀是否打开
  634. this.feiBeng = e;
  635. }
  636. // if (this.colomRoundList.indexOf(item.type) > -1) {
  637. // let changeIndex = index;
  638. // if ((index + 1) % 2 == 0) {
  639. // // 偶数 往前取值
  640. // this.facilityvalve[index - 1].disabled = true;
  641. // changeIndex = index - 1;
  642. // } else if ((index + 1) % 2 == 1) {
  643. // // 基数 往后取值
  644. // this.facilityvalve[index + 1].disabled = true;
  645. // changeIndex = index + 1;
  646. // }
  647. // item.disabled = true;
  648. // this.changeTimeStatus(item, changeIndex);
  649. // this.getEquipcontrol(changeIndex, Number(!e));
  650. // } else {
  651. // }
  652. item.disabled = true;
  653. this.changeTimeStatus(item, index);
  654. //console.log(Number(e), state);
  655. this.getEquipcontrol(state, Number(e));
  656. },
  657. currentchange(e) {
  658. //页码
  659. if (this.type == 0) {
  660. this.pageDialog = e;
  661. } else {
  662. this.page = e;
  663. }
  664. this.getEquipcontroldata(this.type);
  665. },
  666. },
  667. onReachBottom() {
  668. if (this.current != 0 && this.status == 'loadmore') {
  669. this.page++;
  670. this.getEquipcontroldata()
  671. }
  672. },
  673. onLoad(option) {
  674. let deviceItem = JSON.parse(option.shebei)
  675. this.device_id = deviceItem.device_id;
  676. this.getEquipstatus();
  677. this.getElmentInfo();
  678. this.getEquipcontroldata();
  679. }
  680. }
  681. </script>
  682. <style scoped lang="less">
  683. .box {
  684. position: relative;
  685. width: 100%;
  686. height: 100vh;
  687. }
  688. .bigBox {
  689. width: 100%;
  690. }
  691. .bigOpen {
  692. overflow: hidden;
  693. height: 100vh;
  694. }
  695. /deep/ .u-flex {
  696. display: flex;
  697. justify-content: center;
  698. }
  699. .topInfo {
  700. background: #14A478;
  701. color: #fff;
  702. font-size: 28rpx;
  703. padding-bottom: 32rpx;
  704. box-sizing: border-box;
  705. border-bottom-left-radius: 16rpx;
  706. border-bottom-right-radius: 16rpx;
  707. .u-col {
  708. box-sizing: border-box;
  709. margin-top: 32rpx;
  710. .item {
  711. text-align: center;
  712. view:first-child {
  713. font-size: 40rpx;
  714. }
  715. view:nth-child(2) {
  716. font-size: 24rpx;
  717. line-height: 40rpx;
  718. opacity: .72;
  719. }
  720. }
  721. }
  722. }
  723. .readmore {
  724. text-align: center;
  725. font-size: 26rpx;
  726. line-height: 40rpx;
  727. margin-top: 32rpx;
  728. color: #93FFDE;
  729. .u-icon {
  730. margin-left: 15rpx;
  731. }
  732. }
  733. .histimeBox {
  734. display: flex;
  735. align-items: center;
  736. justify-content: space-between;
  737. height: 56rpx;
  738. padding: 6rpx 24rpx;
  739. box-sizing: border-box;
  740. border-radius: 8rpx;
  741. margin-top: 54rpx;
  742. border: 2rpx solid var(--neutral-color-border-light, #E4EDEA);
  743. .u-icon {
  744. z-index: 10;
  745. }
  746. .time {
  747. width: 280rpx;
  748. color: #C1C1C1;
  749. }
  750. view {
  751. color: #333333;
  752. text-align: center;
  753. }
  754. }
  755. .consoleBox {
  756. position: relative;
  757. max-height: 75vh;
  758. padding-bottom: 80rpx;
  759. overflow: auto;
  760. .u-row {
  761. box-sizing: border-box;
  762. .u-col {
  763. box-sizing: border-box;
  764. }
  765. }
  766. .u-btn {
  767. position: absolute;
  768. bottom: 0;
  769. left: 0;
  770. right: 0;
  771. background: #14A478;
  772. }
  773. .swichBox {
  774. position: relative;
  775. padding: 32rpx;
  776. overflow: hidden;
  777. .preSwich {
  778. display: flex;
  779. align-items: center;
  780. justify-content: space-between;
  781. padding: 24rpx 18rpx;
  782. border-radius: 8rpx;
  783. background: #EFF2FA;
  784. margin-bottom: 32rpx;
  785. view {
  786. color: #333333;
  787. font-size: 28rpx;
  788. }
  789. }
  790. }
  791. }
  792. .hisBox {
  793. padding-bottom: 100rpx;
  794. .axiosBox {
  795. padding: 48rpx 32rpx;
  796. .title {
  797. color: #333333;
  798. font-size: 28rpx;
  799. font-weight: 700;
  800. }
  801. .chartBox {
  802. margin-top: 32rpx;
  803. height: 700rpx;
  804. #canvasColumnA {
  805. width: 100%;
  806. height: 700rpx;
  807. }
  808. }
  809. }
  810. .readmore {
  811. color: #14A478;
  812. }
  813. }
  814. .devicePhoto {
  815. padding: 32rpx;
  816. .titleBox {
  817. display: flex;
  818. align-items: center;
  819. justify-content: space-between;
  820. .btn {
  821. padding: 10rpx 14rpx;
  822. border-radius: 8rpx;
  823. background: #14A478;
  824. color: #fff;
  825. font-size: 28rpx;
  826. }
  827. }
  828. .main {
  829. position: relative;
  830. padding-top: 32rpx;
  831. .mainContent {
  832. position: absolute;
  833. left: 50%;
  834. transform: translateX(-50%);
  835. width: 565rpx;
  836. top: 112rpx;
  837. height: 242rpx;
  838. z-index: 1;
  839. }
  840. .sourceBox {
  841. position: absolute;
  842. left: 20rpx;
  843. z-index: 2;
  844. display: flex;
  845. align-items: center;
  846. justify-content: center;
  847. width: 112rpx;
  848. height: 112rpx;
  849. background: #E3FDFF;
  850. border-radius: 112rpx;
  851. color: #fff;
  852. view {
  853. width: 85rpx;
  854. height: 85rpx;
  855. background: #1890FF;
  856. border-radius: 85rpx;
  857. text-align: center;
  858. line-height: 85rpx;
  859. font-size: 28rpx;
  860. }
  861. }
  862. .colList {
  863. position: absolute;
  864. z-index: 2;
  865. top: 24rpx;
  866. left: 120rpx;
  867. width: 470rpx;
  868. display: flex;
  869. justify-content: space-between;
  870. .preClo {
  871. width: 80rpx;
  872. margin-left: 40rpx;
  873. view {
  874. text-align: center;
  875. color: #333333;
  876. font-size: 28rpx;
  877. margin-bottom: 20rpx;
  878. }
  879. image {
  880. width: 80rpx;
  881. height: 164rpx;
  882. }
  883. }
  884. }
  885. .benList {
  886. position: absolute;
  887. width: 565rpx;
  888. left: 50%;
  889. transform: translateX(-50%);
  890. top: 342rpx;
  891. .preBen {
  892. float: left;
  893. text-align: center;
  894. width: 25%;
  895. .daoguan {
  896. width: 20rpx;
  897. height: 40rpx;
  898. }
  899. .info {
  900. color: #333333;
  901. font-size: 12px;
  902. font-weight: 400;
  903. }
  904. .status {
  905. width: 76rpx;
  906. height: 100rpx;
  907. margin-top: 10rpx;
  908. }
  909. }
  910. }
  911. .fengBox {
  912. position: absolute;
  913. right: 12rpx;
  914. top: 270rpx;
  915. width: 55rpx;
  916. height: 44rpx;
  917. z-index: 2;
  918. .relativeBox {
  919. position: relative;
  920. width: 100%;
  921. height: 100%;
  922. image:nth-child(1) {
  923. width: 16rpx;
  924. height: 32rpx;
  925. }
  926. image:nth-child(2) {
  927. position: absolute;
  928. right: 0;
  929. top: -6rpx;
  930. width: 44rpx;
  931. height: 44rpx;
  932. }
  933. }
  934. .circleAnm {
  935. animation: ancirle 2s linear infinite;
  936. }
  937. // 旋转
  938. @keyframes ancirle {
  939. 0% {
  940. transform: rotate(0);
  941. }
  942. 100% {
  943. transform: rotate(360deg);
  944. }
  945. }
  946. }
  947. }
  948. }
  949. .consoleList {
  950. padding: 0 32rpx;
  951. .histimeBox {
  952. margin: 32rpx 0;
  953. }
  954. .tableTitle {
  955. background: #E8F3F0;
  956. color: #333;
  957. font-weight: 600;
  958. }
  959. .tableList {
  960. font-size: 28rpx;
  961. height: 78rpx;
  962. color: #666666;
  963. display: flex;
  964. justify-content: space-between;
  965. align-items: center;
  966. border-bottom: 2rpx solid var(--neutral-color-border-base, #DCE6E3);
  967. view {
  968. text-align: center;
  969. }
  970. view:nth-child(1) {
  971. width: 120rpx;
  972. }
  973. view:nth-child(2) {
  974. width: 280rpx;
  975. }
  976. view:nth-child(3) {
  977. width: 280rpx;
  978. }
  979. }
  980. }
  981. </style>