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 = "") => {
const uploadAttachment = (body) => api.post('transaction/master_budget/upload_attachment', body)
const getRevision = (body) => api.post('transaction/master_budget/get_revision', body)
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 getLastestUpdateMB = (body) => api.post('/transaction/master_budget/get_latest_update', body)
const createSubmitReport = (body) => api.post('transaction/master_budget/create_submission_report', body)
......
......@@ -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}%`),
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.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 },
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),
......@@ -163,7 +163,7 @@ export default class CorporateAnnualTarget extends Component {
item.type_report_id == 1 ? `${Number(item.weight) * 100}%` : item.cat.weight,
item.cat.uom,
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.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),
......@@ -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.uom,
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.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),
......@@ -459,6 +459,7 @@ export default class CorporateAnnualTarget extends Component {
let dataTableBaru = this.state.dataTable
let dataTampung = []
let weightReal = null
let handleKosongKPIMAXYTD = false
this.state.dataTable.map((i, index) => {
if (i[0] == 1) {
dataTampung.push({
......@@ -472,6 +473,21 @@ export default class CorporateAnnualTarget extends Component {
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) {
let indexID = dataTampung.findIndex((val) => val.id == i[2])
if (indexID !== -1) {
......@@ -488,6 +504,9 @@ export default class CorporateAnnualTarget extends Component {
weightReal = i[7]
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 {
}
console.log(totalWeight)
// 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 })
} else {
api.create().validateSubmitReport(payload).then((response) => {
......@@ -779,6 +800,25 @@ export default class CorporateAnnualTarget extends Component {
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) => {
// let valueReal = value.replace('%', '')
......@@ -957,9 +997,9 @@ export default class CorporateAnnualTarget extends Component {
customBodyRender: (val, tableMeta) => {
return (
// handleAction(tableMeta.rowData[2]) &&
handleAction(tableMeta.rowData[2], tableMeta.rowData[0], tableMeta) && <div style={{ display: 'flex' }}>
<div style={{ display: 'flex' }}>
{/* {tableMeta.rowData[6] === "Active" ? */}
{<span>
{handleAction(tableMeta.rowData[2], tableMeta.rowData[0], tableMeta) && <span>
<LightTooltip title={'Add'} arrow>
<button
style={{
......@@ -977,7 +1017,7 @@ export default class CorporateAnnualTarget extends Component {
</button>
</LightTooltip>
</span>}
<span>
{handleAction(tableMeta.rowData[2], tableMeta.rowData[0]) && <span>
<LightTooltip title={'Delete'} arrow>
<button
style={{
......@@ -994,7 +1034,7 @@ export default class CorporateAnnualTarget extends Component {
<img src={Images.delete} />
</button>
</LightTooltip>
</span>
</span>}
</div >
);
}
......@@ -1190,7 +1230,7 @@ export default class CorporateAnnualTarget extends Component {
debug
disableClearable
disabled={!handleAction(tableMeta.rowData[2], tableMeta.rowData[0])}
value={val}
value={handleValueDropdown(val, 'KPI', tableMeta)}
style={{ padding: 0, margin: 0 }}
renderInput={(params) =>
<div ref={params.InputProps.ref} style={{ padding: 0, margin: 0 }}>
......@@ -1223,7 +1263,7 @@ export default class CorporateAnnualTarget extends Component {
onChange={(event, newInputValue) => handleChangeDropdown(newInputValue, tableMeta)}
debug
disableClearable
value={val}
value={handleValueDropdown(val, 'MAX', tableMeta)}
style={{ padding: 0, margin: 0 }}
disabled={!handleAction(tableMeta.rowData[2], tableMeta.rowData[0])}
renderInput={(params) =>
......@@ -1261,7 +1301,7 @@ export default class CorporateAnnualTarget extends Component {
}
debug
disableClearable
value={val}
value={handleValueDropdown(val, 'FORMULA', tableMeta)}
disabled={!handleAction(tableMeta.rowData[2], tableMeta.rowData[0])}
style={{ padding: 0, margin: 0 }}
renderInput={(params) =>
......@@ -2012,7 +2052,7 @@ export default class CorporateAnnualTarget extends Component {
}
]
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
// css={override}
size={20}
......@@ -2274,8 +2314,9 @@ export default class CorporateAnnualTarget extends Component {
{(this.props.lastStatus === 'SUBMIT' || this.props.lastStatus === 'REVISION') && <button
type="button"
onClick={() =>
this.setState({ loading: true }, () => {
this.setState({ loading: true, dataTable: dataTable2, buttonDraft: false }, () => {
setTimeout(() => {
this.handleValidate()
this.setState({ loading: false, buttonError: this.state.errorPreview === true ? true : false, editable: false })
}, 100)
})
......@@ -2289,7 +2330,7 @@ export default class CorporateAnnualTarget extends Component {
{(this.props.lastStatus === 'SUBMIT' || this.props.lastStatus === 'REVISION') && <button
className="button"
type="button"
disabled={this.state.buttonError}
disabled={this.state.buttonDraft}
style={{
backgroundColor: 'transparent',
cursor: this.state.editable === true ? 'default' : 'pointer',
......@@ -2320,6 +2361,7 @@ export default class CorporateAnnualTarget extends Component {
borderColor: 'transparent',
outline: 'none'
}}
disabled={this.state.buttonDraft}
onClick={() =>
this.state.editable === 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