<template>
	<view class="main_manual">
		<SubTitle title="储充信息  8" titleEng="Storage and charging information"></SubTitle>
		<view class="header_title">
			<image class="header_title_img" src="../../../static/equipment/tip.png" mode=""></image>
			仓位上方是电池，下方是充电机，点击仓位可查看充电详情信息
		</view>
		<view class="box_swiper">
			<scroll-view scroll-x="true" class="scroll_x">
				<view v-for="(item, index) in storeInfoLists" :key="index">
					<!-- @click="drawer(item,index)"-->
					<StorageInfo :store-code="item.storeCode" :com-state="item.comState" :sn="item.sn" :soc="item.soc"
						@drawer="drawer(item,index)" :chg-estimated-time="item.chargerInfoVo.chgEstimatedTime"
						:current="item.current" :voltage="item.voltage" :min-temperature="item.minTemperature"
						:max-temperature="item.maxTemperature" :max-cell-voltage="item.maxCellVoltage" index
						:min-cell-voltage="item.minCellVoltage" :soh="item.soh" :store-state="item.storeState"
						:charger-info-vo="item.chargerInfoVo" :class="box_num == index ? 'slect_box':''"
						:chgType='item.chgType' :batInfoOneVo="item.batInfoOneVo" :batInfoTwoVo='item.batInfoTwoVo'
						:chargerInfoOneVo="item.chargerInfoOneVo" :chargerInfoTwoVo="item.chargerInfoTwoVo"
						:showCodeNum='item.showCodeNum' @ExchangeMessage='ExchangeMessage' />
				</view>

			</scroll-view>


			<!--右侧抽屉 -->
			<uni-drawer ref="showRight" mode="right" :width="400" :mask-click="true" @change='changemask'>
				<scroll-view style="height: 100%;" scroll-y="true">
					<batteryDrawe :infodata="infodata" @closeDrawer="closeDrawer" @save='save'></batteryDrawe>


					</PublicDrawer>
				</scroll-view>
			</uni-drawer>
			<!-- 右侧抽屉结束 -->


			<!-- 顶部公共提示信息 -->
			<uni-popup ref="Exchangepopup" type="message">
				<uni-popup-message :type="popupType" :message="popupMessage" :duration="2000"></uni-popup-message>
			</uni-popup>
			<!-- 顶部提示信息结束-->
		</view>
	</view>
</template>

<script>
	import SubTitle from "../../../components/SubTitle/SubTitle.vue"
	import StorageInfo from "../components/StorageInfo.vue"
	import batteryDrawe from "../components/batteryDrawe.vue"
	import chargerDrawe from "../components/chargerDrawe.vue"
	name: 'manual'
	export default {
		components: {
			SubTitle,
			StorageInfo,
			batteryDrawe,
			chargerDrawe
		},
		props: ['storeInfoLists'],
		data() {
			return {
				popupMessage: '成功消息',
				popupType: 'success',
				isSlecte: true,
				box_num: -1, //记录选中了第几个
				name: 'batteryDrawe',
				props: ['infodata'],
				batteryInfoActive: 1, //0代表电池1代表充电机
				infodata: {}, //详情数据
			}
		},
		methods: {
			//抽屉
			drawer(item, index) {
				this.box_num = index;
				this.$refs.showRight.open();
				this.infodata = item;
				console.log(item, index, 'item')
			},
			//关闭抽屉
			closeDrawer() {
				this.batteryInfoActive = 1;
				this.box_num = -1;
				this.$refs.showRight.close();
			},
			//抽屉改变事件
			changemask(e) {
				if (!e) {
					this.closeDrawer()
				}
			},
			//顶部公共消息提示
			ExchangeMessage(type, message) {
				this.popupType = type
				this.popupMessage = message ? message : '后端接口404错误!'
				this.$refs.Exchangepopup.open()
			},
			//抽屉保存修改
			save(datas) {
				console.log(datas, 'e')
				let data = {
					chargerId: datas.cangnum,
					gunNo: datas.Guncall,
					powerNum: datas.powerNum,
					powerType: datas.setType
				}
				if (data.powerType == 0) {
					data.powerNum = undefined
				}
				if (data.gunNo == '' || data.powerType == '' || data.powerType && data.powerNum == "") {
					this.ExchangeMessage('warn', '请填写完整')
				} else {
					this.$http.getlimitPower(data).then(res => {
						this.ExchangeMessage(res.code === 0 ? 'success' : 'error',
							res.code === 0 ? '设置功率下发成功!' : '设置功率下发失败!')
						this.$refs.showRight.close();
					})
				}

			}
		}
	}
</script>

<style lang="scss" scoped>
	.main_manual {
		position: relative;

		.header_title {
			position: absolute;
			font-size: 12px;
			font-family: PingFang SC-Regular, PingFang SC;
			font-weight: 400;
			color: #414A63;
			right: 10px;
			top: 5px;

			.header_title_img {
				width: 14px;
				height: 14px;
				vertical-align: middle;
				margin-right: 5px;
				margin-top: -2px;
			}
		}

		.box_swiper {
			width: 1000px;
			height: 600px;
			background: #111827;
			padding: 20px;

			.scroll_x {
				width: 100%;
				height: 100%;
				// border: 1px solid red;

				/deep/ .uni-scroll-view-content {
					display: flex;

					view:last-child {
						.storage-item {
							margin-right: 0px;
						}
					}
				}
			}
		}
	}

	.slect_box {
		border: 1px solid #338150 !important;
	}

	.header_drawer_btn {
		display: flex;
		font-size: 14px;
		font-family: PingFang SC-Regular, PingFang SC;
		font-weight: 400;
		color: #FFFFFF;

		.header_drawer_btn_left {
			width: 60px;
			height: 32px;
			background: #263042;
			border-radius: 2px 0px 0px 2px;
			line-height: 32px;
			text-align: center;
		}

		.header_drawer_btn_right {
			line-height: 32px;
			text-align: center;
			width: 74px;
			height: 32px;
			background: #263042;
			border-radius: 0px 2px 2px 0px;
		}

		.active {
			color: black;
			background: #91FDB9;
		}
	}

	.drawer_main {
		// border: 1px solid red;
		padding-top: 20px;

	}
</style>
