<template>
	<view class="clued">
		<view class="pfixed">
			<uni-nav-bar  left-icon="left" fixed="true" :border='border'  statusBar='true'  title="省库详情" rightWidth='180rpx' @clickRight="clickRight" @clickLeft='getBack'>
				<block slot="right">
					<view class="min_top" v-if="checkPermi(['projectV2:dzje:list','projectV2:skxm:remove'])">
						<image :src="moreimg"></image>
					</view>
				</block>
			</uni-nav-bar>
			<block >
				<view class="clued_tong btn flexcc" v-if="datainfo.isSh==2">审核已通过</view>
				<view class="clued_tong btn1 flexcc" v-if="datainfo.isSh==3">审核未通过</view>
			</block>
		</view>
		<!-- 站位的 -->
		<uni-nav-bar  left-icon="left" :border='border'   statusBar='true' />
		<view class="zhanline"></view>
		<!-- 线索详情 -->
		<view >
			<view >
				<!-- 省库申报信息 -->
				<view class="cldelista" style="padding-top:40rpx;">
					<view class="contenta">
						<view class="tit">徽商项目</view>
						<view class="txt">{{datainfo.isHs=='Y'?'是':'否'}}</view>
					</view>
					<view class="contenta">
						<view class="tit">项目名称</view>
						<view class="txt">{{datainfo.xmmc}}</view>
					</view>
					<view class="contenta">
						<view class="tit">统一社会信用代码</view>
						<view class="txt">{{datainfo.yyzz}}</view>
					</view>
					<view class="contenta">
						<view class="tit">批准文号</view>
						<view class="txt">{{datainfo.pzwh}}</view>
					</view>
					<view class="contenta">
						<view class="tit">所在地区</view>
						<view class="txt">{{datainfo.szdqName}}</view>
					</view>
					<view class="contenta" style="align-items: center;">
						<view class="tit flex0">所属产业</view>
						<view class="txt">
							<view class="txr">
								<block  v-if="datainfo.sscy">{{getSscyAdr(datainfo.sscy)}};</block>
								<block  v-if="datainfo.xxcy">{{datainfo.xxcy}};</block>
								<block  v-if="datainfo.zdcy">{{datainfo.zdcy}};</block>
								<block  v-if="datainfo.isLt=='Y'">龙头企业;</block>
								<block  v-if="datainfo.isFzzlfdcy=='Y'">非住宅类房地产业;</block>
							</view>
								
						</view>
					</view>
					<view class="contenta">
						<view class="tit">投资方式</view>
						<view class="txt">{{datainfo.tzfs}}</view>
					</view>
					<view class="contenta">
						<view class="tit">项目入库日期</view>
						<view class="txt">{{datainfo.rkTime}}</view>
					</view>
					<view class="contenta">
						<view class="tit">开工建设日期</view>
						<view class="txt">{{datainfo.kgjsTime}}</view>
					</view>
					<view class="contenta">
						<view class="tit">建成完工日期</view>
						<view class="txt">{{datainfo.jswcTime}}</view>
					</view>
					<view class="contenta">
						<view class="tit">总投资金额(万元)</view>
						<view class="txt">{{datainfo.ztze}}</view>
					</view>
					<view class="contenta">
						<view class="tit">省外投资总额(万元)</view>
						<view class="txt">{{datainfo.swzj}}</view>
					</view>
				</view>
				<uni-collapse  ref="collapse" v-model="value" @change="changeone" >
					<view v-for="(ite,idx) in datainfo.zsyzSkSwtzdwList" :key="'swdw-'+idx">
					<uni-collapse-item title="省外投资单位" class='cldelista'   :border="false" title-border="none">
						<template v-slot:title>
							<view class="flexc contentt">
								<view class="flex0 f16 fw cofe">省外投资单位{{Number(idx)+1}}</view>
								<!-- <view  class="flex1 cldelistz" :class="value[0]==0?'act':''">
									<view class="cofe f15">{{value[0]==0?'信息折叠':'信息展开'}}</view>
									<image :src="upimg" ></image>
								</view> -->
							</view>
						</template>
						<view class="content">
							<view class="contenta">
								<view class="tit">单位名称</view>
								<view class="txt">{{ite.dwmc}}</view>
							</view>
							<view class="contenta">
								<view class="tit">注册资金(万元)</view>
								<view class="txt">{{ite.zczj}}</view>
							</view>
							<view class="contenta">
								<view class="tit">投资金额(万元)</view>
								<view class="txt">{{ite.tzje}}</view>
							</view>
							<view class="contenta">
								<view class="tit">所属地区</view>
								<view class="txt">{{ite.province}}
								<block v-if="ite.city">
									/{{ite.city}}
								</block>
								
								</view>
							</view>
							<view class="contenta" style="align-items: center;">
								<view class="tit">单位简介</view>
								<view class="txt">{{ite.dwjj}}</view>
							</view>
						</view>
					</uni-collapse-item>
					</view>
					<view v-for="(ite,idx) in datainfo.zsyzSkDzjeList" :key="'dzqk-'+idx">
					<uni-collapse-item title="到位资金情况" class='cldelista'   :border="false" title-border="none">
						<template v-slot:title>
							<view class="flexc contentt">
								<view class="flex0 f16 fw cofe">到位资金情况{{Number(idx)+1}}</view>
								<!-- <view  class="flex1 cldelistz" :class="value[0]==0?'act':''">
									<view class="cofe f15">{{value[0]==0?'信息折叠':'信息展开'}}</view>
									<image :src="upimg" ></image>
								</view> -->
							</view>
						</template>
						<view class="content">
							<view class="contenta">
								<view class="tit">单位名称</view>
								<view class="txt">{{ite.dwmc}}</view>
							</view>
							<view class="contenta">
								<view class="tit">注册资金(万元)</view>
								<view class="txt">{{ite.zzje}}</view>
							</view>
							<view class="contenta">
								<view class="tit">投资金额(万元)</view>
								<view class="txt">{{ite.dwrq}}</view>
							</view>
						</view>
					</uni-collapse-item>
					
					</view>
					<uni-collapse-item title="其他信息" class='cldelista'   :border="false" title-border="none">
						<template v-slot:title>
							<view class="flexc contentt">
								<view class="flex0 f16 fw cofe">其他信息</view>
							</view>
						</template>
						<view class="content">
							<view class="contenta" style="align-items: center;">
								<view class="tit">项目内容</view>
								<view class="txt">{{datainfo.xmnr}}</view>
							</view>
							<view class="contenta" style="align-items: center;">
								<view class="tit">存在问题</view>
								<view class="txt">{{datainfo.czwt}}</view>
							</view>
							<view class="contenta" style="align-items: center;">
								<view class="tit">项目备注</view>
								<view class="txt">{{datainfo.remark}}</view>
							</view>
						</view>
					</uni-collapse-item>
				</uni-collapse>
				<!-- 备注 -->
				<view class='cldelista cldelistb'>
					<!-- <view class="contenta">
						<view class="tit">备注</view>
						<view class="txt">{{datainfo.remark}}</view>
					</view> -->
					<view class="contenta " v-if="datainfo.zsyzFjList">
						<view class="tit">附件</view>
						<view class="txt flexcj cldelistbf mb10" v-for="(ite,idx) in datainfo.zsyzFjList" :key='idx'>
							<view class="flext f16 c6">
								<view class="imgl">
									<image :src="wimg" ></image>
								</view>
								
								<view>{{ite.fjName}}</view>
								</view>
							<view class="flexc f16 co28 flex0" @click="getDown(ite.path)">
								<image :src="downimg" class="imgr"></image>
								预览</view>
						</view>
					</view>
					<!-- <view class="contenta" >
						<view class="tit">附件</view>
						<view class="txt flexcj cldelistbf">
							<view class="flext f16 c6">
								<image :src="wimg" class="imgl"></image>
								<view>线索附件信息.docx</view>
								</view>
							<view class="flexc f16 co28 flex0">
								<image :src="downimg" class="imgr"></image>
								预览</view>
						</view>
					</view> -->
				</view>
				<!-- 按钮 -->
				<!-- v-if="(roles=='manage'||roles=='admin')&&fotbtnflag&&datainfo.isSh==1" -->
				<view class="pfixedb flexc" >
					<view class="cluebtn btn1" v-if="checkPermi(['projectV2:common:sksh'])&&datainfo.isSh==1" @click="getOperate(2)">审核</view>
					<view class="cluebtn btn2" v-if="checkPermi(['projectV2:skxm:edit'])&&datainfo.isSh!=2" @click="getUpdate">修改信息</view>
					<!-- v-if="datainfo.isSh==2" -->
					<view class="cluebtn btn2" v-if="checkPermi(['projectV2:dzje:add'])&&datainfo.isSh==2"  @click="getAdddwzi">添加到位资金</view?>
				</view>
			</view>
		</view>
		
		<!-- 弹窗 -->
		<pop-up :type="type" @getClose='getClose' @getyjSubmit='getyjSubmit'></pop-up>
		<!-- 弹窗 -->
		<view class="bgbox" @click="getClose" v-if="moreflag"></view>
		<view class="more_fixed" v-if="moreflag">
			<view class="more_fixedt">

				<!-- 专班跟进 -->
				<!-- v-if="checkPermi(['projectV2:skxm:remove'])" -->
				<!-- <view  @click="getshprogress">审核进度</view> -->
				<view v-if="checkPermi(['projectV2:skxm:remove'])" @click="getDelFn">删除</view>
				<view v-if="checkPermi(['projectV2:dzje:list'])"  @click="getlookdzje">到位资金情况</view>
				<!-- 查看批示 -->
			</view>
			<view class="more_fixedb" @click="getClose">取消</view>
		</view>
		<skdwzi-pop :iteminfo="dwzjinfo" @proSure="proSure" @getClose="getClose" :addzjdwflag='addzjdwflag'></skdwzi-pop>
	</view>
</template>

<script>
	import tabList from "@/components/toptab/tab.vue"
	import { getToken } from '@/utils/auth' 
	import popUp from "@/components/popup/popup.vue"
	import skdwziPop from "@/components/popup/skdwzjpop.vue"
	import { getskxmDetail,getskxmSh,getadddzjeFn,getskcyListFn,getdelskxmFn} from '@/api/work/addsk.js'
	import { checkPermi, checkRole } from "@/utils/permission"; // 权限判断函数
	import config from '@/config.js';
	const baseUrl = config.baseUrl;
	export default{
		data(){
			return{
				border:false,
				tablist:[{tit:'线索',val:1},{tit:'签约',val:2},{tit:'开工',val:3},{tit:'投产',val:4},],
				active: 0,
				list1: [{title: '线索'}, {title: '签约'}, {title: '开工'}, {title: '投产'}],
				value:[],
				valuetwo:[],
				content: '折叠内容主体，可自定义内容及样式，点击按钮修改内容使高度发生变化。',
				showArrow:false,
				type:0,//弹窗类型 1暂存/消耗 2审核意见 3批示
				upimg:require('@/static/images/index/up.png'),
				wimg:require('@/static/images/index/wicon.png'),
				downimg:require('@/static/images/index/down.png'),
				id:'',
				datainfo:{},
				roles:this.$store.state.user.roles[0],
				fotbtnflag:true,
				deptId:this.$store.state.user.deptId,
				moreimg:require("@/static/images/index/more.png"),
				moreflag:false,
				
				addzjdwflag:false,
				dwzjinfo:{
					"dwmc":'',//单位名称
					"zzje":'',//注资金额
					"dwrq":'',//到位日期
					},
				cdycydataTree:[],
				sscyresult:'',
			}
		},
		components:{
			tabList,popUp,skdwziPop
		},
		onUnload(){
			uni.$off('refreshdata')
		},
		onLoad(e) {
			this.id=e.id;
			uni.$on('refreshdata',(e) => {
				this.addinfotype=-1;
				this.datainfo='';
				this.getDataFn();
				if(e&&e=='dwzj'){
					
				}else{
					uni.$emit('refreshdatalistsk');
				}
				
			})
			this.getskcyListFn();
			this.getDataFn()
		},
		methods:{
			checkPermi, checkRole,
			getskcyListFn(){
				getskcyListFn().then(res=>{
					// 循环赋值
					this.cdycydataTree=res.data
				})
			},
			getSscyAdr(value){
				var actions = [];
				var datas=this.cdycydataTree;
				Object.keys(datas).some((key) => {
					if (datas[key].skcyId == ('' + value)) {
						actions.push(datas[key].deptName);
						return true;
					}
				})
				return actions.join('');
			},
			getDataFn(){
				var that=this;
				getskxmDetail(this.id).then(res=>{
					if(res.code==200){
						this.datainfo=res.data;
						
					}else{
						this.$toast(res.msg)
					}
				})
			},
			// 暂缓
			getOperate(e){
				// 审核
				this.type=Number(e)
			},
			//审核
			getYuShenFn(){
				this.$tab.navigateTo('/pages/work/xminquiry')
			},
			getshprogress(){
				this.moreflag=false;
				// if(checkPermi(['projectV2:shyj:list'])){
				// 	this.$tab.navigateTo('/pages/work/shprogress?id='+this.id)
				// }else{
				// 	return
				// }
			},
			// 资金情况
			getlookdzje(){
				this.moreflag=false;
				var newobj={
					id:this.id,
					isSh:this.datainfo.isSh,
					xmmc:this.datainfo.xmmc
				}
				this.$tab.navigateTo('/pages/work/skproject/dzjelist?data='+encodeURIComponent(JSON.stringify(newobj)))
			},
			getAdddwzi(){
				this.dwzjinfo={
					"dwmc":'',//单位名称
					"zzje":'',//注资金额
					"dwrq":'',//到位日期
				};
				this.addzjdwflag=true
			},
			proSure(data){
				var that=this;
				var params=JSON.parse(JSON.stringify(data))
				params.skId=this.datainfo.id,
				params.xmmc=this.datainfo.xmmc,
				getadddzjeFn(params).then(res=>{
					if(res.code==200){
						that.$toast("添加到位资金成功")
						setTimeout(function(){
							that.addzjdwflag=false;
							that.dwzjinfo={};
							that.getDataFn()
							// 分派可能有两种状态
						},1500)
					}else{
						this.$toast(res.msg)
					}
				})
			},
			getClose(){
				this.type=0;
				this.moreflag=false;
				this.addzjdwflag=false;
			},
			getDelFn(){
				var that=this;
				this.moreflag=false;
				uni.showModal({
					title: '确认删除',
					content: "是否确认删除该条信息",
					cancelText: '取消删除',
					confirmText: '确认删除',
					success: function(res) {
						if (res.confirm) {
							getdelskxmFn(that.id).then(res=>{
								if(res.code==200){
									that.$toast('删除成功');
									setTimeout(function(){
										uni.$emit('refreshdatalistsk');
										uni.navigateBack({delta:1})
									},1500)
									
								}else{
									that.$toast(res.msg);
								}
							})
						} else if (res.cancel) {
							// console.log('用户点击取消');
						}
					}
				});
			},
			getyjSubmit(data){
				var params={};
				var that=this;
				// return
				 var newObj=JSON.parse(JSON.stringify(data))
				
				 if(newObj.shjg==2){
					 params.isSh='2'
				 }else{
					params.isSh='3'
				 }
				 params.shJy=newObj.shyj;
				 params.id=this.datainfo.id;
				getskxmSh(params).then(res=>{
					if(res.code==200){
						that.$toast("审核提交成功")
						setTimeout(function(){
							that.getDataFn()
							that.type=0;
							uni.$emit('refreshdatalistsk');
							that.fotbtnflag=false;
							// 分派可能有两种状态
						},1500)
					}else{
						this.$toast(res.msg)
					}
				})
			},
			radioChange(){
				
			},
			getUpdate(){
				var obj={
					id:this.datainfo.id,
					pagetype:'update'
				}
				this.$tab.navigateTo('/pages/work/skproject/addsk?data='+encodeURIComponent(JSON.stringify(obj)))
			},
			clickRight(){
				if(checkPermi(['projectV2:dzje:list','projectV2:skxm:remove'])){
					this.moreflag=true;
				}
				
				// this.$tab.navigateTo('/pages/work/shprogress')
			},
			getBack(){
				uni.navigateBack({
					delta:1
				})
			},
			changeone(e){
				// console.log(e,9)
			},
			getDown(e){
				var url=baseUrl+e;
				// 提示
				uni.showLoading({
					title: '加载中'
				});
				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 lang="scss" scoped>
.clued{min-height: 100vh;background-color: #fff;box-sizing: border-box;padding-bottom: 100rpx;}
.clued /deep/ 	.uni-nav-bar-right-text{font-size: 34rpx; color: #1FB9F7 !important;font-weight: 500;padding-right: 14rpx;}
.clued /deep/ .uni-steps__row-circle{margin: 0;width: 20rpx;height: 20rpx;}
.clued /deep/ .uni-steps__row-check{margin: 0;}
.clued /deep/ .uni-steps__row-title{font-size: 30rpx;font-weight: 500;color: #A6A6A6;}

.cldetail{padding-top: 70rpx;}
.cldelist{padding: 48rpx 28rpx 36rpx;border-bottom: 2rpx solid #E5E5E5;}
.cldelista{
	padding: 20rpx 28rpx;
	border-top: 2rpx solid #E5E5E5;
	&:first-of-type{border-top: none;}
	.contentt{padding:30rpx 0rpx;
		.cldelistz{display: flex;align-items: center;justify-content: flex-end;
			image{width: 26rpx;height: 20rpx;margin-left: 20rpx;transition: all .5s; }
		}
	}
	// .content{padding: 0rpx 28rpx 40rpx 28rpx;}
	.contenta{padding: 22rpx 0;display: flex;justify-content: space-between;margin-bottom: 20rpx;
		.tit{font-size: 32rpx;font-weight: bold;color: #343434;margin-right: 20rpx;flex: 0 0 auto;}
		.txt{font-size: 32rpx;color: #666666;}
	}
	&.cldelistb{
		.contenta{display: block;margin-top: 0;
			.tit{margin-bottom: 20rpx;}
		}
	}
	.cldelistbf {
		image{margin-right: 18rpx;flex: 0 0 auto;}
		.imgl{width: 40rpx;height: 44rpx;display: flex;align-items: center;justify-content: center;margin-right: 16rpx;
			image{width: 38rpx;height: 30rpx;}
			}
		.imgr{width: 36rpx;height: 32rpx;}
	}
}

// 操作按钮
.cluebtn{
	display: flex;align-items: center;justify-content: center;font-weight: bold;font-size: 32rpx;color: #ffff;height: 100rpx;
	&.btn1{background-color: #1FB9F7;width: 375rpx;flex: 0 0 auto;}
	&.btn2{background-color:#FF6400;flex: 1;}
}


// 审核通过
// .clued_tong{width: 100%;height: 70rpx;background: #C0FFC0;color: #28C529;font-size: 32rpx;font-weight: 500;}

// 审核通过
.clued_tong{width: 100%;height: 70rpx;font-size: 32rpx;font-weight: 500;
&.btn{background: #C0FFC0;color: #28C529;}
&.btn1{background: #ffcaac;color: #ff440b;}
}

// 消息
.min_top{position: relative;width: 44rpx;height: 44rpx;display: flex;align-items: center;justify-content: center;margin-right: 32rpx;
	image{width: 44rpx;height: 34rpx;}
	
}



</style>