<template>
    <div>
        <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="primary" @click="handleDownload">下载模板</el-button>
			<el-button size="small" type="success" @click="inImport">保存</el-button>
		</el-upload>
        
        <el-table :data="imTableData" border>
			<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="60" 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="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="120" show-overflow-tooltip align="right" header-align="center">
            </el-table-column>
            <el-table-column prop="入库车号" label="入库车号" width="150" show-overflow-tooltip 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="300" 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="100" show-overflow-tooltip header-align="center">
            </el-table-column>
            <el-table-column prop="捆包号" label="捆包号" width="250" 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-column prop="入库操作人员" label="入库操作人员" width="150" 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-column prop="计量方式" label="计量方式" width="150" show-overflow-tooltip header-align="center">
            </el-table-column>
        </el-table>
    </div>
</template>
<script>
	import axios from '@/axios'
	import zrender from 'zrender'
	import {
		mapState
	} from 'vuex'
	export default {
		computed: {
			...mapState({
                serverName: state => state.app.serverName,
				wareBackgroundColor: state => state.color.wareBackgroundColor,
				stackColor: state => state.color.stackColor,
				stackSelectedColor: state => state.color.stackSelectedColor
			})
		},
		components: {

		},
		data() {
			return {
				
			}
		},
		//界面渲染完毕调用   初始化表格参数
		mounted() {
		},
		methods: {
			handleDownload() {
				window.open(this.serverName.substr(0, this.serverName.lastIndexOf('/', this.serverName.lastIndexOf('/') - 1)) +
					'/importWare.xls')
			},
            inImport() {
				var url = 'WareIn/inImportAll.do'
				var json = JSON.stringify(this.imTableData)
				var param = {
					json: json
				}
				this.imptAble = true;
				// console.log(json)
				axios.post(url, param).then(response => {
					if (response.data.code == '0') {
						this.$message({
							type: 'success',
							message: '入库成功!',
						});
						this.imTableData = []
						this.fileTemp = null
					} else {
						this.$message({
							type: 'error',
							message: '入库失败!' + response.data.msg
						});

					}
					this.imptAble = false;
				});
			},

		}
	}
</script>