<template>
	<view style="background-color: #fff" v-if="reportList.length>0">
		<u-checkbox size="25" iconSize="25" activeColor="green" labelSize='40rpx' :label="'全选'" @change="selectAll"
			v-if="reportList.length>0" :checked="selectAllChecked">
		</u-checkbox>
		<u-checkbox-group v-model="checked" @change="getCheckedList" :borderBottom="true" placement="column"
			iconPlacement="right" style="height: 80vh;overflow: scroll;overflow-wrap:anywhere">
			<u-checkbox size="25" iconSize="25" activeColor="green" v-for="(item, index) in reportList" :key="index"
				:disabled="item.disabled" :name="item.id" :label="'\n'+' 序号 : '+(index+1)+'\n\n'+
				'物料编码 : '+(item.ptNoTar?item.ptNoTar:'')+'\n\n'+
				'物料名称 : '+(item.ptTitleTar?item.ptTitleTar:'')+'\n\n'+
				'物料规格 : '+(item.specification1?item.specification1:'')+'\n\n'+
				'数量 : '+(item.reportNumber?item.reportNumber:'')+'\n\n'+
				'仓库 : '+(item.whCode?item.whCode:'')+'\n\n'+
				'合并标签号 : '+(item.singleReportSign? item.singleReportSign:'')+'\n\n'+
				'失败原因 : '+(item.remark? item.remark:'')+'\n'
				">
			</u-checkbox>
		</u-checkbox-group>
		<u-button type="primary" @click="submit" v-if="reportList.length>0">提交</u-button>
	</view>
	<view v-else style="text-align: center;">
		查询无记录
	</view>
</template>

<script>
	import {
		listMesJobSingleReportSign,
		advListMesJobSingleReportSign,
		getMesJobSingleReportSign,
		delMesJobSingleReportSign,
		addMesJobSingleReportSign,
		updateMesJobSingleReportSign,
		reportConfirm,
		qualityConfirm,
		whInConfirm
	} from "@/api/mes/mesJobSingleReportSign";

	export default {
		mounted() {
			this.query()
		},
		data() {
			return {
				selectAllChecked: false,
				checked: [],
				ids: [],
				reportList: [],
				rightOptions: [{
					text: '删除',
					style: {
						backgroundColor: '#ff2a17'
					}
				}, ],
			}
		},
		methods: {
			getCheckedList(e) {
				this.ids = e;
				// 判断当前选中的复选框数量，决定全选框的状态
				if (this.ids.length === this.reportList.length) {
					this.selectAllChecked = true;
				} else {
					this.selectAllChecked = false;
				}
			},
			selectAll() {
				// 点击全选按钮时，更新所有复选框的选中状态
				if (this.checked.length === this.reportList.length) {
					this.checked = [];
					this.selectAllChecked = false; // 全选框不选中
				} else {
					this.checked = this.reportList.map(item => item.id);
					this.selectAllChecked = true; // 全选框选中
				}
			},
			query() {
				listMesJobSingleReportSign({
					errStatus: 1,
					status: 0
				}).then(res => {
					this.reportList = res.rows
				})
			},
			submit() {
				// let ids = this.reportList.map(item => item.id)
				reportConfirm(this.ids)
				this.$tab.switchTab(
					"/pages/work/index");
			},

		}
	}
</script>

<style>
</style>