<template>
	<view class="marginTop">
		<view class="list-wrap" v-for="(item, index) in list" :key="index" v-show="list.length !== 0"
			@click="goDetail(item)">
			<view class="item">
				<view class="s1">
					<text class="title">{{ item.code }}</text>
				</view>
				<!-- <view class="s2">
					{{ item.createTime }}
				</view> -->
			</view>
			<view class="item">
				<view class="s1">任务类型：{{getDict('logistic_delivery_type',item.taskType ) }}</view>
			</view>
			<view class="item">
				<view class="s1">任务名称:{{ item.taskCode }}</view>
			</view>
			
			<div v-if="type==2">
				<view class="item">
					<view class="s1">开始时间:{{ item.realStartTime}}</view>
				</view>
				<view class="item">
					<view class="s1">完成时间:{{ item.realEndTime }}</view>
				</view>
			</div>
			<div v-else>
				<view class="item">
					<view class="s1">应开工时间:{{ item.planTimeStart}}</view>
				</view>
				<view class="item">
					<view class="s1">应完成时间:{{ item.planTimeEnd }}</view>
				</view>
			</div>
			<view class="item">
				<view class="s1">
					<view class="state">
						{{ dict.status[item.status] }}
					</view>
				</view>
			</view>
		</view>
		<view v-show="list.length === 0" class="no_data">
			<u-empty mode="data"></u-empty>
		</view>
	</view>
</template>

<script>
	export default {
		props: {
			type: {
				type: [String, Number]
			},
			list: {
				type: Array,
				default: () => []
			},
			dictList: {
				type: Object,
				default: () => {}
			},
		},

		computed: {
			getDict() {
				return (dictName, val) => {
					let find = this.dictList[dictName].find(item => item[val]) || {}
					return find[val] ? find[val] : ''
				}
			}
		},
		data() {
			return {
				dict: {
					status: {
						0: '待接收',
						1: '执行中',
						2: '已完成'
					},
					//紧急程度
					urgent: {
						1: '普通',
						2: '紧急',
						3: '重要'
					}
				}
			}
		},
		methods: {
			goDetail(item) {
				item.dictList = this.dictList
				let jsonItem = JSON.stringify(item)
				uni.navigateTo({
					url: `/pages/dispatchManage/taskWork/detail?item=${jsonItem}`
				})
			},
			isClass() {
				switch (String(this.type)) {
					case '0':
						return 'd1'
						break
					case '1':
						return 'd2'
						break
					case '3':
						return 'd3'
						break
					default:
						break
				}
			}
		}
	}
</script>

<style lang="scss" scoped>
	.marginTop {
		border-top: 20rpx solid $page-bg;
	}

	.center {
		text-align: center;
		margin-bottom: 10rpx;
		color: #999;
	}

	.no_data {
		position: fixed;
		top: 50%;
		left: 50%;
		transform: translate(-50%, -50%);
		color: #999;
		font-size: 28rpx;
	}

	.list-wrap {
		padding: 10rpx;

		.item {
			display: flex;
			justify-content: space-between;
			padding: 10rpx;
			color: rgb(170, 170, 170);
			font-size: 28rpx;
			word-break: break-all;

			.title {
				color: #333333;
				font-size: 28rpx;
			}

			.state {
				font-size: 12px;
				color: #7f7f7f;
				background: #f1f1f1;
				display: inline;
				padding: 2px 5px;
				border-radius: 10px;
			}
		}

		&+.list-wrap {
			border-top: 1px solid rgba(242, 242, 242, 1);
		}
	}
</style>