<template>
	<view class="container">
		<view class="shop-box" style="border-top:5px solid #eee;" v-for="(item,index) in shopList" :key="index">
			<view class="shop-name" style="position: relative;">
				<img class="img-radius" :src="item.productPicture" alt=""
					style="width: 140rpx;height: 140rpx;margin: 30rpx 0 0 30rpx;" v-if="item.productPicture">
				<view class="noPic" v-else>暂无图片</view>
				<view class="shop-productName">
					<view style="color:#FF5809;">{{item.productName}}
						（{{item.productSn == null ? '暂无':item.productSn}}）
					</view>
					<view>库存总数:{{item.stockCount == null ? '暂无':item.stockCount}}</view>
					<view>
						预警值：{{item.tailWarn == null ? '暂无':item.tailWarn}}
					</view>
				</view>
			</view>
			<view class="shop-type">
				<view class="shop-collapse"
					v-for="(item1,index1) in item.stockAttributeVoList" :key='index1'>
					<text>{{item1.attributeList | sliceMsg}}</text>
					<text>数量：{{item1.stockCount}}</text>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				shopList: []
			}
		},
		filters: {
			sliceMsg(val) {
				var name = ''
				if (typeof(val) == 'string') {
					let newObj = JSON.parse(val)
					for (let as in newObj) {
						name += newObj[as] + '/'
					}
				}
				return name;
			}
		},
		onLoad() {
			this.warnList()
		},
		methods: {
			warnList(){
				this.tui.request('/app/stock/getTailWarnProduct', 'post', {}, false, false).then(res => {
					if(res.code == 200){
						this.shopList = res.result
					}
				})
			}
		},
	}
</script>

<style lang="scss">
	.container {
		padding-bottom: 118rpx;
		background: #fff;
	}
	.shop-box {
		width: 95%;
		margin: 0 auto;
	}
	.shop-name {
		width: 100%;
		height: 200rpx;
		line-height: 80rpx;
		border-top: 1px solid #eee;
		border-bottom: 1px solid #eee;
		font-size: 28rpx;
		font-weight: bold;
		display: flex;
	}
	.shop-productName {
		flex: 1;
		display: flex;
		flex-direction: column;
		padding-left: 20rpx;
	}
	.shop-productName view {
		height: 55rpx;
	}
	.shop-collapse {
		display: flex;
		height: 80rpx;
		font-size: 26rpx;
		line-height: 80rpx;
	}
	.shop-collapse text {
		flex: 1;
		text-align: center;
		border-right: 1px solid #eee;
	}
	.noPic {
		border-radius: 10px;
		width: 140rpx;
		height: 140rpx;
		margin: 30rpx 0 0 30rpx;
		text-align: center;
		line-height: 140rpx;
		color: #777;
		background: #eee;
	}
</style>