<template>
	<view class="dealDetail">
		<view class="timeBox flex justify-between align-center padding-lr-sm">
			<view class="time">{{detailMessage2.time}}</view>
			<button class="cu-btn radius bg-green sm" v-if="handling_status==1">已处理</button>
			<button class="cu-btn radius bg-green sm" v-if="handling_status==0">未处理</button>
		</view>

		<view>
			<!-- 基本信息start -->
			<view class="basic-info">
				<view class="info-tit margin-left-xs">
					<text class="cuIcon-titles margin-right-xs"></text>
					基本信息
				</view>
				<view class="info-content">
					<view class="info-one-info ">
						<text>设备名称：</text>
						<text>{{detailMessage2.deviceName}}</text>
					</view>

					<view>
						<text>设备地址：</text>
						<text>{{detailMessage2.deviceAddress}}</text>
					</view>
					<view>
						<text>告警信息：</text>
						<text>{{detailMessage2.alarmInformation}}</text>
					</view>
				</view>
			</view>
			<!-- 基本信息end -->
			<!-- 报警当前情况截图start -->
			<view class="basic-info">
				<view class="info-tit margin-left-xs">
					<text class="cuIcon-titles margin-right-xs"></text>
					报警当前情况截图
				</view>
				<view class="info-content padding-lr-lg">
					<image :src="detailMessage2.alarmPicture" style="width:100%"></image>
				</view>
			</view>
			<!-- 报警当前情况截图end -->
			<!-- 处理信息start -->
			<view class="processStatus" v-if="handling_status==1">
				<view class="info-tit margin-left-xs">
					<text class="cuIcon-titles margin-right-xs"></text>
					处理信息
				</view>
				<view class="info-content">
					<view class="info-one-info ">
						<text>是否误报：</text>
						<text>{{detailMessage2.alarmStatus=='1'?'误报':'非误报'}}</text>
					</view>
					<view>
						<text>处理人：</text>
						<text>{{detailMessage2.handler}}</text>
					</view>
					<view>
						<text>处理时间：</text>
						<text>{{detailMessage2.handlerTime}}</text>
					</view>
					<view>
						<text>处理内容：</text>
						<text>{{detailMessage2.handlerContent}}</text>
					</view>
				</view>
			</view>
			<!-- 处理状态end -->


			<!-- 处理状态start -->
			<view class="processStatus" v-else>
				<view class="info-tit margin-left-xs">
					<text class="cuIcon-titles margin-right-xs"></text>
					处理内容
				</view>
				<view class="padding-lr padding-bottom-lg">
					<form action="">
						<view class="cu-form-group">
							<textarea class="JTxtArea lg" placeholder="备注信息,最多可输入50个字..." :maxlength="50"
								:data-maxnum="reason.length+'/50'" auto-height v-model="msg2"></textarea>
						</view>
						<view class="btn-area">
							<button class="bg-orange round missReport margin-top" @click="videoMissSubmit()">误 报
							</button>
							<button class="bg-blue round  missReport margin-top " @click="videoSubmit()">告警确认 </button>
						</view>
					</form>
				</view>
			</view>
			<!-- 处理状态end -->
		</view>

	</view>
</template>

<script>
	export default {
		data() {
			return {
				msg2: '',
				reason: '',
				radio: 'A',
				radio: 'B',
				modalName: null,
				type: '0',
				detailMessage2: {},

				handling_status: 0
			}
		},
		onLoad: function(option) {
			
			this.type = option.type;
			this.companyCode = option.companyCode;
			this.alarmId = option.id;
			
			this.getVideoDetail({
				"companyCode": option.companyCode,
				"alarmId": option.id
			})

		},
		methods: {

			async getVideoDetail(ming = {}) {
				const res = await this.$myRequest({
					url: 'IntegratedAlarm/getVideoAlarmDetails',
					data: ming
				})
				console.log(res.data.data[0]);
				this.detailMessage2 = res.data.data[0];
				this.handling_status = this.detailMessage2.handling_status;
				if (this.handling_status != 0) {
					uni.setNavigationBarTitle({
						title: '已处理'
					});
				} else {
					uni.setNavigationBarTitle({
						title: '未处理'
					});
				}
			},

			videoSubmit() {
				if (!this.msg2) {
					uni.showToast({
						title: "请输入处理内容",
						icon: "none"
					});
				} else {
					this.powerSubmitRes({
						"alarmStatus": 0,
						"type": 2,
						"deviceCode": this.detailMessage2.deviceCode,
						"companyCode": this.companyCode,
						"id": this.detailMessage2.id,
						"handlerContent": this.msg2
					})

				}


			},
			videoMissSubmit() {
				if (!this.msg2) {
					uni.showToast({
						title: "请输入处理内容",
						icon: "none"
					});
				} else {
					this.powerSubmitRes({
						"alarmStatus": 1,
						"type": 2,
						"deviceCode": this.detailMessage2.deviceCode,
						"companyCode": this.companyCode,
						"id": this.detailMessage2.id,
						"handlerContent": this.msg2
					})
				}


			},


			powerSubmit() {
				if (!this.msg) {
					uni.showToast({
						title: "请输入处理内容",
						icon: "none"
					});
				} else {
					this.powerSubmitRes({
						"type": 1,
						"deviceCode": this.detailMessage.deviceCode,
						"companyCode": this.companyCode,
						"id": this.detailMessage.id,
						"handlerContent": this.msg
					})
				}
			},

			async powerSubmitRes(params = {}) {
				const res = await this.$myRequest({
					url: 'IntegratedAlarm/setAlarmHandle',
					data: params
				})

				if (res.data.flag) {
					uni.showToast({
						title: "提交成功",
					});
				}

				setTimeout(() => {
					uni.navigateTo({
						url: '/pages/processList/processList?companyCode=' + this.companyCode +
							'&type=' + this.type + '',

					});
				}, 1000);
			},


			submit() {
				uni.makePhoneCall({
					phoneNumber: this.detailMessage.phone
				});
			},

			RadioChange(e) {
				this.radio = e.detail.value
			},
			textareaAInput(e) {
				this.textareaAValue = e.detail.value
			},
			// textarea
			inputReason(e) {
				this.reason = e.detail.value;
			}
		}
	}
</script>

<style lang="scss">
	.timeBox {
		height: 88rpx;
		background: #EFF4FF;
		line-height: 88rpx;

		.time {
			color: #333
		}
	}

	.info-tit {
		color: #4074E7;
		line-height: 90rpx;
		height: 90rpx;
	}

	// 基本信息
	.info-content>view {
		margin-left: 24rpx;
		border-bottom: 1px solid #EDEDED;
		line-height: 92rpx;
		color: #666;
	}

	.info-content view text:first-child {
		width: 160rpx;
		display: inline-block
	}

	/* // 处理内容 */
	.cu-form-group {
		background: #f5f5f5;

	}

	.processStatus {
		textarea {
			background: #F5F5F5;
			color: #999999;
		}
	}

	// textarea
	.JTxtArea {
		position: relative;

		&.sm {
			min-height: 60rpx;
		}

		&.lg {
			min-height: 100rpx;
		}

		&:after {
			content: attr(data-maxnum);
			position: absolute;
			right: 10rpx;
			bottom: 0px;
		}
	}
</style>
