<template>
	<view class="">
		<view @click="goDetail(item)" class="data" v-for="(item, index) in list" :key="index">
			<view class="top">
				<view class="left">
					<view class="title">
						<text>工单编号：{{item.repairNo}}</text>
						<text @click.stop="copy(item.repairNo)" class="padding-left-20">复制</text>
					</view>
				</view>
				<view class="right">
					<text class="text-red" v-if="item.handleStatus==-1">已取消</text>
					<text class="text-orange" v-if="item.handleStatus==0">待处理</text>
					<text class="" v-if="item.handleStatus==1">已完成</text>
					<text class="text-orange" v-if="item.handleStatus==2">待评价</text>
				</view>
			</view>
			<view class="item">
				<view class="left">
					<view style="padding: 0 30rpx;">
						<view class="content">
							<text class="padding-right-10">所在小区：</text>
							<text >{{item.residentialName}}</text>
						</view>
						<view class="content">
							<text class="padding-right-10">维修位置：</text>
							<text>{{item.reportPosition}}</text>
						</view>
						<view class="content">
							<text class="padding-right-10">故障描述：</text>
							<text style="line-height: 50rpx;">{{item.reportDetail}}</text>
						</view>
					</view>
				</view>
			</view>
			<view class="bottom" >
				<button @click.stop="" open-type="contact" class="cu-btn  sm round line-black margin-right-20" >
					联系客服
				</button>
				<!-- 待处理，显示取消工单 -->
				<view v-if="item.handleStatus==0" class="cu-btn  sm round bg-red" @click.stop="cancel(item)">
					取消工单
				</view>
				<!-- 已取消，显示删除订单 -->
				<view v-if="item.handleStatus==-1" class="cu-btn  sm round bg-red" @click.stop="deleteItem(item)">
					删除工单
				</view>
				<!-- 已完成，显示写评价 -->
				<view v-if="item.handleStatus==1" class="cu-btn  sm round bg-red" @click.stop="comment(item)">
					写评价
				</view>
			</view>
		</view>
	</view>
</template>

<script>
export default {
	name: 'card',
	props:{
		list:{
			type:Array,
			default:()=>{
				[]
			}
		}
	},
	data() {
		return {
			
		};
	},
	onLoad() {
		
	},
	methods:{
		copy(data){
			uni.setClipboardData({
				data:data
			})
		},
		goDetail(item){
			getApp().globalData.dataDetail=item
			uni.navigateTo({
				url:"../detail?id="+item.id
			})
		},
		cancel(item){
			this.$emit('cancel',item)
		},
		comment(item){
			getApp().globalData.dataDetail=item
			uni.navigateTo({
				url:"../comment"
			})
		},
		deleteItem(item){
			this.$emit('deleteItem',item)
		},
	}
};
</script>

<style lang="scss">
.data {
	width: 710rpx;
	background-color: #ffffff;
	margin: 20rpx auto;
	border-radius: 6rpx;
	box-sizing: border-box;
	padding: 20rpx;
	font-size: 28rpx;
	.top {
		display: flex;
		justify-content: space-between;
		padding-bottom: 20rpx;
		border-bottom: 1rpx solid $dt-border-color-sm;
		.left {
			display: flex;
			align-items: center;
			.title {
				margin: 0 10rpx;
				font-size: 30rpx;
			}
		}
		.right{
			margin-right: 10rpx;
		}
	}
	.item {
		margin: 5rpx 0 20rpx 0;
		.content {
			border-bottom: 1rpx dashed #DDDDDD;
			padding: 30rpx 0;
		}
	}
	.bottom {
		display: flex;
		margin-top: 30rpx;
		justify-content: flex-end;
		align-items: center;
	}
}
</style>
