<template>
	<div class="app-container">
		<search-bar
			:isFold="true"
			:formConfigs="formConfig"
			ref="searchBarForm"
			@headBtnClick="buttonClick" />
		<el-table
			:data="tableData"
			:header-cell-style="{
				background: '#F2F4F9',
				color: '#606266',
			}"
			border
			v-loading="dataListLoading"
			style="width: 100%"
			ref="dataList">
			<el-table-column type="expand">
				<template slot-scope="scope">
					<product :warehouse-id="scope.row.id" :prop-type="3"></product>
				</template>
			</el-table-column>
			<el-table-column
				prop="finishProductName"
				label="库位名"></el-table-column>
			<el-table-column
				prop="finishProductWarehouseCode"
				label="库位编码"></el-table-column>
			<el-table-column prop="createTime" label="出入库时间">
				<template v-slot="scope">
					<span>{{ parseTime(scope.row.createTime) }}</span>
				</template>
			</el-table-column>
			<el-table-column
				prop="finishProductWarehouseDataState"
				label="出入库状态">
				<template slot-scope="scope">
					<span>
						{{
							scope.row.finishProductWarehouseDataState >= 0
								? warehouseStorehouseStorageState[
										scope.row.finishProductWarehouseDataState
								  ].name
								: ''
						}}
					</span>
				</template>
			</el-table-column>
		</el-table>
		<pagination
			:limit.sync="listQuery.pageSize"
			:page.sync="listQuery.pageNo"
			:total="listQuery.total"
			@pagination="getDataList" />
	</div>
</template>

<script>
import product from '../product-mini';
import basicPage from '../mixins/basic-page';
import { getFinishProductWarehouseDataPage, } from "@/api/fpw/finishProductWarehouseData";
const warehouseStorehouseStorageState = [
	{
		name: '入库',
		id: 0,
	},
	{
		name: '出库',
		id: 1,
	},
	{
		name: '移库',
		id: 2,
	},
];
export default {
	mixins: [basicPage],
	data() {
		return {
			urlOptions: {
				getDataListURL: getFinishProductWarehouseDataPage,
			},
			tableData: [],
			warehouseStorehouseStorageState,
			formConfig: [
				{
					type: 'input',
					label: '库位名',
					placeholder: '库位名',
					param: 'name',
				},
				{
					type: 'input',
					label: '库位编码',
					placeholder: '库位编码',
					param: 'kcode',
				},
				{
					type: 'input',
					label: '托盘编码',
					placeholder: '托盘编码',
					param: 'tcode',
				},
				{
					type: 'select',
					label: '出入库状态',
					selectOptions: warehouseStorehouseStorageState,
					param: 'finishProductWarehouseDataState',
					defaultSelect: '',
					filterable: true,
				},
				{
					type: 'datePicker',
					label: '出入库时间',
					dateType: 'daterange',
					format: 'yyyy-MM-dd',
					valueFormat: 'yyyy-MM-dd hh:mm:ss',
					rangeSeparator: '-',
					startPlaceholder: '开始时间',
					endPlaceholder: '结束时间',
					param: 'searchTime',
				},
				{
					type: 'button',
					btnName: '搜索',
					name: 'search',
					color: 'primary',
				},
				// {
				// 	type: this.$auth.hasPermi('base:factory:create') ? 'separate' : '',
				// },
				// {
				// 	type: this.$auth.hasPermi('base:factory:export') ? 'button' : '',
				// 	btnName: '导出',
				// 	name: 'export',
				// 	color: 'warning',
				// },
			],
		};
	},
	components: {
		product,
	},
	created() {},
	methods: {
		buttonClick(val) {
			switch (val.btnName) {
				case 'search':
					this.listQuery.pageNo = 1;
					this.listQuery.pageSize = 10;
					this.listQuery.finishProductName = val.name;
					this.listQuery.finishProductWarehouseCode = val.kcode;
					this.listQuery.trayCode = val.tcode;
					this.listQuery.createTime = val.searchTime;
					this.listQuery.finishProductWarehouseDataState = val.finishProductWarehouseDataState;
					this.getDataList();
					break;
				case 'reset':
					this.$refs.searchBarForm.resetForm();
					this.listQuery = {
						pageSize: 10,
						pageNo: 1,
						total: 1,
					};
					this.getDataList();
					break;
				case 'add':
					this.addOrEditTitle = '新增';
					this.addOrUpdateVisible = true;
					this.addOrUpdateHandle();
					break;
				case 'export':
					this.handleExport();
					break;
				default:
					console.log(val);
			}
		},
	},
};
</script>
<style>
.app-container .el-table .el-table__cell {
	padding: 0;
	height: 35px;
}
</style>
