Commit 6d96d9dd authored by EKSAD's avatar EKSAD

report item update

parent 18c6d9e7
...@@ -114,7 +114,9 @@ const create = (baseURL = 'https://tia.eksad.com/tia-reporting-dev/public/') => ...@@ -114,7 +114,9 @@ const create = (baseURL = 'https://tia.eksad.com/tia-reporting-dev/public/') =>
//Report Items //Report Items
const getReportItems = () => api.get('item_report/get_all_item_report') const getReportItems = () => api.get('item_report/get_all_item_report')
const getReportType = () => api.get('type_report/get_all_type_report')
const searchReportItems = (body) => api.post('/item_report/search_item_report', body) const searchReportItems = (body) => api.post('/item_report/search_item_report', body)
const createReportItems = (body) => api.post('/item_report/create_item_report', body)
//Template //Template
...@@ -173,7 +175,9 @@ const create = (baseURL = 'https://tia.eksad.com/tia-reporting-dev/public/') => ...@@ -173,7 +175,9 @@ const create = (baseURL = 'https://tia.eksad.com/tia-reporting-dev/public/') =>
checkUploadUser, checkUploadUser,
uploadUser, uploadUser,
getReportItems, getReportItems,
searchReportItems searchReportItems,
createReportItems,
getReportType,
} }
} }
......
...@@ -54,21 +54,75 @@ export default class ReportItems extends Component { ...@@ -54,21 +54,75 @@ export default class ReportItems extends Component {
componentDidMount() { componentDidMount() {
this.getData() this.getData()
console.log(this.props.height)
} }
getData() { getData() {
api.create().getReportItems().then((response) => { api.create().getReportItems().then((response) => {
console.log(response) console.log(response)
// if (response.data.status == 'success') { if (response.data.status == 'success') {
// let data = response.data.data let data = response.data.data
// let listData = data.map((item, index) => { let listData = data.map((item, index) => {
// return [index, item.item_report_id, item.report_name, item.company_name, item.order, item.description, item.parent, item.uom, item.weight, item.type_report_name, item.status ] return [index, item.item_report_id, item.report_name, item.company_name, item.order, item.description, item.parent, item.uom, item.weight, item.type_report_name, item.status ]
// }) })
// this.setState({ dataTable: listData, listData: response.data.data }) this.setState({ dataTable: listData, listData: response.data.data })
// } else { } else {
// alert(response.data.message) alert(response.data.message)
// } }
})
}
openPopUp(index, type) {
if (type === 'edit') {
this.setState({
selectIndex: index,
edit: true
})
} else {
this.setState({
data: this.state.listData[index],
add: true
})
}
}
handleInputChange(e) {
this.setState({ search: e })
let body = {
"keyword": e
}
api.create().searchReportItems(body).then(response => {
// console.log(response.data);
if (response.data.status == 'success') {
let data = response.data.data
let listData = data.map((item, index) => {
return [index, item.item_report_id, item.report_name, item.company_name, item.order, item.description, item.parent, item.uom, item.weight, item.type_report_name, item.status ]
})
this.setState({ dataTable: listData, listData: response.data.data })
} else {
alert(response.data.message)
}
})
}
createReportItems = (payload) => {
this.setState({ add: false })
api.create().createReportItems(payload).then(response => {
if (response.data.status == 'success') {
this.getData()
} else {
alert(response.data.message)
}
})
}
updateReportItems = (payload) => {
this.setState({ edit: false })
api.create().updateReportItems(payload).then(response => {
if (response.data.status == 'success') {
this.getData()
} else {
alert(response.data.message)
}
}) })
} }
...@@ -85,6 +139,7 @@ export default class ReportItems extends Component { ...@@ -85,6 +139,7 @@ export default class ReportItems extends Component {
cursor: 'pointer', cursor: 'pointer',
borderColor: 'transparent' borderColor: 'transparent'
}} }}
onClick={() => this.openPopUp(tableMeta.rowIndex, 'edit')}
> >
<img src={Images.editCopy} /> <img src={Images.editCopy} />
...@@ -93,26 +148,136 @@ export default class ReportItems extends Component { ...@@ -93,26 +148,136 @@ export default class ReportItems extends Component {
); );
} }
} }
}, "ID", "Jenis Laporan", "Perusahaan", "Order", "Deskripsi", "Parent ID", "UOM", "Weight", "Tipe Data", "Status"] },
const data = [ {
["", "1", "KPI", "TIA", "1", "Financial Perspective", "0", "-", "35%", "Formula", "Aktif"], name: "ID",
["", "2", "KPI", "TIA", "2", "Trading Profit", "1", "Rp Bio", "35%", "Formula", "Aktif"], options: {
["", "3", "KPI", "TIA", "3", "Revenue", "1", "Rp Bio", "0%", "Formula", "Aktif"], customBodyRender: (val, tableMeta) => {
["", "4", "KPI", "TIA", "4", "EBITDA", "1", "Rp Bio", "0%", "Formula", "Non Aktif"], return (
["", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-"], <div style={{ display: 'flex' }}>
] <span style={{ color: tableMeta.rowData[10] === "Aktif" ? "#656565" : 'rgba(0, 0, 0, 0.25)' }}>{val}</span>
const options = { </div >
filter: false, );
sort: false, }
responsive: "scroll", }
print: false, },
download: false, {
selectableRows: false, name: "Jenis Laporan",
viewColumns: false, options: {
rowsPerPage: 5, customBodyRender: (val, tableMeta) => {
search: false return (
<div style={{ display: 'flex' }}>
<span style={{ color: tableMeta.rowData[10] === "Aktif" ? "#656565" : 'rgba(0, 0, 0, 0.25)' }}>{val}</span>
</div >
);
}
}
},
{
name: "Perusahaan",
options: {
customBodyRender: (val, tableMeta) => {
return (
<div style={{ display: 'flex' }}>
<span style={{ color: tableMeta.rowData[10] === "Aktif" ? "#656565" : 'rgba(0, 0, 0, 0.25)' }}>{val}</span>
</div >
);
}
}
},
{
name: "Order",
options: {
customBodyRender: (val, tableMeta) => {
return (
<div style={{ display: 'flex' }}>
<span style={{ color: tableMeta.rowData[10] === "Aktif" ? "#656565" : 'rgba(0, 0, 0, 0.25)' }}>{val}</span>
</div >
);
}
}
},
{
name: "Deskripsi",
options: {
customBodyRender: (val, tableMeta) => {
return (
<div style={{ display: 'flex' }}>
<span style={{ color: tableMeta.rowData[10] === "Aktif" ? "#656565" : 'rgba(0, 0, 0, 0.25)' }}>{val}</span>
</div >
);
}
}
},
{
name: "Parent ID",
options: {
customBodyRender: (val, tableMeta) => {
return (
<div style={{ display: 'flex' }}>
<span style={{ color: tableMeta.rowData[10] === "Aktif" ? "#656565" : 'rgba(0, 0, 0, 0.25)' }}>{val}</span>
</div >
);
}
}
},
{
name: "UOM",
options: {
customBodyRender: (val, tableMeta) => {
return (
<div style={{ display: 'flex' }}>
<span style={{ color: tableMeta.rowData[10] === "Aktif" ? "#656565" : 'rgba(0, 0, 0, 0.25)' }}>{val}</span>
</div >
);
}
}
},
{
name: "Weight",
options: {
customBodyRender: (val, tableMeta) => {
return (
<div style={{ display: 'flex' }}>
<span style={{ color: tableMeta.rowData[10] === "Aktif" ? "#656565" : 'rgba(0, 0, 0, 0.25)' }}>{val}</span>
</div >
);
}
}
},
{
name: "Tipe Data",
options: {
customBodyRender: (val, tableMeta) => {
return (
<div style={{ display: 'flex' }}>
<span style={{ color: tableMeta.rowData[10] === "Aktif" ? "#656565" : 'rgba(0, 0, 0, 0.25)' }}>{val}</span>
</div >
);
}
}
},
{
name: "Status",
options: {
customBodyRender: (val, tableMeta) => {
return (
<div style={{ display: 'flex' }}>
<span style={{ color: tableMeta.rowData[10] === "Aktif" ? "#656565" : 'rgba(0, 0, 0, 0.25)' }}>{val}</span>
</div >
);
}
}
} }
]
const data = [
["", "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"],
["", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-"],
]
return ( return (
<div> <div>
{this.state.itemReport === true ? {this.state.itemReport === true ?
...@@ -120,24 +285,25 @@ export default class ReportItems extends Component { ...@@ -120,24 +285,25 @@ export default class ReportItems extends Component {
<div className={"main-color"} style={{ height: 199, width: '100%' }} /> <div className={"main-color"} style={{ height: 199, width: '100%' }} />
<div> <div>
<div style={{ display: 'flex', flexDirection: 'row', justifyContent: 'space-between', paddingRight: 25, paddingLeft: 25, marginTop: -150 }}> <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 Report</label> <label style={{ width: '20%', color: 'white', fontSize: 16, alignSelf: 'center', paddingTop: 8 }}>Master Data - Item Report</label>
<div style={{ color: 'white', width: '50%', height: 37, display: 'flex', backgroundColor: 'white', borderWidth: 2, alignItems: 'center', borderRadius: 6, paddingLeft: 5, paddingRight: 5 }}> <div style={{ color: 'white', width: '50%', height: 37, display: 'flex', backgroundColor: 'white', borderWidth: 2, alignItems: 'center', borderRadius: 6, paddingLeft: 5, paddingRight: 5, alignSelf: 'center' }}>
<img src={Images.searchBlack} style={{ marginRight: 10 }} /> <img src={Images.searchBlack} style={{ marginRight: 10 }} />
<InputBase <InputBase
style={{ width: '100%' }} style={{ width: '100%' }}
placeholder="Search" placeholder="Search"
value={""} value={this.state.search}
onChange={(e) => this.handleInputChange(e)} onChange={(e) => this.handleInputChange(e.target.value)}
inputProps={{ 'aria-label': 'naked' }} inputProps={{ 'aria-label': 'naked' }}
/> />
</div> </div>
<div style={{ width: '20%', justifyContent: 'space-around', display: 'flex' }}> <div style={{ width: '30%', justifyContent: 'flex-end', display: 'flex', flexFlow: 'wrap' }}>
<button <button
style={{ style={{
backgroundColor: 'transparent', backgroundColor: 'transparent',
cursor: 'pointer', cursor: 'pointer',
borderColor: 'transparent', borderColor: 'transparent',
padding: 0 padding: 0,
margin: 5
}} }}
onClick={() => null} onClick={() => null}
> >
...@@ -147,7 +313,8 @@ export default class ReportItems extends Component { ...@@ -147,7 +313,8 @@ export default class ReportItems extends Component {
style={{ style={{
backgroundColor: 'transparent', backgroundColor: 'transparent',
cursor: 'pointer', cursor: 'pointer',
borderColor: 'transparent' borderColor: 'transparent',
margin: 5
}} }}
onClick={() => null} onClick={() => null}
> >
...@@ -157,7 +324,8 @@ export default class ReportItems extends Component { ...@@ -157,7 +324,8 @@ export default class ReportItems extends Component {
style={{ style={{
backgroundColor: 'transparent', backgroundColor: 'transparent',
cursor: 'pointer', cursor: 'pointer',
borderColor: 'transparent' borderColor: 'transparent',
margin: 5
}} }}
onClick={() => null} onClick={() => null}
> >
...@@ -167,7 +335,8 @@ export default class ReportItems extends Component { ...@@ -167,7 +335,8 @@ export default class ReportItems extends Component {
style={{ style={{
backgroundColor: 'transparent', backgroundColor: 'transparent',
cursor: 'pointer', cursor: 'pointer',
borderColor: 'transparent' borderColor: 'transparent',
margin: 5
}} }}
onClick={() => null} onClick={() => null}
> >
...@@ -177,7 +346,8 @@ export default class ReportItems extends Component { ...@@ -177,7 +346,8 @@ export default class ReportItems extends Component {
style={{ style={{
backgroundColor: 'transparent', backgroundColor: 'transparent',
cursor: 'pointer', cursor: 'pointer',
borderColor: 'transparent' borderColor: 'transparent',
margin: 5
}} }}
> >
<img src={Images.add} onClick={() => this.setState({ add: true })} /> <img src={Images.add} onClick={() => this.setState({ add: true })} />
...@@ -188,7 +358,7 @@ export default class ReportItems extends Component { ...@@ -188,7 +358,7 @@ export default class ReportItems extends Component {
<MuiThemeProvider theme={getMuiTheme()}> <MuiThemeProvider theme={getMuiTheme()}>
<MUIDataTable <MUIDataTable
theme={getMuiTheme()} theme={getMuiTheme()}
data={data} data={this.state.dataTable}
columns={columns} columns={columns}
options={options} options={options}
/> />
...@@ -243,13 +413,15 @@ export default class ReportItems extends Component { ...@@ -243,13 +413,15 @@ export default class ReportItems extends Component {
{this.state.add && ( {this.state.add && (
<CreateReportItems <CreateReportItems
onClickClose={() => this.setState({ add: false })} onClickClose={() => this.setState({ add: false })}
data={this.state.indexData} data={this.state.listData}
createReportItems={this.createReportItems.bind(this)}
/> />
)} )}
{this.state.edit && ( {this.state.edit && (
<EditReportItems <EditReportItems
onClickClose={() => this.setState({ edit: false })} onClickClose={() => this.setState({ edit: false })}
data={this.state.indexData} data={this.state.listData[this.state.selectIndex]}
updateReportItems={this.updateReportItems.bind(this)}
/> />
)} )}
{this.state.visibleUpload && ( {this.state.visibleUpload && (
......
import React, { Component } from 'react'; import React, { Component } from 'react';
import { TextField, Typography } from '@material-ui/core'; import { TextField, Typography } from '@material-ui/core';
import * as R from 'ramda';
import api from '../../../api';
import Autocomplete from '@material-ui/lab/Autocomplete';
import { titleCase } from '../../../library/Utils';
import format from "date-fns/format";
import { DatePicker } from '@material-ui/pickers'; import { DatePicker } from '@material-ui/pickers';
const companies = [ const companies = [
...@@ -32,21 +37,6 @@ const companies = [ ...@@ -32,21 +37,6 @@ const companies = [
}, },
]; ];
const reportTypes = [
{
value: '',
label: '',
},
{
value: '1',
label: 'KPI',
},
{
value: '2',
label: 'KPI',
},
];
const parents = [ const parents = [
{ {
value: '-', value: '-',
...@@ -66,9 +56,12 @@ export default class CreateReportItems extends Component { ...@@ -66,9 +56,12 @@ export default class CreateReportItems extends Component {
constructor(props) { constructor(props) {
super(props) super(props)
this.state = { this.state = {
reportType: null,
company: null,
startDate: new Date(), startDate: new Date(),
endDate: new Date(), endDate: new Date(),
listReportType: null,
listCompany: null,
} }
} }
...@@ -85,7 +78,73 @@ export default class CreateReportItems extends Component { ...@@ -85,7 +78,73 @@ export default class CreateReportItems extends Component {
}; };
componentDidMount() { componentDidMount() {
console.log(this.props.data); this.getReportType()
this.getPerusahaan()
}
handleChange(e, type) {
let data = this.state
let isDate = type !== '' ? true : false
if (isDate && type == 'start_date') {
this.setState({ startDate: format(e, 'yyyy-MM-dd') }, () => {
// console.log(this.state.startDate)
})
} else if (isDate && type == 'end_date') {
this.setState({ endDate: format(e, 'yyyy-MM-dd') }, () => {
// console.log(this.state.endDate)
})
} else {
// this.setState({...data, tempData: {...this.state.tempData, [e.target.name] : e.target.value}})
}
}
validasi() {
}
getReportType() {
api.create().getReportType().then((response) => {
console.log(response)
if(response.data.status === 'success') {
let data = response.data.data
let reportData = data.map((item) => {
return {
type_report_id: item.type_report_id,
type_report_name: item.type_report_name
}
})
let defaultProps = {
options: reportData,
getOptionLabel: (option) => titleCase(option.type_report_name),
};
this.setState({listReportType: defaultProps, reportData: response.data.data})
} else {
alert(response.data.message)
}
})
}
getPerusahaan() {
api.create().getPerusahaan().then((response) => {
console.log(response)
if(response.data.status === 'success') {
let data = response.data.data
let companyData = data.map((item) => {
return {
company_id: item.company_id,
company_name: item.company_name
}
})
let defaultProps = {
options: companyData,
getOptionLabel: (option) => titleCase(option.company_name),
};
this.setState({listCompany: defaultProps, companyData: response.data.data})
} else {
alert(response.data.message)
}
})
} }
render() { render() {
...@@ -114,7 +173,7 @@ export default class CreateReportItems extends Component { ...@@ -114,7 +173,7 @@ export default class CreateReportItems extends Component {
<div className="border-bottom grid grid-2x grid-mobile-none gap-15px" style={{ padding: 20 }}> <div className="border-bottom grid grid-2x grid-mobile-none gap-15px" style={{ padding: 20 }}>
<div className="column-1"> <div className="column-1">
<div style={{ backgroundColor: '#e8e8e8', padding: 10, borderRadius: 5 }}> <div className="margin-top-10px" style={{ backgroundColor: '#e8e8e8', padding: 10, borderRadius: 5 }}>
<TextField <TextField
style={{ width: '100%' }} style={{ width: '100%' }}
value={1} value={1}
...@@ -140,41 +199,15 @@ export default class CreateReportItems extends Component { ...@@ -140,41 +199,15 @@ export default class CreateReportItems extends Component {
}} }}
/> />
</div> </div>
<div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}> <div className="margin-top-10px" style={{paddingLeft: 10}} >
<TextField <Autocomplete
{...this.state.listCompany}
id="company" id="company"
style={{ width: '100%' }} onChange={(event, newInputValue) => this.setState({company: newInputValue})}
select debug
label="Perusahaan" renderInput={(params) => <TextField {...params} label="Perusahaan" margin="normal" style={{marginTop: 7}}/>}
// onChange={handleChange} value={this.state.company}
helperText="" />
SelectProps={{
native: true,
}}
InputLabelProps={{
style: {
fontSize: 11,
fontWeight: 600,
fontFamily: 'Nunito Sans, sans-serif',
color: '#7e8085',
paddingLeft: 10
}
}}
inputProps={{
style: {
fontSize: 11,
fontWeight: 600,
fontFamily: 'Nunito Sans, sans-serif',
paddingLeft: 10
}
}}
>
{companies.map((option) => (
<option key={option.value} value={option.value}>
{option.label}
</option>
))}
</TextField>
</div> </div>
<div style={{ padding: 10, borderRadius: 5 }}> <div style={{ padding: 10, borderRadius: 5 }}>
<TextField <TextField
...@@ -228,41 +261,15 @@ export default class CreateReportItems extends Component { ...@@ -228,41 +261,15 @@ export default class CreateReportItems extends Component {
> >
</TextField> </TextField>
</div> </div>
<div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}> <div className="margin-top-10px" style={{paddingLeft: 10}} >
<TextField <Autocomplete
id="dataType" {...this.state.listReportType}
style={{ width: '100%' }} id="reportTypes"
select onChange={(event, newInputValue) => this.setState({reportType: newInputValue})}
label="Tipe Data" debug
// onChange={handleChange} renderInput={(params) => <TextField {...params} label="Tipe Data" margin="normal" style={{marginTop: 7}}/>}
helperText="" value={this.state.reportType}
SelectProps={{ />
native: true,
}}
InputLabelProps={{
style: {
fontSize: 11,
fontWeight: 600,
fontFamily: 'Nunito Sans, sans-serif',
color: '#7e8085',
paddingLeft: 10
}
}}
inputProps={{
style: {
fontSize: 11,
fontWeight: 600,
fontFamily: 'Nunito Sans, sans-serif',
paddingLeft: 10
}
}}
>
{dataTypes.map((option) => (
<option key={option.value} value={option.value}>
{option.label}
</option>
))}
</TextField>
</div> </div>
<div className="margin-top-10px" style={{ backgroundColor: '#e8e8e8', padding: 10, borderRadius: 5 }}> <div className="margin-top-10px" style={{ backgroundColor: '#e8e8e8', padding: 10, borderRadius: 5 }}>
...@@ -364,41 +371,15 @@ export default class CreateReportItems extends Component { ...@@ -364,41 +371,15 @@ export default class CreateReportItems extends Component {
</div> </div>
<div className="column-2"> <div className="column-2">
<div style={{ padding: 10, borderRadius: 5 }}> <div className="margin-top-10px" style={{paddingLeft: 10}} >
<TextField <Autocomplete
id="reportType" {...this.state.listReportType}
style={{ width: '100%' }} id="reportTypes"
select onChange={(event, newInputValue) => this.setState({reportType: newInputValue})}
label="Jenis Laporan" debug
// onChange={handleChange} renderInput={(params) => <TextField {...params} label="Jenis Laporan" margin="normal" style={{marginTop: 7}}/>}
helperText="" value={this.state.reportType}
SelectProps={{ />
native: true,
}}
InputLabelProps={{
style: {
fontSize: 11,
fontWeight: 600,
fontFamily: 'Nunito Sans, sans-serif',
color: '#7e8085',
paddingLeft: 10
}
}}
inputProps={{
style: {
fontSize: 11,
fontWeight: 600,
fontFamily: 'Nunito Sans, sans-serif',
paddingLeft: 10
}
}}
>
{reportTypes.map((option) => (
<option key={option.value} value={option.value}>
{option.label}
</option>
))}
</TextField>
</div> </div>
<div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}> <div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}>
<TextField <TextField
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment