equipmentStatusList.vue 33 KB

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