Commit 66f78845 authored by d.arizona's avatar d.arizona

apdet ngantuk

parent 8115bdd0
...@@ -128,6 +128,7 @@ const create = (baseURL = 'https://tia.eksad.com/tia-reporting-dev/public/') => ...@@ -128,6 +128,7 @@ const create = (baseURL = 'https://tia.eksad.com/tia-reporting-dev/public/') =>
const uploadReportItems = (body) => api.post('/item_report/import_item_report', body) const uploadReportItems = (body) => api.post('/item_report/import_item_report', body)
const getItemReportHierarki = (body) => api.post('item_report/get_item_report_hierarki', body) const getItemReportHierarki = (body) => api.post('item_report/get_item_report_hierarki', body)
const saveVisualisasiReport = (body) => api.post('item_report/save_visualization', body) const saveVisualisasiReport = (body) => api.post('item_report/save_visualization', body)
const getReportParent = (body) => api.post('item_report/get_parent_item_report', body)
//PARAMETER //PARAMETER
const getAllParameter = () => api.get('/setting/get_all_setting') const getAllParameter = () => api.get('/setting/get_all_setting')
...@@ -216,7 +217,8 @@ const create = (baseURL = 'https://tia.eksad.com/tia-reporting-dev/public/') => ...@@ -216,7 +217,8 @@ const create = (baseURL = 'https://tia.eksad.com/tia-reporting-dev/public/') =>
getItemReportHierarki, getItemReportHierarki,
getMenuByRole, getMenuByRole,
saveVisualisasiReport, saveVisualisasiReport,
saveVisualisasiPerusahaan saveVisualisasiPerusahaan,
getReportParent
} }
} }
......
...@@ -452,7 +452,7 @@ export default class ReportItems extends Component { ...@@ -452,7 +452,7 @@ export default class ReportItems extends Component {
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.sort((a,b) => a.item_report_id-b.item_report_id).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 })
......
...@@ -53,7 +53,7 @@ export default class CreateReportItems extends Component { ...@@ -53,7 +53,7 @@ export default class CreateReportItems extends Component {
this.getInputType() this.getInputType()
this.getPerusahaan() this.getPerusahaan()
this.getReportType() this.getReportType()
this.getParent() // this.getParent()
} }
...@@ -169,7 +169,7 @@ export default class CreateReportItems extends Component { ...@@ -169,7 +169,7 @@ export default class CreateReportItems extends Component {
getInputType() { getInputType() {
api.create().getInputType().then((response) => { api.create().getInputType().then((response) => {
// console.log(response) console.log(response.data)
if(response.data.status === 'success') { if(response.data.status === 'success') {
let data = response.data.data let data = response.data.data
let inputData = data.map((item) => { let inputData = data.map((item) => {
...@@ -234,25 +234,31 @@ export default class CreateReportItems extends Component { ...@@ -234,25 +234,31 @@ export default class CreateReportItems extends Component {
} }
getParent() { getParent() {
api.create().getReportItems().then((response) => { if (this.state.reportType !== null && this.state.company !== null) {
// console.log(response) let payload = {
if(response.data.status === 'success') { "report_id": this.state.reportType.report_id,
let data = response.data.data "company_id": this.state.company.company_id
let parentData = data.map((item) => {
return {
item_report_id: item.item_report_id,
report_name: item.report_name
}
})
let defaultProps = {
options: parentData,
getOptionLabel: (option) => titleCase(option.report_name),
};
this.setState({listParent: defaultProps, parentData: response.data.data})
} else {
alert(response.data.message)
} }
}) api.create().getReportParent(payload).then((response) => {
console.log(response)
if(response.data.status === 'success') {
let data = response.data.data
let parentData = data.map((item) => {
return {
item_report_id: item.item_report_id,
description: item.description
}
})
let defaultProps = {
options: parentData,
getOptionLabel: (option) => titleCase(option.description),
};
this.setState({listParent: defaultProps, parentData: response.data.data})
} else {
alert(response.data.message)
}
})
}
} }
handleDate(item) { handleDate(item) {
...@@ -314,7 +320,7 @@ export default class CreateReportItems extends Component { ...@@ -314,7 +320,7 @@ export default class CreateReportItems extends Component {
<Autocomplete <Autocomplete
{...this.state.listCompany} {...this.state.listCompany}
id="company" id="company"
onChange={(event, newInputValue) => this.setState({company: newInputValue})} onChange={(event, newInputValue) => this.setState({company: newInputValue}, () => this.getParent())}
debug debug
renderInput={(params) => renderInput={(params) =>
<TextField {...params} <TextField {...params}
...@@ -570,6 +576,7 @@ export default class CreateReportItems extends Component { ...@@ -570,6 +576,7 @@ export default class CreateReportItems extends Component {
id="parentId" id="parentId"
onChange={(event, newInputValue) => this.setState({parent: newInputValue})} onChange={(event, newInputValue) => this.setState({parent: newInputValue})}
debug debug
disabled={this.state.reportType == null || this.state.company == null}
renderInput={(params) => renderInput={(params) =>
<TextField {...params} <TextField {...params}
label="Parent ID" label="Parent ID"
......
...@@ -145,13 +145,13 @@ export default class EditReportItems extends Component { ...@@ -145,13 +145,13 @@ export default class EditReportItems extends Component {
updateReportItems() { updateReportItems() {
// alert('test') // alert('test')
let payload = { let payload = {
"item_report_id": this.state.parent.item_report_id, "item_report_id": this.state.tempData.item_report_id,
"report_id": this.state.reportType.report_id, "report_id": this.state.reportType == null? this.state.tempData.report_id : this.state.reportType.report_id,
"company_id": this.state.company.company_id, "company_id": this.state.company == null? this.state.tempData.company_id : this.state.company.company_id,
"description": this.state.tempData.description, "description": this.state.tempData.description,
"orders": this.state.tempData.order, "orders": this.state.tempData.order,
"parent": this.state.tempData.parent, "parent": this.state.parent == null? this.state.tempData.parent : this.state.parent.item_report_id,
"type_report_id": this.state.InputType.type_report_id, "type_report_id": this.state.InputType == null? this.state.tempData.type_report_id : this.state.InputType.type_report_id,
"formula": this.state.tempData.formula, "formula": this.state.tempData.formula,
"uom": this.state.tempData.uom, "uom": this.state.tempData.uom,
"weight": this.state.tempData.weight, "weight": this.state.tempData.weight,
...@@ -259,27 +259,32 @@ export default class EditReportItems extends Component { ...@@ -259,27 +259,32 @@ export default class EditReportItems extends Component {
} }
getParent() { getParent() {
api.create().getReportItems().then((response) => { if (this.state.reportType !== null && this.state.company !== null) {
// console.log(response) let payload = {
if(response.data.status === 'success') { "report_id": this.state.reportType.report_id,
let data = response.data.data "company_id": this.state.company.company_id
let parentData = data.map((item) => {
return {
item_report_id: item.item_report_id,
report_name: item.report_name
}
})
let defaultProps = {
options: parentData,
getOptionLabel: (option) => titleCase(option.report_name),
};
let index = parentData.findIndex((val) => val.item_report_id === this.state.tempData.item_report_id)
this.setState({listParent: defaultProps, parent: index === -1 ? null : parentData[index]})
} else {
alert(response.data.message)
} }
}) api.create().getReportParent(payload).then((response) => {
console.log(response)
if(response.data.status === 'success') {
let data = response.data.data
let parentData = data.map((item) => {
return {
item_report_id: item.item_report_id,
description: item.description
}
})
let defaultProps = {
options: parentData,
getOptionLabel: (option) => titleCase(option.description),
};
let index = parentData.findIndex((val) => val.item_report_id === this.state.tempData.parent)
this.setState({listParent: defaultProps, parent: index == -1? null : parentData[index]})
} else {
alert(response.data.message)
}
})
}
} }
render() { render() {
...@@ -338,7 +343,7 @@ export default class EditReportItems extends Component { ...@@ -338,7 +343,7 @@ export default class EditReportItems extends Component {
<Autocomplete <Autocomplete
{...this.state.listCompany} {...this.state.listCompany}
id="company" id="company"
onChange={(event, newInputValue) => this.setState({company: newInputValue})} onChange={(event, newInputValue) => this.setState({company: newInputValue}, () => this.getParent())}
debug debug
renderInput={(params) => renderInput={(params) =>
<TextField {...params} <TextField {...params}
...@@ -515,7 +520,7 @@ export default class EditReportItems extends Component { ...@@ -515,7 +520,7 @@ export default class EditReportItems extends Component {
<Autocomplete <Autocomplete
{...this.state.listReportType} {...this.state.listReportType}
id="reportType" id="reportType"
onChange={(event, newInputValue) => this.setState({reportType: newInputValue})} onChange={(event, newInputValue) => this.setState({reportType: newInputValue}, () => this.getParent())}
debug debug
renderInput={(params) => renderInput={(params) =>
<TextField {...params} <TextField {...params}
...@@ -566,6 +571,7 @@ export default class EditReportItems extends Component { ...@@ -566,6 +571,7 @@ export default class EditReportItems extends Component {
{...this.state.listParent} {...this.state.listParent}
id="parentId" id="parentId"
onChange={(event, newInputValue) => this.setState({parent: newInputValue})} onChange={(event, newInputValue) => this.setState({parent: newInputValue})}
disabled={this.state.reportType == null || this.state.company == null}
debug debug
renderInput={(params) => renderInput={(params) =>
<TextField {...params} <TextField {...params}
......
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