import {
    observer
} from 'mobx-react';
import {
    WeaDialog,
    WeaTableEdit,
    WeaTableEditable
} from 'ecCom';
import {
    Spin,
    Button, Modal
} from 'antd'

import * as mobx from "mobx";
const toJS = mobx.toJS;

@observer
export default class NewWeaTableEditDialog extends React.Component {
    constructor(props) {
        super(props);
    }

    onRowSelect = (sRowKeys, rows, dataIndex, selectedDatas) => {
        const { store } = this.props;
        if (dataIndex === undefined || selectedDatas === undefined) {
          return;
        }
        store.setEnableRows(selectedDatas.isused);
      };

    render() {
        const {
            store,
        } = this.props, {
            temlateManageDialog,
            relatedData
        } = store;
        const { datas, columns, loading,selectedData } = relatedData;

        return (
            <WeaDialog
                {...temlateManageDialog}
                initLoadCss
            >
                <WeaTableEdit
                    ecId={`${this && this.props && this.props.ecId || ""}_WeaTableEdit@7rorir`}
                    deleteConfirm
                    title="提示:当前使用的模板将不再展示"
                    showCopy={false}
                    columns={toJS(columns)}
                    datas={toJS(datas)}
                    copyFilterProps={["id"]}
                    selectedData={!loading && toJS(selectedData)}
                    onChange={e => store.setTableEditDatas(e)}
                    onRowSelect={(sRowKeys, rows, dataIndex, selectedDatas) => this.onRowSelect(sRowKeys, rows, dataIndex, selectedDatas)}
                />
            </WeaDialog>
        );
    }
}