<template>
	<view>
		<view class="tabs-container">
			<u-subsection :list="tabList" :current="activeName" @change="handleTabChange"
				active-color="#157a2c"></u-subsection>
		</view>
		<view class="kd-baseInfo" v-if="activeName === 0">
			<view class="kd-cell">
				<text class="kd-label">盘点名称</text>
				<text class="kd-content">{{ baseInfo.name }}</text>
			</view>
			<view class="kd-cell">
				<text class="kd-label">单据编号</text>
				<text class="kd-content">{{ baseInfo.code }}</text>
			</view>
			<view class="kd-cell">
				<text class="kd-label">盘点仓库</text>
				<text class="kd-content">{{ baseInfo.warehouseName }}</text>
			</view>
			<view class="kd-cell">
				<text class="kd-label">盘点部门</text>
				<text class="kd-content">{{ baseInfo.executeGroupName }}</text>
			</view>
			<view class="kd-cell">
				<text class="kd-label">盘点人员</text>
				<text class="kd-content">{{ baseInfo.executorName }}</text>
			</view>
			<view class="kd-cell">
				<text class="kd-label">计划盘点时长</text>
				<text class="kd-content">{{ baseInfo.executorDuration }} 分钟</text>
			</view>
			<view class="kd-cell">
				<text class="kd-label">备注</text>
				<text class="kd-content">{{ baseInfo.remark }}</text>
			</view>
		</view>
		<view class="list" v-if="activeName === 1">
			<AssetsCard2 v-for="(item, index) in baseInfo.planDetailVOS" class="kd-row" :key="index" :item="item"
				:index="index+Number(1)" />
		</view>
		<view class="list" v-if="activeName === 2">
			<AssetsCard v-for="(item, index) in list" class="kd-row" :key="index" :item="item"
				:index="index+Number(1)" />
		</view>
	</view>
</template>

<script>
	import CellInfo from '@/components/CellInfo.vue'
	import AssetsCard from './AssetsCard.vue'
	import AssetsCard2 from './AssetsCard2.vue'
	export default {
		components: {
			CellInfo,
			AssetsCard,
			AssetsCard2
		},
		props: {
			baseInfo: {
				type: Object,
				default: () => ({})
			},
			list: {
				type: Array,
				default: () => []
			},
			type: {
				type: String,
				default: ''
			}
		},
		computed: {
			sum() {
				return this.list.reduce((sum, item) => {
					if (item.takeStockPattern) {
						sum += +item.amount
					} else {
						sum += item.detailReqList?.length || 0
					}

					return sum
				}, 0)
			}
		},
		data() {
			return {
				tabList: ['基本信息', '盘点清单', '报损报溢清单'],
				activeName: 0,
				statusList: {
					0: '未提交',
					1: '审核中',
					2: '已完成'
				},
				statusClass: {
					0: 'text-danger',
					1: 'text-primary',
					2: 'text-primary'
				}
			}
		},
		methods: {
			handleTabChange(val) {
				this.activeName = val
			}
		}
	}
</script>

<style lang="scss" scoped>
	/deep/.u-subsection__item__text {
		font-size: 28rpx !important;
	}

	.tabs-container {
		height: 80rpx;
	}

	.kd-baseInfo {
		padding: 0 32rpx;
		font-size: 28rpx;

		.kd-cell {
			line-height: 90rpx;
			border-bottom: 1px dashed #dadada;
			display: flex;
			justify-content: space-between;

			.kd-label {
				display: inline-block;
				width: 7em;
				font-weight: bold;
			}

			.kd-content {
				flex: 1;
				text-align: left;
				word-break: break-all;
			}
		}
	}


	.list {
		margin: 0 20rpx 20rpx 20rpx;
		// border: 1rpx solid rgba(204, 204, 204, 1);
	}

	.kd-row {
		font-size: 28rpx;
		padding: 14rpx 12rpx 6rpx;
		border-bottom: 1rpx solid $page-bg;

		.kd-col {
			display: flex;
			justify-content: space-between;
			align-items: center;
			color: #aaaaaa;

			>text {
				flex: 1;
			}

			.label {
				margin-right: 20rpx;
			}

			&.kd-col {
				margin-top: 25rpx;
			}

			.status {
				background-color: $page-bg;
				display: inline-block;
				padding: 4rpx 10rpx;
				border-radius: 18rpx;
			}
		}

		.title {
			font-weight: bold;
			color: #333333;
		}
	}
</style>