equipmentStatusList.vue 38 KB

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