equipmentStatusList.vue 37 KB

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