<template>
	<view class="processWrapper exportBody ">
		<view style="height:98rpx"></view>
		<view class="ding">
			<!-- <calendar></calendar> -->
			<view class="example-body">
				<uni-datetime-picker v-model="datetimerange" type="datetimerange" start-placeholder="请选择开始时间"
					end-placeholder="请选择结束时间" start="2000-3-20 12:00:00" end="2025-10-20 20:00:00" rangeSeparator="至" />
			</view>
		</view>

		<block>
			<view class="processList">
				<view class="cu-list menu-avatar">
					<view class="cu-item" v-for="(item,index) in getExportData" :key="index">
						<view class="cu-avatar lg">
							<image class="image-bg"
								:src="item.clzt==0?'/static/process-icon.png':'/static/processed-icon.png'" />
						</view>
						<view class="content">
							<view class="pro-title">
								<view class="cut">{{keyWords=='人工督察单'?item.artificial_code:item.supervise_code}}</view>
							</view>
							<view class="pro-des  ">
								<view class="text-cut">{{item.content}}</view>
							</view>
							<view class="pro-date ">{{item.timestamp}}</view>
						</view>
						<view class="action" style="z-index:99">
							<view class="unProcess" v-if="item.clzt==0">未处理</view>
							<view class="processed" v-else>已处理</view>
						</view>
					</view>
					<view class=" text-center margin-top" v-if="!this.getExportData.length&&this.dataRes">暂无数据...</view>
				</view>
			</view>
		</block>
		<view v-if="this.getExportData.length>0" class="padding-lr padding-bottom-lg bg-white" style="position:fixed;bottom:0;width:100%">
			<view class="btn-area">
				<button class="bg-blue  round missReport margin-top" @tap="exportButton()">导 出 </button>
			</view>
		</view>



	</view>
</template>

<script>
	import json from '../../data/json.js';
	export default {
		data() {
			return {
				getExportData: [],
				dataRes: 0,
				datetimerange: ['', ''],
				keyWords:'',
		
			};
		},
		onLoad: function(option) {
			this.keyWords=option.keywords;
			this.getData({
				"company_code": uni.getStorageSync('selectedCode'),
				"start_time": '',
				"end_time": '',
			})

		},
		watch: {
			datetimerange(newval) {
				this.getData({
					"company_code": uni.getStorageSync('selectedCode'),
					
					"start_time":newval[0],
					"end_time": newval[1],
				})
			}
		},
		
		methods: {

			async getData(params = {}) {
				const res = await this.$myRequest({
					// url: listUrl, //人员督察单渲染
					url:this.keyWords=='人工督察单'?'FireInspector/getManualInspectorList':'FireInspector/getElectronicInspectorList',
					data: params,
					showLoading: true
				})
				this.getExportData = res.data.data;
				this.dataRes = 1;
			},
			exportButton() {
				let url2 = "";
				switch (this.keyWords) {
					case '人工督察单':
						url2 = "ExportModule/getManualInspectorListExpor"
						break;
					case '电子督察单':
						url2 = "ExportModule/getElectronicInspectorListExpor"
						break;
					default:
						break;
				}
				
				
				//#ifdef H5				
				let exportUrl = this.$BASE_URL +url2+
					`/start_time/${this.datetimerange[0]}/end_time/${this.datetimerange[1]}/company_code/${uni.getStorageSync('selectedCode')}/`
				var ua = window.navigator.userAgent.toLowerCase();
				if (ua.match(/MicroMessenger/i) == 'micromessenger') {
					uni.showModal({
						showCancel: false,
						content: '如需下载，请在默认浏览器中操作',
						success: function(res) {
							window.location.href = exportUrl;
						}
					});
				} else {
					window.location.href = exportUrl;
				}
				//#endif

			}





		}
	}
</script>

<style lang="scss">


</style>
