<template>
	<view class="marginTop">
		<u-list>
			<u-list-item v-for="(item, index) in list" :key="index" v-show="list.length !== 0">
				<view class="card_box" @click="goDetail(item)">
					<view class="item_box flex_between">
						<view class="rx-sc">
							<view class="round">{{ Number(index) + 1 }}</view>
							<view class="orderId">{{ item.code }}</view>
						</view>
						<view class="state">{{ dict.status[item.status] }}</view>
					</view>
					<view class="item_box rx-bc">
						<view class="item_one perce50 rx-sc">
							<view class="lable">任务类型：</view>
							<view>{{ getDict('logistic_delivery_type', item.taskType) }}</view>
						</view>
					</view>
					<view class="item_box rx-bc">
						<view class="item_one perce50 rx-sc">
							<view class="lable">任务名称：</view>
							<view>{{ item.taskCode }}</view>
						</view>
					</view>
					<div v-if="type == 2">
						<view class="item_box rx-bc">
							<view class="item_one perce50 rx-sc">
								<view class="lable">开始时间：</view>
								<view>{{ item.realStartTime }}</view>
							</view>
						</view>
						<view class="item_box rx-bc">
							<view class="item_one perce50 rx-sc">
								<view class="lable">完成时间：</view>
								<view>{{ item.realEndTime }}</view>
							</view>
						</view>
					</div>
					<div v-else>
						<view class="item_box rx-bc">
							<view class="item_one perce50 rx-sc">
								<view class="lable">应开工时间：</view>
								<view>{{ item.planTimeStart }}</view>
							</view>
						</view>
						<view class="item_box rx-bc">
							<view class="item_one perce50 rx-sc">
								<view class="lable">应完成时间：</view>
								<view>{{ item.planTimeEnd }}</view>
							</view>
						</view>
					</div>
				</view>
			</u-list-item>
			<u-list-item v-if="list.length === 0">
				<view style='margin-top: 20vh;'>
					<u-empty iconSize='150' textSize='32' text='暂无数据'></u-empty>
				</view>
			</u-list-item>
		</u-list>
	</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;
	}

	.card_box {
		width: 750rpx;
		padding: 16rpx 32rpx;
		box-sizing: border-box;
		border-bottom: 2rpx solid #E1E1E1;

		.item_box {
			margin-top: 10rpx;

			.round {
				width: 40rpx;
				height: 40rpx;
				line-height: 40rpx;
				border-radius: 50%;
				background: $theme-color;
				color: #fff;
				text-align: center;
				font-size: 20rpx;
			}

			.orderId {
				color: #000;
				font-family: PingFang HK;
				font-size: 28rpx;
				font-style: normal;
				font-weight: 600;
				margin-left: 16rpx;
			}

			.item_one {
				width: 100%;
				font-size: 26rpx;
				font-style: normal;
				font-weight: 400;
				line-height: 38rpx;
				word-wrap: break-word;
			}

			.perce50 {
				width: 100%;
			}
		}

		.flex_between {
			display: flex;
			justify-content: space-between;
		}
	}

	.state {
		font-size: 28rpx;
		background-color: $page-bg;
		display: inline-block;
		padding: 2px 5px;
		border-radius: 18rpx;
	}
</style>