<template>
	<view class="total">
		<view class="header-banner">
			<view @click="headerNavType = 1" :class="headerNavType == 1 ? 'active' : ''">
				面料
			</view>
			<view  @click="headerNavType = 2" :class="headerNavType == 2 ? 'active' : ''">
				墨水
			</view>
		</view>
		<view class=""  v-if="headerNavType == 2">
			<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">{{selectInkStatisticsData.total}}</view></uni-td>
						<uni-td><view class="pa-bg-2">{{selectInkStatisticsData.amountQuantity}}</view></uni-td>
						<uni-td><view class="pa-bg-2">{{selectInkStatisticsData.amountTotal}}</view></uni-td>
					</uni-tr>
					<uni-tr v-for="i in selectInkStatisticsData.details" :key="i.technologyType">
						<uni-td>{{i.houseName}}</uni-td>
						<uni-td>{{i.count}}</uni-td>
						<uni-td>{{i.quantity}}</uni-td>
						<uni-td>{{i.amount}}</uni-td>
					</uni-tr>
				</uni-table>
			</view>
			<commons-select-time @change="timeInit" v-model="req"></commons-select-time>
			<view class="commons-title">
				<view class=""  @click="toRouter('/total/warehouseDtl?type=2')">
					出库汇总 》
				</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">{{selectInkEWData.total}}</view></uni-td>
						<uni-td><view class="pa-bg-2">{{selectInkEWData.amountQuantity}}</view></uni-td>
						<uni-td><view class="pa-bg-2">{{selectInkEWData.amountTotal}}</view></uni-td>
						
					</uni-tr>
					<uni-tr v-for="(i,index) in selectInkEWData.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="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">{{selectInkEWData2.total}}</view></uni-td>
						<uni-td><view class="pa-bg-2">{{selectInkEWData2.amountQuantity}}</view></uni-td>
						<uni-td><view class="pa-bg-2">{{selectInkEWData2.amountTotal}}</view></uni-td>
						
					</uni-tr>
					<uni-tr v-for="(i,index) in selectInkEWData2.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>
		<view class="" v-if="headerNavType == 1">
			<view class="commons-title">
				<view class="" @click="toRouter('/total/summary')">
					库存汇总 》
				</view>
				<view>
					<uni-data-checkbox @change="getSelectFabricStatistics" v-model="fabricStatisticsType" :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>
						<uni-td><view class="pa-bg-2">合计</view>1</uni-td>
						<uni-td><view class="pa-bg-2">{{fabricStatisticsData.total}}</view></uni-td>
						<uni-td><view class="pa-bg-2">{{fabricStatisticsData.amountQuantity}}</view></uni-td>
						<uni-td><view class="pa-bg-2">{{fabricStatisticsData.amountTotal}}</view></uni-td>
					</uni-tr>
					<uni-tr v-for="i in fabricStatisticsData.details" :key="i.technologyType">
						<uni-td>{{technologyTypeList[i.technologyType]}}</uni-td>
						<uni-td>{{i.count}}</uni-td>
						<uni-td>{{i.quantity}}</uni-td>
						<uni-td>{{i.amount}}</uni-td>
					</uni-tr>
				</uni-table>
			</view>
			<commons-select-time @change="timeInit" v-model="req"></commons-select-time>
			<view class="commons-title">
				<view class="" @click="toRouter('/total/warehouseDtl')">
					出库汇总 》
				</view>
				<view>
					<uni-data-checkbox v-model="companyType" :localdata="companyList" />
				</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 v-if="companyType == 1" width="150rpx" align="left">出库(件)</uni-th>
						<uni-th v-if="companyType == 0" width="150rpx" align="left">出库(金额)</uni-th>
						<uni-th v-if="companyType == 2" width="150rpx" align="left">出库(米)</uni-th>
						<uni-th v-if="companyType == 3" 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 v-if="companyType == 1"><view class="pa-bg-2">{{selectFabricEWData.total}}</view></uni-td>
						<uni-td v-if="companyType == 0"><view class="pa-bg-2">{{selectFabricEWData.amountTotal}}</view></uni-td>
						<uni-td v-if="companyType == 2"><view class="pa-bg-2">{{selectFabricEWData.amountQuantity}}</view></uni-td>
						<uni-td v-if="companyType == 3"><view class="pa-bg-2">{{selectFabricEWData.square}}</view></uni-td>
						
						<uni-td><view class="pa-bg-2">{{(companyType == 3) ? selectFabricEWData.quantity : '-'}}</view></uni-td>
						
					</uni-tr>
					<uni-tr v-for="i in selectFabricEWData.details" :key="i.technologyType">
						<uni-td>{{technologyTypeList[i.technologyType]}}</uni-td>
						<uni-td v-if="companyType == 1">{{i.count}}</uni-td>
						<uni-td v-if="companyType == 0">{{i.amount}}</uni-td>
						<uni-td v-if="companyType == 2">{{i.changeNum}}</uni-td>
						<uni-td v-if="companyType == 3">{{i.square}}</uni-td>
						<uni-td>{{(companyType == 3) ? i.quantity : '-'}}</uni-td>
						
					</uni-tr>
				</uni-table>
			</view>
			<view class="commons-title">
				<view class="" @click="toRouter('/total/warehousingDtl')">
					入库汇总 》
				</view>
				<view>
					<uni-data-checkbox @change="getSelectFabricW" v-model="selectFabricWType" :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>
						<uni-td><view class="pa-bg-2">合计</view>1</uni-td>
						<uni-td><view class="pa-bg-2">{{selectFabricWData.total}}</view></uni-td>
						<uni-td><view class="pa-bg-2">{{selectFabricWData.amountQuantity}}</view></uni-td>
						<uni-td><view class="pa-bg-2">{{selectFabricWData.amountTotal}}</view></uni-td>
					</uni-tr>
					<uni-tr v-for="i in selectFabricWData.details" :key="i.technologyType">
						<uni-td>{{technologyTypeList[i.technologyType]}}</uni-td>
						<uni-td>{{i.count}}</uni-td>
						<uni-td>{{i.totalQty}}</uni-td>
						<uni-td>{{i.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 {
				companyType:0,
				companyList:[
					{
						text:"金额",
						value:0
					},
					{
						text:"件",
						value:1
					},
					{
						text:"米",
						value:2
					},
					{
						text:"平方",
						value:3
					},
				],
				warehouseList:[{
					text:"全部",
					value:0
				},
				{
					text:"一楼",
					value:1
				},{
					text:"四楼",
					value:2
				}],
				req:{
					type: 0,
					time: [],
					beginTime: null,
					endTime: null,
				},
				technologyTypeList:["直喷","热转","打纸","墨水","其他"],
				headerNavType:1,
				fabricStatisticsType:0,
				selectFabricWType:0,
				selectFabricEWType:0,
				selectFabricWData:{},
				fabricStatisticsData:{},
				selectFabricEWData:{},
				selectInkStatisticsData:{},
				selectInkEWData:{},
				selectInkEWData2:{},
			}
		},
		onLoad(option) {
			const v = this
			v.getSelectFabricStatistics()
			v.getSelectFabricW()
			v.getSelectFabricEW()
			v.getSelectInkStatistics()
			v.getSelectInkEW()
			v.getSelectInkEW2()
		},
		methods: {
			timeInit(){
				this.getSelectFabricEW()
				this.getSelectFabricW()
				this.getSelectInkEW()
				this.getSelectInkEW2()
			},
			timeChangeFn(){
				console.log(this.req)
			},
			toRouter(url){
				console.log(123123)
				uni.navigateTo({
					url: '/pages' + url
				})
			},
			//出库汇总
			getSelectFabricEW(){
				const v = this
				v.$post('/wx/inventory/selectFabricEW',{houseType:v.selectFabricEWType,...v.req}).then(res=>{
					v.selectFabricEWData = res.data
				})
			},
			//入库
			getSelectFabricW(){
				const v = this
				v.$post('/wx/inventory/selectFabricW',{houseType:v.selectFabricWType,...v.req}).then(res=>{
					v.selectFabricWData = res.data
				})
			},
			//总
			getSelectFabricStatistics(){
				const v = this
				v.$post('/wx/inventory/selectFabricStatistics',{type:v.fabricStatisticsType}).then(res=>{
					v.fabricStatisticsData = res.data
				})
			},
			//墨水 汇总
			getSelectInkStatistics(){
				const v = this
				v.$post('/wx/inventory/selectInkStatistics',{}).then(res=>{
					v.selectInkStatisticsData = res.data
				})
			},
			//墨水 出库
			getSelectInkEW(){
				const v = this
				v.$post('/wx/inventory/selectInkEW',{...v.req,EWType:1}).then(res=>{
					v.selectInkEWData = res.data
				})
			},
			//墨水 入库
			getSelectInkEW2(){
				const v = this
				v.$post('/wx/inventory/selectInkEW',{...v.req,EWType:2}).then(res=>{
					v.selectInkEWData2 = res.data
				})
			},
			
		},
	}
</script>

<style lang="less">
	.commons-time-box{
		display: flex;
		height: 50rpx;
		line-height: 50rpx;
		font-size: 24rpx;
		margin:30rpx;
		border:1px solid #dcdcdc;
		border-radius: 8rpx;
		.time-box{
			width: 15%;
			text-align: center;
		}
		.time-box-icon{
			width: 10%;
		}
		.time-box.active{
			background-color: #487CFF;
			color: #fff;
		}
	}
	.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;
	}
	.total {
		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>
