<template>
	<div style="height:100%;">
		<div class="searchForm-header">
			<el-form :model="query" label-width="100px" inline="">
				<el-row>
					<el-form-item label="库房名称" style="margin-left: -15px">
						<el-select v-model="query.wareName" clearable size="small" style="width:120px;margin-left: -8px">
							<el-option v-for="item in optionsWare" :key="item.id" :label="item.name" :value="item.name">
							</el-option>
						</el-select>
					</el-form-item>
					<el-form-item label="垛位名称" style="margin-left: -35px">
						<el-input v-model="query.stackName" size="small" style="width:120px;margin-left: -8px"></el-input>
					</el-form-item>
					<el-form-item label="物料名称" style="margin-left: -35px">
						<el-input v-model="query.materialName" size="small" style="width:120px;margin-left: -8px">
							<el-button slot="append" icon="el-icon-search" @click="showMaterial"></el-button>
						</el-input>
					</el-form-item>
					<el-form-item label="钢种" style="margin-left: -35px">
						<el-input v-model="query.standard" size="small" style="width:150px;margin-left: -8px">
							<el-button slot="append" icon="el-icon-search" @click="showMaterial"></el-button>
						</el-input>
					</el-form-item>
					<el-form-item label="客户名称" style="margin-left: -35px">
						<el-input v-model="query.fkcustmerName" size="small" style="width:170px;margin-left: -8px">
							<el-button slot="append" icon="el-icon-search" @click="showFKcustmer"></el-button>
						</el-input>
					</el-form-item>
					<el-form-item label="订单客户" style="margin-left: -35px">
						<el-input v-model="query.customerName" size="small" style="width:170px;margin-left: -8px">
							<el-button slot="append" icon="el-icon-search" @click="showCustomer"></el-button>
						</el-input>
					</el-form-item>
					<el-form-item label="规格型号" style="margin-left: -15px">
						<el-input v-model="query.model" size="small" style="width:120px;margin-left: -8px">
						</el-input>
					</el-form-item>
					<el-form-item label="钢板号" style="margin-left: -15px">
						<el-input v-model="query.plateNo" size="small" style="width:120px;margin-left: -8px">
						</el-input>
					</el-form-item>
					<el-form-item label="订单号" style="margin-left: -15px">
						<el-input v-model="query.ordNo" size="small" style="width:120px;margin-left: -8px">
						</el-input>
					</el-form-item>
					<el-form-item label="入库时间" style="margin-left: -35px">
						<el-date-picker size="small" v-model="query.inRecordDate"  style="width:330px;margin-left: -8px" type="datetimerange" range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期">
						</el-date-picker>
					</el-form-item>
					<el-form-item label="" style="margin-top: 0px;margin-left: 10px">
						<el-button @click="handleSearch" size="small"  type="primary">查询</el-button>
						<el-button @click="showChangeCustomer" size="small"  type="primary">货权转移</el-button>
						<!-- <el-button size="medium" type="primary" @click="handleImport">导入</el-button>
						<el-button size="medium" type="primary" @click="handleDownload">下载模板</el-button>
						<el-button size="medium" type="success" @click="showIn">入库</el-button>
						<el-button size="medium" type="danger" @click="handleInBack">取消入库</el-button> -->
						<el-button type="primary" size="small"  @click="showDistribution">配货</el-button>
            			<el-button type="success" size="small"  @click="handleExport" >导出记录</el-button>
            			<el-button type="primary" size="small"  @click="showOut">出库</el-button>
            			<el-button type="danger"  size="small"  @click="handleInBack" :disabled="backAble">取消入库</el-button>
					</el-form-item>
						<!-- <el-button type="primary" @click="showOut">出库</el-button> -->
					<!-- 	<el-form-item label=" ">
						<el-button @click="showChangeAddress" type="primary">修改地址</el-button>
					</el-form-item> -->
				</el-row>
				
			</el-form>
		</div>
		<div class="tabledata-grid">
			<el-table :data="tableData" height="100%"   border style="width: 97%;" v-loading="loading" ref="multipleTable"	@select="handleTableSelect"	 @selection-change="handleSelectionChange" @select-all = "selectAll">
				<el-table-column type="selection" width="40" header-align="center" align="center"></el-table-column>
				<el-table-column prop="layer" label="层数" width="60" show-overflow-tooltip header-align="center" align="center">
				</el-table-column>
				<el-table-column prop="stack.name" label="垛位" width="120" show-overflow-tooltip header-align="center" align="center">
				</el-table-column>
				<el-table-column prop="material.name" label="货物品名" width="100" show-overflow-tooltip header-align="center" align="center">
				</el-table-column>
				<el-table-column prop="material.standard" label="材质" width="100" show-overflow-tooltip header-align="center" align="center">
				</el-table-column>
				<el-table-column prop="plateNo" label="钢板号" width="200" show-overflow-tooltip header-align="center">
				</el-table-column>
				<el-table-column prop="model" label="规格型号" width="160" show-overflow-tooltip header-align="center" align="center">
				</el-table-column>
				<el-table-column prop="count" label="数量" width="120" show-overflow-tooltip align="right" header-align="center">
				</el-table-column>
				<el-table-column prop="weight" label="重量" width="120" show-overflow-tooltip align="right" header-align="center">
				</el-table-column>
				<el-table-column prop="ordNo" label="订单号" width="180" show-overflow-tooltip header-align="center">
				</el-table-column>
				<el-table-column prop="contractNo" label="合约号" width="180" show-overflow-tooltip header-align="center">
				</el-table-column>
				<el-table-column prop="customer.name" label="订单客户" width="300" show-overflow-tooltip header-align="center">
				</el-table-column>
				<el-table-column prop="customer.name" label="客户名称" width="300" show-overflow-tooltip header-align="center">
				</el-table-column>
				<el-table-column prop="receiveAddress" label="收货地址" width="300" show-overflow-tooltip header-align="center">
				</el-table-column>
				<el-table-column prop="productionPlace" label="产地" width="250" show-overflow-tooltip header-align="center">
				</el-table-column>
				<el-table-column prop="remark" label="备注" width="150" show-overflow-tooltip header-align="center">
				</el-table-column>
				<el-table-column prop="addTime" label="入库时间" width="200" show-overflow-tooltip header-align="center">
				</el-table-column>
				<el-table-column prop="carNo" label="入库车号" width="200" show-overflow-tooltip header-align="center">
				</el-table-column>
			</el-table>
			<el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="currentPage"
			 :page-sizes="pageSizes" :page-size="pageSize" layout="total, sizes, prev, pager, next, jumper" :total="totalRows">
			</el-pagination>
		</div>

		<popup-material ref="PopupMaterial" @receviceFromChild="receviceFromMaterial"></popup-material>
		<popup-customer ref="PopupCustomer" @receviceFromChild="receviceFromCustomer"></popup-customer>
		<popup-customer ref="PopupFKcustmer" @receviceFromChild="receviceFKcustmerr"></popup-customer>
		<popup-customer ref="PopupNewCustomer" @receviceFromChild="receviceFromNewCustomer"></popup-customer>
		<popup-address ref="PopupAddress" @receviceFromChild="receviceFromAddress"></popup-address>
		<popup-distribution ref="PopupDistribution" @receviceFromChild="receviceFromDistreibution" :selectRows="selectRows"></popup-distribution>
		<popup-out ref="PopupOut" @receviceFromChild="receviceFromOut"></popup-out>
		<popup-in ref="PopupIn" @receviceFromChild="receviceFromIn" :wares="options" :wareId="query.wareId" :stack="moveFromStack"></popup-in>
		<el-dialog title="货权转移" :visible.sync="customerDialogVisible" width="500px">
			<el-form>
				<el-form-item label="货权转移">
					<el-input v-model="newCustomer.name">
						<el-button slot="append" icon="el-icon-search" @click="showNewCustomer"></el-button>
					</el-input>
				</el-form-item>
				<el-form-item label="修改地址">
					<el-input v-model="newAddress">
						<el-button slot="append" icon="el-icon-search" @click="showAddress"></el-button>
					</el-input>
				</el-form-item>
				<el-form-item label=" ">
					<el-button type="success" @click="handleCustomerSave">保存</el-button>
					<el-button type="danger" @click="handleCustomerCancelSave">取消</el-button>
				</el-form-item>
			</el-form>
		</el-dialog>
		<el-dialog title="库房明细" :visible.sync="importDialogVisible" width="1000px">

			<el-upload class="upload-demo" action="" :on-change="handleChange" :on-exceed="handleExceed" :on-remove="handleRemove"
			 ref="upload" :limit="1" accept="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.ms-excel"
			 :auto-upload="false">
				<el-button slot="trigger" size="small" type="primary">选择文件</el-button>
				<el-button size="small" type="success" @click="inImport">保存</el-button>
				<!-- 				<div slot="tip" class="el-upload__tip">只 能 上 传 xlsx / xls 文 件</div> -->
			</el-upload>

			<el-table :data="imTableData" border>
				<el-table-column prop="层数" label="层数" width="60" show-overflow-tooltip header-align="center">
				</el-table-column>
				<el-table-column prop="库房" label="库房" width="100" show-overflow-tooltip header-align="center">
				</el-table-column>
				<el-table-column prop="垛位" label="垛位" width="120" show-overflow-tooltip header-align="center">
				</el-table-column>
				<el-table-column prop="物料" label="物料" width="120" show-overflow-tooltip align="center" header-align="center">
				</el-table-column>
				<el-table-column prop="钢种" label="钢种" width="120" show-overflow-tooltip align="center" header-align="center">
				</el-table-column>
				<el-table-column prop="钢板号" label="钢板号" width="200" show-overflow-tooltip header-align="center">
				</el-table-column>
				<el-table-column prop="规格型号" label="规格型号" width="120" show-overflow-tooltip header-align="center">
				</el-table-column>
				<el-table-column prop="数量" label="数量" width="120" show-overflow-tooltip align="right" header-align="center">
				</el-table-column>
				<el-table-column prop="重量" label="重量" width="120" show-overflow-tooltip align="right" header-align="center">
				</el-table-column>
				<el-table-column prop="客户" label="客户" width="300" show-overflow-tooltip header-align="center">
				</el-table-column>
				<el-table-column prop="备注" label="备注" width="150" show-overflow-tooltip header-align="center">
				</el-table-column>
			</el-table>

		</el-dialog>
	</div>
</template>

<script>
	import axios from '@/axios'
	import PopupStack from '@/components/PopupStack.vue'
	import PopupMaterial from '@/components/PopupMaterial.vue'
	import PopupCustomer from '@/components/PopupCustomer.vue'
	import PopupAddress from '@/components/PopupAddress.vue'
	import PopupDistribution from '@/components/PopupDistribution.vue'
	import PopupOut from '@/components/PopupOut.vue'
	import PopupIn from '@/components/PopupIn.vue'
	import Export2Excel from '../../excel/Export2Excel.js'
	import {
		mapState
	} from 'vuex'
	export default {
		components: {
			PopupStack,
			PopupMaterial,
			PopupCustomer,
			PopupAddress,
			PopupDistribution,
			PopupOut,
			PopupIn,
		},
		computed: {
			// splitCount: function() {
			// 	let result = Number(this.split.originalCount) - Number(this.split.count)
			// 	return result
			// },
			// splitWeight: function() {
			// 	let result = Number(this.split.originalWeight) - Number(this.split.weight)
			// 	return result
			// },
			...mapState({
				serverName: state => state.app.serverName,
				// wareBackgroundColor: state => state.color.wareBackgroundColor,
				// stackColor: state => state.color.stackColor,
				// stackSelectedColor: state => state.color.stackSelectedColor,
				// lockColor: state => state.color.lockColor,
			})
		},
		data() {
			return {
				addressDialogVisible: false,
				customerDialogVisible: false,
				query: {
					wareName: '',
					stackName: '',
					model: '',
					materialName: '',
					standard: '',
					customerName: '',
					plateNo: '',
					wareId:'',
					inRecordDate:[],
				},
				multipleSelection: [],
				tableData: [],
				optionsWare: [],


				newCustomer: {
					id: '',
					name: ''
				},
				newAddress: '',

				currentPage: 1,
				totalRows: 0,
				pageSizes: [50, 100, 200,1000],
				pageSize: 1000,
				HideAndShow: 0,


				loading: false,
				importDialogVisible: false,
				selectRows: [],
				options: [],
				moveFromStack: {}, //移除垛位
				fileTemp: [],
				imTableData: [],
				moveStore: {},
			};
		},
		mounted() {
			this.getWare(),
			THIS.setSearchTime()
			//this.getTableData()
		},
		methods: {
			setSearchTime(){
				var now = new Date();
				this.query.inRecordDate = [new Date(now.getFullYear(), now.getMonth(), now.getDate()),new Date(now.getFullYear(), now.getMonth(), now.getDate()+1)];
			},
			showMaterial() {
				this.$refs.PopupMaterial.show()
			},
			receviceFromMaterial(material) {
				this.query.materialName = material.name
				this.query.standard = material.standard
			},

			showCustomer() {
				this.$refs.PopupCustomer.show()
			},
			receviceFromCustomer(customer) {
				this.query.customerName = customer.name
			},

			
			showFKcustmer() {
				this.$refs.PopupFKcustmer.show()
			},
			receviceFKcustmerr(customer) {
				this.query.fkcustmerName = customer.name
			},

			showNewCustomer() {
				this.$refs.PopupNewCustomer.show()
			},
			receviceFromNewCustomer(customer) {
				this.newCustomer = customer
				this.newAddress = customer.address
			},
			showAddress() {
				this.$refs.PopupAddress.show(this.newCustomer.id)
			},
			receviceFromAddress(address) {
				this.newAddress = address.address
			},

			handleSearch() {
				this.currentPage = 1
				this.getTableData()
			},
			handleImport() {
				this.importDialogVisible = true
			},
			handleDownload() {
				window.open(this.serverName.substr(0, this.serverName.lastIndexOf('/', this.serverName.lastIndexOf('/') - 1)) +
					'/import.xls')
			},
			showIn() {
				// if (this.query.wareId == '') {
				// 	this.$message({
				// 		type: 'error',
				// 		message: '请选择入库库房'
				// 	});
				// 	return
				// }
				// if (this.query.stackId == '') {
				// 	this.$message({
				// 		type: 'error',
				// 		message: '请选择入库垛位'
				// 	});
				// 	return
				// }
				this.$refs.PopupIn.show()
			},
			handleInBack() {
				if (this.selectRows.length < 1) {
					this.$message({
						type: 'error',
						message: '至少选择一条数据！',
					});
					return
				} else {
					var url = 'WareIn/back.do'
					var param = {
						json: JSON.stringify(this.selectRows),
					}
					axios.post(url, param).then(response => {
						if (response.data.code == 0) {
							this.getStoreByStackId(response.data.data)
						} else {
							this.$message({
								type: 'error',
								message: '操作失败；' + response.data.msg,
							});
						}
					});
				}
			},
			showDistribution() {
				//console.log(this.selectRows.length)
				if (this.selectRows.length < 1) {
					this.$message({
						type: 'warning',
						message: '至少选择一条数据！',
					});
				}
				this.$refs.PopupDistribution.show()

			},
			showOut() {
				this.$refs.PopupOut.show()
			},
			getWare() {
				var url = 'MaintWare/queryByUserId.do'
				var param = {}
				axios.get(url, param).then(response => {
					this.optionsWare = response.data.data
					if (response.data.data.length == 1) {
						this.wareName = response.data.data[0].name

					}
				});
			},
			handleSizeChange(val) {
				this.pageSize = val
				this.getTableData()
			},

			handleCurrentChange(val) {
				this.currentPage = val
				this.getTableData()
			},

			search() {
				this.currentPage = 1
				this.getTableData()
			},

			getTableData() {
				this.loading = true
				var url = 'WareStore/queryStore.do'
				if(this.query.inRecordDate == null){
					this.query.inRecordDate = [false,false];
				}
				var param = {
					page: this.currentPage,
					rows: this.pageSize,
					wareName: this.query.wareName,
					stackName: this.query.stackName,
					model: this.query.model,
					materialName: this.query.materialName,
					standard: this.query.standard,
					customerName: this.query.customerName,
					plateNo: this.query.plateNo,
					fromDate:(!this.query.inRecordDate[0]) ? "1970-01-01 00:00:00" : this.query.inRecordDate[0].Format("yyyy-MM-dd HH:mm:ss"),		//date类型
					toDate  :(!this.query.inRecordDate[1]) ? new Date().Format("yyyy-MM-dd HH:mm:ss") :this.query.inRecordDate[1].Format("yyyy-MM-dd HH:mm:ss"),
				}
				axios.get(url, param).then(response => {
					if (response.data.code == 0) {
						this.tableData = response.data.data.list
						this.totalRows = response.data.data.total
					} else {
						this.$message({
							type: 'error',
							message: '操作失败；' + response.data.msg,
						});
					}
					this.loading = false
				});
			},
			handleSelectionChange(val) {
				this.multipleSelection = val;
			},
			showChangeCustomer() {
				if (this.multipleSelection.length < 1) {
					this.$message({
						type: 'error',
						message: '至少选择一条记录！',
					});
					return
				}
				var customerAddress = this.multipleSelection[0].customer.address
				var boolean = true
				for (var i = 0; i < this.multipleSelection.length; i++) {
					if (this.multipleSelection[i].customer.address == customerAddress) {

					} else {
						boolean = boolean && false
						customerAddress = this.multipleSelection[i].customer.address
					}
				}
				if (boolean) {
					this.newCustomer = this.multipleSelection[0].customer
					this.newAddress = this.multipleSelection[0].receiveAddress
					this.customerDialogVisible = true
				} else {
					this.$message({
						type: 'error',
						message: '请选择同一客户！',
					});
				}
			},

			handleCustomerSave() {

				// 				var boolean = true
				// 				for (var i = 0; i < this.multipleSelection.length; i++) {
				// 					if (this.multipleSelection[i].customer.name == this.newCustomer.name) {
				// 						boolean = boolean && false
				// 						break
				// 					}
				// 				}
				// 				if (!boolean) {
				// 					this.$message({
				// 						type: 'error',
				// 						message: '转移客户与原客户相同！',
				// 					});
				// 					return
				// 				} 
				// 

				var url = 'WareChange/changeCustomer.do'
				var param = {
					json: JSON.stringify(this.multipleSelection),
					customer: JSON.stringify(this.newCustomer),
					address: this.newAddress
				}
				axios.post(url, param).then(response => {
					if (response.data.code == 0) {
						this.getTableData()
						this.customerDialogVisible = false
					} else {
						this.$message({
							type: 'error',
							message: '操作失败；' + response.data.msg,
						});
					}
				});
			},
			handleCustomerCancelSave() {
				this.customerDialogVisible = false
			},
			handleInBack() {
				if (this.selectRows.length < 1) {
					this.$message({
						type: 'error',
						message: '至少选择一条数据！',
					});
					return
				} else {
					var url = 'WareIn/back.do'
					var param = {
						json: JSON.stringify(this.selectRows),
					}
					axios.post(url, param).then(response => {
						if (response.data.code == 0) {
							this.getStoreByStackId(response.data.data)
						} else {
							this.$message({
								type: 'error',
								message: '操作失败；' + response.data.msg,
							});
						}
					});
				}
			},
			inImport() {
				var url = 'WareIn/inImport.do'
				var json = JSON.stringify(this.imTableData)
				var param = {
					json: json
				}
				axios.post(url, param).then(response => {
					if (response.data.code == '0') {
						this.$message({
							type: 'success',
							message: '入库成功!',
						});
						this.importDialogVisible = false
						this.imTableData = []
						this.fileTemp = null
					} else {
						this.$message({
							type: 'error',
							message: '入库失败!' + response.data.msg
						});

					}
				});
			},
			handleTableSelectionChange(val) {
				this.selectRows = val
				this.setLayerColor()
			},
			receviceFromDistreibution() {
				this.getStoreByStackId(null)
			},
			getStoreByStackId(moveSelect) {
				this.tableDataLoading = true
				var url = 'WareStore/queryByWareIdStackId.do'
				var param = {
					wareId: this.query.wareId,
					stackId: this.moveFromStack.id
				}
				axios.get(url, param).then(response => {
					if (response.data.code == 0) {
						this.tableData = response.data.data
						this.selectRows = []
						// if (this.isLayer == '0') {
						// 	this.drawStoreNoLayer(response.data.data)
						// } else if (this.isLayer == '1') {    //1是A开头的，2是B开头的，3是C开头的。
						// 	this.drawStoreAutoLayer(response.data.data)
						// } else if (this.isLayer == '2') {
						// 	this.drawStoreManulLayer(response.data.data)
						// }
						if (moveSelect) {
							this.$refs.multipleTable.clearSelection();
							for (let i = 0; i < this.tableData.length; i++) {
								for (let j = 0; j < moveSelect.length; j++) {
									if (moveSelect[j].layer === this.tableData[i].layer) {
										this.selectRows.push(this.tableData[i])
									}
								}
							}
							this.$nextTick(() => {
								this.toggleSelection(this.selectRows, true)
								this.setLayerColor()
							})

						}
					} else {
						this.$message({
							type: 'error',
							message: '保存失败' + response.data.msg,
						});
					}
					this.tableDataLoading = false
				});
			},
			receviceFromOut(customer) {
				this.getStoreByStackId()
			},
			receviceFromIn() {
				this.getStoreByStackId()
			},
			handleChange(file, fileList) {
				this.fileTemp = file.raw
				if (this.fileTemp) {
					if ((this.fileTemp.type == 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet') || (this.fileTemp.type ==
							'application/vnd.ms-excel')) {
						this.importfxx(this.fileTemp)
					} else {
						this.$message({
							type: 'warning',
							message: '附件格式错误，请删除后重新上传！'
						})
					}
				} else {
					this.$message({
						type: 'warning',
						message: '请上传附件！'
					})
				}

			},
			handleExceed(file, fileList) {},
			handleRemove(file, fileList) {
				this.fileTemp = null
			},
			toggleSelection(rows, selected) {
				if (rows) {
					rows.forEach(row => {
						this.$refs.multipleTable.toggleRowSelection(row, selected);  //接受两个参数，row传递被勾选行的数据，selected设置是否选中
					});
				}
			},
			setLayerColor() {
				if (this.selectRows.length == 0) {
					for (let i = 0; i < this.moveStore.storage._roots.length; i++) {
						if (this.tableData[i].lockFlag == '1') {
							this.moveStore.storage._roots[i].attr('style', {
								fill: this.lockColor,
							})
						} else {
							this.moveStore.storage._roots[i].attr('style', {
								fill: this.stackColor,
							})
						}
					}
				} else {
					for (let i = 0; i < this.moveStore.storage._roots.length; i++) {
						for (let j = 0; j < this.selectRows.length; j++) {
							if (this.tableData[i] === this.selectRows[j]) {
								this.moveStore.storage._roots[i].attr('style', {
									fill: this.stackSelectedColor,
								})
								break;
							} else {
								if (this.tableData[i].lockFlag == '1') {
									this.moveStore.storage._roots[i].attr('style', {
										fill: this.lockColor,
									})
								} else {
									this.moveStore.storage._roots[i].attr('style', {
										fill: this.stackColor,
									})
								}
							}
						}

					}
				}
			},
			handleTableSelect(selection, row) {  //第一个参数是目前所有选中的数据
				console.log(JSON.stringify(row))
				if (row.lockFlag == '1') {
					// this.$message({
					// 	type: 'error',
					// 	message: '该行已被配货锁定',
					// });
					alert("该行已被配货锁定")
					this.toggleSelection([row], false)
					// for(let i = 0;i<selection.length;i++){
					//  if(selection[i]==row){
					// 	 selection.splice(i,1)
					//  }
					// }
				} else {
					this.selectRows = selection
					this.setLayerColor()
				}
			},
			selectAll(selection){
				this.selectRows = selection;
			},

			handleExport() {
				var imptData = [];
				if(this.query.inRecordDate == null){
					this.query.inRecordDate = [false,false];
				}
				var url = 'WareStore/queryStore.do'
				var param = {
					page: this.currentPage,
					rows: this.pageSize,
					wareName: this.query.wareName,
					stackName: this.query.stackName,
					model: this.query.model,
					materialName: this.query.materialName,
					standard: this.query.standard,
					customerName: this.query.customerName,
					plateNo: this.query.plateNo,
					fromDate:(!this.query.inRecordDate[0]) ? "1970-01-01 00:00:00" : this.query.inRecordDate[0].Format("yyyy-MM-dd HH:mm:ss"),		//date类型
					toDate  :(!this.query.inRecordDate[1]) ? new Date().Format("yyyy-MM-dd HH:mm:ss") :this.query.inRecordDate[1].Format("yyyy-MM-dd HH:mm:ss"),
				}


				axios.get(url, param).then(response => {

					if (response.data.code == 0) {
						var imptData = response.data.data.list;
						if (imptData.length == 0) {
							this.$alert('无法导出，没有库存', '提示', {
								confirmButtonText: '确定',
								callback: action => {}
							});
						} else {

							this.exportExcel(imptData)
						}
					} else {
						this.$message({
							type: 'error',
							message: '操作失败；' + response.data.msg,
						});
					}

				});
				
			},
			exportExcel(imptData) {
				// alert(JSON.stringify(imptData))
				const header = ["层数"
								,"垛位"
								,"货物品名"
								,"材质"
								,"钢板号"
								,"规格型号"
								,"数量"
								,"重量"
								,"订单号"
								,"合约号"
								,"订单客户"
								,"客户名称"
								,"收货地址"
								,"产地"
								,"备注"
								,"入库时间"
								,"车号"

				] // 导出的表头名
				const filterVal = ["layer"
									,"stackName"
									,"materialName"
									,"materialStandard"
									,"plateNo"
									,"model"
									,"count"
									,"weight"
									,"ordNo"
									,"contractNo"
									,"customerName"
									,"customerName"
									,"receiveAddress"
									,"productionPlace"
									,"remark"
									,"addTime"
									,"carNo"
				]
				for(var i=0;i<imptData.length;i++){
					imptData[i]["stackName"] 			= imptData[i].stack.name;
					imptData[i]["materialName"]     	= imptData[i].material.name;
					imptData[i]["materialStandard"]     = imptData[i].material.standard;
					imptData[i]["customerName"]     	= imptData[i].customer.name;
				}
				const list = imptData
				const data = this.formatJson(filterVal, list)

				const filename = '库存信息' + (new Date()).toLocaleDateString();
				Export2Excel.export_json_to_excel({
					header,
					data,
					filename
				})
			},
			formatJson(filterVal, jsonData) {
				return jsonData.map(v => filterVal.map(j => {
					return v[j]
				}))
			},

			//showChangeAddress() {},
			// handleAddressSave() {
			// },
			// handleAddressCancelSave() {
			// 	this.addressDialogVisible = false
			// },
		},
	}
</script>

<style>
.option_btn{
	margin-left: 30px
}
.searchForm-header{
		height: auto;
		margin-left: 10px;
	}
	.tabledata-grid{
		font-size: 20px;
		margin-left: 5px;
		height: calc(100% - 100px);

	}
</style>
