details第一版vue 27 KB

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