<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-item name="code" :label="fromData[0]&&fromData[0].name?fromData[0].name:'客户编号'">
				<uni-easyinput disabled="" type="text" :inputBorder="true" v-model="WorkDepartmentFrom.code" :placeholder="fromData[0]&&fromData[0].prompt?fromData[0].prompt:'请输入'"></uni-easyinput>
			</uni-forms-item>
			<uni-forms-item name="name" :label="fromData[1]&&fromData[1].name?fromData[1].name:'客户名称'">
				<uni-easyinput disabled type="text" :inputBorder="true" v-model="WorkDepartmentFrom.name" :placeholder="fromData[1]&&fromData[1].prompt?fromData[1].prompt:'客户名称'"></uni-easyinput>
			</uni-forms-item>
			<uni-forms-item name="time" :label="fromData[7]&&fromData[7].name?fromData[7].name:'法人代表'">
				<uni-easyinput disabled type="text" :inputBorder="true" v-model="WorkDepartmentFrom.legalName" :placeholder="fromData[7]&&fromData[7].prompt?fromData[7].prompt:'请输入'"></uni-easyinput>
			</uni-forms-item>
			<uni-forms-item name="phone" :label="fromData[2]&&fromData[2].name?fromData[2].name:'联系电话'">
				<uni-easyinput disabled type="text" :inputBorder="true" v-model="WorkDepartmentFrom.legalPhone" :placeholder="fromData[2]&&fromData[2].prompt?fromData[2].prompt:'联系电话'"></uni-easyinput>
			</uni-forms-item>
			<uni-forms-item name="time" :label="fromData[8]&&fromData[8].name?fromData[8].name:'联系人'">
				<uni-easyinput disabled type="text" :inputBorder="true" v-model="WorkDepartmentFrom.linkman" :placeholder="fromData[8]&&fromData[8].prompt?fromData[8].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="WorkDepartmentFrom.linkPhone" :placeholder="fromData[4]&&fromData[4].prompt?fromData[4].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="WorkDepartmentFrom.applyAmount" :placeholder="fromData[5]&&fromData[5].prompt?fromData[5].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="WorkDepartmentFrom.amountWide" :placeholder="fromData[3]&&fromData[3].prompt?fromData[3].prompt:'业务类别'"></uni-easyinput>
			</uni-forms-item>
			<uni-forms-item class="margin-top" name="phone" required :label="fromData[9]&&fromData[9].name?fromData[9].name:'参会评委'">
				<uni-easyinput disabled type="textarea" v-model="juryNames" :placeholder="fromData[9]&&fromData[9].prompt?fromData[9].prompt:'参会评委'"></uni-easyinput>
			</uni-forms-item>
			<uni-forms-item name="enGuaranteeMeasures" :label="fromData[6]&&fromData[6].name?fromData[6].name:'反担保措施'">
				<uni-data-checkbox multiple mode="list" v-model="WorkDepartmentFrom.enGuaranteeMeasure" :localdata="easuresList"></uni-data-checkbox>
			</uni-forms-item>
			<uni-forms-item name="name" label="反担保措施描述">
				<uni-easyinput disabled type="textarea" v-model="WorkDepartmentFrom.description" :placeholder="fromData[6]&&fromData[6].prompt?fromData[6].prompt:'反担保措施描述'"></uni-easyinput>
			</uni-forms-item>
			
			<uni-forms-item name="name" :label="fromData[10]&&fromData[10].name?fromData[10].name:'担保部A角审核意见'">
				<view class="audit-box radius">
					<text>{{WorkDepartmentFrom.aauditOpinion||''}}</text>
					<view class="mgt20">
						<view class="flex">
							<text>姓名:</text>
							<text class="mgl10">{{WorkDepartmentFrom.aname}}</text>
						</view>
						<view class="flex mgt20">
							<text>时间:</text>
							<text class="mgl10">{{WorkDepartmentFrom.aTime}}</text>
						</view>
					</view>
				</view>
			</uni-forms-item>
			<uni-forms-item name="name" :label="fromData[11]&&fromData[11].name?fromData[11].name:'担保部B角审核意见'">
				<view class="audit-box radius">
					<text>{{WorkDepartmentFrom.bauditOpinion||''}}</text>
					<view class="mgt20">
						<view class="flex">
							<text>姓名:</text>
							<text class="mgl10">{{WorkDepartmentFrom.bname}}</text>
						</view>
						<view class="flex mgt20">
							<text>时间:</text>
							<text class="mgl10">{{WorkDepartmentFrom.bTime}}</text>
						</view>
					</view>
				</view>
			</uni-forms-item>
			<uni-forms-item name="name" :label="fromData[12]&&fromData[12].name?fromData[12].name:'资产管理部审核意见'">
				<view class="audit-box radius">
					<text>{{WorkDepartmentFrom.assetAuditOpinion||''}}</text>
					<view class="mgt20">
						<view class="flex">
							<text>姓名:</text>
							<text class="mgl10">{{WorkDepartmentFrom.assetName}}</text>
						</view>
						<view class="flex mgt20">
							<text>时间:</text>
							<text class="mgl10">{{WorkDepartmentFrom.assetTime}}</text>
						</view>
					</view>
				</view>
			</uni-forms-item>
			<uni-forms-item name="name" :label="fromData[13]&&fromData[13].name?fromData[13].name:'信息服务部审核意见'">
				<view class="audit-box radius">
					<text>{{WorkDepartmentFrom.messageAuditOpinion||''}}</text>
					<view class="mgt20">
						<view class="flex">
							<text>姓名:</text>
							<text class="mgl10">{{WorkDepartmentFrom.messageName}}</text>
						</view>
						<view class="flex mgt20">
							<text>时间:</text>
							<text class="mgl10">{{WorkDepartmentFrom.messageTime}}</text>
						</view>
					</view>
				</view>
			</uni-forms-item>
			<uni-forms-item name="name" :label="fromData[14]&&fromData[14].name?fromData[14].name:'法规监督部审核意见'">
				<view class="audit-box radius">
					<text>{{WorkDepartmentFrom.regulationAuditOpinion||''}}</text>
					<view class="mgt20">
						<view class="flex">
							<text>姓名:</text>
							<text class="mgl10">{{WorkDepartmentFrom.regulationName}}</text>
						</view>
						<view class="flex mgt20">
							<text>时间:</text>
							<text class="mgl10">{{WorkDepartmentFrom.regulationTime}}</text>
						</view>
					</view>
				</view>
			</uni-forms-item>
		</uni-forms>
				
		<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-item name="name" required label="贷审会议定事项">
				<uni-easyinput :disabled="handle=='watch'" type="textarea" v-model="loansAuditFrom.agreedItems" placeholder="议定事项"></uni-easyinput>
			</uni-forms-item>
			<uni-forms-item name="name" required label="贷审会附加事项">
				<uni-easyinput :disabled="handle=='watch'" type="textarea" v-model="loansAuditFrom.additionalItems" placeholder="附加事项"></uni-easyinput>
			</uni-forms-item>
			<uni-forms-item name="name" required label="贷审会意见">
				<view class="audit-box radius ">
					<text style="display: inline;">为了控制公司担保集中代偿的风险，以及公司担保贷款转换的需要，同意该笔</text>
					<!-- <input class="wd10" type="text" v-model="loansAuditFrom.loanMoney" /> -->
					<uni-easyinput :disabled="handle=='watch'"  class="small-input" type="digit" :inputBorder="true" v-model="loansAuditFrom.loanMoney" placeholder="金额"></uni-easyinput>
					<text style="display: inline;">万元贷款担保，期限</text>
					<picker :disabled="handle=='watch'"  class="small-checkbox" mode="selector" :range="timelimitDatas" range-key="label" :value="loansAuditFrom.loanTern" @change="loansTime" @cancel="applyTimeCencle">
						<view class="picker-view flex-between" :style="handle=='watch'?'background-color:#eee':''">
							<text>{{loansAuditFrom.loanTern ? loansAuditFrom.loanTern : '期限'}}</text>
							<text class="cuIcon-unfold lg text-gray"></text>
						</view>
					</picker> 
				</view>
			</uni-forms-item>
			<uni-forms-item name="name" required label="贷审会日期">
				<picker v-if="handle!=='watch'" mode="date" :value="loansAuditFrom.passingTime" @change="relatedtimeChange">
					<view class="picker-view flex-between">
						<text>{{loansAuditFrom.passingTime ? loansAuditFrom.passingTime : '请选择'}}</text>
						<text class="cuIcon-unfold lg text-gray"></text>
					</view>
				</picker>
				<uni-easyinput v-if="handle=='watch'" disabled type="text" :inputBorder="true" v-model="loansAuditFrom.passingTime" placeholder="请输入"></uni-easyinput>
			</uni-forms-item>
			<uni-forms-item name="name" required label="参会委员意见">
				<text class="jury-text">同意</text>
				<view class="check-jury margin-tb-sm">
					<view class="more-select" @tap="handle!='watch'?pass = true:pass = false">
						<text class="" >{{passInfo || "请选择同意的委员"}}</text>
					</view>
				</view>
				<text class="jury-text margin-top">拒绝</text>
				<view class="check-jury margin-tb-sm">
					<view class="more-select" @tap="handle!='watch'? nopass = true : nopass = false">
						<text class="" >{{nopassInfo || "请选择拒绝的委员"}}</text>
					</view>	
				</view>
			</uni-forms-item>
			<!-- 上传会议纪要 -->
			<view class="cu-bar bg-white">
				<view class="action">
					<text class="is-required">*</text>
					<text class="label-color">上传会议纪要</text>
				</view>
			</view>
			<view class="cu-form-group">
				<upload  @upload="uploadFile" :files="filesArray" :handle="handle!=='watch'"></upload>
			</view>
		</uni-forms>
		<view class="bottom-border" v-if="handle==='audit'||handle=='watch'&&roleManage||handle=='watch'&&roleLeader">
			<view class="left-border"><text class="mgl10">审核意见</text></view>
			<uni-easyinput type="textarea" v-model="loansAuditFrom.refuseOpinion" placeholder="请输入审核意见"></uni-easyinput>
		</view>
		<view class="foot-btn btn-rig pad-bt">
			<button plain class="mini-btn round plain-btn" type="primary" size="mini" @tap="back()">返回</button>
			<!-- 领导 -->
			<button v-if="handle==='audit'" class="mini-btn round suc-btn mar-lr" type="primary" size="mini" @tap="loansAudit(1)">同意</button>
			<button v-if="handle==='audit'" class="mini-btn round ref-btn mar-lr" type="primary" size="mini" @tap="loansAudit(3)">拒绝</button>
			<button v-if="handle==='audit'" class="mini-btn round cancel-btn mar-lr" type="primary" size="mini" @tap="loansAudit(2)">驳回</button>
		</view>
		
		<timeline></timeline>
		<!-- 参会委员同意调起下方选择框 -->
		<multiple-select
			v-model="pass"
			:data="passDatas"
			:default-selected="passSelected"
			@confirm="passJury()"
		></multiple-select>
		<!-- 参会委员拒绝 -->
		
		<multiple-select
			v-model="nopass"
			:data="noPassDatas"
			:default-selected="nopassSelected"
			@confirm="nopassJury()"
		></multiple-select>
	</view>
</template>

<script>
	import upload from '../../../components/pretty-uploadFile/pretty-uploadFile.vue'
	import utils from '@/components/evan-form/utils.js'
	const CONTACT_INFO={
		name:'',
		phone:'',
		duty:''
	}
	export default {
		components: {
			upload
		},
		data() {
			return {
				EvaluationList: [{
					text: '房产',
					value: '0',
					InputValue: ''
				},
				{
					text: '车辆',
					value: '1',
					InputValue: ''
				},
				{
					text: '设备',
					value: '2',
					InputValue: ''
				},
				{
					text: '其他',
					value: '3',
					InputValue: ''
				}],//评估价值列表
				employeeMsg: [{
					name: '个人',
					value: '3'
				},
				{
					name: '企业',
					value: '4'
				}],//客户经理列表
				genderList: [{
					text: '男',
					value: 1
				},
				{
					text: '女',
					value: 0
				}],//性别列表
				easuresList: [{
					text: '第三方保证',
					value: '第三方保证',
					disabled:true
				},
				{
					text: '抵押',
					value: '抵押',
					disabled:true
				},
				{
					text: '个人无限责任连带',
					value: '个人无限责任连带',
					disabled:true
				},
				{
					text: '质押',
					value: '质押',
					disabled:true
				}],
				imgList: [],
				maritalList: ['未婚','已婚','离异','再婚'],//婚姻状况列表
				educationList: ['本科','大专','高职','中专','其他'],//学历列表
				isExistList: [{
					text: '否',
					value: 0
				},
				{
					text: '是',
					value: 1
				}],//是否存在关联人列表
				manager: '',
				enterpriseFrom: {
					maritalStatus: 0,//婚姻状况
					gender: 1,//性别
					education: 0, //学历
					legalGender: 1, //关联人性别
					isExistRelated: 0, //是否存在关联人
					enGuaranteeMeasures: ''
				},//个人form
				enterpriseForm: {},//企业form
				hideRequiredAsterisk: false,
				// 表单的内容必须初始化
				info: {
					name: '',
					email: '',
					desc: '',
					phone: '',
					sex: '',
				},
				rules: {},
				info2:{
					name:'',
					email:'',
					phone:''
				},
				rules2:{},
				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的方式传递并且去除两边的斜杠，中间的斜杠变成两个斜杠
				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个月' },
				],
				// 展示表单
				WorkDepartmentFrom:{
					enGuaranteeMeasure:[],
				},
				
				pass:false,// 触发选择委员
				nopass:false,// 触发选择委员
				
				nopassInfo:'',// 贷审会意见--拒绝委员
				passInfo:'',// 同意委员
				
				juryArrs:[],// 备份委员---还原选项组的委员
				
				passDatas:[],// 同意选项组
				noPassDatas:[],// 拒绝选项组
				
				loansAuditFrom:{
					passingTime:''
				},// 贷审会审议表单
				
				handle:'',// 操作状态
				getItem:{},// 获取列表传值
				
				passSelected:[],// 委员通过勾选项---用于审议选择是否同意的委员，进行组件的双向绑定勾选
				nopassSelected:[],// 委员拒绝项
				
				juryNames:"",// 展示评委名称
				
				filesArray:[],
				
				fromData:[],// 表单值
				
			}
		},
		destroyed() {// 销毁组件操作
			uni.removeStorageSync('handleGe')
			uni.removeStorageSync('applyMsg')
			uni.removeStorageSync('copyData')
		},
		async created() { 
			// 判断来自待处理否
			if(uni.getStorageSync('decideIndex')){
				let data = JSON.parse(uni.getStorageSync('decideIndex'))
				this.getItem.iid = data.detailId
				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.getItem.businessId = data.businessId
			}else{
				this.handle = uni.getStorageSync('handleGe')// 取得操作状态
				if(uni.getStorageSync('applyMsg')){ // 取得传参,取得ID等
					this.getItem = JSON.parse(uni.getStorageSync('applyMsg')) 
					this.businessId = this.getItem.businessId
				}
			}
			// 判断操作禁用
			if(this.handle==='survey'){// 处于调查时
				
			}else{// 非调查时
				this.loansJudge(this.getItem.id)
			}
			// 基础信息
			await this.workOpinion()
			// 贷审会信息
			this.loansDetail()
			this.designFrom()
		},
		mounted() {
			// 这里必须放在mounted中，不然h5，支付宝小程序等会找不到this.$refs.form
			this.$refs.form.setRules(this.rules)
		},
		methods: {
			designFrom(){// 表单数据接口
				this.$http.get('/api-guarantee/form/design/list',{
					processId: 7
				}).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;
				}
			},
			relatedtimeChange(e) {
				this.loansAuditFrom.passingTime = e.detail.value
			},
			// 选择委员赋值
			passJury(data) {
				let arr = data.map(e=>{
					return e.value
				})
				// 重新赋值拒绝的值，然后把已选中的重新勾选？
				
				// 1，根据已有的同意的值---去删除 拒绝的选项
				// 2，删除拒绝前，需要重新赋值拒绝的值（因为可能会有取消同意）
				// 3，执行删除操作后，把已有的值重新勾选
				
				// 4，首次删除已有的值---成功去掉了对面的值
				// 5，反过来删除时：需要先赋值，然后删除己方的值，然后给对面勾选他已选中的值
				this.noPassDatas = JSON.parse(JSON.stringify(this.juryArrs))
				let len = data.length
				// 根据选中的同意，删除对应的拒绝选项
				for(let i=0;i<len;i++){
					// 此时的nopass是全部的值，定位的下标失去准确度
					let num = this.noPassDatas.findIndex((e)=>{return e.value == data[i].value})
					if(num!==-1){
						this.noPassDatas.splice(num,1)
					}
				}
				// 记录当前被勾选中的值
				this.passSelected = data.map(e=>e.value)
				this.passInfo = arr.join(",")
			},
			// 首先：选中的值--删除对应的同意值选项
			
			// 拒绝委员赋值
			nopassJury(data) {
				let arr = data.map(e=>{
					return e.value
				})
				// 重新赋值同意的选项
				this.passDatas = JSON.parse(JSON.stringify(this.juryArrs))
				let len = data.length
				// 选中的拒绝--删除对应的同意
				// 
				for(let i=0;i<len;i++){
					let num = this.passDatas.findIndex((e)=>{return e.value == data[i].value})
					if(num!==-1){
						this.passDatas.splice(num,1)
					}
				}
				
				this.nopassSelected = data.map(e=>e.value)
				
				this.nopassInfo = arr.join(",")
			},
			loansTime(e){// 贷审会意见--期限选择赋值
				this.$set(this.loansAuditFrom,'loanTern',this.timelimitDatas[+e.detail.value].value)	
			},
			applyTimeCencle(e){// 申请期限取消赋值
				this.$set(this.loansAuditFrom,'loanTern','')
			},
			//客户类型选择
			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)
						}
					}
				})
			},
			ChooseImage() {
				uni.chooseImage({
					count: 4, //默认9
					sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图，默认二者都有
					sourceType: ['album'], //从相册选择
					success: (res) => {
						if (this.imgList.length != 0) {
							this.imgList = this.imgList.concat(res.tempFilePaths)
						} else {
							this.imgList = res.tempFilePaths
						}
					}
				});
			},
			// 贷审会-查看
			loansDetail(id){
				this.$http.get('/api-guarantee/committee/consider/query',{id:this.getItem.id}).then(res=>{
					let data = res.data
					// 查看时才进行复制
					if(this.handle!=='audit'){
						this.$set(this.loansAuditFrom,'agreedItems',data.agreedItems)
						this.$set(this.loansAuditFrom,'additionalItems',data.additionalItems)
						this.$set(this.loansAuditFrom,'loanMoney',data.loanMoney)
						this.$set(this.loansAuditFrom,'loanTern',data.loanTern)
						this.passSelected = data.agreePersons // 评委同意拒绝赋值
						this.passInfo = this.passSelected.join()
						this.nopassSelected = data.disagreePersons
						this.nopassInfo = this.nopassSelected.join()
						this.$set(this.loansAuditFrom,'passingTime',data.time)
					}
						this.loansAuditFrom.fileUrls = data.fileUrls // 文件--上传的赋值
						this.handleFiles(data.fileUrls)
					// this.$set(this.loansAuditFrom,'agreedItems',data.agreedItems)
				})
			},
			// 贷审会-获取抽取的评委
			loansJudge(id,type){
				return this.$http.get('/api-guarantee/committee/consider/theJudgesDrawn',{id:id}).then(res=>{
					if(res.success){
						this.juryNames = res.data.join()
						let arr = []
						res.data.map(e=>{
							let obj = {}
							obj.label = e
							obj.value = e
							arr.push(obj)
						})
						this.juryArrs = arr// 备份起来
						this.passDatas = arr
						this.noPassDatas = arr
					}
				})
			},
			// 贷审会--审议--同意
			async testSuccess(val){
				// 重新赋值拒绝的值
				await this.loansJudge(this.getItem.id,2)
				let len = val.length
				// 根据选中的同意，删除对应的拒绝选项
				for(let i=0;i<len;i++){
					if(this.noPassDatas.indexOf(val[i])!==-1){
						this.noPassDatas.splice(this.noPassDatas.indexOf(val[i]),1)
					}
				}
			},
			// 贷审会--审议--拒绝
			async testFull(val){
				// 重新赋值同意的选项
				await this.loansJudge(this.getItem.id,1)
				let len = val.length
				// 选中的拒绝--删除对应的同意
				for(let i=0;i<len;i++){
					if(this.passDatas.indexOf(val[i])!==-1){
						this.passDatas.splice(this.passDatas.indexOf(val[i]),1)
					}
				}
			},
			
			// 贷审会-审议
			loansAudit(type){
				// status: 操作,1:通过,2:拒绝,3:驳回
				this.loansAuditFrom.status = type
				this.loansAuditFrom.id = this.getItem.id
				// 拒绝驳回--展示审核意见框
				if(type===2&&!this.loansAuditFrom.refuseOpinion||type===3&&!this.loansAuditFrom.refuseOpinion){
					return  uni.showToast({
						title:'请输入审核意见！',icon:'none'
					})
				}
				if(type===1){
					if(!this.loansAuditFrom.loanMoney||!this.loansAuditFrom.loanTern){
						return uni.showToast({
							title:'请输入金额和期限！',icon:'none'
						})
					}
					if(!this.loansAuditFrom.fileUrls||this.loansAuditFrom.fileUrls&&!this.loansAuditFrom.fileUrls.length===0){
						return uni.showToast({
							title:'请上传会议纪要！',icon:'none'
						})
					}
					if(!this.loansAuditFrom.agreedItems||!this.loansAuditFrom.additionalItems){
						return uni.showToast({
							title:'请输入贷审会议定事项与贷审会附加事项！',icon:'none'
						})
					}
					if(this.nopassSelected.length===0&&this.passSelected.length===0){
						return uni.showToast({
							title:'请选择同意或拒绝的委员意见！',icon:'none'
						})
					}
					if(this.nopassSelected.length+this.passSelected.length!==this.juryArrs.length){
						return uni.showToast({
							title:'请把委员投票选完！',icon:'none'
						})
					}
				}
				
				this.loansAuditFrom.agreePersons = this.passSelected  //同意
				this.loansAuditFrom.disagreePersons = this.nopassSelected//拒绝
				this.$http.post('/api-guarantee/committee/consider/check',this.loansAuditFrom).then(res=>{
					uni.showToast({
						title:'操作成功！'
					})
					setTimeout(()=>{
						this.back()
					},500)
				}).catch(err=>{
	
				})
			},
			
			workDetail(id){// 工作会-查看详情
				this.$http.get('/api-guarantee/work/conference/query',{id:this.getItem.id}).then(res=>{
					// if(res.code===10000){
					this.$set(this.workAuditFrom,'empNames',res.data.joinJudges)
					this.$set(this.workAuditFrom,'opinion',res.data.remark)
					// }
				})
			},
			/* 上传文件 */
			uploadFile(e) {
				let fileList = e.map(r => r.url)
				this.loansAuditFrom.fileUrls = fileList
			},
			// 传入对应的index
			handleFiles(data){
				if(!data||!data.length) return
				data.map(e=>{
					if(e=='') return
					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)
				})
			},
			 // 工作会-所有审核意见
			workOpinion(){
				// this.businessId = id
				// sessionStorage.setItem('work-detail',id)
				this.$http.get('/api-guarantee/work/conference/getAuditOpinion',{businessId:this.getItem.businessId}).then(res=>{
					if(res.success){
						let data = res.data
						this.$set(this.WorkDepartmentFrom,'aTime',data.aTime)
						this.$set(this.WorkDepartmentFrom,'aauditOpinion',data.aauditOpinion)
						this.$set(this.WorkDepartmentFrom,'aname',data.aname)
						this.$set(this.WorkDepartmentFrom,'bTime',data.bTime)
						this.$set(this.WorkDepartmentFrom,'bauditOpinion',data.bauditOpinion)
						this.$set(this.WorkDepartmentFrom,'bname',data.bname)
						this.$set(this.WorkDepartmentFrom,'assetTime',data.assetTime)
						this.$set(this.WorkDepartmentFrom,'assetName',data.assetName)
						this.$set(this.WorkDepartmentFrom,'assetAuditOpinion',data.assetAuditOpinion)
						this.$set(this.WorkDepartmentFrom,'messageName',data.messageName)
						this.$set(this.WorkDepartmentFrom,'messageTime',data.messageTime)
						this.$set(this.WorkDepartmentFrom,'messageAuditOpinion',data.messageAuditOpinion)
						this.$set(this.WorkDepartmentFrom,'regulationAuditOpinion',data.regulationAuditOpinion)
						this.$set(this.WorkDepartmentFrom,'regulationName',data.regulationName)
						this.$set(this.WorkDepartmentFrom,'regulationTime',data.regulationTime)
						// 上为审核意见
						this.$set(this.WorkDepartmentFrom,'code',res.data.dgBusinessCompany.code)
						this.$set(this.WorkDepartmentFrom,'name',res.data.dgBusinessCompany.name)
						this.$set(this.WorkDepartmentFrom,'applyAmount',res.data.dgApplyAmountInfo.applyAmount)
						this.$set(this.WorkDepartmentFrom,'applyTime',res.data.dgApplyAmountInfo.applyTime)
						this.$set(this.WorkDepartmentFrom,'amountWide',res.data.dgApplyAmountInfo.amountWide)
						
						this.$set(this.WorkDepartmentFrom,'enGuaranteeMeasure',res.data.dgApplyAmountInfo.enGuaranteeMeasure)
						
						this.$set(this.WorkDepartmentFrom,'description',res.data.dgApplyAmountInfo.description)
						// 还有法人信息，联系电话，关联人电话没有匹配
						this.$set(this.WorkDepartmentFrom,'legalName',data.dgBusinessCompany.legalName)
						this.$set(this.WorkDepartmentFrom,'linkman',data.dgBusinessCompany.linkman)
						this.$set(this.WorkDepartmentFrom,'legalPhone',data.dgBusinessCompany.legalPhone)
						this.$set(this.WorkDepartmentFrom,'linkPhone',data.dgBusinessCompany.linkPhone)
					}
				})
			},
		}
	}
</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);
	}
	.audit-box{
		padding: 15rpx 15rpx;
		margin-left: 99rpx;
		width: 392rpx;
		min-height: 120rpx;
		border: 1rpx solid #e5e5e5;
		// background-color: #eee;
		border-radius: 35rpx;
		
	}
	.small-input{
		display: inline-block;
		width: 65%;
		// padding-left: 30rpx;
		/deep/ .uni-easyinput{
			margin-left: 0;
			width: 90%;
		}
		/deep/ .uni-easyinput__content{
			min-height: 60rpx;
			margin-bottom: 5rpx;
			margin-top: 5rpx;
		}
	}
	.small-checkbox{
		display: inline-block;
		width: 60%;
		.picker-view{
			width: 99%;
			margin-left: 1%;
			min-height: 60rpx;
		}
	}
	.check-jury{
		width: 392rpx;
		min-height: 50rpx;
		margin-left: 99rpx;
		border: 1rpx solid #e5e5e5;
		border-radius: 35rpx;
		background-color: #eee;
		
		.more-select{
			
			text-align: center;
			width: 100%;
			line-height: 50rpx;
		}
		
	}
	.pass-warp{
		padding: 15rpx 15rpx;
		margin-left: 99rpx;
		width: 392rpx;
		min-height: 80rpx;
		border: 1rpx solid #e5e5e5;
		border-radius: 35rpx;
	}
	.jury-text{
		margin-left: 99rpx;
		margin-top: 5rpx;
	}
</style>
