| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407 |
- <template>
- <view class="box">
- <view class="status_bar"></view>
- <view style="position: fixed;z-index: 100;width: 100%;">
- <uni-nav-bar @clickLeft="clickLeft" left-icon="back" left-text="返回" title="水肥详情"></uni-nav-bar>
- </view>
- <!-- 上面要素值 -->
- <view class="bigBox bigOpen" v-if="show">
- <view class="topInfo">
- <u-row gutter="10">
- <u-col span="3" v-for="item in ElementList" :key="item.id">
- <view class="item">
- <view>{{item.value}}</view>
- <view>{{item.unit}}</view>
- <view>{{item.name}}</view>
- </view>
- </u-col>
- </u-row>
- <view class="readmore" v-if="!show" @click="show=true;getHistoryData()">
- 查看详情<u-icon name="arrow-down" color="#93FFDE" size="28"></u-icon>
- </view>
- </view>
- <!-- 统计图 -->
- <view class="hisBox" v-show="show">
- <view class="axiosBox">
- <view class="title">
- 历史数据
- </view>
- <view class="histimeBox">
- <u-icon name="calendar" color="#C1C1C1" size="24"></u-icon>
- <view class="time" @click="calendarshow = true">
- {{historyTime.startDate ? historyTime.startDate : timestampToDateTime(new Date().getTime()/1000)}}
- </view>
- <view class="">至</view>
- <view class="time" @click="calendarshow = true">
- {{historyTime.endDate ? historyTime.endDate : timestampToDateTime(new Date().getTime()/1000)}}
- </view>
- <u-icon name="close-circle" color="#C1C1C1" size="28" @click="historyTime={};getHistoryData()"
- v-if="historyTime.startDate"></u-icon>
- </view>
- <u-calendar v-model="calendarshow" mode="range" @change="changeDate"></u-calendar>
- <view class="chartBox">
- <canvas canvas-id="canvasColumnA" id="canvasColumnA" class="charts"
- @touchstart="touchLineA($event)" @touchmove="moveLineA($event)"
- @touchend="touchEndLineA($event)"></canvas>
- </view>
- </view>
- <view class="readmoreHIs" @click="show=false">
- 收起详情<u-icon name="arrow-up" color="#14A478" size="28"></u-icon>
- </view>
- </view>
- </view>
- <view class="bigBox" v-else>
- <view class="topInfo">
- <u-row gutter="10">
- <u-col span="3" v-for="item in ElementList" :key="item.id">
- <view class="item">
- <view>{{item.value}}</view>
- <view>{{item.unit}}</view>
- <view>{{item.name}}</view>
- </view>
- </u-col>
- </u-row>
- <view class="readmore" v-if="!show" @click="show=true;getHistoryData()">
- 查看详情<u-icon name="arrow-down" color="#93FFDE" size="28"></u-icon>
- </view>
- </view>
- <!-- 统计图 -->
- <view class="hisBox" v-show="show">
- <view class="axiosBox">
- <view class="title">
- 历史数据
- </view>
- <view class="histimeBox">
- <u-icon name="calendar" color="#C1C1C1" size="24"></u-icon>
- <view class="time" @click="calendarshow = true">
- {{historyTime.startDate ? historyTime.startDate : timestampToDateTime(new Date().getTime()/1000)}}
- </view>
- <view class="">至</view>
- <view class="time" @click="calendarshow = true">
- {{historyTime.endDate ? historyTime.endDate : timestampToDateTime(new Date().getTime()/1000)}}
- </view>
- <u-icon name="close-circle" color="#C1C1C1" size="28" @click="historyTime={};getHistoryData()"
- v-if="historyTime.startDate"></u-icon>
- </view>
- <u-calendar v-model="calendarshow" mode="range" @change="changeDate"></u-calendar>
- <view class="chartBox">
- <canvas canvas-id="canvasColumnA" id="canvasColumnA" class="charts"
- @touchstart="touchLineA($event)" @touchmove="moveLineA($event)"
- @touchend="touchEndLineA($event)"></canvas>
- </view>
- </view>
- <view class="readmoreHIs" @click="show=false">
- 收起详情<u-icon name="arrow-up" color="#14A478" size="28"></u-icon>
- </view>
- </view>
- </view>
- <view class="" v-if="!show">
- <!-- 历史记录弹框 -->
- <u-tabs :list="list" active-color="#14A478" bar-width="100" :is-scroll="false" :current="current"
- @change="change"></u-tabs>
- <!-- 设备图 -->
- <view class="devicePhoto" v-if="current == 0">
- <view class="titleBox">
- <u-alert-tips type="primary" :title-style="alertTipColor" title="点击按钮可对应控制阀门开关,开即打开,关即关闭"
- :show-icon="true"></u-alert-tips>
- <!-- <view class="btn" @click="statusPanel=true">控制面板</view> -->
- <!-- <u-popup v-model="statusPanel" mode="bottom">
- <view class="consoleBox">
- <view class="swichBox">
- <u-row :gutter="16" justify="space-between">
- <u-col span="6" v-for="(item, index) in buttonList" v-if="(index + 1) % 2 == 1">
- <view class="preSwich">
- <view>肥料{{ (index + 1) / 2 > 1 ? (index + 2) / 2 : 1 }}</view>
- <u-switch v-model="item.off" active-color="#14A478" inactive-color="#AEB4C2"
- :loading="item.disabled"
- @change="switchchange($event, item.number, item, index, true)"></u-switch>
- </view>
- </u-col>
- <u-col span="6" v-for="(item, index) in facilityvalve"
- v-if="index > buttonList.length - 1">
- <view class="preSwich">
- <view>{{item.name}}</view>
- <u-switch v-model="item.off" active-color="#14A478" inactive-color="#AEB4C2"
- :loading="item.disabled"
- @change="switchchange($event, item.number, item, index)"></u-switch>
- </view>
- </u-col>
- </u-row>
- </view>
- <u-button type="success" @click="statusPanel=false">确定</u-button>
- </view>
- </u-popup> -->
- </view>
- <view class="main">
- <image class="mainContent" :src="$imageURL+'/bigdata_app/log/mainNew.png'"></image>
- <!-- <view class="sourceBox">
- <view class="smallBox">
- 水源
- </view>
- </view> -->
- <!-- 桶 -->
- <view class="colList">
- <view class="preClo" v-for="item, index in pickBtnList" :key="item.type">
- <view class="btnName">
- {{resultBan[index].e_name}}
- </view>
- <image :src="$imageURL+'/bigdata_app/log/colNew.png'" v-if="pickBtnList.length == 1">
- </image>
- <image :src="$imageURL+'/bigdata_app/log/colLeft.png'"
- v-else-if="pickBtnList.length > 1 && index == 0"></image>
- <image :src="$imageURL+'/bigdata_app/log/colRight.png'"
- v-else-if="pickBtnList.length > 1 && index == pickBtnList.length - 1"></image>
- <image :src="$imageURL+'/bigdata_app/log/colCenter.png'" v-else></image>
- <view class="jiaoBtn" v-if="resultBan.length > 0">
- <u-switch v-model="resultBan[index]['off']" active-color="#14A478"
- inactive-color="#AEB4C2" :loading="resultBan[index]['disabled']"
- @change="switchchange($event, resultBan[index]['number'], resultBan[index], index)"></u-switch>
- </view>
- <view class="shanBox" v-if="resultBan.length > 0">
- <image v-if="!resultBan[index]['off']"
- :src="$imageURL+'/bigdata_app/log/shan.png'"></image>
- <image v-else class="circleAnm"
- :src="$imageURL+'/bigdata_app/log/shanannimate.png'"></image>
- </view>
- <view class="btnBox" @click="switchchange($event, item.number, item, index, true)">
- <image v-if="item.off" :src="$imageURL+'/bigdata_app/log/feiopen.png'"></image>
- <image v-else :src="$imageURL+'/bigdata_app/log/feiclose.png'"></image>
- </view>
- </view>
- </view>
- <!-- 废料管口 -->
- <view class="exit">
- <image :src="$imageURL+'/bigdata_app/log/exit.png'"></image>
- </view>
- <!-- 注肥泵 -->
- <view class="feiLight"
- @click="switchchange(!feiBengItem.e_status, feiBengItem.number, feiBengItem, feiBengIndex)">
- <image v-if="feiBengItem.e_status" :src="$imageURL+'/bigdata_app/log/feiAllopen.png'"></image>
- <image v-else :src="$imageURL+'/bigdata_app/log/feiAllclose.png'"></image>
- </view>
- <!-- 控制柜 -->
- <view class="kongBox">
- <image v-if="feiBengItem.e_status" :src="$imageURL+'/bigdata_app/log/kongclose.png'"></image>
- <image v-else :src="$imageURL+'/bigdata_app/log/kongopen.png'"></image>
- </view>
- <!-- 进水泵 -->
- <view class="warterIn"
- @click="switchchange(!mainBengItem.e_status, mainBengItem.number, mainBengItem, mainBengIndex)">
- <image v-if="mainBengItem.e_status" :src="$imageURL+'/bigdata_app/log/feiopen.png'"></image>
- <image v-else :src="$imageURL+'/bigdata_app/log/feiclose.png'"></image>
- </view>
- <!-- 进水指示 -->
- <view class="warterLight">
- <image v-if="mainBengItem.e_status" :src="$imageURL+'/bigdata_app/log/bengopen.png'"></image>
- <image v-else :src="$imageURL+'/bigdata_app/log/bengclose.png'"></image>
- </view>
- <!-- 电风扇 -->
- <!-- <view class="fengBox">
- <view class="relativeBox">
- <image :src="$imageURL+'/bigdata_app/log/fengmain.png'"></image>
- <image :class="feiBeng ? 'circleAnm' : ''"
- :src="$imageURL+'/bigdata_app/log/fengleafs.png'"></image>
- </view>
- </view> -->
- <!-- 水管控制阀 -->
- <view class="benList">
- <!-- <view class="preBen" v-for="item, index in buttonList" v-if="(index + 1) % 2 == 1"
- @click="switchchange(!item.off, item.number, item, index, true)">
- <image class="daoguan" :src="$imageURL+'/bigdata_app/log/bottomNew.png'"
- v-if="(index + 1) % 2 < 4"></image>
- <view class="info">
- 肥料{{ (index + 1) / 2 > 1 ? (index + 2) / 2 : 1 }}开关
- </view>
- <image class="status" v-if="item.off" :src="$imageURL+'/bigdata_app/log/open.png'">
- </image>
- <image class="status" v-else :src="$imageURL+'/bigdata_app/log/close.png'"></image>
- </view> -->
- <view class="preBen" v-for="item, index in faList"
- @click="switchchange(!item.e_status, item.number, item, index)">
- <image class="daoguan" :src="$imageURL+'/bigdata_app/log/bottomNew.png'"
- v-if="index < 5"></image>
- <view class="info">
- {{item.e_name}}
- </view>
- <image class="status" v-if="item.e_status" :src="$imageURL+'/bigdata_app/log/open.png'">
- </image>
- <image class="status" v-else :src="$imageURL+'/bigdata_app/log/close.png'"></image>
- </view>
- </view>
- </view>
- </view>
- <!-- 操作记录 -->
- <view class="consoleList" v-else>
- <view class="histimeBox">
- <u-icon name="calendar" color="#C1C1C1" size="24"></u-icon>
- <view class="time" @click="consoleshow = true">
- {{consoleTime.startDate ? consoleTime.startDate : '开始'}}
- </view>
- <view class="">至</view>
- <view class="time" @click="consoleshow = true">{{consoleTime.endDate ? consoleTime.endDate : '结束'}}
- </view>
- <u-icon name="close-circle" color="#C1C1C1" size="28" @click="clearContime"
- v-if="consoleTime.startDate"></u-icon>
- </view>
- <u-calendar v-model="consoleshow" mode="range" @change="changeConsoleDate"></u-calendar>
- <view class="tableList tableTitle">
- <view>设备名称</view>
- <view>操作内容</view>
- <view>操作时间</view>
- </view>
- <view class="tableList" v-for="(item, index) in tableData" :key="item.uptime">
- <view>{{item.device_name}}</view>
- <view :class="item.status ? 'success' : 'error'">{{item.operation_content}}</view>
- <view>{{item.uptime}}</view>
- </view>
- <u-loadmore :status="status" />
- </view>
- </view>
- </view>
- </template>
- <script>
- import uCharts from '../../components/js_sdk/u-charts/u-charts/u-charts.js';
- var canvaColumnA = null;
- var canvasRing = null;
- export default {
- data() {
- return {
- typeObj: {
- 1: '控制柜',
- 2: '灌溉泵',
- 3: '搅拌机',
- 4: '注肥泵',
- 5: '阀控器',
- 6: '施肥桶'
- }, //阀控器类型对应
- pickBtnList: [], // 肥料开关列表
- resultBan: [], // 搅拌机开关列表
- faList: [], // 发空气开关列表
- alertTipColor: {
- color: '#1890FF',
- fontSize: "12px"
- },
- device_id: '',
- mainBengEKey: '',
- mainBengIndex: 0, // 进水泵的位置
- mainBengItem:{},
- mainBeng: false,
- feiBeng: false,
- feiBengItem: {}, // 施肥泵的位置
- feiBengEKey:'',
- calendarshow: false,
- historyTime: {},
- cWidth: '350',
- cHeight: '350',
- pixelRatio: 1,
- facilityvalve: [],
- feiNum: 0, //肥料桶实际占据通道个数
- buttonList: [], // 肥料开关列表
- colomRoundList: ['j1', 'j2', 'j3', 'j4', 'j5', 'j6', 'j7', 'j8'], // 废料桶的通道
- ElementList: [],
- typename: [
- "-",
- "风机",
- "水泵",
- "增氧机",
- "湿帘",
- "遮阳",
- "开窗",
- "保温",
- "投食机",
- ],
- show: false,
- list: [{
- name: '设备控制'
- }, {
- name: '执行结果'
- }, {
- name: '操作记录'
- }],
- statusPanel: false,
- current: 0,
- consoleshow: false,
- consoleTime: {},
- tableData: [],
- page: 1,
- total: 0,
- status: 'loadmore'
- }
- },
- methods: {
- clickLeft() {
- uni.navigateBack({
- delta: 1
- })
- },
- changeTimeStatus(item, changeIndex) {
- this.timer = setTimeout(() => {
- item.disabled = false; // 改变值
- this.facilityvalve[changeIndex].disabled = false;
- this.getEquipstatus()
- this.timer = null; // 清空定时器引用
- }, 15000);
- },
- // 选择日期
- changeDate(e) {
- console.log(e)
- this.historyTime = e;
- this.getHistoryData()
- },
- // 绘制折线图
- showColumn(id, xtitle, xinfo) {
- var _self = this
- const ctx = uni.createCanvasContext(id, this);
- canvaColumnA = new uCharts({
- context: ctx,
- type: 'line',
- legend: {
- position: "top"
- },
- fontSize: 11,
- background: '#FFFFFF',
- pixelRatio: 1,
- animation: true,
- dataLabel: false,
- categories: xtitle,
- series: xinfo,
- enableScroll: true, //开启图表拖拽功能
- xAxis: {
- disabled: true,
- disableGrid: false,
- type: 'grid',
- gridType: 'dash',
- itemCount: 15, //x轴单屏显示数据的数量,默认为5个
- scrollShow: true, //新增是否显示滚动条,默认false
- scrollAlign: 'right', //滚动条初始位置
- scrollBackgroundColor: '#F7F7FF', //默认为 #EFEBEF
- scrollColor: '#DEE7F7', //默认为 #A6A6A6
- },
- yAxis: {},
- width: _self.cWidth * 1,
- height: _self.cHeight * 1,
- extra: {
- line: {
- type: 'curve'
- }
- }
- });
- },
- touchLineA(e) {
- // console.log(e)
- canvaColumnA.scrollStart(e);
- },
- moveLineA(e) {
- canvaColumnA.scroll(e);
- },
- touchEndLineA(e) {
- canvaColumnA.touchLegend(e);
- // canvaColumnA.showToolTip(e);
- canvaColumnA.scrollEnd(e);
- //下面是toolTip事件,如果滚动后不需要显示,可不填写
- canvaColumnA.showToolTip(e, {
- format: function(item, category) {
- return category + ' ' + item.name + ':' + item.data
- }
- });
- },
- // 时间戳转换
- timestampToDateTime(timestamp, isTime) {
- var date = new Date(timestamp * 1000); // 将时间戳转换为毫秒并创建一个日期对象
- var year = date.getFullYear(); // 获取年份
- var month = ('0' + (date.getMonth() + 1)).slice(-2); // 获取月份,并补零
- var day = ('0' + date.getDate()).slice(-2); // 获取日期,并补零
- var hours = ('0' + date.getHours()).slice(-2); // 获取小时,并补零
- var minutes = ('0' + date.getMinutes()).slice(-2); // 获取分钟,并补零
- var seconds = ('0' + date.getSeconds()).slice(-2); // 获取秒数,并补零
- if (isTime) {
- return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
- } else {
- return `${year}-${month}-${day}`;
- }
- },
- // 历史数据
- async getHistoryData() {
- uni.showLoading({
- title: '加载中'
- });
- const {
- historyTime
- } = this;
- // 获取当前日期
- var currentDate = new Date();
- // 设置时间为 0 点
- currentDate.setHours(0, 0, 0, 0);
- let begin = historyTime.startDate ? (new Date(historyTime.startDate).getTime() / 1000) - 8 * 3600 : (
- Math.floor(currentDate.getTime() / 1000));
- // 设置时间为 24 点
- currentDate.setHours(24, 0, 0, 0);
- let end = historyTime.endDate ? (new Date(historyTime.endDate).getTime() / 1000) - 8 * 3600 : (Math
- .floor(currentDate.getTime() / 1000));
- //折线图数据
- let res = await this.$myRequest({
- url: "/api/api_gateway?method=weather.weather.sf_data_chart",
- data: {
- device_id: this.device_id,
- begin: begin,
- end: end,
- },
- })
- uni.hideLoading();
- var conf = res.conf.eleName;
- var dat = res.dat.reverse();
- //console.log(dat);
- conf = conf.split("/");
- // var arr1 = [];
- var regroupData = []; //重组数据
- let options = [];
- var timeList = [];
- for (var i = 0; i < conf.length; i++) {
- // var arr = [];
- if (conf[i] != "-") {
- var optionobj = {};
- optionobj.value = i;
- optionobj.label = conf[i];
- options.push(optionobj);
- var reddata = [];
- dat.forEach((item, index) => {
- if (timeList.length < dat.length) {
- timeList.push(this.timestampToDateTime(item.uptime, true));
- }
- var status = item.device_status.split(",");
- // //console.log(status);
- var arr = [];
- for (var j = 0; j < status.length; j++) {
- if (status[j].indexOf("e") + 1) {
- arr.push(status[j]);
- }
- }
- // //console.log(arr)
- var dataobj = {};
- for (var k = 0; k < arr.length; k++) {
- var indexs = arr[k].indexOf(":");
- // //console.log(arr[k])
- if (k == 0) {
- dataobj[arr[k].slice(1, indexs).trim()] = arr[k]
- .substr(indexs + 1)
- .trim();
- } else {
- dataobj[arr[k].slice(0, indexs).trim()] = arr[k]
- .substr(indexs + 1)
- .trim();
- }
- }
- // //console.log(dataobj)
- for (var key in dataobj) {
- // //console.log(i)
- var str = "'e" + (i + 1) + "'";
- // //console.log(key,str);
- if (key == str) {
- if (Number(dataobj[key]) == 32767) {
- // reddata.push([]);
- } else {
- reddata.push(Number(dataobj[key]));
- }
- }
- }
- });
- regroupData.push({
- name: conf[i],
- type: "spline",
- fillColor: {
- linearGradient: [0, 0, 0, 300],
- },
- data: reddata,
- });
- }
- }
- // console.log(timeList);
- this.showColumn('canvasColumnA', timeList, regroupData)
- },
- // 切换选项卡
- change(index) {
- this.page = 1;
- this.total = 0;
- this.current = index;
- this.status = 'loadmore';
- this.tableData = [];
- this.getEquipcontroldata();
- },
- // 获取要素实时数据
- async getElmentInfo() {
- uni.showLoading({
- title: '加载中'
- });
- let res = await this.$myRequest({
- url: "/api/api_gateway?method=xphsp.views.device_elements",
- data: {
- device_id: this.device_id,
- },
- })
- uni.hideLoading();
- var conf = res.conf.eleName.split('/');
- var dataList = [res.data.device_data];
- if (dataList.length == 0) return
- this.ElementList = [];
- conf.forEach((item, index) => {
- let obj = {}
- if (item == '-') return
- obj.name = item;
- let valList = dataList[0][`e${index + 1}`].split('#');
- obj.value = valList[0];
- obj.unit = valList[1];
- obj.time = dataList[0].uptime;
- this.ElementList.push(obj)
- })
- // console.log(this.ElementList)
- },
- // 当前配置的元素列表
- async getPickList() {
- // e_type类型对应
- // 1:'控制柜',
- // 2:'灌溉泵',
- // 3:'搅拌机',
- // 4:'注肥泵',
- // 5:'阀控器',
- // 6:'施肥桶'
- let res = await this.$myRequest({
- url: "/api/api_gateway?method=xphsp.views.sf_valve_location_list",
- data: {
- sf_device_id: this.device_id,
- },
- });
- let pickList = [];
- let pickBtnList = []; // 肥料开关
- let pickBanList = []; // 肥料搅拌机开关
- let faList = []; // 管道阀开关
- res.forEach((pick, index) => {
- this.facilityvalve.forEach(item => {
- if (pick.e_key == item.type) {
- // 获取当前灌溉泵位置
- let pickObj = Object.assign(pick,item);
- if(pick.e_type == 2) {
- this.mainBengIndex = pickList.length;
- this.mainBengItem = pickObj;
- this.mainBeng = pickObj.e_status;
- this.mainBengEKey = pickObj.e_key;
- }
- // 获取当前施肥泵位置
- if(pick.e_type == 4) {
- this.feiBengIndex = pickList.length;
- this.feiBengItem = pickObj;
- this.feiBeng = pickObj.e_status;
- this.feiBengEKey = pickObj.e_key;
- }
- // 获取肥料开关列表
- if (pick.e_type == 6) {
- pickBtnList.push(pickObj)
- }
- // 获取搅拌机开关列表
- if (pick.e_type == 3) {
- pickBanList.push(pickObj)
- }
- // 获取管道阀开关列表
- if (pick.e_type == 1 || pick.e_type == 5) {
- faList.push(pickObj)
- }
- pickList.push(pickObj)
- }
- })
- })
- // 把肥料和搅拌机位置对应起来(根据创建时间)
- let resultBan = [];
- pickBtnList.forEach(fei => {
- pickBanList.forEach(ban => {
- if (fei.create_time == ban.create_time) {
- resultBan.push(ban)
- }
- })
- })
- this.pickBtnList = pickBtnList;
- this.resultBan = resultBan;
- this.faList = faList;
- console.log(pickBtnList, pickBanList, resultBan, faList)
- },
- // 元素状态
- async getEquipstatus() {
- uni.showLoading({
- title: '加载中'
- });
- this.facilityvalve = [];
- let res = await this.$myRequest({
- url: "/api/api_gateway?method=xphsp.views.device_info",
- data: {
- device_id: this.device_id,
- },
- })
- uni.hideLoading();
- var conf = res.conf.relayName;
- var dataobj = res.device_status;
- var relayNum = res.conf.relayNum;
- var arr = [];
- function numberToArray(number) {
- // 将数字转换为字符串
- let numString = number.toString();
- // 创建一个空数组,用于存储结果
- let result = [];
- // 遍历字符串的每个字符,并将其转换为对应的数字
- for (let i = 0; i < numString.length; i++) {
- result.push(parseInt(numString.charAt(i)));
- }
- return result;
- }
- for (var i = 0; i < dataobj.length; i++) {
- // if (offobj[i].indexOf("j") + 1) {
- arr.push(offobj[i]);
- // }
- }
- conf = conf.split("/");
- relayNum = relayNum.split("/");
- var arr1 = [];
- var reg = /\d/;
- let totalP = Math.ceil((conf.length) / 32); //总圈数
- for (var i = 0; i < conf.length; i++) {
- var obj = {};
- obj.name = conf[i];
- // if (reg.test(conf[i])) {
- // obj.name2 = conf[i].slice(0, conf[i].length - 1);
- // } else {
- // obj.name2 = conf[i];
- // }
- obj.name2 = this.typename[relayNum[i]];
- obj.number = i;
- obj.type = `j${i + 1}`;
- obj.disabled = false;
- // "state": 1 继电器打开 ;"state": 0 继电器关闭
- // 处理开关值
- // J开头表示状态,总共只有32长度,超过32则从头赋值 位数多一位
- // 例:1和33是都在J1里面,返回值是一个二进制数 倒数第一位表示第一个 第二位表示33状态 以此类推
- // 根据总长度 为超过32的j赋值
- // 当前是循环的第几轮
- let baseP = Math.ceil((i + 1) / 32);
- if (i > 31) {
- dataobj[`j${i + 1}`] = dataobj[
- `j${(i + 1) % 32 == 0 ? 32 : (i + 1) % 32}`]; // 当前脚标/32取余 当恰好整除的时候 取32
- }
- dataobj[`j${i + 1}`] = dataobj[`j${i + 1}`].slice(-totalP); // 截取当前圈数的最后几位数字
- let baseOff = numberToArray(dataobj[`j${i + 1}`]); // 把当前值根据位数 转换为数组
- obj.off = baseOff[baseP - 1] == '0' ? false : true; // 根据当前圈数,取对应的数组的值
- arr1.push(obj);
- }
- for (var i = 0; i < arr1.length; i++) {
- if (arr1[i].name != "-") {
- this.facilityvalve.push(arr1[i]);
- }
- }
- let feiNum = 0; // 记录废料桶占据通道个数,两个通道为一个肥料桶
- this.buttonList = [];
- this.facilityvalve.forEach((item, index) => {
- if (this.colomRoundList.indexOf(item.type) > -1) {
- feiNum++;
- this.buttonList.push(item);
- }
- })
- this.feiNum = feiNum;
- this.getPickList();
- console.log(this.facilityvalve)
- },
- async getEquipcontrol(num, state, double_order, item) {
- // console.log({
- // device_id: item.cc_device_id == '' ? this.device_id : item.cc_device_id,
- // relayNum: num,
- // relayState: state,
- // double_order
- // });
- //设备控制
- uni.showLoading({
- title: '正在下发指令'
- });
- let res = await this.$myRequest({
- url: "/api/api_gateway?method=xphsp.views.control_order",
- data: {
- device_id: item.cc_device_id == '' ? this.device_id : item.cc_device_id,
- relayNum: num,
- relayState: state,
- double_order
- },
- })
- uni.hideLoading();
- if (res.msg_code == 200) {
- uni.showToast({
- title: '指令下发成功',
- duration: 2000,
- icon: 'none'
- });
- } else {
- uni.showToast({
- title: res.msg,
- duration: 2000,
- icon: 'none'
- })
- setTimeout(() => {
- this.getEquipstatus()
- }, 2000)
- }
- },
- // sf_control_data
- // 操作记录日期
- changeConsoleDate(e) {
- this.consoleTime = e;
- this.tableData = [];
- this.page = 1;
- this.getEquipcontroldata()
- },
- clearContime() {
- this.consoleTime = {};
- this.tableData = [];
- this.page = 1;
- this.getEquipcontroldata()
- },
- //操作记录
- async getEquipcontroldata() {
- uni.showLoading({
- title: '加载中'
- });
- const {
- consoleTime
- } = this;
- let begin = consoleTime.startDate ? new Date(consoleTime.startDate).getTime() / 1000 : '';
- let end = consoleTime.endDate ? new Date(consoleTime.endDate).getTime() / 1000 : '';
- //操作记录
- let res = await this.$myRequest({
- method: "POST",
- url: "/api/api_gateway?method=xphsp.views.control_log",
- data: {
- device_id: this.device_id,
- page_num: this.page,
- page_size: 15,
- start: begin,
- end: end,
- sys_control: this.current - 1
- },
- })
- uni.hideLoading();
- // this.tableData = [];
- var record = res.result;
- this.tableData = [...this.tableData, ...record];
- this.total = res.count;
- if (this.page * 15 > this.total) {
- this.status = 'nomore'
- } else {
- this.status = 'loadmore'
- }
- // console.log(this.tableData);
- },
- switchchange(e, state, item, index, isfeiButton) {
- // 是否是肥料开关,是的话 两个合并为一个
- item.disabled = true;
- if (isfeiButton) {
- // console.log(item, this.mainBengEKey, this.feiBengEKey)
- this.changeTimeStatus(item, index);
- // 当前是打开
- if (!item.e_status) {
- // 打开通道传1,关闭通道传0
- this.getEquipcontrol(state, 1, 1, item);
- // this.getEquipcontrol(state + 1, 0);
- } else {
- // this.getEquipcontrol(state + 1, 0);
- this.getEquipcontrol(state, 0, 1, item);
- }
- item.off = !item.off;
- item.e_status = !item.e_status;
- return
- }
- item.off = !item.off;
- item.e_status = !item.e_status;
- // if (item.type == this.mainBengEKey) {
- // // 判断注水泵是否打开
- // this.mainBeng = !item.e_status;
- // // console.log(this.mainBeng);
- // }
- // if (item.type == this.feiBengEKey) {
- // // 判断施肥阀是否打开
- // this.feiBeng = !item.e_status;
- // }
- // console.log(item, this.mainBengEKey, this.feiBengEKey)
- // if (this.colomRoundList.indexOf(item.type) > -1) {
- // let changeIndex = index;
- // if ((index + 1) % 2 == 0) {
- // // 偶数 往前取值
- // this.facilityvalve[index - 1].disabled = true;
- // changeIndex = index - 1;
- // } else if ((index + 1) % 2 == 1) {
- // // 基数 往后取值
- // this.facilityvalve[index + 1].disabled = true;
- // changeIndex = index + 1;
- // }
- // item.disabled = true;
- // this.changeTimeStatus(item, changeIndex);
- // this.getEquipcontrol(changeIndex, Number(!e));
- // } else {
- // }
- item.disabled = true;
- this.changeTimeStatus(item, index);
- //console.log(Number(e), state);
- this.getEquipcontrol(state, Number(e), undefined, item);
- },
- currentchange(e) {
- //页码
- if (this.type == 0) {
- this.pageDialog = e;
- } else {
- this.page = e;
- }
- this.getEquipcontroldata(this.type);
- },
- },
- onReachBottom() {
- if (this.current != 0 && this.status == 'loadmore') {
- this.page++;
- this.getEquipcontroldata()
- }
- },
- onLoad(option) {
- this.$forceUpdate()
- let deviceItem = JSON.parse(option.shebei)
- this.device_id = deviceItem.device_id;
- this.getEquipstatus();
- this.getElmentInfo();
- this.getEquipcontroldata();
- // this.getPickList();
- }
- }
- </script>
- <style scoped lang="less">
- .circleAnm {
- animation: ancirle 1s linear infinite;
- }
- // 旋转
- @keyframes ancirle {
- 0% {
- transform: rotate(360deg);
- }
- 100% {
- transform: rotate(0);
- }
- }
- .box {
- position: relative;
- width: 100%;
- min-height: 100vh;
- overflow: auto;
- padding-top: 40px;
- }
- .bigBox {
- width: 100%;
- padding-top: 40px;
- }
- .bigOpen {
- height: 100vh;
- }
- /deep/ .u-flex {
- display: flex;
- justify-content: center;
- }
- .topInfo {
- background: #14A478;
- color: #fff;
- font-size: 28rpx;
- padding-bottom: 32rpx;
- box-sizing: border-box;
- border-bottom-left-radius: 16rpx;
- border-bottom-right-radius: 16rpx;
- /deep/ .u-col {
- box-sizing: border-box;
- margin-top: 32rpx;
- box-sizing: border-box;
- .item {
- text-align: center;
- view:first-child {
- font-size: 40rpx;
- }
- view:nth-child(2) {
- font-size: 24rpx;
- line-height: 40rpx;
- opacity: .72;
- }
- }
- }
- }
- .readmore {
- text-align: center;
- font-size: 26rpx;
- line-height: 40rpx;
- margin-top: 32rpx;
- color: #93FFDE;
- .u-icon {
- margin-left: 15rpx;
- }
- }
- .histimeBox {
- display: flex;
- align-items: center;
- justify-content: space-between;
- height: 56rpx;
- padding: 6rpx 24rpx;
- box-sizing: border-box;
- border-radius: 8rpx;
- margin-top: 54rpx;
- border: 2rpx solid var(--neutral-color-border-light, #E4EDEA);
- .u-icon {
- z-index: 10;
- }
- .time {
- width: 280rpx;
- color: #C1C1C1;
- }
- view {
- color: #333333;
- text-align: center;
- }
- }
- .consoleBox {
- position: relative;
- max-height: 75vh;
- padding-bottom: 80rpx;
- overflow: auto;
- .u-row {
- box-sizing: border-box;
- .u-col {
- box-sizing: border-box;
- }
- }
- .u-btn {
- position: absolute;
- bottom: 0;
- left: 0;
- right: 0;
- background: #14A478;
- }
- .swichBox {
- position: relative;
- padding: 32rpx;
- overflow: hidden;
- .preSwich {
- display: flex;
- align-items: center;
- justify-content: space-between;
- padding: 24rpx 18rpx;
- border-radius: 8rpx;
- background: #EFF2FA;
- margin-bottom: 32rpx;
- view {
- color: #333333;
- font-size: 28rpx;
- }
- }
- }
- }
- .hisBox {
- position: relative;
- width: 100vw;
- padding-bottom: 100rpx;
- box-sizing: border-box;
- overflow-y: scroll;
- .axiosBox {
- position: relative;
- padding: 48rpx 32rpx;
- .title {
- color: #333333;
- font-size: 28rpx;
- font-weight: 700;
- }
- .chartBox {
- position: relative;
- margin-top: 32rpx;
- height: 800rpx;
- overflow: hidden;
- #canvasColumnA {
- width: 100%;
- height: 800rpx;
- }
- }
- }
- .readmoreHIs {
- position: absolute;
- bottom: 60rpx;
- left: 50%;
- transform: translate(-50%);
- color: #14A478;
- z-index: 5;
- }
- }
- .devicePhoto {
- padding: 32rpx;
- .titleBox {
- display: flex;
- align-items: center;
- justify-content: space-between;
- .btn {
- padding: 10rpx 14rpx;
- border-radius: 8rpx;
- background: #14A478;
- color: #fff;
- font-size: 28rpx;
- }
- }
- .main {
- position: relative;
- width: 678rpx;
- height: 612rpx;
- margin-top: 10px;
- .mainContent {
- position: absolute;
- left: 50%;
- transform: translateX(-50%);
- width: 678rpx;
- top: 10rpx;
- height: 602rpx;
- z-index: 1;
- }
- .sourceBox {
- position: absolute;
- left: 20rpx;
- z-index: 2;
- display: flex;
- align-items: center;
- justify-content: center;
- width: 112rpx;
- height: 112rpx;
- background: #E3FDFF;
- border-radius: 112rpx;
- color: #fff;
- view {
- width: 85rpx;
- height: 85rpx;
- background: #1890FF;
- border-radius: 85rpx;
- text-align: center;
- line-height: 85rpx;
- font-size: 28rpx;
- }
- }
- .colList {
- position: absolute;
- z-index: 2;
- top: 44rpx;
- left: 154rpx;
- width: 528rpx;
- display: flex;
- justify-content: center;
- overflow: hidden;
- .preClo {
- position: relative;
- float: left;
- width: 88rpx;
- // margin-left: 40rpx;
- view {
- text-align: center;
- color: #333333;
- font-size: 20rpx;
- margin-bottom: 20rpx;
- }
- .btnName{
- width: 100%;
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
- }
- image {
- width: 88rpx;
- height: 272rpx;
- }
- .shanBox {
- position: absolute;
- width: 64rpx;
- height: 64rpx;
- top: 116rpx;
- left: 50%;
- transform: translateX(-50%);
- z-index: 2;
- image {
- width: 64rpx;
- height: 64rpx;
- }
- }
- .jiaoBtn {
- position: absolute;
- width: 64rpx;
- height: 32rpx;
- top: 72rpx;
- left: 50%;
- transform: translateX(-50%);
- z-index: 2;
- /deep/ .u-switch__node {
- width: 28rpx !important;
- height: 28rpx !important;
- top: 2rpx !important;
- }
- /deep/ .u-switch__loading {
- height: 20rpx !important;
- }
- /deep/ .u-switch {
- width: 64rpx;
- height: 32rpx;
- }
- /deep/ .u-switch--on .u-switch__node {
- transform: translateX(36rpx) !important;
- }
- }
- .btnBox {
- position: absolute;
- width: 66rpx;
- height: 72rpx;
- bottom: 40rpx;
- left: 22rpx;
- z-index: 2;
- image {
- width: 66rpx;
- height: 72rpx;
- }
- }
- }
- }
- .benList {
- position: absolute;
- width: 678rpx;
- left: 50%;
- transform: translateX(-50%);
- top: 610rpx;
- .preBen {
- float: left;
- text-align: center;
- width: 20%;
- .daoguan {
- width: 20rpx;
- height: 40rpx;
- }
- .info {
- color: #333333;
- font-size: 12px;
- font-weight: 400;
- }
- .status {
- width: 76rpx;
- height: 100rpx;
- margin-top: 10rpx;
- }
- }
- }
- .lineExit {}
- .exit {
- position: absolute;
- width: 22rpx;
- height: 20rpx;
- top: 360rpx;
- right: 251rpx;
- z-index: 2;
- image {
- width: 22rpx;
- height: 20rpx;
- }
- }
- .warterIn {
- position: absolute;
- width: 66rpx;
- height: 72rpx;
- top: 190rpx;
- left: 52rpx;
- z-index: 3;
- image {
- width: 66rpx;
- height: 72rpx;
- }
- }
- .warterLight {
- position: absolute;
- width: 72rpx;
- height: 48rpx;
- top: 506rpx;
- left: 110rpx;
- z-index: 3;
- image {
- width: 72rpx;
- height: 48rpx;
- }
- }
- .feiLight {
- position: absolute;
- width: 72rpx;
- height: 66rpx;
- top: 424rpx;
- right: 140rpx;
- z-index: 3;
- image {
- width: 72rpx;
- height: 66rpx;
- }
- }
- .kongBox {
- position: absolute;
- width: 84rpx;
- height: 108rpx;
- top: 390rpx;
- right: 228rpx;
- z-index: 3;
- image {
- width: 84rpx;
- height: 108rpx;
- }
- }
- .fengBox {
- position: absolute;
- right: 12rpx;
- top: 270rpx;
- width: 55rpx;
- height: 44rpx;
- z-index: 2;
- .relativeBox {
- position: relative;
- width: 100%;
- height: 100%;
- image:nth-child(1) {
- width: 16rpx;
- height: 32rpx;
- }
- image:nth-child(2) {
- position: absolute;
- right: 0;
- top: -6rpx;
- width: 44rpx;
- height: 44rpx;
- }
- }
- }
- }
- }
- .consoleList {
- padding: 0 32rpx;
- .histimeBox {
- margin: 32rpx 0;
- }
- .tableTitle {
- background: #E8F3F0;
- color: #333;
- font-weight: 600;
- }
- .tableList {
- font-size: 28rpx;
- height: 78rpx;
- color: #666666;
- display: flex;
- justify-content: space-between;
- align-items: center;
- border-bottom: 2rpx solid var(--neutral-color-border-base, #DCE6E3);
- view {
- text-align: center;
- }
- .success {
- color: #14A478;
- }
- .error {
- color: #FF5951;
- }
- view:nth-child(1) {
- width: 120rpx;
- text-align: left;
- }
- view:nth-child(2) {
- width: 280rpx;
- }
- view:nth-child(3) {
- width: 280rpx;
- }
- }
- }
- </style>
|