page

46 阅读1分钟

import React, { Component } from 'react'; import {inject, observer} from 'mobx-react'; import { toJS } from 'mobx'; import { withRouter } from 'react-router'; import { Modal, } from 'antd'; import PageHeader from '../component/PageHeader'; import AppInfor from './component/AppInfor' import CheckParam from './component/CheckParam' import CodeInfor from './component/CodeInfor' import indexStyles from '../index.scss';

@inject('health', 'cmbusStage') @withRouter @observer export default class Index extends Component {

constructor(props){
    super(props)
    this.state = {
        breadCrumb: [
            {
                title: '应用信息'
            }
        ],
        appKey: ''
    }
}

componentDidMount() {
    // this.initHandle()
}

/**
 * 数据初始化
 */
initHandle = async () => {
    const { match } = this.props;
    const { domainId, appId } = match.params;
    const appKey = `${domainId}_${appId}`
    this.setState({
        appKey,
    })
}


callBack = () => {
}

/**
 * 提交任务
 */
startTask = async ()=>{
    const { health, cmbusStage, match } = this.props;
    const { appId, appName } = match.params;
    const ruleSelectResult = toJS(health.ruleSelectResult)
    const queryTaskConfResult = toJS(health.queryTaskConfResult)
    const confSelectResult = toJS(health.confSelectResult)
    const ruleHasAppKey = ruleSelectResult.hasOwnProperty(this.state.appKey)
    const confHasAppKey = confSelectResult.hasOwnProperty(this.state.appKey)
    if(ruleHasAppKey&&confHasAppKey){
        const rule = ruleSelectResult[this.state.appKey].selectedRules.filter((item)=>{
            const itemRowKeyIndex = ruleSelectResult[this.state.appKey].selectedRowKeys.findIndex((itemRowKey)=>{
                return item.ruleId === itemRowKey
            })
            return itemRowKeyIndex > -1
        })
        const conf = queryTaskConfResult.map((item)=>{
            const itemSelectObj = confSelectResult[this.state.appKey].find((itemSelect)=>{
                return item.name === itemSelect.name
            })
            if(itemSelectObj){
                item.value = itemSelectObj.value
            }
            return {...item}
        })
        await health.startTask(
            {
                stage: cmbusStage.currentStage,
                domainAppId: appId,
                appName,
                rule,
                conf,
                seedVersion:"20210601102229-feb55208",
                artifactId:"a1f728a28bad033a5ab35443c9762644ee8450d153a007b2872c26a81b0b3b271dcce0c8",
            }
        );
        const startTaskResult = toJS(health.startTaskResult)
        if(startTaskResult.taskId){
            this.nextStep()
        }
        else{
            Modal.error({
                title: '服务出错了',
                content: '排查问题重新操作',
            });
        }
    }
    else{
        Modal.error({
            title: '操作有误,重新操作',
            content: '按流程重新填写数据',
        });
    }
}

render() {
    return (
        <div className={indexStyles.healthBox}>
            <PageHeader dataSource={this.state.breadCrumb} callBack={this.callBack} />
            <AppInfor />
            <CheckParam />
            <CodeInfor />
        </div>
    )
}

}