<template>
	<div class="app-container">
		<!-- 搜索工作栏 -->
		<search-bar
			:formConfigs="formConfig"
			ref="searchBarForm"
			@headBtnClick="buttonClick" />
		<!-- 列表 -->
		<base-table
			:page="queryParams.pageNo"
			:limit="queryParams.pageSize"
			:table-props="tableProps"
			:table-data="list"
			:max-height="tableH">
			<method-btn
				v-if="tableBtn.length"
				slot="handleBtn"
				:width="80"
				label="操作"
				:method-list="tableBtn"
				@clickBtn="handleClick" />
		</base-table>
		<pagination
			:page.sync="queryParams.pageNo"
			:limit.sync="queryParams.pageSize"
			:total="total"
			@pagination="getList" />
		<!-- 详情抽屉 -->
		<delivery-log-det-detail ref="deliveryLogDetail" />
	</div>
</template>
<script>
import { deliveryProgressPage } from '@/api/base/delivery';
import DeliveryLogDetDetail from './components/deliveryLogDetDetail.vue';
import tableHeightMixin from '@/mixins/lb/tableHeightMixin';
const tableProps = [
	{
		prop: 'orderName',
		label: '订单名',
		showOverflowtooltip: true,
	},
	{
		prop: 'customerName',
		label: '客户名称',
		showOverflowtooltip: true,
	},
	{
		prop: 'unit',
		label: '单位',
	},
	{
		prop: 'orderNum',
		label: '订单数量',
	},
	{
		prop: 'num',
		label: '发货数量',
	},
	{
		prop: 'rate',
		label: '累计发货比例(%)',
	},
];
export default {
	name: 'DeliveryLogDet',
	mixins: [tableHeightMixin],
	data() {
		return {
			formConfig: [
				{
					type: 'input',
					label: '订单名',
					param: 'orderName',
				},
				{
					type: 'button',
					btnName: '查询',
					name: 'search',
					color: 'primary',
				},
			],
			// 查询参数
			queryParams: {
				pageNo: 1,
				pageSize: 20,
				orderName: '',
			},
			tableProps,
			list: [],
			total: 0,
			tableBtn: [
				this.$auth.hasPermi('extend:delivery-log-det:detail')
					? {
							type: 'detail',
							btnName: '详情',
					  }
					: undefined,
			].filter((v) => v),
		};
	},
	components: { DeliveryLogDetDetail },
	created() {
		this.getList();
	},
	methods: {
		getList() {
			deliveryProgressPage({ ...this.queryParams }).then((res) => {
				this.list = res.data.list || [];
				this.total = res.data.total || 0;
			});
		},
		buttonClick(val) {
			this.queryParams.orderName = val.orderName;
			this.getList();
		},
		handleClick(val) {
			console.log(val);
			this.$nextTick(() => {
				this.$refs.deliveryLogDetail.init(val.data);
			});
		},
	},
};
</script>