<!-- 行政资产 -->
<template>
	<view class="travel-expense" v-show="isShow">
		<view class="travel-top">		
			<administrative :ExpenseBill="ExpenseBill" v-if="pageType=='401101'" @showImg="showImg"/>
			<bigPay :ExpenseBill="ExpenseBill" v-else-if="pageType=='401302'" @showImg="showImg"/>
			<budget :ExpenseBill="ExpenseBill" v-else-if="pageType=='401204'" @showImg="showImg"/>
			<checkRecipients :ExpenseBill="ExpenseBill" v-else-if="pageType=='401303'" @showImg="showImg"/>
			<engineering :ExpenseBill="ExpenseBill" v-else-if="pageType=='401203'" @showImg="showImg"/>
			<fixedAssets :ExpenseBill="ExpenseBill" v-else-if="pageType=='401205'" @showImg="showImg"/>
			<getPayment :ExpenseBill="ExpenseBill" v-else-if="pageType=='401304'" @showImg="showImg"/>
			<internalTransfer :ExpenseBill="ExpenseBill" v-else-if="pageType=='401301'" @showImg="showImg"/>
			<officialEntertaining :ExpenseBill="ExpenseBill" v-else-if="pageType=='401102'" @showImg="showImg"/>
			<publicTransportation :ExpenseBill="ExpenseBill" v-else-if="pageType=='401207'" @showImg="showImg"/>
			<reimbursement :ExpenseBill="ExpenseBill" v-else-if="pageType=='401201'" @click="clickGetSubscribefee" @showImg="showImg"/>
			<travelExcessive :ExpenseBill="ExpenseBill" v-else-if="pageType=='401206'" @showImg="showImg"/>
			<travelExpense :ExpenseBill="ExpenseBill" v-else-if="pageType=='401202'" @showImg="showImg"/>
		
			<view class="button-box" v-if="ExpenseBill.NOWSTAFF_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>
		
		<block v-if="pageType=='401207'|| pageType=='401206' || pageType=='401202'">
			<view class="base-info">
				<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.ExpenseDetail" :key="item.EXPENSEDETAIL_ID" :item="item" :cardType="pageType=='401202' ? 1: 2"/>
					</div>
				</div>
			</view>
			
			<view class="base-info" v-if="ExpenseBill.OtherCostDetail && ExpenseBill.OtherCostDetail.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 ">
							<view class="uni-flex trip-subsidies" v-for="item in ExpenseBill.OtherCostDetail" :key="item.EXPENSEDETAIL_ID" style="align-items: center;" >
								<span style="flex:2;">{{item.OTHER_COST}}</span>
									
								<view class="uni-flex" style="flex:1;align-items: center;justify-content: flex-end;">
									
									<i v-if="item.OTHERBILL_COUNT!==''" class="ico ico-pj"></i>
									<span style="padding-left:8rpx;">{{item.OTHERBILL_COUNT}}</span>
									<text class="span24">张</text>
								</view>
								<view v-if="item.OTHERBILL_COUNT!==''" style="flex:2;color: #ec8538;text-align: right;"><text>￥{{item.OTHERBILL_AMOUNT}}</text></view>
							</view>
						</view>
					</div>
				</div>
			</view>
		</block>
		<!-- 审批流程 -->
		<view class="base-info" v-if="ExpenseBill.RejectApproved && ExpenseBill.RejectApproved.length>0">
			<div class="uni-list-cell uni-collapse">
				<div class="cat-box uni-list-cell-navigate" >
					<b>驳回意见</b>
				</div>
				<div class="process-box uni-collapse-content uni-active">
					<processUnit :item=" ExpenseBill.RejectApproved[0]" :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="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">
					<processUnit v-for="item in ExpenseBill.ApprovedList" :item="item" :key="item.APPROVED_DATE" :approveType='1' />
				</div>
			</div>
		</view>
		<popUp :show="showPopupMiddle" :msg="preSubscribefeeMap[showId].ACCEPT_TYPE == '401101'?'行政资产申购':'公务接待'" @hidePopup="closePop" type="middle">
			
			<div style="width: 600rpx;margin-top: 40rpx;" v-if="preSubscribefeeMap[showId].ACCEPT_TYPE=='401101'">
		
					<div class="span24 uni-flex ai-top" style="aligin-items:flex-start; margin-bottom: 12rpx;">
						<text style="color:#888;">申请部门：</text>
						<text class="lie_right">{{preSubscribefeeMap[showId].DEPARTMENT_NAME}}</text>
						
					</div>
					<div class="span24 uni-flex ai-top" style="aligin-items:flex-start; margin-bottom: 12rpx;">
						<text style="color:#888;min-width:120rpx;">申&nbsp;&nbsp;请&nbsp;人：</text>
						<text class="lie_right">{{preSubscribefeeMap[showId].APPLY_PERSON}}</text>
						
					</div>
					<div class="span24 uni-flex ai-top" style="margin-bottom: 12rpx;">
						<text style="color:#888;min-width:120rpx;">申请日期：</text>
						<text class="lie_right">{{preSubscribefeeMap[showId].APPLY_DATE}}</text>
						
					</div>
					<div class="span24 uni-flex ai-top" style="margin-bottom: 12rpx;">
						<text style="color:#888;min-width:120rpx;">申请理由：</text>
						<text class="lie_right">{{preSubscribefeeMap[showId].APPLY_INFO}}</text>
						
					</div>
					<div class="span24 uni-flex ai-top" style="margin-bottom: 12rpx;">
						<text style="color:#888;min-width:120rpx;">品&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;名：</text>
						<text class="lie_right">{{preSubscribefeeMap[showId].COMMODITY_NAME}}</text>
						
					</div>
					<div class="span24 uni-flex ai-top" style="margin-bottom: 12rpx;">
						<text style="color:#888;min-width:120rpx;">规&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;格：</text>
						<text class="lie_right">{{preSubscribefeeMap[showId].COMMODITY_RULE}}</text>
						
					</div>
					<div class="span24 uni-flex ai-top" style="margin-bottom: 12rpx;">
						<text style="color:#888;min-width:120rpx;">预计费用：</text>
						<text class="lie_right">{{preSubscribefeeMap[showId].BUDGET_PRICE}}</text>
					
					</div>
					<div class="span24 uni-flex ai-top" style="margin-bottom: 12rpx;">
						<text style="color:#888;min-width:120rpx;">其它要求：</text>
						<text class="lie_right">{{preSubscribefeeMap[showId].APPLY_OTHER}}</text>
						
					</div>
				
			</div>
			<div style="width: 600rpx;margin-top: 40rpx;" v-else>
				<div class="span24 uni-flex ai-top" style="margin-bottom: 12rpx;">
					<text style="color:#888;min-width:120rpx;">来宾单位：</text>
					<text class="lie_right">{{preSubscribefeeMap[showId].DEPARTMENT_NAME}}</text>
				
				</div>
				<div class="span24 uni-flex ai-top" style="margin-bottom: 12rpx;">
					<text style="color:#888;min-width:120rpx;">来宾时间：</text>
					<text class="lie_right">{{preSubscribefeeMap[showId].VISITOR_DATE}}</text>
				
				</div>
				<div class="span24 uni-flex ai-top" style="margin-bottom: 12rpx;">
					<text style="color:#888;min-width:120rpx;">来宾人数：</text>
					<text class="lie_right">{{preSubscribefeeMap[showId].VISITOR_PERSONS}}</text>
				
				</div>
				<div class="span24 uni-flex ai-top" style="margin-bottom: 12rpx;">
					<text style="color:#888;min-width:120rpx;">经办人：</text>
					<text class="lie_right">{{preSubscribefeeMap[showId].APPLY_STAFF}}</text>
				
				</div>
				<div class="span24 uni-flex ai-top" style="margin-bottom: 12rpx;">
					<text style="color:#888;min-width:120rpx;">陪同人数：</text>
					<text class="lie_right">{{preSubscribefeeMap[showId].ACCOMPANY_PERSON}}</text>
			
				</div>
				<div class="span24 uni-flex ai-top" style="margin-bottom: 12rpx;">
					<text style="color:#888;min-width:120rpx;" >拟定饭店及标准：</text>
					<text class="lie_right" style="width:60%">{{preSubscribefeeMap[showId].HOTEL_INFO}}</text>
				
				</div>
				
			</div>
		</popUp>
	</view>
</template>

<script>
	import { mapGetters } from 'vuex'
	import filesUnit from '@/components/filesComponent/fileUnit.vue'
	import processUnit from '@/components/auditingProcess/item.vue'
	import popUp from '@/components/uni-popup.vue'
	import administrative from './components/administrative.vue'
	import bigPay from './components/bigPay.vue'
	import budget from './components/budget.vue'
	import checkRecipients from './components/checkRecipients.vue'
	import engineering from './components/engineering.vue'
	import fixedAssets from './components/fixedAssets.vue'
	import getPayment from './components/getPayment.vue'
	import internalTransfer from './components/internalTransfer.vue'
	import officialEntertaining from './components/officialEntertaining.vue'
	import publicTransportation from './components/publicTransportation.vue'
	import reimbursement from './components/reimbursement.vue'
	import travelExpense from './components/travelExpense.vue'
	import travelExcessive from './components/travelExcessive.vue'
	
	export default {
		
		data() {
		
			return {
				pageType: '',
				imageUrls: [],
				isShow: false,
				ExpenseBill: {},
				ApprovedList: [], // 审核流程
				cardShow: true, // 控制折叠面板
				cardShow2: true, // 控制折叠面板
				preSubscribefeeMap: {}, // 公务接待
				showId: ''  ,// 公务接待
				showPopupMiddle: false
			};
		},
		components: {
			filesUnit,
			processUnit,
			popUp,
			administrative,
			bigPay,
			budget,
			checkRecipients,
			engineering,
			fixedAssets,
			getPayment,
			internalTransfer,
			officialEntertaining,
			publicTransportation,
			reimbursement,
			travelExpense,
			travelExcessive
	
		},
		computed: {
			...mapGetters({'users':'getUser'}),
	
		},
		methods: {
			clickGetSubscribefee(id) {
				this.showId = id
				this.showPopupMiddle = true
			
			},
			closePop(){
				this.showPopupMiddle = false
			},
			// 图片预览
			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=3000&PROINST_ID='+_this.ExpenseBill.FINANCEPROINST_ID+'&NOWACTINST_ID='+_this.ExpenseBill.NOWACTDEF_IDS
						break;
					case 2000:
							url = '/pages/auditingPop/toExamine?businessType=3000&PROINST_ID='+_this.ExpenseBill.FINANCEPROINST_ID+'&NOWACTINST_ID='+_this.ExpenseBill.NOWACTDEF_IDS+'&ApproName='+_this.ExpenseBill.ApproName+'&ACCEPT_TYPE='+_this.ExpenseBill.ACCEPT_TYPE+'&NeedApproved='+_this.ExpenseBill.NeedApproved

						break;
					case 3000:
							url = '/pages/auditingPop/reject?businessType=3000&PROINST_ID='+_this.ExpenseBill.FINANCEPROINST_ID+'&NOWACTINST_ID='+_this.ExpenseBill.NOWACTDEF_IDS+'&ACCEPT_TYPE='+_this.ExpenseBill.ACCEPT_TYPE
						break;
					
				}
				this.$util.toNextRoute('navigateTo', url)
			},
			// 获取页面数据
			getData(_id) {
				let _this =this
				this.$request.$get('GetFinanceFlowDetail',{
					FINANCEPROINST_ID: _id  //业务内码
				
				}).then(res => {
					if(!res.ResultCode ||res.ResultCode!='100'){
						_this.isShow = false
						uni.hideLoading()
						return
					}
					
					let _data = res.Data
					
					_data.BUDGET_PRICE = _data.ExpenseBill.BUDGET_PRICE
					_data.PAYMENT_LOWER = _data.ExpenseBill.PAYMENT_LOWER
					_data.CONTRACT_TOTALAMOUNT = _data.ExpenseBill.PAYMENT_LOWER
					_data.PERPAID_TOTALAMOUNT = _data.ExpenseBill.PERPAID_TOTALAMOUNT
					if(_data.FileList){
						
						_data.FileList.map(v => {
							let name= v.ATTACHMENT_NAME.split('.')
							v.type = name[name.length-1]
							v.name = v.ATTACHMENT_NAME
							v.path = v.ATTACHMENT_URL
						})
					}
					let arr = []
					if(_data.ImageList){
						
						_data.ImageList.map(v => {
							arr.push(v.IMAGE_URL)
						})
					}
					_this.imageUrls = arr
					let  preSubscribefeeMap = {}
					if(_data.PreSubscribefeeList) {
						
						_data.PreSubscribefeeList.map(u=>{
							preSubscribefeeMap[u.FINANCEPROINST_ID] = u
						})
						_this.preSubscribefeeMap = preSubscribefeeMap
					}
					 
					_this.ExpenseBill = _data || {}
					
					_this.$forceUpdate()
					
					setTimeout(function(){
						uni.hideLoading()
						_this.isShow  = true
						_this.isLoading  = false
					},500)
					
				})
			},
			setTitle() {
				let pageName = ''
				let pageType = parseInt(this.pageType)
				switch (pageType) {
					// 行政资产申请
					case 401101:
						pageName = '行政资产申请'
						break;
					//大额支付审批
					case 401302:
						pageName = '大额支付审批'
						break;
					// 经费预算申请
					case 401204: 
						pageName = '经费预算申请'
						break;
					// 支票领用审批
					case 401303:
						pageName = '支票领用审批'
						break;
					// 工程款支付
					case 401203:
						pageName = '工程款支付'
						break;
					// 固定资产处理
					case 401205:
						pageName = '固定资产处理'
						break;
					// 领付款申请
					case 401304:
						pageName = '领付款申请'
						break;
					// 内部转账审批
					case 401301:
						pageName = '内部转账审批'
						break;
					// 公务接待审批
					case 401102:
						pageName = '公务接待审批'
						break;
					// 公务交通费用
					case 401207:
						pageName = '公务交通费用'
						break;
					// 费用报销审批
					case 401201: 
						pageName = '费用报销审批'
						break
					// 差旅费超标准
					case 401206:
						pageName = '差旅费超标准'
						break;
					// 差旅费报销
					case 401202:
						pageName = '差旅费报销'
						break
				}
				uni.setNavigationBarTitle({
					title: pageName,
					// complete(res) {
					// 	console.log(res)
					// }
				})
			}
		},
		
		onLoad(option) {
			let _this = this
			uni.showLoading({
				title:'正在加载'
			})
			
			this.isLoading = true
			this.pageType = option.type
			this.getData(option.id)
			
			uni.$on('3000', function (data){
				
				if(data) {
					uni.showLoading({
						title:'正在加载'
					})
					_this.isShow = false
					
					_this.isLoading = true
					_this.getData(_this.ExpenseBill.FINANCEPROINST_ID)
					
				}
			});
		},
		onReady() {
		
			this.setTitle()
			
		},
		onUnload() {
			this.$util.addUserBehavior()
			uni.$off('3000');
		},
		onHide() {
			
		}
	}
</script>

<style scoped>
	@import url("/common/css/expensesTop.css");
	.trip-detail {
		border: 1rpx solid rgb(234, 234, 234);
		box-shadow: 0px 1rpx 8rpx rgb(234, 234, 234);
		border-radius: 14rpx;
		margin-bottom: 20rpx;
		margin-left: 30rpx;
		margin-right: 30rpx;
		padding: 20rpx 24rpx 20rpx 24rpx;
	}
	.trip-subsidies + .trip-subsidies {
	
		margin-top: 16rpx;
		padding-top: 16rpx;
		border-top: 2rpx dashed rgb(234, 234, 234);
	}
	
	.trip-subsidies span {
		font-size: 24rpx;
	}
</style>
