<template>
	<view>
		<u-popup :show="show" duration='300' :mode='mode' :closeOnClickOverlay='false'>
			<view class="content-box">

				<view class="list_box">
					<u-list @scrolltolower="scrolltolower">

						<checkbox-group v-for="(item, index) in list" :key="index"
							@change="e => selectVal(e, item, index)">
							<label class="listBox rx-bs">

								<view class="listBox-sel">
									<checkbox :value="item.code" color="#fff" :disabled="item.disabled"
										:checked="item.checked" />
								</view>

								<view class="listBox-con">
									<view class="listBox-top rx-bc">
										<view> {{ item.name }}</view>
										<view class="code">{{ item.code}}</view>
									</view>

									<view class="listBox-bottom rx">
										<view v-for="(itm, index) in tableH(item.rootCategoryLevelId)" :key="index"
											class="items">
											{{ itm.label }}：{{ item[itm.prop] }}
										</view>

										<view class="items">
											可用库存：{{ item.availableCountBase }} {{item.unit}}
										</view>

									</view>

								</view>


							</label>

						</checkbox-group>

					</u-list>
				</view>

				<view class="operate_box rx-sc">
					<u-button size="small" class="u-reset-button" @click="handleClose">取消</u-button>
					<u-button size="small" class="u-reset-button" type="success" @click="save">确认 </u-button>
				</view>

			</view>
		</u-popup>
	</view>
</template>

<script>
	import {
		tableHeader
	} from '../../common.js'
	export default {
		data() {
			return {
				show: true,
				mode: 'right',
				memoList: [],
				list: [{
						"id": "1753322665677725698",
						"createTime": "2024-02-02 15:41:13",
						"categoryId": "1740639160215891970",
						"name": "返工料",
						"rootCategoryLevelId": "1",
						"code": "W31000056388",
						"fixCode": "",
						"brand": "",
						"color": "",
						"weight": "",
						"purpose": "",
						"ownershipGroupId": "",
						"ownershipGroupName": "",
						"ownershipUserId": "",
						"repairGroupId": "",
						"repairUserId": "",
						"supplierId": "",
						"positionId": "",
						"roteId": "",
						"detailLocation": "",
						"imageUrl": "",
						"attUrl": "",
						"isIotEnable": 0,
						"iotId": "",
						"runStatus": "",
						"networkStatus": "",
						"extInfo": "",
						"extInfoSelf": "",
						"position": [{
							"id": "1753322666474643458",
							"substanceId": "1753322665677725698",
							"sourceBizNo": "W30000025534080013",
							"sourceType": 1,
							"sourceBatchNo": "080",
							"pathIds": "1745372293592903681,1745374089405132802,1745374089413521409,1745374089677762562",
							"pathName": "型材分公司-原料仓,1号库区,A,A-11",
							"minPositionId": "1745374089677762562",
							"detailPosition": "",
							"type": 2,
							"num": 1,
							"unit": "PCS",
							"minUnit": "桶",
							"deleted": 0,
							"createTime": "2024-02-02 15:41:13",
							"updateTime": "2024-02-02 15:41:13",
							"createUserId": "1683714098556100610",
							"updateUserId": "1683714098556100610"
						}],
						"category": {
							"id": "1740639160215891970",
							"createTime": "2024-01-01 23:41:29",
							"categoryLevelGroupId": "",
							"factoryCode": "",
							"price": "",
							"priceUnit": "",
							"categoryLevelGroupCode": "",
							"mrpControllerUser": "",
							"differenceCode": "",
							"mrpType": "",
							"categoryLevelGroupName": "",
							"categoryLevelId": "1738396672025526273",
							"categoryLevelName": "返工料",
							"name": "返工料",
							"code": "W30000025534",
							"categoryLevelPathIdParent": "",
							"categoryLevelPathId": "1,1738375428798509057,1738396672025526273",
							"categoryLevelPath": "物料-PR料-返工料",
							"measuringUnit": "PCS",
							"packingUnit": "箱",
							"brandNum": "YL10.2",
							"modelType": "YL10.2|BΦ16.0*100(MG)",
							"specification": "",
							"volume": "",
							"volumeUnit": "",
							"volumeUnitId": "",
							"roughWeight": 0,
							"netWeight": 50,
							"weightUnit": "KG",
							"weightUnitId": "",
							"isProduct": 0,
							"productCategoryLevelName": "",
							"deptId": "",
							"deptLeaderId": "",
							"iotProductKey": "",
							"remarkAttach": [],
							"remark": "",
							"description": "",
							"warrantyPeriod": "",
							"warrantyPeriodUnit": ""
						},
						"categoryDetail": "",
						"codeNumber": ""
					},
					{
						"id": "1747105301001793538",
						"createTime": "2024-01-16 11:55:38",
						"categoryId": "1739922471153106946",
						"name": "混合料",
						"rootCategoryLevelId": "1",
						"code": "S310000552732",
						"fixCode": "",
						"brand": "",
						"color": "",
						"weight": "",
						"purpose": "",
						"ownershipGroupId": "",
						"ownershipGroupName": "",
						"ownershipUserId": "",
						"repairGroupId": "",
						"repairUserId": "",
						"supplierId": "",
						"positionId": "",
						"roteId": "",
						"detailLocation": "",
						"imageUrl": "",
						"attUrl": "",
						"isIotEnable": 0,
						"iotId": "",
						"runStatus": "",
						"networkStatus": "",
						"extInfo": "",
						"extInfoSelf": "",
						"position": [{
							"id": "1747105301005987842",
							"substanceId": "1747105301001793538",
							"sourceBizNo": "IN202401160074",
							"sourceType": 2,
							"sourceBatchNo": "001",
							"pathIds": "test",
							"pathName": "test",
							"minPositionId": "-1",
							"detailPosition": "test",
							"type": 1,
							"num": 2,
							"unit": "KG",
							"minUnit": "KG",
							"deleted": 0,
							"createTime": "2024-01-16 11:55:38",
							"updateTime": "2024-01-16 11:55:38",
							"createUserId": "1683714098556100610",
							"updateUserId": "1683714098556100610"
						}],
						"category": {
							"id": "1739922471153106946",
							"createTime": "2023-12-29 00:13:37",
							"categoryLevelGroupId": "",
							"factoryCode": "10J0",
							"price": "",
							"priceUnit": "1",
							"categoryLevelGroupCode": "",
							"mrpControllerUser": "",
							"differenceCode": "",
							"mrpType": "",
							"categoryLevelGroupName": "",
							"categoryLevelId": "1738393436870770689",
							"categoryLevelName": "混合料",
							"name": "混合料",
							"code": "W31000055273",
							"categoryLevelPathIdParent": "",
							"categoryLevelPathId": "[1,1677145633090453506,1738393436870770689]",
							"categoryLevelPath": "物料,原料,混合料",
							"measuringUnit": "PCS",
							"packingUnit": "箱",
							"brandNum": "XU102",
							"modelType": "",
							"specification": "",
							"volume": "",
							"volumeUnit": "",
							"volumeUnitId": "",
							"roughWeight": 10,
							"netWeight": 10,
							"weightUnit": "KG",
							"weightUnitId": "",
							"isProduct": 0,
							"productCategoryLevelName": "",
							"deptId": "",
							"deptLeaderId": "",
							"iotProductKey": "",
							"remarkAttach": [],
							"remark": "XU102",
							"description": "",
							"warrantyPeriod": "",
							"warrantyPeriodUnit": ""
						},
						"categoryDetail": "",
						"codeNumber": ""
					},
					{
						"id": "1747105300896935938",
						"createTime": "2024-01-16 11:55:38",
						"categoryId": "1739922471153106946",
						"name": "混合料",
						"rootCategoryLevelId": "1",
						"code": "S310000552731",
						"fixCode": "",
						"brand": "",
						"color": "",
						"weight": "",
						"purpose": "",
						"ownershipGroupId": "",
						"ownershipGroupName": "",
						"ownershipUserId": "",
						"repairGroupId": "",
						"repairUserId": "",
						"supplierId": "",
						"positionId": "",
						"roteId": "",
						"detailLocation": "",
						"imageUrl": "",
						"attUrl": "",
						"isIotEnable": 0,
						"iotId": "",
						"runStatus": "",
						"networkStatus": "",
						"extInfo": "",
						"extInfoSelf": "",
						"position": [{
							"id": "1747105300993404930",
							"substanceId": "1747105300896935938",
							"sourceBizNo": "IN202401160074",
							"sourceType": 2,
							"sourceBatchNo": "001",
							"pathIds": "test",
							"pathName": "test",
							"minPositionId": "-1",
							"detailPosition": "test",
							"type": 1,
							"num": 2,
							"unit": "KG",
							"minUnit": "KG",
							"deleted": 0,
							"createTime": "2024-01-16 11:55:38",
							"updateTime": "2024-01-16 11:55:38",
							"createUserId": "1683714098556100610",
							"updateUserId": "1683714098556100610"
						}],
						"category": {
							"id": "1739922471153106946",
							"createTime": "2023-12-29 00:13:37",
							"categoryLevelGroupId": "",
							"factoryCode": "10J0",
							"price": "",
							"priceUnit": "1",
							"categoryLevelGroupCode": "",
							"mrpControllerUser": "",
							"differenceCode": "",
							"mrpType": "",
							"categoryLevelGroupName": "",
							"categoryLevelId": "1738393436870770689",
							"categoryLevelName": "混合料",
							"name": "混合料",
							"code": "W31000055273",
							"categoryLevelPathIdParent": "",
							"categoryLevelPathId": "[1,1677145633090453506,1738393436870770689]",
							"categoryLevelPath": "物料,原料,混合料",
							"measuringUnit": "PCS",
							"packingUnit": "箱",
							"brandNum": "XU102",
							"modelType": "",
							"specification": "",
							"volume": "",
							"volumeUnit": "",
							"volumeUnitId": "",
							"roughWeight": 10,
							"netWeight": 10,
							"weightUnit": "KG",
							"weightUnitId": "",
							"isProduct": 0,
							"productCategoryLevelName": "",
							"deptId": "",
							"deptLeaderId": "",
							"iotProductKey": "",
							"remarkAttach": [],
							"remark": "XU102",
							"description": "",
							"warrantyPeriod": "",
							"warrantyPeriodUnit": ""
						},
						"categoryDetail": "",
						"codeNumber": ""
					}
				]
			}
		},
		methods: {
			scrolltolower() {},

			save() {

			},

			//勾选
			selectVal(e, val, index) {
				this.list[index].checked = !this.list[index].checked



				const idx = this.memoList.findIndex(
					item => item.id === this.list[index].id
				)

				if (this.list[index].checked) {
					if (idx === -1) {
						this.memoList.push(this.list[index])
					}
				} else {
					if (idx > -1) {
						this.memoList.splice(idx, 1)
					}
				}

			},

	tableH(type) {
				return tableHeader(type)
			},
			handleClose() {
				this.$emit('close')
			},
		}
	}
</script>

<style lang="scss" scoped>
	.content-box {
		width: 80vw;
		height: 100vh;
		overflow: hidden;
		display: flex;
		flex-direction: column;
		background-color: $page-bg;
	}


	.list_box {
		flex: 1;
		overflow: hidden;
		padding: 4rpx 0;

		.u-list {
			height: 100% !important;
		}




	}


	.listBox {
		margin-top: 8rpx;
		padding: 8rpx 24rpx;
		background: #fff;


		/deep/ .uni-checkbox-input-checked {
			background-color: $theme-color !important;
			border-color: $theme-color !important;
		}

		.listBox-con {
			width: 650rpx;
			font-weight: 400;
		}

		.listBox-top {
			margin-top: 6rpx;
			color: #090A0A;
			font-size: 28rpx;
			font-style: normal;
		}

		.listBox-bottom {
			color: #090A0A;
			font-size: 24rpx;
			font-style: normal;
			flex-wrap: wrap;

			.items {
				width: 50%;
				margin-top: 8rpx;
			}
		}
	}

	.operate_box {
		background-color: #fff;
		padding: 10rpx 100rpx;

		/deep/ .u-button {
			width: 160rpx;
		}
	}
</style>