<template>
	<div class="show-box">
		<!-- 搜索工作栏 -->
		<search-bar
			:formConfigs="formConfig"
			ref="searchBarForm"
			@headBtnClick="buttonClick2" />
		<!-- 列表 -->
		<base-table
			:page="queryParams2.pageNo"
			:limit="queryParams2.pageSize"
			:table-props="tableProps"
			:table-data="list2">
			<method-btn
				v-if="tableBtn2.length"
				slot="handleBtn"
				:width="240"
				label="操作"
				:method-list="tableBtn2"
				@clickBtn="handleClick2" />
		</base-table>
		<pagination
			:page.sync="queryParams2.pageNo"
			:limit.sync="queryParams2.pageSize"
			:total="total2"
			@pagination="getList2" />
	</div>
</template>
<script>
import { parseTime } from '@/utils/ruoyi';
import { getPackingPage } from '@/api/base/packingInfo';
import { getCorePLList } from '@/api/base/coreProductionLine';
const tableProps = [
	{
		prop: 'packagingCode',
		label: '成品周转编号',
		minWidth: 180,
		showOverflowtooltip: true,
	},
	{
		prop: 'lineId',
		label: '产线',
		showOverflowtooltip: true,
	},
	{
		prop: 'specifications',
		label: '规格',
		showOverflowtooltip: true,
	},
	{
		prop: 'check',
		label: '判定',
		showOverflowtooltip: true,
	},
	{
		prop: 'workStation',
		label: '工位号',
		showOverflowtooltip: true,
	},
	{
		prop: 'num',
		label: '片数',
	},
	{
		prop: 'remark',
		label: '备注1',
		showOverflowtooltip: true,
	},
	{
		prop: 'printStatus',
		label: '打印状态',
		filter: (val) => (val == 1 ? '未打印' : '已打印'),
	},
	{
		prop: 'createTime',
		label: '时间',
		filter: parseTime,
		minWidth: 160,
		showOverflowtooltip: true,
	},
	{
		prop: 'groupClass',
		label: '班次',
		showOverflowtooltip: true,
	},
];
export default {
	name: 'Printed',
	data() {
		return {
			formConfig: [
				{
					type: 'select',
					label: '产线',
					selectOptions: [],
					param: 'lineId',
					filterable: true,
				},
				{
					type: 'datePicker',
					label: '时间段',
					dateType: 'daterange',
					format: 'yyyy-MM-dd HH:mm:ss',
					valueFormat: 'yyyy-MM-dd HH:mm:ss',
					rangeSeparator: '-',
					startPlaceholder: '开始时间',
					endPlaceholder: '结束时间',
					param: 'timeVal',
					defaultSelect: [],
					width: 350,
				},
				{
					type: 'button',
					btnName: '查询',
					name: 'search',
					color: 'primary',
				},
			],
			// 查询参数
			queryParams2: {
				pageNo: 1,
				pageSize: 20,
				printStatus: '2',
				lineId: '',
				createTime: [],
			},
			total2: 0,
			tableProps,
			list2: [],
			tableBtn2: [
				this.$auth.hasPermi('base:order-group:update')
					? {
							type: 'reprint',
							btnName: '重打',
					  }
					: undefined,
				this.$auth.hasPermi('base:order-group:query')
					? {
							type: 'detail',
							btnName: '详情',
					  }
					: undefined,
				this.$auth.hasPermiAnd([
					'base:order-group:update',
					'base:core-product:query',
					'base:core-customer:query',
				])
					? {
							type: 'edit',
							btnName: '编辑',
					  }
					: undefined,
			].filter((v) => v),
		};
	},
	mounted() {
		this.getLineList();
	},
	methods: {
		getLineList() {
			getCorePLList().then((res) => {
				console.log(res);
				this.formConfig[0].selectOptions = res.data;
			});
		},
		getList2() {
			getPackingPage({ ...this.queryParams2 }).then((res) => {
				console.log(res);
				this.list2 = res.data.records || [];
				this.total2 = res.data.total;
			});
		},
		buttonClick2(val) {
			console.log(val);
			this.queryParams2.lineId = val.lineId;
			this.queryParams2.createTime = val.timeVal;
			this.getList2();
		},
		handleClick2() {},
	},
};
</script>
