<template>
	<view>
		<view class="tabs-container">
			<u-subsection :list="tabList" :current="activeName" @change="changeTab"
				active-color="#157a2c"></u-subsection>
		</view>
		<view v-if="activeName == 0" class="kd-baseInfo">
			<view class="kd-cell" v-if="type !== 'view'">
				<text class="kd-label">调拨名称</text>
				{{ baseInfo.name }}
			</view>
			<view class="kd-cell" v-if="type !== 'view'">
				<text class="kd-label">调拨单号</text>
				{{ baseInfo.allotCode }}
			</view>
			<view class="kd-cell">
				<text class="kd-label">调拨类型</text>
				{{ baseInfo.type == 1 ? '库内调拨' : '库外调拨' }}
			</view>
			<view class="kd-cell">
				<text class="kd-label">调出库</text>
				{{baseInfo.sourceWarehouse }}
			</view>
			<view class="kd-cell">
				<text class="kd-label">调入库</text>
				{{ baseInfo.targetWarehouse}}
			</view>
			<view class="kd-cell">
				<text class="kd-label">创建人</text>
				{{ baseInfo.allotName }}
			</view>
			<view class="kd-cell">
				<text class="kd-label">创建时间</text>
				{{ baseInfo.createTime }}
			</view>
			<view class="kd-cell">
				<text class="kd-label">状态</text>
				<view :class="statusClass[baseInfo.status]">{{ type === 'view' ? '草稿' : statusList[baseInfo.status] }}
				</view>
			</view>

			<!-- <template v-if="type !== 'view'">
				<CellInfo label="创建时间" :value="baseInfo.createTime" />
				<CellInfo label="提交时间" :value="baseInfo.submissionTime" />
				<CellInfo label="审核时间" :value="baseInfo.auditorTime" />
				<CellInfo label="审核说明" :value="baseInfo.auditCause" />
			</template> -->
		</view>
		<view class="list" v-if="activeName === 1">
			<AssetsCard v-for="(item, index) in list" class="kd-row" type="detail" :key="index" :item="item"
				:index="index+Number(1)" />
		</view>
	</view>
</template>

<script>
	import CellInfo from '@/components/CellInfo.vue'
	import AssetsCard from './AssetsCard.vue'
	export default {
		components: {
			CellInfo,
			AssetsCard
		},
		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: {
			changeTab(val) {
				this.activeName = val
			}
		}
	}
</script>

<style lang="scss" scoped>
	.tabs-container {
		height: 80rpx;
	}

	/deep/.u-subsection__item__text {
		font-size: 28rpx !important;
	}

	/deep/.u-cell__body {
		// {
		// 	font-size: 26rpx !important;
		// }
		// padding: 12rpx 12rpx;

		.u-cell__title-text,
		.input-value,
		.uni-input-wrapper {
			font-size: 26rpx !important;
		}
	}

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

	.kd-cell {
		min-height: 90rpx;
		border-bottom: 1px dashed #dadada;
		display: flex;
		align-items: center;

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

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


	.list {
		// margin: 20rpx 40rpx;
		// 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>