<!-- 库存报表 -->
<template>
	<div class="container">
		<Tabs :value="tabName" @on-click="tabClick">
			<TabPane label="盘盈亏单" name="1">
				<my-table
					ref="pykd"
					:data="data1"
					:columns="columns1"
					:table-filter="tableFilter1"
					:table-page="params1"
					@event-handle="eventHandle"
					@on-change="changePage"
				></my-table>
			</TabPane>
			<TabPane label="入库序时簿" name="2">
				<my-table
					ref="rkxsb"
					:data="data2"
					:columns="columns2"
					:table-filter="tableFilter2"
					:table-page="params2"
					@event-handle="eventHandle"
					@on-change="changePage"
				></my-table>
			</TabPane>
			<TabPane label="* 领料序时簿" name="3">
				<div style="overflow: hidden;">
					<Button :type="params7.materialType ? 'default' : 'primary'" @click.native="getAlldata">全部</Button>
					<date-select v-model="params7" @change="selectTime"></date-select>

				</div>
				<div class="total-warp">
					<div class="left-total" style="padding-right: 1px">
						<div class="total-header" @click="dataModalTypeFn">
							<div class="title">面料</br>领用</div>
							<div>卷数</br><span>{{pickingStatisticsData.fabricStatistics.total}}</span></div>
							<div>米数</br><span>{{pickingStatisticsData.fabricStatistics.length}}</span></div>
							<div>面积</br><span>{{pickingStatisticsData.fabricStatistics.measureArea}}</span></div>
							<div>金额</br><span>{{pickingStatisticsData.fabricStatistics.money}}</span></div>
						</div>
						<div v-if="dataModalType">
							<Table height="175" 
								@on-expand="expandChange"
								@on-row-click="moshuiTbleLineCk2" 
								:columns="columns7" 
								:row-class-name="rowClassName"
								:data="data7">
							 </Table>
						</div>
					</div>
					<div class="right-total">
						<div class="total-header"  @click="dataModalTypeFn">
							<div class="title">墨水</br>领用</div>
							<div>件数</br><span>{{pickingStatisticsData.inkStatistics.total}}</span></div>
							<div>公斤</br><span>{{pickingStatisticsData.inkStatistics.weight}}</span></div>
							<div>金额</br><span>{{pickingStatisticsData.inkStatistics.money}}</span></div>
						</div>
						<div  v-if="dataModalType">
							<Table  height="175" @on-row-click="moshuiTbleLineCk" :row-class-name="(row,index)=>rowClassName2('moshui',row,index)" :columns="columns8" :data="data8"></Table>
						</div>
					</div>
				</div>
				<div class="h2">
					领料详情<span v-if="selectMaterialProperties">-{{selectMaterialProperties}}<span v-if="selectUserName">-{{selectUserName}}</span></span>
				</div>
				<div style="margin:10px 0">
					<RadioGroup v-model="params7.type" @on-change="radioChange">
						<Radio label="0">全部 
							(<span style="color:red">
								{{radioTotal.cancellingStocks*1 + radioTotal.exWarehouse*1 + radioTotal.supplementaryDelivery*1}}
							</span>)
						</Radio>
						<Radio label="20">正常出库(<span style="color:red">{{radioTotal.exWarehouse}}</span>)</Radio>
						<Radio label="23">补出库(<span style="color:red">{{radioTotal.supplementaryDelivery}}</span>)</Radio>
						<Radio label="15">退库(<span style="color:red">{{radioTotal.cancellingStocks}}</span>)</Radio>
					</RadioGroup>
				</div>
				<Table :height="table3Hiehgt" :columns="columns3" :data="data3"></Table>
				<div style="text-align:center;margin-top:20px">
					<Page :current="params7.pageNum" @on-change="changePage3" :total="params3.total" />
				</div>
				<!-- <div style="height:calc(100vh - 516px)">
					<my-table
						ref="llsxb"
						:data="data3"
						:columns="columns3"
						:table-page="params3"
						@event-handle="eventHandle"
						@on-change="changePage3"
						:table-filter="tableFilter3"
					></my-table>
				</div> -->
			</TabPane>
			<TabPane label="物料收发汇总" name="4">
				<my-table
					ref="wlsfhz"
					:data="data4"
					:columns="columns4"
					:border="true"
					:table-filter="tableFilter4"
					@event-handle="eventHandle"
					:is-show-page="false"
					@on-change="changePage"
				></my-table>
			</TabPane>
			<TabPane label="物料月汇总" name="5">
				<my-table
					:data="data5"
					:columns="columns5"
					:border="true"
					:table-filter="tableFilter5"
					:table-page="params5"
					@event-handle="eventHandle"
					@on-change="changePage"
				></my-table>
			</TabPane>
			<TabPane label="物料进出信息" name="6">
				<my-table
					ref="table"
					:data="data6"
					:columns="columns6"
					:table-filter="tableFilter6"
					@event-handle="eventHandle"
					:is-show-page="false"
					@on-change="changePage"
				></my-table>
			</TabPane>
		</Tabs>
		<my-modal-material
			ref="materialModal"
			:multiple="true"
			v-model="show"
			@getselectedList="getselectedList"
		></my-modal-material>
	</div>
</template>

<script>
import { exportExcel } from '@/libs/util'
import {
	GetMonthStockCheck,
	GetStockInDocumentList,
	GetStockTakeDocumentList,
	GetMaterialStockInOutSum,
	GetMaterialMonthSum,
	GetStockWaterInOut,
} from '@/api/stock'
import MyTable from '_c/my-table/my-table'
import MyModalMaterial from '_c/my-modal-form/my-modal-material'
// import TreeTable from 'iview-tree-table'
import axios from 'axios'
import  dateSelect  from '@/components/dateSelect/dateSelect'
import expandRow from './table-expand.vue';
export default {
	name: 'store_report',
	components: {
		MyTable,
		MyModalMaterial,
		// TreeTable,
		expandRow,
    	dateSelect
	},
	data() {
		return {
			tabName: '1',
			formData: {},
			show: false,
			data1: [],
			data2: [],
			data3: [],
			data4: [],
			data5: [],
			data6: [],
      		data7: [],
			data8: [],
			columns1: [
				{
					title: '序号',
					type: 'index',
					width: 60,
					align: 'center',
				},
				{
					title: '盘点日期',
					key: 'checkTime',
					minWidth: 150,
				},
				{
					title: '盘点人',
					key: 'userName',
					minWidth: 150,
				},
				{
					title: '审核日期',
					key: 'approvalTime',
					minWidth: 150,
				},
				{
					title: '物料编码',
					key: 'materialCode',
					minWidth: 150,
				},
				{
					title: '物料名称',
					key: 'materialName',
					minWidth: 150,
				},
				{
					title: '物料规格',
					key: 'spec',
					minWidth: 150,
				},
				{
					title: '单位',
					key: 'untilName',
					minWidth: 150,
				},
				{
					title: '账存数量',
					key: 'stockQty',
					minWidth: 150,
				},
				{
					title: '实存数量',
					key: 'actualQty',
					minWidth: 150,
				},
				{
					title: '盘盈/亏',
					key: 'checkDiffQty',
					minWidth: 150,
				},
				{
					title: '单价',
					key: 'price',
					minWidth: 150,
				},
				{
					title: '盘盈/亏金额',
					key: 'checkDiffAmout',
					minWidth: 150,
				},
			],
			columns2: [
				{
					title: '序号',
					type: 'index',
					width: 60,
					align: 'center',
				},
				{
					title: '物料编码',
					key: 'materialCode',
					minWidth: 150,
				},
				{
					title: '物料名称',
					key: 'materialName',
					minWidth: 150,
				},
				{
					title: '物料规格',
					key: 'spec',
					minWidth: 150,
				},
				{
					title: '采购合同号',
					key: 'purchaseBillNo',
					minWidth: 150,
				},
				{
					title: '供应商',
					key: 'supplierName',
					minWidth: 150,
				},
				{
					title: '单位',
					key: 'stockUnitID',
					minWidth: 150,
				},
				{
					title: '应收数量',
					key: 'quantity',
					minWidth: 150,
					render:(h,p)=>{
						return h('span',{},
							p.row.quantity * 1
						)
					}
				},
				{
					title: '单价',
					key: 'price',
					minWidth: 150,
				},
				{
					title: '到货日期',
					key: 'createTime',
					minWidth: 150,
				},
				{
					title: '到货数量',
					key: 'changeNum',
					minWidth: 150,
					render:(h,p)=>{
						return h('span',{},
							p.row.changeNum * 1
						)
					}
				},
				{
					title: '金额',
					key: 'amount',
					minWidth: 150,
					render:(h,p)=>{
						return h('span',{},
							p.row.amount * 1
						)
					}
				},
			],
			materialTypeList:['直喷','热转','打纸','墨水','其他'],
			columns3: [
				{
					title: '序号',
					type: 'index',
					width: 60,
					align: 'center',
				},
				{
					title: '日期',
					key: 'createdTime',
					minWidth: 150,
				},
				{
					title: '物料类型',
					key: 'materialType',
					minWidth: 150,
					render:(h,p)=>{
						const v = this
						return h('span',v.materialTypeList[p.row.materialType])
					}
					
				},
				{
					title: '物料编码',
					key: 'materialCode',
					minWidth: 150,
				},
				{
					title: '物料名称',
					key: 'materialName',
					minWidth: 150,
				},
				{
					title: '物料规格',
					key: 'materialSpec',
					minWidth: 150,
				},
				{
					title: '单位',
					key: 'materialUnit',
					minWidth: 150,
				},
				{
					title: '领料数量',
					key: 'changeNum',
					minWidth: 150,
				},
				{
					title: '单价',
					key: 'materialPrice',
					minWidth: 150,
				},
				{
					title: '金额',
					key: 'money',
					minWidth: 150,
				},
				{
					title: '人员',
					key: 'realName',
					minWidth: 150,
				},
				{
					title: '备注',
					key: 'remark',
					minWidth: 150,
				},
			],
			columns4: [
				{
					title: '会计期间',
					key: 'accPeriod',
					minWidth: 150,
				},
				{
					title: '物料编码',
					key: 'materialCode',
					minWidth: 150,
				},
				{
					title: '物料名称',
					key: 'materialName',
					minWidth: 150,
				},
				{
					title: '单位',
					key: 'untilName',
					minWidth: 100,
				},
				{
					title: '初期存结',
					align: 'center',
					children: [
						{
							title: '单价',
							key: 'beginBalancePrice',
							minWidth: 100,
						},
						{
							title: '数量',
							key: 'beginBalanceQty',
							minWidth: 100,
						},
						{
							title: '金额',
							key: 'beginBalanceAmount',
							minWidth: 100,
						},
					],
				},
				{
					title: '本期收入',
					align: 'center',
					children: [
						{
							title: '单价',
							key: 'curIncomePrice',
							minWidth: 100,
						},
						{
							title: '数量',
							key: 'curIncomeQty',
							minWidth: 100,
						},
						{
							title: '金额',
							key: 'curIncomeAmount',
							minWidth: 100,
						},
					],
				},
				{
					title: '本期发出',
					align: 'center',
					children: [
						{
							title: '单价',
							key: 'curSendPrice',
							minWidth: 100,
						},
						{
							title: '数量',
							key: 'curSendQty',
							minWidth: 100,
						},
						{
							title: '金额',
							key: 'curSendAmount',
							minWidth: 100,
						},
					],
				},
				{
					title: '本期存结',
					align: 'center',
					children: [
						{
							title: '单价',
							key: 'curBalancePrice',
							minWidth: 100,
						},
						{
							title: '数量',
							key: 'curBalanceQty',
							minWidth: 100,
						},
						{
							title: '金额',
							key: 'curBalanceAmount',
							minWidth: 100,
						},
					],
				},
			],
			columns_4: [
				{
					title: '会计期间',
					key: 'accPeriod',
					minWidth: 150,
				},
				{
					title: '物料编码',
					key: 'materialCode',
					minWidth: 150,
				},
				{
					title: '物料名称',
					key: 'materialName',
					minWidth: 150,
				},
				{
					title: '单位',
					key: 'untilName',
					minWidth: 100,
				},
				{
					title: '单价',
					key: 'beginBalancePrice',
					minWidth: 100,
				},
				{
					title: '数量',
					key: 'beginBalanceQty',
					minWidth: 100,
				},
				{
					title: '金额',
					key: 'beginBalanceAmount',
					minWidth: 100,
				},
				{
					title: '单价',
					key: 'curIncomePrice',
					minWidth: 100,
				},
				{
					title: '数量',
					key: 'curIncomeQty',
					minWidth: 100,
				},
				{
					title: '金额',
					key: 'curIncomeAmount',
					minWidth: 100,
				},
				{
					title: '单价',
					key: 'curSendPrice',
					minWidth: 100,
				},
				{
					title: '数量',
					key: 'curSendQty',
					minWidth: 100,
				},
				{
					title: '金额',
					key: 'curSendAmount',
					minWidth: 100,
				},
				{
					title: '单价',
					key: 'curBalancePrice',
					minWidth: 100,
				},
				{
					title: '数量',
					key: 'curBalanceQty',
					minWidth: 100,
				},
				{
					title: '金额',
					key: 'curBalanceAmount',
					minWidth: 100,
				},
			],
			columns5: [
				{
					title: '物料编码',
					key: 'materialCode',
					align: 'center',
					minWidth: 150,
				},
				{
					title: '物料名称',
					key: 'materialName',
					align: 'center',
					minWidth: 150,
				},
				{
					title: '实时库存',
					key: 'quantity',
					align: 'center',
					minWidth: 150,
				},
				{
					title: '单位',
					key: 'untilName',
					align: 'center',
					minWidth: 100,
				},
				{
					title: '领用数量',
					align: 'center',
					children: [
						{
							title: this.$dayjs().format('YYYY-MM'),
							key: 'firstTakeQty',
							align: 'center',
							minWidth: 100,
						},
						{
							title: this.$dayjs(
								new Date().setMonth(new Date().getMonth() - 1)
							).format('YYYY-MM'),
							key: 'secTakeQty',
							align: 'center',
							minWidth: 100,
						},
						{
							title: this.$dayjs(
								new Date().setMonth(new Date().getMonth() - 2)
							).format('YYYY-MM'),
							key: 'threeTakeQty',
							align: 'center',
							minWidth: 100,
						},
					],
				},
				{
					title: '近三月平均用量',
					key: 'nearlyAverTakeQty',
					align: 'center',
					minWidth: 100,
				},
				{
					title: '采购周期（天）',
					key: 'safetyWarnDay',
					align: 'center',
					minWidth: 100,
				},
				{
					title: '单次申购数量',
					key: 'averPurchaseQty',
					align: 'center',
					minWidth: 100,
				},
			],
			columns6: [
				{
					title: '月份',
					key: 'month',
					minWidth: 100,
				},
				{
					title: '日期',
					key: 'date',
					minWidth: 150,
				},
				{
					title: '单据号',
					key: 'billNo',
					minWidth: 150,
				},
				{
					title: '物料编码',
					key: 'materialCode',
					minWidth: 150,
				},
				{
					title: '物料名称',
					key: 'materialName',
					minWidth: 150,
				},
				{
					title: '物料规格',
					key: 'spec',
					minWidth: 150,
				},
				{
					title: '单位',
					key: 'unitName',
					minWidth: 150,
				},
				{
					title: '类型',
					key: 'billTypeStr',
					minWidth: 150,
				},
				{
					title: '收入数量',
					key: 'incomeQty',
					minWidth: 150,
				},
				{
					title: '收入单价',
					key: 'incomePrice',
					minWidth: 150,
				},
				{
					title: '收入金额',
					key: 'incomeAmount',
					minWidth: 150,
				},
				{
					title: '发出数量',
					key: 'sendQty',
					minWidth: 150,
				},
				{
					title: '发出单价',
					key: 'sendPrice',
					minWidth: 150,
				},
				{
					title: '发出金额',
					key: 'sendAmount',
					minWidth: 150,
				},
				{
					title: '结存数量',
					key: 'balanceQty',
					minWidth: 150,
				},
				{
					title: '结存金额',
					key: 'balanceAmount',
					minWidth: 150,
				},
			],
			columns7: [
				{
					type: 'expand',
					width: 50,
					render: (h, params) => {
						return h(expandRow, {
							props: {
								row: params,
								params :this.params7
							},
							on:{
								'on-row-click': (item)=>{
									console.log(params)
									this.params7.userId = item.userId
									this.selectUserName = item.name
									this.selectMaterialProperties = params.row.name
									this.params7.materialType = params.row.materialType
									this.params7.pageIndex = 1
									this.params7.pageNum = 1
									this.getPickingPage()
								}
							},
						})
					}
				},
				{
					title: '领料人',
					key: 'name',
					minWidth: 100,
				},
				{
					title: '卷数',
					key: 'total',
					minWidth: 100,
				},
				{
					title: '米数',
					key: 'length',
					minWidth: 100,
				},
				{
					title: '面积',
					key: 'measureArea',
					minWidth: 100,
				},
				{
					title: '金额',
					key: 'money',
					minWidth: 100,
				},
			],
			columns8: [
				{
					title: '领料人',
					key: 'userName',
					minWidth: 100,
				},
				{
					title: '件数',
					key: 'total',
					minWidth: 100,
				},
				{
					title: '公斤',
					key: 'weight',
					minWidth: 100,
				},
				{
					title: '金额',
					key: 'money',
					minWidth: 100,
				},
			],
			tableFilter1: [
				{
					name: 'Input',
					value: 'workKey',
					placeholder: '请输入关键字',
				},
				{
					name: 'DatePicker',
					value: 'yearMonth',
					placeholder: '请选择日期',
					type: 'month',
					unClearable: true,
				},
				{
					name: 'Button',
					type: 'primary',
					text: '查询',
					e: 'search',
				},
				{
					name: 'Button',
					type: 'primary',
					text: '导出Excel',
					e: 'export',
				},
			],
			tableFilter2: [
				{
					name: 'Input',
					value: 'workKey',
					placeholder: '请输入关键字',
				},
				{
					name: 'DatePicker',
					value: 'yearMonth',
					placeholder: '请选择日期',
					type: 'month',
					unClearable: true,
				},
				{
					name: 'Button',
					type: 'primary',
					text: '查询',
					e: 'search',
				},
				{
					name: 'Button',
					type: 'primary',
					text: '导出Excel',
					e: 'export',
				},
			],
			tableFilter3: [
				// {
				// 	name: 'Input',
				// 	value: 'workKey',
				// 	placeholder: '请输入关键字',
				// },
				// {
				// 	name: 'DatePicker',
				// 	value: 'yearMonth',
				// 	placeholder: '请选择日期',
				// 	unClearable: true,
				// 	type: 'month',
				// },
				// {
				// 	name: 'Button',
				// 	type: 'primary',
				// 	text: '查询',
				// 	e: 'search',
				// },
				// {
				// 	name: 'Button',
				// 	type: 'primary',
				// 	text: '导出Excel',
				// 	e: 'export',
				// },
			],
			tableFilter4: [
				{
					name: 'Input',
					value: 'workKey',
					placeholder: '请输入关键字',
				},
				{
					name: 'DatePicker',
					value: 'yearMonth',
					placeholder: '请选择日期',
					type: 'month',
					unClearable: true,
				},
				{
					name: 'Button',
					type: 'primary',
					text: '查询',
					e: 'search',
				},
				{
					name: 'Button',
					type: 'primary',
					text: '导出Excel',
					e: 'export',
				},
			],
			tableFilter5: [
				{
					name: 'Input',
					value: 'workKey',
					placeholder: '请输入关键字',
				},
				{
					name: 'Button',
					type: 'primary',
					text: '查询',
					e: 'search',
				},
				{
					name: 'Button',
					type: 'primary',
					text: '导出Excel',
					e: 'export',
				},
			],
			tableFilter6: [
				{
					name: 'Input',
					value: 'materialCode',
					placeholder: '请选择物料',
					icon: 'ios-add-circle-outline',
					e: 'showMaterial',
				},
				{
					name: 'DatePicker',
					value: 'yearMonth',
					placeholder: '请选择日期',
					type: 'month',
					unClearable: true,
				},
				{
					name: 'Button',
					type: 'primary',
					text: '查询',
					e: 'search',
				},
				{
					name: 'Button',
					type: 'primary',
					text: '导出Excel',
					e: 'export',
				},
			],
			params1: {
				pageIndex: 1,
				pageSize: 20,
				total: 0,
			},
			params2: {
				pageIndex: 1,
				pageSize: 20,
				total: 0,
				keyword:null,
			},
			params3: {
				pageNum: 1,
				pageSize: 10,
				total: 0,
				beginTime:null,
				endTime:null,
				pageIndex:1,
				type:'0',
				userId:null,
				materialType:null,
			},
			params4: {},
			params5: {
				pageIndex: 1,
				pageSize: 20,
				total: 0,
				
			},
			params6: {},
      		params7: {
				pageNum: 1,
				pageSize: 10,
				total: 0,
				beginTime:null,
				endTime:null,
				pageIndex:1,
				type:'0',
				userId:null,
				materialType:null,
			},
			pickingStatisticsData:{
				fabricStatistics:{
				},
				inkDetails:[],
				fabricTree:[],
				inkStatistics:{},
			},
			selectUserName:null,
			selectMaterialProperties:null,
			table3Hiehgt:300,
			radioTotal:{},
			dataModalType:true,
		}
		
	},
	methods: {
		dataModalTypeFn(){
			this.dataModalType = !this.dataModalType
			if(this.dataModalType){
				this.table3Hiehgt = document.body.clientHeight - 630
			}else{
				this.table3Hiehgt = document.body.clientHeight - 450
			}
			
		},
		rowClassName2(type,row,index){
			if(row.userId == this.params7.userId && this.selectMaterialProperties == '墨水'){
				return 'table-info-row';
			}
		},
		rowClassName(row,index){
			if(row.name == this.selectMaterialProperties){
				return 'table-info-row';
			}
		},
		getAlldata(){
			this.params7.materialType = null
			this.params7.userId = null
			this.params7.pageNum = 1
			this.params7.pageIndex = 1
			this.selectUserName = null
			this.selectMaterialProperties = null
		},
		expandChange(){
			
		},
		moshuiTbleLineCk2(row,index){
			this.params7.materialType = row.materialType
			this.selectMaterialProperties = row.name
			this.params7.pageNum = 1
			this.params7.pageIndex = 1
			this.selectUserName = null
			this.params7.userId = null
			this.getPickingPage()
		},
		moshuiTbleLineCk(row,index){
			this.params7.userId = row.userId
			this.selectUserName = row.userName
			this.params7.pageNum = 1
			this.params7.pageIndex = 1
			this.selectMaterialProperties = '墨水'
			this.params7.materialType = '3'
			this.getPickingPage()
		},
		radioChange(){
			this.params7.pageNum = 1
			this.params7.pageIndex = 1
			this.getPickingPage()
		},
    	selectTime(){
			this.params7.materialType = null
			this.params7.userId = null
			this.selectUserName = null
			this.selectMaterialProperties = null
			this.totalInit()
		},
		changePage3(e){
			this.params7.pageNum = e
			axios.post('/cloudApi/stockWater/getPickingPage', {
					...this.params7,
				})
				.then((res) => {
					this.data3 = res.data.data.records
					this.params7.total = res.data.data.total
					console.log(this.params3.total)
					
				})
		},
		totalInit(){
			if(this.dataModalType){
				this.table3Hiehgt = document.body.clientHeight - 630
			}else{
				this.table3Hiehgt = document.body.clientHeight - 450
			}
			axios.post('/cloudApi/stockWater/getPickingStatistics', {
					...this.params7,
				})
				.then((res) => {
					this.pickingStatisticsData.fabricStatistics = res.data.data.fabricStatistics || {
						total:0,
						measureArea:0,
						money:0,
						length:0
					}
					this.pickingStatisticsData.inkStatistics = res.data.data.inkStatistics || {
						total:0,
						money:0,
						weight:0,
					}
					
					this.data7 = res.data.data.fabricTree
					this.data8 = res.data.data.inkDetails
					
				})
			
			axios.post('/cloudApi/stockWater/getPickingStockChangeTypeCount',{...this.params7}).then(res=>{
				this.radioTotal = res.data.data
			})
			
			axios.post('/cloudApi/stockWater/getPickingPage', {
					...this.params7,
				})
				.then((res) => {
					this.data3 = res.data.data.records
					this.params3.total = res.data.data.total
					
				})
		},
		getPickingPage() {
			axios.post('/cloudApi/stockWater/getPickingPage', {
					...this.params7,
				})
				.then((res) => {
					this.data3 = res.data.data.records
					this.params3.total = res.data.data.total
					
				})
			axios.post('/cloudApi/stockWater/getPickingStockChangeTypeCount',{...this.params7}).then(res=>{
				this.radioTotal = res.data.data
			})
			
		},
		tabClick(name) {
			this.tabName = name
			if (this.tabName === '1') {
				this.$refs.pykd.setModel('yearMonth', new Date())
			} else if (this.tabName === '2') {
				this.$refs.rkxsb.setModel('yearMonth', new Date())
			} else if (this.tabName === '3') {
				// this.$refs.llsxb.setModel('yearMonth', new Date())
			} else if (this.tabName === '4') {
				this.$refs.wlsfhz.setModel('yearMonth', new Date())
			} else if (this.tabName === '6') {
				this.$refs.table.setModel('yearMonth', new Date())
			} // 物料进出信息要选择物料所以默认不查找列表
			if (this.tabName !== '6' && this.tabName !== '3') {
				this.getList()
			}
		},
		cfm(type, formData) {
			if (type === 'add') {
				FacPriceAdd({
					...formData,
					materialCode: formData.code,
				}).then((res) => {
					if (res.code === 0) {
						this.$Message.info(res.msg)
						this.getList()
					}
				})
			} else if (type === 'edit') {
				FacPriceChange({
					...formData,
					factoryPriceId: formData.id,
				}).then((res) => {
					if (res.code === 0) {
						this.$Message.info(res.msg)
						this.getList()
					}
				})
			}
		},
		getselectedList(list, multiple) {
			this.$refs.table.setModel('materialCode', list[0].code)
			this.params6.materialCode = list[0].code
		},
		// 检索条件事件处理
		eventHandle(option) {
			switch (option._evnet) {
				case 'search':
					this['params' + this.tabName].pageIndex = 1
					this['params' + this.tabName].workKey = option.workKey
					this['params' + this.tabName].yearMonth = option.yearMonth
					if (this.tabName === '6') {
						this.params6.materialCode = option.materialCode
					}
					let date = new Date(
						this.$dayjs(option.yearMonth).format('YYYY-MM')
					).getTime()
					let now = new Date(
						this.$dayjs().format('YYYY-MM')
					).getTime()
					if (date > now) {
						return this.$Message.error('日期不可大于当前月')
					}
					this.getList()
					break
				case 'export':
					if (this[`data${this.tabName}`].length < 1)
						return this.$Message.error('数据为空！')
					// exportExcel(this[`columns${this.tabName}`], this[`data${this.tabName}`], '库存报表')
					if (this.tabName === '1') {
						GetMonthStockCheck({
							...this.params1,
							pageIndex: 1,
							pageSize: 99999,
						}).then((res) => {
							if (res.code === 0) {
								exportExcel(
									this[`columns${this.tabName}`],
									res.result.list,
									'盘盈亏单'
								)
							}
						})
					} else if (this.tabName === '2') {
						axios
							.post('/cloudApi/stockWater/receiptSequence', {
								pageNum:1,
								pageSize:999999,
								search: this.params2.keyword,
								date:this.params2.yearMonth
							})
							.then((res) => {
								console.log(res)
								exportExcel(
									this[`columns${this.tabName}`],
									res.data.data.records,
									'入库序时簿'
								)
							})
						// GetStockInDocumentList({
						// 	...this.params2,
						// 	pageIndex: 1,
						// 	pageSize: 99999,
						// }).then((res) => {
						// 	if (res.code === 0) {
						// 		exportExcel(
						// 			this[`columns${this.tabName}`],
						// 			res.result.list,
						// 			'入库序时簿'
						// 		)
						// 	}
						// })
					} else if (this.tabName === '3') {
						GetStockTakeDocumentList({
							...this.params3,
							pageIndex: 1,
							pageSize: 9999,
						}).then((res) => {
							if (res.code === 0) {
								exportExcel(
									this[`columns${this.tabName}`],
									res.result.list,
									'领料序时簿'
								)
							}
						})
					} else if (this.tabName === '4') {
						GetMaterialStockInOutSum({
							...this.params4,
							pageIndex: 1,
							pageSize: 99999,
						}).then((res) => {
							if (res.code === 0) {
								exportExcel(
									this.columns_4,
									res.result,
									'物料收发汇总'
								)
							}
						})
					} else if (this.tabName === '5') {
						GetMaterialMonthSum({
							...this.params5,
							pageIndex: 1,
							pageSize: 99999,
						}).then((res) => {
							if (res.code === 0) {
								exportExcel(
									this[`columns${this.tabName}`],
									res.result.list,
									'物料月汇总'
								)
							}
						})
					} else if (this.tabName === '6') {
						GetStockWaterInOut({
							...this.params6,
							pageIndex: 1,
							pageSize: 99999,
						}).then((res) => {
							if (res.code === 0) {
								exportExcel(
									this[`columns${this.tabName}`],
									res.result.list,
									'物料进出信息'
								)
							}
						})
					}
					break
				case 'showMaterial':
					this.show = true
					break
			}
		},
		changePage(pageIndex) {
			this['params' + this.tabName].pageIndex = pageIndex
			this.getList()
		},
		getList() {
			this['data' + this.tabName] = []
			if (this.tabName === '1') {
				GetMonthStockCheck(this.params1).then((res) => {
					if (res.code === 0) {
						this.data1 = res.result.list
						this.params1.total = res.result.totalCount
					}
				})
			} else if (this.tabName === '2') {
				const v = this
				v.$Spin.show();
				axios
					.post('/cloudApi/stockWater/receiptSequence', {
						pageNum:v.params2.pageIndex,
						pageSize:v.params2.pageSize,
						keyword: v.params2.workKey,
						date:v.params2.yearMonth,
					})
					.then((res) => {
						console.log(res)
						this.data2 = res.data.data.records
						this.params2.total = res.data.data.total
						setTimeout(() => {
							v.$Spin.hide();
						}, 1000);
					})
				// GetStockInDocumentList(this.params2).then((res) => {
				// 	if (res.code === 0) {
				// 		this.data2 = res.result.list
				// 		this.params2.total = res.result.totalCount
				// 	}
				// })
			} else if (this.tabName === '3') {
				
				// GetStockTakeDocumentList(this.params3).then((res) => {
				// 	if (res.code === 0) {
				// 		this.data3 = res.result.list
				// 		this.params3.total = res.result.totalCount
				// 	}
				// })
			} else if (this.tabName === '4') {
				GetMaterialStockInOutSum(this.params4).then((res) => {
					if (res.code === 0) {
						this.data4 = res.result
					}
				})
			} else if (this.tabName === '5') {
				GetMaterialMonthSum(this.params5).then((res) => {
					if (res.code === 0) {
						this.data5 = res.result.list
						this.params5.total = res.result.totalCount
					}
				})
			} else if (this.tabName === '6') {
				GetStockWaterInOut(this.params6).then((res) => {
					if (res.code === 0) {
						this.data6 = res.result.list
					}
				})
			}
		},
    
	},
	mounted() {
		this.tabClick('1') 
    	this.totalInit()
	},
}
</script>
<style>
.ivu-table-expanded-cell {
	padding-right: 0px !important;
}
.total-warp .ivu-table td{
	height: 32px!important;
}
.total-warp .ivu-table-cell-with-expand{
	height: 32px!important;
	line-height: 32px;
}
.ivu-table .table-info-row td{
	background-color: #2db7f5;
	color: #fff;
}
</style>
<style lang="less" scoped>
.h2{
	font-size: 18px;
	font-weight: bold;
	color: #333;
	height: 40px;
	line-height: 40px;
}
.total-warp {
	display: flex;
	justify-content: space-between;
	margin-top: 10px;
	
	.left-total,
	.right-total {
		width: 49%;
		background: #fff;
		.total-header {
			width: 100%;
			height: 60px;
			border: 1px solid #dcdcdc;
			border-bottom: 0px;
			div{
				color: #666;
				font-size: 16px;
				height: 100%;
				overflow: hidden;
				line-height: 30px;
				span{
					font-size: 18px;
					color: #000;
				}
			}
		}
	}
	.left-total {
		.total-header {
			padding-left: 50px;
			div {
				width: 20%;
				float: left;
				padding: 0 16px;
			}
		}
	}
	.right-total {
		.total-header {
			div {
				width: 25%;
				float: left;
				padding: 0 16px;
			}
		}
	}
}
.container {
	height: 100%;
}
/deep/ .ivu-tabs {
	height: 100%;
	.ivu-tabs-content {
		height: ~'calc(100% - 52px)';
	}
}
</style>
