equipmentStatusList.vue 37 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250
  1. <!-- 机器状态页面 -->
  2. <template>
  3. <view v-if="merchantList.length>1">
  4. <uni-collapse :accordion="true">
  5. <view class="titleFlag">
  6. <image class="img" src="../../static/img/red.png"></image>
  7. <font class="wenziT">红色代表机器报警</font>
  8. <image class="img" src="../../static/img/green.png"></image>
  9. <font class="wenziT">绿色代表机器正常</font>
  10. </view>
  11. <view class="titlelist" v-for="(merchant,index) in merchantList" :key="merchant.id">
  12. <uni-collapse-item :title="getMerchantTitle(merchant)" :open="index===0">
  13. <view style="padding: 20upx;background-color: aliceblue;">
  14. <view v-if="merchant.equipmentList.length==0" style="text-align: center;">暂无数据</view>
  15. <view v-if="merchant.equipmentList.length>0">
  16. <uni-collapse :show-animation="true">
  17. <view style="position: relative;" v-for="equipment in merchant.equipmentList"
  18. :key="equipment.id">
  19. <span class="status-css"
  20. :class="equipment.hasTodayAlarm===true?statusError : statusNormal"></span>
  21. <uni-collapse-item :title="getEquipmentTitle(equipment)">
  22. <view style="padding: 20upx;background-color: antiquewhite;">
  23. <view class="swithBox" v-if="equipment.isSleep">
  24. <view class="swichFont">睡眠状态:机器已睡眠</view>
  25. <view class="switch">
  26. <switch style="transform:scale(0.65)" checked
  27. @change="change(equipment.id,0)" />
  28. </view>
  29. </view>
  30. <view class="swithBox" v-else>
  31. <view class="swichFont">睡眠状态:未睡眠</view>
  32. <view class="switch">
  33. <switch style="transform:scale(0.65)" :checked="sleepChecked"
  34. @change="change(equipment.id,1)" />
  35. </view>
  36. </view>
  37. <view class="line1"></view>
  38. <view class="swithBox" v-if="equipment.eqeStatus==0">
  39. <view class="swichFont">关机:已关机</view>
  40. <view class="switch">
  41. <switch style="transform:scale(0.65)" checked
  42. @change="OnOff(equipment.id,1)" />
  43. </view>
  44. </view>
  45. <view class="swithBox" v-else>
  46. <view class="swichFont">关机:未关机</view>
  47. <view class="switch">
  48. <switch style="transform:scale(0.65)" :checked="onffChecked"
  49. @change="OnOff(equipment.id,0)" />
  50. </view>
  51. </view>
  52. <view class="line1"></view>
  53. <view><span>机器唯一码:</span><span>{{equipment.clientId}}</span></view>
  54. <view>
  55. <span>所在地:</span><span>{{equipment.fullName?equipment.fullName:''}}</span>
  56. </view>
  57. <view>
  58. <span>炉头温度:</span><span>{{equipment.furnaceTm?equipment.furnaceTm:''}}</span>
  59. </view>
  60. <view>
  61. <span>柜内湿度:</span><span>{{equipment.cabinetHd?equipment.cabinetHd:''}}</span>
  62. </view>
  63. <view>
  64. <span>柜内温度:</span><span>{{equipment.cabinetTm?equipment.cabinetTm:''}}</span>
  65. </view>
  66. <view v-if="equipment.hasTodayAlarm">
  67. <view><span>报警内容:</span></view>
  68. <view v-for="(alarm,index) in equipment.alarmList" :key="index">
  69. <view><span
  70. class="baojing">{{alarm.occurrenceTime?alarm.occurrenceTime:''}}
  71. {{alarm.alarmContent}}
  72. <button v-if="alarm.isEliminate==1" style="color:#BEBEBE;"
  73. @click="eliminate(alarm.id)" class="eliminateButton">
  74. <p class="p">已消除</p>
  75. </button>
  76. <button v-if="alarm.isEliminate!=1" type="primary"
  77. @click="eliminate(alarm.id)" class="eliminateButton">
  78. <p class="p">消除</p>
  79. </button>
  80. </span></view>
  81. </view>
  82. </view>
  83. <view v-else>
  84. <view><span>报警内容:</span><span>{{equipment.occurrenceTime?equipment.occurrenceTime:''}}
  85. {{equipment.alarmContent}}</span></view>
  86. </view>
  87. </view>
  88. </uni-collapse-item>
  89. </view>
  90. </uni-collapse>
  91. </view>
  92. </view>
  93. </uni-collapse-item>
  94. </view>
  95. </uni-collapse>
  96. </view>
  97. <view v-else>
  98. <uni-collapse :show-animation="true">
  99. <view class="titleFlag">
  100. <image class="img" src="../../static/img/red.png"></image>
  101. <font class="wenziT">{{$t('equipmentStatusList.red')}}</font>
  102. <image class="img" src="../../static/img/green.png"></image>
  103. <font class="wenziT">{{$t('equipmentStatusList.green')}}</font>
  104. </view>
  105. <view class="search">
  106. <view class="search-title">
  107. <picker @change="changeSearch" :value="index" :range="searchList">
  108. <view class="uni-input">{{searchList[index]}}</view>
  109. </picker>
  110. <!-- {{$t('equipmentStatusList.equipmentClientID')}} -->
  111. </view>
  112. <view class="search-input">
  113. <input v-if="searchList[index] === $t('equipmentStatusList.equipmentClientID')" type="text" :placeholder="$t('equipmentStatusList.devicePlaceholder')" v-model="searchClientId" />
  114. <input v-else type="text" :placeholder="$t('equipmentStatusList.deviceNamePlaceholder')" v-model="searchDeviceName" />
  115. </view>
  116. <view class="search-button">
  117. <button type="primary" size="mini" class="" @click="search()">
  118. <p class="">{{$t('equipmentStatusList.search')}}</P>
  119. </button>
  120. </view>
  121. </view>
  122. <view class="line"></view>
  123. <view class="titlelist" style="position: relative;" v-for="(equipment, index) in equipmentList"
  124. :key="equipment.id">
  125. <span class="status-css" :class="equipment.hasTodayAlarm===true?statusError : statusNormal"></span>
  126. <uni-collapse-item :title="getEquipmentTitle(equipment)">
  127. <!-- 睡眠 -->
  128. <view style="padding: 20upx;background-color: antiquewhite;">
  129. <view class="swithBox" v-if="equipment.isSleep">
  130. <view class="swichFont">{{$t('equipmentStatusList.sleep')}}</view>
  131. <view class="switch">
  132. <switch style="transform:scale(0.65)" checked @change="change(equipment.id,0,index)" />
  133. </view>
  134. </view>
  135. <view class="swithBox" v-else>
  136. <view class="swichFont">{{$t('equipmentStatusList.unsleep')}}</view>
  137. <view class="switch">
  138. <switch style="transform:scale(0.65)" :checked="sleepChecked"
  139. @change="change(equipment.id,1,index)" />
  140. </view>
  141. </view>
  142. <view class="line1"></view>
  143. <view class="swithBox" v-if="equipment.isSleep">
  144. <view class="swichFont2">{{$t('equipmentStatusList.sleepDesc')}}:</view>
  145. <input v-if="descShow" class="swichFont3" :value=equipment.sleepDesc @input="getValue"
  146. style="background: #fff" />
  147. <span v-else class="swichFont4">{{equipment.sleepDesc==null?$t('equipmentStatusList.confirm'):equipment.sleepDesc}}</span>
  148. <view v-if="editBtn" class="switch3">
  149. <button type="primary" @click="toggleReadOnly" class="button">
  150. <p class="p">{{$t('equipmentStatusList.edit')}}</p>
  151. </button>
  152. </view>
  153. <view v-else class="switch2">
  154. <button type="primary" @click="confirmDesc(equipment.sleepDesc,equipment.id)" class="button">
  155. <p class="p">{{$t('equipmentStatusList.confirm')}}</p>
  156. </button>
  157. <button style="color:#BEBEBE;" @click="cancelDesc" class="button">
  158. <p class="p">{{$t('equipmentStatusList.cancel')}}</p>
  159. </button>
  160. </view>
  161. </view>
  162. <view v-if="equipment.isSleep" class="line1"></view>
  163. <!-- 一键重启 -->
  164. <view class="opendoor"><span>{{$t('equipmentStatusList.reboot')}}:</span>
  165. <view class="">
  166. <button type="primary" @click="reboot(equipment.id)" class="button">
  167. <p class="p">{{$t('equipmentStatusList.reset')}}</p>
  168. </button>
  169. </view>
  170. </view>
  171. <view class="line1"></view>
  172. <!-- 关机 -->
  173. <view class="" v-if="globalUser.open==0">
  174. <!-- 已关机 -->
  175. <view class="swithBox" v-if="equipment.eqeStatus==0">
  176. <view class="swichFont1">{{$t('equipmentStatusList.off')}}</view>
  177. <view class="switch2">
  178. <!-- <switch style="transform:scale(0.65)" checked @change="OnOff(equipment.id,1)" /> -->
  179. <button style="color:#BEBEBE;" @click="OnOff(equipment.id,1)" class="button">
  180. <p class="p">{{$t('equipmentStatusList.kaiqi')}}</p>
  181. </button>
  182. <button type="primary" @click="OnOff(equipment.id,0)" class="button">
  183. <p class="p">{{$t('equipmentStatusList.guanbi')}}</p>
  184. </button>
  185. </view>
  186. </view>
  187. <!-- 已开机 -->
  188. <view class="swithBox" v-else>
  189. <view class="swichFont1">{{$t('equipmentStatusList.on')}}</view>
  190. <view class="switch2">
  191. <!-- <switch style="transform:scale(0.65)" :checked="onffChecked" @change="OnOff(equipment.id,0)" /> -->
  192. <button type="primary" @click="OnOff(equipment.id,1)" class="button">
  193. <p class="p">{{$t('equipmentStatusList.kaiqi')}}</p>
  194. </button>
  195. <button style="color:#BEBEBE;" @click="OnOff(equipment.id,0)" class="button">
  196. <p class="p">{{$t('equipmentStatusList.guanbi')}}</p>
  197. </button>
  198. </view>
  199. </view>
  200. </view>
  201. <view class="line1"></view>
  202. <!-- 远程开门 -->
  203. <!-- 类型,0:外门,1:内门,状态:0:关闭,1:开启 -->
  204. <!-- 外门 -->
  205. <view class="" v-if="equipment.equimentType=='MG320'||equipment.equimentType=='MG330'">
  206. <view class="opendoor"><span>{{$t('equipmentStatusList.outDoor')}}:{{equipment.outDoor==1?$t('equipmentStatusList.openStatus'):$t('equipmentStatusList.closeStatus')}}</span>
  207. <view class="switch1">
  208. <button type="primary" @click="updateEquipment(equipment.id,0,1)" class="button">
  209. <p class="p">{{$t('equipmentStatusList.open')}}</p>
  210. </button>
  211. <button type="primary" @click="updateEquipment(equipment.id,0,0)" class="button">
  212. <p class="p">{{$t('equipmentStatusList.close')}}</p>
  213. </button>
  214. </view>
  215. </view>
  216. <view class="line1"></view>
  217. <!-- 内门 -->
  218. <view class="opendoor"><span>{{$t('equipmentStatusList.inDoor')}}:{{equipment.inDoor==1?$t('equipmentStatusList.openStatus'):$t('equipmentStatusList.closeStatus')}}</span>
  219. <view class="switch1">
  220. <button type="primary" @click="updateEquipment(equipment.id,1,1)" class="button">
  221. <p class="p">{{$t('equipmentStatusList.open')}}</p>
  222. </button>
  223. <button type="primary" @click="updateEquipment(equipment.id,1,0)" class="button">
  224. <p class="p">{{$t('equipmentStatusList.close')}}</p>
  225. </button>
  226. </view>
  227. </view>
  228. <view class="line1"></view>
  229. </view>
  230. <!-- 一键重启 -->
  231. <!-- <view class="opendoor"><span>{{$t('equipmentStatusList.reboot')}}:</span>
  232. <view class="">
  233. <button type="primary" @click="reboot(equipment.id)" class="button">
  234. <p class="p">{{$t('equipmentStatusList.reset')}}</p>
  235. </button>
  236. </view>
  237. </view>
  238. <view class="line1"></view> -->
  239. <!-- 远程开门 -->
  240. <view class="opendoor"><span>{{$t('equipmentStatusList.door')}}:</span>
  241. <view class="">
  242. <button type="primary" @click="openDoor(equipment.id)" class="button">
  243. <p class="p">{{$t('equipmentStatusList.open')}}</p>
  244. </button>
  245. </view>
  246. </view>
  247. <!-- 查看定位 -->
  248. <view class="opendoor"><span>{{$t('equipmentStatusList.gps')}}:</span>
  249. <view class="">
  250. <button type="primary"
  251. @click="lookMap(equipment.id,equipment.longitude,equipment.latitude)"
  252. class="button">
  253. <p class="p">{{$t('equipmentStatusList.look')}}</p>
  254. </button>
  255. </view>
  256. </view>
  257. <view><span>{{$t('equipmentStatusList.equipmentNo')}}:</span><span>{{equipment.clientId}}</span>
  258. </view>
  259. <view>
  260. <span>{{$t('equipmentStatusList.area')}}:</span><span>{{equipment.fullName?equipment.fullName:''}}</span>
  261. </view>
  262. <view>
  263. <span>{{$t('equipmentStatusList.temperature')}}:</span><span>{{equipment.furnaceTm?equipment.furnaceTm:''}}</span>
  264. </view>
  265. <view>
  266. <span>{{$t('equipmentStatusList.humidity')}}:</span><span>{{equipment.cabinetHd?equipment.cabinetHd:''}}</span>
  267. </view>
  268. <view>
  269. <span>{{$t('equipmentStatusList.equipmentTemperature')}}:</span><span>{{equipment.cabinetTm?equipment.cabinetTm:''}}</span>
  270. </view>
  271. <view><span>plcVersion:</span><span>{{equipment.plcVersion}}</span></view>
  272. <!-- 物料 -->
  273. <view v-show="equipment.isMaterialUse==1">
  274. <span>{{$t('equipmentStatusList.whiteSugar')}}:</span><span>{{equipment.whiteSugar?equipment.whiteSugar:''}}%
  275. -- </span>
  276. <span>{{$t('equipmentStatusList.redSugar')}}:</span><span>{{equipment.redSugar?equipment.redSugar:''}}%
  277. -- </span>
  278. <span>{{$t('equipmentStatusList.yellowSugar')}}:</span><span>{{equipment.yellowSugar?equipment.yellowSugar:''}}%
  279. -- </span>
  280. <span>{{$t('equipmentStatusList.blueSugar')}}:</span><span>{{equipment.blueSugar?equipment.blueSugar:''}}%
  281. </span>
  282. </view>
  283. <view v-show="equipment.isMaterialUse==1">
  284. <span>{{$t('equipmentStatusList.stick')}}:</span><span>{{equipment.stick?equipment.stick:''}}%
  285. </span></view>
  286. <view v-show="equipment.isMaterialUse==1">
  287. <span>{{$t('equipmentStatusList.water')}}:</span><span>{{equipment.water?equipment.water:''}}%
  288. -- </span>
  289. <span>{{$t('equipmentStatusList.wasteWater')}}:</span><span>{{equipment.wasteWater?equipment.wasteWater:''}}%</span>
  290. </view>
  291. <view class="opendoor" v-show="equipment.isMaterialUse==1"><span>{{$t('equipmentStatusList.buliao')}}:</span>
  292. <view class="">
  293. <button type="primary" @click="buliao(equipment.id)" class="button">
  294. <p class="p">{{$t('equipmentStatusList.buliaoT')}}</p>
  295. </button>
  296. </view>
  297. </view>
  298. <view>
  299. <span>{{$t('equipmentStatusList.refreshTime')}}:</span><span>{{equipment.lastUpdateTime}}</span>
  300. </view>
  301. <view>
  302. <span>{{$t('equipmentStatusList.volume')}}:</span><span>{{equipment.volume?equipment.volume:''}}</span>
  303. </view>
  304. <view class="" v-if="equipment.hasTodayAlarm">
  305. <view><span>{{$t('equipmentStatusList.alarm')}}:</span></view>
  306. <view v-for="(alarm,index) in equipment.alarmList" :key="index">
  307. <view>
  308. <span class="baojing">{{alarm.occurrenceTime?alarm.occurrenceTime:''}}
  309. {{alarm.alarmContent}}
  310. <button v-if="alarm.isEliminate==1" style="color:#BEBEBE;"
  311. @click="eliminate(alarm.id)" class="eliminateButton">
  312. <p class="p">{{$t('equipmentStatusList.yixiaochu')}}</p>
  313. </button>
  314. <button v-if="alarm.isEliminate!=1" type="primary" @click="eliminate(alarm.id)"
  315. class="eliminateButton">
  316. <p class="p">{{$t('equipmentStatusList.xiaochu')}}</p>
  317. </button>
  318. </span>
  319. </view>
  320. </view>
  321. </view>
  322. <view class="" v-else>
  323. <view><span>{{$t('equipmentStatusList.alarm')}}:</span><span>{{equipment.occurrenceTime?equipment.occurrenceTime:''}}
  324. {{equipment.alarmContent}}</span></view>
  325. </view>
  326. </view>
  327. </uni-collapse-item>
  328. </view>
  329. <view v-if="btnShow" class="button-container">
  330. <button v-if="upBtn" class="left-button" :disabled="isLoading" @click="previousPage">{{$t('equipmentStatusList.previousPage')}}</button>
  331. <button v-if="nextBtn" class="right-button" :disabled="isLoading" @click="nextPage">{{$t('equipmentStatusList.nextPage')}}</button>
  332. </view>
  333. </uni-collapse>
  334. </view>
  335. </template>
  336. <script>
  337. import {
  338. mapState,
  339. mapActions,
  340. mapMutations
  341. } from 'vuex'
  342. import uniCollapse from '@/components/uni-collapse/uni-collapse.vue'
  343. import uniCollapseItem from '@/components/uni-collapse-item/uni-collapse-item.vue'
  344. import uniList from '@/components/uni-list/uni-list.vue'
  345. import uniListItem from '@/components/uni-list-item/uni-list-item.vue'
  346. import {
  347. dateUtils
  348. } from '@/common/util.js';
  349. export default {
  350. components: {
  351. uniCollapse,
  352. uniCollapseItem,
  353. uniList,
  354. uniListItem,
  355. },
  356. data() {
  357. return {
  358. globalUser: {},
  359. merchantList: [{
  360. equipmentList: []
  361. }],
  362. equipmentList: [],
  363. extraIcon: {
  364. color: '#4cd964',
  365. size: '22',
  366. type: 'spinner'
  367. },
  368. statusNormal: 'status-normal',
  369. statusError: 'status-error',
  370. sleepChecked: null,
  371. onffChecked: null,
  372. time: null,
  373. timeAll: {
  374. },
  375. input: 0,
  376. isReadOnly: true,
  377. editBtn:true,
  378. sleepDesc:false,
  379. descShow:false,
  380. btnShow:false, // 按钮显示
  381. upBtn:false, // 上一页按钮
  382. nextBtn:true, // 下一页按钮
  383. equipmentTotal:0, // 设备总数
  384. isLoading: false, //是否加载中
  385. searchList:[this.$t('equipmentStatusList.equipmentClientID'),this.$t('equipmentStatusList.deviceName')],
  386. index: 0,
  387. searchClientId: null,
  388. searchDeviceName: null,
  389. }
  390. },
  391. computed: {
  392. ...mapState(['loginUser']),
  393. },
  394. onPullDownRefresh() {
  395. this.index = 0;
  396. this.searchClientId = null;
  397. this.searchDeviceName = null;
  398. this.globalUser.deviceName = null;
  399. this.globalUser.clientId = null;
  400. this.globalUser.offset = 0;
  401. this.globalUser.limit = 20;
  402. this.getEquipmentListData();
  403. },
  404. onShow() {
  405. this.input = this.input + 1;
  406. this.globalUser = uni.getStorageSync("globalUser");
  407. this.globalUser.offset = 0;
  408. this.globalUser.limit = 20;
  409. this.searchClientId = null;
  410. this.searchDeviceName = null;
  411. this.globalUser.deviceName = null;
  412. this.globalUser.clientId = null;
  413. uni.setNavigationBarTitle({
  414. title: this.$t('equipmentStatusList.title')
  415. });
  416. uni.setTabBarItem({
  417. index: 3,
  418. text: this.$t('tabs.tab4')
  419. });
  420. var token = uni.getStorageSync("token");
  421. if (token.length > 1) {
  422. this.getEquipmentListData();
  423. this.upBtn = false;
  424. this.nextBtn = true;
  425. } else {
  426. uni.reLaunch({
  427. url: '../Login/Login',
  428. });
  429. }
  430. },
  431. methods: {
  432. ...mapActions('chart', ['getEquipmentListByUser']),
  433. getMerchantTitle(merchant) {
  434. return merchant.name ? merchant.name : merchant.username;
  435. },
  436. getEquipmentTitle(equipment) {
  437. return equipment.name ? equipment.name : equipment.clientId;
  438. },
  439. getEquipmentListData() {
  440. this.isLoading = true;
  441. this.getEquipmentListByUser(this.globalUser)
  442. .then(data => {
  443. this.merchantList = data;
  444. // this.equipmentList.push(...data[0].equipmentList);
  445. this.equipmentList = data[0].equipmentList;
  446. this.equipmentTotal = this.merchantList[0].equipmentTotal;
  447. if(this.equipmentTotal > this.globalUser.limit && this.globalUser.limit != null) {
  448. this.btnShow = true;
  449. } else {
  450. this.btnShow = false;
  451. }
  452. console.log(this.equipmentList);
  453. this.isLoading = false;
  454. var listName = data[0].equipmentList;
  455. var times = new Map;
  456. if (this.input == 1) {
  457. for (var i = 0; i < listName.length; i++) {
  458. var k = listName[i].id;
  459. times.set(k, null);
  460. }
  461. this.timeAll = times;
  462. }
  463. var listId = data[0].id;
  464. if (listId != null && listId != '1') {
  465. uni.setStorageSync("listName", listName);
  466. }
  467. uni.stopPullDownRefresh();
  468. }, _ => void uni.stopPullDownRefresh());
  469. },
  470. // 更改按钮显示状态
  471. changeBtnshow() {
  472. if(this.globalUser.offset != 0) {
  473. this.upBtn = true;
  474. } else {
  475. this.upBtn = false;
  476. }
  477. if(this.globalUser.offset + this.globalUser.limit < this.equipmentTotal) {
  478. this.nextBtn = true;
  479. } else {
  480. this.nextBtn = false;
  481. }
  482. },
  483. // 点击上一页
  484. previousPage() {
  485. this.globalUser.offset = this.globalUser.offset - this.globalUser.limit;
  486. this.getEquipmentListData();
  487. this.changeBtnshow();
  488. },
  489. // 点击下一页
  490. nextPage() {
  491. this.globalUser.offset = this.globalUser.offset + this.globalUser.limit;
  492. this.getEquipmentListData();
  493. this.changeBtnshow();
  494. },
  495. getValue: function(event) {
  496. // 绕过v-model 获取input输入框的值
  497. var value = event.target.value;
  498. this.sleepDesc = value;
  499. },
  500. // 点击更改
  501. toggleReadOnly() {
  502. this.descShow = true;
  503. this.editBtn = false;
  504. },
  505. // 取消更改
  506. cancelDesc() {
  507. this.descShow = false;
  508. this.editBtn = true;
  509. },
  510. // 选择搜索类型
  511. changeSearch: function(e) {
  512. // console.log('picker发送选择改变,携带值为', e.detail.value)
  513. this.index = e.detail.value
  514. this.searchClientId = null;
  515. this.searchDeviceName = null;
  516. this.globalUser.deviceName = null;
  517. this.globalUser.clientId = null;
  518. },
  519. // 点击搜索
  520. search() {
  521. if(this.index === 0) {
  522. if(this.searchClientId === null || this.searchClientId === '') {
  523. uni.showToast({
  524. title: '请输入设备编码后6位',
  525. icon: "none",
  526. duration: 2000
  527. });
  528. return;
  529. // this.globalUser.offset = 0;
  530. // this.globalUser.limit = 20;
  531. } else {
  532. this.globalUser.offset = null;
  533. this.globalUser.limit = null;
  534. console.log(this.globalUser)
  535. this.globalUser.clientId = this.searchClientId;
  536. this.getEquipmentListData();
  537. }
  538. } else {
  539. if(this.searchDeviceName === null || this.searchDeviceName === '') {
  540. uni.showToast({
  541. title: '请输入设备名称关键字',
  542. icon: "none",
  543. duration: 2000
  544. });
  545. return;
  546. } else {
  547. this.globalUser.offset = null;
  548. this.globalUser.limit = null;
  549. this.globalUser.deviceName = this.searchDeviceName;
  550. this.getEquipmentListData();
  551. console.log(this.globalUser)
  552. }
  553. }
  554. },
  555. // 更改睡眠描述
  556. confirmDesc(sleepDesc,id) {
  557. var that = this;
  558. uni.showModal({
  559. title: that.$t('equipmentStatusList.tip'),
  560. content: that.$t('equipmentStatusList.sleepDescTip'),
  561. success: function(res) {
  562. if (res.confirm) {
  563. var serverurl = that.serverurl;
  564. var sleepDescNew = that.sleepDesc;
  565. if(sleepDescNew == null||sleepDescNew == '') {
  566. if(sleepDesc!=null) {
  567. sleepDescNew = sleepDesc;
  568. } else {
  569. sleepDescNew = that.$t('equipmentStatusList.suspendBusiness');
  570. }
  571. }
  572. var token = uni.getStorageSync("token");
  573. uni.request({
  574. url: serverurl + '/TEquipmentDesc/updateSleepDesc',
  575. data: {
  576. "sleepDesc": sleepDescNew,
  577. "equipmentId": id
  578. },
  579. method: "POST",
  580. header: {
  581. 'token': token
  582. },
  583. success: (res) => {
  584. console.log(res.data.code);
  585. if (res.data.code) {
  586. uni.showModal({
  587. title: that.$t('equipmentStatusList.tip'),
  588. content: that.$t('equipmentStatusList.modifiedSuccessfully'),
  589. })
  590. that.descShow = false;
  591. that.editBtn = true;
  592. that.getEquipmentListData();
  593. } else {
  594. uni.showModal({
  595. title: that.$t('equipmentStatusList.tip'),
  596. content: that.$t('equipmentStatusList.modificationFailure'),
  597. })
  598. that.descShow = false;
  599. that.editBtn = true;
  600. that.getEquipmentListData();
  601. }
  602. }
  603. });
  604. }
  605. }
  606. })
  607. },
  608. //查看经纬度
  609. lookMap(id, longitude, latitude) {
  610. var item = {};
  611. item["id"] = id;
  612. item["longitude"] = longitude;
  613. item["latitude"] = latitude;
  614. var globalUser = uni.getStorageSync("globalUser");
  615. var ifForeign = globalUser.ifForeign;
  616. if (ifForeign == 0) {
  617. uni.navigateTo({
  618. url: '../../packageA/pages/equipmentStatus/map?item=' + encodeURIComponent(JSON.stringify(
  619. item))
  620. });
  621. }
  622. if (ifForeign == 1) {
  623. uni.navigateTo({
  624. url: '../../packageA/pages/equipmentStatus/GoogleMap?item=' + encodeURIComponent(JSON
  625. .stringify(item))
  626. });
  627. }
  628. },
  629. //一键重启
  630. reboot(id) {
  631. var that = this;
  632. uni.showModal({
  633. title: that.$t('equipmentStatusList.tip'),
  634. content: that.$t('equipmentStatusList.rebootTip'),
  635. success: function(res) {
  636. if (res.confirm) {
  637. var serverurl = that.serverurl;
  638. var code = "1";
  639. var equipmentId = id;
  640. var token = uni.getStorageSync("token");
  641. uni.request({
  642. url: serverurl + '/TEquipment/onOff',
  643. data: {
  644. "adminId": code,
  645. "equipmentId": equipmentId
  646. },
  647. method: "POST",
  648. header: {
  649. 'token': token
  650. },
  651. success: (res) => {
  652. var list = res.data.data;
  653. if (list == "SUCCESS") {
  654. uni.showModal({
  655. title: that.$t('equipmentStatusList.kaiji'),
  656. content: '发送成功',
  657. success: function(res) {}
  658. })
  659. } else {
  660. uni.showModal({
  661. title: that.$t('equipmentStatusList.error'),
  662. content: that.$t(
  663. 'equipmentStatusList.kaijierror'),
  664. success: function(res) {}
  665. })
  666. }
  667. }
  668. });
  669. }
  670. }
  671. })
  672. },
  673. OnOff(id, code) {
  674. var that = this;
  675. var ddd = this.timeAll.get(id);
  676. if (that.timeAll.get(id) != null) {
  677. var stamp = Date.parse(new Date());
  678. var t = (stamp - that.timeAll.get(id)) / 1000;
  679. if (t < 15) {
  680. var s = 15 - t;
  681. uni.showModal({
  682. title: that.$t('equipmentStatusList.onoff'),
  683. content: that.$t('equipmentStatusList.remainingtime') + s + "s",
  684. success: function(res) {
  685. that.getEquipmentListData();
  686. }
  687. });
  688. return;
  689. }
  690. }
  691. var code1 = code;
  692. if (code1 == 0) {
  693. uni.showModal({
  694. title: that.$t('equipmentStatusList.tip'),
  695. content: that.$t('equipmentStatusList.onoffTip'),
  696. success: function(res) {
  697. if (res.confirm) {
  698. var serverurl = that.serverurl;
  699. var code2 = code1;
  700. var equipmentId = id;
  701. var token = uni.getStorageSync("token");
  702. uni.request({
  703. url: serverurl + '/TEquipment/onOff',
  704. data: {
  705. "adminId": code2,
  706. "equipmentId": equipmentId
  707. },
  708. method: "POST",
  709. header: {
  710. 'token': token
  711. },
  712. success: (res) => {
  713. var list = res.data.data;
  714. that.input = 2;
  715. var timestamp = Date.parse(new Date());
  716. that.timeAll.set(id, timestamp);
  717. var oo = that.timeAll;
  718. that.getEquipmentListData();
  719. if (list == 'SUCCESS') {
  720. uni.showModal({
  721. title: that.$t(
  722. 'equipmentStatusList.guanji'),
  723. content: that.$t(
  724. 'equipmentStatusList.tishi'),
  725. success: function(res) {
  726. that.getEquipmentListData();
  727. setTimeout(function() {
  728. that.network(id);
  729. }, 7000);
  730. }
  731. })
  732. } else {
  733. uni.showModal({
  734. title: that.$t(
  735. 'equipmentStatusList.error'),
  736. content: that.$t(
  737. 'equipmentStatusList.guanjierror'),
  738. success: function(res) {
  739. that.onffChecked = true;
  740. that.getEquipmentListData();
  741. }
  742. })
  743. }
  744. }
  745. });
  746. } else if (res.cancel) {
  747. that.onffChecked = false;
  748. // that.getEquipmentListData();
  749. }
  750. }
  751. });
  752. } else {
  753. var serverurl = that.serverurl;
  754. var code = code;
  755. var equipmentId = id;
  756. var token = uni.getStorageSync("token");
  757. uni.request({
  758. url: serverurl + '/TEquipment/onOff',
  759. data: {
  760. "adminId": code,
  761. "equipmentId": equipmentId
  762. },
  763. method: "POST",
  764. header: {
  765. 'token': token
  766. },
  767. success: (res) => {
  768. that.input = 2;
  769. var list = res.data.data;
  770. that.getEquipmentListData();
  771. var timestamp = Date.parse(new Date());
  772. that.timeAll.set(id, timestamp);
  773. var oo = that.timeAll;
  774. if (list == "SUCCESS") {
  775. uni.showModal({
  776. title: that.$t('equipmentStatusList.kaiji'),
  777. content: that.$t('equipmentStatusList.tishi'),
  778. success: function(res) {
  779. that.getEquipmentListData();
  780. setTimeout(function() {
  781. that.network(id);
  782. }, 7000);
  783. }
  784. })
  785. } else {
  786. uni.showModal({
  787. title: that.$t('equipmentStatusList.error'),
  788. content: that.$t('equipmentStatusList.kaijierror'),
  789. success: function(res) {
  790. that.equipmentList = [];
  791. that.getEquipmentListData();
  792. }
  793. })
  794. }
  795. }
  796. });
  797. }
  798. },
  799. eliminate(id) {
  800. var token = uni.getStorageSync("token");
  801. uni.request({
  802. url: this.serverurl + '/TEquipment/eliminate',
  803. data: {
  804. "id": id
  805. },
  806. method: "POST",
  807. header: {
  808. 'token': token
  809. },
  810. success: (res) => {
  811. uni.showToast({
  812. title: "发送成功",
  813. icon: 'none',
  814. duration: 1000
  815. });
  816. this.getEquipmentListData();
  817. }
  818. });
  819. },
  820. network(id) {
  821. console.log("network");
  822. var token = uni.getStorageSync("token");
  823. var equipmentId = id;
  824. uni.request({
  825. url: this.serverurl + '/TEquipment/checkStatus',
  826. data: {
  827. "equipmentId": id
  828. },
  829. method: "POST",
  830. header: {
  831. 'token': token
  832. },
  833. success: (res) => {
  834. var data = res.data.data;
  835. if (data == 'fail') {
  836. uni.showToast({
  837. title: this.$t('equipmentStatusList.network'),
  838. icon: 'none',
  839. duration: 3000
  840. });
  841. this.getEquipmentListData();
  842. }
  843. }
  844. });
  845. },
  846. openDoor(id) {
  847. var token = uni.getStorageSync("token");
  848. uni.request({
  849. url: this.serverurl + '/TEquipment/openDoor',
  850. data: {
  851. "equipmentId": id
  852. },
  853. method: "POST",
  854. header: {
  855. 'token': token
  856. },
  857. success: (res) => {
  858. uni.showModal({
  859. title: this.$t('equipmentStatusList.open'),
  860. content: this.$t('equipmentStatusList.opensuccess'),
  861. success: function(res) {
  862. }
  863. })
  864. }
  865. });
  866. },
  867. // type(类型,0:外门,1:内门),
  868. // status(状态:0:关闭,1:开启)
  869. updateEquipment(id,type,status){
  870. var that = this;
  871. uni.showModal({
  872. title: that.$t('equipmentStatusList.tip'),
  873. content: that.$t('equipmentStatusList.updateTip'),
  874. success: function(res) {
  875. if (res.confirm) {
  876. var serverurl = that.serverurl;
  877. var token = uni.getStorageSync("token");
  878. uni.request({
  879. url: serverurl + '/TEquipment/updateEquipment?id='+id+'&type='+type+'&status='+status,
  880. method: "GET",
  881. header: {
  882. 'token': token
  883. },
  884. success: (res) => {
  885. var code = res.data.code;
  886. if (code) {
  887. uni.showModal({
  888. title: that.$t(
  889. 'equipmentStatusList.tip'),
  890. content: that.$t(
  891. 'equipmentStatusList.successReturn'),
  892. success: function(res) {
  893. // setTimeout(function() {
  894. // }, 7000);
  895. }
  896. })
  897. } else {
  898. uni.showModal({
  899. title: that.$t(
  900. 'equipmentStatusList.tip'),
  901. content: that.$t(
  902. 'equipmentStatusList.errorReturn'),
  903. success: function(res) {
  904. }
  905. })
  906. }
  907. }
  908. });
  909. } else if (res.cancel) {
  910. that.onffChecked = false;
  911. that.getEquipmentListData();
  912. }
  913. }
  914. });
  915. },
  916. buliao(id) {
  917. var that = this;
  918. var token = uni.getStorageSync("token");
  919. uni.showModal({
  920. title: this.$t('equipmentStatusList.tip'),
  921. content: this.$t('equipmentStatusList.wuliaoTip'),
  922. success: function(res) {
  923. uni.request({
  924. url: that.serverurl + '/TEquipment/buliao',
  925. data: {
  926. "equipmentId": id
  927. },
  928. method: "POST",
  929. header: {
  930. 'token': token
  931. },
  932. success: (res) => {
  933. uni.showModal({
  934. title: this.$t('equipmentStatusList.tip'),
  935. content: res.data.message,
  936. success: function(res) {
  937. that.getEquipmentListData();
  938. }
  939. })
  940. }
  941. })
  942. }
  943. })
  944. },
  945. change(id, code, index) {
  946. this.sleepChecked = true;
  947. var that = this;
  948. var code1 = code;
  949. // console.log(index);
  950. // console.log(code);
  951. if (code1 == 1) {
  952. // that.sleepChecked = true;
  953. uni.showModal({
  954. title: that.$t('equipmentStatusList.tip'),
  955. content: that.$t('equipmentStatusList.sleepTip'),
  956. success: function(res) {
  957. if (res.confirm) {
  958. var serverurl = that.serverurl;
  959. var code2 = code1;
  960. var equipmentId = id;
  961. var token = uni.getStorageSync("token");
  962. uni.request({
  963. url: serverurl + '/TEquipment/sleep',
  964. data: {
  965. "adminId": code2,
  966. "equipmentId": equipmentId
  967. },
  968. method: "POST",
  969. header: {
  970. 'token': token
  971. },
  972. success: (res) => {
  973. var list = res.data.data;
  974. that.equipmentList[index].isSleep = true;
  975. that.sleepChecked = null;
  976. that.getEquipmentListData();
  977. }
  978. });
  979. } else {
  980. that.equipmentList[index].isSleep = false;
  981. that.sleepChecked = false;
  982. that.getEquipmentListData();
  983. }
  984. }
  985. });
  986. } else {
  987. that.descShow = false;
  988. that.editBtn = true;
  989. var serverurl = that.serverurl;
  990. var code = code;
  991. var equipmentId = id;
  992. var token = uni.getStorageSync("token");
  993. uni.request({
  994. url: serverurl + '/TEquipment/sleep',
  995. data: {
  996. "adminId": code,
  997. "equipmentId": equipmentId
  998. },
  999. method: "POST",
  1000. header: {
  1001. 'token': token
  1002. },
  1003. success: (res) => {
  1004. var list = res.data.data;
  1005. that.equipmentList[index].isSleep = false;
  1006. that.sleepChecked = false;
  1007. that.getEquipmentListData();
  1008. }
  1009. });
  1010. }
  1011. },
  1012. }
  1013. }
  1014. </script>
  1015. <style>
  1016. .status-css {
  1017. position: absolute;
  1018. width: 30upx;
  1019. height: 30upx;
  1020. right: 86upx;
  1021. top: 30upx;
  1022. border-radius: 30upx;
  1023. color: "#596D83";
  1024. font-size: 12upx;
  1025. }
  1026. .status-error {
  1027. background-color: #dd524d
  1028. }
  1029. .status-normal {
  1030. background-color: #4cd964
  1031. }
  1032. .baojing {
  1033. display: flex;
  1034. flex-direction: row;
  1035. padding-left: 20upx;
  1036. }
  1037. .titleFlag {
  1038. height: 56upx;
  1039. background-color: #F8F8F8;
  1040. color: #8C959F;
  1041. font-size: 22upx;
  1042. display: flex;
  1043. flex-direction: row;
  1044. }
  1045. .opendoor {
  1046. /* #ifdef H5
  1047. /* #endif */
  1048. padding-top: 10upx;
  1049. padding-bottom: 10upx;
  1050. /* text-align: center; */
  1051. display: flex;
  1052. flex-direction: row;
  1053. }
  1054. .button {
  1055. /* #ifdef H5 */
  1056. text-align: center;
  1057. height: 50upx;
  1058. weight: 20upx;
  1059. /* #endif */
  1060. padding-left: 15upx;
  1061. /* padding-top: 2upx; */
  1062. }
  1063. .eliminateButton {
  1064. /* #ifdef H5 */
  1065. text-align: center;
  1066. height: 50upx;
  1067. weight: 20upx;
  1068. /* #endif */
  1069. padding-left: 15upx;
  1070. /* padding-top: 2upx; */
  1071. }
  1072. .p {
  1073. /* #ifdef H5 */
  1074. font-size: 28upx;
  1075. height: 50upx;
  1076. weight: 20upx;
  1077. transform: translateY(-14upx);
  1078. /* text-align: center; */
  1079. /* #endif */
  1080. /* padding-bottom: 50upx; */
  1081. text-align: center;
  1082. padding-left: 13upx;
  1083. }
  1084. .img {
  1085. padding-top: 20upx;
  1086. padding-left: 30upx;
  1087. width: 15upx;
  1088. height: 15upx;
  1089. }
  1090. .wenziT {
  1091. padding-top: 10upx;
  1092. padding-left: 10upx;
  1093. }
  1094. .titlelist {
  1095. color: #363D44;
  1096. font-size: 16upx;
  1097. font-family: "PingFang-SC-Medium";
  1098. }
  1099. .swithBox {
  1100. display: flex;
  1101. flex-direction: row;
  1102. padding-bottom: 15upx;
  1103. padding-top: 5upx;
  1104. }
  1105. .switch {
  1106. width: 100upx;
  1107. height: 22upx;
  1108. }
  1109. .switch1 {
  1110. display: flex;
  1111. /* flex-direction: row; */
  1112. width: 35%;
  1113. height: 42upx;
  1114. /* padding-top: 13upx; */
  1115. /* padding-left: 132px; */
  1116. margin-left: auto;
  1117. }
  1118. .switch2 {
  1119. display: flex;
  1120. flex-direction: row;
  1121. padding-top: 13upx;
  1122. width: 35%;
  1123. height: 42upx;
  1124. margin-left: auto;
  1125. }
  1126. .switch3 {
  1127. height: 42upx;
  1128. padding-top: 13upx;
  1129. margin-left: auto;
  1130. }
  1131. .swichFont {
  1132. width: 85%;
  1133. padding-top: 12upx;
  1134. }
  1135. .swichFont2{
  1136. width: auto;
  1137. padding-top: 12upx;
  1138. }
  1139. .swichFont3{
  1140. width: 40%;
  1141. margin-top: 8px;
  1142. font-size: 14px;
  1143. }
  1144. .swichFont4 {
  1145. width: auto;
  1146. padding-top: 12upx;
  1147. }
  1148. .swichFont1 {
  1149. width: 60%;
  1150. padding-top: 12upx;
  1151. }
  1152. .line1 {
  1153. width: 100%;
  1154. height: 3upx;
  1155. background: #000000;
  1156. }
  1157. .line {
  1158. width: 100%;
  1159. height: 3upx;
  1160. background: #c8c7cc;
  1161. }
  1162. .button-container {
  1163. display: flex;
  1164. }
  1165. .left-button,
  1166. .right-button {
  1167. flex: 1;
  1168. }
  1169. .search {
  1170. width: 100%;
  1171. padding-top: 10upx;
  1172. display: flex;
  1173. flex-direction: row;
  1174. justify-content: flex-start;
  1175. }
  1176. .search-title {
  1177. width: 25%;
  1178. /* margin: 0 10px; */
  1179. margin-right: 10px;
  1180. text-align: center;
  1181. font-family: "PingFang-SC-Bold";
  1182. /* box-shadow: 0upx 0upx 20upx #D3D3D3; */
  1183. border-radius: 20px;
  1184. /* padding: 2px; */
  1185. }
  1186. .search-input{
  1187. width: 48%;
  1188. height: 25px;
  1189. text-align: center;
  1190. margin-top: 5px;
  1191. font-size: 26upx;
  1192. font-family: "PingFang-SC-Bold";
  1193. box-shadow: 0upx 0upx 30upx #D3D3D3;
  1194. border-radius: 5upx;
  1195. }
  1196. .search-button{
  1197. width: 20%;
  1198. padding-left: 10px;
  1199. padding-bottom: 5px;
  1200. margin-top: 3px;
  1201. text-align: center;
  1202. height: 60upx;
  1203. text-align: left;
  1204. }
  1205. </style>