<template>
	<view class="page-wraper">
		<view class="page-header">
			<view class="header_job_top">
				<request-top :dataContent="requestContent"></request-top>
			</view>
			<view class="header_item">
				<work-station :workshopCode="requestContent.workshopCode"
					:productionLineCode="titleInfo.productionLineCode" :workStationCode="titleInfo.workStationCode"
					:rawLocationCode="titleInfo.toLocationCode"></work-station>
			</view>

		</view>
		<view class='split_line'></view>
		<view class="page-main">
			<scroll-view scroll-y="true" class="page-main-scroll">
				<view class="detail-list">
					<view class="">
						<comIssueRequestDetailCard :dataContent="requestContent">
						</comIssueRequestDetailCard>
					</view>
				</view>
			</scroll-view>
			<!-- <div class="btn_bottom" >
				<view class="" style="display: flex;flex-direction: row;">
					<view class="">
						<button class="btn_commit" hover-class="btn_commit_after" @click="submit()">提交</button>
					</view>
				</view>
			</div> -->
		</view>
		<comMessage ref="comMessage"></comMessage>
	</view>
</template>

<script>
	import {
		getIssueRequestDetail,
	} from '@/api/request2.js';

	import {
		goHome,
		updateTitle
	} from '@/common/basic.js';

	import {
		getDataSource,
	} from '@/common/detail.js';

	import comIssueRequestDetailCard from "@/pages/issue/coms/comIssueRequestDetailCard.vue"
	import requestTop from "@/mycomponents/request/requestTop.vue"
	import workStation from '@/mycomponents/workStation/workStation.vue'

	export default {
		components: {
			comIssueRequestDetailCard,
			requestTop,
			workStation
		},
		data() {
			return {
				id: '',
				requestContent: {}, //任务内容
				subList: [], //接口返回的任务
				type: 'query', //来源新增add,  query查询
				titleInfo: {}
			};
		},
		onLoad(option) {
			this.id = option.id;
			this.getDetail();
		},

		//返回首页
		onNavigationBarButtonTap(e) {
			if (e.index === 0) {
				goHome();
			}
		},

		onPullDownRefresh() {
			this.getDetail();
			uni.stopPullDownRefresh();
		},

		mounted() {

		},
		methods: {
			getDetail() {
				var that = this;
				uni.showLoading({
					title: "加载中....",
					mask: true
				});

				getIssueRequestDetail(that.id).then(res => {
					uni.hideLoading();
					if (res.data == null) {
						that.showMessage('未获取到详情');
					} else {
						if (res.data.subList.length > 0) {
							that.requestContent = res.data;

							that.requestContent.subList = res.data.subList;
							that.titleInfo = that.requestContent.subList[0]
							that.subList = res.data.subList;
							// that.subList.forEach(res => {
							// 	res.fromLocationCode = res.toLocationCode
							// })
							// that.detailSource = getDataSource(that.subList);
							// updateTitle(this.requestContent.number);
						} else {
							that.showMessage('列表数据为0');
						}
					}
				}).catch(error => {
					uni.hideLoading()
					this.showMessage(error)
				})
			},

			showMessage(message) {
				this.$refs.comMessage.showMessage(message, res => {
					if (res) {}
				});
			},

		}
	}
</script>

<style scoped lang="scss">

</style>
