<template>
	<view class="checkSubmit">
		<view class="form-box" style="margin:0 30rpx">
			<uni-forms ref="baseForm" :modelValue="formData" label-position="left">
				<view class="commons-title">
					交班人员
				</view>
				<uni-forms-item label="交班人员">
					<view style="padding-top:18rpx"><span v-for="(i) in userName">{{i}}</span> </view>
				</uni-forms-item>
				<view class="commons-title">
					转班明细
				</view>
				<view style="border-bottom: 1rpx solid #000;" v-for="(i,index) in listData" :key="i.qrCode">
					<uni-forms-item label="物料名称" >
						<view style="padding-top:18rpx">{{i.materialName}}</view>
					</uni-forms-item>
					<uni-forms-item label="称重结果" >
						<view style="padding-top:18rpx">{{i.weighingResults}}kg</view>
					</uni-forms-item>
					<uni-forms-item label="有无外包装" >
						<view style="padding-top:18rpx">{{i.outerPackaging ? '有' : '无'}}</view>
					</uni-forms-item>
					<uni-forms-item label="有无卷芯" >
						<view style="padding-top:18rpx">{{i.convolution ? '有' : '无'}}</view>
					</uni-forms-item>
				</view>
			</uni-forms>
		</view>
		<view class="submit-box">
			<view class="" style="line-height: 80rpx;text-align: center;">
				本次转班：{{listData.length}} 件
			</view>
			<button @click="shiftChange" style="background: #0066CC;color:#fff;margin-bottom: 30rpx;">提交</button>
			
		</view>
		
	</view>
</template>

<script>
	import {
		getInfo
	} from "@/util/api.js";
	import Vue from 'vue'
	import htzImageUpload from '@/components/htz-image-upload/htz-image-upload.vue'
	import {
		dateFormat,
		getTime
	} from '../../util/uitl.js'
	export default {
		components: {
			htzImageUpload,
		},
		data() {
			return {

				formData: {
					
				},
				userName:[],
				listData:[],
				req:{
					shiftChangeId:null,
				},
			}
		},
		onLoad(option) {
			const v = this
			uni.getStorage({
				key: "userInfo",
				success(_data) {
					v.req.shiftChangeId = _data.data.id
					v.getData()
				},
				fail() {
			
				}
			})
			
		},
		methods: {
			
			shiftChange(){
				const v = this
				if(v.listData.length == 0){
					uni.showToast({
						icon:'none',
						title: '暂无交接信息',
						duration: 2000
					});
					return
				}
				v.$post("/mgr/shiftChange/updateShift",v.req).then(res=>{
					if(res.code == 200){
						uni.showToast({
							title:'接班成功,跳转中！'
						})
						setTimeout(()=>{
							wx.reLaunch({
								url: '/pages/home'
							})
						},1000)
					}
				})
			},
			getData(){
				const v = this
				v.$post('/mgr/shiftChange/selectSuccession',v.req).then(res=>{
					if(res.code == 200){
						for (var i = 0; i < res.data.length; i++) {
							v.userName.push(res.data[i].nickName)
						}
						v.userName = [...new Set(v.userName)]
						if(res.data.length != 0 ){
							v.listData = res.data
						}
					}
				})
			},
			switchChange(){
				
			},
			bindPickerChange2(){
				
			},
			imgDelete(_index){
				const v = this
				v.imgs.splice(_index,1)
			},
			zidingyiSuccess() {

			},
			checkSubmit(_type) {
				const v = this
				v.formData.checkJudgment = _type
				v.$post('/wx/check/temp',v.formData).then(res=>{
					if(res.code == 200){
						uni.showToast({
							title: '提交成功，跳转中！'
						})
						setTimeout(() => {
							
							wx.reLaunch({
								url: '/pages/check/checkDtl?data=' + encodeURIComponent(JSON.stringify(v.optionCopy))
							})
						}, 2000)
					}
				})
				

			},
			select(e) {
				console.log(e)
				const v = this
				v.$post('/wx/common/uploadFile', {
					file: e.tempFilePaths[0]
				}).then(res => {

				})
			},
		},
	}
</script>

<style lang="less">
	.checkSubmit {
		.submit-box {

			padding: 0 30rpx;
		}

		.dtl {
			padding: 30rpx;
			border-bottom: 1rpx solid #dcdcdc;
			font-size: 26rpx;
			line-height: 40rpx;
		}

		.addQrcode-list {
			height: 80rpx;
			display: flex;
			justify-content: space-between;
			padding: 15rpx;
			border-bottom: 1rpx solid #dcdcdc;
			font-size: 24rpx;

			.fl {
				display: flex;

				.code {
					margin-right: 20rpx;
				}
			}

			.fr {
				line-height: 80rpx;
			}
		}
	}

	.popup-input-warp {
		padding: 30rpx 40rpx;
	}


	.txt {
		margin-bottom: 20rpx;
	}

	.imglist {
		display: flex;
		flex-wrap: wrap;
	}

	.imglist .item {
		width: 150rpx;
		height: 150rpx;
		margin-right: 22rpx;
		margin-bottom: 10rpx;
		position: relative;
	}

	.imglist .last-item {
		width: 150rpx;
		height: 150rpx;
		text-align: center;
		line-height: 146rpx;
		border: 2rpx dashed #8B97A9;
		box-sizing: border-box;
	}

	.imglist .item image {
		width: 100%;
		height: 100%;
	}

	.imglist .item .delete {
		width: 30rpx;
		height: 30rpx;
		position: absolute;
		top: -25rpx;
		right: -12rpx;
		font-size: 40rpx;
		font-weight: bold;
	}
</style>
