BatteryInfo.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. <template>
  2. <view class="battery-info" :class="[IsSelect?'SelectBorder':'defaultBorder']" @click="HandleBatterySelected(storeCode,storeState,getChgState)">
  3. <view class="battery-header" :class="[storeState===1?'battery-have':'battery-null']">
  4. <view class="battery-box" v-show="getChgState!=2 && storeState===1">
  5. <view class="batteryList">
  6. <view class="battery-many" v-for="item in getBatteryNum" :key="item"
  7. :style="{ 'bottom': item * 14 - 14 + 'px' }">
  8. <image :src="item === getBatteryNum ? '/static/change/ding.png' : '/static/change/zhong.png'"></image>
  9. </view>
  10. </view>
  11. <span>SOC {{soc || '0'}}%<br>{{chgEstimatedTime || '0'}}min 充满</span>
  12. </view>
  13. <view class="battery-anmition" v-show="getChgState==2">
  14. <span>SOC {{soc || '0'}}%<br>{{chgEstimatedTime || '0'}}min 充满</span>
  15. </view>
  16. </view>
  17. <view class="battery-footer">
  18. <span class="battery-number">{{ storeCode }}号仓</span>
  19. </view>
  20. </view>
  21. </template>
  22. <script>
  23. export default {
  24. name: "BatteryInfo",
  25. props: ['soc',
  26. 'chgState',
  27. 'storeCode',
  28. 'IsSelect',
  29. 'BatterySelected',
  30. 'BatterySelectAllArr',
  31. 'chgEstimatedTime',
  32. 'storeState',
  33. 'freezeState', //冻结状态
  34. 'comState', //电池通讯状态
  35. 'chargerComState', //充电机通讯状态
  36. ],
  37. data() {
  38. return {
  39. };
  40. },
  41. computed: {
  42. //计算电池块数
  43. getBatteryNum() {
  44. if (this.soc === 0) {
  45. return 0
  46. } else if (this.soc > 0 && this.soc <= 20) {
  47. return 1
  48. } else if (this.soc > 20 && this.soc <= 40) {
  49. return 2
  50. } else if (this.soc > 40 && this.soc <= 60) {
  51. return 3
  52. } else if (this.soc > 60 && this.soc <= 80) {
  53. return 4
  54. } else if (this.soc > 80 && this.soc <= 100) {
  55. return 5
  56. }
  57. },
  58. //计算电池是否充电中
  59. getChgState(){
  60. if(this.chgState==1 || this.chgState==2){
  61. return 2
  62. }else{
  63. return 0
  64. }
  65. }
  66. },
  67. methods: {
  68. //把选择的仓位号传给父组件,触发函数BatterySelected
  69. HandleBatterySelected(storeCode,storeState,getChgState) {
  70. const CurrentStore={storeCode,storeState,getChgState}//当前选择的电池仓位号,以及是否有电池
  71. this.BatterySelected(CurrentStore)
  72. // console.log(storeCode)
  73. }
  74. }
  75. }
  76. </script>
  77. <style lang="scss" scoped>
  78. .SelectBorder{
  79. border: 1px solid #338150;
  80. }
  81. .defaultBorder{
  82. border: 1px solid #111827;
  83. }
  84. .battery-info {
  85. width: 110px;
  86. height: 180px;
  87. background: #0A101C;
  88. display: flex;
  89. flex-direction: column;
  90. cursor: pointer;
  91. .battery-null{
  92. background: #292D46;
  93. }
  94. .battery-have{
  95. background: #0A101C;
  96. }
  97. .battery-header {
  98. height: 156px;
  99. // background: #292D46;
  100. box-sizing: border-box;
  101. padding-top: 10px;
  102. .battery-anmition {
  103. width: 90px;
  104. height: 136px;
  105. background-image: url('~@/static/change/battery-anim.gif');
  106. background-size: 100% 100%;
  107. margin: 0 10px;
  108. position: relative;
  109. }
  110. .battery-box {
  111. width: 90px;
  112. height: 136px;
  113. background-image: url('~@/static/change/battery.png');
  114. background-size: 100% 100%;
  115. margin: 0 10px;
  116. padding-bottom: 26px;
  117. box-sizing: border-box;
  118. position: relative;
  119. .batteryList {
  120. position: relative;
  121. height: 110px;
  122. width: 100%;
  123. display: flex;
  124. flex-direction: column;
  125. justify-content: flex-end;
  126. align-items: center;
  127. .batteryOne {
  128. position: absolute;
  129. bottom: 0;
  130. z-index: 10;
  131. }
  132. .battery-many {
  133. position: absolute;
  134. width: 50px;
  135. image{
  136. width: 50px;
  137. height: 21.5px;
  138. }
  139. // span{
  140. // position: absolute;
  141. // width: 78px;
  142. // font-weight: 500;
  143. // color: #FFFFFF;
  144. // text-shadow: 0px 0px 4px rgba(39,69,201,0.5);
  145. // font-size: 12px;
  146. // left: 0;
  147. // text-align: center;
  148. // bottom:-24px;
  149. // line-height: 14px;
  150. // }
  151. }
  152. }
  153. }
  154. span {
  155. position: absolute;
  156. width: 100%;
  157. font-weight: 500;
  158. color: #FFFFFF;
  159. text-shadow: 0px 0px 4px rgba(39, 69, 201, 0.5);
  160. font-size: 12px;
  161. left: 0;
  162. text-align: center;
  163. top: 41%;
  164. line-height: 16px;
  165. }
  166. }
  167. .battery-footer {
  168. height: 24px;
  169. background-color: #1C263A;
  170. width: 100%;
  171. line-height: 24px;
  172. color: white;
  173. font-size: 12px;
  174. text-indent: 8px;
  175. }
  176. }
  177. </style>