<!--
 * @Author: zwq
 * @Date: 2023-08-21 14:26:23
 * @LastEditors: zwq
 * @LastEditTime: 2024-08-19 09:38:57
 * @Description:
-->
<template>
	<div class="app-container">
		<search-bar
			:formConfigs="formConfig"
			ref="searchBarForm"
			@headBtnClick="buttonClick" />
		<div class="tips">
			<el-tag
				effect="dark"
				color="#16DC09"
				style="border: none">
				满
			</el-tag>
			<el-tag effect="dark" color="#d3d3d3" style="border: none">空</el-tag>
			<el-tag effect="dark" color="#ff0000" style="border: none">不可用</el-tag>
		</div>
		<div class="mainbody">
			<div v-for="i in listQuery.total" :key="i" class="div-row">
						<el-row type="flex" class="flex-warp">
							<div
								class="dashboard-layout-item"
								v-for="j in wareData.slice((i - 1) * 30, i * 30)"
								:key="j.id + j.finishProductCode"
								:title="j.finishProductName">
								<el-popover
									placement="top-start"
									:title="j.finishProductName"
									width="200"
									trigger="hover">
									库位状态:
									{{
										j.deactivate === 1
											? ['空', '满'][j.finishProductWarehouseState]
											: '不可用'
									}}
									<div
										slot="reference"
										class="hoverDiv"
										:style="{
											cursor:
												j.deactivate === 0 || j.finishProductWarehouseState === 1
													? 'not-allowed'
													: 'pointer',
									background:
										j.deactivate === 1
											? bgColor[j.finishProductWarehouseState]
											: '#ff0000',
										}" />
								</el-popover>
							</div>
				</el-row>
			</div>
		</div>
	</div>
</template>

<script>
import { getWarehouseStorehouseList,
  exportFinishProductWarehouseExcel
} from "@/api/fpw/finishProductWarehouse";
import basicPage from '../mixins/basic-page';

export default {
	mixins: [basicPage],
	data() {
		return {
			urlOptions: {
				getDataListURL: getWarehouseStorehouseList,
				exportURL: exportFinishProductWarehouseExcel,
			},
			listQuery: {
				total: 0,
			},
			wareData: [],
			bgColor: ['#d3d3d3', '#16DC09'], //空，满
			formConfig: [
				// {
				// 	type: 'select',
				// 	label: '选择层',
				// 	selectOptions: [
				// 		{ id: 1, name: '1' },
				// 		{ id: 2, name: '2' },
				// 		{ id: 3, name: '3' },
				// 		{ id: 4, name: '4' },
				// 	],
				// 	param: 'value',
				// 	filterable: true,
				// 	defaultSelect: 1,
				// 	clearable: false,
				// },
				{
					type: 'button',
					btnName: '刷新',
					name: 'search',
					color: 'primary',
				},
				{
					type: 'button',
					btnName: '下载',
					name: 'export',
					plain: true,
					color: 'primary',
				},
			],
		};
	},
	components: {},
	created() {},
	methods: {
		// 获取数据列表
		getDataList() {
			this.dataListLoading = true;
			this.wareData = [],
				this.urlOptions.getDataListURL(this.listQuery).then((response) => {
          this.wareData = response.data
					this.listQuery.total = Math.ceil(response.data.length / 30);
					this.dataListLoading = false;
				});
		},
		buttonClick(val) {
			switch (val.btnName) {
				case 'search':
					this.getDataList();
					break;
				case 'export':
					this.handleExport(this.aId);
					break;
				default:
					console.log(val);
			}
		},
	},
};
</script>

<style lang="scss" scoped>
.mainbody {
	display: flex;
	flex-direction: column;
	justify-content: space-around;
	min-width: 80vw;
	border-radius: 5px;
	padding-top: 25px;
}
.flex-warp {
	flex-wrap: nowrap;
}
.div-row{
	&:nth-child(2n) {
		margin-bottom: 30px;
	}
}
.dashboard-layout-item {
	width: 30px;
	height: 30px;
	background-color: #d3d3d3;
	border-radius: 2px;
	margin: 0 6px 8px 0;
	position: relative;
	&:nth-child(2n) {
		margin-right: 18px;
	}
	&:first-child {
		margin-left: 30px;
	}
	&:last-child {
		margin-right: 30px;
	}
}
.hoverDiv {
	width: 100%;
	height: 30px;
	&:hover {
    border: 1px #000000 dashed;
		transform: scale(1.3);
	}
}
.tips {
	position: absolute;
	top: 22px;
	right: 120px;
}
</style>
