<template>
	<view>
		<view class="" v-if="!loading && approvalInfo.PERMISSIONAPPLY_ID">
			<view v-if="pageData.type=='4'">
				<ShopApproval :businessId="pageData.id" :data="approvalInfo" ref="shop" @refresh="reload"
					:approvalData="approvalData" />
			</view>
			<view v-if="pageData.type=='7'">
				<ShopChangeState :businessId="pageData.id" :data="approvalInfo" ref="shop" @refresh="reload"
					:approvalData="approvalData" />
			</view>
			<view v-if="pageData.type=='8'">
				<MerchartInfoView :businessId="pageData.id" :data="approvalInfo" ref="shop" @refresh="reload"
					:approvalData="approvalData" />
			</view>
		</view>
		<noFound v-show="!loading && !approvalInfo.PERMISSIONAPPLY_ID" :nodata="true" text="抱歉,没有找到该数据" />
	</view>
</template>

<script>
	import ShopApproval from './components/shopApproval.vue'
	import ShopChangeState from './components/shopChangeState.vue'
	import MerchartInfoView from './components/merchartInfoView.vue'
	export default {
		data() {
			return {
				pageData: {
					type: null,
					id: null
				},
				loading: true,
				approvalInfo: {},
				approvalData: {} // 审批后授权的列表
			}
		},
		components: {
			ShopApproval,
			ShopChangeState,
			MerchartInfoView
		},
		methods: {
			getDetail(opt) {
				let _this = this
				this.$request.$webGet('/EShangApiMain/Platform/GetPermissionApplyDetail?permissionApplyid=' + opt.id).then(
					res => {
						uni.hideLoading()
						_this.loading = false

						if (res.Result_Code !== 100) {
							return
						}
						_this.approvalInfo = res.Result_Data
						if ( ['4','8'].indexOf(_this.pageData.type)>-1) {
							_this.$nextTick(()=>{
								
							_this.$refs['shop'].getShops(res.Result_Data)
							})
						}
						_this.getDetailList({
							id: opt.id,
							type: res.Result_Data.PERMISSIONAPPLY_TYPE
						})
					})
			},
			getDetailList(obj) {
				let _this = this
				this.$request.$webGet('/EShangApiMain/BusinessProcess/GetPermissionApplyDetailList?permissionApplyid=' +
					obj.id + '&PermissionApplyType=' + obj.type).then(res => {
					uni.hideLoading()
					if (res.Result_Code !== 100) {
						return
					}
					_this.approvalData = res.Result_Data

				})
			},
			reload() {

				this.getDetail(this.pageData)
				this.getDetailList(this.pageData)
			}
		},
		onLoad(option) {
			uni.showLoading()
			this.pageData = option
			this.loading = true
			this.getDetail(option)
			this.$forceUpdate()
		}
	}
</script>

<style>

</style>
