index.vue 3.12 KB
<template>
	<div class="main">
		<div
			class="flowContent"
		>
			<flowNode :flowData="flowData" :flowState="flowState" v-if="flowShow"></flowNode>
			<ul class="legend">
				<li><span class="circle wjh"></span><span class="name">未激活</span></li>
				<li><span class="circle jh"></span><span class="name">激活</span></li>
				<li><span class="circle gq"></span><span class="name">挂起</span></li>
				<li><span class="circle wc"></span><span class="name">完成</span></li>
				<li><span class="circle zz"></span><span class="name">终止</span></li>
			</ul>
		</div>
	</div>
</template>

<script>
import { getActivityDetail,templateLoad,getProcessOutline } from "@api/user";
import flowNode from "./flownode"
export default {
	name: "",
	components: {flowNode},
	props: {},
	data() {
        return {
			flowData:{},
			flowShow:false,
			flowState:[]
        }
	},
	created() {},
	mounted() {
        this.getTemplate();
    },
	methods: {
        getTemplate(){
            let params = {
                "params": {},
                "workflowPeriod": "current",
                "workitemInstanceId": this.$route.query.workitemInstanceId
            }
            getActivityDetail(params).then((res) => {
                console.log(res.processInstance.templetId);
                templateLoad(res.processInstance.templetId).then((res1) => {
					console.log(this.$x2js.xml2js(res1).Process,'Process');
					getProcessOutline(res.processInstance.id).then((res2) => {
						this.flowData = this.$x2js.xml2js(res1).Process;
						console.log(res2.activityOutlines,'res.activityOutlines');
						this.flowState = res2.activityOutlines;
						this.$nextTick(()=>{
							this.flowData.Nodes.ManualNode.push(this.flowData.Nodes.EndNode);
							this.flowData.Nodes.ManualNode.unshift(this.flowData.Nodes.StartNode);
							// this.flowData.Nodes.StartNode.activityType = this.flowState.filter( i => i.activityTemplateId == this.flowData.Nodes.StartNode.id)[0].activityType;
							// this.flowData.Nodes.EndNode.activityType = this.flowState.filter( i => i.activityTemplateId == this.flowData.Nodes.EndNode.id)[0].activityType;
							this.flowData.Nodes.ManualNode.forEach(item => {
								item.activityState = this.flowState.filter( i => i.activityTemplateId == item.id)[0].activityState;
							});
							this.flowShow = true;
						})
					})
					.catch((error) => {});
                })
                .catch((error) => {});
				})
            .catch((error) => {});
        },
	},
	computed: {},
	watch: {},
};
</script>
<style scoped lang="less">
.main {
	position: relative;
	.flowContent {
		width: calc(100% + 6px);
		height: 100%;
		position: relative;
    	overflow-x: scroll;
	}
	.legend{
		position: absolute;
		top: 20px;
		right: 20px;
		li{
			margin-bottom: 10px;
			.circle{
				display: inline-block;
				width: 12px;
				height: 12px;
				border-radius: 6px;
			}
			.name{
				margin-left: 10px;
				font-weight: bold;
			}
			.wjh{
			background-color: #A9A9A9;
			}
			.jh{
			background-color: #449D44;
			}
			.gq{
			background-color: #F0AD4E;
			}
			.wc{
			background-color: #5BC0DE;
			}
			.zz{
			background-color: #F13F2F;
			}
		}
	}
}
</style>