<template>
	<view class="evan-form-show">
		<view class="bottom-border">
			<view class="left-border"><text class="mgl10">基本信息</text></view>
		</view>
		<uni-forms :value="assetFromData" ref="surveyFrom" validate-trigger="bind" err-show-type="toast">
			<uni-forms-item  name="cusType" :label="fromData[0]?fromData[0].name:'客户类型'">
				<uni-data-checkbox disabled v-model="enterpriseForm.customerType" :localdata="cusTypeList"></uni-data-checkbox>
			</uni-forms-item>
			<uni-forms-item name="code" :label="fromData[1]?fromData[1].name:'客户编号'">
				<uni-easyinput disabled="" type="text" :inputBorder="true" v-model="enterpriseForm.code" :placeholder="fromData[1]&&fromData[1].prompt?fromData[1].prompt:'请输入客户编号'"></uni-easyinput>
			</uni-forms-item>
			<uni-forms-item name="name" :label="fromData[2]&&fromData[2].name?fromData[2].name:'客户名称'">
				<uni-easyinput disabled type="text" :inputBorder="true" v-model="enterpriseForm.name" :placeholder="fromData[2]&&fromData[2].prompt?fromData[2].prompt:'请输入客户名称'"></uni-easyinput>
			</uni-forms-item>
			<uni-forms-item name="time" :label="fromData[4]?fromData[4].name:'业务类别'">
				<uni-easyinput disabled type="text" :inputBorder="true" v-model="enterpriseForm.businessType" :placeholder="fromData[4]&&fromData[4].prompt?fromData[4].prompt:'请输入'"></uni-easyinput>
			</uni-forms-item>
			<uni-forms-item name="phone" :label="fromData[3]&&fromData[3].name?fromData[3].name:'联系电话'">
				<uni-easyinput disabled type="text" :inputBorder="true" v-model="enterpriseForm.phone" :placeholder="fromData[3]&&fromData[3].prompt?fromData[3].prompt:'系统读取'"></uni-easyinput>
			</uni-forms-item>
			<uni-forms-item name="phone" :label="fromData[5]&&fromData[5].name?fromData[5].name:'申请额度(万元)'">
				<uni-easyinput disabled type="text" :inputBorder="true" v-model="enterpriseForm.applyAmount" :placeholder="fromData[5]&&fromData[5].prompt?fromData[5].prompt:'申请额度'"></uni-easyinput>
			</uni-forms-item>
			<uni-forms-item name="phone" :label="fromData[6]&&fromData[6].name?fromData[6].name:'申请期限'">
				<uni-easyinput disabled type="text" :inputBorder="true" v-model="enterpriseForm.applyTime" :placeholder="fromData[6]&&fromData[6].prompt?fromData[6].prompt:'申请期限'"></uni-easyinput>
			</uni-forms-item>
			<uni-forms-item name="assetsName" required :label="fromData[8]&&fromData[8].name?fromData[8].name:'资产评估报告(名称)'">
				<uni-easyinput :disabled="survey" type="text" :inputBorder="true" v-model="assetFromData.assetsName" :placeholder="fromData[8]&&fromData[8].prompt?fromData[8].prompt:'资产评估报告'"></uni-easyinput>
			</uni-forms-item>
			<uni-forms-item name="assetsCode" required :label="fromData[9]&&fromData[9].name?fromData[9].name:'资产评估报告编号'">
				<uni-easyinput :disabled="survey" type="text" :inputBorder="true" v-model="assetFromData.assetsCode" :placeholder="fromData[9]&&fromData[9].prompt?fromData[9].prompt:'资产评估报告编号'"></uni-easyinput>
			</uni-forms-item>
			<uni-forms-item name="amountSum" required :label="fromData[10]&&fromData[10].name?fromData[10].name:'评估价值(万元)'">
				<!-- <uni-data-checkbox @change="getCost" :inputVisble="true" :multiple="true" mode="list" v-model="enterpriseFrom.gender" :localdata="EvaluationList"></uni-data-checkbox> -->
				<!-- :checked="item.selected" 是否勾选 -->
				<checkbox-group class="coust">
					<label class="flex-end coust">
						<uni-data-checkbox  v-model="house" :checked="house" :localdata="houses" @tap="Checked(1)"></uni-data-checkbox>
						<uni-easyinput @input='allTotal' class="wd60" :disabled="house==''||handle!=='survey'"  type="digit" :inputBorder="true"  v-model="assetFromData.houseMoney" placeholder="房产价值"></uni-easyinput>
					</label>
					<label class="flex-end margin-tb-sm">
						<uni-data-checkbox v-model="car" :localdata="cars" @tap="Checked(2)"></uni-data-checkbox>
						<uni-easyinput @input='allTotal' class="wd60" :disabled="car==''||handle!=='survey'"  type="digit" :inputBorder="true" v-model="assetFromData.carMoney" placeholder="车辆价值"></uni-easyinput>					
					</label>
					<label class="flex-end">
						<uni-data-checkbox v-model="equipment" :localdata="equipments" @tap="Checked(3)"></uni-data-checkbox>
						<uni-easyinput @input='allTotal' class="wd60" :disabled="equipment==''||handle!=='survey'"  type="digit" :inputBorder="true" v-model="assetFromData.equipmentMoney" placeholder="设备价值"></uni-easyinput>
					</label>
					<label class="flex-end margin-tb-sm">
						<uni-data-checkbox v-model="elseMoney" :localdata="elseMoneys" @tap="Checked(4)"></uni-data-checkbox>
						<uni-easyinput @input='allTotal' class="wd60" :disabled="elseMoney==''||handle!=='survey'"  type="digit" :inputBorder="true" v-model="assetFromData.otherMoney" placeholder="其他资产"></uni-easyinput>					
					</label>
				</checkbox-group>
				<view class="flex-end">
					<text>合计</text>
					<uni-easyinput disabled type="text" :inputBorder="true" v-model="assetFromData.amountSum" placeholder="自动合计"></uni-easyinput>
				</view>
			</uni-forms-item>
			<uni-forms-item name="assetsTime" required :label="fromData[11]&&fromData[11].name?fromData[11].name:'评估日期'">
				<picker :disabled="handle!=='survey'" :class="handle!=='survey'?'disabled':''" mode="date" :value="assetFromData.assetsTime" @change="bindDateChange">
					<view disabled  class="picker-view flex-between">
						<text>{{assetFromData.assetsTime ? assetFromData.assetsTime : '请选择'}}</text>
						<text class="cuIcon-unfold lg text-gray"></text>
					</view>
				</picker>
				<!-- <uni-easyinput v-if="handle!=='survey'" disabled type="text" :inputBorder="true" v-model="assetFromData.assetsTime" placeholder="审计价值"></uni-easyinput> -->
			</uni-forms-item>
			<uni-forms-item name="auditCode" required :label="fromData[12]&&fromData[12].name?fromData[12].name:'审计编号'">
				<uni-easyinput :disabled="survey" type="text" :inputBorder="true" v-model="assetFromData.auditCode" :placeholder="fromData[12]&&fromData[12].prompt?fromData[12].prompt:'审计编号'"></uni-easyinput>
			</uni-forms-item>	
			<uni-forms-item name="auditName" required :label="fromData[14]&&fromData[14].name?fromData[14].name:'审计报告(名称)'">
				<uni-easyinput :disabled="survey" type="text" :inputBorder="true" v-model="assetFromData.auditName" :placeholder="fromData[14]&&fromData[14].prompt?fromData[14].prompt:'审计报告(名称)'"></uni-easyinput>
			</uni-forms-item>
			<uni-forms-item required name="auditTime" label="审计日期">
				<!-- <uni-datetime-picker v-if="handle==='survey'" v-model="assetFromData.auditTime" :timestamp="true"></uni-datetime-picker> -->
				<picker :disabled="handle!=='survey'" :class="handle!=='survey'?'disabled':''" mode="date" :value="assetFromData.auditTime" @change="bindAuditTime">
					<view disabled  class="picker-view flex-between">
						<text>{{assetFromData.auditTime ? assetFromData.auditTime : '请选择'}}</text>
						<text class="cuIcon-unfold lg text-gray"></text>
					</view>
				</picker>
				<!-- <uni-easyinput v-if="handle!=='survey'"  disabled type="text" :inputBorder="true" v-model="assetFromData.auditTime" placeholder="审计价值"></uni-easyinput> -->
			</uni-forms-item>
			<uni-forms-item name="auditAmount" required :label="fromData[15]&&fromData[15].name?fromData[15].name:'审计价值(万元)'">
				<uni-easyinput :disabled="survey" type="text" :inputBorder="true" v-model="assetFromData.auditAmount" :placeholder="fromData[15]&&fromData[15].prompt?fromData[15].prompt:'审计价值'"></uni-easyinput>
			</uni-forms-item>
			<uni-forms-item required name="enGuaranteeMeasures" :label="fromData[7]&&fromData[7].name?fromData[7].name:'反担保措施'">
				<uni-data-checkbox @change="testc" multiple mode="list" :value="assetFromData.enGuaranteeMeasures" :localdata="easuresList"></uni-data-checkbox>
			</uni-forms-item>	
			<uni-forms-item name="description" label="反担保措施描述">
				<uni-easyinput :disabled="survey" type="textarea" v-model="assetFromData.description" :placeholder="fromData[7]&&fromData[7].prompt?fromData[7].prompt:'反担保措施描述'"></uni-easyinput>
			</uni-forms-item>
		</uni-forms>		
		<view class="bottom-border">
			<view class="left-border">
				<text v-if="handle==='survey'" class="mgl10">办理抵押人意见</text>
				<text v-if="handle!=='survey'" class="mgl10">附件</text>	
			</view>
		</view>
		<view class="cu-bar bg-white" v-if="handle==='survey'">
			<view class="action">
				<text class="is-required">*</text>
				<text class="label-color">上传附件</text>
			</view>
		</view>
		<upload @upload="($event)=>uploadFile($event)" :files="filesArray" :handle="handle=='survey'"></upload>
		<!-- 调查员审核意见 -->
		<view v-if="handle==='survey'" class="self margin-top" >
			<text style="color: #00B9FF;" class="label-audit">审核意见</text>
			<uni-easyinput type="textarea" v-model="auditFrom.applyContent" placeholder="请输入审核意见"></uni-easyinput>
		</view>
		
		<!-- 等于审核和领导查看的时候才展示，得判断领导 -->
		<!-- 领导的暂时未进行判断 -->
		<!-- 待完善 -->
		<view class="bottom-border" v-if="handle=='audit'">
			<view class="left-border">
				<text class="mgl10">审核</text>	
			</view>
		</view>
		<uni-forms v-if="handle=='audit'" :value="assetAuditFrom" ref="assetAuditFrom" validate-trigger="bind" err-show-type="toast">
			<uni-forms-item name="amount" label="申请额度(万元)">
				<uni-easyinput type="digit" :inputBorder="true" v-model="assetAuditFrom.amount" placeholder="请输入申请额度"></uni-easyinput>
			</uni-forms-item>
			<uni-forms-item name="term" label="期限">
				<picker mode="selector" :range="timelimitDatas" range-key="label" :value="assetAuditFrom.term" @change="termTimeClicked" @cancel="applyTimeCencle">
					<view class="picker-view flex-between">
						<text>{{assetAuditFrom.term ? assetAuditFrom.term : '请选择申请期限'}}</text>
						<text class="cuIcon-unfold lg text-gray"></text>
					</view>
				</picker> 
			</uni-forms-item>
			<uni-forms-item name="remark" label="补充调查原因">
				<uni-data-checkbox multiple mode="list" v-model="assetAuditFrom.remark" :localdata="remakeList"></uni-data-checkbox>
			</uni-forms-item>
			<uni-forms-item name="otherRemark" label="其他原因">
				<uni-easyinput type="text" :inputBorder="true" v-model="assetAuditFrom.otherRemark" placeholder="请输入其他原因"></uni-easyinput>
			</uni-forms-item>
		</uni-forms>
		<view class="self" v-if="handle=='audit'">
			<text style="color: #00B9FF;" class="label-audit">审核意见</text>
			<uni-easyinput type="textarea" v-model="assetAuditFrom.applyContent" placeholder="请输入审核意见"></uni-easyinput>
		</view>
		
		<view class="foot-btn btn-rig pad-bt margin-top">
			<button plain class="mini-btn round plain-btn" type="primary" size="mini" @click="back()">返回</button>
			<!-- 调查员 -->
			<button v-if="handle==='survey'" class="mini-btn round def-btn mar-lr" type="primary" size="mini" @click="assetSurvey">同意</button>
			<!-- 经理/领导 -->
			<button v-if="handle==='audit'" class="mini-btn round suc-btn  mar-lr" type="primary" size="mini" @click="assetAudit(1)">同意</button>
			<button v-if="handle==='audit'" class="mini-btn round ref-btn mar-lr" type="primary" size="mini" @click="assetAudit(3)">拒绝</button>
			<button v-if="handle==='audit'" class="mini-btn round cancel-btn" type="primary" size="mini" @click="assetAudit(4)">驳回</button>
		</view>
		
		<timeline></timeline>
	</view>
</template>

<script>
	import utils from '@/components/evan-form/utils.js'
	import upload from '../../../components/pretty-uploadFile/pretty-uploadFile.vue'
	const CONTACT_INFO={
		name:'',
		phone:'',
		duty:''
	}
	export default {
		components: {
			upload
		},
		data() {
			return {
				survey:false,// 必填项是否禁用--根据操作进行判断
				cusTypeList: [
					// {//客户类型列表
					// 	text: '个人',
					// 	value: '1',
					// 	disabled:true
					// },
				{
					text: '企业',
					value: '2',
					disabled:true
				}],
				house:'',
				houses:[{
					text: '房产',
					value: '房产',
					disabled:this.survey,
				}],
				car:'',
				cars:[{
					text: '车辆',
					value: '车辆',
					disabled:this.survey
				}],
				equipment:'',
				equipments:[{
					text: '设备',
					value: '设备',
					disabled:this.survey
				}],
				elseMoney:'',
				elseMoneys:[{
					text: '其他',
					value: '其他',
					disabled:this.survey
				}],
				
				cusType: '2',
				
				employeeMsg: [{
					name: '个人',
					value: '3'
				},
				{
					name: '企业',
					value: '4'
				}],//客户经理列表
				genderList: [{
					text: '男',
					value: 1
				},
				{
					text: '女',
					value: 0
				}],//性别列表
				
				easuresList: [{
					text: '第三方保证',
					value: '第三方保证'
				},
				{
					text: '抵押',
					value: '抵押'
				},
				{
					text: '个人无限责任连带',
					value: '个人无限责任连带'
				},
				{
					text: '质押',
					value: '质押'
				}],
				imgList: [],
				maritalList: ['未婚','已婚','离异','再婚'],//婚姻状况列表
				educationList: ['本科','大专','高职','中专','其他'],//学历列表
				isExistList: [{
					text: '否',
					value: 0
				},
				{
					text: '是',
					value: 1
				}],//是否存在关联人列表
				manager: '',
				enterpriseFrom: {
					customerType:'2',
					maritalStatus: 0,//婚姻状况
					gender: 1,//性别
					education: 0, //学历
					legalGender: 1, //关联人性别
					isExistRelated: 0, //是否存在关联人
					enGuaranteeMeasures: ''
				},//个人form
				enterpriseForm: {
					customerType:'2',
				},//企业form
				hideRequiredAsterisk: false,
				// 表单的内容必须初始化
				info: {
					name: '',
					email: '',
					desc: '',
					phone: '',
					sex: '',
				},
				rules: {
					cusType: {
						required: true,
						message: '请选择客户'
					},
					code: {
						required: true,
						message: '请选择客户编号'
					},
					manager: {
						required: true,
						message: '请选择客户经理'
					},
					name: {
						required: true,
						message: '请输入姓名'
					},
					email: [{
						required: true,
						message: '请输入邮箱'
					}, {
						type: 'email',
						message: '邮箱格式不正确'
					}],
					desc: [{
							required: true,
							message: '请输入简介'
						},
						{
							min: 10,
							max: 30,
							message: '简介必须在10到30个字之间'
						}
					],
					phone: [{
							required: true,
							message: '请输入手机号'
						},
						{
							validator: (rule, value, callback) => {
								// 注意这里如果用的是methods里的isMobilePhone将不生效
								if (this.$utils.isMobilePhone(value)) {
									callback()
								} else {
									callback(new Error('手机号格式不正确'))
								}
							}
						},
						// 或者这样也是可以的
						// {
						// 	validator: this.isMobile
						// }
					],
					sex: {
						required: true,
						message: '请选择性别'
					}
				},
				info2:{
					name:'',
					email:'',
					phone:''
				},
				rules2:{
					name: {
						required: true,
						message: '请输入姓名'
					},
					email: [{
						required: true,
						message: '请输入邮箱'
					}, {
						type: 'email',
						message: '邮箱格式不正确'
					}],
					phone:[{
							required: true,
							message: '请输入手机号'
						},
						{
							pattern:'^1\\d{10}$', // 注意这里由于小程序的缘故正则表达式需要通过string的方式传递并且去除两边的斜杠，中间的斜杠变成两个斜杠
							message:'手机号格式不正确'
						}
					]
				},
				dynamicInfo:{
					test1:'',
					test2:'',
					list:[{...CONTACT_INFO}]
				},
				dynamicRules:{
					test1:[{required:true,message:'请输入rule规则字段'},{min:4,max:8,message:'必须4-8位'}]
				},
				showRuleParam:true,
				showRequiredParam:true,
				mobileRules:[{required:true,message:'请输入手机号'},{pattern:'^1\\d{10}$',message:'手机号格式不正确'}], // 注意这里由于小程序的缘故正则表达式需要通过string的方式传递并且去除两边的斜杠，中间的斜杠变成两个斜杠
				handle:'',// 操作状态
				getItem:{},// 获取列表传值
				
				assetFromData:{// 调查员表单
					assetsName:'',// 资产评估报告名称
					assetsCode:'',// 资产评估报告编号
					houseMoney:'',// 房产
					carMoney:'',//车产
					equipmentMoney:'',//设备
					otherMoney:'',//其他
					amountSum:'',// 合计
					assetsTime:'',// 评估日期
					auditCode:'',// 审计编号
					auditName:'',//审计报告(名称)
					auditTime:'',// 审计日期
					auditAmount:'',// 审计价值
					enGuaranteeMeasures:[],// 反担保措施enGuaranteeMeasures
					remarks:'',// 反担保描述
					file:[],// 文件
					assetsAmount:[],// 四个勾选
				},
				// 调查员表单验证
				serveyRules: {
					assetsName: {
						rules: [{
							required: true,
							errorMessage: '请输入资产评估报告名称',
						}]
					},
					assetsCode: {
						rules: [{
							required: true,
							errorMessage: '请输入资产评估报告编号',
						}]
					},
					amountSum: {
						rules: [{
							required: true,
							errorMessage: '请输入评估价值',
						}]
					},
					assetsTime: {
						rules: [{
							required: true,
							errorMessage: '请输入评估日期',
						}]
					},
					auditCode: {
						rules: [{
							required: true,
							errorMessage: '请输入审计编号',
						}]
					},
					auditName: {
						rules: [{
							required: true,
							errorMessage: '请输入审计报告名称',
						}]
					},
					auditTime: {
						rules: [{
							required: true,
							errorMessage: '请输入审计日期',
						}]
					},
					auditAmount: {
						rules: [{
							required: true,
							errorMessage: '请输入审计价值',
						}]
					},
					enGuaranteeMeasures: {
						rules: [{
							required: true,
							errorMessage: '请选择反担保措施',
						}]
					},
					// description: {
					// 	rules: [{
					// 		required: true,
					// 		errorMessage: '请输入反担保措施描述',
					// 	}]
					// },
				},
				
				assetAccessory:[],// 已有文件赋值展示
				
				assetAuditFrom:{// 资产部经理审核from
					amount:'',// 金额
					term:'',// 期限
					remark:[],// 补充调查
					otherRemark:'',// 其他原因
					applyContent:'',// 审核意见
				},
				assetAuditRules: {
					amount: {
						rules: [{
							required: true,
							errorMessage: '请输入金额',
						}]
					},
					term: {
						rules: [{
							required: true,
							errorMessage: '请输入期限',
						}]
					}
				},
				remakeList: [{// remake
					text: '资料不全',
					value: '资料不全',
				},
				{
					text: '贷款用途不合理',
					value: '贷款用途不合理',
				},
				{
					text: '资料不符合要求',
					value: '资料不符合要求',
				},
				{
					text: '其他',
					value: '其他',
				}],
				replenish:[
					{ value: '资料不全', label: '资料不全' },
					{ value: '贷款用途不合理', label: '贷款用途不合理' },
					{ value: '资料不符合要求', label: '资料不符合要求' },
					{ value: '其他', label: '其他' }
				],
				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个月' },
				],
				filesArray:[],// 展示文件用
				subBoolean:false,// 验证用
				
				
				houseChecked:0,
				carChecked:0,
				equipmentChecked:0,
				elseMoneyChecked:0,
				fromData:[],// 表单值
			}
		},
		onReady() {
			// 领导审核表单验证
			if(this.$refs.assetAuditFrom) this.$refs.assetAuditFrom.setRules(this.assetAuditRules)
			// 调查员表单验证
			if(this.$refs.surveyFrom) this.$refs.surveyFrom.setRules(this.serveyRules)
		},
		destroyed() {// 销毁组件操作
			uni.removeStorageSync('handleGe')
			uni.removeStorageSync('applyMsg')
			uni.removeStorageSync('copyData')
		},
		created() {
			// 判断来自待处理否
			if(uni.getStorageSync('decideIndex')){
				let data = JSON.parse(uni.getStorageSync('decideIndex'))
				this.getItem.id = data.detailId
				if(data.btn==='调查'){
					this.handle = 'survey'
				}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
			}else{
				this.handle = uni.getStorageSync('handleGe')// 取得操作状态
			}
			// 判断操作禁用
			if(this.handle==='survey'){
				this.survey = false
			}else{// 禁用
				this.survey = true
				// 四个资产
				this.houses[0].disabled = true
				this.cars[0].disabled = true
				this.equipments[0].disabled = true
				this.elseMoneys[0].disabled = true
				
				this.easuresList.forEach(e=>{
					e.disabled = true
				})
			}
			if(uni.getStorageSync('applyMsg')){ // 取得传参,取得ID等
				this.getItem = JSON.parse(uni.getStorageSync('applyMsg')) 
				this.businessId = this.getItem.businessId
			}
			// 获取详情
			this.getDetails(this.getItem.id)
			this.designFrom()
			
			this.handle==='audit'
		},
		mounted() {
			// 这里必须放在mounted中，不然h5，支付宝小程序等会找不到this.$refs.form
			// this.$refs.form.setRules(this.rules)
			
			this.EvaluationList = [
				{
					text: '房产',
					value: '0',
					InputValue: 852,
					selected:Boolean,
				},
				{
					text: '车辆',
					value: '1',
					InputValue: 456
				},
				{
					text: '设备',
					value: '2',
					InputValue: '852'
				},
				{
					text: '其他',
					value: '3',
					InputValue: '964'
				}
			]
		},
		methods: {
			designFrom(){// 表单数据接口
				this.$http.get('/api-guarantee/form/design/list',{
					processId: 3
				}).then(res=>{
					if(!res.data||res.data.length==0) return
					this.fromData = res.data 
					this.fromData.sort(this.compare('id'))// 排序对象
				})
			},
			compare(key){ // 用于对象数组排序
				return function(value1,value2){
					let val1=value1[key];
					let val2=value2[key];
					return val1-val2;
				}
			},
			testc(e){// 反担保措施赋值
				this.assetFromData.enGuaranteeMeasures = e.detail.value
			},
			//时间选择
			bindDateChange(e) {
				this.assetFromData.assetsTime = e.detail.value
			},
			bindAuditTime(e) {
				this.assetFromData.auditTime = e.detail.value
			},
			Checked(index){
				switch (index){
					case 1:
						if(this.house=='房产') {
							this.assetFromData.assetsAmount.push('房产')
							this.houseChecked++
						}
						if(this.houseChecked>1) {
							this.assetFromData.assetsAmount.splice(this.assetFromData.assetsAmount.indexOf('房产'),1)
							this.house = ''
							this.houseChecked = 0
						}
						break;
					case 2:
						if(this.car=='车辆') {
							this.assetFromData.assetsAmount.push('车辆')
							this.carChecked++
						}
						if(this.carChecked >1) {
							this.assetFromData.assetsAmount.splice(this.assetFromData.assetsAmount.indexOf('车辆'),1)
							this.car = ''
							this.carChecked = 0
						}
						break;
					case 3:
						if(this.equipment=='设备') {
							this.assetFromData.assetsAmount.push('设备')
							this.equipmentChecked++
						}
						if(this.equipmentChecked >1) {
							this.assetFromData.assetsAmount.splice(this.assetFromData.assetsAmount.indexOf('设备'),1)
							this.equipment = ''
							this.equipmentChecked = 0
						}
						break;
					case 4:
						if(this.elseMoney=='其他') {
							this.assetFromData.assetsAmount.push('其他')
							this.elseMoneyChecked++
						}
						if(this.elseMoneyChecked >1) {
							this.assetFromData.assetsAmount.splice(this.assetFromData.assetsAmount.indexOf('其他'),1)
							this.elseMoney = ''
							this.elseMoneyChecked = 0
						}
						break;
					default:
						break;
				}
			},
			//提交表单验证
			async submitForm(form) {
				this.subBoolean = false
				let that = this
				await this.$refs[form].submit()
					.then((res) => {
						that.subBoolean = true
					})
					.catch(err=>{
						that.subBoolean = false
					})
				return this.subBoolean?true:false
			},
			
			applyTimeClicked(e){// 补充调查原因选择赋值
				this.$set(this.assetAuditFrom,'remark',this.replenish[+e.detail.value].value)	
			},
			termTimeClicked(e){// 经理审核-期限赋值
				this.$set(this.assetAuditFrom,'term',this.timelimitDatas[+e.detail.value].value)	
			},
			applyTimeCencle(e){// 申请期限取消赋值
				this.$set(this.assetAuditFrom,'term','')
			},
			//客户类型选择
			cusChange(e) {
				this.cusType = e.detail.value
			},
			//性别选择
			genderChange(e) {
				this.personageForm.gender = e.detail.value
			},
			//婚姻状况选择
			maritalChange(e) {
				this.personageForm.maritalStatus = e.detail.value
			},
			//学历选择
			educationChange(e) {
				this.personageForm.education = e.detail.value
			},
			//关联人性别选择
			legalGenderChange(e) {
				this.personageForm.legalGender = e.detail.value
			},
			isExistChange(e) {
				this.personageForm.isExistRelated = e.detail.value
			},
			bindPickerChange: function(e) {
				// this.cusType = e.target.value
			},
			save() {
				this.$refs.form.validate((res) => {
					if (res) {
						uni.showToast({
							title: '验证通过'
						})
					}
				})
			},
			promiseSave(){
				this.$refs.form.validate().then((res)=>{
					uni.showToast({
						title: '验证通过'
					})
				}).catch(()=>{
				})
			},
			async asyncSave(){
				try{
					const result=await this.$refs.form.validate()
					if(result){
						uni.showToast({
							title: '验证通过'
						})
					}
				} catch(e){
				}
			},
			saveForm2(){
				this.$refs.form2.validate((res) => {
					if (res) {
						uni.showToast({
							title: '验证通过'
						})
					}
				})
			},
			utilsSave() {
				utils.validate(this.info, this.rules, (res, errors) => {
					if (res) {
						uni.showToast({
							title: '验证通过'
						})
					}
				})
			},
			validateSingle() {
				this.$refs.form.validateField('email', (res) => {
					if (res) {
						uni.showToast({
							title: '验证通过'
						})
					}
				})
			},
			validateMultiple() {
				this.$refs.form.validateField(['email', 'phone'], (res) => {
					if (res) {
						uni.showToast({
							title: '验证通过'
						})
					}
				})
			},
			isMobilePhone() {
				const reg = /^1\d{10}$/
				if (reg.test(value)) {
					return true
				}
				return false
			},
			isMobile(rule, value, callback) {
				if (this.$utils.isMobilePhone(value)) {
					callback()
				} else {
					callback(new Error('手机号格式不正确'))
				}
			},
			sexChange(e) {
				this.info.sex = e.detail.value
			},
			addContact(){
				this.dynamicInfo.list.push({...CONTACT_INFO})
			},
			deleteContact(index){
				this.dynamicInfo.list.splice(index,1)
			},
			toggleRuleParam(){
				this.showRuleParam=!this.showRuleParam
			},
			toggleRequiredParam(){
				this.showRequiredParam=!this.showRequiredParam
			},
			dynamicSave(){
				this.$refs.dynamicForm.validate((res)=>{
					if(res){
						uni.showToast({
							title: '验证通过'
						})
					}
				})
			},
			ViewImage(e) {
				uni.previewImage({
					urls: this.imgList,
					current: e.currentTarget.dataset.url
				});
			},
			DelImg(e) {
				uni.showModal({
					title: '提示',
					content: '确定要删除该文件吗？',
					cancelText: '取消',
					confirmText: '确定',
					success: res => {
						if (res.confirm) {
							this.imgList.splice(e.currentTarget.dataset.index, 1)
						}
					}
				})
			},
			
			// 获取传值事件--
			getCost(val){
			},
			// 获取详情
			// /api-guarantee/dg-assets-investigation/assetsDetail
			getDetails(id){
				uni.getStorageSync('applyMsg')
				this.$http.get('/api-guarantee/dg-assets-investigation/assetsDetail',{id:this.getItem.id}).then(res=>{
					let client = res.data.dgApplyAmountInfo
					// 基本信息赋值
					this.enterpriseForm = {
						code:res.data.dgBusinessCompany.code,
						name:res.data.dgBusinessCompany.name,
						businessType: client.businessType,
						applyAmount:client.applyAmount,
						applyTime:client.applyTime,
						customerType: res.data.dgApplyAmountInfo.customerType,
						phone: res.data.dgBusinessCompany.phone,
						description:res.data.dgApplyAmountInfo.description
					}
					// enGuaranteeMeasures
					this.assetFromData.description = res.data.dgApplyAmountInfo.description
					let data = res.data.assetsResponse 
					// 必填项赋值
					if(this.handle=='watch'||this.handle=='audit'||this.handle=='survey'){
						// 判断资产价值是否填上
						let assetArr = data.assetsAmountList?data.assetsAmountList:[]
						assetArr.includes('房产')?this.house = '房产':this.house = ''
						assetArr.includes('车辆')?this.car = '车辆':this.car = ''
						assetArr.includes('设备')?this.equipment = '设备':this.equipment = ''
						assetArr.includes('其他')?this.elseMoney = '其他':this.elseMoney = ''
						
						
						
						this.$set(this.assetFromData,'assessmentList',data.assessmentList?data.assessmentList:[])
						// 多选项assetFromData
						this.$set(this.assetFromData,'enGuaranteeMeasures',res.data.dgApplyAmountInfo.enGuaranteeMeasure?res.data.dgApplyAmountInfo.enGuaranteeMeasure:[])
						this.$set(this.assetFromData,'assetsName',data.assetsName)
						this.$set(this.assetFromData,'amountSum',data.amountSum)
						this.$set(this.assetFromData,'auditName',data.auditName)
						this.$set(this.assetFromData,'auditAmount',data.auditAmount)
						this.$set(this.assetFromData,'assetsCode',data.assetsCode)
						this.$set(this.assetFromData,'auditCode',data.auditCode)
						this.$set(this.assetFromData,'assetsTime',data.assetsTime)
						this.$set(this.assetFromData,'auditTime',data.auditTime)
						this.$set(this.assetFromData,'description',res.data.dgApplyAmountInfo.description)
						
						if(data.dgAssetsMoney){							
							this.$set(this.assetFromData,'houseMoney',data.dgAssetsMoney.houseMoney)
							this.$set(this.assetFromData,'carMoney',data.dgAssetsMoney.carMoney)
							this.$set(this.assetFromData,'equipmentMoney',data.dgAssetsMoney.equipmentMoney)
							this.$set(this.assetFromData,'otherMoney',data.dgAssetsMoney.otherMoney)
						}
		
						this.$set(this.assetFromData,'applyContent',data.applyContent)
						
						this.assetFromData.file = data.fileList
						this.handleFiles(data.fileList)
						
						
						
						actualRepaymentDate: "2021-03-08"
						createTime: "2021-03-23"
						currentRepayment: 324
						deductionAmount: 324
						id: 9
						insuranceId: 2
						interest: 5325
						otherExpenses: 234
						overdueDays: 17
						repaymentDate: "2021-03-09"
						repaymentNotes: "wfgegerg"
						repaymentStatus: 3
						submitterId: 1
						submitterName: "Admin"
						totalRepayment: 3425
						updateTime: "2021-03-26"
						
						
						
						
						// 仅需要区分领导和调查员，角色的状态判断
						// 尝试不判断，仅赋值
						if(this.handle=='watch'){// 经理或者领导查看的情况下
							this.$set(this.assetAuditFrom,'amount',data.amount)
							this.$set(this.assetAuditFrom,'term',data.term)
							this.$set(this.assetAuditFrom,'applyContent',data.applyContent)
							this.$set(this.assetAuditFrom,'otherRemark',data.otherRemark)
						}
						if(data.remarkList&&this.handle=='watch'){
							this.$set(this.assetAuditFrom,'remark',data.remarkList)
						}
						
						// }
						// this.$set(this.assetAuditFrom,'otherMoney',data.dgAssetsMoney.otherMoney)
					}
				})
			},
			// 传入 data 要处理的数据，格式['url1','url2']
			// 传入对应的index
			handleFiles(data){
				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.push(obj)
				})
			},
			// 合计
			allTotal(){
				let car,house,equipment,other
				this.assetFromData.houseMoney?house=+this.assetFromData.houseMoney:house=0
				this.assetFromData.carMoney?car=+this.assetFromData.carMoney:car=0
				this.assetFromData.equipmentMoney?equipment=+this.assetFromData.equipmentMoney:equipment=0
				this.assetFromData.otherMoney?other=+this.assetFromData.otherMoney:other=0
				if(car<1||house<1||equipment<1||other<1){
					this.$set(this.assetFromData,'amountSum',(car*10000000+house*10000000+equipment*10000000+other*10000000)/10000000)
				}else{
					this.$set(this.assetFromData,'amountSum',car+house+equipment+other)
				} 
			},
			// 图像
			ViewImage(img,index) {
				let urls = ''
				urls = this.survey.businessLicense// 匹配文件
				uni.previewImage({
					urls: urls,
					current: img
				});
			},
			// 
			DelImg(val,index) {
				uni.showModal({
					title: '提示',
					content: '确定要删除该文件吗？',
					cancelText: '取消',
					confirmText: '确定',
					success: res => {
						if (res.confirm) {
							this.assetFromData.file.splice(index,1)
						}
					}
				})
			},
			
			/* 上传文件 */
			uploadFile(e,inx) {
				let fileList = e.map(r => r.url)
				this.assetFromData.file = fileList
			},
			// 调查员同意
			async assetSurvey(){
				this.assetFromData.status = 1// 当前仅能同意，无其他处理
				this.assetFromData.id = this.getItem.id
				
				// if(this.assetFromData.enGuaranteeMeasures.includes('其他')&&!this.assetFromData.description){
				// 	return uni.showToast({title: '请输入其他反担保措施描述！',icon:'none'}) 
				// }
				if(await this.submitForm('surveyFrom')==false){
					return uni.showToast({title: '请输入必填项！',icon:'none'})
				}
				// 四个财产勾选赋值
				// this.house = ''
				
				// 处理驳回时的调查，有值的状态
				if(this.assetAccessory&&this.assetAccessory.length!==0){
					let len = this.assetAccessory.length
					this.assetAccessory.map(e=>{
						if(!this.assetFromData.file){
							this.assetFromData.file = []
						}
						this.assetFromData.file.push(e)
					})
				}
				if(!this.assetFromData.file||this.assetFromData.file.length===0){
					return uni.showToast({title: '请上传调查文件！',icon:'none'})
				}
				this.$http.post('/api-guarantee/dg-assets-investigation/investigateAssets',this.assetFromData).then(res=>{
					if(res.code === 10000){
						uni.showToast({
							title: '操作成功'
						})
						this.back()
					}
				})
			},
			
			// 领导操作
			assetAudit(type){
				this.assetAuditFrom.status = type
				// 获取角色权限，后面判断用
				let btnPermissionsStr = uni.getStorageSync('roleArr').split(',');
				if(type==1&&btnPermissionsStr.includes('64')){//领导传2
					this.assetAuditFrom.status = 2
				}
				this.assetAuditFrom.id= this.getItem.id
				// this.submitForm('assetAuditFrom')
				// this.submitForm('assetAuditFrom').then(res=>{
				this.assetAuditFrom.amount
				this.assetAuditFrom.term
				// 当处于同意时才触发
				if(type==1){
					if(!this.assetAuditFrom.amount)return uni.showToast({title: '请输入金额！',icon:'none'})
					if(!this.assetAuditFrom.term)return uni.showToast({title: '请选择期限！',icon:'none'})
				}
				if(type!=1&&!this.assetAuditFrom.applyContent){
					return uni.showToast({title: '拒绝/驳回时请输入审核意见！',icon:'none'})
				}
				
				if(type==4&&!this.assetAuditFrom.remark||type==4&&this.assetAuditFrom.remark.length===0){
					return uni.showToast({title: '驳回请选择补充调查原因！',icon:'none'})
				}
				// 审核内容，和担保选项
				if(!this.assetAuditFrom.applyContent||!this.assetAuditFrom.remark){
					this.assetAuditFrom.applyContent = ''
					// this.assetAuditFrom.otherRemark 
				}
				// 经理审核必传金额和期限--表单验证做校验
				// if(type==1){
				// 	if(!this.assetAuditFrom.amount)return uni.showToast({title: '请输入金额！',icon:'none'})
				// 	else if(!this.assetAuditFrom.term)return uni.showToast({title: '请输入期限！',icon:'none'})
				// }
				uni.showLoading({
					title:'加载中'
				})
				this.$http.post('/api-guarantee/dg-assets-investigation/approvalAssets',this.assetAuditFrom).then(res=>{
					// 领导审核的情况下，进行抄送炒作--小程序端抄送待完善
					if(btnPermissionsStr.includes('64')){
						setTimeout(()=>{
							uni.hideLoading()
							this.back()
						},1000)
					}else{							
						setTimeout(()=>{
							uni.hideLoading()
							this.back()
						},500)
					}
				// })
			})
				
			}
		}
	}
</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;
			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;
	}
	
	
	
	.checklist-group {
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		flex-direction: row;
		flex-wrap: wrap;
	}
	
	.checklist-box {
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		flex-direction: row;
		align-items: center;
		margin: 10rpx 0;
		margin-right: 50rpx;
	}
	
	.checklist-content {
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		flex: 1;
		flex-direction: row;
		align-items: center;
		justify-content: space-between;
	}
	
	.checklist-text {
		font-size: 28rpx;
		color: #333;
		margin-left: 10rpx;
		transition: color 0.2s;
	}
	
	.checkbox__inner {
		flex-shrink: 0;
		position: relative;
		border: 2rpx solid #DCDFE6;
		border-radius: 4rpx;
		box-sizing: border-box;
		width: 32rpx;
		height: 32rpx;
		background-color: #fff;
		z-index: 1;
		transition: border-color 0.1s;
	}
	
	.checkbox__inner-icon {
		border: 2rpx solid #fff;
		border-left: 0;
		border-top: 0;
		height: 16rpx;
		left: 10rpx;
		position: absolute;
		top: 2rpx;
		width: 6rpx;
		opacity: 0;
		transition: transform .2s;
		transform-origin: center;
		transform: rotate(40deg) scaleY(0.4);
	}
	.hidden {
		 /* #ifdef MP-ALIPAY */
		 display: none;
		 /* #endif */
	}
	/deep/ checkbox::before{
		border-radius: 32rpx;	
	}
	/deep/ radio::before{
		border-radius: 32rpx;
	}
	/deep/ .uni-data-checklist{
		width: 110%;
	}
	.label-audit{
		position: absolute;
		top: 1%;
		left: 0%;
	}
</style>
