<template>
	<view class="warehousingDtl">
		<commons-select-time v-model="req" @change="init"></commons-select-time>
		<view class="commons-title">
			<view class="">
				汇总
			</view>
		</view>
		<view style="margin: 0 30rpx;font-size: 12rpx;">
			<uni-table border stripe emptyText="暂无更多数据">
				<!-- 表头行 -->
				<uni-tr>
					<uni-th width="90rpx" align="left"></uni-th>
					<uni-th width="150rpx" align="left">件</uni-th>
					<uni-th width="150rpx" align="left">米</uni-th>
					<uni-th width="150rpx" align="left">金额</uni-th>
				</uni-tr>
				<!-- 表格数据行 -->
				<uni-tr>
					<uni-td><view class="pa-bg-2">合计</view>1</uni-td>
					<uni-td><view class="pa-bg-2">{{selectFabricWDetailsData.total}}</view></uni-td>
					<uni-td><view class="pa-bg-2">{{selectFabricWDetailsData.amountQuantity}}</view></uni-td>
					<uni-td><view class="pa-bg-2">{{selectFabricWDetailsData.amountTotal}}</view></uni-td>
				</uni-tr>
				<uni-tr v-for="(i,index) in selectFabricWDetailsData.details" :key="index">
					<uni-td>{{i.houseName}}</uni-td>
					<uni-td>{{i.count}}</uni-td>
					<uni-td>{{i.changeNum}}</uni-td>
					<uni-td>{{i.amount}}</uni-td>
				</uni-tr>
			</uni-table>
		</view>
		<view class="" v-for="i in dataList" :key="i.type" v-if="i.type != 3">
			<view class="commons-title">
				<view class="">
					{{i.name}}
				</view>
				<view>
					<uni-data-checkbox 
						v-model="i.houseType" 
						@change="(e)=>getSelectFabricWTypeDetails(e.detail.data.value,i.type)" 
						:localdata="warehouseList" 
					/>
				</view>
			</view>
			<view style="margin: 0 30rpx;font-size: 12rpx;">
				<uni-table border stripe emptyText="暂无更多数据">
					<!-- 表头行 -->
					<uni-tr>
						<uni-th width="90rpx" align="left"></uni-th>
						<uni-th width="150rpx" align="left">件</uni-th>
						<uni-th width="150rpx" align="left">米</uni-th>
						<uni-th width="150rpx" align="left">金额</uni-th>
					</uni-tr>
					<!-- 表格数据行 -->
					<uni-tr v-for="(j,jindex) in i.dtlList" :key="jindex">
						<uni-td>{{j.rurpose}}</uni-td>
						<uni-td>{{j.count}}</uni-td>
						<uni-td>{{j.changeNum}}</uni-td>
						<uni-td>{{j.amount}}</uni-td>
					</uni-tr>
				</uni-table>
			</view>
		</view>
	</view>
</template>

<script>
	import commonsSelectTime from '../../components/commons-select-time/index.vue'
	import {
		getInfo
	} from "@/util/api.js";
	export default {
		components: {
			commonsSelectTime
		},
		data() {
			return {
				warehouseList: [{
						text: "全部",
						value: '0'
					},
					{
						text: "一楼",
						value: '1'
					}, {
						text: "四楼",
						value: '2'
					}
				],
				req: {
					type: 0,
					time: [],
					beginTime: null,
					endTime: null,
				},
				headerNavType: 1,
				selectFabricWData: {},
				fabricStatisticsData: {},
				selectFabricWDetailsData: {},
				dataList:[
					{name:"直喷",type:0,houseType:'0',dtlList:[]},
					{name:"热转",type:1,houseType:'0',dtlList:[]},
					{name:"打纸",type:2,houseType:'0',dtlList:[]},
					{name:"墨水",type:3,houseType:'0',dtlList:[]},
					{name:"其他",type:4,houseType:'0',dtlList:[]}
				],
			}
		},
		onLoad(option) {
			const v = this
			v.init()
		},
		methods: {
			getSelectFabricWTypeDetails(houseType,technologyType){
				const v = this
				v.$post('/applet/selectFabricWTypeDetails',{...v.req,houseType,technologyType}).then(res=>{
					if(res.code == 200) {
						for (var i = 0; i < res.data.length; i++) {
							res.data[i].amount = res.data[i].amount * 1
						}
						v.dataList[technologyType].dtlList = res.data
					}
				})
			},
			init() {
				const v = this
				uni.showLoading({
					title: '加载中'
				});
				// v.getSelectFabricStatistics()
				v.getSelectFabricWDetails()
				for (var i = 0; i < v.dataList.length; i++) {
					v.getSelectFabricWTypeDetails(v.dataList[i].houseType,v.dataList[i].type)
				}
				setTimeout(()=>{
					uni.hideLoading();
				},1500)
			},
			toRouter(url) {
				console.log(123123)
				uni.navigateTo({
					url: '/pages' + url
				})
			},
			getSelectFabricWDetails() {
				const v = this
				v.$post('/applet/selectFabricWDetails', v.req).then(res => {
					v.selectFabricWDetailsData = res.data
				})
			},
			getSelectFabricStatistics() {
				const v = this
				v.$post('/applet/selectFabricStatistics', {
					type: v.fabricStatisticsType
				}).then(res => {
					v.fabricStatisticsData = res.data
				})
			},

		},
	}
</script>

<style lang="less">
	.uni-data-checklist {
		margin-top: 10rpx;
		padding: 16rpx 10rpx;
	}

	.uni-table-td {
		font-size: 24rpx !important;
	}

	.uni-data-checklist .checklist-group .checklist-box {
		margin-right: 20rpx !important;
	}

	.warehousingDtl {
		background-color: #f1f1f1;
		min-height: 100vh;
		color: #333;

		.header-banner {
			display: flex;
			justify-content: center;
			border-bottom: 1px solid #dcdcdc;

			view {
				width: 40%;
				text-align: center;
				height: 100rpx;
				line-height: 100rpx;
				color: #333;
				margin: 0 5%;
			}

			.active {
				color: #487CFF;
				border-bottom: 2px solid #487CFF;
			}
		}


	}
</style>
