<template>
	<view class="list">
		<view class="listItem">
			<view class="lable">
				案件编号：
			</view>
			<view class="main">
				{{defalutVal.caseNum}}
			</view>
		</view>
		<view class="listItem" v-if="sysType == 1">
			<view class="lable">
				申请人：
			</view>
			<view class="main">
				{{defalutVal.applicantName}}
			</view>
		</view>
		<view class="listItem" v-if="sysType == 2">
			<view class="lable">
				申请人：
			</view>
			<uni-tooltip :content="defalutVal.applicationName">
			<view class="textHidden">
				{{defalutVal.applicationName}}	 
			</view>
			</uni-tooltip>
		</view>
		<view class="listItem" style="margin-top:22rpx">
			<view class="lable">
				被申请人：
			</view>
			<uni-tooltip :content="defalutVal.respondentName">
			<view class="textHidden">
				{{defalutVal.respondentName}}
			</view>
			</uni-tooltip>
		</view>
		<view class="listItem">
			<view class="lable">
				案件状态：
			</view>
			<view class="main">
				{{defalutVal.caseStatusName}}
			</view>
		</view>
		<view class="btn" v-if="sysType == 2">
			<button class="btnItem" type="primary" size="mini" @tap="modify"
				v-if="checkPermi(['caseManagement:list:edit']) && defalutVal.caseFlowId <= 1">修改</button>
			<button class="btnItem" type="primary" size="mini" @tap="deleteCase"
				v-if="checkPermi(['caseManagement:list:delete']) && defalutVal.caseFlowId <= 1">删除</button>
			<!-- <button class="btnItem" type="primary" size="mini" @tap="clickPay">申请人缴费</button>
			<button class="btnItem" type="primary" size="mini" @tap="caseDetail">选择调解员</button> -->
			<button class="btnItem" type="primary" @tap="clickType(item.id)" size="mini" v-for="(item) in buttonList"
				:key="item.id"
				v-if="item.id == defalutVal.caseFlowId && checkPermi([item.buttonAuthFlag])&& (defalutVal.appOperatorFlag == 1 || defalutVal.resOperatorFlag == 1 || defalutVal.otherFlag == 1)">{{ item.nodeName }}</button>
			<!-- <button class="btnItem" type="primary" size="mini" @tap="confirmationEvidence">确认证据</button>
			<button class="btnItem" type="primary" size="mini" @tap="isAssignrbitrators">是否指派仲裁员</button>
			<button class="btnItem" type="primary" size="mini" @tap="isAssignrbitrators">是否指派仲裁员</button>
			<button class="btnItem" type="primary" size="mini" @tap="chooseMethod">选择仲裁方式</button> -->
		</view>
		<view class="btn" v-if="sysType == 1">
			<button class="btnItem" type="primary" size="mini" @tap="caseCrossExamin">案件质证</button>
		</view>
	</view>
</template>

<script>
	import {
		queryCaseFlowInfo,
		caseAppSubmit,
		caseDelete,
		msCaseSign
	} from '@/api/handlecase/index.js'
	export default {
		data() {
			return {

			}
		},
		props: {
			defalutVal: {
				type: Object,
				default: () => {}
			},
			sysType: {
				type: Number,
				default: () => {}
			},
			buttonList: {
				type: Array,
				default: () => {}
			}
		},
		methods: {
			/**点击列表按钮*/
			clickType(type) {
				if (type == 1) {
					// 提交案件
					this.onsubmitRow()
				} else if (type == 2) {
					// 缴费
					this.clickPay(4)
				} else if (type == 3 || type == 45) {
					this.confirmPayments()
					// 确认缴费
				} else if (type == 4) {
					// 受理分配
				} else if (type == 5) {
					// 选择调解员
					this.caseDetail()
				} else if (type == 6) {
					// 核实调解员
				} else if (type == 7) {
					// 确认调解员
				} else if (type == 8) {
					// 确定调解时间
				} else if (type == 9) {
					// 调解
				} else if (type == 10) {
					// 确认调解书
				} else if (type == 11) {
					// 签名
				} else if (type == 12) {
					// 用印申请
				} else if (type == 13) {
					// 用印
				} else if (type == 14) {
					// 归档
				} else if (type == 15) {
					// 申请人签收
					this.signMediation();
				} else if (type == 16) {
					// 被申请人签收
					this.receivedMediation();
				} else if (type == 17) {
					//结束
				} else if (type == 44) {
					// 被申请人缴费
					this.clickPay(9)
				}
			},
			// 案件质证
			caseCrossExamin(){
				uni.navigateTo({
					url:`/pages/handlecase/component/uploadEvidence?id=${this.defalutVal.id}`
				})
			},
			// 案件详情以及操作
			caseDetail() {
				uni.navigateTo({
					url: `/pages/handlecase/component/uploadEvidence?id=${this.defalutVal.id}`
				})
			},
			// 缴费
			clickPay(type) {
				uni.navigateTo({
					url: `/pages/handlecase/component/payList?id=${this.defalutVal.id}&type=${type}`
				})
			},
			// 确认缴费
			confirmPayments() {
				uni.navigateTo({
					url: `/pages/handlecase/component/confirmPayment?id=${this.defalutVal.id}&caseFlowId=${this.defalutVal.caseFlowId}`
				})
			},
			/**提交案件*/
			onsubmitRow() {
				let onsubmitVal = {
					id: this.defalutVal.id,
					batchNumber: "",
					caseFlowId: this.defalutVal.caseFlowId
				}
				uni.showModal({
					title: '提示',
					content: '您确定要提交案件',
					success: function(res) {
						if (res.confirm) {
							// console.log('用户点击确定');
							caseAppSubmit(onsubmitVal).then(res => {
								uni.showToast({
									title: '提交成功',
									icon: 'none',
									duration: 1000
								})
								uni.navigateTo({
									url: '/pages/handlecase/index'
								})
							})
						} else if (res.cancel) {
							// console.log('用户点击取消');
						}
					}
				});
			},
			// 修改
			modify() {
				uni.navigateTo({
					url: `/pages/handlecase/component/newlyAddedCase?id=${this.defalutVal.id}`,
				})
			},
			/*删除*/
			deleteCase() {
				let objValue = {
					id: this.defalutVal.id,
					batchNumber: "",
					caseFlowId: this.defalutVal.caseFlowId
				}
				uni.showModal({
					title: '提示',
					content: '您确定要删除案件',
					success: function(res) {
						if (res.confirm) {
							// console.log('用户点击确定');
							caseDelete(objValue).then(res => {
								uni.showToast({
									title: '删除成功',
									icon: 'none',
									duration: 1000
								})
								uni.navigateTo({
									url: '/pages/handlecase/index'
								})
							})
						} else if (res.cancel) {
							// console.log('用户点击取消');
						}
					}
				});

			},
			/**申请人签收*/
			signMediation() {
				let that = this;
				let objValue = {
					caseId: this.defalutVal.id,
					isSignApply: 1
				}
				uni.showModal({
					title: '提示',
					content: '您确定要签收',
					success: function(res) {
						if (res.confirm) {
							that.signingMediationAgreement(objValue)
						} else if (res.cancel) {
							// console.log('用户点击取消');
						}
					}
				});
			},
			/**被申请人签收*/
			receivedMediation() {
				let that = this;
				let objValue = {
					caseId: this.defalutVal.id,
					isSignRespon: 1
				}
				uni.showModal({
					title: '提示',
					content: '您确定要签收',
					success: function(res) {
						if (res.confirm) {
							that.signingMediationAgreement(objValue)
						} else if (res.cancel) {
							// console.log('用户点击取消');
						}
					}
				});
			},
			/**申请人和被申请人签收调解书接口*/
			signingMediationAgreement(val) {
				msCaseSign(val).then((res) => {
					uni.showToast({
						title: '签收成功',
						icon: 'none',
						duration: 1000
					})
					uni.navigateTo({
						url: '/pages/handlecase/index'
					})
				});
			},
		},
		created() {}
	}
</script>

<style lang="scss" scoped>
	.list {
		padding: 15rpx;
		display: flex;
		flex-direction: column;
		background-color: #ffffff;
		border-radius: 30rpx;
		margin-top: 20rpx;

		.listItem {
			width: 100%;
			display: flex;
			height: 50rpx;

			.lable {
				width: 30%;
			}

			.main {
				width: 60%;
			}

		}

		.btn {
			margin-top: 20rpx;
			width: 100%;
			display: flex;
			justify-content: space-between;
			flex-wrap: wrap;

			.btnItem {
				height: 50rpx;
				background-color: #5395ff;
				border-radius: 10rpx;
				text-align: center;
				line-height: 50rpx;
			}
		}
	}
	.textHidden{	
		width: 300rpx;
		text-overflow: ellipsis;
		overflow: hidden;
		white-space: nowrap;
	}
</style>