<template>
	<view>
		<!-- <view class="cancellation">取消</view> -->

		<view class="padding">
			<view class="title" style="margin-bottom: 20rpx;">
				拆下日期
			</view>
			<!-- <view class="cu-form-group border-ddd border-rad margin-top-sm form-group-time"> -->
			<view style="padding: 0;" class="cu-form-group margin-top-sm padding-none">
				<view style="width: 100%;" class="cu-form-group border-ddd border-rad w-100">
					<view @tap="lowVisible = true" class="cu-form-group-text text-left"
						:class="!!enterLLInfo.startDateTime ? '' : 'main-sub-color'">
						{{ !!enterLLInfo.startDateTime ? enterLLInfo.startDateTime : '请选择' }}</view>
					<image src="../../../../static/img/hcdb/i-date.png" class="i-down"></image>
					<w-picker :visible.sync="lowVisible" mode="date" startYear="2000" endYear="2099" :current="true"
						fields="day" @confirm="onConfirmTime($event, 'startDateTime')" @cancel="onCancel"
						:disabled-after="false" ref="start"></w-picker>
				</view>
				<text class="margin-right-sm margin-left-sm">至</text>
				<view style="width: 100%;" class="cu-form-group border-ddd border-rad w-100">
					<view @tap="highVisible = true" class="cu-form-group-text text-left"
						:class="!!enterLLInfo.endDateTime ? '' : 'main-sub-color'">
						{{ !!enterLLInfo.endDateTime ? enterLLInfo.endDateTime : '请选择' }}</view>
					<image src="../../../../static/img/hcdb/i-date.png" class="i-down"></image>
					<w-picker :visible.sync="highVisible" mode="date" startYear="2000" endYear="2099" :current="true"
						fields="day" @confirm="onConfirmTime($event, 'endDateTime')" @cancel="onCancel"
						:disabled-after="false" ref="end"></w-picker>
				</view>
			</view>

			<!-- </view> -->
			<view class="cu-form-group border-ddd border-rad margin-top">
				<view class="title">短机号<span style="color: red;">*</span></view>
				<view style="margin-left: 415rpx;">B-</view>
				<input type="text" v-model="enterLLInfo.zmsgrp" placeholder="xxxx"
					placeholder-class="text-right main-sub-color" dir="ltr"
					style="width: 92rpx;flex: none;flex-shrink: 0;" />
				<!-- <textarea maxlength="5" auto-height class="text-right" style="width: 60px;" v-model="enterLLInfo.zmsgrp" placeholder="xxxx"
					placeholder-class="text-right main-sub-color" /> -->
			</view>
			<view class="cu-form-group border-ddd border-rad margin-top">
				<view class="title">件号</view>
				<textarea auto-height class="text-right" v-model="enterLLInfo.matnr" placeholder="请输入件号"
					placeholder-class="text-right main-sub-color" />
			</view>
			<view class="cu-form-group border-ddd border-rad margin-top">
				<view class="title">序号</view>
				<textarea auto-height class="text-right" v-model="enterLLInfo.sernr" placeholder="请输入序号"
					placeholder-class="text-right main-sub-color" />
			</view>

			<view class="flex justify-center margin-top-xl" style="display: flex; justify-content: space-between;">
				<button class="main-button font30" style="width: 30%;" @click="add">新增</button>
				<button class="main-button font30" style="width: 30%;" @click="querys">查询</button>
			</view>
			<view style="padding: .66rem;" @click="detailsClick(item)" v-for="(item,index) in dataList" :key="index"
				class="cu-form-group border-ddd border-rad margin-top-sm flex-direction align-start">
				<view style="width: 100%; display: flex; justify-content: space-between;">
					<view>拆下日期: {{ item.zchdt }}</view>
					<view>短机号: {{ item.zmsgrp }}</view>
				</view>
				<view style="width: 100%; display: flex; justify-content: space-between;">
					<view>件号: {{ item.matnr }}</view>
					<view>序号: {{ item.sernr }}</view>
				</view>
			</view>


		</view>
		<q-loading mask="true" click="true" ref="loading"></q-loading>
	</view>
</template>

<script>
	import {
		requestWithFile,
		ipConfig,
		request
	} from '../../../../utils/request';
	import DateFormat from '@/js_sdk/xfl-DateFormat/DateFormat.js';
	import dictionaryApi from '../../../../utils/dictionary';
	export default {
		data() {
			return {
				dateImg: '../../../../static/img/hcdb/i-date.png',
				limitCount: 1,
				lowVisible: false,
				highVisible: false,
				startDateTime: '',
				endDateTime: '',
				param: {
					startDateTime: '',
					endDateTime: ''
				},
				enterLLInfo: {
					zmsgrp: ''
				},
				dataList: [],
				modelsList1: ['787', '73N', '73M'],
				modelsList2: ['A33', 'A23'],
			};
		},
		props: {
			lmoId: {
				type: String,
				default: ''
			},
			type: {
				type: String,
				default: ''
			}
		},
		watch: {},
		mounted() {
			this.dataList = uni.getStorageSync('jlinfo') || []
		},
		methods: {
			getShowToast(text) {
				uni.showToast({
					title: text,
					icon: 'none'
				});
			},
			querys() {
				if (!this.enterLLInfo.zmsgrp) {
					this.getShowToast('请输入短机号！')
					return
				}
				let vm = this;
				vm.$refs.loading.open();
				let data = JSON.parse(JSON.stringify(this.enterLLInfo))
				// let str = 'B-';
				// data.zmsgrp = str + data.zmsgrp;
				request({
						url: 'lfl-nff',
						data: data,
						method: 'get'
					})
					.then(res => {
						vm.$refs.loading.close();
						if (res.code == 0) {
							uni.showToast({
								title: '查询成功！',
								icon: 'none'
							});
							res.data.map(item => {
								if (item.fileList.length > 0) {
									item.fileList.map(itens => {
										itens.folder =
											`${ipConfig.indexOf('191') > -1 ? 'http://10.119.47.118:8080/' : ipConfig}mronfs${itens.folder}`
									})
								}
							})
							this.dataList = res.data;
							this.getList('B-' + data.zmsgrp);
						} else {
							uni.showToast({
								title: res.msg || '系统繁忙，请稍后重试！',
								icon: 'none'
							});
						}
					})
					.catch(res => {
						vm.$refs.loading.close();
					});
			},
			getList(val) {
				request({
						method: 'get',
						url: 'daAcreg-getByAcno',
						data: {
							acno: val
						}
					}, true)
					.then(res => {
						if (res.code == 0) {
							let testModel = res.data.mpActype
							let workerType = '0'
							console.log(this.contains(this.modelsList1, testModel), this.contains(this.modelsList2,
								testModel))
							if (this.contains(this.modelsList1, testModel)) {
								workerType = '1'
							}
							if (this.contains(this.modelsList2, testModel)) {
								workerType = '2'
							}

							if (this.dataList.length > 0) {
								this.dataList.map(item => {
									item['workerType'] = workerType
									item['mpActype'] = testModel
								})
								console.log(this.dataList)
								uni.setStorageSync('jlinfo', this.dataList)
							}
						}
					})
			},
			contains(arr, val) {
				return arr.some(item => item === val)
			},
			add() {
				this.$emit("passfunction", 0)
			},
			detailsClick(row) {
				this.$emit("pdetailsfunction", row)
				this.$emit("pdetailszi", 2)
			},

			
			onConfirmTime(res, type) {
				this[type] = res.value;
				this.param[type] = res.value.replace(/[^0-9,]*/g, '');
				this.enterLLInfo[type] = res.value + ' ' + '00:00:00';
				this.onCancel();
			},
			onCancel() {
				this.lowVisible = false
				this.highVisible = false
			},
		},
		onShow() {},
		onLoad() {},
		onReady() {}
	};
</script>

<style lang="less" scoped>
	.title {
		flex-shrink: 0;
		height: auto !important;
		line-height: 1.5em !important;
	}

	.state-bar {
		padding-top: 30rpx;
		padding-bottom: 20rpx;
	}

	.yellow {
		color: rgb(255, 170, 0);
		background: linear-gradient(rgba(255, 170, 0, 0.8), #fdfdff);
	}

	.green {
		color: green;
		background: linear-gradient(rgba(4, 177, 44, 0.8), #fdfdff);
	}

	.item-center-btn {
		width: 30%;
		margin: 0 10rpx;
		height: 66rpx;
	}

	.uni-searchbar {
		width: 100%;
		padding: 0rpx 0rpx 20rpx 0rpx !important;

	}

	.rotate-right {
		transform: rotate(-90deg);
	}

	.clearImg {
		height: 70rpx;
		width: 70rpx;
		flex-shrink: 0;
	}

	.i-point {
		width: 20rpx;
		height: 20rpx;
	}

	.i-down {
		width: 32rpx;
		height: 32rpx;
		transition: all 0.2s linear;
	}

	.rotate {
		transform: rotate(180deg);
	}

	.prop-text {
		width: 20%;
		display: inline-flex;
	}

	.cu-form-group uni-picker {
		padding-right: 0rpx;
	}

	.picker-after::after {
		display: none;
	}

	.picker-text {
		padding-right: 8rpx;
	}

	.i-photo {
		width: 140rpx;
		height: 140rpx;
	}

	/deep/.uni-drawer--right {
		/* #ifdef H5 */
		padding-top: 45px;
		/* #endif */
		/* #ifdef APP-PLUS */
		padding-top: 90px;
		/* #endif */
		box-sizing: border-box;
	}

	.radio-wrap {
		width: 100%;
		display: flex;
		flex-direction: column;
		align-items: flex-start;
		justify-content: flex-start;
		box-sizing: border-box;
		padding: 0 20rpx;

		.radio-cover {
			width: 100%;
			display: flex;
			align-items: center;
			margin-bottom: 20rpx;
			padding-bottom: 20rpx;
			border-bottom: 1rpx solid #DDDDDD;

			&:last-child {
				border-bottom: 0px;
			}

			uni-radio {
				margin-right: 10rpx;
			}
		}
	}

	/deep/.checklist-group {
		justify-content: flex-end;

		.checklist-box {
			margin-right: 0rpx !important;
			margin-left: 20rpx !important;
		}
	}

	.titles {
		margin-top: 30rpx;
		font-weight: bold;
	}

	.btn2 {
		height: 44px;
		line-height: 44px;
		border-radius: 25px;
		font-size: 17px;
		color: #000;
		padding: 0 20px;
		box-sizing: border-box;
		background-color: #ffffff;
		margin: 0;
		border: 4rpx solid;
	}

	.form-group-time {
		padding: 0;
		display: flex;
		justify-content: center;
		align-items: center;
		margin: 0;
		padding: 30rpx 0;

		.margin-top-sm {
			margin-top: 0px;
			width: 100%;

			.border-rad {
				width: 100%;
			}
		}
	}

	.cancellation {}
</style>