<template>
	<view class="detail-view">
		<u-form label-width="150" :model="form" ref="uForm">
			<view class="form-model-view">
				<u-form-item label="退款单位">
					<view class="form-value">{{ detail_data.unitName }}</view>
				</u-form-item>
				<u-form-item label="业务类型">
					<view class="form-value">{{ detail_data.financeType }}</view>
				</u-form-item>
				<u-form-item label="所属店铺">
					<view class="form-value">{{ detail_data.shopName }}</view>
				</u-form-item>
				<u-form-item label="制单人">
					<view class="form-value">{{ detail_data.currentAccountName }}</view>
				</u-form-item>
				<u-form-item label="单据日期">
					<view class="form-value">{{ $u.timeFormat(detail_data.createTime, 'yyyy-mm-dd') }}</view>
				</u-form-item>
				<u-form-item label="单据状态">
					<view class="form-value">
						<text class="success-status" v-if="detail_data.auditStatus === 2">已审核</text>
						<text class="warning-status" v-else>待审核</text>
					</view>
				</u-form-item>
			</view>
			<view class="detail-ul">
				<view class="detail-li" v-for="(item,index) in detail_data.accountList" :key="index">
					<view class="other-ul">
						<view class="other-li">结算账户：{{ item.accountName || '--' }}</view>
						<!-- <view class="other-li">退款方式：{{ item.accountName||'--' }}</view> -->
						<view class="other-li">
							实际退款金额：
							<text class="money">{{ $utils.formattedNumber(item.money) }}</text>
						</view>
					</view>
					<view class="remark">备注：{{ item.remark || '无' }}</view>
				</view>
			</view>
		</u-form>
		<view class="detail-bottom" v-if="detail_data.auditStatus !== 2 && $accessCheck($Access.RefundFormupdateRefundStatus)">
			<view class="handel-btn" @click="openModel('确定要审核通过该退款单吗？', '审核')">审核</view>
		</view>
		<u-modal v-model="model_show" :show-cancel-button="true" :content="model_content" @confirm="modelConfirm" @cancel="modelCancel"></u-modal>
	</view>
</template>

<script>
export default {
	data() {
		return {
			model_tag: '',
			model_show: false,
			model_content: '',
			createTime: '',
			id: '',
			detail_data: []
		};
	},
	onLoad(options) {
		this.id = options.id;
		this.createTime = options.createTime;
	},
	onShow() {
		this.getRefundInfo();
	},
	onPullDownRefresh() {
		this.getRefundInfo();
	},
	methods: {
		getRefundInfo() {
			this.$u.api
				.getRefundInfo({
					id: this.id,
					createTime: this.createTime
				})
				.then(res => {
					this.detail_data = res.data;
				});
		},
		// 打开提示框
		openModel(content, tag) {
			this.model_content = content;
			this.model_show = true;
			this.model_tag = tag;
		},
		modelConfirm() {
			switch (this.model_tag) {
				case '审核':
					this.updateRefundStatus();
					break;
			}
		},
		updateRefundStatus() {
			this.$u.api
				.updateRefundStatus({
					id: this.id,
					createTime: this.detail_data.createTime
				})
				.then(res => {
					this.$u.toast('操作成功');
					this.getRefundInfo();
				});
		}
	}
};
</script>

<style lang="scss">
.detail-ul {
	.detail-li {
		width: 710rpx;
		margin: 20rpx auto;
		background-color: #ffffff;
		border-radius: 20rpx;
		padding: 20rpx 24rpx;
		.title {
			font-weight: bold;
		}
		.other-ul {
			// display: flex;
			padding-top: 20rpx;
			.other-li {
				// flex: 3;
				font-size: 24rpx;
				line-height: 40rpx;
				// text-align: center;
				.money {
					font-size: 28rpx;
					font-weight: bold;
					color: $uni-color-error;
				}
				&:first-child {
					text-align: left;
				}
				&:last-child {
					// text-align: right;
				}
			}
		}

		.remark {
			border-top: 1px solid #eeeeee;
			padding-top: 20rpx;
			margin-top: 20rpx;
		}
	}
}
</style>
