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,19 +234,24 @@ export default class CreateReportItems extends Component { ...@@ -234,19 +234,24 @@ 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 = {
"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') { if(response.data.status === 'success') {
let data = response.data.data let data = response.data.data
let parentData = data.map((item) => { let parentData = data.map((item) => {
return { return {
item_report_id: item.item_report_id, item_report_id: item.item_report_id,
report_name: item.report_name description: item.description
} }
}) })
let defaultProps = { let defaultProps = {
options: parentData, options: parentData,
getOptionLabel: (option) => titleCase(option.report_name), getOptionLabel: (option) => titleCase(option.description),
}; };
this.setState({listParent: defaultProps, parentData: response.data.data}) this.setState({listParent: defaultProps, parentData: response.data.data})
} else { } else {
...@@ -254,6 +259,7 @@ export default class CreateReportItems extends Component { ...@@ -254,6 +259,7 @@ export default class CreateReportItems extends Component {
} }
}) })
} }
}
handleDate(item) { handleDate(item) {
let value = format(item, 'dd MMMM yyyy') let value = format(item, 'dd MMMM yyyy')
...@@ -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,28 +259,33 @@ export default class EditReportItems extends Component { ...@@ -259,28 +259,33 @@ 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 = {
"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') { if(response.data.status === 'success') {
let data = response.data.data let data = response.data.data
let parentData = data.map((item) => { let parentData = data.map((item) => {
return { return {
item_report_id: item.item_report_id, item_report_id: item.item_report_id,
report_name: item.report_name description: item.description
} }
}) })
let defaultProps = { let defaultProps = {
options: parentData, options: parentData,
getOptionLabel: (option) => titleCase(option.report_name), getOptionLabel: (option) => titleCase(option.description),
}; };
let index = parentData.findIndex((val) => val.item_report_id === this.state.tempData.parent)
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]})
this.setState({listParent: defaultProps, parent: index === -1 ? null : parentData[index]})
} else { } else {
alert(response.data.message) alert(response.data.message)
} }
}) })
} }
}
render() { render() {
const { startDate, endDate } = this.state; const { startDate, endDate } = this.state;
...@@ -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