equipmentStatusList.vue 37 KB

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