<template>
	<div class="sel-confirm-module">
		<!-- 列表 -->
		<time-axis v-if="!$util.isEmpty(orderComData)">
			<!-- 送达 -->
			<timeaxis-item class="axis-list axis-first com-wrap" bgcolor="none">
				<template v-slot:node>
					<div class="tui-node node-big">
						<div class="node-small"></div>
					</div>
				</template>
				<template v-slot:content>
					<div class="axis-slot-wrap">
						<div class="axis-title">送达</div>
						<div class="axis-det express-wrap">
							<button class="admin-button-com big blue" @click="confirmFn">确认已送达</button>
							<div class="button-prompt">送达会自动通知客户哦</div>
						</div>
					</div>
				</template>
			</timeaxis-item>
			<!-- 发货 -->
			<timeaxis-item class="axis-list confirm-wrap" bgcolor="none">
				<template v-slot:content>
					<div class="axis-slot-wrap">
						<div class="axis-title">{{ orderComData[1].actionName }}</div>
						<div class="axis-det">
							<div class="app-color-0 app-bold">{{ orderComData[1].addTime | formatTime }}</div>
							<block v-if="!$util.isEmpty(orderComData[1].sendInfo)">
								<div>配送方：{{ orderComData[1].sendInfo.sendSideName }}</div>
								<div>距离：{{ orderComData[1].sendInfo.sendDistance }}km</div>
								<div>运费：¥{{ orderComData[1].sendInfo.sendCost }}</div>
								<div>小费：¥{{ orderComData[1].sendInfo.sendTip }}</div>
								<div>
									<span>状态：</span>
									<span class="app-color-4">{{ orderComData[1].sendInfo.sendStatus | constantfilter('SEND_STATUS') }}</span>
								</div>
							</block>
							<block v-else>
								<div>配送方：自己送</div>
							</block>
						</div>
					</div>
				</template>
			</timeaxis-item>
			<!-- 打单 -->
			<timeaxis-item class="axis-list com-wrap" bgcolor="none">
				<template v-slot:content>
					<div class="axis-slot-wrap">
						<div class="axis-title">{{ orderComData[2].actionName }}</div>
						<div class="axis-det">
							<div class="app-bold">{{ orderComData[2].addTime | formatTime }}</div>
							<card-name :info="orderComData[2].receive" />
							<div class="btn-wrap-com">
								<!-- <button class="admin-button-com default">明细</button> -->
								<button class="admin-button-com default">重打</button>
							</div>
						</div>
					</div>
				</template>
			</timeaxis-item>
			<!-- 下单 -->
			<timeaxis-item class="axis-list com-wrap" bgcolor="none">
				<template v-slot:content>
					<div class="axis-slot-wrap">
						<div class="axis-title">{{ orderComData[3].actionName }}</div>
						<div class="axis-det">
							<div class="app-color-0 app-bold">{{ orderComData[3].addTime | formatTime }}</div>
						</div>
					</div>
				</template>
			</timeaxis-item>
		</time-axis>
	</div>
</template>

<script>
import TimeAxis from '@/admin/home/components/plugin/time-axis'
import TimeaxisItem from '@/admin/home/components/plugin/timeaxis-item'
import CardName from './card-name'
// api
import { orderReach } from '@/api/order'
export default {
	name: 'sel-confirm-module',
	components: {
		TimeAxis,
		TimeaxisItem,
		CardName
	},
	props: {
		query: {
			type: Object,
			default: () => {}
		},
		orderData: {
			type: Object,
			default: () => {}
		},
		orderComData: {
			type: Array,
			default: () => []
		}
	},
	methods: {
		confirmFn() {
			orderReach({
				id: this.orderData.id,
				option: 1
			}).then(res => {
				this.$msg('确认送达成功！')
				setTimeout(() => {
					this.$util.pageTo({
						url: '/admin/order/ship',
						query: {
							id: this.query.id,
							pageStatus: 5
						}
					})
				}, 1000)
			})
		}
	}
}
</script>

<style lang="scss" scoped>
	// 发货
	.confirm-wrap {
		.axis-det {
			margin-top: 20px;
			margin-bottom: 10px;
			color: $fontColor2;
			& > div {
				margin-top: 14px;
				&:first-child {
					margin-top: 0;
				}
			}
			.admin-button-com {
				width: 120px;
				margin-top: 20px;
			}
			.modify-btn {
				color: $mainColor;
				font-size: 24px;
				margin-left: 30px;
			}
		}
	}
	// 打单
	.com-wrap {
		.axis-det {
			margin-top: 14px;
			& > div {
				margin-top: 20px;
				&:first-child {
					margin-top: 0;
				}
			}
		}
		.express-wrap {
			.admin-button-com {
				width: 100%;
			}
			.button-prompt {
				text-align: center;
				color: $fontColor2;
			}
		}
	}
</style>
