<template>
	<view class="evan-form-show">
		<view class="bottom-border">
			<view class="left-border"><text class="mgl10">基本信息</text></view>
		</view>
		<!-- <uni-forms :value="formData" ref="form" validate-trigger="bind" err-show-type="toast">	</uni-forms> -->
		<!-- 企业客户 -->
		<uni-forms v-if="cusType == 2" :value="businessApply" ref="businessApply" validate-trigger="bind" err-show-type="toast">
			<uni-forms-item required name="cusType" :label="fromData[0]?fromData[0].name:'客户类型'">
				<uni-data-checkbox v-model="cusType" :localdata="cusTypeList"></uni-data-checkbox>
			</uni-forms-item>
			<uni-forms-item name="code" required :label="fromData[1]?fromData[1].name:'客户编号'">
				<view class="comBox"  v-if="handle=='new'||handle=='change'">
					<uni-combox :inputBorder="true" v-model="code" @input="clientodeCange($event,'code')" :candidates="clientCode" :placeholder="fromData[1]&&fromData[1].prompt?fromData[1].prompt:'请输入客户编号'"></uni-combox>					
				</view>
				<uni-easyinput disabled  v-if="handle=='watch'||handle=='audit'" type="text" :inputBorder="true" v-model="code" :placeholder="fromData[1]&&fromData[1].prompt?fromData[1].prompt:'客户编号'"></uni-easyinput>
			</uni-forms-item>
			<uni-forms-item class="mgt10" name="name" required :label="fromData[2]&&fromData[2].name?fromData[2].name:'客户名称'">
				<view class="comBox"  v-if="handle=='new'||handle=='change'">
					<uni-combox :inputBorder="true" v-model="name" @input="clientodeCange($event,'name')" :candidates="clientName" :placeholder="fromData[2]&&fromData[2].prompt?fromData[2].prompt:'请输入客户名称'"></uni-combox>					
				</view>
				<uni-easyinput disabled  v-if="handle=='watch'||handle=='audit'" type="text" :inputBorder="true" v-model="name" :placeholder="fromData[2]&&fromData[2].prompt?fromData[2].prompt:'客户名称'"></uni-easyinput>
			</uni-forms-item>
			<uni-forms-item name="socialUnifiedCode" :label="fromData[3]&&fromData[3].name?fromData[3].name:'社会统一代码'">
				<uni-easyinput disabled type="text" :inputBorder="true" v-model="enterpriseForm.socialUnifiedCode" :placeholder="fromData[3]&&fromData[3].prompt?fromData[3].prompt:'系统读取'"></uni-easyinput>
			</uni-forms-item>
			<uni-forms-item name="phone" :label="fromData[4]&&fromData[4].name?fromData[4].name:'联系电话'">
				<uni-easyinput     disabled type="text" :inputBorder="true" v-model="enterpriseForm.phone" :placeholder="fromData[4]&&fromData[4].prompt?fromData[4].prompt:'系统读取'"></uni-easyinput>
			</uni-forms-item>
			<uni-forms-item name="registerTime" :label="fromData[5]&&fromData[5].name?fromData[5].name:'注册时间'">
				<picker disabled class="disabled" mode="date" :value="enterpriseForm.registerTime" @change="bindDateChange">
					<view disabled  class="picker-view flex-between">
						<text>{{enterpriseForm.registerTime ? enterpriseForm.registerTime : '请选择'}}</text>
						<text class="cuIcon-unfold lg text-gray"></text>
					</view>
				</picker>
			</uni-forms-item>
			<uni-forms-item name="registeredCapital" :label="fromData[6]&&fromData[6].name?fromData[6].name:'注册资金(万元)'">
				<uni-easyinput disabled  type="digit" :inputBorder="true" v-model="enterpriseForm.registeredCapital" :placeholder="fromData[6]&&fromData[6].prompt?fromData[6].prompt:'系统读取'"></uni-easyinput>
			</uni-forms-item>
			<uni-forms-item name="empNum" :label="fromData[8]&&fromData[8].name?fromData[8].name:'员工人数'">
				<uni-easyinput disabled  type="number" :inputBorder="true" v-model="enterpriseForm.empNum" :placeholder="fromData[8]&&fromData[8].prompt?fromData[8].prompt:'系统读取'"></uni-easyinput>
			</uni-forms-item>
			<uni-forms-item name="registerAddr" :label="fromData[7]&&fromData[7].name?fromData[7].name:'注册地址'">
				<uni-easyinput  disabled type="text" :inputBorder="true" v-model="enterpriseForm.registerAddr" :placeholder="fromData[7]&&fromData[7].prompt?fromData[7].prompt:'系统读取'"></uni-easyinput>
			</uni-forms-item>
			<uni-forms-item  :label="fromData[9]&&fromData[9].name?fromData[9].name:'经营地址'">
				<uni-easyinput disabled  type="text" :inputBorder="true" v-model="enterpriseForm.businessAddr" :placeholder="fromData[9]&&fromData[9].prompt?fromData[9].prompt:'系统读取'"></uni-easyinput>
			</uni-forms-item>
			<uni-forms-item name="businessType" required :label="fromData[10]&&fromData[10].name?fromData[10].name:'业务类别'">
				<picker v-if="handle=='new'||handle=='change'" :disabled="handle=='watch'" mode="selector" :range="businessType" range-key="key" :value="businessApply.businessType" @change="bindBusinessType">
					<view class="picker-view flex-between">
						<text>{{businessApply.businessType ? businessApply.businessType : '请选择'}}</text>
						<text class="cuIcon-unfold lg text-gray"></text>
					</view>
				</picker>
				<uni-easyinput disabled v-if="handle!='new'&&handle!='change'" type="text" :inputBorder="true" v-model="businessApply.businessType" placeholder="业务类别"></uni-easyinput>
			</uni-forms-item>
			<uni-forms-item name="businessScope" :label="fromData[11]&&fromData[11].name?fromData[11].name:'经营范围'">
				<uni-easyinput disabled  type="textarea" :inputBorder="true" v-model="enterpriseForm.businessScope" :placeholder="fromData[11]&&fromData[11].prompt?fromData[11].prompt:'请输入经营范围'"></uni-easyinput>
			</uni-forms-item>
			<!-- 法人信息 -->
			<view class="bottom-border mab15">
				<view class="left-border"><text class="mgl10">法人信息</text></view>
			</view>
			<uni-forms-item name="legalName" :label="fromData[12]&&fromData[12].name?fromData[12].name:'姓名'">
				<uni-easyinput disabled type="text" :inputBorder="true" v-model="enterpriseForm.legalName" :placeholder="fromData[12]&&fromData[12].prompt?fromData[12].prompt:'系统读取'"></uni-easyinput>
			</uni-forms-item>
			<uni-forms-item disabled name="legalGender" :label="fromData[13]&&fromData[13].name?fromData[13].name:'性别'">
				<uni-data-checkbox :disabled="true" v-model="enterpriseForm.legalGender" :localdata="genderList"></uni-data-checkbox>
			</uni-forms-item>
			<uni-forms-item name="legalIdNumber" :label="fromData[14]&&fromData[14].name?fromData[14].name:'身份证号码'">
				<uni-easyinput disabled type="idcard" :inputBorder="true" v-model="enterpriseForm.legalIdNumber" :placeholder="fromData[14]&&fromData[14].prompt?fromData[14].prompt:'系统读取'"></uni-easyinput>
			</uni-forms-item>
			<uni-forms-item name="legalHukouAddr" :label="fromData[16]&&fromData[16].name?fromData[16].name:'户口所在地'">
				<uni-easyinput disabled type="text" :inputBorder="true" v-model="enterpriseForm.legalHukouAddr" :placeholder="fromData[16]&&fromData[16].prompt?fromData[16].prompt:'系统读取'"></uni-easyinput>
			</uni-forms-item>
			<uni-forms-item name="legalPhone" :label="fromData[15]&&fromData[15].name?fromData[15].name:'联系电话'">
				<uni-easyinput disabled type="text" :inputBorder="true" v-model="enterpriseForm.legalPhone" :placeholder="fromData[15]&&fromData[15].prompt?fromData[15].prompt:'系统读取'"></uni-easyinput>
			</uni-forms-item>
			<uni-forms-item name="legalHomeAddr" :label="fromData[17]&&fromData[17].name?fromData[17].name:'家庭住址'">
				<uni-easyinput disabled type="text" :inputBorder="true" v-model="enterpriseForm.legalHomeAddr" :placeholder="fromData[17]&&fromData[17].prompt?fromData[17].prompt:'系统读取'"></uni-easyinput>
			</uni-forms-item>
			<uni-forms-item name="isExistRelated" required :label="fromData[18]&&fromData[18].name?fromData[18].name:'是否存在关联人'">
				<uni-data-checkbox  v-model="enterpriseForm.isExistRelated" :localdata="isExistList"></uni-data-checkbox>
			</uni-forms-item>
		</uni-forms>
		
		<!-- 展示关联人,传递handle默认false不禁用，传递companyId调用获取关联人接口 -->
		<linkMan v-if="enterpriseForm.isExistRelated==1" :handle="handle!=='new'&&handle!=='change'" :companyId="companyId"></linkMan>

		<view class="bottom-border">
			<view class="left-border"><text class="mgl10">申请贷款相关信息</text></view>
		</view>
		
		<uni-forms :value="enterpriseFrom" ref="form" validate-trigger="bind" err-show-type="toast">
			<uni-forms-item required name="applyAmount" :label="fromData[19]&&fromData[19].name?fromData[19].name:'申请额度(万元)'">
				<uni-easyinput :disabled="handle=='watch'||handle=='audit'" type="digit" :inputBorder="true" v-model="businessApply.applyAmount" :placeholder="fromData[19]&&fromData[19].prompt?fromData[19].prompt:'请输入申请额度'"></uni-easyinput>
			</uni-forms-item>
			<uni-forms-item required name="gender" :label="fromData[20]&&fromData[20].name?fromData[20].name:'申请期限'">
				<picker v-if="handle=='new'||handle=='change'" mode="selector" :range="timelimitDatas" range-key="label" :value="businessApply.applyTime" @change="applyTimeClicked" @cancel="applyTimeCencle">
					<view class="picker-view flex-between">
						<text>{{businessApply.applyTime ? businessApply.applyTime : '请选择'}}</text>
						<text class="cuIcon-unfold lg text-gray"></text>
					</view>
				</picker> 
				<uni-easyinput disabled v-if="handle=='audit'||handle=='watch'" type="text" :inputBorder="true" v-model="businessApply.applyTime" :placeholder="fromData[20]&&fromData[20].prompt?fromData[20].prompt:'申请期限'"></uni-easyinput>
			</uni-forms-item>
			<uni-forms-item name="name" required :label="fromData[21]&&fromData[21].name?fromData[21].name:'贷款银行'">
				<view v-if="handle=='new'||handle=='change'" class="comBox">
					<uni-combox :inputBorder="true" v-model="mainbank" @input="bankgroup($event,'main')" :candidates="banklist" :placeholder="fromData[21]&&fromData[21].prompt?fromData[21].prompt:'请输入银行名称'"></uni-combox>					
				</view>
				<uni-easyinput disabled v-if="handle!='new'&&handle!='change'" type="text" :inputBorder="true" v-model="mainbank" :placeholder="fromData[21]&&fromData[21].prompt?fromData[21].prompt:'银行名称'"></uni-easyinput>
			</uni-forms-item>
			<uni-forms-item name="name" label="分行">
				<uni-easyinput :disabled="handle=='watch'||handle=='audit'" type="text" :inputBorder="true" v-model="elsebank" @input="bankgroup($event,'else')" placeholder="分行名称"></uni-easyinput>
			</uni-forms-item>
			<uni-forms-item name="name" required :label="fromData[22]&&fromData[22].name?fromData[22].name:'贷款用途'">
				<picker v-if="handle=='new'||handle=='change'" mode="selector" :range="applyDatas" range-key="label" :value="businessApply.amountWide" @change="applyClicked">
					<view class="picker-view flex-between">
						<text>{{businessApply.amountWide ? businessApply.amountWide : '请选择'}}</text>
						<text class="cuIcon-unfold lg text-gray"></text>
					</view>
				</picker>
				<uni-easyinput disabled v-if="handle!='new'&&handle!='change'" type="text" :inputBorder="true" v-model="businessApply.amountWide" placeholder="贷款用途"></uni-easyinput>
			</uni-forms-item>
			<uni-forms-item v-if="businessApply.amountWide=='其他'" name="name" label="其他贷款用途">
				<uni-easyinput :disabled="handle=='watch'" type="text" :inputBorder="true" v-model="businessApply.otherAmountWide" placeholder="其他贷款用途"></uni-easyinput>
			</uni-forms-item>
			<uni-forms-item name="enGuaranteeMeasures" required :label="fromData[23]&&fromData[23].name?fromData[23].name:'反担保措施'">
				<uni-data-checkbox multiple mode="list" v-model="businessApply.enGuaranteeMeasures" :localdata="easuresList"></uni-data-checkbox>
				<!-- <view class="more-select" @click="show = true">
				  <text class="" >{{info || "请选择"}}</text>
				</view> -->
			</uni-forms-item>
			<uni-forms-item name="name" label="反担保措施描述">
				<uni-easyinput :disabled="handle!='new'&&handle!='change'" type="textarea" v-model="businessApply.description" :placeholder="fromData[23]&&fromData[23].prompt?fromData[23].prompt:'请输入反担保措施描述'"></uni-easyinput>
			</uni-forms-item>
		</uni-forms>
		
		<view class="bottom-border">
			<view class="left-border"><text class="mgl10">附件</text></view>
		</view>
		
		<view class="cu-bar bg-white">
			<view class="action">
				<text v-if="!fromData[24].ifRequired" class="is-required">*</text>
				<text class="label-color">{{fromData[24]&&fromData[24].name?fromData[24].name:'上传营业执照'}}</text>
			</view>
		</view>
		<upload @upload="($event)=>uploadFile($event,0)" :files="filesArray[0]" :handle="handle=='new'||handle=='change'"></upload>
		<view class="cu-bar bg-white">
			<view class="action">
				<text v-if="!fromData[25].ifRequired" class="is-required">*</text>
				<text class="label-color">{{fromData[25]&&fromData[25].name?fromData[25].name:'上传法定代表人夫妻及企业实际经营者身份证附件'}}</text>
			</view>
		</view>
		<upload @upload="($event)=>uploadFile($event,1)" :files="filesArray[1]" :handle="handle=='new'||handle=='change'"></upload>
		<view class="cu-bar bg-white">
			<view class="action">
				<text v-if="!fromData[26].ifRequired" class="is-required">*</text>
				<text class="label-color">{{fromData[26]&&fromData[26].name?fromData[26].name:'上传法定代表人夫妻户口本、结婚证（离婚证）'}}</text>
			</view>
		</view>
		<upload @upload="($event)=>uploadFile($event,2)" :files="filesArray[2]" :handle="handle=='new'||handle=='change'"></upload>
		<view class="cu-bar bg-white">
			<view class="action">
				<text v-if="!fromData[27].ifRequired" class="is-required">*</text>
				<text class="label-color">{{fromData[27]&&fromData[27].name?fromData[27].name:'上传法定代表人身份证证明'}}</text>
			</view>
		</view>
		<upload @upload="($event)=>uploadFile($event,3)" :files="filesArray[3]" :handle="handle=='new'||handle=='change'"></upload>
		<view class="cu-bar bg-white">
			<view class="action">
				<text v-if="!fromData[28].ifRequired" class="is-required">*</text>
				<text class="label-color">{{fromData[28]&&fromData[28].name?fromData[28].name:'上传公司章程'}}</text>
			</view>
		</view>
		<upload @upload="($event)=>uploadFile($event,4)" :files="filesArray[4]" :handle="handle=='new'||handle=='change'"></upload>
		<view class="cu-bar bg-white">
			<view class="action">
				<text v-if="!fromData[29].ifRequired" class="is-required">*</text>
				<text class="label-color">{{fromData[29]&&fromData[29].name?fromData[29].name:'上传由会计师事务所审计的上一年度及本年度审计报告'}}</text>
			</view>
		</view>
		<upload @upload="($event)=>uploadFile($event,5)" :files="filesArray[5]" :handle="handle=='new'||handle=='change'"></upload>
		<view class="cu-bar bg-white">
			<view class="action">
				<text v-if="!fromData[30].ifRequired" class="is-required">*</text>
				<text class="label-color">{{fromData[30]&&fromData[30].name?fromData[30].name:'上传企业信用报告'}}</text>
			</view>
		</view>
		<upload @upload="($event)=>uploadFile($event,6)" :files="filesArray[6]" :handle="handle=='new'||handle=='change'"></upload>
		<view class="cu-bar bg-white">
			<view class="action">
				<text v-if="!fromData[31].ifRequired" class="is-required">*</text>
				<text class="label-color">{{fromData[31]&&fromData[31].name?fromData[31].name:'上传企业法人夫妇信用报告、实际经营者信用报告'}}</text>
			</view>
		</view>
		<upload @upload="($event)=>uploadFile($event,7)" :files="filesArray[7]" :handle="handle=='new'||handle=='change'"></upload>
		<view class="cu-bar bg-white">
			<view class="action">
				<text v-if="!fromData[32].ifRequired" class="is-required">*</text>
				<text class="label-color">{{fromData[32]&&fromData[32].name?fromData[32].name:'上传征信业务授权书、承诺书'}}</text>
			</view>
		</view>
		<upload @upload="($event)=>uploadFile($event,8)" :files="filesArray[8]" :handle="handle=='new'||handle=='change'"></upload>
		<view class="cu-bar bg-white">
			<view class="action">
				<text v-if="!fromData[33].ifRequired" class="is-required">*</text>
				<text class="label-color">{{fromData[33]&&fromData[33].name?fromData[33].name:'上传增值税纳税报表首表/完税证明'}}</text>
			</view>
		</view>
		<upload @upload="($event)=>uploadFile($event,9)" :files="filesArray[9]" :handle="handle=='new'||handle=='change'"></upload>
		<view class="cu-bar bg-white">
			<view class="action">
				<text v-if="!fromData[34].ifRequired" class="is-required">*</text>
				<text class="label-color">{{fromData[34]&&fromData[34].name?fromData[34].name:'上传股东会会议纪要'}}</text>
			</view>
		</view>
		<upload @upload="($event)=>uploadFile($event,10)" :files="filesArray[10]" :handle="handle=='new'||handle=='change'"></upload>
		<view class="cu-bar bg-white">
			<view class="action">
				<text v-if="!fromData[35].ifRequired" class="is-required">*</text>
				<text class="label-color">{{fromData[35]&&fromData[35].name?fromData[35].name:'上传反担保资料和评估报告'}}</text>
			</view>
		</view>
		<l-file ref="lFile" @up-success="onSuccess"></l-file>
		<upload @upload="($event)=>uploadFile($event,11)" :files="filesArray[11]" :handle="handle=='new'||handle=='change'"></upload>
		<!-- 判断 经理和领导的查看，未完成,待完善 -->
		<view class="bottom-border" v-if="handle=='audit'">
			<view class="left-border"><text class="mgl10">审核</text></view>
		</view>
		
		<view class="margin-top" v-if="handle=='audit'">
			<view class="self">
				<text style="color: #00B9FF;" class="label-audit">审核意见</text>
				<uni-easyinput type="textarea" v-model="businessAuditParameter.remark" placeholder="请输入审核意见"></uni-easyinput>
			</view>
		</view>
		
		<view class="foot-btn btn-rig pad-bt margin-top">
			<button v-show="handle==='watch'&&this.getItem.roleId==='57'" class="mini-btn round def-btn mar-lr" type="primary" size="mini" @tap="repaelPop()">撤销</button>
			<button v-if="handle==='new'" class="mini-btn round def-btn mar-lr" type="primary" size="mini" @tap="newBusiness(0)">保存</button>
			
			<button v-if="handle==='change'" class="mini-btn round suc-btn mar-lr" type="primary" size="mini" @tap="businessApplyEdit()">提交</button>
				
			<button v-if="handle==='new'" class="mini-btn round suc-btn mar-lr" type="primary" size="mini" @tap="newBusiness(1)">提交</button>
			<button v-if="handle==='audit'" class="mini-btn round suc-btn mar-lr" type="primary" size="mini" @tap="auditHandle(2)">同意</button>
			<button v-if="handle==='audit'" class="mini-btn round ref-btn mar-lr" type="primary" size="mini" @tap="auditHandle(3)">拒绝</button>
			<button v-if="handle==='audit'" class="mini-btn round cancel-btn mar-lr" type="primary" size="mini" @tap="auditHandle(4)">驳回</button>
			<button plain class="mini-btn round plain-btn" type="primary" size="mini" @tap="back()">返回</button>
			
		</view>
		<!-- 流程进程-判断新增的情况不展示 -->
		<timeline v-if="flowShow"></timeline>
		<!-- 反担保措施多选框 -->
		  <multiple-select
			v-model="show"
			:data="enGuaranteeDatas"
			:default-selected="defaultSelected"
			@confirm="confirm"
		  ></multiple-select>
		  <!-- 申请期限 -->
		  <multiple-select
			v-model="timelimitShow"
			:data="timelimitDatas"
			:default-selected="timelimitSelected"
			@confirm="timelimitConfirm"
		  ></multiple-select>
		  <!-- 贷款用途 -->
		  <multiple-select
			v-model="applyShow"
			:data="applyDatas"
			:default-selected="applySelected"
			@confirm="applyConfirm"
		  ></multiple-select>
		</view> 
	</view>
</template>

<script>
	import uniPagination from '@/components/uni-pagination/uni-pagination.vue'
	import upload from '../../../components/pretty-uploadFile/pretty-uploadFile.vue'

	const CONTACT_INFO={
		name:'',
		phone:'',
		duty:''
	}
	export default {
		components: {
			uniPagination,
			upload
		},
		data() {
			return {
				url:"https://www.huorantech.cn/api-guarantee/dg-apply-amount-info/uploadFile",
				fileList:[],
				header:{"token":"eyJhbGciOiJIUzI1NiJ9.eyJqdGkiOiIxIiwic3ViIjoidG9rZW4iLCJpc3MiOiJBZG1pbiIsImlhdCI6MTYxMTEzMzk1MywiZXhwIjoxNjExMjIwMzUzfQ.ZB_zJgzmgk8uw4wwH5TY8r1IOvObd2rPSfTU3cFA69U"},
				customerId: '',
				cusTypeList: [
					// {//客户类型列表--暂时只有个人
					// text: '个人',
					// value: '1',
					// disabled: true
					// },
				{
					text: '企业',
					value: '2',
					disabled: true
				}],
				linkTypeList: [{//客户类型列表--关联人
					text: '个人',
					value: "0",
					disabled:this.handle=='watch'
				},
				{
					text: '企业',
					value: "1",
					disabled: false
				}],
				genderList: [{//性别列表-禁用
					text: '男',
					value: 1,
					disabled:true
				},
				{
					text: '女',
					value: 0,
					disabled:true
				}],
				genders: [{//性别列表-禁用
					text: '男',
					value: 1,
				},
				{
					text: '女',
					value: 0,
				}],
				maritalList: [{
					name: '未婚',
					value: 0
				},
				{
					name: '已婚',
					value: 1
				},
				{
					name: '离异',
					value: 2
				},
				{
					name: '再婚',
					value: 3
				}],//婚姻状况列表
				educationList: [//学历列表
				{
					name: '本科',
					value: 0
				},
				{
					name: '大专',
					value: 1
				},
				{
					name: '高职',
					value: 2
				},
				{
					name: '中专',
					value: 3
				},
				{
					name: '其他',
					value: 4
				}],
				legalgenderList: [{
					text: '男',
					value: 1
				},
				{
					text: '女',
					value: 0
				}],//法人性别列表
				isExistList: [{//是否存在关联人列表
					text: '否',
					value: 0
				},
				{
					text: '是',
					value: 1
				}],
				cusType: '2',//客户类型
				maritalStatusVal: '',//婚姻状况列表下标
				educationVal: '', //学历列表下标			
				enterpriseForm: {//企业form
					name: '', //客户姓名
					socialUnifiedCode: '', //社会统一代码
					phone: '', //联系电话
					registerTime: '',//注册时间
					registeredCapital: '',//注册资金
					empNum: '', //员工人数
					registerAddr: '', //注册地址
					linkman: '', //联系人
					linkPhone: '', //联系人电话
					businessAddr: '', //经营地址
					businessSource: '', //业务来源
					businessScope: '', //经营范围
					legalName: '', //法人姓名
					legalGender: 1, //性别
					legalIdNumber: '', //身份证号码
					legalHukouAddr: '', //户口所在地
					legalPhone: '', //联系电话	
					legalHomeAddr: '', //家庭地址	
					isExistRelated: 0, //是否存在联系人
				},
				enterpriseRules: {
					name: {
						rules: [{
							required: true,
							errorMessage: '请输入客户姓名',
						}]
					},
					socialUnifiedCode: {
						rules: [{
							required: true,
							errorMessage: '请输入社会统一代码',
						}]
					},
					phone: {
						rules: [{
							required: true,
							errorMessage: '请输入手机号码',
						},{
							validateFunction: function(rule, value, data, callback) {
								let pattern = /^1[3456789]\d{9}$/
								if (!pattern.test(value)) {
									callback('请输入正确的手机号码')
								}
								return true
							}
						}]						
					},
					registerTime: {
						rules: [{
							required: true,
							errorMessage: '请选择注册时间',
						},]
					},
					registeredCapital: {
						rules: [{
							required: true,
							errorMessage: '请输入注册资金',
						},{
							validateFunction: function(rule, value, data, callback) {
								let pattern = /(^[1-9]([0-9]+)?(\.[0-9]{1,2})?$)|(^(0){1}$)|(^[0-9]\.[0-9]([0-9])?$)/
								if (!pattern.test(value)) {
									callback('请输入正确金额格式,可保留两位小数')
								}
								return true
							}
						}]
					},
					empNum: {
						rules: [{
							required: true,
							errorMessage: '请输入员工人数',
						}]
					},
					registerAddr: {
						rules: [{
							required: true,
							errorMessage: '请输入注册地址',
						}]
					},
					linkman: {
						rules: [{
							required: true,
							errorMessage: '请输入联系人姓名',
						}]
					},
					linkPhone: {
						rules: [{
							required: true,
							errorMessage: '请输入联系人手机号码',
						},{
							validateFunction: function(rule, value, data, callback) {
								let pattern = /^1[3456789]\d{9}$/
								if (!pattern.test(value)) {
									callback('请输入正确的手机号码')
								}
								return true
							}
						}]						
					},
					businessAddr: {
						rules: [{
							required: true,
							errorMessage: '请输入经营地址',
						}]
					},
					businessSource: {
						rules: [{
							required: true,
							errorMessage: '请选择业务类别',
						}]
					},
					businessScope: {
						rules: [{
							required: true,
							errorMessage: '请输入经营范围',
						}]
					},
					legalName: {
						rules: [{
							required: true,
							errorMessage: '请输入法人姓名',
						}]
					},
					legalIdNumber: {
						rules: [{
							required: true,
							errorMessage: '请输入法人身份证号',
						},{
							validateFunction: function(rule, value, data, callback) {
								let pattern = /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/
								if (!pattern.test(value)) {
									callback('请输入正确的身份证号')
								}
								return true
							}
						}]
					},
					legalHukouAddr: {
						rules: [{
							required: true,
							errorMessage: '请输入法人户口所在地',
						}]
					},
					legalPhone: {
						rules: [{
							required: true,
							errorMessage: '请输入联系人手机号码',
						},{
							validateFunction: function(rule, value, data, callback) {
								let pattern = /^1[3456789]\d{9}$/
								if (!pattern.test(value)) {
									callback('请输入正确的手机号码')
								}
								return true
							}
						}]						
					},
					legalHomeAddr: {
						rules: [{
							required: true,
							errorMessage: '请输入家庭地址',
						}]
					}
				},
				hideRequiredAsterisk: false,
				
				page: 1,
				pageSize: 10,
				total: 1,
				companyId: '',
				formData:{},//客户类型
				enterpriseFrom:{},// 表单
				easuresList: [{// 反担保措施的值
					text: '第三方保证',
					value: '第三方保证',
				},
				{
					text: '抵押',
					value: '抵押',
				},
				{
					text: '个人无限责任连带',
					value: '个人无限责任连带',
				},
				{
					text: '质押',
					value: '质押',
				}],
				// 反担保措施多选框变量
				show:false,// 反担保措施变量
				defaultSelected: [], // 多选框默认选中项
				info: "",// 多选框选中项展示
				enGuaranteeDatas:[ // 多选框选项
					{
					  label: "第三方保证",
					  value: "第三方保证"
					},
					{
					  label: "抵押",
					  value: "抵押",
					  // disabled: true //禁用
					},
					{
					  label: "个人无限责任连带",
					  value: "个人无限责任连带"
					},
					{
					  label: "质押",
					  value: "质押"
					},
				],
				// 申请期限
				timelimitShow:false,// 申请期限多选框
				timelimitSelected: [], // 多选框默认选中项
				timelimitinfo: "",// 多选框选中项展示
				timelimitDatas:[ // 多选框选项
					{ value: '1个月', label: '1个月' },
					{ value: '3个月', label: '3个月' },
					{ value: '6个月', label: '6个月' },
					{ value: '9个月', label: '9个月' },
					{ value: '12个月', label: '12个月' },
					{ value: '24个月', label: '24个月' },
				],
				// 贷款用途多选框变量
				applyShow:false,// 反担保措施变量
				applySelected: [], // 多选框默认选中项
				applyinfo: "",// 多选框选中项展示
				applyDatas:[ // 多选框选项
					{ value: 0, label: '短期周转' },
					{ value: 1, label: '购房贷款' },
					{ value: 2, label: '装修贷款' },
					{ value: 3, label: '购车贷款' },
					{ value: 4, label: '教育贷款' },
					{ value: 5, label: '投资创业' },
					{ value: 6, label: '其他' },
				],
				imgList:[],// 绑定上传图片
				businessType:[//业务类型
					{
						key:'融资担保',
						value:'融资担保'
					},
					{
						key:'担保',
						value:'担保'
					},
					{
						key:'借贷',
						value:'借贷'
					},
					{
						key:'小额贷',
						value:'小额贷'
					},
					{
						key:'企业大贷',
						value:'企业大贷'
					},
					{
						key:'其他',
						value:'其他'
					},
				],
				businessApply:{// 提交时的值
					businessType:'',// 业务类别
					applyAmount:'',// 申请额度
					applyTime:"",//申请期限
					bank:'',//贷款银行
					amountWide:'',//贷款用途
					enGuaranteeMeasures:[],//反担保措施
					description:"",// 反担保描述
					businessLicense:[],// 营业执照
					legalCardCopy:[],
					marriageCopy:[],
					legalCopy:[],
					companyConstitution:[],
					accountingFirm:[],
					companyCredit:[],
					creditReport:[],
					certificateAuthorization:[],
					taxCertificate:[],
					meetingMinutes:[],
					assessmentReport:[],//从上到下对应十二个上传文件
					customerType:"2",// 客户
				},
				code: '',//客户编号
				name: '',//客户姓名
				clientCode:[],//客户编号的备选值
				clientName:[],//客户名称的备选值
				clientMessageFrom:{},// 编号读取数据后填充的值
				mainbank:'',// 银行
				elsebank:'',//分行--需要拼接
				banklist:[],// 银行索引
				handle:'',// 当前操作状态
				getItem:{},// 列表传来的参数
				flowShow:true,//是否隐藏底部的流程
				linkMan:false,//是否能操作关联人的修改或者删除
				businessAuditParameter:{},// 审核用对象
				Aname:'',// a角
				Bname:'',// b角
				uploadBtn:true,// 隐藏上传文件按钮
				
				filesArray:[],// 展示用的数组传值
				
				fromData: [],
				upDataArr: [],
				uploadFileList: []
			}
		},
		onReady() {
			// 这里必须放在mounted中，不然h5，支付宝小程序等会找不到this.$refs.form
			if(this.$refs.enterpriseForm) this.$refs.enterpriseForm.setRules(this.enterpriseRules)
		},
		onHide(){
			// 销毁组件时，删除保存的值
			uni.removeStorageSync('applyHandle')
			uni.removeStorageSync('applyMsg')
		},
		created() {
			// 判断来自待处理否
			if(uni.getStorageSync('decideIndex')){
				let data = JSON.parse(uni.getStorageSync('decideIndex'))
				this.getItem.id = data.detailId
				this.businessId = data.businessId
				if(data.btn==='修改'){ // 修改
					this.handle = 'change'
				}else{// 审核
					this.handle = 'audit'
				}
				uni.removeStorageSync('decideIndex')//删除
			}else if(uni.getStorageSync('copyData')){// 抄送的查看处理
				let data =JSON.parse(uni.getStorageSync('copyData'))
				this.handle = 'watch'
				this.getItem.id = data.detailId
				this.businessId = data.businessId
			}else{// 正常逻辑
				this.searchClien()// 搜索所有客户--选择用
				this.allBank()// 所有银行
				this.handle = uni.getStorageSync('applyHandle')// 取得操作状态
				
			}
			
			if(this.handle==='watch'){// 处于查看状态下的处理
				 this.uploadBtn = false // 隐藏上传按钮
				 
			}else if(this.handle==='new'||this.handle==='change'){
				this.linkMan = true
			}
			if(uni.getStorageSync('applyMsg')){ // 取得传参,取得ID等
				this.getItem = JSON.parse(uni.getStorageSync('applyMsg')) 
				this.businessId = this.getItem.businessId
			}
			// 判断操作状态的同时，修改顶部栏展示的名字
			let title = ''
			// 四个状态：新增，查看，修改，审核
			switch (this.handle){
				case 'watch': // 查看
					title = '查看业务申请'
					this.isExistList.map(e=>{
						e.disabled = true
					})
					this.easuresList.map(e=>{
						e.disabled = true
					})
					this.linkTypeList.map(e=>{
						e.disabled = true
					})
					this.genders.map(e=>{
						e.disabled = true
					})
					this.genderList.map(e=>{
						e.disabled = true
					})
					// linkTypeList
					// this.genderList.map(e=>{
					// 	e.disabled = true
					// })
					this.businessApplyDetail()// 读取业务详情
					break; 
				case 'new' : // 新增 
					title = '新增业务'
					this.linkMan = true
					this.flowShow = false// 取消展示流程图
					this.linkMan = true // 可操作关联人
					break;
				case 'audit' : // 审核
					title = '业务申请审核'
					this.businessApplyDetail()// 读取业务详情
					this.isExistList.map(e=>{
						e.disabled = true
					})
					this.easuresList.map(e=>{
						e.disabled = true
					})
					this.linkTypeList.map(e=>{
						e.disabled = true
					})
					this.genderList.map(e=>{
						e.disabled = true
					})
					this.cusTypeList.map(e=>{
						e.disabled = true
					})
					this.genders.map(e=>{
						e.disabled = true
					})
					
					break;
				case 'change' : // 修改
					this.linkMan = true
					title = '修改业务申请'
					this.businessApplyDetail()// 读取业务详情
					this.linkMan = true // 可操作关联人
					this.flowShow = false// 取消展示流程图
					break;
				default:
					break;
			}
			uni.setNavigationBarTitle({
				title:title
			})
			this.designFrom()
		},		
		mounted() {
			
		},
		destroyed() {// 销毁组件操作
			uni.removeStorageSync('handleGe')
			uni.removeStorageSync('applyMsg')
			uni.removeStorageSync('copyData')
		},
		methods: {
			designFrom(){// 表单数据接口
				this.$http.get('/api-guarantee/form/design/list',{
					processId: 1
				}).then(res=>{
					if(!res.data||res.data.length==0) return
					this.fromData = res.data 
					this.fromData.sort(this.compare('id'))// 排序对象
					this.upDataArr = []
					this.upDataArr.push(this.fromData[24].ifRequired,this.fromData[25].ifRequired,this.fromData[26].ifRequired,this.fromData[27].ifRequired,this.fromData[28].ifRequired,this.fromData[29].ifRequired,this.fromData[30].ifRequired,this.fromData[31].ifRequired,this.fromData[32].ifRequired,this.fromData[33].ifRequired,this.fromData[34].ifRequired,this.fromData[35].ifRequired )
					// 修改文件名称
					this.uploadFileList = []
					this.uploadFileList.push(this.fromData[24].name,this.fromData[25].name,this.fromData[26].name,this.fromData[27].name,this.fromData[28].name,this.fromData[29].name,this.fromData[30].name,this.fromData[31].name,this.fromData[32].name,this.fromData[33].name,this.fromData[34].name,this.fromData[35].name)
				})
			},
			//	多选框的三个事件
			//	反担保措施--确定事件
			confirm(data) {
				this.businessApply.enGuaranteeMeasures = data.map(e=>{
					return e.value
				})
				// this.info = data.map(el => el.label).join(",");
				this.info = this.businessApply.enGuaranteeMeasures.join(",")
			},
			//	申请期限--多选框事件
			timelimitConfirm(data) {
				this.businessApply.applyTime = data.map(e=>{
					return e.value
				})
				this.timelimitinfo = data.map(el => el.label).join(",");
			},
			
			//	贷款用途--确定事件
			applyConfirm(data) {
				this.businessApply.amountWide = data.map(e=>{
					return e.value
				})
				this.applyinfo = data.map(el => el.label).join(",");
			},
			// 所有银行
			allBank(){
				this.$http.get('/api-guarantee/dg-bank/bankList').then(res=>{
					this.banklist = res.data.map(e=>{
						if(e.bankName){ 
							return e.bankName
						}
					})
				})
			},	
			//拼接银行
			bankgroup(e,val){
				if(val==='else'){   
					if(this.mainbank){
						this.$set(this.businessApply,'bank',this.mainbank + '-' + this.elsebank)
					}
				}else{
					this.$set(this.businessApply,'bank',this.mainbank)
				}
			},
			//性别选择
			genderChange(e) {
				this.personageForm.gender = e.detail.value
			},
			//婚姻状况选择
			maritalChange(e,index) {
				this.list[index].maritalStatusVal = e.detail.value
				this.list[index].maritalStatus = this.maritalList[e.detail.value].value
			},
			//学历选择
			educationChange(e,index) {
				this.list[index].educationVal = e.detail.value
				this.list[index].education = this.educationList[e.detail.value].value
			},
			//关联人性别选择
			legalGenderChange(e,index) {
				this.list[index].legalGender = e.detail.value
			},
			// //是否有关联人
			// isExistChange(e) {
			// 	this.personageForm.isExistRelated = e.detail.value
			// },
			//关联人婚姻状况选择
			relatedMaritalChange(e,item) {
				item.maritalStatusVal = e.detail.value
				item.maritalStatus = this.maritalList[e.detail.value].value
			},
			//分页选择
			pageChange(e){
				this.page = e.current
				this.getLinkList()
			},
			//注册时间选择
			bindDateChange(e) {
				this.enterpriseForm.registerTime = e.detail.value
			},
			bindBusinessType(e){// 业务类型赋值
				this.$set(this.businessApply,'businessType',this.businessType[+e.detail.value].value)
			},
			applyTimeClicked(e){// 申请期限赋值
				this.$set(this.businessApply,'applyTime',this.timelimitDatas[+e.detail.value].value)	
			},
			applyTimeCencle(e){// 申请期限取消赋值
				e.detail.value = ''
				this.$set(this.businessApply,'applyTime','')	
				this.$set(e,'detail.value','')
			},
			applyClicked(e){// 贷款用途赋值
				this.$set(this.businessApply,'amountWide',this.applyDatas[+e.detail.value].label)	
			},
			//企业关联人注册时间选择
			relatedtimeChange(e,item) {
				item.registeredTime = e.detail.value
			},
			// // 是否有关联人change事件
			// hasLinkman(e){
			// 	// 存在关联人
			// 	if(e===1){this.getLinkmanList()}
			// },
			// 查询客户姓名和编号
			searchClien(){
				this.$http.get('/api-crms/crms/customer/queryCompanyCodeAndName',{type:1}).then(res=>{
					if(!res.data) return
					// 把值提出到备选数组
					this.clientCode = res.data.map(e=>{
						if(e.code) return e.code
					})
					this.clientName = res.data.map(e=>{
						if(e.name) return e.name
					})
				})
			},
			// 输入客户名称或者编号，查询详情
			clientodeCange(val,str){
				// 判断值是否为已有的值，包含则进入接口阶段
				if(!val||!str) return
				if(str==='code'){
					if(this.clientCode.indexOf(val)===-1){
						this.enterpriseForm = {}
						this.name = ''
						this.list = []
						this.businessApply.companyId = ""
						this.companyId = ""
						this.$set(this.businessApply,'isExistRelated','')// 清空关联人是否
						this.$set(this.enterpriseForm,'isExistRelated','')// 清空关联人展示
						this.$set(this.businessApply,'companyId','')// 清空客户id
						return						
					}
				}else{
					if(this.clientName.indexOf(val)===-1){
						this.enterpriseForm = {}
						this.code = ''						
						this.businessApply.companyId = ""
						this.companyId = ""
						this.$set(this.businessApply,'isExistRelated','')// 清空关联人是否
						this.$set(this.enterpriseForm,'isExistRelated','')// 清空关联人展示
						this.$set(this.businessApply,'companyId','')// 清空客户id
						return	
					}
				}
				
				// 判断是code还是name
				this.$http.post('/api-guarantee/dg-apply-amount-info/companyInfoBySth',
					str==='code'?{code:this.code}:{name:this.name},
					).then(res=>{
						// if(!res.data) return
						this.enterpriseForm = res.data
						this.$set(this.businessApply,'isExistRelated',res.data.isExistRelated)// 关联人是否存在--接口传值
						this.$set(this.enterpriseForm,'isExistRelated',res.data.isExistRelated)// 关联人展示
						this.$set(this.businessApply,'companyId',res.data.id)// 客户id
						this.companyId = res.data.id
						this.code = res.data.code
						this.name = res.data.name
						// this.businessApply.companyId = +this.code// 客户编号赋值
						this.businessApply.customerId = this.enterpriseForm.customerId
						// 如果有关联人，则调关联人接口
						// if(this.businessApply.isExistRelated===1) this.getLinkmanList()
					})	
			},
			
			// 把多余的字段赋值--上传记录，防止企业变更
			saveElseMsg(){
				this.businessApply.socialUnifiedCode = this.enterpriseForm.socialUnifiedCode// 社会码
				this.businessApply.registerTime = this.enterpriseForm.registerTime// 注册时间
				this.businessApply.registerAddr = this.enterpriseForm.registerAddr//注册地址
				this.businessApply.businessAddr = this.enterpriseForm.businessAddr// 经营地址
				this.businessApply.phone = this.enterpriseForm.phone// 企业电话
				this.businessApply.registeredCapital = this.enterpriseForm.registeredCapital// 注册资金
				this.businessApply.empNum = this.enterpriseForm.empNum // 员工人数
				this.businessApply.businessScope = this.enterpriseForm.businessScope// 经营范围
				this.businessApply.legalName = this.enterpriseForm.legalName//法人姓名
				this.businessApply.legalIdNumber = this.enterpriseForm.legalIdNumber// 法人身份证
				this.businessApply.legalHukouAddr = this.enterpriseForm.legalHukouAddr// 法人户口所在地
				this.businessApply.legalGender = this.enterpriseForm.legalGender// 法人性别
				this.businessApply.legalPhone = this.enterpriseForm.legalPhone // 联系电话
				this.businessApply.legalHomeAddr = this.enterpriseForm.legalHomeAddr // 家庭住址
				this.businessApply.code  = this.code // 客户编号 --- 等同于企业ID
				this.businessApply.name  = this.name // 客户名称
		
			},
			// 新建业务/保存/提交
			newBusiness(val){
				if(val==1){ // 提交的情况下判空
					this.businessApply.isExistRelated = this.enterpriseForm.isExistRelated
					let apply = this.businessApply
					if (!apply.companyId)return uni.showToast({title:'请输入客户编号/客户名称',icon:"none"})
					if (!apply.businessType)return uni.showToast({title:'请输入业务类别',icon:"none"})
					if (!apply.applyAmount)return uni.showToast({title:'请输入申请额度',icon:"none"})
					if (!apply.applyTime)return uni.showToast({title:'请输入申请期限',icon:"none"})
					if (!apply.bank)return uni.showToast({title:'请输入贷款银行',icon:"none"})
					if (!apply.amountWide)return uni.showToast({title:'请输入贷款用途',icon:"none"})
					if (!apply.enGuaranteeMeasures)return uni.showToast({title:'请输入反担保措施',icon:"none"})
				} 
				this.businessApply.isSaveOrCommit = val//0保存，1提交
				// 企业类型
				this.businessApply.customerType = this.cusType
				if(val==1){//提交时需要进行判断，
				// 当提交时，此处有旧的上传的url，需要一起提交！
					// if(!this.upDataArr[0]){
					if(!this.upDataArr[0]){
						if(!this.businessApply.businessLicense||this.businessApply.businessLicense.length===0){
							return uni.showToast({title:'请上传营业执照！',icon:'none'})
						}
					}
					if(!this.upDataArr[1]){
						if(!this.businessApply.legalCardCopy||this.businessApply.legalCardCopy.length===0){
							return uni.showToast({title:'请上传法定代表人夫妻及企业实际经营者身份证附件！',icon:'none'})
						}
					}
					if(!this.upDataArr[2]){
						if(!this.businessApply.marriageCopy||this.businessApply.marriageCopy.length===0){
							return uni.showToast({title:'请上传法定代表人夫妻户口本、结婚证（离婚证）！',icon:'none'})
						}
					}
					if(!this.upDataArr[3]){
						if(!this.businessApply.legalCopy||this.businessApply.legalCopy.length===0){
							return uni.showToast({title:'请上传法定代表人身份证证明！',icon:'none'})
						}
					}
					if(!this.upDataArr[4]){
						if(!this.businessApply.companyConstitution||this.businessApply.companyConstitution.length===0){
							return uni.showToast({title:'请上传公司章程！',icon:'none'})
						}
					}
					if(!this.upDataArr[5]){
						if(!this.businessApply.accountingFirm||this.businessApply.accountingFirm.length===0){
							return uni.showToast({title:'请上传由会计师事务所审计的上一年度及本年度审计报告！',icon:'none'})
						}
					}
					if(!this.upDataArr[6]){
						if(!this.businessApply.companyCredit||this.businessApply.companyCredit.length===0){
							return uni.showToast({title:'请上传企业信用报告！',icon:'none'})
						}
					}
					if(!this.upDataArr[7]){
						if(!this.businessApply.creditReport||this.businessApply.creditReport.length===0){
							return uni.showToast({title:'请上传企业法人夫妇信用报告、实际经营者信用报告！',icon:'none'})
						}
					}
					if(!this.upDataArr[8]){
						if(!this.businessApply.certificateAuthorization||this.businessApply.certificateAuthorization.length===0){
							return uni.showToast({title:'请上传征信业务授权书、承诺书！',icon:'none'})
						}
					}
					if(!this.upDataArr[9]){
						if(!this.businessApply.taxCertificate||this.businessApply.taxCertificate.length===0){
							return uni.showToast({title:'请上传增值税纳税报表首表/完税证明！',icon:'none'})
						}
					}
					if(!this.upDataArr[10]){
						if(!this.businessApply.meetingMinutes||this.businessApply.meetingMinutes.length===0){
							return uni.showToast({title:'请上传股东会会议纪要！',icon:'none'})
						}
					}
					if(!this.upDataArr[11]){
						if(!this.businessApply.assessmentReport||this.businessApply.assessmentReport.length===0){
							return uni.showToast({title:'请上传反担保资料和评估报告！',icon:'none'})
						}
					}
					if(this.businessApply.amountWide==6){//贷款用途为其他时
						return uni.showToast({title:'请输入其他贷款用途描述！',icon:'none'})
					}
				}else{//保存的时候，起码得有个客户信息
					if(!this.businessApply.companyId){
						return  uni.showToast({title:'至少输入客户编号或者客户名称后才能进行保存！',icon:'none'})
					}
				}
				// uni.showLoading({// 调用加载动画
				// 	title: '加载中',
				// 	mask: true
				// });
				this.businessApply.conversationSummary = []
				this.businessApply.inspectionPhotos = []
				this.businessApply.applyType = 0// 记录业务申请
				this.businessApply.customerId = this.enterpriseForm.customerId
				this.saveElseMsg()// 把法人和企业非必填的值记录上传
				this.$http.post('/api-guarantee/dg-apply-amount-info/businessApplication',this.businessApply).then(res=>{
					uni.showToast({title:val==1?'提交成功！':'保存成功！'})
					this.businessAuditParameter = {}
					this.back()// 返回上一页
					// uni.hideLoading()// 结束加载
				}).catch(err=>{})
			},
			businessApplyEdit(){// 修改业务
				this.businessApply.isExistRelated = this.enterpriseForm.isExistRelated
				let apply = this.businessApply
				if(!apply.companyId||!apply.businessType||!apply.applyAmount||!apply.applyTime||!apply.bank||!apply.amountWide||!apply.enGuaranteeMeasures){
					return uni.showToast({
						title:'请输入必填项！',icon:'none'
					})
				}else{
					// this.concatUrlArr()
					this.businessApply.id = this.getItem.id
					if(!this.upDataArr[0]){
						if(!this.businessApply.businessLicense||this.businessApply.businessLicense.length===0){
							return uni.showToast({title:'请上传营业执照！',icon:'none'})
						}
					}
					if(!this.upDataArr[1]){
						if(!this.businessApply.legalCardCopy||this.businessApply.legalCardCopy.length===0){
							return uni.showToast({title:'请上传法定代表人夫妻及企业实际经营者身份证附件！',icon:'none'})
						}
					} 
					if(!this.upDataArr[2]){
						if(!this.businessApply.marriageCopy||this.businessApply.marriageCopy.length===0){
							return uni.showToast({title:'请上传法定代表人夫妻户口本、结婚证（离婚证）！',icon:'none'})
						}
					}
					if(!this.upDataArr[3]){
						if(!this.businessApply.legalCopy||this.businessApply.legalCopy.length===0){
							return uni.showToast({title:'请上传法定代表人身份证证明！',icon:'none'})
						}
					}
					if(!this.upDataArr[4]){
						if(!this.businessApply.companyConstitution||this.businessApply.companyConstitution.length===0){
							return uni.showToast({title:'请上传公司章程！',icon:'none'})
						}
					}
					if(!this.upDataArr[5]){
						if(!this.businessApply.accountingFirm||this.businessApply.accountingFirm.length===0){
							return uni.showToast({title:'请上传由会计师事务所审计的上一年度及本年度审计报告！',icon:'none'})
						}
					}
					if(!this.upDataArr[6]){
						if(!this.businessApply.companyCredit||this.businessApply.companyCredit.length===0){
							return uni.showToast({title:'请上传企业信用报告！',icon:'none'})
						}
					}
					if(!this.upDataArr[7]){
						if(!this.businessApply.creditReport||this.businessApply.creditReport.length===0){
							return uni.showToast({title:'请上传企业法人夫妇信用报告、实际经营者信用报告！',icon:'none'})
						}
					}
					if(!this.upDataArr[8]){
						if(!this.businessApply.certificateAuthorization||this.businessApply.certificateAuthorization.length===0){
							return uni.showToast({title:'请上传征信业务授权书、承诺书！',icon:'none'})
						}
					}
					if(!this.upDataArr[9]){
						if(!this.businessApply.taxCertificate||this.businessApply.taxCertificate.length===0){
							return uni.showToast({title:'请上传增值税纳税报表首表/完税证明！',icon:'none'})
						}
					}
					if(!this.upDataArr[10]){
						if(!this.businessApply.meetingMinutes||this.businessApply.meetingMinutes.length===0){
							return uni.showToast({title:'请上传股东会会议纪要！',icon:'none'})
						}
					}
					if(!this.upDataArr[11]){
						if(!this.businessApply.assessmentReport||this.businessApply.assessmentReport.length===0){
							return uni.showToast({title:'请上传反担保资料和评估报告！',icon:'none'})
						}
					}
					if(this.businessApply.amountWide==6){//贷款用途为其他时
						return uni.showToast({title:'请输入其他贷款用途描述！',icon:'none'})
					}
					// if(this.businessApply.amountWide==6){//贷款用途为其他时
					//     return uni.showToast({ title:'请输入其他贷款用途描述！',icon:'none' })
					// }
					this.businessApply.applyType = 0// 记录业务申请
					this.businessApply.customerId = this.enterpriseForm.customerId
					this.saveElseMsg()// 记录企业-法人的其他信息上传
					this.$http.post('/api-guarantee/dg-apply-amount-info/updateBusinessApplication',this.businessApply).then(res=>{
						uni.showToast({
							title:'提交成功！'
						})
						this.back()
					})
				}
			},
			// 读取业务申请详情
			businessApplyDetail(){
				this.$http.get('/api-guarantee/dg-apply-amount-info/businessApplicationDetail',{id:this.getItem.id}).then(res=>{
					// dgApplyAmountInfo//业务详情
					// dgEnclosureInfo//附件详情
					// dgBusinessCompany//企业信息
					let apply = res.data.dgApplyAmountInfo
					let reg = new RegExp(' ','g')//删除字符里的空格
					// let handle = apply.enGuaranteeMeasure//反担保
					// if(handle[0]==""){
					// 	handle.splice(0,1)
					// }
					this.businessAuditParameter.id = this.getItem.id//审核用-业务id
					this.businessAuditParameter.companyId = apply.companyId//审核用-企业id
					// handle = handle.map(i=>{ // 删除空白值
					// 	return i.replace(reg,"") })
					this.enterpriseForm = res.data.dgBusinessCompany//企业详情
					this.companyId = apply.companyId
					this.businessApply={
						companyId:apply.companyId,
						businessType:apply.businessType,
						isExistRelated:apply.isExistRelated,
						applyAmount:apply.applyAmount,
						bank:apply.bank,
						applyTime:apply.applyTime,
						amountWide:apply.amountWide,
						enGuaranteeMeasures:apply.enGuaranteeMeasure,
						description:apply.description,
						customerType:apply.customerType,
						otherAmountWide:apply.otherAmountWide
					}
					this.info = this.businessApply.enGuaranteeMeasures.join(",")// 小程序端，处理反担保展示
					if(res.data.dgBusinessCompany!==null){
						this.name = res.data.dgBusinessCompany.name//客户名称
						this.$set(this.businessApply,'isExistRelated',+res.data.dgBusinessCompany.isExistRelated)//是否存在关联人
						this.enterpriseForm.customerId = res.data.dgEnclosureInfo.companyId
						this.code = res.data.dgBusinessCompany.code //客户编号
						// 传递给关联人
						this.clientMessageFrom.customerId = res.data.dgEnclosureInfo.companyId//企业id
					}else{
						this.clientMessageFrom.customerId = ''//企业id
					}
					if(this.businessApply.bank){//银行字符串处理
						let across = this.businessApply.bank.indexOf('-')
						if(across!==-1){
							this.mainbank = this.businessApply.bank.substring(0,across)
							let len = this.businessApply.bank.length
							this.elsebank = this.businessApply.bank.substring(across+1,len)
						}else{
							this.mainbank = this.businessApply.bank
						}
					}
					// this.enterpriseForm.registerTime = res.data.dgBusinessCompany.registerTime.slice(0,10)//截取时间
					let files = res.data.dgEnclosureInfo
					// 删除文件首个值的双引号
					for(let item in files){
						if(files[item]&&files[item].length&&files[item][0]===''){
							files[item].splice(0,1)
						}
					}

					// 循环赋值12个空数组
					for(let i=0;i<12;i++){
						this.filesArray.push([])
					}
					// 展示的赋值--
					this.businessApply.businessLicense = files.businessLicenseList
					this.handleFiles(files.businessLicenseList,0)
					
					this.businessApply.legalCardCopy = files.legalCardCopyList
					this.handleFiles(files.legalCardCopyList,1)
					
					this.businessApply.marriageCopy = files.marriageCopyList
					this.handleFiles(files.marriageCopyList,2)
					
					this.businessApply.legalCopy = files.legalCopyList
					this.handleFiles(files.legalCopyList,3)
					
					this.businessApply.companyConstitution = files.companyConstitutionList
					this.handleFiles(files.companyConstitutionList,4)
					
					this.businessApply.accountingFirm = files.accountingFirmList
					this.handleFiles(files.accountingFirmList,5)
					
					this.businessApply.companyCredit = files.companyCreditList
					this.handleFiles(files.companyCreditList,6)
					
					this.businessApply.creditReport = files.creditReportList
					this.handleFiles(files.creditReportList,7)
					
					this.businessApply.certificateAuthorization = files.certificateAuthorizationList
					this.handleFiles(files.certificateAuthorizationList,8)
					
					this.businessApply.taxCertificate = files.taxCertificateList
					this.handleFiles(files.taxCertificateList,9)
					
					this.businessApply.meetingMinutes = files.meetingMinutesList
					this.handleFiles(files.meetingMinutesList,10)
					
					this.businessApply.assessmentReport = files.assessmentReportList
					this.handleFiles(files.assessmentReportList,11)
					
					// let len = get.length
					// 后端传来的值带空格。。。
					// for(let i=0;i<len;i++){
					//     get[i] = get[i].map(i=>{
					//        return i.replace(reg,"")
					//     })
					// }
					this.businessApply.businessId = res.data.dgEnclosureInfo.businessId
					// this.disposeFileList(get)
				})
			},
			// 传入 data 要处理的数据，格式['url1','url2']
			// 传入对应的index
			handleFiles(data,index){
				if(!data||!data.length) return
				data.map(e=>{
					let obj = {},
					num= e.lastIndexOf("."),
					ext = e.substr(num+1);
					// 判断格式--图片或者其他
					if(e.toLowerCase().includes('jpg','jpeg','png','bmp','gif')){
						obj.book = 'img'
					}else{
						obj.book = "file"
						if(ext=='png'){
							obj.book = 'img'
						}
					}
					// 确定文件格式
					obj.ext = ext
					obj.url = e
					// 接收的数组
					this.filesArray[index].push(obj)
				})
			},
		
			compare(key){ // 用于对象数组排序
				return function(value1,value2){
					let val1=value1[key];
					let val2=value2[key];
					return val1-val2;
				}
			},
			// 撤销弹框
			repaelPop() {
				uni.showModal({
					title: '提示',
					content: '确定要撤销吗？',
					cancelText: '取消',
					confirmText: '确定',
					success: res => {
						if (res.confirm) {
							this.$http.get('/api-guarantee/dg-apply-amount-info/revokeBusinessApplication',{id:this.getItem.id}).then(res=>{
								uni.showToast({
									title:"撤销成功！"
								})
								this.back()
							})
						}
					},
				})
			},
			// 审核
			auditHandle(type){
				this.businessAuditParameter.status = type 
				
				if(type === 3&&!this.businessAuditParameter.remark||type === 4&&!this.businessAuditParameter.remark){
					return uni.showToast({title: '请输入审核意见！',icon:'none'})
				}
				this.$http.post('/api-guarantee/dg-apply-amount-info/approvalBusinessApplication',this.businessAuditParameter).then(res=>{
					setTimeout(()=>{
						this.back()
					},1000)
				})
			},
			onSuccess(res) {
				uni.showToast({
					title: JSON.stringify(res),
					icon: 'none'
				})
			},
			/* 上传文件 */
			uploadFile(e,inx) {
				let fileList = e.map(r => r.url)
				// 对应文件一一匹配
				switch (inx){
					case 0:this.businessApply.businessLicense = fileList
						break;
					case 1:this.businessApply.legalCardCopy = fileList
						break;
					case 2:this.businessApply.marriageCopy = fileList
						break;
					case 3:this.businessApply.legalCopy = fileList
						break;
					case 4:this.businessApply.companyConstitution = fileList
						break;
					case 5:this.businessApply.accountingFirm = fileList
						break;
					case 6:this.businessApply.companyCredit = fileList
						break;
					case 7:this.businessApply.creditReport = fileList
						break;
					case 8:this.businessApply.certificateAuthorization = fileList
						break;
					case 9:this.businessApply.taxCertificate = fileList
						break;
					case 10:this.businessApply.meetingMinutes = fileList
						break;
					case 11:this.businessApply.assessmentReport = fileList
						break;
					default:
						break;
				}
			},
			
			
		},
	}
</script>

<style lang="scss" scoped>
	.evan-form-show {
		padding: 0 30rpx;
		background-color: #fff;

		.form-input {
			font-size: 28rpx;
			color: #333;
			text-align: right;
			// width: 100%;
			box-sizing: border-box;
			min-height: 60rpx;
			&.textarea{
				height: 240rpx;
				padding: 24rpx 0;
				text-align: left;
			}
		}

		.form-input-placeholder {
			font-size: 28rpx;
			color: #999;
		}

		&__button {
			width: 100%;
			height: 88rpx;
			border-radius: 8rpx;
			display: flex;
			align-items: center;
			justify-content: center;
			padding: 0;
			font-size: 36rpx;
			color: #fff;
			margin-top: 20rpx;
			background-color: #2D87D5;

			&::before,
			&::after {
				border: none;
			}
		}

		.customize-form-item {
			&__label {
				font-size: 28rpx;
				color: #333;
				margin-bottom: 16rpx;
			}

			&__radio {
				display: flex;
				align-items: center;
				margin-bottom: 16rpx;

				&__text {
					font-size: 28rpx;
					color: #333;
				}
			}
		}
	}
	.label-color{
		color: #00B9FF;
	}
	// 必填
	.is-required {
		color: $uni-color-error;
	}

	.comBox{//客户编号样式
		display: flex;
		justify-content: flex-end;
		width: 80%;
		margin-left: 20%;
		margin-right: 20%;
		font-size: 28rpx;
		border: 2rpx solid #E6E6E6;
		border-radius: 40rpx;
		height: 70rpx;
		line-height: 70rpx;
		padding: 0 20rpx 0 40rpx;
		color: #333;
	}
	/deep/ .uni-combox__input {
		margin-bottom: 10rpx;
	}
	/deep/ .uni-combox__input-arrow {
		margin-bottom: 10rpx;
	}
	/deep/ .uni-icons {
		font-size: 28rpx!important;
	}
	
	// uni-input取消overflow
	/deep/ .uni-forms{
		overflow: initial;
	}
	// 多选框样式
	.more-select{
		margin-left: 20%;
		border: 2rpx solid #E6E6E6;
		border-radius: 40rpx;
		min-height: 70rpx;
		line-height: 70rpx;
		padding: 0 40rpx;
		color: #333;
		font-size: 28rpx;
	}
	/deep/ .uni-easyinput__content-input{
		overflow: auto;
	}
	.label-audit{
		position: absolute;
		top: 30%;
		left: 0%;
	}
</style>
