Commit 3685fb2d authored by Dida Adams Arizona's avatar Dida Adams Arizona

Merge branch 'didam' into 'master'

apdet

See merge request !484
parents 8469448f d3599430
...@@ -189,7 +189,7 @@ const create = (type = "") => { ...@@ -189,7 +189,7 @@ const create = (type = "") => {
const uploadAttachment = (body) => api.post('transaction/master_budget/upload_attachment', body) const uploadAttachment = (body) => api.post('transaction/master_budget/upload_attachment', body)
const getRevision = (body) => api.post('transaction/master_budget/get_revision', body) const getRevision = (body) => api.post('transaction/master_budget/get_revision', body)
const getPeriodeTransaction = () => api.get('transaction/get_periode') const getPeriodeTransaction = () => api.get('transaction/get_periode')
const deleteAttachment = (id) => api.post(`transaction/delete_attachment/${id}`) const deleteAttachment = (id) => api.post(`transaction/master_budget/delete_attachment/${id}`)
const getDetailReportMB = (body) => api.post('/transaction/master_budget/get_report_hierarki', body) const getDetailReportMB = (body) => api.post('/transaction/master_budget/get_report_hierarki', body)
const getLastestUpdateMB = (body) => api.post('/transaction/master_budget/get_latest_update', body) const getLastestUpdateMB = (body) => api.post('/transaction/master_budget/get_latest_update', body)
const createSubmitReport = (body) => api.post('transaction/master_budget/create_submission_report', body) const createSubmitReport = (body) => api.post('transaction/master_budget/create_submission_report', body)
......
...@@ -121,7 +121,7 @@ export default class CorporateAnnualTarget extends Component { ...@@ -121,7 +121,7 @@ export default class CorporateAnnualTarget extends Component {
item.type_report_id == 1 ? `${Number(item.weight) * 100}%` : (String(item.cat.weight).indexOf(".") == -1 ? item.cat.weight : `${Number(item.weight) * 100}%`), item.type_report_id == 1 ? `${Number(item.weight) * 100}%` : (String(item.cat.weight).indexOf(".") == -1 ? item.cat.weight : `${Number(item.weight) * 100}%`),
parentTrue ? item.cat.uom : item.uom, parentTrue ? item.cat.uom : item.uom,
parentTrue ? item.cat.kpi_type == "" ? null : { value: item.cat.kpi_type } : item.kpi_type == "" ? null : { value: item.kpi_type }, parentTrue ? item.cat.kpi_type == "" ? null : { value: item.cat.kpi_type } : item.kpi_type == "" ? null : { value: item.kpi_type },
parentTrue ? item.cat.max_ach == "" ? null : { value: item.cat.max_ach } : item.max_ach == "" ? null : { value: item.max_ach }, parentTrue ? item.cat.max_ach == "" ? null : { value: titleCase(item.cat.max_ach) } : item.max_ach == "" ? null : { value: titleCase(item.max_ach) },
parentTrue ? item.cat.formula == "" ? null : { value: item.cat.formula } : item.formula_ytd == "" ? null : { value: item.formula_ytd }, parentTrue ? item.cat.formula == "" ? null : { value: item.cat.formula } : item.formula_ytd == "" ? null : { value: item.formula_ytd },
item.cat.total_actual_before == "" ? item.cat.total_actual_before : String(item.cat.total_actual_before).indexOf(".") == -1 ? Number(item.cat.total_actual_before) : Number(item.cat.total_actual_before).toFixed(1), item.cat.total_actual_before == "" ? item.cat.total_actual_before : String(item.cat.total_actual_before).indexOf(".") == -1 ? Number(item.cat.total_actual_before) : Number(item.cat.total_actual_before).toFixed(1),
item.cat.january == "" ? item.cat.january : String(item.cat.january).indexOf(".") == -1 ? Number(item.cat.january) : Number(item.cat.january).toFixed(1), item.cat.january == "" ? item.cat.january : String(item.cat.january).indexOf(".") == -1 ? Number(item.cat.january) : Number(item.cat.january).toFixed(1),
...@@ -163,7 +163,7 @@ export default class CorporateAnnualTarget extends Component { ...@@ -163,7 +163,7 @@ export default class CorporateAnnualTarget extends Component {
item.type_report_id == 1 ? `${Number(item.weight) * 100}%` : item.cat.weight, item.type_report_id == 1 ? `${Number(item.weight) * 100}%` : item.cat.weight,
item.cat.uom, item.cat.uom,
item.kpi_type == "" ? null : { value: item.kpi_type }, item.kpi_type == "" ? null : { value: item.kpi_type },
item.max_ach == "" ? null : { value: item.max_ach }, item.max_ach == "" ? null : { value: titleCase(item.max_ach) },
item.formula == "" ? null : { value: item.formula_ytd }, item.formula == "" ? null : { value: item.formula_ytd },
item.cat.total_actual_before == "" ? item.cat.total_actual_before : String(item.cat.total_actual_before).indexOf(".") == -1 ? Number(item.cat.total_actual_before) : Number(item.cat.total_actual_before).toFixed(1), item.cat.total_actual_before == "" ? item.cat.total_actual_before : String(item.cat.total_actual_before).indexOf(".") == -1 ? Number(item.cat.total_actual_before) : Number(item.cat.total_actual_before).toFixed(1),
item.cat.january == "" ? item.cat.january : String(item.cat.january).indexOf(".") == -1 ? Number(item.cat.january) : Number(item.cat.january).toFixed(1), item.cat.january == "" ? item.cat.january : String(item.cat.january).indexOf(".") == -1 ? Number(item.cat.january) : Number(item.cat.january).toFixed(1),
...@@ -342,7 +342,7 @@ export default class CorporateAnnualTarget extends Component { ...@@ -342,7 +342,7 @@ export default class CorporateAnnualTarget extends Component {
item.type_report_id == 1 ? `${Number(item.weight) * 100}%` : (String(item.weight).indexOf(".") == -1 ? item.weight : `${Number(item.weight) * 100}%`), item.type_report_id == 1 ? `${Number(item.weight) * 100}%` : (String(item.weight).indexOf(".") == -1 ? item.weight : `${Number(item.weight) * 100}%`),
item.uom, item.uom,
item.kpi_type == "" || item.kpi_type == null ? null : { value: item.kpi_type }, item.kpi_type == "" || item.kpi_type == null ? null : { value: item.kpi_type },
item.max_ach == "" || item.max_ach == null ? null : { value: item.max_ach }, item.max_ach == "" || item.max_ach == null ? null : { value: titleCase(item.max_ach) },
item.formula_ytd == "" || item.formula_ytd == null ? null : { value: item.formula_ytd }, item.formula_ytd == "" || item.formula_ytd == null ? null : { value: item.formula_ytd },
item.total_actual_before == "" ? item.total_actual_before : String(item.total_actual_before).indexOf(".") == -1 ? Number(item.total_actual_before) : Number(item.total_actual_before).toFixed(1), item.total_actual_before == "" ? item.total_actual_before : String(item.total_actual_before).indexOf(".") == -1 ? Number(item.total_actual_before) : Number(item.total_actual_before).toFixed(1),
item.january == "" ? item.january : String(item.january).indexOf(".") == -1 ? Number(item.january) : Number(item.january).toFixed(1), item.january == "" ? item.january : String(item.january).indexOf(".") == -1 ? Number(item.january) : Number(item.january).toFixed(1),
...@@ -459,6 +459,7 @@ export default class CorporateAnnualTarget extends Component { ...@@ -459,6 +459,7 @@ export default class CorporateAnnualTarget extends Component {
let dataTableBaru = this.state.dataTable let dataTableBaru = this.state.dataTable
let dataTampung = [] let dataTampung = []
let weightReal = null let weightReal = null
let handleKosongKPIMAXYTD = false
this.state.dataTable.map((i, index) => { this.state.dataTable.map((i, index) => {
if (i[0] == 1) { if (i[0] == 1) {
dataTampung.push({ dataTampung.push({
...@@ -472,6 +473,21 @@ export default class CorporateAnnualTarget extends Component { ...@@ -472,6 +473,21 @@ export default class CorporateAnnualTarget extends Component {
totalWeight += Number(i[7] == "" || i[7] == undefined ? 0 : i[7].replace('%', '')) totalWeight += Number(i[7] == "" || i[7] == undefined ? 0 : i[7].replace('%', ''))
} }
if (i[2] !== null) {
let indexID = this.state.dataTable.findIndex((val) => val[1] == i[2])
console.log(indexID)
console.log(i[2])
if (indexID !== -1) {
console.log(dataTableBaru[indexID][6])
if (dataTableBaru[indexID][6] == 'INTERNAL BUSINESS PROCESS PERSPECTIVE' || dataTableBaru[indexID][6] == 'CUSTOMER PERSPECTIVE') {
if (i[6] == "" || i[7] == "" || i[9] == null || i[10] == null || i[11] == null) {
handleKosongKPIMAXYTD = true
console.log(handleKosongKPIMAXYTD)
}
}
}
}
if (i[2] !== null) { if (i[2] !== null) {
let indexID = dataTampung.findIndex((val) => val.id == i[2]) let indexID = dataTampung.findIndex((val) => val.id == i[2])
if (indexID !== -1) { if (indexID !== -1) {
...@@ -488,6 +504,9 @@ export default class CorporateAnnualTarget extends Component { ...@@ -488,6 +504,9 @@ export default class CorporateAnnualTarget extends Component {
weightReal = i[7] weightReal = i[7]
dataTampung[indexID].valChild = dataTampung[indexID].valChild + Number(i[7] == "" || i[7] == undefined ? 0 : i[7].replace('%', '')) dataTampung[indexID].valChild = dataTampung[indexID].valChild + Number(i[7] == "" || i[7] == undefined ? 0 : i[7].replace('%', ''))
} }
console.log(weightReal)
console.log(dataTableBaru[index][7])
console.log(dataTampung[indexID].valChild)
} }
} }
...@@ -533,7 +552,9 @@ export default class CorporateAnnualTarget extends Component { ...@@ -533,7 +552,9 @@ export default class CorporateAnnualTarget extends Component {
} }
console.log(totalWeight) console.log(totalWeight)
// this.setState({dataTable: dataTampung}) // this.setState({dataTable: dataTampung})
if (totalWeight < 100) { if (handleKosongKPIMAXYTD) {
this.setState({ alert: true, messageAlert: 'KPI / Weight / KPI Type / Max Ach / Formula YTD / Cannot be Empty', tipeAlert: 'warning', loading: false, buttonError: true, editable: true })
} else if (totalWeight < 100) {
this.setState({ alert: true, messageAlert: 'Total weight less than 100%', tipeAlert: 'warning', loading: false, buttonError: true, editable: true }) this.setState({ alert: true, messageAlert: 'Total weight less than 100%', tipeAlert: 'warning', loading: false, buttonError: true, editable: true })
} else { } else {
api.create().validateSubmitReport(payload).then((response) => { api.create().validateSubmitReport(payload).then((response) => {
...@@ -779,6 +800,25 @@ export default class CorporateAnnualTarget extends Component { ...@@ -779,6 +800,25 @@ export default class CorporateAnnualTarget extends Component {
dataTable2[tableMeta.rowIndex][25] = (valz == 'SUM' ? total : (valz == 'AVG' ? (total / 12) : lastValz)) dataTable2[tableMeta.rowIndex][25] = (valz == 'SUM' ? total : (valz == 'AVG' ? (total / 12) : lastValz))
} }
} }
const handleValueDropdown = (value, type, tableMeta) => {
let data = type == 'KPI'? this.state.kpiTypeList.options : (type == 'MAX'? this.state.maxAchList.options : this.state.formulaYtdList.options)
let index = 0
if (value == null) {
index = -1
} else {
index = data.findIndex((val) => val.value == value.value)
}
console.log(value)
console.log(data)
console.log(index)
if (index == -1) {
dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = null
return null
} else {
dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = value
return value
}
}
const handleChangePercentage = (value, tableMeta) => { const handleChangePercentage = (value, tableMeta) => {
// let valueReal = value.replace('%', '') // let valueReal = value.replace('%', '')
...@@ -957,9 +997,9 @@ export default class CorporateAnnualTarget extends Component { ...@@ -957,9 +997,9 @@ export default class CorporateAnnualTarget extends Component {
customBodyRender: (val, tableMeta) => { customBodyRender: (val, tableMeta) => {
return ( return (
// handleAction(tableMeta.rowData[2]) && // handleAction(tableMeta.rowData[2]) &&
handleAction(tableMeta.rowData[2], tableMeta.rowData[0], tableMeta) && <div style={{ display: 'flex' }}> <div style={{ display: 'flex' }}>
{/* {tableMeta.rowData[6] === "Active" ? */} {/* {tableMeta.rowData[6] === "Active" ? */}
{<span> {handleAction(tableMeta.rowData[2], tableMeta.rowData[0], tableMeta) && <span>
<LightTooltip title={'Add'} arrow> <LightTooltip title={'Add'} arrow>
<button <button
style={{ style={{
...@@ -977,7 +1017,7 @@ export default class CorporateAnnualTarget extends Component { ...@@ -977,7 +1017,7 @@ export default class CorporateAnnualTarget extends Component {
</button> </button>
</LightTooltip> </LightTooltip>
</span>} </span>}
<span> {handleAction(tableMeta.rowData[2], tableMeta.rowData[0]) && <span>
<LightTooltip title={'Delete'} arrow> <LightTooltip title={'Delete'} arrow>
<button <button
style={{ style={{
...@@ -994,7 +1034,7 @@ export default class CorporateAnnualTarget extends Component { ...@@ -994,7 +1034,7 @@ export default class CorporateAnnualTarget extends Component {
<img src={Images.delete} /> <img src={Images.delete} />
</button> </button>
</LightTooltip> </LightTooltip>
</span> </span>}
</div > </div >
); );
} }
...@@ -1190,7 +1230,7 @@ export default class CorporateAnnualTarget extends Component { ...@@ -1190,7 +1230,7 @@ export default class CorporateAnnualTarget extends Component {
debug debug
disableClearable disableClearable
disabled={!handleAction(tableMeta.rowData[2], tableMeta.rowData[0])} disabled={!handleAction(tableMeta.rowData[2], tableMeta.rowData[0])}
value={val} value={handleValueDropdown(val, 'KPI', tableMeta)}
style={{ padding: 0, margin: 0 }} style={{ padding: 0, margin: 0 }}
renderInput={(params) => renderInput={(params) =>
<div ref={params.InputProps.ref} style={{ padding: 0, margin: 0 }}> <div ref={params.InputProps.ref} style={{ padding: 0, margin: 0 }}>
...@@ -1223,7 +1263,7 @@ export default class CorporateAnnualTarget extends Component { ...@@ -1223,7 +1263,7 @@ export default class CorporateAnnualTarget extends Component {
onChange={(event, newInputValue) => handleChangeDropdown(newInputValue, tableMeta)} onChange={(event, newInputValue) => handleChangeDropdown(newInputValue, tableMeta)}
debug debug
disableClearable disableClearable
value={val} value={handleValueDropdown(val, 'MAX', tableMeta)}
style={{ padding: 0, margin: 0 }} style={{ padding: 0, margin: 0 }}
disabled={!handleAction(tableMeta.rowData[2], tableMeta.rowData[0])} disabled={!handleAction(tableMeta.rowData[2], tableMeta.rowData[0])}
renderInput={(params) => renderInput={(params) =>
...@@ -1261,7 +1301,7 @@ export default class CorporateAnnualTarget extends Component { ...@@ -1261,7 +1301,7 @@ export default class CorporateAnnualTarget extends Component {
} }
debug debug
disableClearable disableClearable
value={val} value={handleValueDropdown(val, 'FORMULA', tableMeta)}
disabled={!handleAction(tableMeta.rowData[2], tableMeta.rowData[0])} disabled={!handleAction(tableMeta.rowData[2], tableMeta.rowData[0])}
style={{ padding: 0, margin: 0 }} style={{ padding: 0, margin: 0 }}
renderInput={(params) => renderInput={(params) =>
...@@ -2012,7 +2052,7 @@ export default class CorporateAnnualTarget extends Component { ...@@ -2012,7 +2052,7 @@ export default class CorporateAnnualTarget extends Component {
} }
] ]
const loadingComponent = ( const loadingComponent = (
<div style={{ position: 'absolute', zIndex: 110, top: 0, left: 0, width: '100%', height: '100%', display: 'flex', justifyContent: 'center', alignItems: 'center', background: 'rgba(255,255,255,0.8)' }}> <div style={{ position: 'absolute', zIndex: 1500, top: 0, left: 0, width: '100%', height: '100%', display: 'flex', justifyContent: 'center', alignItems: 'center', background: 'rgba(255,255,255,0.8)' }}>
<PropagateLoader <PropagateLoader
// css={override} // css={override}
size={20} size={20}
...@@ -2274,8 +2314,9 @@ export default class CorporateAnnualTarget extends Component { ...@@ -2274,8 +2314,9 @@ export default class CorporateAnnualTarget extends Component {
{(this.props.lastStatus === 'SUBMIT' || this.props.lastStatus === 'REVISION') && <button {(this.props.lastStatus === 'SUBMIT' || this.props.lastStatus === 'REVISION') && <button
type="button" type="button"
onClick={() => onClick={() =>
this.setState({ loading: true }, () => { this.setState({ loading: true, dataTable: dataTable2, buttonDraft: false }, () => {
setTimeout(() => { setTimeout(() => {
this.handleValidate()
this.setState({ loading: false, buttonError: this.state.errorPreview === true ? true : false, editable: false }) this.setState({ loading: false, buttonError: this.state.errorPreview === true ? true : false, editable: false })
}, 100) }, 100)
}) })
...@@ -2289,7 +2330,7 @@ export default class CorporateAnnualTarget extends Component { ...@@ -2289,7 +2330,7 @@ export default class CorporateAnnualTarget extends Component {
{(this.props.lastStatus === 'SUBMIT' || this.props.lastStatus === 'REVISION') && <button {(this.props.lastStatus === 'SUBMIT' || this.props.lastStatus === 'REVISION') && <button
className="button" className="button"
type="button" type="button"
disabled={this.state.buttonError} disabled={this.state.buttonDraft}
style={{ style={{
backgroundColor: 'transparent', backgroundColor: 'transparent',
cursor: this.state.editable === true ? 'default' : 'pointer', cursor: this.state.editable === true ? 'default' : 'pointer',
...@@ -2320,6 +2361,7 @@ export default class CorporateAnnualTarget extends Component { ...@@ -2320,6 +2361,7 @@ export default class CorporateAnnualTarget extends Component {
borderColor: 'transparent', borderColor: 'transparent',
outline: 'none' outline: 'none'
}} }}
disabled={this.state.buttonDraft}
onClick={() => onClick={() =>
this.state.editable === true ? this.state.editable === true ?
null : this.setState({ loading: true }, () => null : this.setState({ loading: true }, () =>
......
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