<template>
	<view class="page-body">
		<!-- 顶部信息卡片 -->
		<view class="card-header">
				<!-- 顶部信息卡片第一行 -->
				<h3>{{dataDetail.SHOPNAME }}</h3>
				<!-- 顶部信息卡片第二行 -->
				<view class="uni-flex ai-center jc-between fs12">
					<!-- 左侧 -->
					<span>{{dataDetail.QUALIFICATION_DATE }}</span>
					<!-- 右侧 -->
					<span>商品名称：{{dataDetail.COMMODITY_NAME}}</span>
				</view>
		</view>
		<!-- 详情信息 -->
		<view class="modle-title">
			<h2>商品资质</h2>
		</view>
		<!-- 详情信息卡片 -->
		<view class="content-detail-box main-card ino-flex ai-center uni-column">
			<!-- 商品类型名称 -->
			<!-- 单列样式 -->
			<view class="cellTopStyle">
				<span class="fourth-name">商品类型：</span>
				<span>{{dataDetail.COMMODITY_TYPENAME||''}}</span>
			</view>
			<!-- 商品名称 -->
			<!-- 单列样式 -->
			<!-- <view class="cellTopStyle">
				<span class="fourth-name">商品名称：</span>
				<span>{{dataDetail.COMMODITY_NAME||''}}</span>
			</view> -->
			<!-- 商品条码 -->
			<!-- 单列样式 -->
			<view class="cellTopStyle">
				<span class="fourth-name">商品条码：</span>
				<span>{{dataDetail.COMMODITY_BARCODE||''}}</span>
			</view>
			<!-- 服务区名称 -->
			<!-- 单列样式 -->
			<view class="cellTopStyle">
				<span class="fourth-name">服务区名：</span>
				<span>{{dataDetail.SERVERPART_NAME||''}}</span>
			</view>
			<!-- 商品业态 -->
			<!-- 单列样式 -->
			<view class="cellTopStyle">
				<span class="fourth-name">商品业态：</span>
				<span>{{dataDetail.BUSINESSTYPE||''}}</span>
			</view>
			<!-- 资质到期时间 -->
			<!-- 单列样式 -->
			<view class="cellTopStyle">
				<span class="fourth-name">资质到期时间：</span>
				<span>{{dataDetail.QUALIFICATION_DATE||''}}</span>
			</view>
			<!-- 资质延期时间 -->
			<!-- 单列样式 -->
			<view class="cellTopStyle">
				<span class="fourth-name">资质延期时间：</span>
				<span>{{dataDetail.QUALIFICATION_DELAYDATE||''}}</span>
			</view>
			<!-- 统计日期 -->
			<!-- 单列样式 -->
			<view class="cellTopStyle">
				<span class="fourth-name">统计日期：</span>
				<span>{{dataDetail.STATISTICS_DATE||''}}</span>
			</view>
			<!-- 操作人员 -->
			<!-- 单列样式 -->
			<view class="cellTopStyle">
				<span class="fourth-name">延期人员：</span>
				<span>{{dataDetail.STAFF_NAME||''}}</span>
			</view>
			<!-- 有效状态 -->
			<!-- 单列样式 -->
			<view class="cellTopStyle">
				<span class="fourth-name">延期状态：</span>
				<span>{{state[dataDetail.COMMODITY_TEMP_STATE]||''}}</span>
			</view>
		</view>
		<view class="main-card ino-flex ai-center uni-column button-sp-area">
			<button type="primary" plain="true" :loading="loading" :disabled="disabled" @click="Synchro(dataDetail)">临时延期3天</button>
		</view>
	</view>
</template>

<script>
	import {mapGetters,mapMutations} from 'vuex'
	export default {
		data() {
			return {
				pageData: {
					type: null,
					id: null
				},
				loading: true,
				dataDetail: {},
				state:{
					0:"无效",
					1:"待延期",
					2:"已延期"
				},
				disabled:false
			}
		},
		computed:{
			...mapGetters({
				'user':'getUser',
			})
		},
		methods: {
			...mapMutations(['shouldReLoadingList']),
			/**
			 * 调用接口获取数据详情
			 * 
			 * Api接口地址：EShangApiMain/BusinessMan/Getcommodity_tempDetail
			 */
			getDetail(option) {
				this.$request.$webGet("EShangApiMain/BusinessMan/Getcommodity_tempDetail",{
					//这里设置接口参数
					COMMODITY_TEMPId: option.COMMODITY_TEMP_ID,
				})
				.then(res => {
					uni.hideLoading()
					this.loading = false
					if (res.Result_Code !== 100) {
						return
					}
					this.dataDetail = res.Result_Data
					let delayDate = res.Result_Data.QUALIFICATION_DELAYDATE
					let qualificationDate = res.Result_Data.QUALIFICATION_DATE
					let datediff = this.$util.DateDiff(delayDate,qualificationDate)
					console.log(datediff)
					if (datediff >=9 ){
					 this.disabled = true
					}else{
					 this.disabled = false
					}
				})
			},
			Synchro(item){
				this.loading = true
				//获取当前到期日期
				let delayDate = item.QUALIFICATION_DELAYDATE||item.QUALIFICATION_DATE
				//设置延期
				item.QUALIFICATION_DELAYDATE = this.$util.cutDate(delayDate,"YYYY/MM/DD",3)
				item.COMMODITY_TEMP_STATE = 2
				item.STAFF_ID = this.user.UserId
				item.STAFF_NAME =  this.user.UserName
				item.OPERATE_DATE = this.$util.cutDate(new Date(),"YYYY/MM/DDThh:mm:ss",0)
				//同步数据到云端
				this.$request.$webPost("EShangApiMain/BusinessMan/SynchroCOMMODITY_TEMP",item)
				.then(res => {
					uni.hideLoading()
					this.loading = false
					if (res.Result_Code !== 100) {
						return
					}
					this.dataDetail = res.Result_Data
					let delayDate = res.Result_Data.QUALIFICATION_DELAYDATE
					let qualificationDate = res.Result_Data.QUALIFICATION_DATE
					let datediff = this.$util.DateDiff(delayDate,qualificationDate)
					console.log(datediff)
					if (datediff >=9 ){
					 this.disabled = true
					}else{
					 this.disabled = false
					}
				})
				this.$forceUpdate()
			}
		},
		onLoad(option) {
			uni.showLoading()
			this.pageData = option
			this.loading = true
			this.getDetail(option)
			this.$forceUpdate()
		}
	}
</script>

<style scoped>
	.page-body {
		min-height: 100%;
		padding: 40rpx 25rpx;
		background-color: #fff;
		box-sizing: border-box;
		padding-bottom: 196rpx;
	}
	.card-header {
		border-radius: 10rpx;
		width: 700rpx;
		background: linear-gradient(to right, #8998bb 0%, #a9b5d2 100%);
		color: #FFFFFF;
		padding: 24rpx 16rpx;
	}
	
	.card-header h3 {
		padding-bottom: 10rpx;
		font-size: 30rpx;
	}
	
	.card-header .fs12>text {
		font-size: 24rpx;
	
	}
	.cellTopStyle {
		line-height: 45rpx;
		width: 100%;
		display: flex;
		align-items: center; //上下对齐
		justify-content: space-between; //两端对齐
	}
	.fourth-name {
		min-width: 120rpx;
		max-width: 185rpx;
		color: #ADB2BF;
		font-size: 26rpx;
	}
	.modle-title {
		color: #000;
		padding: 36rpx 30rpx 24rpx 30rpx;
		font-size: 26rpx;
		display: flex;
		align-items: center;
		justify-content: space-between;
	}
	
	.modle-title h2 {
		font-weight: bolder;
	}
	.content-detail-box {
		margin: 0 26rpx 22rpx 26rpx;
		background: #ffffff;
		border-radius: 8rpx;
		box-shadow: 0rpx 2rpx 8rpx 0rpx rgba(231, 231, 231, 0.67);
		overflow: hidden;
		position: relative;
		padding: 10rpx 30rpx 16rpx 30rpx;
		font-size: 26rpx;
	}
	
		.content-detail-box span {
		font-size: 26rpx;
	}
</style>
