<template>
    <u-popup :show="isShow" @close="close" mode="bottom" :closeOnClickOverlay="false" round="10"
		:customStyle="{
			overflow: 'hidden'
		}"
	>
		<view class="page-container">
			<scroll-view
				scroll-y style="max-height: 90vh" enable-back-to-top
			>
				<view class="page-head">		
				</view>
				<view class="page-body">
					<u--form label-width="auto" labelAlign="left"
						ref="uForm"
						:model="model" 
						:rules="rules"
						:labelStyle="{
							fontSize: '28rpx',
							fontWeight: '500',
						}"
					>
						<u-cell-group :border="false">
							<view class="input-box">
								<template>
									<u-cell title="" :border="true" :isLink="false" :clickable="true" class="hidde-cell-title"
										@click="$refs.dueTimeRef.show()"
									>
										<view slot="value" class="value">
											<u-form-item :label="labelTitle" labelPosition="" prop="form.dueTime" :required="true">
												<u--input
													:value="model.form.dueTime" 
													placeholder="请选择" 
													border="none"
													inputAlign="right"
													:disabled="true"
													disabledColor="none"
													:customStyle="{
														pointerEvents: 'none',
													}"
												>
												</u--input>
											</u-form-item>
										</view>	
									</u-cell>
									
									<tq-date-time ref="dueTimeRef"
										mode="date"
										format="YYYY-MM-DD"
										@confirm="(data) => {
											model.form.dueTime = data
											$refs.uForm.validateField('form.dueTime')
										}"
									>
									</tq-date-time>
								</template>
					
							</view>
							
							
							<view class="box" v-if="model.form.msgType == 4">
								<u-cell title="" :border="false" :isLink="false" :clickable="false" class="hidde-cell-title">
									<view slot="value" class="value">
										<u-form-item labelPosition="top" prop="form.photo" :required="true">
											<view slot="label" class="item-label">
												<view class="item-label-left">
													<!-- <text>*</text> -->
													驾驶证照片
												</view>
												<view  class="item-label-right">{{model.form.photo?model.form.photo.split(',').length:0}}/1</view>
											</view>
											<view style="margin-top: 30rpx;">
												<tq-upload-img
													v-model="model.form.photo"
													:maxCount="1"
													width="80"
													height="80"
													uploadText=""
												>	
												</tq-upload-img>
											</view>
										</u-form-item>
									</view>	
								</u-cell> 
							</view>
							
						</u-cell-group>
						
					</u--form>
				</view>
			</scroll-view>
		
			<view class="page-footer">
				<u-row style="">
					<u-col :span="6">
						<u-button type="info" shape="" :hairline="false" :custom-style="{
								width: '100%',
								borderRadius: '0',
								background: '#FFF',
								height: '100rpx',
								fontSize: '32rpx',
								fontWeight: '500',
							  }" @click="close">取消
						</u-button>
					</u-col>	
					<u-col :span="6">
						<u-button type="primary" shape="" :hairline="false" :custom-style="{
								width: '100%',
								borderRadius: '0',
								height: '100rpx',
								fontSize: '32rpx',
								fontWeight: '500',
								background: '#0075F7',
							  }" @click="handleSubmit">确认
						</u-button>
					</u-col>
				</u-row>
				
			</view>
		</view>
	</u-popup>
</template>

<script>
import { updateObjDueTime } from "@/api/system/sysMessage.js";
import {copyProps,clearProps} from '@/utils/gdtq.js'

export default {
    data() {
        return {
			isShow: false,
			model: {
				  form: {
					   objIds: '',
					   msgType: '',
					   dueTime: '',
					   photo: '',
				  }
			},
			rules: {
				'form.dueTime': {
					type: 'string',
					required: true,
					message: '请选择到期时间',
					trigger: ['blur', 'change']
				},		
			},	
			copyInfo: null,
			labelTitle: '',
        }
    },
	mounted() {
		
	},
	
	onReady() {
		this.$refs.uForm.setRules(this.rules)
	},
	
    methods: {

		show(e) {
			console.log(e,'eeee')
			this.model.form.objIds = e.objId
			this.model.form.msgType = e.msgType
			this.model.form.dueTime = e.dueTime
			this.model.form.photo = e.photo
			if (this.model.form.msgType == 1) {
				this.labelTitle = '下次保险到期时间'
			} else if (this.model.form.msgType == 2) {
				this.labelTitle = '下次年检到期时间'
			} else if (this.model.form.msgType == 3) {
				this.labelTitle = '下次保养到期时间'
			} else if (this.model.form.msgType == 4) {
				this.labelTitle = '下次驾驶证到期时间'
			}
			this.copyInfo = e;
			this.isShow= true;	
			
		},
		close() {
			clearProps(this.model.form)
		    this.isShow = false
			
		},
		
		
		// 提交
		async handleSubmit() {
			  this.$refs.uForm.validate().then(async res => {
				 
					let ajaxData = {
						 ...this.model.form,
					}
				
					let { data, code,msg } = await updateObjDueTime(ajaxData) 
					
					if (code == 0) {
						this.$modal.msg(msg) 
						this.$emit('getList')
						
						this.close()
						
					} else {
						this.$modal.msgError(msg)
					}
				  
			  }).catch(errors => {
				  console.log('校验失败',errors)
			  })
		},
		
    }

}
</script>

<style lang="scss" scoped>
	.disflex {
		display: flex;
	}
	.page-container {
		min-width: 600rpx;
		font-size: 28rpx;
		min-height: 100%;
		position: relative;
		
		.input-box {
			margin: 24rpx 24rpx 0;
			padding: 0 0rpx;
		}
		
		.box {
			margin: 24rpx 24rpx 0;
			border-radius: 20rpx;
			background: #fff;
			// padding: 0 20rpx;
			// border: 1rpx solid #EBEDF0;
			
			.item-label {
				display: flex;
				justify-content: space-between;
				align-items: center;
				&-left {
					font-family: PingFangSC, PingFang SC;
					font-weight: 400;
					font-size: 28rpx;
					color: #333333;
					position: relative;
					text {
						color: #f56c6c;
						font-size: 40rpx;
						position: absolute;
						left: -18rpx;
					}
				}
				&-right {
					font-family: PingFangSC, PingFang SC;
					font-weight: 400;
					font-size: 20rpx;
					color: #999999;
				}
			}
		}
		
		
		.page-head {
			text-align: center;
			font-size: 34rpx;
			font-weight: 700;
			// padding: 20rpx 0;
		}
		.page-body {
			padding-bottom: 120rpx;
			height: auto;
			// height: calc(100vh - 200rpx);
			// overflow-y: scroll;
		}
		.page-footer {
			position: absolute;
			width: 100%;
			left: 0;
			bottom: 0;
		}
	}
	
	
	::v-deep {
		.u-cell-group {
			.u-radio+.u-radio {
				margin-left: 30rpx;
			}
			.u-cell__title-text {
				font-family: PingFangSC, PingFang SC;
				font-weight: 400;
				font-size: 28rpx;
				color: #333333;
			}
			
			.u-form-item__body__right__content__slot {
				font-family: PingFangSC, PingFang SC;
				font-weight: 400;
				font-size: 28rpx;
				color: #333333;
				
				.u-input__content__field-wrapper__field {
					font-family: PingFangSC, PingFang SC !important;
					font-weight: 400 !important;
					font-size: 26rpx !important;
					color: #333333 !important;
				}
			}
		}
		
		.u-form-item__body {
			padding: 0;
		}
		.hidde-cell-title {
			
			.u-cell__body__content {
				width: auto;
				flex: none;
				
			}
			.u-cell__body {
				.value {
					flex: 1;
				}
			}
			
		}
	}
		
</style>
