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