<template>
	<view class="probox inform">
		<view class="zhanline" ></view>
		<view class="steps" v-if="jzqklist.length">
			<view class="lssteplist" v-for="(ite,idx) in jzqklist" :key="idx">
				<view class="stepcir"></view>
				<view class="flex1">
					<view class="mb20">
						<view class="f16 c34 fw mb8 lh22">上报日期</view>
						<view class="f15 c6">{{ite.createTime}}</view>
					</view>
					<view class="mb20">
						<view class="f16 c34 fw mb8">对接情况</view>
						<view class="f15 c6">{{ite.jzqk}}</view>
					</view>
					<view v-if="ite.zsyzFjList&&ite.zsyzFjList.length">
						<view class="f16 c34 fw mb8">附件</view>
						<view class=" cldelistbf flex1" v-for="(zite,zidx) in ite.zsyzFjList" :key='zidx'>
							<view class="flext f16 c6">
								<view class="imgl"><image :src="wimg" ></image></view>
								<view>{{zite.fjName}}</view>
							</view>
							<view class="flexc f16 co28 flex0" @click="getDown(zite.path)">
								<image :src="downimg" class="imgr"></image>预览</view>
						</view>
					</view>
				</view>
			</view>
		</view>
		<no-data v-else></no-data>
	</view>
</template>

<script>
	import noData from "@/components/nodata/nodata.vue"
	import {getjzqklist} from "@/api/work/clue.js"
	import config from '@/config'
	const baseUrl = config.baseUrl
	export default{
		components:{
			noData
		},
		data(){
			return{
				wimg:require('@/static/images/index/wicon.png'),
				downimg:require('@/static/images/index/down.png'),
				xmId:'',
				xmbh:'',
				pageSize: 10,
				pageNum: 1,
				reachflag:true,
				deptId:this.$store.state.user.deptId,
				jzqklist:[],
			}
		},
		onLoad(e) {
			this.xmId=e.id;
			this.xmbh=e.xmbh;
			this.getDataFn()
		},
		onReachBottom() {
			if (this.reachflag) {
				this.pageNum++
				this.getDataFn()
			}
		},
		methods:{
			getDataFn(){
				var params={
					xmId:this.xmId,
					xmbh:this.xmbh,
					pageSize:this.pageSize,
					pageNum: this.pageNum,
				}
				getjzqklist(params).then(res=>{
					if(res.code==200){
						if (res.rows.length < this.pageSize) {
							this.reachflag = false
							this.wtdt = '到底了~';
						} else {
							var num = parseInt(res.rows.length) + parseInt(this.pageSize) * parseInt(this.pageNum -	1)
							if (num < res.total) {
								this.reachflag = true
								this.wtdt = '上拉加载更多'
							} else {
								this.reachflag = false
								this.wtdt = '到底了~';
							}
						}
						if (this.pageNum == 1) {
							this.jzqklist = res.rows;
						} else {
							this.jzqklist = this.jzqklist.concat(res.rows)
						}									
					}else{
						this.$toast(res.msg)
					}
				})
			},
			getDown(e){
				uni.showLoading({
					title: '加载中'
				});
				var url=baseUrl+e;
				uni.downloadFile({
					url: url,//文件的下载路径
					success(result) {
						uni.hideLoading()
						var filePath = result.tempFilePath;
						   uni.openDocument({
						     filePath: filePath,
						     showMenu: true,
						     success: function (res) {
						       console.log('打开文档成功');
						     }
						   });
					},
					fail(res) {uni.hideLoading()}
				})
			},
		}
	}
</script>

<style scoped lang="scss">
</style>