equipmentStatusList.vue 33 KB

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