<template>
	<view class="app">
		<view class="items">
			<uni-table border stripe emptyText="">
				<uni-tr class='toptr'>
					<uni-th width="90" align="center">资料名称</uni-th>
					<uni-th width="90" align="center">状态</uni-th>
					<!-- <uni-th width="90" align="center">乡镇/街道</uni-th> -->
					<uni-th width="110" align="center">操作</uni-th>
				</uni-tr>
				<uni-tr v-for="(item,index) in list" :key='index' class='tr'>
					<uni-td align="center">{{item.careerProfilename}}</uni-td>
					<uni-td align="center" :style="{
                color: item.docstatusremark != '已提交' ? 'red' : '',
              }">{{item.docstatusremark}}</uni-td>
					<!-- <uni-td align="center">{{item.atStreetName}}</uni-td> -->
					<uni-td align="center">
						<view class="" style="color: #169BD5;" @click="report(item)">查看报告

						</view>
					</uni-td>

				</uni-tr>
			</uni-table>
		</view>
		<u-toast ref="uToast" />
		<u-back-top :scroll-top="scrollTop"></u-back-top>

	</view>
</template>

<script>
	import {
		getZlList,
		getFileInfo,
		
	} from '@/api/details/details.js'
	import baseUrl from '@/api/baseurl.js'
	export default {
		data() {
			return {
				list: null,
				scrollTop: 0,
				enterpriseid: '',
				// qyName: '',
				// page: 1,
				// limit: 20,
				count: null,

			}
		},
		onLoad(options) {
			if (options.enterprisId) {
				this.enterpriseid = options.enterprisId

			}


			this.info()

		},

		methods: {
			info() {
				// this.page = 1;
				// this.wordsName = ''
				// console.log(this.enterpriseid)
				getZlList(this.enterpriseid).then(res => {
					this.list = res.data
					this.count = res.count
				})
			},
			// 查看报告
			report(item) {
				// console.log('11', item)
				// this.enterprisId = item.enterpriseid
				if (item.docstatusremark != "已提交") {
					this.$refs.uToast.show({
						title: '未提交报告',
						type: 'error',
						duration: 1500
					})

				} else {
					getFileInfo(item.enterpriseid, item.doctypeid).then(res => {
						if (res == '无文件提交' || res == '') {
							this.$refs.uToast.show({
								title: '无文件提交',
								type: 'error',
								duration: 1500
							})

						} else {
							uni.showLoading({
								title: '文件加载中'
							});
							this.filePath = res
							let urls = baseUrl + `/dzzyb` + res
							
							uni.downloadFile({
								url:encodeURI(urls),
								success: (data) => {
									console.log(data)
									if (data.statusCode == 200) {
										//文件保存到本地
										uni.saveFile({
											tempFilePath: data.tempFilePath, //临时路径
											success: function(res) {
												// console.log(res)
											}
										});
										uni.openDocument({

											filePath: data.tempFilePath,
											success: function(res) {
												uni.hideLoading();
												// console.log('打开文档成功');
											},
											fail: function() {
												uni.hideLoading();
												uni.showToast({
													title: '暂不支持此类型',
													duration: 2000,
													icon: "none",
												});
											}
										});
										// if (this.filePath) {
										// 	delPgFile(this.filePath).then(res => {})
										// };
									}
								},
							})

						}


					})
				}


			},


		}
	}
</script>

<style lang="scss">
	::v-deep .uni-table {
		min-width: 100% !important;
	}
	::v-deep .u-iconfont::before{
		font-size: tovmin(10);
	
	}
	.app {
		// padding: 0 0 100rpx;
		margin-top: tovmin(10);
		height: 100%;
		position: relative;
		// .tr{
		// 	padding: tovmin(19) tovmin(10) !important;
			
		// }
	
		.topbody {
			display: flex;
	
			// background-color: red;
			.text {
				font-size: tovmin(30);
	
				text-align: center;
				height: tovmin(80);
				line-height: tovmin(80);
				// margin-top: 1rpx;
			}
		}
	
		.items {
			width: 98%;
			margin: tovmin(10) auto;
			padding-bottom: 0rpx;
			position: absolute;
			top: tovmin(120);
	
	
			.toptr {}
		}
	
		.radio {
			// background-color: red;
			// margin-left: 10rpx;
			width: 20%;
	
		}
	
		.radio::v-deep .u-dropdown__content__mask {
			background: none;
		}
	
		.query {
			font-size: tovmin(24);
			background-color: #169BD5;
			width: 17%;
			border-radius: tovmin(20);
			height: tovmin(65);
			line-height: tovmin(65);
			text-align: center;
			color: #Ffffff;
			position: absolute;
			top: tovmin(30);
			left: 60%;
		}
	
		.top {
			height: 10%;
			position: relative;
			left: tovmin(170);
			top: tovmin(-100);
		}
		.statistics{
			width: 100%;
			color: #169BD5;
			position: absolute;
			left: 4%;
		}
	
		.inputs {
			box-shadow: tovmin(0) tovmin(9) tovmin(31) tovmin(9) rgba(0, 0, 0, 0.03);
			border: 1px solid #f0f0f0;
			width: 52%;
			height: tovmin(65);
			margin: tovmin(30) 0 tovmin(10) 5%;
			// transform: translateX(-50%);
			border-radius: tovmin(20);
			background-color: #Ffffff;
			z-index: 999;
			float: left;
			position: relative;
	
			.input {
				margin: 0 auto;
				position: absolute;
				height: tovmin(62);
				left: 15%;
				width: 80%;
				font-size: tovmin(26);
				color: #000000;
			}
	
			.icon {
				background: url(@/static/sousuo.png) no-repeat;
				width: tovmin(30);
				height: tovmin(28);
				background-size: cover;
				position: absolute;
				top: 50%;
				transform: translateY(-50%);
				left: 3%;
			}
		}
	}

</style>