// 云医保平台入口
import React from 'react';
import { Row, Col, Button, Card, message } from 'antd';
import { INSUYBUtil } from 'tools/index';
import { $http } from '../../../containers/config/https';
export default class CloudINSUPlatform extends React.Component {

    constructor(props) {
        super(props)
        this.state = {
            btnArr: []
        }
    }
    componentDidMount() {
        this.getConfigInfo();
    }

    /// 获取入口配置
    getConfigInfo = () => {
        let params = {
            params: [{
            }]
        }
        $http.post('urlDeault', this, {
            code: "05110012",
            data: params,
            success: function (res) {
                if (res.errorCode == '0') {
                    this.setState({
                        btnArr: res.result
                    })
                } else {
                    message.error('获取配置信息报错！')
                }
            }
        });
    }
    /// 入口程序
    onBtnClick = async (item) => {
        let postObj = {
            params: [{}],
            hospID: JSON.parse(window.sessionStorage.userData).hospID,
            businessType: item.functionName,
            type: item.type,
            session: [JSON.parse(sessionStorage.getItem('userData'))]
        }
        console.log(postObj)
        let rtn = await INSUYBUtil.insuNew("AgentFun", postObj, item.dllPath, item.className);
        let res = JSON.parse(rtn);
        if (res.errorCode == '0') {
        }
        else {
            message.warn('调用医保入口报错！');
        }
    }

    render() {
        let { btnArr } = this.state
        return (
            <div className='hospital-zation-express'>
                <Card>
                    <Row style={{ margin: '20px' }}>
                        {
                            btnArr.map((item) => {
                                return (<Col span={5} key={item.code} style={{ margin: '20px' }}>
                                    <Button type='primary' onClick={this.onBtnClick.bind(this, item)}>{item.descripts}</Button>
                                </Col>)
                            })
                        }
                    </Row>
                </Card>

            </div >
        )
    }
}