import { inject, observer } from "mobx-react";
import { toJS } from "mobx";
import { Button, Modal } from "antd";
import {
    WeaLocaleProvider,
    WeaTop,
    WeaTab,
    WeaRightMenu,
} from "ecCom";

import { WeaLogView, WeaTableNew, WeaForm } from "comsMobx";
import isEmpty from 'lodash/isEmpty';
const { WeaTable } = WeaTableNew;
const WeaLogViewComp = WeaLogView.Component;

import * as IntegrationUtil from "../../util/IntegrationUtil";
import NewForm from "./NewForm";
import NewDetailForm from "./NewDetailForm";
import NoRight from "../../public/NoRight";
import NonStand from "../../public/NonStand";
import XmlDialog from './XmlDialog';
import DbDialog from './DbDilaog';
import FTPDialog from './FTPDialog';
import LocalDialog from './LocalDialog';
import DatabaseDialog from './DatabaseDialog';

const getLabel = WeaLocaleProvider.getLabel;


@inject("archiveStore")
@observer
class Archive extends React.Component {
    constructor(props) {
        super(props);
        this.state = {
            selectedKey: 0,
          logTargetId:''
        };
    }

    componentDidMount() {
        const { archiveStore } = this.props;
        archiveStore.doInit();
        this.setState({selectedKey: 0});
    }

    componentWillReceiveProps(nextProps) {
        const { archiveStore } = this.props;
        if (this.props.location.key !== nextProps.location.key) {
            archiveStore.doInit();
            this.setState({selectedKey: 0});
        }
    }

    /**
     * 获取右键菜单
     * @returns {Array}
     */
    getRightMenu = () => {
        const { archiveStore } = this.props;
        const {logTableStore, status, ftpTableStore, localTableStore, dbTableStore, schemeTableStore, tableStore} = archiveStore;
        const { selectedKey, rightMenus, logRightMenus, detailTabSelectedKey, ftpRightMenus, localRightMenus, dbRightMenus, schemeRightMenus } = toJS(status);
        let btnArr = [];
        let toggleRightMenu = rightMenus;
        let disabled = true;

        if (selectedKey == 2) {
            toggleRightMenu = logRightMenus;
            disabled = logTableStore.selectedRowKeys.length > 0 ? false : true;
        } else if (selectedKey == 1) {
            toggleRightMenu = [];
            switch (detailTabSelectedKey) {
                case "dt1":
                    toggleRightMenu = ftpRightMenus;
                    disabled = ftpTableStore.selectedRowKeys.length > 0 ? false : true;
                    break;
                case "dt2":
                    toggleRightMenu = localRightMenus;
                    disabled = localTableStore.selectedRowKeys.length > 0 ? false : true;
                    break;
                case "dt3":
                    toggleRightMenu = dbRightMenus;
                    disabled = dbTableStore.selectedRowKeys.length > 0 ? false : true;
                    break;
                case "dt4":
                    toggleRightMenu = schemeRightMenus;
                    disabled = schemeTableStore.selectedRowKeys.length > 0 ? false : true;
                    break;
                default:
                    break;
            }

        } else if (selectedKey == 0) {
            disabled = tableStore.selectedRowKeys.length > 0 ? false : true;
        }

        btnArr = toggleRightMenu && toggleRightMenu.map(m => {
            return {
                key: m.type,
                icon: <i className={m.menuIcon} />,
                content: m.menuName,
                disabled: (selectedKey == '2' && m.menuIcon === 'icon-coms-File' && disabled) || (m.menuIcon === 'icon-coms-delete' && disabled),
                onClick: () => this.onRightMenuClick(m.type)
            }
        });
        //显示列定制
        btnArr.push({
            key: "BTN_COLUMN",
            icon: <i className="icon-coms-Custom" />,
            content: `${getLabel(32535, "显示列定制")}`,
            onClick: () => this.onRightMenuClick("BTN_COLUMN")
        });


        return btnArr;
    }

    getColumnsInfo = data => {
        const {selectedKey} = toJS(this.props.archiveStore.status);
        const that = this;
        if (!isEmpty(data)) {
            for (let index = 0; index < data.length; index++) {
                if (data[index].dbField == 'id' && selectedKey == 0) {
                    data[index].render = (text, record, index) => {
                        // console.log(record);
                        let name = { __html: record.idspan };
                        // console.log(record);
                        return (<a onClick={that.doEditDetailById.bind(that, record)}><span dangerouslySetInnerHTML={name}></span></a>);
                    }
                }
                if(data[index].dbField == "requestname" && selectedKey == 2) {
                    data[index].render = (text, record, index) => 
                      <a href={`${window.ecologyContentPath || ""}/spa/workflow/index_form.jsp#/main/workflow/req?requestid=${record.requestid}&_workflowid=${record.workflowid}`} target="_blank"><span dangerouslySetInnerHTML={{ __html: record.requestnamespan }}></span></a>
                }
            }
        }
    }

    doEditById(record) {
        const { archiveStore } = this.props;
        archiveStore.newForm.reset();
        archiveStore.getArchiveRegisterEditForm({ id: record.id });
        archiveStore.setState({ showNewFormDialog: true, });
    }

    doEditDetailById(record) {
        const { archiveStore } = this.props;
        const { getArchiveRegisterEditFormLogList, status } = archiveStore;
        const { editId } = toJS(status);
        getArchiveRegisterEditFormLogList({ id: record.randomFieldId });
        archiveStore.newForm = new WeaForm();
        archiveStore.newFormRegisterDB = new WeaForm();
        archiveStore.newFormRegisterXML = new WeaForm();
        archiveStore.getArchiveRegisterEditForm({ id: record.id });
        archiveStore.setState({ showNewFormDialog: false });
        if (record.ProType == 0) {
            archiveStore.getArchiveRegisterEditFormFieldXMLMapping({ id: record.id });
        } else if (record.ProType == 1) {
            archiveStore.getArchiveRegisterEditFormFieldDBMapping({ id: record.id });
        }
        archiveStore.setState({ showNewDetailFormDialog: true, editId: record.id, proType: record.ProType, newDetailSelectedKey: 0 });
    }

    /**
     * 右键菜单点击事件
     * @param type
     */
    onRightMenuClick = (type, recordId) => {
        //todo
        const { archiveStore } = this.props;
        const { tableStore } = archiveStore;
        const { ftpTableStore, localTableStore, dbTableStore, schemeTableStore, } = archiveStore;
        const { selectedKey, detailTabSelectedKey, rowSelectIds, rowSelectRows } = toJS(archiveStore.status);

        // 归档流程注册
        if (selectedKey == 0) {

            if (type == "rb_1") {
                this.doEditById({ id: '' });
            }
            if (type == "rb_2") {
                //删除
                archiveStore.confirmModal(`${getLabel(385625, '确定要删除选择的记录吗？')}`, archiveStore.getArchiveRegisterOperation, { operation: 'delete', id: tableStore.selectedRowKeys });
            }
            if (type == "rb_3") {
                //日志
              this.setState({logTargetId:''});
                archiveStore.setState({ logArchiveid: "84", logArchiveVisible: true });
            }
        }
        // 归档配置
        if (selectedKey == 1) {
            // 归档FTP列表
            if (detailTabSelectedKey == "dt1") {
                if (type == 'rb_1') {
                    archiveStore.getArchiveConfigFTPAddForm();
                }
                if (type == 'rb_2') {
                    archiveStore.confirmModal(
                        `${getLabel(385625, '确定要删除选择的记录吗？')}`,
                        archiveStore.getArchiveConfigFTPOperation,
                        { operation: 'delete', id: ftpTableStore.selectedRowKeys }
                    );
                }
                if (type == 'rb_3') {
                  this.setState({logTargetId:''});
                    archiveStore.setState({ logArchiveid: "85", logArchiveVisible: true })
                }
            }
            // 归档本地列表
            if (detailTabSelectedKey == "dt2") {
                if (type == 'rb_1') {
                    archiveStore.getArchiveConfigLocalAddForm();
                }
                if (type == 'rb_2') {
                    archiveStore.confirmModal(
                        `${getLabel(385625, '确定要删除选择的记录吗？')}`,
                        archiveStore.getArchiveConfigLocalOperation,
                        { operation: 'delete', id: localTableStore.selectedRowKeys }
                    );
                }
                if (type == 'rb_3') {
                  this.setState({logTargetId:''});
                    archiveStore.setState({ logArchiveid: "86", logArchiveVisible: true })
                }
            }
            // 归档数据库列表
            if (detailTabSelectedKey == "dt3") {
                if (type == 'rb_1') {
                    archiveStore.getArchiveConfigDatabaseAddForm();
                }
                if (type == 'rb_2') {
                    archiveStore.confirmModal(
                        `${getLabel(385625, '确定要删除选择的记录吗？')}`,
                        archiveStore.getArchiveConfigDatabaseOperation,
                        { operation: 'delete', id: dbTableStore.selectedRowKeys }
                    );
                }
                if (type == 'rb_3') {
                  this.setState({logTargetId:''});
                    archiveStore.setState({ logArchiveid: "87", logArchiveVisible: true })
                }
            }
            // 归档方案列表
            if (detailTabSelectedKey == "dt4") {
                // 注册xml方案
                if (type == 'rb_1') {
                    archiveStore.getArchiveConfigSchemeAddFormXML();
                }
                // 注册数据库方案
                if (type == 'rb_2') {
                    archiveStore.getArchiveConfigSchemeAddFormDB();
                }
                // 删除
                if (type == 'rb_3') {
                    archiveStore.confirmModal(
                        `${getLabel(385625, '确定要删除选择的记录吗？')}`,
                        () => {
                            let xmlIds = [], dbIds = [];

                            rowSelectRows && rowSelectRows.forEach(item => {
                                if('1' == item.ProType) {
                                    dbIds.push(item.randomFieldId);
                                } else {
                                    xmlIds.push(item.randomFieldId);
                                }
                            })

                            if(xmlIds.length) {
                                archiveStore.getArchiveConfigSchemeOperationXML({ operation: 'delete', id: xmlIds });
                            }

                            if(dbIds.length) {
                                archiveStore.getArchiveConfigSchemeOperationDB({ operation: 'delete', id: dbIds })
                            }
                        }
                    );
                }
                if (type == 'rb_4') {
                  this.setState({logTargetId:''});
                    archiveStore.setState({ logArchiveid: "88", logArchiveVisible: true })
                }
            }
        }

        // 归档日志
        if (selectedKey == 2) {
            // 重新归档
            if (type == "rb_1") {
                if (rowSelectIds.length > 0) {
                    archiveStore.confirmModal(`${getLabel(125754, '是否批量归档')}`, archiveStore.getArchiveRegisterOperation, { operation: 'exp', ids: rowSelectIds });
                } else {
                    archiveStore.confirmModal(`${getLabel(125753, '请选择需要归档的流程')}`);
                }
            }
        }

        if (type == "BTN_COLUMN") {
            //显示列定制
            if (selectedKey == 0) {
                archiveStore.tableStore.setColSetVisible(true);
                archiveStore.tableStore.tableColSet(true);
            } else if (selectedKey == 1) {
                switch (detailTabSelectedKey) {
                    case "dt1":
                        archiveStore.ftpTableStore.setColSetVisible(true);
                        archiveStore.ftpTableStore.tableColSet(true);
                        break;
                    case "dt2":
                        archiveStore.localTableStore.setColSetVisible(true);
                        archiveStore.localTableStore.tableColSet(true);
                        break;
                    case "dt3":
                        archiveStore.dbTableStore.setColSetVisible(true);
                        archiveStore.dbTableStore.tableColSet(true);
                        break;
                    case "dt4":
                        archiveStore.schemeTableStore.setColSetVisible(true);
                        archiveStore.schemeTableStore.tableColSet(true);
                        break;
                }
            } else {
                archiveStore.logTableStore.setColSetVisible(true);
                archiveStore.logTableStore.tableColSet(true);
            }
        }
    };

    /**
     * 获取顶部按钮
     * @returns {Array}
     */
    getBtns = () => {
        const { archiveStore } = this.props;
        const { tableStore, logTableStore,
            ftpTableStore,
            localTableStore,
            dbTableStore,
            schemeTableStore,
        } = archiveStore;

        const { selectedKey,
            rightMenus, rowSelectIds,
            logRightMenus,
            detailTabSelectedKey,
            ftpRightMenus,
            localRightMenus, dbRightMenus, schemeRightMenus,
        } = toJS(archiveStore.status);

        let myMenus = [];
        if (selectedKey == 0) {
            myMenus = rightMenus;
            myMenus && myMenus.pop();
        } else if (selectedKey == 1) {
            myMenus = [];
            switch (detailTabSelectedKey) {
                case "dt1":
                    myMenus = ftpRightMenus;
                    break;
                case "dt2":
                    myMenus = localRightMenus;
                    break;
                case "dt3":
                    myMenus = dbRightMenus;
                    break;
                case "dt4":
                    myMenus = schemeRightMenus;
                    break;
                default:
                    break;
            }
            myMenus && myMenus.pop();
        } else if (selectedKey == 2) {
            myMenus = logRightMenus;
        }
        let btnArr = [];
        if (!myMenus) { return btnArr }
        let disabled = true;
        switch (selectedKey.toString()) {
            case "0":
                disabled = tableStore.selectedRowKeys.length > 0 ? false : true;
                break;
            case "1":
                switch (detailTabSelectedKey.toString()) {
                    case "dt1":
                        disabled = ftpTableStore.selectedRowKeys.length > 0 ? false : true;
                        break;
                    case "dt2":
                        disabled = localTableStore.selectedRowKeys.length > 0 ? false : true;
                        break;
                    case "dt3":
                        disabled = dbTableStore.selectedRowKeys.length > 0 ? false : true;
                        break;
                    case "dt4":
                        disabled = schemeTableStore.selectedRowKeys.length > 0 ? false : true;
                        break;
                }
                break;
            case "2":
                disabled = toJS(logTableStore.selectedRowKeys).length > 0 ? false : true;
                break;
        }
        // 不显示 日志 按钮
        // myMenus.pop();

        for (let j = 0, len = myMenus.length; j < len; j++) {
            let m = myMenus[j];
            let btn = <Button ecId={`${this && this.props && this.props.ecId || ''}_Button@wi47l4`}
                type="primary"
                disabled={(selectedKey == '2' && m.menuIcon === 'icon-coms-File' && disabled) || (m.menuIcon === 'icon-coms-delete' && disabled)}
                onClick={() => { { this.onRightMenuClick(m.type); } }}>{`${m.menuName}`}</Button>;
            btnArr.push(btn);
        }

        return btnArr;
    };

    /**
     * 获取高级查询
     * @returns {Array}
     */
    getAdvancedSearch = () => {
        const { archiveStore } = this.props;
        const { searchForm, logSearchForm, status } = archiveStore;
        const { selectedKey, ArchiveConditionInfo, ArchiveLogConditionInfo, } = toJS(status);
        let form1 = searchForm;
        let condition1 = ArchiveConditionInfo;
        if (selectedKey == 2) {
            form1 = logSearchForm;
            condition1 = ArchiveLogConditionInfo;
        }
        return IntegrationUtil.getAdvancedItem(form1, condition1, this.handleSearchFun, false, this && this.props && this.props.ecId || '', "integrationWorkflowarchive");
    };

    handleSearchFun = () => {
        const { archiveStore } = this.props;
        const { selectedKey } = toJS(archiveStore.status);
        if (selectedKey == 0) {
          archiveStore.getArchiveRegisterList();
        } else {
          archiveStore.getArchiveLogList();
        }
        archiveStore.setState({ showSearchAd: false });
    }

    getTabButtonsAd() {
        const { archiveStore } = this.props;
        const { selectedKey } = toJS(archiveStore.status);
        return IntegrationUtil.getSearchBtns(
            this.handleSearchFun,
            () => selectedKey == 0 ? archiveStore.searchForm.reset() : archiveStore.logSearchForm.reset(),
            () => archiveStore.setState({showSearchAd: false}),
            this && this.props && this.props.ecId || '', 
            "integrationWorkflowarchive",
        );
    }

    /**
     * 数据列表行数据的操作项
     * @param record
     * @param index
     * @param operate
     * @param flag
     */
    onOperatesClick = (record, index, operate, flag) => {
        const { archiveStore } = this.props;
        const { setState } = archiveStore;
        const { selectedKey, detailTabSelectedKey } = toJS(archiveStore.status);
        // console.log("operate",operate);
        if (selectedKey == 0) {
            if (operate.index == "0") {
                //编辑
                setState({ editId : record.randomFieldId })
                this.doEditDetailById(record);
            }
            else if (operate.index == "1") {
                if (operate.href == 'javascript:doDeleteById()') {
                    //删除归档流程注册
                    archiveStore.confirmModal(`${getLabel(15097, '确定要删除吗？')}`, archiveStore.getArchiveRegisterOperation, { operation: 'delete', id: record.id });
                } else {
                    //日志
                  this.setState({logTargetId:record.randomFieldId});
                    archiveStore.setState({ logArchiveid: "84", logArchiveVisible: true });
                }

            }
            else if (operate.index == "2") {
                //删除

            }
            else if (operate.index == "3") {
                //预览  todo
            }
        }
        if (selectedKey == 1) {
            // edit
            if (operate.index == "0") {
                if (detailTabSelectedKey == "dt1") {
                    archiveStore.getArchiveConfigFTPEditForm({ id: record.randomFieldId });
                }
                if (detailTabSelectedKey == "dt2") {
                    archiveStore.getArchiveConfigLocalEditForm({ id: record.randomFieldId });
                }
                // 归档数据库列表
                if (detailTabSelectedKey == "dt3") {
                    archiveStore.getArchiveConfigDatabaseEditForm({ id: record.randomFieldId });
                }
                // 归档方案列表
                if (detailTabSelectedKey == "dt4") {
                    if (record.ProType == '1') {
                        archiveStore.getArchiveConfigSchemeEditFormDB({ id: record.Proid, proid: record.Proid });
                    } else {
                        archiveStore.getArchiveConfigSchemeEditFormXML({ id: record.Proid, proid: record.Proid });
                    }
                }
            }

            // delete
            if (operate.index == "1") {
                Modal.confirm({
                    title: `${getLabel(131329, '信息确认')}`,
                    content: `${getLabel(15097, '确定要删除吗？')}`,
                    okText: `${getLabel(16631, '确定')}`,
                    cancelText: `${getLabel(201, '取消')}`,
                    onOk: () => {
                        if (detailTabSelectedKey == "dt1") {
                            archiveStore.getArchiveConfigFTPOperation({ id: record.randomFieldId, operation: 'delete' });
                        }
                        if (detailTabSelectedKey == "dt2") {
                            archiveStore.getArchiveConfigLocalOperation({ id: record.randomFieldId, operation: 'delete' });
                        }
                        // 归档数据库列表
                        if (detailTabSelectedKey == "dt3") {
                            archiveStore.getArchiveConfigDatabaseOperation({ id: record.randomFieldId, operation: 'delete' });
                        }
                        if (detailTabSelectedKey == "dt4") {
                            if (record.ProType == '1') {
                                archiveStore.getArchiveConfigSchemeOperationDB({ id: record.randomFieldId, proid: record.ProType, operation: 'delete' });
                            } else {
                                archiveStore.getArchiveConfigSchemeOperationXML({ id: record.randomFieldId, proid: record.ProType, operation: 'delete' });
                            }
                        }
                    }
                });
            }

            // log
            if (operate.index === "2") {
                // 85 86 87 88
                const idHash = { dt1: "85", dt2: "86", dt3: "87", dt4: "88", };
              this.setState({logTargetId:record.randomFieldId});
                archiveStore.setState({ logArchiveid: idHash[detailTabSelectedKey], logArchiveVisible: true })
            }
        }
        if (selectedKey == 2) {
            if (operate.index == "1") {
                archiveStore.getArchiveRegisterOperation({ ids: record.randomFieldId, operation: 'exp' })
            }
        }
    };

    redoColumnsByName = columns => {
        let newColumns = "";
        newColumns = columns.map(column => {
            let newColumn = column;
            newColumn.render = (text, record, index) => {
                // 前端元素转义
                let valueSpan =
                    record[newColumn.dataIndex] !== undefined
                        ? record[newColumn.dataIndex + "span"]
                        : record[newColumn.dataIndex];
                switch (newColumn.dataIndex.toString()) {
                    case "name":
                    case "ProName":
                        return (
                            <a
                                onClick={() => {
                                    this.onOperatesClick(record, index, { index: "0" });
                                }}
                                dangerouslySetInnerHTML={{ __html: valueSpan }}
                            />
                        );
                    default:
                        return <div dangerouslySetInnerHTML={{ __html: valueSpan }} />;
                }
            };
            return newColumn;
        });
        return newColumns;
    }

    getRowSelection = () => {
      return { 
        onChange: (selectedRowKeys, rowSelectRows) => {
            this.props.archiveStore.setState({ 
                rowSelectIds: selectedRowKeys,
                rowSelectRows,
            })
        } 
      }
    }

    getArchiveConfigTabs = () => {
        const { archiveStore } = this.props;
        const { ftpTableStore, localTableStore, dbTableStore, schemeTableStore, } = archiveStore;
        const { selectedKey, detailTabSelectedKey } = toJS(archiveStore.status);
        switch (detailTabSelectedKey.toString()) {
            case "dt1":
                return (
                    <WeaTable ecId={`${this && this.props && this.props.ecId || ''}_WeaTable@pndb4r`}
                        comsWeaTableStore={ftpTableStore}
                        hasOrder={true}
                        needScroll={true}
                        onOperatesClick={this.onOperatesClick}
                        rowSelection={this.getRowSelection()}
                        getColumns={this.redoColumnsByName}
                    />
                )
            case "dt2":
                return (
                    <WeaTable ecId={`${this && this.props && this.props.ecId || ''}_WeaTable@bmecak`}
                        comsWeaTableStore={localTableStore}
                        hasOrder={true}
                        needScroll={true}
                        onOperatesClick={this.onOperatesClick}
                        rowSelection={this.getRowSelection()}
                        getColumns={this.redoColumnsByName}
                    />
                )
            case "dt3":
                return (
                    <WeaTable ecId={`${this && this.props && this.props.ecId || ''}_WeaTable@76lobq`}
                        comsWeaTableStore={dbTableStore}
                        hasOrder={true}
                        needScroll={true}
                        onOperatesClick={this.onOperatesClick}
                        rowSelection={this.getRowSelection()}
                        getColumns={this.redoColumnsByName}
                    />
                )
            case "dt4":
                return (
                    <WeaTable ecId={`${this && this.props && this.props.ecId || ''}_WeaTable@fin3ca`}
                        comsWeaTableStore={schemeTableStore}
                        hasOrder={true}
                        needScroll={true}
                        onOperatesClick={this.onOperatesClick}
                        rowSelection={this.getRowSelection()}
                        getColumns={this.redoColumnsByName}
                    />
                )
        }
    }

    getLogRightMenu = () => {
        let menu = [];

        menu.push({
            key: '1',
            icon: <i className='icon-coms-search' />,
            content: '按钮 1',
        });
        menu.push({
            key: '2',
            icon: <i className='icon-coms-search' />,
            content: '按钮 2',
        })
            
        return menu;
    }

    closeLogDialog = () => { this.props.archiveStore.setState({ logArchiveVisible: false }) };

    handleChangeArchiveConfigTab = key => { 
        const { archiveStore } = this.props;

        if(key == "dt1") {
            archiveStore.ftpTableStore.reloadCurrent();
        } else if(key == "dt3") {
            archiveStore.dbTableStore.reloadCurrent();
        } else if(key == "dt2") {
            archiveStore.localTableStore.reloadCurrent();
        } else if(key == "dt4") {
            archiveStore.schemeTableStore.reloadCurrent();  
        }

        archiveStore.setState({ 
            detailTabSelectedKey: key, 
            rowSelectIds: [], 
            rowSelectRows: [] 
        });
    }

    render() {
        const { archiveStore } = this.props;
        const { searchForm, logSearchForm, tableStore, logTableStore, status, hasRight, rightLoading } = archiveStore;
        const { hasNonStandard, nonStandLoading, showSearchAd, selectedKey, advancedSearchHeight, logArchiveVisible, detailTabSelectedKey, logArchiveid, topTab, archieveTopTab } = status;

        return (nonStandLoading
          ? null
          : hasNonStandard
            ? rightLoading 
              ? null
              : hasRight 
                ? <WeaRightMenu ecId={`${this && this.props && this.props.ecId || ''}_WeaRightMenu@vuse5p`}
                    datas={this.getRightMenu()}
                    collectParams={{
                        favname: `${getLabel(83203, "流程归档集成")}`,
                        favouritetype: 1,
                        objid: 0,
                        link: "wui/engine.html#/integration/WorkflowArchive",
                        importantlevel: 1
                    }}
                  >
                    <WeaTop ecId={`${this && this.props && this.props.ecId || ''}_WeaTop@g2aupw`}
                        title={getLabel(83203, "流程归档集成")}
                        icon={<i className="icon-coms-integration" />}
                        iconBgcolor="#1a57a0"
                        buttons={this.getBtns()}
                        showDropIcon={true}
                        dropMenuDatas={this.getRightMenu()}
                        dropMenuProps={{
                            collectParams: {
                                favname: `${getLabel(83203, "流程归档集成")}`,
                                favouritetype: 1,
                                objid: 0,
                                link: "wui/engine.html#/integration/workflowArchive",
                                importantlevel: 1
                            }
                        }}
                    >
                        <WeaTab ecId={`${this && this.props && this.props.ecId || ''}_WeaTab@8vopj3`}
                            datas={topTab}
                            keyParam="viewcondition" //主键
                            selectedKey={this.state.selectedKey}
                            searchType={selectedKey != 1 ? ['base', 'advanced'] : []}
                            advanceHeight={advancedSearchHeight}
                            searchsAd={this.getAdvancedSearch()}
                            showSearchAd={showSearchAd}
                            buttonsAd={this.getTabButtonsAd()}
                            setShowSearchAd={() => archiveStore.setState({ showSearchAd: !showSearchAd })}
                            hideSearchAd={() => archiveStore.setState({ showSearchAd: false })}
                            onChange={v => {
                                this.setState({ selectedKey: v });
                                archiveStore.setState({ 
                                    selectedKey: v, 
                                    rowSelectIds: [],
                                    rowSelectRows: [],
                                    detailTabSelectedKey: "dt1",
                                    advancedSearchHeight: v == 2 ? 160 : 120
                                });
                                if(v == 0) {
                                    searchForm.reset();
                                    archiveStore.getArchiveRegisterList();
                                    archiveStore.getArchiveRegisterRightMenu();
                                    archiveStore.getArchiveRegisterCondition();
                                }else if(v == 2) {
                                    logSearchForm.reset();
                                    archiveStore.getArchiveLogList();
                                    archiveStore.getArchiveLogRightMenu();
                                    archiveStore.getArchiveLogCondition();
                                }
                            }}
                            onSearch={this.handleSearchFun}
                            onSearchChange={value => {
                                selectedKey == 0
                                    ? searchForm.updateFields({ workflowname: value })
                                    : logSearchForm.updateFields({ requestname: value })
                            }}
                            searchsBaseValue={
                                selectedKey == 0 
                                ? searchForm.getFormParams().workflowname 
                                : selectedKey == 2
                                    ? logSearchForm.getFormParams().requestname
                                    : ""
                            }
                        />
                        {selectedKey == 0 ? (
                            <WeaTable ecId={`${this && this.props && this.props.ecId || ''}_WeaTable@6tm3jm`}
                                comsWeaTableStore={tableStore}
                                hasOrder={true}
                                needScroll={true}
                                onOperatesClick={this.onOperatesClick}
                                getColumns={this.getColumnsInfo}
                                rowSelection={this.getRowSelection()}
                            />
                        ) :
                            selectedKey == 2 ? (
                                <WeaTable ecId={`${this && this.props && this.props.ecId || ''}_WeaTable@cwi3bi`}
                                    comsWeaTableStore={logTableStore}
                                    hasOrder={true}
                                    needScroll={true}
                                    onOperatesClick={this.onOperatesClick}
                                    getColumns={this.getColumnsInfo}
                                    rowSelection={this.getRowSelection()}
                                />
                            ) : (
                                    //第二个标签页
                                    <div className="content">
                                        <WeaTab ecId={`${this && this.props && this.props.ecId || ''}_WeaTab@rhnvka`}
                                            datas={archieveTopTab}
                                            keyParam="viewcondition" //主键
                                            countParam="groupid" //数量
                                            type="card"
                                            selectedKey={detailTabSelectedKey}
                                            onChange={this.handleChangeArchiveConfigTab} />
                                        {this.getArchiveConfigTabs()}
                                    </div>
                                )
                        }
                    </WeaTop>
                    <NewForm ecId={`${this && this.props && this.props.ecId || ''}_NewForm@cmobmo`} />
                    <NewDetailForm ecId={`${this && this.props && this.props.ecId || ''}_NewDetailForm@jwfoml`} />
                    <XmlDialog ecId={`${this && this.props && this.props.ecId || ''}_XmlDialog@njzo7q`} />
                    <DbDialog ecId={`${this && this.props && this.props.ecId || ''}_DbDialog@38qg15`} />
                    <FTPDialog ecId={`${this && this.props && this.props.ecId || ''}_FTPDialog@rum30l`} />
                    <LocalDialog ecId={`${this && this.props && this.props.ecId || ''}_LocalDialog@bjxtyu`} />
                    <DatabaseDialog ecId={`${this && this.props && this.props.ecId || ''}_DatabaseDialog@vua2a4`} />
                    <WeaLogViewComp ecId={`${this && this.props && this.props.ecId || ''}_WeaLogViewComp@iq65no`} 
                        visible={logArchiveVisible} 
                        onCancel={this.closeLogDialog} 
                        logStore={archiveStore.logStore} logType="15" logSmallType={logArchiveid}
                        targetId={this.state.logTargetId}
                    />
                  </WeaRightMenu>
                : <NoRight ecId={`${this && this.props && this.props.ecId || ''}_NoRight@fmv7bc`} />
            : <NonStand ecId={`${this && this.props && this.props.ecId || ''}_NonStand@e61j92`} />
        );
    }
}

export default Archive;
