<template>
	<view>
		<view class="white-card">
			<view class="list-list">
				<view class="list-title">物料编号</view>
				<view class="list-right">
					<text>5651145dssdffd</text>
				</view>
			</view>
			<view class="list-list">
				<view class="list-title">填报日期</view>
				<view class="list-right">
					<text>5651145dssdffd</text>
				</view>
			</view>
			<view class="list-list">
				<view class="list-title">线别</view>
				<view class="list-right">
					<text>{{CyInfo.line_title}}</text>
					<!-- <image class="next" src="../../static/next.png"></image> -->
				</view>
			</view>
			<view class="list-list">
				<view class="list-title">班次</view>
				<view class="list-right">
					<text>{{CyInfo.line_title==0?'夜班':'白班'}}</text>
				</view>
			</view>		
		</view>
		<!-- <view class="white-card" style="margin-top: 30upx;">
			<picker @change="bindReason" :value="reasonIds" :range="reason">
			<view class="list-list">
				<view class="list-title">停线原因</view>
				<view class="list-right">
					<text>{{reason[reasonIds]}}</text>
					<image class="next" src="../../static/next.png"></image>
				</view>
			</view>
			</picker>
		</view> -->
		<view class="big-titlt">产出情况填报</view>
		<view class="white-card">
			<view class="list-list">
				<view class="list-title">生产数量</view>
				<view class="list-right">
					<input v-model="from.product_number" placeholder="请输入生产数量" />
				</view>
			</view>
			<view class="list-list">
				<view class="list-title">良品数量</view>
				<view class="list-right">
					<input v-model="from.ok_number" placeholder="请输入良品数量" />
				</view>
			</view>
			<view class="list-list">
				<view class="list-title">待返修数</view>
				<view class="list-right">
					<input v-model="from.rework" placeholder="请输入" />
				</view>
			</view>
			<view class="list-list">
				<view class="list-title">休息时间</view>
				<view class="list-right">
					<input v-model="from.rest_time" type="number" placeholder="请输入" />
					<text>分钟</text>
				</view>
			</view>
			<view class="list-list">
				<view class="list-title">报废数量</view>
				<view class="list-right">
					<input v-model="from.no_number" placeholder="请输入" />
				</view>
			</view>

		</view>
		<view class="submit-btn">
			<button type="primary" v-if="CyInfo.o_id==null" :disabled="buttonState==false?true:false" @tap="offLine()">提交</button>
			<button type="primary" v-if="CyInfo.o_id!=null" :disabled="buttonState==false?true:false" @tap="offLineExam()">审核</button>
		</view>
	</view>
</template>

<script>
	import {
		offline
	} from "../../api/index.js"
	import {offlineDetail,xxExamine} from "../../api/user.js"
	export default {
		data() {
			return {
				CyInfo:{},
				line: ["A线", "B线"],
				lineIndex: 0,
				frequency: ["白班", "夜班"],
				frequencyIds: 0,
				reason: ["模具维修", "设备维修", "品质待定", "辅料短缺", "偶发停电"],
				reasonIds: 0,
				mould: ["1", "2", "3"],
				mouldIds: 0,
				buttonState: true,
				from: {
					product_number: "",
					ok_number: "",
					rework: "",
					no_number: "",
					frequency: 0,
					plan_id: '',
					rest_time:''
				}
			};
		},
		onLoad(e) {
			this.from.plan_id = e.plan_id;
			this.CyInfo = JSON.parse(decodeURIComponent(e.planInfo));
			console.log("是三手11",e)
			if(e.type==2){
				this.getDetail()
			}
		},
		methods: {
			bindline: function(e) {
				console.log('picker发送选择改变，携带值为', e.target.value)
				this.lineIndex = e.target.value
			},
			bindfrequencyIds(e) {
				this.frequencyIds = e.target.value
				this.from.frequency = e.target.value
			},
			bindReason(e) {
				this.reasonIds = e.target.value
			},
			bindmouldIds(e) {
				this.mouldIds = e.target.value
			},
			getDetail(){
				offlineDetail({id:this.CyInfo.o_id}).then(res=>{
					this.from=res
				})
			},
			offLine() {
				
				this.from.frequency=this.CyInfo.frequency
				this.buttonState = false;
				offline(this.from).then(res => {
					console.log("成功", this.from);
					this.$functions.success('操作成功').then(() => {
						
						uni.navigateBack({});
					});
				}).catch(res => {
					console.log("失败", this.from);
					this.buttonState = true;
				});
			},
			offLineExam(){
				this.$functions.confirm("是否进行此操作?").then(() => {
					xxExamine({id: this.CyInfo.o_id,status:1,remark:''}).then(res => {
						this.$functions.success('提交成功').then(() => {
							uni.navigateBack();
						})
					}).catch(res => {
						this.buttonState = true;
					});
				})
			}
		}
	}
</script>

<style lang="scss">
	@import "./index.scss"
</style>
