<template>
	<view>
		<mescroll-empty :option="option" v-if="list.length === 0"></mescroll-empty>
		<view class="data-house-list" v-else>
			<view class="data-house-item" v-for="(item,index) in list" :key="item.id" @click="clickBim(item)">
				<image class="image"
					src="https://assets.api.uizard.io/api/cdn/stream/c05650d2-192b-4a56-ae97-05638f53804c.png"
					mode="aspectFill"></image>
				<view class=" content">
					<view class="title">{{item.name}}</view>
					<view class="sub">
						<text>位置：</text><text>{{item.projectItemName}}</text>-<text>{{item.projectItemTargetName}}</text>
					</view>
					<view class="sub"><text>上传人：</text><text>{{item.createUserName}}</text></view>
				</view>
				<view class="hui-table-tag">
					<view class="hui-tag success" v-if="item.status === 2">转换成功</view>
					<view class="hui-tag warning" v-if="item.status === 1">转换中</view>
					<view class="hui-tag info" v-if="item.status === 0">等待转换</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		getBimList
	} from '@/request/api/bim.js'
	export default {
		data() {
			return {
				option: {
					tip: '暂无模型数据'
				},
				list: [],
			}
		},
		onLoad() {
			this.init();
			uni.$on('reloadData', () => {
				this.mescroll.resetUpScroll();
			})
		},
		onShow() {},
		methods: {
			init() {
				getBimList(this.$store.getters.project.id).then(res => {
					if (res.code === 200) {
						this.list = res.data;
					}
				})
			},
			clickBim(item) {
				if (item.status === 1) return this.$toast('模型转换中');
				if (item.status === 0) return this.$toast('该模型暂未转换');
				this.$navigateTo('/pages/bimShow/bimShow?title=' + item.name + '&fileId=' + item.bimfaceInfo.fileId +
					'&type=model&showType=1');
			}
		}
	}
</script>

<style lang="scss">
	.data-house-list {
		padding: 30rpx;

		.data-house-item {
			height: 200rpx;
			background: #fff;
			display: flex;
			align-items: center;
			border-radius: 16rpx;
			box-shadow: 0px 1px 12px rgba(3, 3, 3, 0.08);
			padding: 0 30rpx;
			margin-bottom: 30rpx;
			position: relative;
		}

		.hui-table-tag {
			position: absolute;
			bottom: 30rpx;
			right: 30rpx;
		}

		.image {
			width: 200rpx;
			height: 140rpx;
			border-radius: 8rpx;
		}

		.content {
			margin-left: 20rpx;
			flex: 1;
			width: 0;
			overflow: hidden;
		}

		.title {
			font-size: 32rpx;
			font-weight: 600;
			margin-bottom: 10rpx;
			overflow: hidden;
			white-space: nowrap;
			text-overflow: ellipsis;
		}

		.sub {
			font-weight: 300;
			font-size: 24rpx;
			margin-top: 10rpx;
			color: $uni-secondary-color;
		}

		.const {
			display: flex;
			align-items: center;

			.const-item {
				display: flex;
				align-items: center;
				color: $uni-secondary-color;
				margin-right: 20rpx;
			}

			.text {
				margin-left: 6rpx;
			}
		}
	}
</style>