<template>
	<view class="Urgent-Work-List"
	:style="{margin}"
	@click="$emit('click')">
		<view class="Work-List">
			<view class="label">
				任务号：
			</view>
			<view class="text">
				{{ obj.taskNo }}
			</view>
		</view>
		
		<view class="Work-List">
			<view class="label">
				担当信息：
			</view>
			<view class="text">
				{{ obj.responsibler }}
			</view>
		</view>
		
		<view class="Work-List">
			<view class="label">
				机型信息：
			</view>
			<view class="text">
				{{ obj.model }}
			</view>
		</view>
		
		<view class="Work-List">
			<view class="label">
				数量：
			</view>
			<view class="text">
				{{ obj.number }}
			</view>
		</view>
		
		<view class="Work-List">
			<view class="label">
				工单状态：
			</view>
			<view class="text">
				{{ obj.statusId_dictText }}
			</view>
		</view>
		
		<view class="Work-List"
		v-if="isShowCollect">
			<view class="modi"
			v-if="obj.collectonFlag"
			@click.stop="addCollection">
				收藏
			</view>
			<view class="modi a"
			v-else
			@click.stop="addCollection">
				取消收藏
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		name: "WorkOrderitem",
		props : {
			obj : {},
			margin : {
				default : '30rpx 0'
			},
			isShowCollect : {
				default : false,
			}
		},
		data() {
			return {

			};
		},
		methods : {
			//收藏信息-添加收藏
			addCollection(){
				this.$api('addCollection', {
					templateId : this.obj.id
				}, res => {
					this.$emit('getData')
					if(res.code == 200){
						uni.showToast({
							title: this.obj.collectonFlag ? '收藏成功' : '取消成功',
							icon: 'none'
						})
						this.obj.collectonFlag = !this.obj.collectonFlag
					}
				})
			},
		}
	}
</script>

<style scoped lang="scss">
	.Urgent-Work-List{
		box-shadow: 0 0 10rpx 10rpx #00000009;
		border-radius: 25rpx;
		padding: 15rpx;
		background-color: #fff;
		font-size: 28rpx;
		.Work-List{
			display: flex;
			padding: 20rpx 0rpx;
			.label{
				width: 150rpx;
				flex-shrink: 0;
			}
			
			.modi{
				padding: 15rpx 30rpx;
				border-radius: 15rpx;
				background-color: $uni-color;
				color: #fff;
				font-size: 22rpx;
				margin-left: auto;
			}
			.a{
				background-color: #fff;
				border: 1rpx solid $uni-color;
				color: $uni-color;
			}
		}
	}
</style>