<template>
	<el-container>
		<el-main class="orderMain" v-loading="loading" element-loading-text="加载中...">
			<el-scrollbar>
				<detailView :data="info"></detailView>
			</el-scrollbar>
		</el-main>
	</el-container>
</template>

<script>
import detailView from "@/views/order/orderList/detailView";
export default {
	name: "order-info",
	components:{
		detailView
	},
	data(){
		return{
			loading:false,
			params:{
				order_id:Number(this.$route.query.id)
			},
			info:{}

		}
	},
	mounted() {
		this.getData();
	},
	methods:{
		async getData() {
			this.loading = true;
			const res = await this.$API.orders.order.maintenance.info.post(this.params);
			if(res.code == 200){
				if(res.data.process_engine){
					let obj = this.processList(res.data.process_engine);
					res.data.process_engine = obj.processedList;
					res.data.process_num = obj.num;
				}
				this.info = res.data;
			}
			this.loading = false;
		},
		processList(list) {
			let obj = {
				num:0,
				processedList:this.$TOOL.objCopy(list)
			}
			let foundNodeTrue = false;
			for (let i = 0; i < obj.processedList.length; i++) {
				if (obj.processedList[i].node === true) {
					foundNodeTrue = true;
					obj.processedList[i].status = 'finish';
					obj.num = i;
				} else if (!foundNodeTrue) {
					obj.processedList[i].status = 'success';
				}
				if (foundNodeTrue && obj.processedList[i].node !== true) break;
			}
			return obj;
		}
	}
}
</script>

<style scoped lang="scss">

</style>
