<template>
	<view class="history">
		<view class="item" v-for="(item, i) in instockHistory">
			<text class="code" :style="{ color: item.status ? 'green' : '#666' }">
				{{ item.orderNum }}
				<text v-if="item.batch_text">批次号: {{ item.batch_text }}</text>
				<text v-if="item.space">仓位编码: {{ item.space }}</text>
				{{ item.type }}
			</text>
			<uni-icons v-if="item.status" type="checkmarkempty" class="status" size="16" color="green"></uni-icons>
			<text class="status fail" v-else>F</text>
			<text style="margin-left: 10rpx; font-weight: 300">
				{{ '\r\n' + item.createTime }}
			</text>
		</view>
		<view v-if="instockHistory.length === 0" class="is-empty">暂无历史</view>
	</view>
</template>

<script setup lang="ts">
import { reactive, ref } from 'vue';
import { onLoad } from '@dcloudio/uni-app';
const instockHistory = ref([]);
const getHistory = () => {
	instockHistory.value = uni.getStorageSync('instockHistory');
};
onLoad(() => {
	getHistory();
});
</script>

<style lang="scss" scoped>
.history {
	display: flex;
	width: 100%;
	flex-direction: column;
	justify-items: start;

	.title {
		padding: 20rpx;
		font-size: 24rpx;
		font-weight: 600;
	}
	.type {
		padding-right: 20rpx;
		font-size: 24rpx;
	}
	.code {
		font-weight: 600;
	}

	.item {
		padding: 20rpx;
		font-size: 20rpx;
		color: #666;

		.status {
			padding-left: 20rpx;
		}

		.fail {
			font-weight: 600;
			color: #f00;
		}
	}

	.is-empty {
		text-align: center;
		margin: 40px 0;
		color: #999;
	}
}
</style>
