import React, { Component } from "react";
import { observer } from "mobx-react";
import { WeaDialog } from "ecCom";
import { WeaTableNew } from "comsMobx";
import SignDetail from "./SignDetail";
import { Tabs } from "../../../../../pc4backstage/hrmComsPublic/index";
import uuid from 'uuid/v1';
const { WeaTable } = WeaTableNew;

const tabHeight = 50, paginationHeight = 90;

@observer
export default class Detail extends Component {
    render(){
        const { store } = this.props;
        const { detailDialogProps, detailDialogHeight, detailTabs, detailTabProps, detailTable, isSignDetailData } = store;
        const children = [];
        if(detailTabs.length > 0){
            children.push(
                (
                    <Tabs ecId={`${this && this.props && this.props.ecId || ''}_Tabs@przn3q`} {...detailTabProps}>
                        <div className='tabPane tabPane-dialog'>
                            <WeaTable ecId={`${this && this.props && this.props.ecId || ''}_WeaTable@yxav0g`}
                                comsWeaTableStore={detailTable}
                                hasOrder={true}
                                needScroll={true}
                                scroll={{y: detailDialogHeight - paginationHeight - tabHeight}}
                            />
                        </div>
                    </Tabs>
                )
            )
        }else{
            children.push(
                (
                    <WeaTable ecId={`${this && this.props && this.props.ecId || ''}_WeaTable@6lf7q2`}
                        comsWeaTableStore={detailTable}
                        hasOrder={true}
                        needScroll={true}
                        scroll={{y: detailDialogHeight - paginationHeight}}
                    />
                )
            )
        }

        return (
            <WeaDialog ecId={`${this && this.props && this.props.ecId || ''}_WeaDialog@86etj9`} {...detailDialogProps} onChangeHeight={height => store.detailDialogHeight = height}>
                {
                    isSignDetailData ? <SignDetail ecId={`${this && this.props && this.props.ecId || ''}_SignDetail@snbmos`} store={store}/> : children
                }
            </WeaDialog>
        )
    }
}
