<template>
	<view class="assignrbitrators">
		<view class="from">
			<uni-forms ref="form" :modelValue="formData" :rules="rules">
				<view class="title">案件详情</view>
				<view class="box">
					<uni-forms-item label="案件编号：" name="caseNum" label-width="120px" required>
						<uni-easyinput :inputBorder="false" :disabled='true' v-model="formData.caseNum" placeholder="" />
					</uni-forms-item>
					<uni-forms-item label="申请人：" name="applicantName" label-width="120px" required>
						<uni-easyinput :inputBorder="false" :disabled='true' v-model="formData.applicantName" placeholder="" />
					</uni-forms-item>
					<uni-forms-item label="被申请人：" name="respondentName" label-width="120px" required>
						<uni-easyinput :inputBorder="false" :disabled='true' v-model="formData.respondentName" placeholder="" />
					</uni-forms-item>
					<uni-forms-item label="借款开始日期：" name="loanStartDate" label-width="120px" required>
						<uni-easyinput :inputBorder="false" :disabled='true' v-model="formData.loanStartDate" placeholder="" />
					</uni-forms-item>
					<uni-forms-item label="借款结束日期：" name="loanEndDate" label-width="120px" required>
						<uni-easyinput :inputBorder="false" :disabled='true' v-model="formData.loanEndDate" placeholder="" />
					</uni-forms-item>
					<uni-forms-item label="案件标的：" name="caseSubjectAmount" label-width="120px" required>
						<uni-easyinput :inputBorder="false" :disabled='true' v-model="formData.caseSubjectAmount" placeholder="" />
					</uni-forms-item>
					<uni-forms-item label="申请人主张欠本金：" name="claimPrinciOwed" label-width="120px" required>
						<uni-easyinput :inputBorder="false" :disabled='true' v-model="formData.claimPrinciOwed" placeholder="" />
					</uni-forms-item>
					<uni-forms-item label="申请人主张欠利息：" name="claimInterestOwed" label-width="120px" required>
						<uni-easyinput :inputBorder="false" :disabled='true' v-model="formData.claimInterestOwed" placeholder="" />
					</uni-forms-item>
					<uni-forms-item label="申请人主张违约金：" name="claimLiquidDamag" label-width="120px" required>
						<uni-easyinput :inputBorder="false" :disabled='true' v-model="formData.claimLiquidDamag" placeholder="" />
					</uni-forms-item>
					<uni-forms-item label="上传证据" name="headImage" label-width="120px" required>
						<uni-file-picker  ref="files" :auto-upload="false" @select="select"  :limit='1'/>
					</uni-forms-item>
				</view>
			</uni-forms>
			<button type="primary" @click="submitImg">确认提交</button>
		</view>

	</view>
</template>

<script>
	import {respondentDetail} from '../../../api/handlecase/index.js'
	import { uploadImage } from '../../../api/upload.js'
	import { getToken } from '@/utils/auth'
	import moment from 'moment'
	const app = getApp()
	export default {
		data() {
			return {
				formData: {},
				tempFilePaths:null,
				rules: {},
				maintenancetypeArr:[{
					text: '是',
					value: 0
				}, {
					text: '否',
					value: 1
				},],
			}
		},
		methods: {
			maintenancetypeChange(val){
				// console.log(val,"PPPPPPPPPPPPPPPPPP");
			},
			getData(parms){
				respondentDetail(parms).then(res=>{
					this.formData = res.data
					this.formData.loanEndDate = moment(this.formData.loanEndDate).format('YYYY-MM-DD HH:mm:ss');
					this.formData.loanStartDate = moment(this.formData.loanStartDate).format('YYYY-MM-DD HH:mm:ss');
					this.formData.id = this.formData.id + ''
				})
			},
			// 文件上传
			select(e){
				this.tempFilePaths = e.tempFilePaths;
				// loading
			},
			submitImg(){
				uni.showLoading({
					title: '上传中'
				});
				uni.uploadFile({
					url:getApp().globalData.requestUrl + uploadImage,
					filePath: this.tempFilePaths[0],
					header:{
						Authorization:getToken() || '',
					},
					formData: {
						annexType:2,
						id:this.formData.id
					},
					name: 'file',
					success:(res) => {
						let { data } = res
						uni.showToast({
							title:'上传成功',
							icon:'none',
							duration:1000
						})
						uni.hideLoading();
					},
					fail:(err) => {
						uni.showToast({
							title:'上传失败',
							icon:'none',
							duration:1000
						})
						uni.hideLoading()
					}
				})
			}
		},
		onLoad(data){
			this.getData(data.id)
		},
	}
</script>

<style lang="scss">
	.assignrbitrators {
		// text-align: center;
		padding: 20rpx;

		.box {
			background-color: #fff;
			padding: 20rpx;
			border-radius: 20rpx;
		}

		.flexd {
			padding-top: 20rpx;

			.btn {
				width: 80%;
				font-size: 26rpx;
				border-radius: 60rpx;
			}
		}

		.btn {
			margin-top: 20rpx;
		}

		.select-picker {
			display: flex;
			box-sizing: border-box;
			flex-direction: row;
			align-items: center;
			border: 1px solid #DCDFE6;
			border-radius: 8rpx;
			width: 100%;
			height: 100%;
			padding: 0 24rpx;
			font-size: 28rpx;
		}

		.table-content {
			background-color: #fff;
			padding: 20rpx;
			border-radius: 20rpx;

			.none {
				font-size: 24rpx;
				height: 60rpx;
				line-height: 60rpx;
			}
		}

		.box {
			/deep/.title {
				font-size: 28rpx;
				height: 60rpx;
				line-height: 60rpx;
			}
		}

		.htmltitle {
			font-size: 30rpx;
			height: 80rpx;
			line-height: 80rpx;
			display: flex;
			justify-content: space-between;

			.look {
				color: #0D91F9;
			}
		}

		.title {
			font-size: 30rpx;
			height: 80rpx;
			line-height: 80rpx;
		}

		.adsTitle {
			font-size: 30rpx;
		}

		.multiple {
			width: 75%;
			height: 72rpx;
			line-height: 72rpx;
			font-size: 24rpx;
			// @include text-overflow($width: 100%)
		}
	}
</style>