BatteryInfo.vue 5.1 KB

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