<!-- 差旅费报销 -->
<template>
	<view class="travel-expense" v-show="isShow">
		<view class="travel-top">
			<fundAppropriation :ExpenseBill="ExpenseBill" v-if="pageType=='4000'" @showImg="showImg"/>
			<paymentApproval :ExpenseBill="ExpenseBill" v-else-if="pageType=='2000'" @showImg="showImg"/>
			<reimbursement :ExpenseBill="ExpenseBill" v-else-if="pageType=='3000'" @showImg="showImg"/>
			<travelExpense :ExpenseBill="ExpenseBill" v-else-if="pageType=='1000'" @showImg="showImg"/>

			<view class="button-box" v-if="ExpenseBill.USER_ID == users.UserId">
				<span @tap="showPop(4000)"><image src="/static/images/yj-btn.png" mode="aspectFit"></image> 移交 </span>
				<span @tap="showPop(2000)"><image src="/static/images/sh-btn.png" mode="aspectFit"></image> 审核 </span>
				<span @tap="showPop(3000)" v-if="ExpenseBill.CAN_REJECT===1"><image src="/static/images/bh-btn.png" mode="aspectFit"></image> 驳回</span>
			</view>

		</view>

		<view class="base-info"  v-if="pageType=='1000' &&  ExpenseBill.BillDetailList &&  ExpenseBill.BillDetailList.length>0">
			<div class="uni-list-cell uni-collapse">
				<div class="cat-box uni-list-cell-navigate" :class="cardShow ? ' uni-navigate-bottom' : 'uni-navigate-right'" @tap="cardShow =!cardShow">
					<b>行程详情</b>
				</div>
				<div class="process-box uni-collapse-content" :class="cardShow ? 'uni-active' : ''" v-show="cardShow">
					<travelCard  v-for="item in ExpenseBill.BillDetailList" :key="item.EXPENSEDETAIL_ID" :item="item" />

				</div>
			</div>
		</view>
		<view class="base-info" v-if="pageType=='1000' &&  ExpenseBill.OtherCostList && ExpenseBill.OtherCostList.length>0">
			<div class="uni-list-cell uni-collapse">
				<div class="cat-box uni-list-cell-navigate" :class="cardShow2 ? ' uni-navigate-bottom' : 'uni-navigate-right'" @tap="cardShow2 =!cardShow2">
					<b>其他费用</b>
				</div>
				<div class="process-box uni-collapse-content" :class="cardShow2 ? 'uni-active' : ''" v-show="cardShow2">
					<view class="trip-detail uni-flex" v-for="item in ExpenseBill.OtherCostList" :key="item.EXPENSEDETAIL_ID" style="align-items: center;" >

						<span style="flex:1;">{{item.OTHER_COST}}</span>

						<view class="uni-flex" style="flex:1;align-items: center;">

							<i v-if="item.OTHERBILL_COUNT!==''" class="ico ico-pj"></i>
							<span style="padding-left:8upx;">{{item.OTHERBILL_COUNT}}</span>
							<text class="span24">张</text>
						</view>

						<view v-if="item.OTHERBILL_COUNT!==''" style="flex:1;color: #ec8538;text-align: right;"><text>￥{{item.OTHERBILL_AMOUNT}}</text></view>

					</view>
				</div>
			</div>
		</view>
		<view class="base-info" v-if="pageType=='3000'">
			<div class="uni-list-cell uni-collapse">
				<div class="cat-box uni-list-cell-navigate" :class="cardShow1 ? ' uni-navigate-bottom' : 'uni-navigate-right'" @tap="cardShow1 =!cardShow1">
					<b>报销详情</b>
				</div>
				<div class="process-box uni-collapse-content" :class="cardShow1 ? 'uni-active' : ''" v-show="cardShow">

					<view class="trip_detail" v-for="item in ExpenseBill.BillDetailList" :key="item.EXPENSEBILL_ID">
						<view class="trip-detail-top">
							<view class="uni-flex" style="justify-content: space-between;align-items: center;">
								<text class="trip-date">{{$util.cutDate(item.EXPENSEDETAIL_DATE,'YYYY-MM-DD')}}</text>
								<div>
									<image src="/static/images/expense/pj.png" mode="aspectFit" style="width: 30upx;height: 24upx;margin-right: 8upx;"></image>
									<text >{{item.EXPENSEDETAIL_COUNT}}</text>
									<text class="span24"> 张</text>
								</div>
								<text class="trip-price" style="color:#ec8538;">￥{{$util.fmoney(item.EXPENSEDETAIL_AMOUNT,2)}}</text>
							</view>
						</view>
						<view class="trip-subsidies" v-if="item.EXPENSE_DETAIL || item.EXPENSEDETAIL_DESC">

							<view style="line-height:1.6;" v-if="item.EXPENSE_DETAIL"><text class="text-title">报销内容：</text><text>{{item.EXPENSE_DETAIL}}</text></view>
							<view style="line-height:1.6;" v-if="item.EXPENSEDETAIL_DESC"><text class="text-title">备注说明：</text><text>{{item.EXPENSEDETAIL_DESC}}</text></view>

						</view>
					</view>

				</div>
			</div>
		</view>
		<!-- 审批流程 -->
		<view class="base-info" v-if="ExpenseBill.RejectList && ExpenseBill.RejectList.length>0">
			<div class="uni-list-cell uni-collapse">
				<div class="cat-box uni-list-cell-navigate" :class="cardShow4 ? ' uni-navigate-bottom' : 'uni-navigate-right'" @tap="cardShow4 =!cardShow4">
					<b>驳回意见</b>
				</div>
				<div class="process-box uni-collapse-content" :class="cardShow4 ? 'uni-active' : ''" v-show="cardShow4">
					<processUnit v-for="item in ExpenseBill.RejectList" :item="item" :key="item.APPROVED_DATE" :approveType='0' />
				</div>
			</div>
		</view>
		<view class="base-info" v-if="ExpenseBill.ApprovedList && ExpenseBill.ApprovedList.length > 0">
			<div class="uni-list-cell uni-collapse">
				<div class="cat-box uni-list-cell-navigate" :class="cardShow3 ? ' uni-navigate-bottom' : 'uni-navigate-right'" @tap="cardShow3 =!cardShow3">
					<b>审批流程</b>
				</div>
				<div class="process-box uni-collapse-content" :class="cardShow3 ? 'uni-active' : ''" v-show="cardShow3">
					<processUnit v-for="item in ExpenseBill.ApprovedList" :item="item" :key="item.APPROVED_DATE" :approveType='1' />
				</div>
			</div>
		</view>

	</view>
</template>

<script>
	import {mapGetters} from 'vuex'
	import processUnit from '@/components/auditingProcess/item.vue'
	import fundAppropriation from './components/fundAppropriation.vue'
	import travelCard from './components/travelCard/travelCard.vue'
	import paymentApproval from './components/paymentApproval.vue'
	import reimbursement from './components/reimbursement.vue'
	import travelExpense from './components/travelExpense.vue'


	export default {

		data() {

			return {
				pageType: '',
				imageUrls:[],
				doUser: false,
				isShow: false,
				ExpenseBill: {},
				cardShow1: true,
				cardShow: true, // 控制折叠面板
				cardShow2: true,
				cardShow3: true,
				cardShow4: true,

			};
		},
		components: {
			travelCard,
			processUnit,
			fundAppropriation,
			paymentApproval,
			reimbursement,
			travelExpense
		},
		computed: {
			...mapGetters({'users':'getUser'}),

		},
		methods: {
			// 图片预览
			showImg(index) {
				uni.previewImage({
					urls: this.imageUrls,
					current: index,
					loop: true,
					indicator: 'number'
				});
			},

			showPop(type) {
				let _this = this
				let url = ''
				switch (type) {
					case 4000:
							url = '/pages/auditingPop/transfer?businessType=5000&PROINST_ID='+_this.ExpenseBill.HIGHWAYPROINST_ID+'&NOWACTINST_ID='+_this.ExpenseBill.NOWACTINST_ID

						break;
					case 2000:
							url = '/pages/auditingPop/toExamine?businessType=5000&PROINST_ID='+_this.ExpenseBill.HIGHWAYPROINST_ID+'&NOWACTINST_ID='+_this.ExpenseBill.NOWACTINST_ID+'&ApproName='+_this.ExpenseBill.ACTINST_NAME+'&NeedApproved='+_this.ExpenseBill.NeedApproved

						break;
					case 3000:
							url = '/pages/auditingPop/reject?businessType=5000&PROINST_ID='+_this.ExpenseBill.HIGHWAYPROINST_ID+'&NOWACTINST_ID='+_this.ExpenseBill.NOWACTINST_ID

						break;

				}
				this.$util.toNextRoute('navigateTo', url)
			},

			// 获取页面数据
			getData(_id) {
				let _this =this
				this.$request.$get('GetFinanceExpenseDetail',{
					action_data: _this.users.UserId,
					HighWayProinstId: _id, //业务内码

				}).then(res => {
					if(!res.ResultCode ||res.ResultCode!='100'){
						_this.isShow = false
					}

					let _data = res.Data
					if(_data.FileList){

						_data.FileList.map(v => {
							let name= v.ATTACHMENT_DESC.split('.')
							v.type = name[name.length-1]
							v.name = v.ATTACHMENT_DESC
							v.path = v.ATTACHMENT_URL
						})
					}

					let arr = []
					if(_data.ImgList){

						_data.ImgList.map(v => {
							arr.push(v.IMAGE_URL)
						})
					}

					_this.imageUrls = arr

					if (_this.ExpenseBill.USER_ID == _this.users.UserId) { // 该用户是当前详情处理人

						_this.doUser = true
					}
					_this.ExpenseBill = _data || {};



					uni.hideLoading()
					setTimeout(function(){

						_this.isShow  = true
						_this.isLoading  = false
					},500)
					_this.$forceUpdate()
				})
			},
			setTitle() {
				let pageName = ''
				let pageType = parseInt(this.pageType)
				switch (pageType) {
					// 差旅费报销
					case 1000:
						pageName = '差旅费报销'
						break;
					// 付款报销
					case 2000:
						pageName = '付款报销'
						break;
					// 费用报销审批
					case 3000:
						pageName = '费用报销审批'
						break;
					// 资金拨付
					case 4000:
						pageName = '资金拨付'
						break;

				}
				uni.setNavigationBarTitle({
					title: pageName,
					// complete(res) {
					// 	console.log(res)
					// }
				})
			}
		},
		onReady() {
			this.setTitle()
		},
		onLoad(option) {
			let _this = this
			uni.showLoading({
				title:'正在加载'
			})
			this.pageType = option.type
			this.isLoading =true
			this.getData(option.id)
			
			uni.$on('5000', function (data){
				if(data) {
					uni.showLoading({
						title:'正在加载'
					})
					_this.isShow  = false
					_this.isLoading  = true
					_this.getData(_this.ExpenseBill.HIGHWAYPROINST_ID)
			
				}
			});
		},
		onShow() {
			
		},
		onUnload() {
			this.$util.addUserBehavior()
			uni.$off('5000');
		},
		onHide() {
		}
	}
</script>

<style scoped>
	@import url("/common/css/expensesTop.css");
	//.ico-big::before {
	//	width: 40upx;
	//	height: 40upx;
	//	margin-right: 0;
	//	vertical-align: top;
	//}
	//
	//.ico-rs1::before{
	//	vertical-align: unset;
	//}
	//
	//.ico-big2::before {
	//	width: 60upx;
	//	height: 60upx;
	//}

	.uni-list-cell:after {
		height: 0;
	}

	.base-info {
		margin-top: 30upx;
	}

	.trip-detail {
		border: 1px solid rgb(234, 234, 234);
		box-shadow: 0px 1px 8px rgb(234, 234, 234);
		border-radius: 7px;
		margin-bottom: 20upx;
		margin-left: 30upx;
		margin-right: 30upx;
		padding: 20upx 24upx 20upx 24upx;
	}
	.trip-subsidies {
		display: flex;
		justify-content: space-between;
		margin-top: 16upx;
		/* margin-bottom: 20upx; */
		border-top: 1upx dashed rgb(234, 234, 234);
	}

	.trip-subsidies span {
		font-size: 24upx;
	}

	/* 费用报销 报销详情 */
	.trip_detail {
		border: 2upx solid rgb(234, 234, 234);
		box-shadow: 0px 1px 8px rgb(234, 234, 234);
		border-radius: 7px;
		margin-bottom: 20upx;
		margin-left: 30upx;
		margin-right: 30upx;
		padding: 20upx 24upx 20upx 24upx;
	}

	//.trip_detail_top {
	//	width: 100%;
	//	box-sizing: border-box;
	//}
	//

	.trip-date {
		font-size: 24upx;
	}
	.trip-price {
		color: #6cc09c;
		font-size: 30upx;
	}


	//.trip_person {
	//	display: flex;
	//}
	//
	//.trip_person div {
	//	display: flex;
	//	align-items: center;
	//}
	//
	//
	//.trip_person span {
	//	padding: 0 12upx;
	//	padding-left: 0;
	//}
	//
	.trip-subsidies {
		margin-top: 16upx;
		padding-top: 16upx;

		border-top: 2upx dashed rgb(234, 234, 234);
	}

	.trip-subsidies text {
		font-size: 24upx;
	}

</style>
