equipmentStatusList.vue 37 KB

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