equipmentStatusList.vue 32 KB

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