BatteryInfo.vue 5.2 KB

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