Commit 550e0882 authored by d.arizona's avatar d.arizona

lebih baik kita usai disini

parent 574b28ed
...@@ -78,7 +78,9 @@ export default class CorporateAnnualTarget extends Component { ...@@ -78,7 +78,9 @@ export default class CorporateAnnualTarget extends Component {
buttonDraft: true, buttonDraft: true,
updateBy: '', updateBy: '',
handleTekTekTek: 0, handleTekTekTek: 0,
editable: false editable: false,
dataCustomerPrs: [],
dataInternalBsn: []
} }
this.fileHandler = this.fileHandler.bind(this); this.fileHandler = this.fileHandler.bind(this);
...@@ -104,12 +106,35 @@ export default class CorporateAnnualTarget extends Component { ...@@ -104,12 +106,35 @@ export default class CorporateAnnualTarget extends Component {
// console.log(JSON.stringify(payload)) // console.log(JSON.stringify(payload))
api.create().getDetailReportMB(payload).then(response => { api.create().getDetailReportMB(payload).then(response => {
let dataTable = [] let dataTable = []
let dataCustomerPrs = []
let dataInternalBsn = []
// console.log(response) // console.log(response)
let res = response.data.data let res = response.data.data
const handlePushChild = (item) => { const handlePushChild = (item) => {
let indexIDzz = dataTable.findIndex((val) => val[1] === item.id) let indexIDzz = dataTable.findIndex((val) => val[1] === item.id)
if (indexIDzz === -1) { if (indexIDzz === -1) {
let parentTrue = item.parent_name == 'INTERNAL BUSINESS PROCESS PERSPECTIVE' || item.parent_name == 'CUSTOMER PERSPECTIVE' let parentTrue = item.parent_name == 'INTERNAL BUSINESS PROCESS PERSPECTIVE' || item.parent_name == 'CUSTOMER PERSPECTIVE'
if (item.parent_name == 'INTERNAL BUSINESS PROCESS PERSPECTIVE') {
if (item.type_report_id !== 4) {
dataInternalBsn.push({
id: item.id,
name: item.description,
check: false
})
}
}
if (item.parent_name == 'CUSTOMER PERSPECTIVE') {
if (item.type_report_id !== 4) {
dataCustomerPrs.push({
id: item.id,
name: item.description,
check: false
})
}
}
dataTable.push([ dataTable.push([
item.type_report_id, item.type_report_id,
item.id, item.id,
...@@ -192,7 +217,9 @@ export default class CorporateAnnualTarget extends Component { ...@@ -192,7 +217,9 @@ export default class CorporateAnnualTarget extends Component {
} }
} }
}) })
this.setState({ dataTable, loading: false, dataReal: res, editable: true }) this.setState({ dataTable, loading: false, dataReal: res, editable: true, dataCustomerPrs, dataInternalBsn }, () => {
console.log(dataCustomerPrs)
})
}) })
} }
...@@ -325,13 +352,37 @@ export default class CorporateAnnualTarget extends Component { ...@@ -325,13 +352,37 @@ export default class CorporateAnnualTarget extends Component {
console.log(JSON.stringify(this.state.payload)) console.log(JSON.stringify(this.state.payload))
api.create().checkUploadMB(this.state.payload).then(response => { api.create().checkUploadMB(this.state.payload).then(response => {
// // console.log(JSON.stringify(this.state.payload)); // // console.log(JSON.stringify(this.state.payload));
// console.log(response) console.log(response)
if (response.data) { if (response.data) {
if (response.data.status === 'success') { if (response.data.status === 'success') {
// this.setState({ visibleUpload: false, visibleCAT: false }) // this.setState({ visibleUpload: false, visibleCAT: false })
this.setState({ visibleUpload: false, visibleCAT: false }) this.setState({ visibleUpload: false, visibleCAT: false })
let dataTable = response.data.data.map((item, index) => { let dataTable = []
return [ let custoId = 0
let bisnsId = 0
let dataDelete = this.state.dataDelete
response.data.data.map((item, index) => {
if (item.item_report == 'CUSTOMER PERSPECTIVE') {
custoId = item.item_report_id
}
if (item.item_report == 'INTERNAL BUSINESS PROCESS PERSPECTIVE') {
bisnsId = item.item_report_id
}
if (item.type_report_id !== 4 && item.parent !== null && (item.parent == custoId || item.parent == bisnsId)) {
let indexCust = this.state.dataCustomerPrs.findIndex((val) => val.name == item.item_report)
let indexBisn = this.state.dataInternalBsn.findIndex((val) => val.name == item.item_report)
if (indexCust !== -1 && item.item_report_id == 0) {
dataDelete.push(this.state.dataCustomerPrs[indexCust].id)
}
if (indexBisn !== -1 && item.item_report_id == 0) {
dataDelete.push(this.state.dataInternalBsn[indexBisn].id)
}
}
dataTable.push([
item.type_report_id, item.type_report_id,
item.item_report_id, item.item_report_id,
item.parent, item.parent,
...@@ -363,11 +414,11 @@ export default class CorporateAnnualTarget extends Component { ...@@ -363,11 +414,11 @@ export default class CorporateAnnualTarget extends Component {
item.strategic, item.strategic,
item.pic, item.pic,
item.error item.error
] ])
}) })
// console.log(dataTable) console.log(dataTable)
// console.log(this.state.buttonError) // console.log(this.state.buttonError)
this.setState({ dataTable, dataLoaded: true, loading: false, buttonError: false, editable: true }, () => { this.setState({ dataTable, dataLoaded: true, loading: false, buttonError: false, editable: true, dataDelete }, () => {
this.state.dataTable.map(item => { this.state.dataTable.map(item => {
if (item[30].length > 0) { if (item[30].length > 0) {
// console.log('masuk') // console.log('masuk')
...@@ -382,8 +433,9 @@ export default class CorporateAnnualTarget extends Component { ...@@ -382,8 +433,9 @@ export default class CorporateAnnualTarget extends Component {
} }
uploadCAT(type) { uploadCAT(type) {
// let dataDelete = this.state.dataDelete
// console.log(dataDelete)
let payload = { "item_report_id": this.state.dataDelete } let payload = { "item_report_id": this.state.dataDelete }
if (this.state.dataDelete.length > 0) { if (this.state.dataDelete.length > 0) {
api.create().deleteAllItemReport(payload).then((response) => { api.create().deleteAllItemReport(payload).then((response) => {
this.functionUpload(type) this.functionUpload(type)
...@@ -436,7 +488,7 @@ export default class CorporateAnnualTarget extends Component { ...@@ -436,7 +488,7 @@ export default class CorporateAnnualTarget extends Component {
"cat": data "cat": data
} }
// console.log(data); // console.log(data);
// console.log(JSON.stringify(body)) console.log(JSON.stringify(body))
api.create('UPLOAD').uploadMasterBudget(body).then(response => { api.create('UPLOAD').uploadMasterBudget(body).then(response => {
// console.log(response); // console.log(response);
if (response.data) { if (response.data) {
...@@ -888,7 +940,7 @@ export default class CorporateAnnualTarget extends Component { ...@@ -888,7 +940,7 @@ export default class CorporateAnnualTarget extends Component {
} }
const handleTambah = (data, rowIndex) => { const handleTambah = (data, rowIndex) => {
// console.log(dataTable2) console.log(dataTable2)
let newData = [] let newData = []
dataTable2.map((item, index) => { dataTable2.map((item, index) => {
newData.push(item) newData.push(item)
...@@ -932,6 +984,7 @@ export default class CorporateAnnualTarget extends Component { ...@@ -932,6 +984,7 @@ export default class CorporateAnnualTarget extends Component {
this.setState({ dataTable: dataTable2 }, () => { this.setState({ dataTable: dataTable2 }, () => {
setTimeout(() => { setTimeout(() => {
this.setState({ loading: false }) this.setState({ loading: false })
console.log(dataTable2)
}, 500) }, 500)
}) })
} }
......
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