equipmentStatusList.vue 37 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262
  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.deviceName')" type="text" :placeholder="$t('equipmentStatusList.deviceNamePlaceholder')" v-model="searchDeviceName" />
  114. <input v-else type="text" :placeholder="$t('equipmentStatusList.devicePlaceholder')" v-model="searchClientId" />
  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:''}}°C</span>
  264. </view>
  265. <view>
  266. <span>{{$t('equipmentStatusList.humidity')}}:</span><span>{{equipment.cabinetHd?equipment.cabinetHd:''}}%RH</span>
  267. </view>
  268. <view>
  269. <span>{{$t('equipmentStatusList.equipmentTemperature')}}:</span><span>{{equipment.cabinetTm?equipment.cabinetTm:''}}°C</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.deviceName'),this.$t('equipmentStatusList.equipmentClientID')],
  386. index: 0,
  387. searchClientId: null,
  388. searchDeviceName: null,
  389. firstShow: true, // 添加一个标志变量
  390. }
  391. },
  392. computed: {
  393. ...mapState(['loginUser']),
  394. },
  395. onPullDownRefresh() {
  396. this.index = 0;
  397. this.searchClientId = null;
  398. this.searchDeviceName = null;
  399. this.globalUser.deviceName = null;
  400. this.globalUser.clientId = null;
  401. this.globalUser.offset = 0;
  402. this.globalUser.limit = 20;
  403. this.getEquipmentListData();
  404. },
  405. onShow() {
  406. if (this.firstShow) {
  407. this.input = this.input + 1;
  408. this.globalUser = uni.getStorageSync("globalUser");
  409. this.globalUser.offset = 0;
  410. this.globalUser.limit = 20;
  411. this.searchClientId = null;
  412. this.searchDeviceName = null;
  413. this.globalUser.deviceName = null;
  414. this.globalUser.clientId = null;
  415. uni.setNavigationBarTitle({
  416. title: this.$t('equipmentStatusList.title')
  417. });
  418. uni.setTabBarItem({
  419. index: 3,
  420. text: this.$t('tabs.tab4')
  421. });
  422. var token = uni.getStorageSync("token");
  423. if (token.length > 1) {
  424. this.getEquipmentListData();
  425. this.upBtn = false;
  426. this.nextBtn = true;
  427. } else {
  428. uni.reLaunch({
  429. url: '../Login/Login',
  430. });
  431. }
  432. this.firstShow = false;
  433. }
  434. },
  435. methods: {
  436. ...mapActions('chart', ['getEquipmentListByUser']),
  437. getMerchantTitle(merchant) {
  438. return merchant.name ? merchant.name : merchant.username;
  439. },
  440. getEquipmentTitle(equipment) {
  441. return equipment.name ? equipment.name : equipment.clientId;
  442. },
  443. getEquipmentListData() {
  444. if(this.globalUser.id == 1) {
  445. uni.showToast({
  446. icon: 'none',
  447. title:'暂时无法查看数据',
  448. });
  449. return;
  450. } else {
  451. this.isLoading = true;
  452. this.getEquipmentListByUser(this.globalUser)
  453. .then(data => {
  454. this.merchantList = data;
  455. // this.equipmentList.push(...data[0].equipmentList);
  456. this.equipmentList = data[0].equipmentList;
  457. this.equipmentTotal = this.merchantList[0].equipmentTotal;
  458. if(this.equipmentTotal > this.globalUser.limit && this.globalUser.limit != null) {
  459. this.btnShow = true;
  460. } else {
  461. this.btnShow = false;
  462. }
  463. console.log(this.equipmentList);
  464. this.isLoading = false;
  465. var listName = data[0].equipmentList;
  466. var times = new Map;
  467. if (this.input == 1) {
  468. for (var i = 0; i < listName.length; i++) {
  469. var k = listName[i].id;
  470. times.set(k, null);
  471. }
  472. this.timeAll = times;
  473. }
  474. var listId = data[0].id;
  475. if (listId != null && listId != '1') {
  476. uni.setStorageSync("listName", listName);
  477. }
  478. uni.stopPullDownRefresh();
  479. }, _ => void uni.stopPullDownRefresh());
  480. }
  481. },
  482. // 更改按钮显示状态
  483. changeBtnshow() {
  484. if(this.globalUser.offset != 0) {
  485. this.upBtn = true;
  486. } else {
  487. this.upBtn = false;
  488. }
  489. if(this.globalUser.offset + this.globalUser.limit < this.equipmentTotal) {
  490. this.nextBtn = true;
  491. } else {
  492. this.nextBtn = false;
  493. }
  494. },
  495. // 点击上一页
  496. previousPage() {
  497. this.globalUser.offset = this.globalUser.offset - this.globalUser.limit;
  498. this.getEquipmentListData();
  499. this.changeBtnshow();
  500. },
  501. // 点击下一页
  502. nextPage() {
  503. this.globalUser.offset = this.globalUser.offset + this.globalUser.limit;
  504. this.getEquipmentListData();
  505. this.changeBtnshow();
  506. },
  507. getValue: function(event) {
  508. // 绕过v-model 获取input输入框的值
  509. var value = event.target.value;
  510. this.sleepDesc = value;
  511. },
  512. // 点击更改
  513. toggleReadOnly() {
  514. this.descShow = true;
  515. this.editBtn = false;
  516. },
  517. // 取消更改
  518. cancelDesc() {
  519. this.descShow = false;
  520. this.editBtn = true;
  521. },
  522. // 选择搜索类型
  523. changeSearch: function(e) {
  524. // console.log('picker发送选择改变,携带值为', e.detail.value)
  525. this.index = e.detail.value
  526. this.searchClientId = null;
  527. this.searchDeviceName = null;
  528. this.globalUser.deviceName = null;
  529. this.globalUser.clientId = null;
  530. },
  531. // 点击搜索
  532. search() {
  533. if(this.index === 1) {
  534. if(this.searchClientId === null || this.searchClientId === '') {
  535. uni.showToast({
  536. title: this.$t('equipmentStatusList.devicePlaceholder'),
  537. icon: "none",
  538. duration: 2000
  539. });
  540. return;
  541. // this.globalUser.offset = 0;
  542. // this.globalUser.limit = 20;
  543. } else {
  544. this.globalUser.offset = null;
  545. this.globalUser.limit = null;
  546. console.log(this.globalUser)
  547. this.globalUser.clientId = this.searchClientId;
  548. this.getEquipmentListData();
  549. }
  550. } else {
  551. if(this.searchDeviceName === null || this.searchDeviceName === '') {
  552. uni.showToast({
  553. title: this.$t('equipmentStatusList.deviceNamePlaceholder'),
  554. icon: "none",
  555. duration: 2000
  556. });
  557. return;
  558. } else {
  559. this.globalUser.offset = null;
  560. this.globalUser.limit = null;
  561. this.globalUser.deviceName = this.searchDeviceName;
  562. this.getEquipmentListData();
  563. console.log(this.globalUser)
  564. }
  565. }
  566. },
  567. // 更改睡眠描述
  568. confirmDesc(sleepDesc,id) {
  569. var that = this;
  570. uni.showModal({
  571. title: that.$t('equipmentStatusList.tip'),
  572. content: that.$t('equipmentStatusList.sleepDescTip'),
  573. success: function(res) {
  574. if (res.confirm) {
  575. var serverurl = that.serverurl;
  576. var sleepDescNew = that.sleepDesc;
  577. if(sleepDescNew == null||sleepDescNew == '') {
  578. if(sleepDesc!=null) {
  579. sleepDescNew = sleepDesc;
  580. } else {
  581. sleepDescNew = that.$t('equipmentStatusList.suspendBusiness');
  582. }
  583. }
  584. var token = uni.getStorageSync("token");
  585. uni.request({
  586. url: serverurl + '/TEquipmentDesc/updateSleepDesc',
  587. data: {
  588. "sleepDesc": sleepDescNew,
  589. "equipmentId": id
  590. },
  591. method: "POST",
  592. header: {
  593. 'token': token
  594. },
  595. success: (res) => {
  596. console.log(res.data.code);
  597. if (res.data.code) {
  598. uni.showModal({
  599. title: that.$t('equipmentStatusList.tip'),
  600. content: that.$t('equipmentStatusList.modifiedSuccessfully'),
  601. })
  602. that.descShow = false;
  603. that.editBtn = true;
  604. that.getEquipmentListData();
  605. } else {
  606. uni.showModal({
  607. title: that.$t('equipmentStatusList.tip'),
  608. content: that.$t('equipmentStatusList.modificationFailure'),
  609. })
  610. that.descShow = false;
  611. that.editBtn = true;
  612. that.getEquipmentListData();
  613. }
  614. }
  615. });
  616. }
  617. }
  618. })
  619. },
  620. //查看经纬度
  621. lookMap(id, longitude, latitude) {
  622. var item = {};
  623. item["id"] = id;
  624. item["longitude"] = longitude;
  625. item["latitude"] = latitude;
  626. var globalUser = uni.getStorageSync("globalUser");
  627. var ifForeign = globalUser.ifForeign;
  628. if (ifForeign == 0) {
  629. uni.navigateTo({
  630. url: '../../packageA/pages/equipmentStatus/map?item=' + encodeURIComponent(JSON.stringify(
  631. item))
  632. });
  633. }
  634. if (ifForeign == 1) {
  635. uni.navigateTo({
  636. url: '../../packageA/pages/equipmentStatus/GoogleMap?item=' + encodeURIComponent(JSON
  637. .stringify(item))
  638. });
  639. }
  640. },
  641. //一键重启
  642. reboot(id) {
  643. var that = this;
  644. uni.showModal({
  645. title: that.$t('equipmentStatusList.tip'),
  646. content: that.$t('equipmentStatusList.rebootTip'),
  647. success: function(res) {
  648. if (res.confirm) {
  649. var serverurl = that.serverurl;
  650. var code = "1";
  651. var equipmentId = id;
  652. var token = uni.getStorageSync("token");
  653. uni.request({
  654. url: serverurl + '/TEquipment/onOff',
  655. data: {
  656. "adminId": code,
  657. "equipmentId": equipmentId
  658. },
  659. method: "POST",
  660. header: {
  661. 'token': token
  662. },
  663. success: (res) => {
  664. var list = res.data.data;
  665. if (list == "SUCCESS") {
  666. uni.showModal({
  667. title: that.$t('equipmentStatusList.kaiji'),
  668. content: that.$t('equipmentStatusList.successReturn'),
  669. success: function(res) {}
  670. })
  671. } else {
  672. uni.showModal({
  673. title: that.$t('equipmentStatusList.error'),
  674. content: that.$t(
  675. 'equipmentStatusList.kaijierror'),
  676. success: function(res) {}
  677. })
  678. }
  679. }
  680. });
  681. }
  682. }
  683. })
  684. },
  685. OnOff(id, code) {
  686. var that = this;
  687. var ddd = this.timeAll.get(id);
  688. if (that.timeAll.get(id) != null) {
  689. var stamp = Date.parse(new Date());
  690. var t = (stamp - that.timeAll.get(id)) / 1000;
  691. if (t < 15) {
  692. var s = 15 - t;
  693. uni.showModal({
  694. title: that.$t('equipmentStatusList.onoff'),
  695. content: that.$t('equipmentStatusList.remainingtime') + s + "s",
  696. success: function(res) {
  697. that.getEquipmentListData();
  698. }
  699. });
  700. return;
  701. }
  702. }
  703. var code1 = code;
  704. if (code1 == 0) {
  705. uni.showModal({
  706. title: that.$t('equipmentStatusList.tip'),
  707. content: that.$t('equipmentStatusList.onoffTip'),
  708. success: function(res) {
  709. if (res.confirm) {
  710. var serverurl = that.serverurl;
  711. var code2 = code1;
  712. var equipmentId = id;
  713. var token = uni.getStorageSync("token");
  714. uni.request({
  715. url: serverurl + '/TEquipment/onOff',
  716. data: {
  717. "adminId": code2,
  718. "equipmentId": equipmentId
  719. },
  720. method: "POST",
  721. header: {
  722. 'token': token
  723. },
  724. success: (res) => {
  725. var list = res.data.data;
  726. that.input = 2;
  727. var timestamp = Date.parse(new Date());
  728. that.timeAll.set(id, timestamp);
  729. var oo = that.timeAll;
  730. that.getEquipmentListData();
  731. if (list == 'SUCCESS') {
  732. uni.showModal({
  733. title: that.$t(
  734. 'equipmentStatusList.guanji'),
  735. content: that.$t(
  736. 'equipmentStatusList.tishi'),
  737. success: function(res) {
  738. that.getEquipmentListData();
  739. setTimeout(function() {
  740. that.network(id);
  741. }, 7000);
  742. }
  743. })
  744. } else {
  745. uni.showModal({
  746. title: that.$t(
  747. 'equipmentStatusList.error'),
  748. content: that.$t(
  749. 'equipmentStatusList.guanjierror'),
  750. success: function(res) {
  751. that.onffChecked = true;
  752. that.getEquipmentListData();
  753. }
  754. })
  755. }
  756. }
  757. });
  758. } else if (res.cancel) {
  759. that.onffChecked = false;
  760. // that.getEquipmentListData();
  761. }
  762. }
  763. });
  764. } else {
  765. var serverurl = that.serverurl;
  766. var code = code;
  767. var equipmentId = id;
  768. var token = uni.getStorageSync("token");
  769. uni.request({
  770. url: serverurl + '/TEquipment/onOff',
  771. data: {
  772. "adminId": code,
  773. "equipmentId": equipmentId
  774. },
  775. method: "POST",
  776. header: {
  777. 'token': token
  778. },
  779. success: (res) => {
  780. that.input = 2;
  781. var list = res.data.data;
  782. that.getEquipmentListData();
  783. var timestamp = Date.parse(new Date());
  784. that.timeAll.set(id, timestamp);
  785. var oo = that.timeAll;
  786. if (list == "SUCCESS") {
  787. uni.showModal({
  788. title: that.$t('equipmentStatusList.kaiji'),
  789. content: that.$t('equipmentStatusList.tishi'),
  790. success: function(res) {
  791. that.getEquipmentListData();
  792. setTimeout(function() {
  793. that.network(id);
  794. }, 7000);
  795. }
  796. })
  797. } else {
  798. uni.showModal({
  799. title: that.$t('equipmentStatusList.error'),
  800. content: that.$t('equipmentStatusList.kaijierror'),
  801. success: function(res) {
  802. that.equipmentList = [];
  803. that.getEquipmentListData();
  804. }
  805. })
  806. }
  807. }
  808. });
  809. }
  810. },
  811. eliminate(id) {
  812. var token = uni.getStorageSync("token");
  813. uni.request({
  814. url: this.serverurl + '/TEquipment/eliminate',
  815. data: {
  816. "id": id
  817. },
  818. method: "POST",
  819. header: {
  820. 'token': token
  821. },
  822. success: (res) => {
  823. uni.showToast({
  824. title: "发送成功",
  825. icon: 'none',
  826. duration: 1000
  827. });
  828. this.getEquipmentListData();
  829. }
  830. });
  831. },
  832. network(id) {
  833. console.log("network");
  834. var token = uni.getStorageSync("token");
  835. var equipmentId = id;
  836. uni.request({
  837. url: this.serverurl + '/TEquipment/checkStatus',
  838. data: {
  839. "equipmentId": id
  840. },
  841. method: "POST",
  842. header: {
  843. 'token': token
  844. },
  845. success: (res) => {
  846. var data = res.data.data;
  847. if (data == 'fail') {
  848. uni.showToast({
  849. title: this.$t('equipmentStatusList.network'),
  850. icon: 'none',
  851. duration: 3000
  852. });
  853. this.getEquipmentListData();
  854. }
  855. }
  856. });
  857. },
  858. openDoor(id) {
  859. var token = uni.getStorageSync("token");
  860. uni.request({
  861. url: this.serverurl + '/TEquipment/openDoor',
  862. data: {
  863. "equipmentId": id
  864. },
  865. method: "POST",
  866. header: {
  867. 'token': token
  868. },
  869. success: (res) => {
  870. uni.showModal({
  871. title: this.$t('equipmentStatusList.open'),
  872. content: this.$t('equipmentStatusList.opensuccess'),
  873. success: function(res) {
  874. }
  875. })
  876. }
  877. });
  878. },
  879. // type(类型,0:外门,1:内门),
  880. // status(状态:0:关闭,1:开启)
  881. updateEquipment(id,type,status){
  882. var that = this;
  883. uni.showModal({
  884. title: that.$t('equipmentStatusList.tip'),
  885. content: that.$t('equipmentStatusList.updateTip'),
  886. success: function(res) {
  887. if (res.confirm) {
  888. var serverurl = that.serverurl;
  889. var token = uni.getStorageSync("token");
  890. uni.request({
  891. url: serverurl + '/TEquipment/updateEquipment?id='+id+'&type='+type+'&status='+status,
  892. method: "GET",
  893. header: {
  894. 'token': token
  895. },
  896. success: (res) => {
  897. var code = res.data.code;
  898. if (code) {
  899. uni.showModal({
  900. title: that.$t(
  901. 'equipmentStatusList.tip'),
  902. content: that.$t(
  903. 'equipmentStatusList.successReturn'),
  904. success: function(res) {
  905. // setTimeout(function() {
  906. // }, 7000);
  907. }
  908. })
  909. } else {
  910. uni.showModal({
  911. title: that.$t(
  912. 'equipmentStatusList.tip'),
  913. content: that.$t(
  914. 'equipmentStatusList.errorReturn'),
  915. success: function(res) {
  916. }
  917. })
  918. }
  919. }
  920. });
  921. } else if (res.cancel) {
  922. that.onffChecked = false;
  923. that.getEquipmentListData();
  924. }
  925. }
  926. });
  927. },
  928. buliao(id) {
  929. var that = this;
  930. var token = uni.getStorageSync("token");
  931. uni.showModal({
  932. title: this.$t('equipmentStatusList.tip'),
  933. content: this.$t('equipmentStatusList.wuliaoTip'),
  934. success: function(res) {
  935. uni.request({
  936. url: that.serverurl + '/TEquipment/buliao',
  937. data: {
  938. "equipmentId": id
  939. },
  940. method: "POST",
  941. header: {
  942. 'token': token
  943. },
  944. success: (res) => {
  945. uni.showModal({
  946. title: this.$t('equipmentStatusList.tip'),
  947. content: res.data.message,
  948. success: function(res) {
  949. that.getEquipmentListData();
  950. }
  951. })
  952. }
  953. })
  954. }
  955. })
  956. },
  957. change(id, code, index) {
  958. this.sleepChecked = true;
  959. var that = this;
  960. var code1 = code;
  961. // console.log(index);
  962. // console.log(code);
  963. if (code1 == 1) {
  964. // that.sleepChecked = true;
  965. uni.showModal({
  966. title: that.$t('equipmentStatusList.tip'),
  967. content: that.$t('equipmentStatusList.sleepTip'),
  968. success: function(res) {
  969. if (res.confirm) {
  970. var serverurl = that.serverurl;
  971. var code2 = code1;
  972. var equipmentId = id;
  973. var token = uni.getStorageSync("token");
  974. uni.request({
  975. url: serverurl + '/TEquipment/sleep',
  976. data: {
  977. "adminId": code2,
  978. "equipmentId": equipmentId
  979. },
  980. method: "POST",
  981. header: {
  982. 'token': token
  983. },
  984. success: (res) => {
  985. var list = res.data.data;
  986. that.equipmentList[index].isSleep = true;
  987. that.sleepChecked = null;
  988. that.getEquipmentListData();
  989. }
  990. });
  991. } else {
  992. that.equipmentList[index].isSleep = false;
  993. that.sleepChecked = false;
  994. that.getEquipmentListData();
  995. }
  996. }
  997. });
  998. } else {
  999. that.descShow = false;
  1000. that.editBtn = true;
  1001. var serverurl = that.serverurl;
  1002. var code = code;
  1003. var equipmentId = id;
  1004. var token = uni.getStorageSync("token");
  1005. uni.request({
  1006. url: serverurl + '/TEquipment/sleep',
  1007. data: {
  1008. "adminId": code,
  1009. "equipmentId": equipmentId
  1010. },
  1011. method: "POST",
  1012. header: {
  1013. 'token': token
  1014. },
  1015. success: (res) => {
  1016. var list = res.data.data;
  1017. that.equipmentList[index].isSleep = false;
  1018. that.sleepChecked = false;
  1019. that.getEquipmentListData();
  1020. }
  1021. });
  1022. }
  1023. },
  1024. }
  1025. }
  1026. </script>
  1027. <style>
  1028. .status-css {
  1029. position: absolute;
  1030. width: 30upx;
  1031. height: 30upx;
  1032. right: 86upx;
  1033. top: 30upx;
  1034. border-radius: 30upx;
  1035. color: "#596D83";
  1036. font-size: 12upx;
  1037. }
  1038. .status-error {
  1039. background-color: #dd524d
  1040. }
  1041. .status-normal {
  1042. background-color: #4cd964
  1043. }
  1044. .baojing {
  1045. display: flex;
  1046. flex-direction: row;
  1047. padding-left: 20upx;
  1048. }
  1049. .titleFlag {
  1050. height: 56upx;
  1051. background-color: #F8F8F8;
  1052. color: #8C959F;
  1053. font-size: 22upx;
  1054. display: flex;
  1055. flex-direction: row;
  1056. }
  1057. .opendoor {
  1058. /* #ifdef H5
  1059. /* #endif */
  1060. padding-top: 10upx;
  1061. padding-bottom: 10upx;
  1062. /* text-align: center; */
  1063. display: flex;
  1064. flex-direction: row;
  1065. }
  1066. .button {
  1067. /* #ifdef H5 */
  1068. text-align: center;
  1069. height: 50upx;
  1070. weight: 20upx;
  1071. /* #endif */
  1072. padding-left: 15upx;
  1073. /* padding-top: 2upx; */
  1074. }
  1075. .eliminateButton {
  1076. /* #ifdef H5 */
  1077. text-align: center;
  1078. height: 50upx;
  1079. weight: 20upx;
  1080. /* #endif */
  1081. padding-left: 15upx;
  1082. /* padding-top: 2upx; */
  1083. }
  1084. .p {
  1085. /* #ifdef H5 */
  1086. font-size: 28upx;
  1087. height: 50upx;
  1088. weight: 20upx;
  1089. transform: translateY(-14upx);
  1090. /* text-align: center; */
  1091. /* #endif */
  1092. /* padding-bottom: 50upx; */
  1093. text-align: center;
  1094. padding-left: 13upx;
  1095. }
  1096. .img {
  1097. padding-top: 20upx;
  1098. padding-left: 30upx;
  1099. width: 15upx;
  1100. height: 15upx;
  1101. }
  1102. .wenziT {
  1103. padding-top: 10upx;
  1104. padding-left: 10upx;
  1105. }
  1106. .titlelist {
  1107. color: #363D44;
  1108. font-size: 16upx;
  1109. font-family: "PingFang-SC-Medium";
  1110. }
  1111. .swithBox {
  1112. display: flex;
  1113. flex-direction: row;
  1114. padding-bottom: 15upx;
  1115. padding-top: 5upx;
  1116. }
  1117. .switch {
  1118. width: 100upx;
  1119. height: 22upx;
  1120. }
  1121. .switch1 {
  1122. display: flex;
  1123. /* flex-direction: row; */
  1124. width: 35%;
  1125. height: 42upx;
  1126. /* padding-top: 13upx; */
  1127. /* padding-left: 132px; */
  1128. margin-left: auto;
  1129. }
  1130. .switch2 {
  1131. display: flex;
  1132. flex-direction: row;
  1133. padding-top: 13upx;
  1134. width: 35%;
  1135. height: 42upx;
  1136. margin-left: auto;
  1137. }
  1138. .switch3 {
  1139. height: 42upx;
  1140. padding-top: 13upx;
  1141. margin-left: auto;
  1142. }
  1143. .swichFont {
  1144. width: 85%;
  1145. padding-top: 12upx;
  1146. }
  1147. .swichFont2{
  1148. width: auto;
  1149. padding-top: 12upx;
  1150. }
  1151. .swichFont3{
  1152. width: 40%;
  1153. margin-top: 8px;
  1154. font-size: 14px;
  1155. }
  1156. .swichFont4 {
  1157. width: auto;
  1158. padding-top: 12upx;
  1159. }
  1160. .swichFont1 {
  1161. width: 60%;
  1162. padding-top: 12upx;
  1163. }
  1164. .line1 {
  1165. width: 100%;
  1166. height: 3upx;
  1167. background: #000000;
  1168. }
  1169. .line {
  1170. width: 100%;
  1171. height: 3upx;
  1172. background: #c8c7cc;
  1173. }
  1174. .button-container {
  1175. display: flex;
  1176. }
  1177. .left-button,
  1178. .right-button {
  1179. flex: 1;
  1180. }
  1181. .search {
  1182. width: 100%;
  1183. padding-top: 10upx;
  1184. display: flex;
  1185. flex-direction: row;
  1186. justify-content: flex-start;
  1187. }
  1188. .search-title {
  1189. width: 25%;
  1190. /* margin: 0 10px; */
  1191. margin-right: 10px;
  1192. text-align: center;
  1193. font-family: "PingFang-SC-Bold";
  1194. /* box-shadow: 0upx 0upx 20upx #D3D3D3; */
  1195. border-radius: 20px;
  1196. /* padding: 2px; */
  1197. }
  1198. .search-input{
  1199. width: 48%;
  1200. height: 25px;
  1201. text-align: center;
  1202. margin-top: 5px;
  1203. font-size: 26upx;
  1204. font-family: "PingFang-SC-Bold";
  1205. box-shadow: 0upx 0upx 30upx #D3D3D3;
  1206. border-radius: 5upx;
  1207. }
  1208. .search-button{
  1209. width: 20%;
  1210. padding-left: 10px;
  1211. padding-bottom: 5px;
  1212. margin-top: 3px;
  1213. text-align: center;
  1214. height: 60upx;
  1215. text-align: left;
  1216. }
  1217. </style>