<template>
	<view class="form_warp">
		<view class="form_intro">
			<view>如有填报问题，请咨询公共服务中心</view>
			<view>中心值班电话：<text @click="call(mobile)" class="tel">{{mobile}}</text></view>
		</view>
		<view class="form_item_box">
			<view class="form_item_title">基本信息</view>
			<!-- <view class="form_item">
				<view class="form_item_label">管理单位名称：</view>
				<view class="form_item_input select">
					{{form.affiliatedUnit}}
				</view>
			</view> -->
			<!-- <view class="form_item" v-if="form.bizWaterwayIslandDataSaveOrUpdateDTOList.length == 1">
				<view class="form_item_label">陆岛名称：</view>
				<view class="form_item_input select">
					{{form.bizWaterwayIslandDataSaveOrUpdateDTOList.length > 0 ? form.bizWaterwayIslandDataSaveOrUpdateDTOList[landNameIndex].landName : ''}}
				</view>
			</view> -->
			<view class="form_item">
				<view class="form_item_label">统计日期：</view>
				<view class="form_item_input picker">
					<picker v-if="pageType == 'add'" mode="date" :value="form.reportDate" @change="bindDateChange">
						<text class="picker_select"
							:style="form.reportDate?'color:#333;':''">{{form.reportDate?form.reportDate:'请选择时段'}}</text>
						<uni-icons type="right" size="16" color="#D4D4D4"></uni-icons>
					</picker>
					<text v-else>{{form.reportDate?form.reportDate:''}}</text>
				</view>
			</view>
			<view class="form_item">
				<view class="form_item_label">统计时段：</view>
				<view class="form_item_input picker">
					<picker v-if="pageType == 'add'" :value="index" :range="array" range-key="dictLabel" @change="changeStatPeriod">
						<text class="picker_select"
							:style="index>-1?'color:#333;':''">{{index>-1?array[index].dictLabel:'请选择时段'}}</text>
						<uni-icons type="right" size="16" color="#D4D4D4"></uni-icons>
					</picker>
					<text v-else>{{index>-1?array[index].dictLabel:''}}</text>
				</view>
			</view>
			<!-- 汇总统计 -->
			<view class="form_item">
				<view class="form_item_label">航次统计：</view>
				<view class="form_item_input">
					{{form.voyage === 0 ? form.voyage : form.voyage || ''}}
				</view>
			</view>
			<!-- 同比环比 -->
			<view class="form_item_rate"
				:class="checkNotEmpty(form.voyage) && form.voyage === yoySum.minusDaySummaryData.voyage ? 'danger' : ''">
				<view class="rate_item">
					<view class="rate_item_label"
						:style="checkNotEmpty(form.voyage) && form.voyage === yoySum.minusDaySummaryData.voyage ?'color: #EB4747':''">
						航次统计环比</view>
					<view class="rate_item_input"
						:style="checkNotEmpty(form.voyage) && form.voyage === yoySum.minusDaySummaryData.voyage ?'color: #EB4747':''">
						{{formatDigit(form.voyageMom)}}%
					</view>
				</view>
				<view class="line"></view>
				<view class="rate_item">
					<view class="rate_item_label">航次统计同比</view>
					<view class="rate_item_input">
						{{formatDigit(form.voyageYoy)}}%
					</view>
				</view>
			</view>
			<view class="form_item">
				<view class="form_item_label">人数统计：</view>
				<view class="form_item_input">
					{{form.numberOfPeople === 0 ? form.numberOfPeople : form.numberOfPeople || ''}}
				</view>
			</view>
			<!-- 同比环比 -->
			<view class="form_item_rate"
				:class="checkNotEmpty(form.numberOfPeople) && form.numberOfPeople === yoySum.minusDaySummaryData.numberOfPeople ? 'danger' : ''">
				<view class="rate_item">
					<view class="rate_item_label"
						:style="checkNotEmpty(form.numberOfPeople) && form.numberOfPeople === yoySum.minusDaySummaryData.numberOfPeople ?'color: #EB4747':''">
						人数统计环比</view>
					<view class="rate_item_input"
						:style="checkNotEmpty(form.numberOfPeople) && form.numberOfPeople === yoySum.minusDaySummaryData.numberOfPeople ?'color: #EB4747':''">
						{{formatDigit(form.numberOfPeopleMom)}}%
					</view>
				</view>
				<view class="line"></view>
				<view class="rate_item">
					<view class="rate_item_label">人数统计同比</view>
					<view class="rate_item_input">
						{{formatDigit(form.numberOfPeopleYoy)}}%
					</view>
				</view>
			</view>
		</view>
		<!-- 陆岛权限 -->
		<view class="station_box">
			<view v-if="index < 9" :style="(index+1)%3 == 0 ? 'margin-right:0;':''" @click="changeLandNameIndex(index)"
				class="station_item" :class="[item.isFinish ? 'active' : '',index == landNameIndex ? 'choosed' : '']"
				v-for="(item, index) in landList" :key="item.id">
				<view v-if='item.isFinish' class="tag">
					<uni-icons type="checkmarkempty" color="#fff" size="12"></uni-icons>
				</view>
				{{item.stationName || ''}}
			</view>
			<view v-if="index >= 9 && showLand" :style="(index+1)%3 == 0 ? 'margin-right:0;':''"
				@click="changeLandNameIndex(index)" class="station_item"
				:class="[item.isFinish ? 'active' : '',index == landNameIndex ? 'choosed' : '']"
				v-for="(item, index) in landList" :key="item.id">
				<view v-if='item.isFinish' class="tag">
					<uni-icons type="checkmarkempty" color="#fff" size="12"></uni-icons>
				</view>
				{{item.stationName || ''}}
			</view>
		</view>
		<view v-if="landList.length > 9" class="station_act" @click="showLand = !showLand">
			<uni-icons v-if="!showLand" type="bottom" size="14" color="#2D8CF0" style="margin-right:10rpx;">
			</uni-icons>
			<uni-icons v-if="showLand" type="top" size="14" color="#2D8CF0" style="margin-right:10rpx;"></uni-icons>
			{{showLand?'收起':'展开'}}
		</view>
		<view class="form_item_box">
			<!-- 陆岛 -->
			<view class="form_item_li">
				<view class="form_item">
					<view class="form_item_label">水路(陆岛)：</view>
					<view class="form_item_input picker">
						<!-- <picker :value="item.landNameIndex" :range="landList" @change="e => changeLandName(e, index)">
							<text class="picker_select"
								:style="item.landName?'color:#333;':''">{{item.landName ? item.landName : '请选择'}}</text>
							<uni-icons type="right" size="16" color="#D4D4D4"></uni-icons>
						</picker> -->
						{{form.bizWaterwayIslandDataSaveOrUpdateDTOList[landNameIndex] ? form.bizWaterwayIslandDataSaveOrUpdateDTOList[landNameIndex].landName : ''}}
					</view>
				</view>
				<view class="form_item">
					<view class="form_item_label">航次：</view>
					<view class="form_item_input form_input">
						<uni-easyinput @blur="calcYoyMom(landNameIndex)" @clear="calcYoyMom(landNameIndex)" type="number"
							v-model="form.bizWaterwayIslandDataSaveOrUpdateDTOList[landNameIndex].voyage"
							placeholderStyle="color: #D4D4D4;font-size:28rpx;" placeholder="请输入" maxlength="20">
						</uni-easyinput>
					</view>
				</view>
				<!-- 同比环比 -->
				<view class="form_item_rate"
					:class="form.bizWaterwayIslandDataSaveOrUpdateDTOList[landNameIndex].voyageRingRatio === 0 ? 'danger' : '' ">
					<view class="rate_item">
						<view class="rate_item_label"
							:style="form.bizWaterwayIslandDataSaveOrUpdateDTOList[landNameIndex].voyageRingRatio === 0 ? 'color: #EB4747' : ''">
							航次环比
						</view>
						<view class="rate_item_input"
							:style="form.bizWaterwayIslandDataSaveOrUpdateDTOList[landNameIndex].voyageRingRatio === 0 ? 'color: #EB4747' : ''">
							{{form.bizWaterwayIslandDataSaveOrUpdateDTOList[landNameIndex] ? formatDigit(form.bizWaterwayIslandDataSaveOrUpdateDTOList[landNameIndex].voyageRingRatio) : '--'}}%
						</view>
					</view>
					<view class="line"></view>
					<view class="rate_item">
						<view class="rate_item_label">航次同比</view>
						<view class="rate_item_input">
							{{form.bizWaterwayIslandDataSaveOrUpdateDTOList[landNameIndex] ? formatDigit(form.bizWaterwayIslandDataSaveOrUpdateDTOList[landNameIndex].voyageYearOnYear) : '--'}}%
						</view>
					</view>
				</view>
				<view class="form_item">
					<view class="form_item_label">人数：</view>
					<view class="form_item_input form_input">
						<uni-easyinput @blur="calcYoyMom(landNameIndex)" @clear="calcYoyMom(landNameIndex)" type="number"
							v-model="form.bizWaterwayIslandDataSaveOrUpdateDTOList[landNameIndex].numberOfPeople"
							placeholderStyle="color: #D4D4D4;font-size:28rpx;" placeholder="请输入" maxlength="20">
						</uni-easyinput>
					</view>
				</view>
				<!-- 同比环比 -->
				<view class="form_item_rate"
					:class="form.bizWaterwayIslandDataSaveOrUpdateDTOList[landNameIndex].peopleRingRatio === 0 ? 'danger' : '' ">
					<view class="rate_item">
						<view class="rate_item_label"
							:style="form.bizWaterwayIslandDataSaveOrUpdateDTOList[landNameIndex].peopleRingRatio === 0 ? 'color: #EB4747' : ''">
							人数环比
						</view>
						<view class="rate_item_input"
							:style="form.bizWaterwayIslandDataSaveOrUpdateDTOList[landNameIndex].peopleRingRatio === 0 ? 'color: #EB4747' : ''">
							{{form.bizWaterwayIslandDataSaveOrUpdateDTOList[landNameIndex] ? formatDigit(form.bizWaterwayIslandDataSaveOrUpdateDTOList[landNameIndex].peopleRingRatio) : '--'}}%
						</view>
					</view>
					<view class="line"></view>
					<view class="rate_item">
						<view class="rate_item_label">人数同比</view>
						<view class="rate_item_input">
							{{form.bizWaterwayIslandDataSaveOrUpdateDTOList[landNameIndex] ? formatDigit(form.bizWaterwayIslandDataSaveOrUpdateDTOList[landNameIndex].peopleYearOnYear) : '--'}}%
						</view>
					</view>
				</view>
				<view class="form_item_remark">
					<view class="form_item_label">备注：</view>
					<view class="form_item_input">
						<uni-easyinput v-model="form.bizWaterwayIslandDataSaveOrUpdateDTOList[landNameIndex].remarks"
							placeholderStyle="color: #D4D4D4;font-size:28rpx;" placeholder="请输入备注信息" type="textarea" maxlength="200"
							autoHeight></uni-easyinput>
					</view>
				</view>
				<!-- <view class="line"></view> -->
			</view>
			<!-- <view class="add_btn" @click="addRow()">增行</view> -->

		</view>
		<!-- 底部按钮 -->
		<view class="foot_btn">
			<!-- <view class="act_btn" @click="doCancel">取消</view> -->
			<view class="act_btn blue" @click="doSubmit">{{btnText}}</view>
		</view>
	</view>
</template>
<script>
	import {
		checkNotEmpty,
		getDateStr
	} from "../../../common/util.js"
	export default {
		data() {
			return {
				form: {
					"bizWaterwayIslandDataSaveOrUpdateDTOList": [{
						"landName": "",
						"lastYearNumberOfPeople": '',
						"lastYearVoyage": '',
						"numberOfPeople": '',
						"peopleRingRatio": '',
						"peopleYearOnYear": '',
						"voyage": '',
						"voyageRingRatio": '',
						"voyageYearOnYear": '',
						"yesterdayNumberOfPeople": '',
						"yesterdayVoyage": '',
						"remarks": ''
					}],
					"numberOfPeople": "",
					"voyage": '',
					"reportDate": "",
					"statPeriod": ""
				}, //登录form
				array: [], //时段选择列表
				index: 2, //时段选择,默认0-24
				userInfo: {},
				landList: [],
				landNameIndex: 0,
				showLand: false,
				pageType: '',
				btnText: '保存',
				mobile: getApp().globalData.mobile,
				yoySum: {
					minusDaySummaryData: {},
					minusYearSummaryData: {}
				},//汇总同环比
			}
		},
		onLoad(options) {
			this.userInfo = uni.getStorageSync('userInfo');
			if (options.type == 'add') {
				this.pageType = 'add';
				let now = new Date();
				this.form.reportDate = getDateStr(now, -1); //默认前一天
				this.queryTime(); //统计时段
				// this.queryLandList(); //陆岛权限列表
			} else if (options.item) {
				this.btnText = '修改并保存';
				// this.form = JSON.parse(options.item);
				// this.form.bizWaterwayIslandDataSaveOrUpdateDTOList = this.form.bizWaterwayIslandDataVOList;
				// this.queryLandList(); //陆岛权限列表
				// this.queryTime();
				let obj = JSON.parse(options.item);
				this.queryDetailInfo2(obj.statDate, obj.statPeriod);
			} else if (options.id) {
				this.btnText = '修改并保存';
				this.queryDetailInfo(options.id);
			}
		},
		methods: {
			call(tel) {
				uni.makePhoneCall({
					phoneNumber: tel
				});
			},
			checkNotEmpty(data) {
				return checkNotEmpty(data);
			},
			formatDigit(data) {
				return !checkNotEmpty(data) ? '--' : (data+'').indexOf('.') > -1 && (data+'').substring((data+'').indexOf('.')).length > 2 ? data.toFixed(2) : data;
			},
			//切换当前编辑陆岛索引
			changeLandNameIndex(index) {
				this.landList[this.landNameIndex].isFinish = checkNotEmpty(this.form.bizWaterwayIslandDataSaveOrUpdateDTOList[this.landNameIndex].voyage) && checkNotEmpty(this.form
					.bizWaterwayIslandDataSaveOrUpdateDTOList[this.landNameIndex].numberOfPeople) ? true : false;
				this.landNameIndex = index;
			},
			//陆岛列表
			queryLandList(type) {
				this.$request(getApp().globalData.baseUrl + '/api/biz/waterwayIslandData/getByCurrentUserId', {}, 'GET').then(res => {
					this.landList = res.data;
					if (type == 'add') {
						this.form.bizWaterwayIslandDataSaveOrUpdateDTOList = [];
						this.landList.map(item => {
							item.isFinish = false;
							this.form.bizWaterwayIslandDataSaveOrUpdateDTOList.push({
								"landName": item.stationName,
								"lastYearNumberOfPeople": '',
								"lastYearVoyage": '',
								"numberOfPeople": '',
								"peopleRingRatio": '',
								"peopleYearOnYear": '',
								"voyage": '',
								"voyageRingRatio": '',
								"voyageYearOnYear": '',
								"yesterdayNumberOfPeople": '',
								"yesterdayVoyage": '',
								"remarks": ''
							})
						})
					} else {
						let arr = JSON.parse(JSON.stringify(this.form.bizWaterwayIslandDataSaveOrUpdateDTOList));
						this.form.bizWaterwayIslandDataSaveOrUpdateDTOList = [];
						this.landList.map(item => {
							let idx = arr.findIndex(item2 => item2.landName == item.stationName);
							console.log(idx)
							if (idx > -1) {
								item.isFinish = checkNotEmpty(arr[idx].numberOfPeople) && checkNotEmpty(arr[idx].voyage) ? true :
									false;
								this.form.bizWaterwayIslandDataSaveOrUpdateDTOList.push(arr[idx]);
							} else {
								item.isFinish = false;
								this.form.bizWaterwayIslandDataSaveOrUpdateDTOList.push({
									"landName": item.stationName,
									"lastYearNumberOfPeople": '',
									"lastYearVoyage": '',
									"numberOfPeople": '',
									"peopleRingRatio": '',
									"peopleYearOnYear": '',
									"voyage": '',
									"voyageRingRatio": '',
									"voyageYearOnYear": '',
									"yesterdayNumberOfPeople": '',
									"yesterdayVoyage": '',
									"remarks": ''
								})
							}
						})
						this.form.bizWaterwayIslandDataSaveOrUpdateDTOList.map((item,index) => {
							this.calcYoyMom(index);
						})
					}
				})
			},
			//陆岛切换
			changeLandName(e, index) {
				//判断是否重复选择
				let idx = this.form.bizWaterwayIslandDataSaveOrUpdateDTOList.findIndex(item => item.landNameIndex == e.detail
					.value);
				if (idx > -1 && this.form.bizWaterwayIslandDataSaveOrUpdateDTOList[index].landNameIndex !== idx) {
					uni.showToast({
						title: '水运(陆岛)不能重复选择',
						icon: 'none'
					});
				} else {
					this.form.bizWaterwayIslandDataSaveOrUpdateDTOList[index].landNameIndex = e.detail.value;
					this.form.bizWaterwayIslandDataSaveOrUpdateDTOList[index].landName = this.landList[e.detail.value];
					this.calcYoyMom(index);
				}
			},
			//环比同比计算
			calcYoyMom(index) {
				if (this.form.reportDate == '' || this.form.statPeriod == '' || this.form
					.bizWaterwayIslandDataSaveOrUpdateDTOList[index].landName == '') {
					return;
				}
				this.landList[index].isFinish = checkNotEmpty(this.form
					.bizWaterwayIslandDataSaveOrUpdateDTOList[index].voyage) && checkNotEmpty(this.form
					.bizWaterwayIslandDataSaveOrUpdateDTOList[index].numberOfPeople) ? true : false;
				//重新计算汇总统计
				let _voyage = 0;
				let _numberOfPeople = 0;
				this.form.bizWaterwayIslandDataSaveOrUpdateDTOList.map(item => {
					_voyage = _voyage + (checkNotEmpty(item.voyage) ? parseInt(item.voyage) : 0);
					_numberOfPeople = _numberOfPeople + (checkNotEmpty(item.numberOfPeople) ? parseInt(item.numberOfPeople) : 0);
				})
				this.form.voyage = _voyage;
				this.form.numberOfPeople = _numberOfPeople;
				//重新计算汇总同环比
				this.calcSum();
				this.$request(getApp().globalData.baseUrl + '/api/biz/waterwayIslandData/getYoyMom?statDate=' + this.form
						.reportDate + '&statPeriod=' + this.form.statPeriod + '&landName=' + this.form
						.bizWaterwayIslandDataSaveOrUpdateDTOList[index].landName + '&_t=' + Date.parse(new Date()), {},
						'GET')
					.then(res => {
						let yesterdayData = res.data.yesterdayData;
						let lastYearData = res.data.lastYearData;
						this.form.bizWaterwayIslandDataSaveOrUpdateDTOList[index].yesterdayVoyage = yesterdayData.voyage;
						this.form.bizWaterwayIslandDataSaveOrUpdateDTOList[index].lastYearVoyage = lastYearData.voyage;
						this.form.bizWaterwayIslandDataSaveOrUpdateDTOList[index].yesterdayNumberOfPeople = yesterdayData.numberOfPeople;
						this.form.bizWaterwayIslandDataSaveOrUpdateDTOList[index].lastYearNumberOfPeople = lastYearData.numberOfPeople;
						//环比-同比
						//环比计算规则 if今天没有值不计算，elseif昨天没有值不计算，elseif昨天===0并且今天===0百分比0，esleif昨天0今天大于0百分比100,else(今天-昨天)/昨天*100
						// let obj = this.form.bizWaterwayIslandDataSaveOrUpdateDTOList[index];
						this.form.bizWaterwayIslandDataSaveOrUpdateDTOList[index].voyageRingRatio = this.$calcMom(this.form.bizWaterwayIslandDataSaveOrUpdateDTOList[index].voyage, yesterdayData.voyage);
						this.form.bizWaterwayIslandDataSaveOrUpdateDTOList[index].voyageYearOnYear = this.$calcYoy(this.form.bizWaterwayIslandDataSaveOrUpdateDTOList[index].voyage, lastYearData.voyage);
						this.form.bizWaterwayIslandDataSaveOrUpdateDTOList[index].peopleRingRatio = this.$calcMom(this.form.bizWaterwayIslandDataSaveOrUpdateDTOList[index].numberOfPeople, yesterdayData.numberOfPeople);
						this.form.bizWaterwayIslandDataSaveOrUpdateDTOList[index].peopleYearOnYear = this.$calcYoy(this.form.bizWaterwayIslandDataSaveOrUpdateDTOList[index].numberOfPeople, lastYearData.numberOfPeople);
						// console.log('环比同比', this.form.bizWaterwayIslandDataSaveOrUpdateDTOList[index]);
						this.$forceUpdate();
					})
			},
			//id查询详情
			queryDetailInfo(id) {
				this.$request(getApp().globalData.baseUrl + '/api/biz/waterwayIslandData/getById/' + id, {},
					'GET').then(res => {
					this.form = res.data;
					this.form.bizWaterwayIslandDataSaveOrUpdateDTOList = this.form.bizWaterwayIslandDataVOList;
					this.queryTime(); //统计时段
					this.queryLandList();
				})
			},
			//根据日期和时段查询详情
			queryDetailInfo2(statData, statPeriod) {
				this.$request(getApp().globalData.baseUrl + '/api/biz/waterwayIslandData/getDataByTime?statDate=' + statData + '&statPeriod=' + statPeriod, {},
					'GET').then(res => {
					res.data.reportDate = statData;
					res.data.statPeriod = statPeriod;
					this.form = res.data;
					this.form.bizWaterwayIslandDataSaveOrUpdateDTOList = this.form.bizWaterwayIslandDataVOList;
					//查询汇总同环比
					this.$request(getApp().globalData.baseUrl + '/api/biz/waterwayIslandData/getSummaryDataYoYAndMoM?statDate=' + statData + '&statPeriod=' + statPeriod + '&_t=' + Date.parse(new Date()), {},
							'GET')
						.then(res2 => {
							res2.data.minusDaySummaryData = res2.data.minusDaySummaryData ? res2.data.minusDaySummaryData : {};
							res2.data.minusYearSummaryData = res2.data.minusYearSummaryData ? res2.data.minusYearSummaryData : {};
							this.yoySum = res2.data;
							// this.calcSum();
							if(this.pageType != 'add') {
								this.queryTime(); //统计时段
							}
							this.queryLandList();
						})
				})
			},
			//汇总同环比计算
			calcSum() {
				this.form.voyageMom = this.$calcMom(this.form.voyage,this.yoySum.minusDaySummaryData.voyage);
				this.form.voyageYoy = this.$calcYoy(this.form.voyage,this.yoySum.minusYearSummaryData.voyage);
				this.form.numberOfPeopleMom = this.$calcMom(this.form.numberOfPeople,this.yoySum.minusDaySummaryData.numberOfPeople);
				this.form.numberOfPeopleYoy = this.$calcYoy(this.form.numberOfPeople,this.yoySum.minusYearSummaryData.numberOfPeople);
			},
			//统计时段切换选择
			changeStatPeriod(e) {
				this.index = e.detail.value;
				this.form.statPeriod = this.array[e.detail.value].dictValue;
				console.log('change 时段', this.form)
				if(this.pageType == 'add') {
					this.queryDetailInfo2(this.form.reportDate, this.form.statPeriod);
				}
				else {
					//重新计算同比环比
					this.form.bizWaterwayIslandDataSaveOrUpdateDTOList.map((item, index) => {
						this.calcYoyMom(index);
					})
				}
			},
			//取消
			doCancel() {
				uni.navigateBack();
			},
			//选择统计日期
			bindDateChange(e) {
				this.form.reportDate = e.detail.value;
				if(this.pageType == 'add') {
					this.queryDetailInfo2(this.form.reportDate, this.form.statPeriod);
				}
				else {
					//重新计算同比环比
					this.form.bizWaterwayIslandDataSaveOrUpdateDTOList.map((item, index) => {
						this.calcYoyMom(index);
					})
				}
			},
			//时段
			queryTime() {
				this.$request(getApp().globalData.baseUrl + '/api/dict/dictList?dictType=waterage_time' + '&_t=' + Date
					.parse(
						new Date()), {}, 'GET').then(res => {
					this.array = res.data;
					if (this.pageType == 'add') {
						let now = new Date();
						//11:00-13:30 默认选择0-12
						let dateStr = getDateStr(now, 0).replaceAll('-', '/');
						// if (new Date(dateStr + ' 11:00').getTime() < new Date().getTime() && new Date().getTime() <
						// 	new Date(dateStr +
						// 		' 14:30').getTime()) {
						// 	this.form.statPeriod = '0012';
						// 	let idx = this.array.findIndex(item => item.dictValue == '0012');
						// 	this.index = idx > -1 ? idx : '';
						// } else {
							this.form.statPeriod = '03'; //默认0-24
							let idx = this.array.findIndex(item => item.dictValue == '03');
							this.index = idx > -1 ? idx : '';
						// }
						this.queryDetailInfo2(this.form.reportDate, this.form.statPeriod);
					} else {
						let idx = this.array.findIndex(item => item.dictValue == this.form.statPeriod);
						this.index = idx > -1 ? idx : '';
					}
				})
			},
			//增行
			addRow() {
				this.form.bizWaterwayIslandDataSaveOrUpdateDTOList.push({
					"landNameIndex": "",
					"landName": "",
					"lastYearNumberOfPeople": 0,
					"lastYearVoyage": 0,
					"numberOfPeople": 0,
					"peopleRingRatio": 0.0,
					"peopleYearOnYear": 0.0,
					"voyage": 0,
					"voyageRingRatio": 0.0,
					"voyageYearOnYear": 0.0,
					"yesterdayNumberOfPeople": 0,
					"yesterdayVoyage": 0
				});
			},
			//删行
			delRow(index) {
				this.form.bizWaterwayIslandDataSaveOrUpdateDTOList.splice(index, 1);
			},
			//确认提交
			doSubmit() {
				console.log(this.form)
				if (this.form.reportDate == '' || this.form.statPeriod == '') {
					uni.showToast({
						title: '报送日期和时段不能为空',
						icon: 'none'
					})
					return;
				}
				let checkAccident = true;
				if (this.form.bizWaterwayIslandDataSaveOrUpdateDTOList.length > 0) {
					checkAccident = this.form.bizWaterwayIslandDataSaveOrUpdateDTOList.every(item => {
						return checkNotEmpty(item.landName) && checkNotEmpty(item.numberOfPeople) && checkNotEmpty(
							item.voyage)
					})
				}
				if (!checkAccident) {
					uni.showToast({
						title: '陆岛详情不能为空',
						icon: 'none'
					})
					return;
				}
				console.log(this.form.id)
				uni.showModal({
					title: '提示',
					content: this.pageType == 'add' ? '您确认提交该条报送数据?' : '您确认将该条数据进行修改?',
					success: (res) => {
						if (res.confirm) {
							this.submitForm();
						}
					}
				})
			},
			submitForm() {
				uni.showLoading({
					title: '提交中...',
					mask: true
				})
				this.$request(getApp().globalData.baseUrl + '/api/biz/waterwayIslandData/saveOrUpdateV2', this
					.form,
					'POST').then(res => {
					uni.hideLoading();
					if (res.code == 200) {
						uni.showToast({
							title: '报送提交成功',
							icon: 'none',
							success: () => {
								if (this.form.id == undefined) {
									setTimeout(() => {
										uni.redirectTo({
											url: '/pages/water/waterWay/list'
										})
									}, 300)
								} else {
									uni.navigateBack();
								}
							}
						})
					}
				}).catch(() => {
					uni.hideLoading();
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	.form_warp {
		padding: 30rpx 30rpx 195rpx;

		.form_intro {
			color: #666;
			font-size: 26rpx;
			font-family: PingFang SC-Bold, PingFang SC;
			line-height: 48rpx;
			text-align: center;
			margin-bottom: 20rpx;

			.tel {
				color: #2D8CF0;
				font-weight: bold;
			}
		}

		.form_item_box {
			padding: 30rpx 20rpx 30rpx 30rpx;
			background-color: #fff;
			border-radius: 30rpx;

			//环比同比
			.form_item_rate {
				background: #F6F6F6;
				border: 1px solid #F6F6F6;
				padding: 30rpx;
				margin-bottom: 30rpx;
				border-radius: 30rpx;

				.line {
					height: 1px;
					background-color: #dfdfdf;
					margin: 30rpx 0;
				}

				.rate_item {
					display: flex;
					justify-content: space-between;
					font-size: 24rpx;
					font-family: PingFang SC-Regular, PingFang SC;
					font-weight: 400;

					.rate_item_label {
						color: #666;
						font-size: 24rpx;
					}

					.rate_item_input {
						color: #333;
						font-size: 28rpx;
					}
				}

				&.danger {
					background-color: #FEF6F3;
					border-color: #F0622D;
				}
			}

			.form_item_title {
				color: #333;
				line-height: 42rpx;
				font-size: 30rpx;
				font-family: PingFang SC-Bold, PingFang SC;
				font-weight: bold;
				margin-bottom: 30rpx;
			}

			.form_item_remark {
				margin-bottom: 30rpx;

				.form_item_label {
					color: #333333;
					line-height: 42rpx;
					font-size: 30rpx;
					font-family: PingFang SC-Bold, PingFang SC;
					font-weight: bold;
					margin-bottom: 30rpx;
				}
				/deep/ .is-input-border{
					border-radius: 20rpx !important;
					border: 1px solid #c1c1c1 !important;
				}
			}

			.form_item {
				display: flex;
				align-items: center;
				justify-content: space-between;
				line-height: 37rpx;
				font-family: PingFang SC-Regular, PingFang SC;
				font-weight: 400;
				margin-bottom: 30rpx;

				.form_item_label {
					width: 260rpx;
					color: #666666;
					font-size: 26rpx;
					word-break: break-all;
				}

				.form_item_input {
					color: #333;
					text-align: right;
					word-break: break-all;

					&.picker {
						flex: 1;
						// display: flex;
						// justify-content: space-between;

						// /deep/ picker {
						// 	flex: 1;
						// }

						.picker_select {
							color: #D4D4D4;
							font-size: 28rpx;
							font-family: PingFang SC-Regular, PingFang SC;
							font-weight: 400;
							text-align: right;
						}
					}

					//纯展示
					&.text {
						color: #333333;
						line-height: 40rpx;
						font-size: 28rpx;
						font-family: PingFang SC-Regular, PingFang SC;
						font-weight: 400;
					}

					//输入框
					&.form_input {
						/deep/ .is-input-border {
							border: 0 !important;

							.uni-easyinput__content-input {
								height: 35rpx !important;
								text-align: right;
							}
						}

						/deep/ .uni-date-x--border {
							border: 0 !important;

							.uni-date__x-input {
								// height: 35rpx !important;
								text-align: right;
							}
						}
					}
				}
			}
		}
	}

	//收费站
	.station_box {
		display: flex;
		flex-wrap: wrap;
		margin-top: 40rpx;

		.station_item {
			width: 173rpx;
			height: 60rpx;
			color: #666666;
			line-height: 60rpx;
			font-size: 26rpx;
			font-family: PingFang SC-Regular, PingFang SC;
			font-weight: 400;
			text-align: center;
			border-radius: 20rpx;
			border: 1rpx solid #C1C1C1;
			padding: 0 20rpx;
			margin-bottom: 40rpx;
			margin-right: 20rpx;
			overflow: hidden;

			&.active {
				position: relative;
				color: #1ECE5F;
				border-color: #1ECE5F;
				background: #EBFAF2;

				.tag {
					position: absolute;
					top: 0;
					right: 0;
					width: 34rpx;
					height: 23rpx;
					color: #fff;
					line-height: 23rpx;
					background: #1ECE5F;
					border-radius: 0rpx 20rpx 0rpx 5rpx;
					text-align: center;
				}
			}

			&.choosed {
				border-color: #2D8CF0 !important;
			}
		}
	}

	.foot_btn {
		position: fixed;
		left: 0;
		right: 0;
		bottom: 0;
		display: flex;
		justify-content: space-between;
		padding: 40rpx 30rpx;
		background-color: #f5f5f5;
		z-index: 11;

		.act_btn {
			width: 690rpx;
			height: 90rpx;
			color: #666666;
			font-size: 28rpx;
			line-height: 90rpx;
			font-family: PingFang SC-Regular, PingFang SC;
			font-weight: 400;
			text-align: center;
			background: #F6F6F6;
			border-radius: 100rpx;
			border: 1rpx solid #C1C1C1;

			&.blue {
				color: #fff;
				background: #2D8CF0;
				border-color: #2D8CF0;
			}
		}
	}

	//增行
	.line {
		height: 1px;
		background-color: #E1E1E1;
	}

	.add_btn {
		height: 90rpx;
		line-height: 90rpx;
		color: #2D8CF0;
		font-size: 28rpx;
		font-family: PingFang SC-Regular, PingFang SC;
		font-weight: 400;
		text-align: center;
		background: #ECF5FF;
		border-radius: 30rpx;
		border: 2rpx solid #2D8CF0;
		margin-top: 30rpx;
	}

	.tab_box {
		display: flex;
		justify-content: space-around;

		.tab_nav {
			color: #999999;
			line-height: 42rpx;
			font-size: 30rpx;
			font-family: PingFang SC-Regular, PingFang SC;
			font-weight: 400;
			padding-bottom: 25rpx;

			&.active {
				position: relative;
				color: #2D8CF0;
				font-weight: bold;

				&::after {
					position: absolute;
					content: '';
					left: 50%;
					bottom: 0;
					width: 74rpx;
					height: 6rpx;
					background: #2D8CF0;
					border-radius: 100rpx;
					margin-left: -37rpx;
				}
			}
		}
	}

	button {
		background-color: #007aff;
		color: #ffffff;
	}
</style>