<template>
<view  :style="'padding-bottom:' + bottom ">
  	  <view class='zhanline'></view>
	  <!-- 第一页 -->
	  <!-- <uni-data-picker  :localdata="cdycydataTree" :map="sscymap" v-model="cdycidx" popup-title="请选择班级" @change="onchange" @nodeclick="onnodeclick"></uni-data-picker> -->
		<view v-show="type==1" >
			<uni-forms class='inform'  ref="firstform" :rules="firstrules" :modelValue="datainfo">
				<!-- <view class="info_tit">基本信息</view> -->
				<uni-forms-item name="isHs" style='margin-bottom: 0;'>
				 <view class="infolist">
				  	<view class="f16 fw c34 flex0 pr pl12">徽商项目</view>
					<picker  range-key='label' :value="hsindex" :range="hslist" class="infolist_a" @change='bindDateChangea'>
						<view :class="datainfo.isHs?'':'f16 co80'">{{datainfo.isHs=='Y'?'是':'否'}}</view>
					</picker>
				  </view>
				</uni-forms-item>
				<uni-forms-item name="xmmc" style='margin-bottom: 0;'>
				 <view class="infolist">
				  	<view class="f16 fw c34 flex0 pr pl12"><text class="cir">*</text>项目名称</view>
				  	<input  placeholder="请输入项目名称" v-model="datainfo.xmmc"  class="f16  c34 flex1 txr"/>
				  </view>
				</uni-forms-item>
				<uni-forms-item name="yyzz" style='margin-bottom: 0;'>
				 <view class="infolist">
				  	<view class="f16 fw c34 flex0 pr pl12"><text class="cir">*</text>企业营业执照</view>
				  	<input  placeholder="请输入企业营业执照" v-model="datainfo.yyzz" class="f16  c34 flex1 txr"/>
				  </view>
				</uni-forms-item>
				<uni-forms-item name="pzwh" style='margin-bottom: 0;'>
				 <view class="infolist">
				  	<view class="f16 fw c34 flex0 pr pl12"><text class="cir">*</text>批准文号</view>
				  	<input  placeholder="请输入批准文号" v-model="datainfo.pzwh" class="f16  c34 flex1 txr"/>
				  </view>
				</uni-forms-item>
				<uni-forms-item name="szdqName" style='margin-bottom: 0;'>
				 <view class="infolist">
				  	<view class="f16 fw c34 flex0 pr pl12"><text class="cir">*</text>所在地区</view>
					<picker  range-key='dictLabel' :value="szdqindex" :range="location" class="infolist_a" @change='bindDateChangeb'>
						<view :class="datainfo.szdqName?'':'f16 co80'">{{datainfo.szdqName||"请选择所在地区"}}</view>
					</picker>
				  </view>
				</uni-forms-item>
				<uni-forms-item name="sscy" style='margin-bottom: 0;'>
				 <view class="infolist" @click="getSscyFn">
				  	<view class="f16 fw c34 flex0 pr pl12"><text class="cir">*</text>所属产业</view>
					<view class="f16 txr flex1 ml8" v-if='datainfo.xxcy' >
						<view class="txr">
							<block  v-if="datainfo.sscy">{{sscyresult||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 v-else class="f16 co80 txr flex1 over ml8">
						请选择所属产业
					</view>
					
					
				  </view>
				</uni-forms-item>
				<uni-forms-item name="tzfs" style='margin-bottom: 0;'>
				 <view class="infolist">
				  	<view class="f16 fw c34 flex0 pr pl12"><text class="cir">*</text>投资方式</view>
					<picker  range-key='dictLabel' :value="tzfsindex" :range="tzfslist" class="infolist_a" @change='bindDateChangec'>
						<view :class="datainfo.tzfs?'':'f16 co80'">{{datainfo.tzfs||"请选择投资方式"}}</view>
					</picker>
				  </view>
				</uni-forms-item>
				<uni-forms-item name="rkTime" style='margin-bottom: 0;'>
				 <view class="infolist">
				  	<view class="f16 fw c34 flex0 pr pl12">项目入库时间</view>
				  	<picker mode="date" :value="datainfo.rkTime"  class="infolist_a" @change='bindtimeDateChange'>
						<view :class="datainfo.rkTime?'':'f16 co80'">{{datainfo.rkTime||"请选择项目入库时间"}}</view>
				  	</picker>
				  </view>
				</uni-forms-item>
				<uni-forms-item name="kgjsTime" style='margin-bottom: 0;'>
				 <view class="infolist">
				  	<view class="f16 fw c34 flex0 pr pl12">开工建设日期</view>
				  	<picker mode="date" :value="datainfo.kgjsTime"  class="infolist_a" @change='bindtimeDateChangea'>
						<view :class="datainfo.kgjsTime?'':'f16 co80'">{{datainfo.kgjsTime||"请选择开工建设日期"}}</view>
				  	</picker>
				  </view>
				</uni-forms-item>
				<uni-forms-item name="jswcTime" style='margin-bottom: 0;'>
				 <view class="infolist">
				  	<view class="f16 fw c34 flex0 pr pl12">建成完工日期</view>
				  	<picker mode="date" :value="datainfo.jswcTime"  class="infolist_a" @change='bindtimeDateChangeb'>
						<view :class="datainfo.jswcTime?'':'f16 co80'">{{datainfo.jswcTime||"请选择建成完工日期"}}</view>
				  	</picker>
				  </view>
				</uni-forms-item>
				<uni-forms-item name="ztze" style='margin-bottom: 0;'>
				 <view class="infolist">
				  	<view class="f16 fw c34 flex0 pr pl12"><text class="cir">*</text>总投资金额(万元)</view>
				  	<input  placeholder="请输入总投资金额" type="number" v-model="datainfo.ztze" class="f16  c34 flex1 txr"/>
				  </view>
				</uni-forms-item>
				<uni-forms-item name="swzj" style='margin-bottom: 0;'>
				 <view class="infolist">
				  	<view class="f16 fw c34 flex0 pr pl12"><text class="cir">*</text>省外投资总额(万元)</view>
				  	<input  placeholder="请输入省外投资总额" type="number" v-model="datainfo.swzj" class="f16  c34 flex1 txr"/>
				  </view>
				</uni-forms-item>
			</uni-forms>
			<view class="infobtn flexcc cf f16 f500" @click="getNext(1)">下一步</view>
			
			<!-- 弹框 -->
			<view class="bgbox" @click="getClose" v-if="addcyflag"></view>
			<!--  -->
			<view class="fixedbox" v-if="addcyflag">
				<image :src="closeimg" class="choseimg" @click="getClose"></image>
				<view class="top">所属产业</view>
				<view class="boxs">
					<!-- 所属产业 -->
					<uni-forms ref="cyform" :rules="cyrules" :modelValue="datainfo" >
						 <uni-forms-item name="sscy" style='margin-bottom:10rpx;'>
						  <view class="infolist" @click="getSscytreeFn">
							  <!--  -->
						   	<view class="f16 fw c34 flex0 pr pl12"><text class="cir">*</text>第一产业</view>
							<!-- <uni-data-picker placeholder="请选择第一产业" popup-title="请选择第一产业" :localdata="cdycydataTree" v-model="sscyindex" :map="sscymap">
							</uni-data-picker> -->
							<!-- @change="onchange" @nodeclick="onnodeclick" @popupopened="onpopupopened" @popupclosed="onpopupclosed" -->
							
						 	<!-- <picker  range-key='dictLabel' :value="sscyindex" :range="xxcylist" class="infolist_a" @change='bindDateChanged'>
						 		<view :class="datainfo.sscy?'':'f16 co80'">{{datainfo.sscy||"请选择第一产业"}}</view>
						 	</picker> -->
							<view class="txr flex1 over f16 ml8" v-if="sscyresult">
								{{sscyresult||getSscyAdr(datainfo.sscy)}}
							</view>
							<view class="txr flex1 over ml8 f16 co80" v-else>请选择第一产业</view>
						</view>
						 </uni-forms-item>
						<uni-forms-item name="xxcy" style='margin-bottom: 10rpx;'>
						 <view class="infolist">
						  	<view class="f16 fw c34 flex0 pr pl12">十大新兴产业</view>
							<picker  range-key='dictLabel' :value="xxcyindex" :range="xxcylist" class="infolist_a" @change='bindDateChangee'>
								<view :class="datainfo.xxcy?'':'f16 co80'">{{datainfo.xxcy||"请选择十大新兴产业"}}</view>
							</picker>
						  </view>
						</uni-forms-item>
						<uni-forms-item name="zdcy" style='margin-bottom: 10rpx;'>
						 <view class="infolist">
						  	<view class="f16 fw c34 flex0 pr pl12">八大主导产业</view>
							<picker  range-key='dictLabel' :value="zdcyindex" :range="zdcylist" class="infolist_a" @change='bindDateChangef'>
								<view :class="datainfo.zdcy?'':'f16 co80'">{{datainfo.zdcy||"请选择八大主导产业"}}</view>
							</picker>
						  </view>
						</uni-forms-item>
					</uni-forms>
					
					<view class="flex">
						<view class="boxcen" :class="isLt?'act':''" @click="isLt=!isLt">
							<image :src="gcheckimg" v-if="isLt"></image>
							<image :src="checknimg" v-else></image>
							<view :class="isLt?'co28':''">龙头企业</view>
						</view>
						<view class="boxcen" :class="isFzzlfdcy?'act':''" @click="isFzzlfdcy=!isFzzlfdcy">
							<image :src="gcheckimg" v-if="isFzzlfdcy"></image>
							<image :src="checknimg" v-else></image>
							<view :class="isFzzlfdcy?'co28':''">非住宅类房地产业</view>
						</view>
					</view>
					<!-- <uni-data-checkbox multiple @change="checkboxChangea" v-model="cyvalue" :localdata="cymorelist" ></uni-data-checkbox> -->
				</view>
				<view class="fixedbtn" @click="proSure">确认</view>
			</view>
		</view>
		<!-- 第二页 -->
		<view v-show="type==2">
			<uni-forms class='inform'  ref="swdwform"   :modelValue="datainfo">
				<!-- <view class="info_tit">项目信息</view> -->
				<view class="infolist_add" @click="getAddswtzdw">
					<image :src="addimg"></image>
					<view>添加省外投资单位</view>
				</view>
				<view v-for="(ite,idx) in swtzdwlist" :key="'swdw-'+idx">
					<uni-forms-item name="" style='margin-bottom: 0;'>
						<view class="infolist">
						 	<view class="f16 fw cofe flex1 pr pl12">省外投资单位{{Number(idx)+1}}</view>
							<view class="delbx" @click="getDelswtzdw(idx)" v-if="idx!=0">
								<image :src="delimg"></image>
							</view>
						</view>
					</uni-forms-item>
					<uni-forms-item name="dwmc" style='margin-bottom: 0;' >
					 <view class="infolist">
					  	<view class="f16 fw c34 flex0 pr pl12"><text class="cir">*</text>单位名称</view>
					  	<input  placeholder="请输入单位名称"  v-model="ite.dwmc"   class="f16  c34 flex1 txr"/>
					  </view>
					</uni-forms-item>
					<uni-forms-item name="zczj" style='margin-bottom: 0;'>
					 <view class="infolist">
					  	<view class="f16 fw c34 flex0 pr pl12">注册资金(万元)</view>
					  	<input  placeholder="请输入注册资金" type="number" v-model="ite.zczj"    class="f16  c34 flex1 txr"/>
					  </view>
					</uni-forms-item>
					<uni-forms-item name="tzje" style='margin-bottom: 0;'>
					 <view class="infolist">
					  	<view class="f16 fw c34 flex0 pr pl12"><text class="cir">*</text>投资金额(万元)</view>
					  	<input  placeholder="请输入投资金额" type="number" v-model="ite.tzje" class="f16  c34 flex1 txr"/>
					  </view>
					</uni-forms-item>
					<uni-forms-item name="province" style='margin-bottom: 0;'>
					 <view class="infolist" @click="getAreaFn(idx)">
					  	<view class="f16 fw c34 flex0 pr pl12"><text class="cir">*</text>所属地区</view>
						<view class="txr flex1 over f16 ml8" v-if="ite.province">
							{{ite.province}}
							<block v-if='ite.city'>/</block>
							{{ite.city}}
						</view>
						<view class="txr flex1 over ml8 f16 co80" v-else>请选择所属地区</view>
						<!-- <view class="txr flex1 over ml8 f16 co80" :class="ite.province?'':' '">{{
							
							
							||"请选择所属地区"}}</view> -->
					  </view>
					</uni-forms-item>
					<uni-forms-item name="dwjj" style='margin-bottom: 0;'>
					 <view class="infolist" style="align-items: flex-start;">
					  	<view class="f16 fw c34 flex0 pr pl12">单位简介</view>
						<uni-easyinput :inputBorder='false' type="textarea"  v-model="ite.dwjj"  placeholder="(请输入单位简介)" placeholderStyle='text-align: right;font-size:32rpx;color:#808080'></uni-easyinput>
					  </view>
					</uni-forms-item>
				</view>
			</uni-forms>
			
			<!-- 到资情况 -->
			<uni-forms class='inform'  ref="zjdwform" :rules="zjdwrules"  :modelValue="datainfo">
				<!-- <view class="info_tit">项目信息</view> -->
				<!-- <view class="infolist_add" @click="getAddzjdw">
					<image :src="addimg"></image>
					<view>添加资金到资情况</view>
				</view> -->
				<view v-for="(ite,idx) in zjdwList" :key="'zjdw-'+idx">
					<uni-forms-item name="" style='margin-bottom: 0;'>
						<view class="infolist">
						 	<view class="f16 fw cofe flex1 pr pl12">资金到位情况</view>
							<!-- <view class="delbx" @click="getDelzjdw(idx)" v-if="idx!=0">
								<image :src="delimg"></image>
							</view> -->
						</view>
					</uni-forms-item>
					<uni-forms-item name="dwmc" style='margin-bottom: 0;'>
					 <view class="infolist">
					  	<view class="f16 fw c34 flex0 pr pl12"><text class="cir">*</text>单位名称</view>
					  	<input  placeholder="请输入单位名称"  v-model="ite.dwmc"   class="f16  c34 flex1 txr"/>
					  </view>
					</uni-forms-item>
					<uni-forms-item name="zzje" style='margin-bottom: 0;'>
					 <view class="infolist">
					  	<view class="f16 fw c34 flex0 pr pl12"><text class="cir">*</text>注资金额(万元)</view>
					  	<input  placeholder="请输入注资金额" type="number" v-model="ite.zzje"  class="f16  c34 flex1 txr"/>
					  </view>
					</uni-forms-item>
					<uni-forms-item name="dwrq" style='margin-bottom: 0;'>
					 <view class="infolist" @click="getTimeFn(idx)">
					  	<view class="f16 fw c34 flex0 pr pl12"><text class="cir">*</text>到位日期</view>
					  	<picker mode="date" :value="ite.dwrq"  class="infolist_a" @change='bindtimeDateChangec'>
							<view :class="ite.dwrq?'':'f16 co80'">{{ite.dwrq||"请选择到位日期"}}</view>
					  	</picker>
					  </view>
					</uni-forms-item>
				</view>
			</uni-forms>
			<view class="infobtn flexcc cf f16 f500" @click="getNext(2)">下一步</view>
			
		</view>	
		<!-- 第三页 -->
		<view v-show="type==3">
			<uni-forms class='inform'  ref="thirdform" :rules="thirdrules" :modelValue="datainfo">
				<!-- <view class="info_tit">首谈信息</view> -->
				<uni-forms-item name="xmnr" style='margin-bottom: 0;'>
				 <view class="infolist">
				  	<view class="f16 fw c34 flex0 pr pl12"><text class="cir">*</text>项目内容</view>
				  	<input  placeholder="请输入项目内容" v-model="datainfo.xmnr"  class="f16  c34 flex1 txr"/>
				  </view>
				</uni-forms-item>
				<uni-forms-item name="czwt" style='margin-bottom: 0;'>
				 <view class="infolist">
				  	<view class="f16 fw c34 flex0 pr pl12">存在问题</view>
				  	<input  placeholder="请输入存在问题" v-model="datainfo.czwt"   class="f16  c34 flex1 txr"/>
				  </view>
				</uni-forms-item>
				<uni-forms-item name="remark" style='margin-bottom: 0;'>
				 <view class="infolist">
				  	<view class="f16 fw c34 flex0 pr pl12">项目备注</view>
				  	<input  placeholder="请输入项目备注" v-model="datainfo.remark"    class="f16  c34 flex1 txr"/>
				  </view>
				</uni-forms-item>
				
				<view class="border"></view>
				<uni-forms-item name="zsyzFjList" style='margin-bottom: 0;'>
				 <view class="infolist">
				  	<view class="f16 fw c34 flex0 pr pl12"><text class="cir">*</text>附件</view>
					<view class="infolist_a co28">
						<!-- 上传附件 -->
						<lsj-upload 
						    ref="lsjUpload"
						    childId="upload1"
						    :width="width"
						    :height="height"
						    :option="option"
						    :size="size"
						    :formats="formats"
						    :debug="debug"
						    :instantly="instantly"
						    @progress=""
							@uploadEnd="onuploadEnd" >
						        <view class="btn" :style="{width: width,height: height}">选择附件</view>
						</lsj-upload>
					</view>
				  </view>
				</uni-forms-item>
				<view class=" cldelistbf"  v-for="(ite,idx) in filelist" :key='idx'>
					<view class="flext f15 c6" @click="getDown(ite.path)">
						<view class="imgl"><image :src="wimg" ></image></view>
						<view>{{ite.fjName}}</view>
					</view>
					<!-- 删除 -->
					<view class="delimg flex0" @click.stop="getDelFj(idx)">
						<image :src="delimg"></image>
					</view>
				</view>
				<view class="infolist_b"><text>*</text>请上传大小不超过<text>100MB</text>格式为<text>doc/xls/ppt/txt/pdf/zip/rar/word</text>的文件</view>
				<view class="infolist_b" style="margin-top: 20rpx;">含项目建议书（项目分析报告或投资计划书）、洽谈现场照片等资料</view>
			</uni-forms>
			<view class="infobtn flexcc cf f16 f500" v-if="checkPermi(['projectV2:skxm:edit','projectV2:skxm:add'])" @click="getNext(3)">提交</view>
			<!-- <third-clue @getNext='getNext' :datainfo='datainfo'></third-clue> -->
		</view>
		<view style="height: 100rpx;"></view>
		
		
		<!-- 所属地区 -->
		<selectMorePicker
					ref="picker" 
					:title="auiPicker.title"
					:layer="auiPicker.layer"
					:titflag='auiPicker.titflag'
					:data="auiPicker.data"
					@callback="pickerCallback"
				></selectMorePicker>
		<!-- 第一产业 -->
		<selectnore-more-picker
			ref="sscypicker"
			:title="sscyauiPicker.title"
			:layer="sscyauiPicker.layer"
			:titflag='sscyauiPicker.titflag'
			:data="sscyauiPicker.data"
			@callback="sscypickerCallback"
		></selectnore-more-picker>
  </view>
  <!-- <uni-easyinput type="textarea" v-model="value" placeholder="请输入内容"></uni-easyinput> -->
</template>

<script>
	import selectMorePicker from "@/components/ba-tree-picker/selectMorePicker.vue"
	import selectnoreMorePicker from "@/components/ba-tree-picker/selectnoreMorePicker.vue"
	import {getarealist,getskxmDetail,getaddskxmFn,getputskxmFn,getskcyListFn} from "@/api/work/addsk.js"
	
  import { getDictionaryFn} from '@/api/work/index.js'
  import {selectDictLabel} from "@/utils/common.js"
  
  import { checkPermi, checkRole } from "@/utils/permission"; // 权限判断函数
  import config from '@/config'
  const baseUrl = config.baseUrl
  import { getToken } from '@/utils/auth'
  export default {
	  components:{
		  selectMorePicker,selectnoreMorePicker
	  },
    data() {
      return {
		   items: [{
		            text: "一年级",
		            value: "1-0",
		            children: [
		              {
		                text: "1.1班",
		                value: "1-1"
		              },
		              {
		                text: "1.2班",
		                value: "1-2"
		              }
		            ]
		          },
		          {
		            text: "二年级",
		            value: "2-0"
		          },
		          {
		            text: "三年级",
		            value: "3-0"
		          }],
		  //附件
		  option: {
                // 上传服务器地址，需要替换为你的接口地址
                url: baseUrl+'/common/upload', // 该地址非真实路径，需替换为你项目自己的接口地址
                // 上传附件的key
                name: 'file',
                // 根据你接口需求自定义请求头,默认不要写content-type,让浏览器自适配
                header: {
                    // 示例参数可删除
                    'Authorization':  'Bearer ' + getToken(),
                },
                // 根据你接口需求自定义body参数
                formData: {
                }
            },
		// 选择文件后是否立即自动上传，true=选择后立即上传
        instantly: true,
        // 必传宽高且宽高应与slot宽高保持一致
        width: '',
        height: '48rpx',
        // 限制允许上传的格式，空串=不限制，默认为空
        formats: 'doc,docx,xls,ppt,txt,pdf,zip,rar,word',
        // 文件上传大小限制
        size: 100,
        // 文件数量限制 默认10
        count: 5,
        // 文件回显列表
        files: new Map(),
        // 微信小程序Map对象for循环不显示，所以转成普通数组，不要问为什么，我也不知道
        wxFiles: [],
        // 是否打印日志
        debug: false,
        filelist:[], 
		
		
		auiPicker: {
			title: '选择地区',
			layer: null,
			titflag:true,
			data: []
		},
		sscyauiPicker: {
			title: '选择所属产业',
			layer: null,
			titflag:true,
			data: []
		},
		selectDate: '',
		defaultPhoneHeight: '', //屏幕默认高度
		nowPhoneHeight: '', //屏幕现在的高度
		bottom:0,
		type:1,
		poptype:0,//弹窗类型 1暂存/消耗 2审核意见 3批示
		pagetype:'add',
		status: 'loading',
		loading:false,
		contentText:{contentrefresh: '加载中',},
		checknimg:require("@/static/images/mine/jnicon.png"),
		gcheckimg:require("@/static/images/mine/jicon.png"),
		isFzzlfdcy:false,
		isLt:false,
		datainfo:{
			"isHs":"N",//是否徽商项目 N:否 Y:是
			"xmmc":"",//项目名称
			"pzwh":"",//批准文号
			"yyzz":"",//企业营业执照
			"szdqId":"",//所在地区id
			"szdqName":"",//所在地区名称
			
			"sscy":"",//所属产业
			"xxcy":"",//新兴产业
			"zdcy":"",//主导产业
			"isLt":"",//是否龙头企业
			"isFzzlfdcy":"",//是否非住宅类房地产业
			
			"tzfs":"",//投资方式
			"rkTime":"",//项目入库时间
			"kgjsTime":"",//开工建设日期
			"jswcTime":"",//建设完成日期
			"ztze":"",//总投资额(万元)
			"swzj":"",//省外资金(万元)
			
			"xmnr":"",//项目内容
			"czwt":"",//存在问题
			"remark":"",//项目备注
			
			"zsyzSkSwtzdwList":'',//省外投资单位
			
			
			"zsyzSkDzjeList":'',//到资金额
			
			
			"zsyzFjList":"",//附件集合
		},
		// 十大产业
		// cyinfo:{
		// 	"sscy":"",//所属产业
		// 	"xxcy":"",//新兴产业
		// 	"zdcy":"",//主导产业
		// 	"isLt":"",//是否龙头企业
		// 	"isFzzlfdcy":"",//是否非住宅类房地产业
		// },
		addimg:require("@/static/images/mine/add.png"),
		delimg:require("@/static/images/mine/del.png"),
		checknimg:require("@/static/images/mine/jnicon.png"),
		gcheckimg:require("@/static/images/mine/jicon.png"),
		closeimg:require('@/static/images/close.png'),
		wimg:require('@/static/images/index/wicon.png'),
		downimg:require('@/static/images/index/down.png'),
		firstrules: {
		  xmmc: {rules: [{required: true,errorMessage: '请输入项目名称'}]},
		  yyzz: {rules: [{required: true,errorMessage: '请输入企业营业执照'}]},
		  pzwh: {rules: [{required: true,errorMessage: '请输入批准文号' } ]},
		  szdqName: {rules: [{required: true,errorMessage: '请选择所属产业'} ]},
		  // sscy: {rules: [{required: true,errorMessage: '请选择所在地区'} ]},
		  tzfs: {rules: [{required: true,errorMessage: '请选择投资方式'} ]},
		  ztze: {rules: [{required: true,errorMessage: '请输入总投资金额'}]},
		  swzj: {rules: [{required: true,errorMessage: '请输入省外投资总额' } ]},
		},
		cyrules:{
			sscy: {rules: [{required: true,errorMessage: '请选择第一产业'}]},
		},
		// 省外投资单位
		swdwrules: {
		  dwmc: {rules: [{required: true,errorMessage: '请输入单位名称'}]},
		  tzje: {rules: [{required: true,errorMessage: '请输入投资金额'}]},
		  province: {rules: [{required: true,errorMessage: '请选择所属地区'} ]},
		},
		//到资情况
		zjdwrules: {
		  dwmc: {rules: [{required: true,errorMessage: '请输入单位名称'}]},
		  zzje: {rules: [{required: true,errorMessage: '请输入注资金额'}]},
		  dwrq: {rules: [{required: true,errorMessage: '请选择到位日期'} ]},
		},
		thirdrules: {
		  xmnr: {rules: [{required: true,errorMessage: '请输入项目内容'}]},
		  zsyzFjList: {rules: [{required: true,errorMessage: '请上传附件'}]},
		},
		addcyflag:false,
		cyvalue:[],
		cymorelist: [{"value": 1,"text": "龙头企业"},{"value": 2,"text": "非住宅类房地产业"}],
		// sfhsxm:'否',
		hsindex:1,//徽商项目
		szdqindex:0,//所在地区
		tzfsindex:0,//投资方式
		sscyindex:0,//第一产业
		xxcyindex:0,//新兴产业
		zdcyindex:0,//主导产业
		hslist:[{label:'是',id:'Y'},{label:'否',id:'N'},],//徽商
		location:[],//所在地区
		tzfslist:[],//投资方式
		sscylist:[],//第一产业
		xxcylist:[],//新兴产业
		zdcylist:[],//主导产业
		
		swtzdwlist:[
			{
				"dwmc":'',//单位名称
				"zczj":"",//注册资金
				"tzje":"",//投资金额
				"province":"",//省
				"provinceId":"",//省_id
				"city":"",//市
				"cityId":"",//	市id
				"dwjj":"",//	单位简介
			}
		],//省外投资单位
		areaidx:0,//省市选择第几个
		zjidx:0,
		zjdwList:[{
			"dwmc":'',//单位名称
			"zzje":'',//注资金额
			"dwrq":'',//到位日期
		}],//到资金额
		
		
		currentdate:'',//当前日期
		// sfwlhxxxm:'',
		firstform:{},
		cyform:{},//所属产业
		swdwform:{},//省外投资单位
		zjdwform:{},//到资情况
		thirdform:{},
		id:'',
		cdycydataTree:[],//第一产业数组
		sscyresult:'',
		sscymap:{text:'deptName',value:'skcyId'},
		sscyindex:'',
		cdycidx:0,
		
		}
    },
	onLoad(e) {
		var that=this;
		this.currentdate = this.getNowFormatDate();
		var newObj={}
		if(e.data){
			 newObj=JSON.parse(decodeURIComponent(e.data))
		}
		this.pagetype=newObj.pagetype||'add';
		this.getinvestmentarea()
		this.getskcyListFn();
		// 获取省市
		this.getArea()
		if(this.pagetype=='update'){
			// this.datainfo.xmId=newObj.xmId;
			// this.datainfo.xmbh=newObj.xmbh;
			// this.datainfo.xmmc=newObj.xmmc;
			this.getDataFn(newObj.id)
		}else{
			this.datainfo.rkTime=this.currentdate
		}
		
		// #ifdef APP
		uni.onKeyboardHeightChange(res=> { //监听键盘高度变化
		    const res_keyboard = uni.getSystemInfoSync();
		    let key_height = res.height - (res_keyboard.screenHeight - res_keyboard.windowHeight)
		    // let key_height = res.height - (res_keyboard.screenHeight - res_keyboard.windowHeight + res_keyboard.safeAreaInsets.bottom)
		     this.bottom = `${ key_height>0 ? key_height : 0}px`; 
		})
		// #endif
		
	},
	onHide() {
		// #ifdef APP-PLUS
		uni.offKeyboardHeightChange();  // 取消监听键盘高度变化事件，避免内存消耗
		// #endif
	    
	},
    methods: {
		checkPermi, checkRole,
		 onchange(e) {
		        const value = e.detail.value
		      },
		      onnodeclick(node) {
		      },
		getArea(){
			getarealist(0).then(res=>{
				this.auiPicker.data = res.data
			})
		},
		getAreaFn(idx){
			var aridx=1;
			if(idx==this.areaidx){
				aridx=0
			}
			this.areaidx=idx;
			this.$refs.picker.open(aridx).then(function() {
			
			});
		},
		//picker多级联动回调
		pickerCallback(e) {
			const that = this;
			var idx=that.areaidx;
			let result = '';
			e.data.forEach(function(item, index) {
				switch (index) {
					case 0:
						that.swtzdwlist[idx].provinceId = e.data[0].areaid;
						that.swtzdwlist[idx].province = e.data[0].name;
						break;
					case 1:
						that.swtzdwlist[idx].cityId = e.data[1].areaid;
						that.swtzdwlist[idx].city = e.data[1].name;
						break;
					default:
						break;
				}
			});
			// console.log(e)
		},
		getAddswtzdw(){
			var obj ={
				"dwmc":'',//单位名称
				"zczj":"",//注册资金
				"tzje":"",//投资金额
				"province":"",//省
				"provinceId":"",//省_id
				"city":"",//市
				"cityId":"",//	市id
				"dwjj":"",//	单位简介
			}
			this.swtzdwlist.push(obj)
		},
		getDelswtzdw(idx){
			var that = this;
			uni.showModal({
				title: '提示',
				content: "是否确认删除",
				success: function(res) {
					if (res.confirm) {
						that.swtzdwlist.splice(idx, 1)
					} else if (res.cancel) {
					}
				}
			});
		},
		getAddzjdw(){
			var obj = {
			"dwmc":'',//单位名称
			"zzje":'',//注资金额
			"dwrq":'',//到位日期
		}
			this.zjdwList.push(obj)
		},
		getDelzjdw(idx){
			var that = this;
			uni.showModal({
				title: '提示',
				content: "是否确认删除",
				success: function(res) {
					if (res.confirm) {
						that.zjdwList.splice(idx, 1)
					} else if (res.cancel) {
					}
				}
			});
		},
		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;
				}
			})
			this.sscyresult=actions.join('');
			return actions.join('');
		},
		// 省库详情
		getDataFn(id){
			getskxmDetail(id).then(res=>{
				var that=this;
				if(res.code==200){
					this.datainfo=res.data;
					// 徽商
					// this.sfhsxm=this.datainfo.isHs=='Y'?'是':'否';
					this.hsindex=this.datainfo.isHs=='Y'?0:1;
					this.isLt=this.datainfo.isLt=='Y'?true:false;
					this.isFzzlfdcy=this.datainfo.isFzzlfdcy=='Y'?true:false;
					// 所在地区
					for(var i=0;i<that.location.length;i++){
						if(that.location[i].dictLabel==this.datainfo.szdqName){
							this.szdqindex=Number(i)
							break;
						}
					}
					this.sscyresult=that.getSscyAdr(this.datainfo.sscy)
					// 第一产业
					// for(var i=0;i<that.cdycydataTree.length;i++){
					// 	if(that.cdycydataTree[i].skcyId==this.datainfo.sscy){
					// 		this.sscyresult=that.cdycydataTree[i].deptName
					// 		break;
					// 	}
					// }
					// 新兴产业
					for(var i=0;i<that.xxcylist.length;i++){
						if(that.xxcylist[i].dictLabel==this.datainfo.xxcy){
							this.xxcyindex=Number(i)
							break;
						}
					}
					// 主导产业
					for(var i=0;i<that.zdcylist.length;i++){
						if(that.zdcylist[i].dictLabel==this.datainfo.zdcy){
							this.zdcyindex=Number(i)
							break;
						}
					}
					// 投资方式
					for(var i=0;i<that.tzfslist.length;i++){
						if(that.tzfslist[i].dictLabel==this.datainfo.tzfs){
							this.tzfsindex=Number(i)
							break;
						}
					}
					
					if(res.data.zsyzFjList&&res.data.zsyzFjList.length){
						this.filelist=JSON.parse(JSON.stringify(res.data.zsyzFjList))
					}
					if(res.data.zsyzSkSwtzdwList&&res.data.zsyzSkSwtzdwList.length){
						this.swtzdwlist=JSON.parse(JSON.stringify(res.data.zsyzSkSwtzdwList))
					}
					if(res.data.zsyzSkDzjeList&&res.data.zsyzSkDzjeList.length){
						this.zjdwList=JSON.parse(JSON.stringify(res.data.zsyzSkDzjeList))
					}
					// sfwlhxxxm
				}else{
					this.$toast(res.msg)
				}
			})
		},
		getNowFormatDate(){
			let date = new Date();
			let y = date.getFullYear();
			let m = date.getMonth() + 1;
			m = m < 10 ? "0" + m : m;
			let d = date.getDate();
			d = d < 10 ? "0" + d : d;
			const timeday = y + "-" + m + "-" + d;
			return timeday;
		},
		init(){
			
		},
		// 潜山市重点工程
		// 招商引资 
		getSscytreeFn(){
			this.$refs.sscypicker.open(0).then(function() {
			
			});
		},
		getskcyListFn(){
			getskcyListFn().then(res=>{
				// 循环赋值
				this.cdycydataTree=res.data;
				// this.cdycydataTree=this.toTree2(res.data);
				this.sscyauiPicker.data=this.toTree2(res.data)
			})
		},
		sscypickerCallback(e){
			const that = this;
			var newArr=e.data;
			var len=Number(newArr.length)-1
			this.datainfo.sscy=newArr[len].skcyId;
			this.sscyresult=newArr[len].deptName;
		},
		toTree2(arr){
			// 先copy一份数据
			let newA = JSON.parse(JSON.stringify(arr));
			let data = newA.filter(item => {
				item.children = newA.filter(e => {
				    return item.skcyId === e.parentId
				  })
				  return !item.parentId
				})
								
				return data
		},
		// 字典值
		getinvestmentarea(){
			// 所属地区
			getDictionaryFn('location_fgw').then(res=>{
				if(res.code==200){
					this.location = res.data.map(v => {
						return {
							dictLabel: v.dictLabel,
							dictValue: Number(v.dictValue)
						}
					})
				}
			})
			// 投资方式
			getDictionaryFn('investment_method').then(res=>{
				if(res.code==200){
					this.tzfslist = res.data.map(v => {
						return {
							dictLabel: v.dictLabel,
							dictValue: Number(v.dictValue)
						}
					})
				}
			})
			// 十大新兴产业
			getDictionaryFn('emerging_industries').then(res=>{
				if(res.code==200){
					this.xxcylist = res.data.map(v => {
						return {
							dictLabel: v.dictLabel,
							dictValue: Number(v.dictValue)
						}
					})
				}
			})
			// 八大主导产业
			getDictionaryFn('prime_industry').then(res=>{
				if(res.code==200){
					this.zdcylist = res.data.map(v => {
						return {
							dictLabel: v.dictLabel,
							dictValue: Number(v.dictValue)
						}
					})
				}
			})
			// 第一产业
			// getskcyListFn().then(res=>{
			// 	console.log(res,85)
			// })
		},
		
		// 数组验证
		 validateArray(array) {
		  let isValid = true;
		  array.forEach((item) => {
		    if (!item.value) {
		      isValid = false;
		    }
		  });
		  return isValid;
		},
		getNext(idx){
			var that=this;
			if(idx==1){
				// 第一页
				this.$refs.firstform.validate().then(res => {
					
					that.type=2
				})
			}else if(idx==2){
				// 判断省外投资  资金到位是否有值
				var swtzdwlist=that.swtzdwlist;
				for(var i =0;i<swtzdwlist.length;i++){
					var str='省外投资'+(Number(i)+1)
					var nstr=''
					if(!swtzdwlist[i].dwmc){
						nstr="请输入"+str+":单位名称"
						that.$toast(nstr)	
						return
					}
					if(!swtzdwlist[i].tzje){
						nstr="请输入"+str+":投资金额"
						that.$toast(nstr)	
						return
					}
					if(!swtzdwlist[i].province){
						nstr="请选择"+str+":所属地区"
						that.$toast(nstr)	
						return
					}	
				}
				var zjdwList=that.zjdwList;
				for(var i =0;i<zjdwList.length;i++){
					var str='资金到位'
					var nstr='';
					if(!zjdwList[i].dwmc){
						nstr="请输入"+str+":单位名称"
						that.$toast(nstr)	
						return
					}
					if(!zjdwList[i].zzje){
						nstr="请输入"+str+":注资金额"
						that.$toast(nstr)	
						return
					}
					if(!zjdwList[i].dwrq){
						nstr="请选择"+str+":到位日期"
						that.$toast(nstr)	
						return
					}	
				}
				that.datainfo.zsyzSkSwtzdwList=JSON.parse(JSON.stringify(swtzdwlist))
				that.datainfo.zsyzSkDzjeList=JSON.parse(JSON.stringify(zjdwList))
				that.type=3
				// for(var i=0;i<swtzdwlist.length;i++)
				// this.$refs.swdwrules.validate().then(res => {
				// 	// this.type=3
				// })
				// this.$refs.twoform.validate().then(res => {
				// 	this.type=3
				// })
			}else{
				this.datainfo.zsyzFjList=JSON.parse(JSON.stringify(this.filelist));
				this.$refs.thirdform.validate().then(res => {
					var params=this.datainfo;
					if(this.pagetype=='add'){
						getaddskxmFn(params).then(res=>{
							if(res.code==200){
								this.$toast('新增省库成功')	
								setTimeout(function() {
									uni.$emit('refreshdatalistsk');
									uni.navigateBack({delta: 1});
								},1500);
							}else{
								this.$toast(res.msg)
							}
							
						})
					}else{
						getputskxmFn(params).then(res=>{
							if(res.code==200){
								this.$toast('修改省库成功')	
								setTimeout(function() {
									uni.$emit('refreshdata');
									uni.navigateBack({delta: 1});
								},1500);
							}else{
								this.$toast(res.msg)
							}
							
						})
					}
					
				})
			}
		},
		// 第二步骤
		getSscyFn(){
			this.addcyflag=true
		},
		// 徽商
		bindDateChangea(e) {
			var val=e.detail.value;
			this.datainfo.isHs=this.hslist[val].id;
		},
		// 所在地区location
		bindDateChangeb(e) {
			var val=e.detail.value;
			this.datainfo.szdqName=this.location[val].dictLabel
			this.datainfo.szdqId=this.location[val].dictValue
		},
		// 投资方式
		bindDateChangec(e) {
			var val=e.detail.value;
			this.datainfo.tzfs=this.tzfslist[val].dictLabel;
			// this.datainfo.tzfs=this.tzfslist[val].dictValue
		},
		// 第一产业
		bindDateChanged(e) {
			var val=e.detail.value;
			this.datainfo.sscy=this.xxcylist[val].dictLabel;
		},
		// 十大新兴产业
		bindDateChangee(e) {
			var val=e.detail.value;
			this.datainfo.xxcy=this.xxcylist[val].dictLabel;
			// this.datainfo.xxcy=this.xxcylist[val].dictValue
		},
		// 八大主导产业
		bindDateChangef(e) {
			var val=e.detail.value;
			this.datainfo.zdcy=this.zdcylist[val].dictLabel;
			// this.datainfo.zdcy=this.zdcylist[val].dictValue
		},
		// 项目入库时间
		bindtimeDateChange(e){
			this.datainfo.rkTime = e.detail.value
		},
		// 开工建设日期
		bindtimeDateChangea(e){
			this.datainfo.kgjsTime = e.detail.value
		},
		// 建成完工日期
		bindtimeDateChangeb(e){
			this.datainfo.jswcTime = e.detail.value
		},
		getTimeFn(idx){
			this.zjidx=idx;
		},
		// 到位日期(多个)
		bindtimeDateChangec(e){
			var idx=this.zjidx
			this.zjdwList[idx].dwrq = e.detail.value
		},
		proSure(){
			var that=this;
			this.$refs.cyform.validate().then(res => {
				if(that.isLt){
					that.datainfo.isLt='Y'
				}else{
					that.datainfo.isLt='N'
				}
				if(that.isFzzlfdcy){
					that.datainfo.isFzzlfdcy='Y'
				}else{
					that.datainfo.isFzzlfdcy='N'
				}
				this.addcyflag=false;
			})
			
			
		},
		checkboxChangea(e){
			// var newArr=e.detail.data;
			// var newArrs=[]
			// newArr.forEach((ite,idx)=>{
			// 	if(ite.value==)
			// 	newArrs[idx]=ite.dictLabel
			// })
			// this.projectchose=newArrs
		},
		getClose(){
			this.addcyflag=false;
		},
		getAdddzFn(){
			
		},
		// 某文件上传结束回调(成功失败都回调)
		onuploadEnd(item) {
			var newobj={}
			var responseText=JSON.parse(item.responseText)
			newobj.fjName=responseText.originalFilename;
			newobj.path=responseText.fileName;
			this.filelist.push(newobj)
			this.datainfo.zsyzFjList=JSON.parse(JSON.stringify(this.filelist))
		},
		getDelFj(idx){
			this.filelist.splice(idx,1)
			this.datainfo.zsyzFjList=JSON.parse(JSON.stringify(this.filelist))
		},
		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) {
					     }
					   });
				},
				fail(res) {uni.hideLoading()}
			})
		},
		
    }
  }
</script>

<style lang="scss">
 page {
    background-color: #ffffff;
  }

.inform{padding-top: 30rpx;}
  .infolist{padding: 30rpx 32rpx 30rpx 24rpx;position: relative;display: flex;align-items: center;
	.cir{position: absolute;font-size: 36rpx;font-weight: bold;color: #FE5706;left: 0rpx;}
	
  }
  .delimg{width: 40rpx;height:40rpx;margin-left: 16rpx;display: flex;align-items: center;justify-content: center;
  	image{width: 30rpx;height: 30rpx;}
  }
  .infobtn{width: 100%;height: 88rpx;background: #FA5F03;line-height: 88rpx;position: fixed;left: 0;right: 0;bottom: 0;z-index: 3;}
  .input_ye image{width: 34rpx;height: 18rpx;}
.info_tit{font-size: 32rpx;color: #FE5706;padding: 30rpx 26rpx;font-weight: bold;}
.infolist_a{height: 44rpx;flex: 1;text-align: right;font-size: 32rpx;color: #343434;}
.infolist_add{font-size: 28rpx;color: #41C942;padding-right: 30rpx;display: flex;align-items: center;justify-content: flex-end;
	image{width: 30rpx;height: 30rpx;margin-right: 20rpx;}
}

// // 弹窗
.fixedbox{position: fixed;left:56rpx;right: 56rpx;background: #fff;border-radius: 10rpx;min-height: 468rpx;top: 50%;transform: translateY(-60%);z-index: 20;padding: 48rpx 36rpx 68rpx;max-height: calc(100vh - 200rpx);overflow: auto;box-sizing: border-box;
.infolist{padding:24rpx 0 24rpx 0;}
.choseimg{width: 34rpx;height: 34rpx;position: absolute;left: 36rpx;top: 54rpx;z-index: 22;}
.chebox{position: absolute;right: 36rpx;top:54rpx;display: flex;align-items: center;
	image{width: 30rpx;height: 32rpx;margin-right: 12rpx;}
	view{font-size: 32rpx;font-weight: 500;color: #F13800;;}
}
.top{position: relative;text-align: center;font-size: 32rpx;font-weight: bold;color: #343434;}
.boxs{padding: 60rpx 0;
	.box{display: flex;align-items: center;min-height:100rpx;}
	.boxcen{flex:1;display: flex;align-items: flex-start;margin-right: 
	10rpx;
		&.act{
			view{color: #FF6400;}
		}
		image{width: 32rpx;height: 32rpx;margin-right: 20rpx;flex: 0 0 auto;margin-top: 4rpx;}
		view{font-size: 32rpx;font-weight: 500;
color: #666666;}
	}
}
.fixedbtn{width:100%;height: 80rpx;background: #FF6400;
border-radius: 10rpx;display: flex;align-items: center;justify-content: center;font-size: 32rpx;font-weight: bold;color: #FFFFFF;
	&.btn1{background-color: #20ACCF;margin-bottom: 36rpx;}
	}
}
 .inform /deep/ .uni-forms-item__error{margin-top: -30rpx;margin-left: 24rpx;}
 .fixedbox /deep/ .uni-forms-item__error{margin-top: -30rpx;margin-left: 24rpx;}
 
 
 .fixedbox   /deep/ .uni-data-checklist .checklist-group .checklist-box{margin: 10rpx 0;padding: 4rpx 0;width: 50%;box-sizing: border-box;}
 .fixedbox   /deep/ .uni-data-checklist .checklist-group .checklist-box .checklist-text{color: #343434;font-size: 30rpx;}
 // .fixedbox   /deep/ .uni-data-checklist .checklist-group .checklist-box .checkbox__inner{margin-right: 40rpx;}
 .fixedbox    /deep/ .uni-data-checklist .checklist-group .checklist-box.is--default.is-checked .checkbox__inner{border-color: #FF440B; background-color: #FF440B;}
 .fixedbox   /deep/ .uni-data-checklist .checklist-group .checklist-box.is--default.is-checked .checklist-text{color: #343434;}
  .inform .pl12{margin-right: 10rpx;}
  .fixedbox .pl12{margin-right: 10rpx;}
  
  .inform /deep/ .uni-easyinput__content-textarea{min-height: 200rpx;}
  
  
  
// 新的
.delbx{width:44rpx;height: 44rpx;display: flex;align-items: center;justify-content: center;flex:0 0 auto;
	image{width: 30rpx;height: 30rpx;}

}
// .boxcen{flex:1;
// 		&.act{
// 			view{color: #FF6400;}
// 		}
// 		image{width: 32rpx;height: 32rpx;margin-right: 20rpx;margin-top: 4rpx;}
// 		view{font-size: 32rpx;font-weight: 500;
// color: #666666;}
// 	}
	
</style>
