cell.vue 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348
  1. <template>
  2. <view>
  3. <view class="top-box">
  4. <view class="top-title">
  5. <view v-if="!userInfo.storeId" @click="showPop=true" class="ddflex" :style="'height: '+ systems.navigationHeight + 'rpx;padding-top:' + systems.ktxStatusHeight + 'rpx;'+'line-height: '+ systems.navigationHeight + 'rpx;'">
  6. <view>{{actMerchant.name}}</view>
  7. <image class="dow-ssicon" src="../../static/pages/images/dow-ssicon.png"></image>
  8. </view>
  9. </view>
  10. <view class="tab-box ddflex">
  11. <view class="fflex ddflex">
  12. <view :class="'tab-item fflex '+(queryType==''?'tab-item-active':'')" @click="queryTypeChange(-1)">
  13. <view>全部</view>
  14. <image class="tab-active-icon" src="../../static/images/tab_cur.png"></image>
  15. </view>
  16. <view :class="'tab-item fflex '+(queryType==2?'tab-item-active':'')" @click="queryTypeChange(2)">
  17. <view>未租</view>
  18. <image class="tab-active-icon" src="../../static/images/tab_cur.png"></image>
  19. </view>
  20. <view :class="'tab-item fflex '+(queryType==1?'tab-item-active':'')" @click="queryTypeChange(1)">
  21. <view>已租</view>
  22. <image class="tab-active-icon" src="../../static/images/tab_cur.png"></image>
  23. </view>
  24. </view>
  25. <view class="ddflex">
  26. <image class="saoma" src="../../static/pages/images/saoma.png" @click="saomaFn()"></image>
  27. <image class="sousuo" src="../../static/pages/images/search.png" @click="jumpUrl('/machineAndCell/cellSearch/cellSearch?storeId='+actMerchant.id+'&type='+queryType)"></image>
  28. </view>
  29. </view>
  30. </view>
  31. <view :style="'height: '+ (systems.navigationHeight+systems.ktxStatusHeight+106) + 'rpx;'"></view>
  32. <view class="ddflex state-box">
  33. <view class="state-item">
  34. <view class="ddflex">
  35. <view class="icon"></view>
  36. <view class="state-label">租赁中</view>
  37. </view>
  38. <view class="ddflex state-data">
  39. <view>{{count.leaseCount}}</view>
  40. <view>{{getP(1)}}%</view>
  41. </view>
  42. </view>
  43. <view class="state-item">
  44. <view class="ddflex">
  45. <view class="icon" style="background: #0FCB27;"></view>
  46. <view class="state-label">空闲</view>
  47. </view>
  48. <view class="ddflex fflex state-data">
  49. <view>{{count.noLeaseCount}}</view>
  50. <view>{{getP(2)}}%</view>
  51. </view>
  52. </view>
  53. </view>
  54. <!-- 电池 -->
  55. <view>
  56. <view class="cell-box" v-for="item,index in groupList">
  57. <view class="ddflex">
  58. <view style="margin-right: 35rpx;">
  59. <cell :width="99" :height="197" :soc="index*10" :showsoc="true"></cell>
  60. </view>
  61. <view class="cell-info fflex">
  62. <view class="ddflex">
  63. <view class="cell-title">{{item.model}}</view>
  64. <view class="cell-state" :style="item.leaseStatus==1?'':'background-color: #0FCB27;'">{{item.leaseStatus==1?'已租':'空闲'}}</view>
  65. </view>
  66. <view class="cell-info ddflex">
  67. <view>电池Id:</view>
  68. <view>{{item.batteryId}}</view>
  69. </view>
  70. <view class="cell-info ddflex">
  71. <view>设备编号:</view>
  72. <view>{{item.number}}</view>
  73. </view>
  74. <view class="cell-info ddflex">
  75. <view>门店:</view>
  76. <view>{{item.storeName}}</view>
  77. </view>
  78. <view class="cell-info ddflex">
  79. <view>到期时间:</view>
  80. <view>{{item.blockDate}}</view>
  81. </view>
  82. </view>
  83. </view>
  84. <view class="cell-option ddflex">
  85. <view class="fflex" @click="jumpUrl('/machineAndCell/map/map?id='+item.batteryId)">定位</view>
  86. <view class="fflex" @click="jumpUrl('/machineAndCell/BMS/BMS?id='+item.batteryId)">BMS</view>
  87. <view class="fflex" @click="jumpUrl('/machineAndCell/cellDetail/cellDetail?id='+item.batteryId)">详情</view>
  88. </view>
  89. </view>
  90. </view>
  91. <left-pop v-if="showPop" :showPop="showPop" :btnColor="'#11BB8B'" :showBtn='false' title="解除提醒" width="460rpx"
  92. @closePop="closePop()" @popSubmit="popSubmit()">
  93. <view class="" style="height: 100%;flex-direction: column;display: flex;">
  94. <view @click="closePop()" class="pop-title ddflex" :style="'height: '+ systems.navigationHeight + 'rpx;padding-top:' + systems.ktxStatusHeight + 'rpx;'+'line-height: '+ systems.navigationHeight + 'rpx;'">
  95. <view>切换门店</view>
  96. <image class="change-ssicon" src="../../static/pages/images/change.png"></image>
  97. </view>
  98. <scroll-view :scroll-y="true" @scrolltolower="loadLeftData" class="pop-content fflex">
  99. <view :class="'pop-content-item '+(actMerchant.id==item.id?'pop-content-active':'')" v-for="(item,index) in merchantList" @click="changePop(item)">
  100. <view class="pop-content-name">{{item.name}}</view>
  101. <image class="pop-content-icon" src=""></image>
  102. </view>
  103. </scroll-view>
  104. </view>
  105. </left-pop>
  106. <foot channel="cell" :isUpdate="isUpdate"></foot>
  107. </view>
  108. </template>
  109. <script>
  110. const app = getApp();
  111. const req = require("../../utils/request.js");
  112. import cell from "../../components/cell/index";
  113. import foot from "../../components/nav-bar/index";
  114. import leftPop from "../../components/left-pop/index";
  115. export default {
  116. components: {
  117. cell,
  118. foot,
  119. leftPop
  120. },
  121. props: {},
  122. data() {
  123. return {
  124. systems: {},
  125. isTop:0,
  126. userInfo:{},
  127. showPop: false,
  128. tempData: null,
  129. groupList: [],
  130. page: 1,
  131. limit: 10,
  132. searchValue:'',
  133. isQuerying:false,//正在查询数据
  134. queryType:'',
  135. merchantList: [],
  136. merchantPage: 1,
  137. merchantLimit: 10,
  138. actMerchant:null,//当前门店
  139. count:{}
  140. }
  141. },
  142. onLoad(options) {
  143. // 判断当前登录用户身份
  144. if(req.isLogins(true)){
  145. this.userInfo = req.getStorage('userInfo')
  146. if(!this.userInfo.storeId){
  147. this.getMerchantList()
  148. }else{
  149. this.actMerchant={
  150. id:this.userInfo.storeId
  151. }
  152. this.getMachineList()
  153. }
  154. }else{
  155. this.getMachineList()
  156. }
  157. },
  158. onShow() {
  159. },
  160. onReachBottom() {
  161. this.getMachineList(true)
  162. },
  163. methods: {
  164. getP(type){
  165. let p = 0
  166. if(type==1){
  167. if(this.count.leaseCount == 0){}
  168. else{
  169. return (this.count.leaseCount/(this.count.leaseCount+this.count.noLeaseCount)).toFixed(4)*100
  170. }
  171. }
  172. if(type==2){
  173. if(this.count.noLeaseCount == 0){}
  174. else{
  175. return (this.count.noLeaseCount/(this.count.leaseCount+this.count.noLeaseCount)).toFixed(4)*100
  176. }
  177. }
  178. return p*100
  179. },
  180. jumpUrl(url){
  181. if(req.isLogins(true)){
  182. uni.navigateTo({
  183. url:url
  184. })
  185. }
  186. },
  187. queryTypeChange(val) {
  188. if (this.queryType == val) return false
  189. this.queryType = val
  190. this.queryType = val==-1?'':val
  191. this.getMachineList()
  192. },
  193. // 弹窗弹出
  194. openPop(item) {
  195. this.tempData = JSON.parse(JSON.stringify(item))
  196. this.showPop = true
  197. },
  198. closePop(){
  199. this.showPop = false
  200. },
  201. changePop(item){
  202. this.actMerchant = item
  203. this.closePop()
  204. this.getMachineList()
  205. this.getTopNum()
  206. },
  207. // 电池数量
  208. getTopNum(){
  209. console.log('getTopNum')
  210. req.getRequest(
  211. '/admin/v2/battery/count',
  212. {storeId:this.actMerchant.id},
  213. data => {
  214. this.count = data
  215. }
  216. )
  217. },
  218. // 获取电池列表
  219. getMachineList(isPage){
  220. if(this.isQuerying) return
  221. else this.isQuerying = true
  222. if (!isPage) {
  223. this.page = 1
  224. }
  225. let queryParams = {
  226. page: this.page,
  227. limit: this.limit,
  228. }
  229. if(this.searchValue){
  230. queryParams.number=this.searchValue
  231. }
  232. if(this.queryType){
  233. queryParams.type = this.queryType
  234. }
  235. queryParams.storeId = this.actMerchant.id
  236. req.getRequest(
  237. '/admin/v2/battery/page',
  238. queryParams,
  239. data => {
  240. if (data != null && data.list.length > 0) {
  241. if (!isPage) {
  242. this.groupList = data.list
  243. } else {
  244. this.groupList = this.groupList.concat(data.list)
  245. }
  246. this.page++
  247. } else {
  248. if (!isPage)
  249. this.groupList = data.list
  250. else {}
  251. }
  252. uni.hideLoading()
  253. this.isQuerying = false
  254. }
  255. )
  256. },
  257. loadLeftData(res){
  258. this.getMerchantList(true)
  259. },
  260. getMerchantList(isPage){
  261. if (!isPage) {
  262. this.merchantPage = 1
  263. }
  264. let queryParams = {
  265. page: this.merchantPage,
  266. limit: this.merchantLimit,
  267. }
  268. queryParams.merchantId = req.getStorage('userInfo').merchantId?req.getStorage('userInfo').merchantId:null
  269. req.getRequest(
  270. '/admin/v2/store/page',
  271. queryParams,
  272. data => {
  273. if (data != null && data.list.length > 0) {
  274. if (!isPage) {
  275. this.merchantList = data.list
  276. } else {
  277. this.merchantList = this.merchantList.concat(data.list)
  278. }
  279. this.merchantPage++
  280. } else {
  281. if (!isPage)
  282. this.merchantList = data.list
  283. else {}
  284. }
  285. if(!isPage){
  286. if(this.actMerchant){
  287. }else{
  288. this.actMerchant = this.merchantList[0]
  289. }
  290. this.getMachineList()
  291. this.getTopNum()
  292. }
  293. }
  294. )
  295. },
  296. saomaFn(){
  297. // 只允许通过相机扫码
  298. uni.scanCode({
  299. onlyFromCamera: false,
  300. success: (res) =>{
  301. console.log('条码类型:' + res.scanType);
  302. console.log('条码内容:' + res.result);
  303. // did设备id
  304. this.jumpUrl('/machineAndCell/cellSearch/cellSearch?storeId='+this.actMerchant.id+'&searchValue='+res.result+'&type='+this.queryType)
  305. }
  306. });
  307. }
  308. },
  309. mounted() {
  310. const systemInfo = uni.getSystemInfoSync();
  311. // px转换到rpx的比例
  312. let pxToRpxScale = 750 / systemInfo.windowWidth;
  313. let systems = {
  314. ktxStatusHeight: systemInfo.statusBarHeight * pxToRpxScale, // 状态栏的高度
  315. navigationHeight: 44 * pxToRpxScale // 导航栏的高度
  316. };
  317. systems.barHeight = systems.ktxStatusHeight + systems.navigationHeight;
  318. this.systems = systems;
  319. },
  320. onPageScroll: function(e) {
  321. if (e.scrollTop > this.systems.barHeight) {
  322. this.isTop = 1;
  323. } else {
  324. this.isTop = 0;
  325. }
  326. }
  327. }
  328. </script>
  329. <style>
  330. @import "./cell.css";
  331. </style>