audit_detail.vue 2.58 KB
<template>
	<view class="page">
		<view class="fixed">
			<view class="tabs" :class="[`${tab === 'base' ? 'bg1' : 'bg2'}`]">
				<view :class="['tab', { active: tab === 'base' }]" @click="tab = 'base'">基础信息</view>
				<view :class="['tab', { active: tab === 'flow' }]" @click="tab = 'flow'">流程</view>
			</view>
		</view>
		<view class="body">
			<view v-if="tab === 'base'">
				<component :is="componentName" :id="auditCtx.businessId" ref="basicRef" />
			</view>
			<view v-else>
				<FlowTimeline :nodeList="nodeList" :isEnd="isEnd" />
			</view>
		</view>
	</view>
</template>
<script>
import FlowTimeline from '@/components/flow-timeline/index.vue'
import { getSysFlowComponentPath } from '@/utils/flow-components.js'
import { getFlowLinkByInstanceIdApi } from '@/api/flow.js'
export default {
	components: {
		FlowTimeline
	},
	data() {
		return {
			tab: 'base',
			auditCtx: {
				taskId: '',
				instanceId: '',
				businessId: '',
				bizFlag: ''
			},
			isEnd: false, // 流程是否结束
			nodeList: []
		}
	},
	computed: {
		componentName() {
			const name = getSysFlowComponentPath(this.auditCtx.bizFlag || '')
			return name || ''
		}
	},
	onLoad() {
		const CACHE_KEY = 'FLOW_AUDIT_CACHE'
		const cache = uni.getStorageSync(CACHE_KEY) || {};
		console.log('审核详情__cache', cache)
		this.auditCtx = cache;
		if (this.auditCtx && this.auditCtx.instanceId) {
			this.loadFlowLinkByInstanceId(this.auditCtx.instanceId)
		}
	},
	methods: {
		loadFlowLinkByInstanceId(instanceId) {
			getFlowLinkByInstanceIdApi({ instanceId }).then(res => {
				console.log('审核__loadFlowLinkByInstanceId', res)
				const _data = res && res.data ? res.data : {};
				this.nodeList = _data.nodeList || [];
				this.isEnd = _data.end || false;
			}).catch(() => { })
		},
	}
}
</script>
<style lang="scss" scoped>
.page {
	display: flex;
	flex-direction: column;
	height: 100vh
}

.fixed {
	position: fixed;
	top: 96rpx;
	left: 0;
	right: 0;
	z-index: 2;

	.tabs {
		display: flex;
		align-items: center;
		height: 96rpx;

		&.bg1 {
			background-image: url('/static/images/flow/tab_1_icon.png');
			background-repeat: no-repeat;
			background-position: right center;
			background-size: cover;
		}

		&.bg2 {
			background-image: url('/static/images/flow/tab_2_icon.png');
			background-repeat: no-repeat;
			background-position: right center;
			background-size: cover;
		}

		.tab {
			width: 50%;
			height: 96rpx;
			line-height: 96rpx;
			text-align: center;
			font-weight: 600;
			color: rgba(0, 0, 0, 0.9);

			&.active {
				color: $theme-primary;
			}
		}
	}
}

.body {
	flex: 1;
	padding-top: 104rpx;
}
</style>