<template>
	<view class="page">
		<view class="example-b">
			<view class="item">
				<view class="itemname fz36">派工单编号:</view>
				<view class="itemtext">
					<input class="iteminput" disabled  v-model="dataList.code"/>
				</view>
			</view>
			<view class="item">
				<view class="uni-flex uni-row">
					<view style="-webkit-flex:1;flex: 1;">
						<button type="primary" style="width: 90%;" :disabled="false"  @click="workHangUP">挂起</button>
					</view>
					<view style="-webkit-flex:1;flex: 1;">
						<button type="primary" style="width: 90%;" :disabled="false" @click="report">报工</button>
					</view>
					<view style="-webkit-flex:1;flex: 1;">
						<button type="primary" style="width: 90%;" :disabled="false" @click="goMaterialCollect">用料采集</button>
					</view>
				</view>
			</view>
			<view class="title">
				工单信息
			</view>
		</view>
		<view class="info">
			<view class="item">
				<view class="itemname">操作工</view>
				<view class="itemtext">
					<input disabled class="iteminput" v-model="dataList.operatorName">
				</view>
			</view>
			<view class="item">
				<view class="itemname">工序</view>
				<view class="itemtext">
					<input disabled class="iteminput" v-model="dataList.processName">
				</view>
			</view>
			<view class="item">
				<view class="itemname">设备</view>
				<view class="itemtext">
					<input disabled class="iteminput" v-model="dataList.deviceName">
				</view>
			</view>
			<view class="item">
				<view class="itemname">产品</view>
				<view class="itemtext">
					<input disabled class="iteminput" v-model="dataList.materielName">
				</view>
			</view>
			<view class="item">
				<view class="itemname">型号规格</view>
				<view class="itemtext">
					<input disabled class="iteminput" v-model="dataList.specification">
				</view>
			</view>
			<view class="item">
				<view class="itemname">计划数量</view>
				<view class="itemtext">
					<input disabled class="iteminput" v-model="dataList.planCount">
				</view>
			</view>
			<view class="item">
				<view class="itemname">计划开工日期</view>
				<view class="itemtext">
					<input disabled class="iteminput" v-model="dataList.startTime">
				</view>
			</view>
			<view class="item">
				<view class="itemname">计划完工日期</view>
				<view class="itemtext">
					<input disabled class="iteminput" v-model="dataList.endTime">
				</view>
			</view>
			<view class="item">
				<view class="itemname">实际开工时间</view>
				<view class="itemtext">
					<input disabled class="iteminput" v-model="dataList.actualStartTime">
				</view>
			</view>
			<view class="item item_textarea">
				<view class="itemname">工艺要求:</view>
				<textarea disabled class="textarea" placeholder="请输入工艺要求" v-model="dataList.demand"></textarea>
			</view>
		</view>
		<view class="goHome" @click='goMain()'>
			<img src="../../static/img/gohome.png">
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				id: '',
				dataList: {},
				disabled: false,
			}
		},
		onLoad(option) {
			this.id = option.id
			console.log(this.id)
		}, 
		created() {
			this.getDetail()
		},
		methods: {
			getDetail() {
				var filterRes = {id:this.id};
				this.$http.request({
					url: 'apis/mes/dispatch/getStartWorkingDetail',
					params: filterRes,
				}).then(res=>{
					if(res.data.data) {
						this.dataList = res.data.data	
						this.dataList.startTime = this.dataList.startTime.substr(0,10)
						this.dataList.endTime = this.dataList.endTime.substr(0,10)
					}else{
						this.disabled = true;
						uni.showToast({
							title: '没有数据',
							duration: 	1000,
							icon:"none"
						});
					}	
				})
			},
			// 用料采集
			goMaterialCollect() {
				uni.removeStorageSync('materialCollectInfo');
				
				uni.navigateTo({
				    url: 'materialCollect?+dispatchItemId='+this.dataList.dispatchItemId+"&code="+this.dataList.code+"&from="+"startWorking"
				});
			},
			// 挂起
			workHangUP() {
				uni.removeStorageSync('pendingReason');
				
				uni.navigateTo({
				    url: 'pendingReason?+dispatchId='+this.dataList.dispatchItemId
				});
				// this.$http.request({
				// 	url:'/apis/mes/dispatch/workHangUp',
				// 	params: {
				// 		dispatchId: this.dataList.dispatchItemId
				// 	}
				// }).then(res=>{
				// 	uni.showToast({
				// 		title: '操作成功',
				// 		duration: 	1000,
				// 		icon:"none"
				// 	});
				// 	uni.switchTab({
				// 		url: "../main/main"
				// 	});
				// }).catch(err=>{
				// 	uni.showToast({
				// 		title: '操作失败',
				// 		duration: 	2000,
				// 		icon:"none"
				// 	});
				// })
			},
			// 报工
			report() {
				uni.removeStorageSync('processReportInfo');
				uni.navigateTo({
				    url: 'processReport?+dispatchItemId='+this.dataList.dispatchItemId+"&code="+this.dataList.code
				});
			}
		},
	}
</script>

<style scoped>
	.title {
		font-size: 40upx;
		padding: 20upx;
		font-weight: 700;
	}

	.info {
		padding: 0 20upx 0 20upx;
	}
</style>
