equipmentStatusList.vue 32 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084
  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.globalUser.offset = 1;
  366. this.globalUser.limit = 20;
  367. this.getEquipmentListData();
  368. },
  369. onReachBottom() {
  370. if(this.onReach) {
  371. this.globalUser.offset = this.globalUser.offset + this.globalUser.limit;
  372. this.getEquipmentListData();
  373. }
  374. },
  375. onShow() {
  376. this.input = this.input + 1;
  377. this.globalUser = uni.getStorageSync("globalUser");
  378. this.globalUser.offset = 1;
  379. this.globalUser.limit = 20;
  380. uni.setNavigationBarTitle({
  381. title: this.$t('equipmentStatusList.title')
  382. });
  383. uni.setTabBarItem({
  384. index: 3,
  385. text: this.$t('tabs.tab4')
  386. });
  387. var token = uni.getStorageSync("token");
  388. if (token.length > 1) {
  389. if(this.equipmentList.length === 0) {
  390. this.getEquipmentListData();
  391. }
  392. } else {
  393. uni.reLaunch({
  394. url: '../Login/Login',
  395. });
  396. }
  397. },
  398. methods: {
  399. ...mapActions('chart', ['getEquipmentListByUser']),
  400. getMerchantTitle(merchant) {
  401. return merchant.name ? merchant.name : merchant.username;
  402. },
  403. getEquipmentTitle(equipment) {
  404. return equipment.name ? equipment.name : '暂无名称';
  405. },
  406. getEquipmentListData() {
  407. this.getEquipmentListByUser(this.globalUser)
  408. .then(data => {
  409. this.merchantList = data;
  410. if(data[0].equipmentList.length === 0) {
  411. this.onReach = false;
  412. }
  413. this.equipmentList.push(...data[0].equipmentList);
  414. console.log(this.equipmentList);
  415. var listName = data[0].equipmentList;
  416. var times = new Map;
  417. if (this.input == 1) {
  418. for (var i = 0; i < listName.length; i++) {
  419. var k = listName[i].id;
  420. times.set(k, null);
  421. }
  422. this.timeAll = times;
  423. }
  424. var listId = data[0].id;
  425. if (listId != null && listId != '1') {
  426. uni.setStorageSync("listName", listName);
  427. }
  428. uni.stopPullDownRefresh();
  429. }, _ => void uni.stopPullDownRefresh());
  430. },
  431. getValue: function(event) {
  432. // 绕过v-model 获取input输入框的值
  433. var value = event.target.value;
  434. this.sleepDesc = value;
  435. },
  436. // 点击更改
  437. toggleReadOnly() {
  438. this.descShow = true;
  439. this.editBtn = false;
  440. },
  441. // 取消更改
  442. cancelDesc() {
  443. this.descShow = false;
  444. this.editBtn = true;
  445. },
  446. // 更改睡眠描述
  447. confirmDesc(sleepDesc,id) {
  448. var that = this;
  449. uni.showModal({
  450. title: that.$t('equipmentStatusList.tip'),
  451. content: that.$t('equipmentStatusList.sleepDescTip'),
  452. success: function(res) {
  453. if (res.confirm) {
  454. var serverurl = that.serverurl;
  455. var sleepDescNew = that.sleepDesc;
  456. if(sleepDescNew == null||sleepDescNew == '') {
  457. if(sleepDesc!=null) {
  458. sleepDescNew = sleepDesc;
  459. } else {
  460. sleepDescNew = that.$t('equipmentStatusList.suspendBusiness');
  461. }
  462. }
  463. var token = uni.getStorageSync("token");
  464. uni.request({
  465. url: serverurl + '/TEquipmentDesc/updateSleepDesc',
  466. data: {
  467. "sleepDesc": sleepDescNew,
  468. "equipmentId": id
  469. },
  470. method: "POST",
  471. header: {
  472. 'token': token
  473. },
  474. success: (res) => {
  475. console.log(res.data.code);
  476. if (res.data.code) {
  477. uni.showModal({
  478. title: that.$t('equipmentStatusList.tip'),
  479. content: that.$t('equipmentStatusList.modifiedSuccessfully'),
  480. })
  481. that.descShow = false;
  482. that.editBtn = true;
  483. that.getEquipmentListData();
  484. } else {
  485. uni.showModal({
  486. title: that.$t('equipmentStatusList.tip'),
  487. content: that.$t('equipmentStatusList.modificationFailure'),
  488. })
  489. that.descShow = false;
  490. that.editBtn = true;
  491. that.getEquipmentListData();
  492. }
  493. }
  494. });
  495. }
  496. }
  497. })
  498. },
  499. //查看经纬度
  500. lookMap(id, longitude, latitude) {
  501. var item = {};
  502. item["id"] = id;
  503. item["longitude"] = longitude;
  504. item["latitude"] = latitude;
  505. var globalUser = uni.getStorageSync("globalUser");
  506. var ifForeign = globalUser.ifForeign;
  507. if (ifForeign == 0) {
  508. uni.navigateTo({
  509. url: '../../packageA/pages/equipmentStatus/map?item=' + encodeURIComponent(JSON.stringify(
  510. item))
  511. });
  512. }
  513. if (ifForeign == 1) {
  514. uni.navigateTo({
  515. url: '../../packageA/pages/equipmentStatus/GoogleMap?item=' + encodeURIComponent(JSON
  516. .stringify(item))
  517. });
  518. }
  519. // uni.navigateTo({
  520. // // url:'map?item='+ encodeURIComponent(JSON.stringify(item))
  521. // url:'../../packageA/pages/equipmentStatus/map?item='+ encodeURIComponent(JSON.stringify(item))
  522. // // url:'../../packageA/pages/equipmentStatus/GoogleMap?item='+ encodeURIComponent(JSON.stringify(item))
  523. // // url: '/pages/user/map?item='+ encodeURIComponent(JSON.stringify(item))
  524. // });
  525. },
  526. //一键重启
  527. reboot(id) {
  528. var that = this;
  529. uni.showModal({
  530. title: that.$t('equipmentStatusList.tip'),
  531. content: that.$t('equipmentStatusList.rebootTip'),
  532. success: function(res) {
  533. if (res.confirm) {
  534. var serverurl = that.serverurl;
  535. var code = "1";
  536. var equipmentId = id;
  537. var token = uni.getStorageSync("token");
  538. uni.request({
  539. url: serverurl + '/TEquipment/onOff',
  540. data: {
  541. "adminId": code,
  542. "equipmentId": equipmentId
  543. },
  544. method: "POST",
  545. header: {
  546. 'token': token
  547. },
  548. success: (res) => {
  549. var list = res.data.data;
  550. if (list == "SUCCESS") {
  551. uni.showModal({
  552. title: that.$t('equipmentStatusList.kaiji'),
  553. content: '发送成功',
  554. success: function(res) {}
  555. })
  556. } else {
  557. uni.showModal({
  558. title: that.$t('equipmentStatusList.error'),
  559. content: that.$t(
  560. 'equipmentStatusList.kaijierror'),
  561. success: function(res) {}
  562. })
  563. }
  564. }
  565. });
  566. }
  567. }
  568. })
  569. },
  570. OnOff(id, code) {
  571. var that = this;
  572. var ddd = this.timeAll.get(id);
  573. if (that.timeAll.get(id) != null) {
  574. var stamp = Date.parse(new Date());
  575. var t = (stamp - that.timeAll.get(id)) / 1000;
  576. if (t < 30) {
  577. var s = 30 - t;
  578. uni.showModal({
  579. title: that.$t('equipmentStatusList.onoff'),
  580. content: that.$t('equipmentStatusList.remainingtime') + s + "s",
  581. success: function(res) {
  582. that.getEquipmentListData();
  583. }
  584. });
  585. return;
  586. }
  587. }
  588. var code1 = code;
  589. if (code1 == 0) {
  590. uni.showModal({
  591. title: that.$t('equipmentStatusList.tip'),
  592. content: that.$t('equipmentStatusList.onoffTip'),
  593. success: function(res) {
  594. if (res.confirm) {
  595. var serverurl = that.serverurl;
  596. var code2 = code1;
  597. var equipmentId = id;
  598. var token = uni.getStorageSync("token");
  599. uni.request({
  600. url: serverurl + '/TEquipment/onOff',
  601. data: {
  602. "adminId": code2,
  603. "equipmentId": equipmentId
  604. },
  605. method: "POST",
  606. header: {
  607. 'token': token
  608. },
  609. success: (res) => {
  610. var list = res.data.data;
  611. that.input = 2;
  612. var timestamp = Date.parse(new Date());
  613. that.timeAll.set(id, timestamp);
  614. var oo = that.timeAll;
  615. that.getEquipmentListData();
  616. if (list == 'SUCCESS') {
  617. uni.showModal({
  618. title: that.$t(
  619. 'equipmentStatusList.guanji'),
  620. content: that.$t(
  621. 'equipmentStatusList.tishi'),
  622. success: function(res) {
  623. that.getEquipmentListData();
  624. setTimeout(function() {
  625. that.network(id);
  626. }, 7000);
  627. }
  628. })
  629. } else {
  630. uni.showModal({
  631. title: that.$t(
  632. 'equipmentStatusList.error'),
  633. content: that.$t(
  634. 'equipmentStatusList.guanjierror'),
  635. success: function(res) {
  636. that.onffChecked = true;
  637. that.getEquipmentListData();
  638. }
  639. })
  640. }
  641. }
  642. });
  643. } else if (res.cancel) {
  644. that.onffChecked = false;
  645. that.getEquipmentListData();
  646. }
  647. }
  648. });
  649. } else {
  650. var serverurl = that.serverurl;
  651. var code = code;
  652. var equipmentId = id;
  653. var token = uni.getStorageSync("token");
  654. uni.request({
  655. url: serverurl + '/TEquipment/onOff',
  656. data: {
  657. "adminId": code,
  658. "equipmentId": equipmentId
  659. },
  660. method: "POST",
  661. header: {
  662. 'token': token
  663. },
  664. success: (res) => {
  665. that.input = 2;
  666. var list = res.data.data;
  667. that.getEquipmentListData();
  668. var timestamp = Date.parse(new Date());
  669. that.timeAll.set(id, timestamp);
  670. var oo = that.timeAll;
  671. if (list == "SUCCESS") {
  672. uni.showModal({
  673. title: that.$t('equipmentStatusList.kaiji'),
  674. content: that.$t('equipmentStatusList.tishi'),
  675. success: function(res) {
  676. that.getEquipmentListData();
  677. setTimeout(function() {
  678. that.network(id);
  679. }, 7000);
  680. }
  681. })
  682. } else {
  683. uni.showModal({
  684. title: that.$t('equipmentStatusList.error'),
  685. content: that.$t('equipmentStatusList.kaijierror'),
  686. success: function(res) {
  687. that.onffChecked = false;
  688. that.getEquipmentListData();
  689. }
  690. })
  691. }
  692. }
  693. });
  694. }
  695. },
  696. eliminate(id) {
  697. var token = uni.getStorageSync("token");
  698. uni.request({
  699. url: this.serverurl + '/TEquipment/eliminate',
  700. data: {
  701. "id": id
  702. },
  703. method: "POST",
  704. header: {
  705. 'token': token
  706. },
  707. success: (res) => {
  708. uni.showToast({
  709. title: "发送成功",
  710. icon: 'none',
  711. duration: 1000
  712. });
  713. this.getEquipmentListData();
  714. }
  715. });
  716. },
  717. network(id) {
  718. console.log("network");
  719. var token = uni.getStorageSync("token");
  720. var equipmentId = id;
  721. uni.request({
  722. url: this.serverurl + '/TEquipment/checkStatus',
  723. data: {
  724. "equipmentId": id
  725. },
  726. method: "POST",
  727. header: {
  728. 'token': token
  729. },
  730. success: (res) => {
  731. var data = res.data.data;
  732. if (data == 'fail') {
  733. uni.showToast({
  734. title: this.$t('equipmentStatusList.network'),
  735. icon: 'none',
  736. duration: 3000
  737. });
  738. this.getEquipmentListData();
  739. }
  740. }
  741. });
  742. },
  743. openDoor(id) {
  744. var token = uni.getStorageSync("token");
  745. uni.request({
  746. url: this.serverurl + '/TEquipment/openDoor',
  747. data: {
  748. "equipmentId": id
  749. },
  750. method: "POST",
  751. header: {
  752. 'token': token
  753. },
  754. success: (res) => {
  755. uni.showModal({
  756. title: this.$t('equipmentStatusList.open'),
  757. content: this.$t('equipmentStatusList.opensuccess'),
  758. success: function(res) {
  759. }
  760. })
  761. }
  762. });
  763. },
  764. // type(类型,0:外门,1:内门),
  765. // status(状态:0:关闭,1:开启)
  766. updateEquipment(id,type,status){
  767. var that = this;
  768. uni.showModal({
  769. title: that.$t('equipmentStatusList.tip'),
  770. content: that.$t('equipmentStatusList.updateTip'),
  771. success: function(res) {
  772. if (res.confirm) {
  773. var serverurl = that.serverurl;
  774. var token = uni.getStorageSync("token");
  775. uni.request({
  776. url: serverurl + '/TEquipment/updateEquipment?id='+id+'&type='+type+'&status='+status,
  777. method: "GET",
  778. header: {
  779. 'token': token
  780. },
  781. success: (res) => {
  782. var code = res.data.code;
  783. if (code) {
  784. uni.showModal({
  785. title: that.$t(
  786. 'equipmentStatusList.tip'),
  787. content: that.$t(
  788. 'equipmentStatusList.successReturn'),
  789. success: function(res) {
  790. // setTimeout(function() {
  791. // }, 7000);
  792. }
  793. })
  794. } else {
  795. uni.showModal({
  796. title: that.$t(
  797. 'equipmentStatusList.tip'),
  798. content: that.$t(
  799. 'equipmentStatusList.errorReturn'),
  800. success: function(res) {
  801. }
  802. })
  803. }
  804. }
  805. });
  806. } else if (res.cancel) {
  807. that.onffChecked = false;
  808. that.getEquipmentListData();
  809. }
  810. }
  811. });
  812. },
  813. buliao(id) {
  814. var that = this;
  815. var token = uni.getStorageSync("token");
  816. uni.showModal({
  817. title: this.$t('equipmentStatusList.tip'),
  818. content: this.$t('equipmentStatusList.wuliaoTip'),
  819. success: function(res) {
  820. uni.request({
  821. url: that.serverurl + '/TEquipment/buliao',
  822. data: {
  823. "equipmentId": id
  824. },
  825. method: "POST",
  826. header: {
  827. 'token': token
  828. },
  829. success: (res) => {
  830. uni.showModal({
  831. title: this.$t('equipmentStatusList.tip'),
  832. content: res.data.message,
  833. success: function(res) {
  834. that.getEquipmentListData();
  835. }
  836. })
  837. }
  838. })
  839. }
  840. })
  841. },
  842. change(id, code) {
  843. var that = this;
  844. var code1 = code;
  845. if (code1 == 1) {
  846. uni.showModal({
  847. title: that.$t('equipmentStatusList.tip'),
  848. content: that.$t('equipmentStatusList.sleepTip'),
  849. success: function(res) {
  850. if (res.confirm) {
  851. var serverurl = that.serverurl;
  852. var code2 = code1;
  853. var equipmentId = id;
  854. var token = uni.getStorageSync("token");
  855. uni.request({
  856. url: serverurl + '/TEquipment/sleep',
  857. data: {
  858. "adminId": code2,
  859. "equipmentId": equipmentId
  860. },
  861. method: "POST",
  862. header: {
  863. 'token': token
  864. },
  865. success: (res) => {
  866. var list = res.data.data;
  867. that.getEquipmentListData();
  868. }
  869. });
  870. } else if (res.cancel) {
  871. that.sleepChecked = false;
  872. that.getEquipmentListData();
  873. }
  874. }
  875. });
  876. } else {
  877. that.descShow = false;
  878. that.editBtn = true;
  879. var serverurl = that.serverurl;
  880. var code = code;
  881. var equipmentId = id;
  882. var token = uni.getStorageSync("token");
  883. uni.request({
  884. url: serverurl + '/TEquipment/sleep',
  885. data: {
  886. "adminId": code,
  887. "equipmentId": equipmentId
  888. },
  889. method: "POST",
  890. header: {
  891. 'token': token
  892. },
  893. success: (res) => {
  894. var list = res.data.data;
  895. that.getEquipmentListData();
  896. }
  897. });
  898. }
  899. },
  900. }
  901. }
  902. </script>
  903. <style>
  904. .status-css {
  905. position: absolute;
  906. width: 30upx;
  907. height: 30upx;
  908. right: 86upx;
  909. top: 30upx;
  910. border-radius: 30upx;
  911. color: "#596D83";
  912. font-size: 12upx;
  913. }
  914. .status-error {
  915. background-color: #dd524d
  916. }
  917. .status-normal {
  918. background-color: #4cd964
  919. }
  920. .baojing {
  921. display: flex;
  922. flex-direction: row;
  923. padding-left: 20upx;
  924. }
  925. .titleFlag {
  926. height: 56upx;
  927. background-color: #F8F8F8;
  928. color: #8C959F;
  929. font-size: 22upx;
  930. display: flex;
  931. flex-direction: row;
  932. }
  933. .opendoor {
  934. /* #ifdef H5
  935. /* #endif */
  936. padding-top: 10upx;
  937. padding-bottom: 10upx;
  938. /* text-align: center; */
  939. display: flex;
  940. flex-direction: row;
  941. }
  942. .button {
  943. /* #ifdef H5 */
  944. text-align: center;
  945. height: 50upx;
  946. weight: 20upx;
  947. /* #endif */
  948. padding-left: 15upx;
  949. /* padding-top: 2upx; */
  950. }
  951. .eliminateButton {
  952. /* #ifdef H5 */
  953. text-align: center;
  954. height: 50upx;
  955. weight: 20upx;
  956. /* #endif */
  957. padding-left: 15upx;
  958. /* padding-top: 2upx; */
  959. }
  960. .p {
  961. /* #ifdef H5 */
  962. font-size: 28upx;
  963. height: 50upx;
  964. weight: 20upx;
  965. transform: translateY(-14upx);
  966. /* text-align: center; */
  967. /* #endif */
  968. /* padding-bottom: 50upx; */
  969. text-align: center;
  970. padding-left: 13upx;
  971. }
  972. .img {
  973. padding-top: 20upx;
  974. padding-left: 30upx;
  975. width: 15upx;
  976. height: 15upx;
  977. }
  978. .wenziT {
  979. padding-top: 10upx;
  980. padding-left: 10upx;
  981. }
  982. .titlelist {
  983. color: #363D44;
  984. font-size: 16upx;
  985. font-family: "PingFang-SC-Medium";
  986. }
  987. .swithBox {
  988. display: flex;
  989. flex-direction: row;
  990. padding-bottom: 15upx;
  991. padding-top: 5upx;
  992. }
  993. .switch {
  994. width: 100upx;
  995. height: 22upx;
  996. }
  997. .switch1 {
  998. display: flex;
  999. /* flex-direction: row; */
  1000. width: 35%;
  1001. height: 42upx;
  1002. /* padding-top: 13upx; */
  1003. /* padding-left: 132px; */
  1004. margin-left: auto;
  1005. }
  1006. .switch2 {
  1007. display: flex;
  1008. flex-direction: row;
  1009. padding-top: 13upx;
  1010. width: 35%;
  1011. height: 42upx;
  1012. margin-left: auto;
  1013. }
  1014. .switch3 {
  1015. height: 42upx;
  1016. padding-top: 13upx;
  1017. margin-left: auto;
  1018. }
  1019. .swichFont {
  1020. width: 85%;
  1021. padding-top: 12upx;
  1022. }
  1023. .swichFont2{
  1024. width: auto;
  1025. padding-top: 12upx;
  1026. }
  1027. .swichFont3{
  1028. width: 40%;
  1029. margin-top: 8px;
  1030. font-size: 14px;
  1031. }
  1032. .swichFont4 {
  1033. width: auto;
  1034. padding-top: 12upx;
  1035. }
  1036. .swichFont1 {
  1037. width: 60%;
  1038. padding-top: 12upx;
  1039. }
  1040. .line1 {
  1041. width: 100%;
  1042. height: 3upx;
  1043. background: #000000;
  1044. }
  1045. </style>