<template>
    <view>
        <cu-custom bgColor="bg-gradual-blueness" :isBack="true">
            <block slot="backText">返回</block>
            <block slot="content">动火作业流程图</block>
        </cu-custom>
        <view class="form">
            <uni-steps :options="varList" direction="column" :active="active"></uni-steps>
        </view>
        <view class="cu-bar btn-group" style="margin-top: 30upx;">
            <button class="cu-btn bg-green margin-tb-sm lg" @click="$noMultipleClicks(goback)">返回
            </button>
        </view>

    </view>
</template>

<script>
    import {
        basePath,
        corpinfoId,
        loginUser,
        loginSession,
        formatDate,
        loginUserId
    } from '@/common/tool.js';
    export default {
        data() {
            return {
                msg: 'add',
                noClick: true,
                HOTWORKAPPLICATION_ID: '',
				varList:[],
				active:0
            }
        },
        onLoad(event) {
			this.HOTWORKAPPLICATION_ID = event.id
            loginSession();
            this.getData();
        },
        methods: {
            getData() {
                var _this = this;
                uni.showLoading({
                    title: '请稍候'
                })
                uni.request({
                    url: basePath + '/app/hotworkapplication/showFlowChart',
                    method: 'POST',
                    header: {
                        'Content-type': 'application/x-www-form-urlencoded'
                    },
                    data: {
                        FOREIGN_KEY: _this.HOTWORKAPPLICATION_ID,
                    },
                    success: (res) => {
                        if ("success" == res.data.result) {
							var list = []
							var active = 0
							if(res.data.varList != null && res.data.varList.length > 0){
								
								for(var i = 0; i < res.data.varList.length; i++){
									var userName = res.data.varList[i].USER_NAME || res.data.varList[i].SPECIAL_USER_NAME || res.data.varList[i].REGULATORY_USER_NAME
									res.data.varList[i].title = res.data.varList[i].NAME + ':'+ userName
									if(res.data.varList[i].TYPE != '-1'){
										res.data.varList[i].desc = res.data.varList[i].OPERATTIME
									} else{
										res.data.varList[i].desc = '待操作'
									}
									// res.data.varList[i].desc = res.data.varList[i].OPERATTIME
									list.push(res.data.varList[i])
									if(res.data.varList[i].TYPE && res.data.varList[i].TYPE == 2){
										active++
									}
								}
							}
							_this.varList = list
							_this.active = active
                            // _this.varList = res.data.varList;
                            uni.hideLoading();
                        } else if ("exception" == res.data.result) {
                            uni.showToast({
                                title: '错误',
                                duration: 2000
                            });
                        }
                    }
                });
            },
           
           goback() {
               uni.navigateBack({
                   delta: 1
               });
               uni.hideLoading();
           }, 
        }
    }
</script>

<style lang="scss">
	.status-btn {
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		flex-direction: row;
		align-items: center;
		justify-content: center;
		height: 92rpx;
		margin: 30rpx;
		background-color: #007AFF;
	}

	.example-body {
		/* #ifndef APP-NVUE */
		display: block;
		/* #endif */
		padding: 15px;
		flex-direction: row;
	}
</style>