ItemLaporan.js 6.59 KB
Newer Older
EKSAD's avatar
EKSAD committed
1 2 3
import React, { Component } from "react";
import { Container, Row, Col } from "react-bootstrap";
import { makeStyles, createMuiTheme, MuiThemeProvider } from '@material-ui/core/styles';
EKSAD's avatar
EKSAD committed
4
import SearchIcon from '@material-ui/icons/Search';
EKSAD's avatar
EKSAD committed
5
import Images from "../../assets/Images";
EKSAD's avatar
EKSAD committed
6 7 8
import MUIDataTable from "mui-datatables";
import { TextField, InputBase } from "@material-ui/core";
import { ExcelRenderer } from 'react-excel-renderer';
EKSAD's avatar
EKSAD committed
9
import CreateItemLaporan from "./formItemLaporan/CreateItemLaporan";
EKSAD's avatar
EKSAD committed
10

EKSAD's avatar
EKSAD committed
11
var ct = require("../../library/CustomTable");
EKSAD's avatar
EKSAD committed
12 13 14
const getMuiTheme = () => createMuiTheme(ct.customTable());
const options = ct.customOptions();
const options2 = ct.customOptions2();
EKSAD's avatar
EKSAD committed
15

EKSAD's avatar
EKSAD committed
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
export default class ItemLaporan extends Component {
    constructor(props) {
        super(props)
        this.state = {
            dataTable: [],
            listData: [],
            data: [],
            add: false,
            edit: false
        }
    }

    closeEdit() {
        this.setState({edit: false})
    }
    
    closeAdd() {
        this.setState({add: false})
    }
    
EKSAD's avatar
EKSAD committed
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
    render() {
        const columns = [{
            name: "Action",
            options: {
                customBodyRender: (val, tableMeta) => {
                    return (
                        <div style={{ display: 'flex' }}>
                            <button
                                style={{
                                    backgroundColor: 'transparent',
                                    cursor: 'pointer',
                                    borderColor: 'transparent'
                                }}
                                onClick={() => null}
                            >
                                <img src={Images.editCopy} />
                            </button>
                        </div >
                    );
                }
            }
EKSAD's avatar
EKSAD committed
57
        }, "ID", "Jenis Laporan", "Perusahaan", "Order", "Deskripsi", "Parent ID", "UOM", "Weight", "Tipe Data", "Status"]
EKSAD's avatar
EKSAD committed
58
        const data = [
EKSAD's avatar
EKSAD committed
59 60 61 62 63
            ["", "1", "KPI", "TIA", "1", "Financial Perspective", "0", "-", "35%", "Formula", "Aktif"],
            ["", "2", "KPI", "TIA", "2", "Trading Profit", "1", "Rp Bio", "35%", "Formula", "Aktif"],
            ["", "3", "KPI", "TIA", "3", "Revenue", "1", "Rp Bio", "0%", "Formula", "Aktif"],
            ["", "4", "KPI", "TIA", "4", "EBITDA", "1", "Rp Bio", "0%", "Formula", "Non Aktif"],
            ["", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-"],
EKSAD's avatar
EKSAD committed
64 65 66 67 68 69 70 71 72 73 74 75 76 77
        ]
        const options = {
            filter: false,
            sort: false,
            responsive: "scroll",
            print: false,
            download: false,
            selectableRows: false,
            viewColumns: false,
            rowsPerPage: 5,
            search: false
        }

        return (
EKSAD's avatar
EKSAD committed
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
            <div style={{ height: this.props.height }}>
                {/* <Row> */}

                <div style={{ height: 199, backgroundColor: '#354960', width: '100%' }} />
                    <div>
                        <div style={{ display: 'flex', flexDirection: 'row', justifyContent: 'space-between', paddingRight: 25, paddingLeft: 25, marginTop: -150 }}>
                            <label style={{ color: 'white', fontSize: 16, alignSelf: 'center' }}>Master Data - Item Laporan</label>
                            <div style={{ color: 'white', width: '50%', height: 37, display: 'flex', backgroundColor: 'white', borderWidth: 2, alignItems: 'center', borderRadius: 6, paddingLeft: 5, paddingRight: 5 }}>
                                <img src={Images.searchBlack} style={{ marginRight: 10 }} />
                                <InputBase
                                    style={{ width: '100%' }}
                                    placeholder="Search"
                                    value={""}
                                    onChange={(e) => this.handleInputChange(e)}
                                    inputProps={{ 'aria-label': 'naked' }}
                                />
                            </div>
                            <div style={{ width: '20%', justifyContent: 'space-around', display: 'flex' }}>
EKSAD's avatar
EKSAD committed
96
                                <img src={Images.template} />
EKSAD's avatar
EKSAD committed
97 98 99 100 101 102 103 104
                                <button
                                    style={{
                                        backgroundColor: 'transparent',
                                        cursor: 'pointer',
                                        borderColor: 'transparent'
                                    }}
                                    onClick={() => this.setState({ visibleUpload: true })}
                                >
EKSAD's avatar
EKSAD committed
105
                                <img src={Images.upload} />
EKSAD's avatar
EKSAD committed
106
                                </button>
EKSAD's avatar
EKSAD committed
107
                                <img src={Images.download} />
EKSAD's avatar
EKSAD committed
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122
                                <button
                                    style={{
                                        backgroundColor: 'transparent',
                                        cursor: 'pointer',
                                        borderColor: 'transparent'
                                    }}
                                >
                                    <img src={Images.visualisasi} />
                                </button>
                                <button
                                    style={{
                                        backgroundColor: 'transparent',
                                        cursor: 'pointer',
                                        borderColor: 'transparent'
                                    }}
EKSAD's avatar
EKSAD committed
123
                                    onClick={() => this.setState({ add: true })}
EKSAD's avatar
EKSAD committed
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139
                                >
                                    <img src={Images.add} />
                                </button>
                            </div>
                        </div>
                        <div style={{ padding: 25 }}>
                            <MuiThemeProvider theme={getMuiTheme()}>
                                <MUIDataTable
                                    theme={getMuiTheme()}
                                    data={data}
                                    columns={columns}
                                    options={options}
                                />
                            </MuiThemeProvider>

                        </div>
EKSAD's avatar
EKSAD committed
140
                    </div>
EKSAD's avatar
EKSAD committed
141 142 143 144 145 146
                    {this.state.add && (
                        <CreateItemLaporan 
                            onClickClose={this.closeAdd.bind(this)}
                            data={this.state.indexData}
                        />
                    )}   
EKSAD's avatar
EKSAD committed
147 148 149 150
            </div>
        );
    }
}