Commit 4b705e7e authored by Dida Adams Arizona's avatar Dida Adams Arizona

Merge branch 'didam' into 'master'

Didam

See merge request !436
parents 963725e6 961c65fe
...@@ -172,7 +172,7 @@ export default class BudgetTahunan extends Component { ...@@ -172,7 +172,7 @@ export default class BudgetTahunan extends Component {
item.revision, item.revision,
item.current_status, item.current_status,
item.report_id, item.report_id,
item.is_can_upload, Number(item.revision) > 0? (String(item.current_status).toLocaleLowerCase() == 'submitted'? false : item.is_can_upload) : item.is_can_upload,
item.revision item.revision
] ]
}) })
...@@ -267,13 +267,21 @@ export default class BudgetTahunan extends Component { ...@@ -267,13 +267,21 @@ export default class BudgetTahunan extends Component {
api.create().getPeriodeTransaction().then(response => { api.create().getPeriodeTransaction().then(response => {
// let dateNow = new Date // let dateNow = new Date
// let year = this.state.rawData ? this.state.rawData.periode : format(dateNow, 'yyyy') // let year = this.state.rawData ? this.state.rawData.periode : format(dateNow, 'yyyy')
let currentYear = new Date().getFullYear()
console.log(currentYear)
if (response.data) { if (response.data) {
if (response.data.status === "success") { if (response.data.status === "success") {
let data = [] let data = []
response.data.data.map((item) => { response.data.data.map((item) => {
if ((item == this.state.latestPeriode || item > this.state.latestPeriode) && (item == this.state.lastPeriod || item < this.state.lastPeriod)) { if (this.state.isApprover) {
if (item >= 2000 && item <= (Number(currentYear) + 1)) {
data.push(item) data.push(item)
} }
} else {
if ((item >= 2000) && (item == this.state.lastPeriod || item < this.state.lastPeriod)) {
data.push(item)
}
}
}) })
let periodeData = data.map((item) => { let periodeData = data.map((item) => {
return { return {
...@@ -284,7 +292,11 @@ export default class BudgetTahunan extends Component { ...@@ -284,7 +292,11 @@ export default class BudgetTahunan extends Component {
options: periodeData, options: periodeData,
getOptionLabel: (option) => option.periode, getOptionLabel: (option) => option.periode,
}; };
let index = data.sort((a, b) => a - b).findIndex((val) => val === this.state.lastPeriod) let index = data.sort((a, b) => a - b).findIndex((val) => val === (this.state.lastPeriod == ""? String(Number(currentYear) + 1) : this.state.lastPeriod))
console.log(data)
console.log(this.state.lastPeriod)
console.log(periodeData)
console.log(index)
this.setState({ listPeriode: defaultProps, periode: index === -1 ? periodeData[0] : periodeData[index] }, () => { this.setState({ listPeriode: defaultProps, periode: index === -1 ? periodeData[0] : periodeData[index] }, () => {
if (this.state.isApprover === true) { if (this.state.isApprover === true) {
this.getCompanySubmitted() this.getCompanySubmitted()
...@@ -913,7 +925,7 @@ export default class BudgetTahunan extends Component { ...@@ -913,7 +925,7 @@ export default class BudgetTahunan extends Component {
<div style={{ width: '50%' }}> <div style={{ width: '50%' }}>
<Typography style={{ fontSize: '16px', color: '#4b4b4b', fontWeight: 'bold' }}>Attachment: </Typography> <Typography style={{ fontSize: '16px', color: '#4b4b4b', fontWeight: 'bold' }}>Attachment: </Typography>
</div> </div>
{!this.state.isApprover && ( {!this.state.isApprover && (this.state.lastStatus !== 'SUBMITTED' && this.state.lastStatus !== 'APPROVED') && (
<div style={{ width: '50%' }}> <div style={{ width: '50%' }}>
<button <button
style={{ style={{
...@@ -959,7 +971,7 @@ export default class BudgetTahunan extends Component { ...@@ -959,7 +971,7 @@ export default class BudgetTahunan extends Component {
: null : null
} }
</div> </div>
{!this.state.isApprover && ( {!this.state.isApprover && (this.state.lastStatus !== 'SUBMITTED' && this.state.lastStatus !== 'APPROVED') && (
<div style={{ width: '50%' }}> <div style={{ width: '50%' }}>
{this.state.listAttachment.length > 0 ? {this.state.listAttachment.length > 0 ?
this.state.listAttachment.map((item) => { this.state.listAttachment.map((item) => {
......
...@@ -86,10 +86,10 @@ export default class CorporateAnnualTarget extends Component { ...@@ -86,10 +86,10 @@ export default class CorporateAnnualTarget extends Component {
componentDidMount() { componentDidMount() {
this.getItemHierarki() this.getItemHierarki()
this.getLatestUpdate()
console.log(this.props.lastStatus);
this.getKPIType() this.getKPIType()
this.getMaxAch() this.getMaxAch()
this.getLatestUpdate()
console.log(this.props.lastStatus);
} }
...@@ -119,7 +119,7 @@ export default class CorporateAnnualTarget extends Component { ...@@ -119,7 +119,7 @@ export default class CorporateAnnualTarget extends Component {
item.level, item.level,
"", "",
item.description, item.description,
item.type_report_id == 1 ? `${Number(item.weight) * 100}%` : item.cat.weight, 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: item.cat.max_ach } : item.max_ach == "" ? null : { value: item.max_ach },
...@@ -289,8 +289,8 @@ export default class CorporateAnnualTarget extends Component { ...@@ -289,8 +289,8 @@ export default class CorporateAnnualTarget extends Component {
total_current_year: i[20] == 0? "0.0" : String(Number(nilaiTotal).toFixed(1)).trim(), total_current_year: i[20] == 0? "0.0" : String(Number(nilaiTotal).toFixed(1)).trim(),
total_next_year: i[21] === undefined ? "0.0" : reg.test(String(i[21])) === false ? "0.0" : String(Number(i[21]).toFixed(1)).trim(), total_next_year: i[21] === undefined ? "0.0" : reg.test(String(i[21])) === false ? "0.0" : String(Number(i[21]).toFixed(1)).trim(),
total_more_year: i[22] === undefined ? "0.0" : reg.test(String(i[22])) === false ? "0.0" : String(Number(i[22]).toFixed(1)).trim(), total_more_year: i[22] === undefined ? "0.0" : reg.test(String(i[22])) === false ? "0.0" : String(Number(i[22]).toFixed(1)).trim(),
strategic: i[23] === undefined ? "" : reg.test(String(i[23])) === false ? "" : String(i[23]).trim(), strategic: i[23] === undefined ? "" : String(i[23]).trim(),
pic: i[24] === undefined ? "" : reg.test(String(i[24])) === false ? "" : String(i[24]).trim() pic: i[24] === undefined ? "" : String(i[24]).trim()
}) })
} }
}) })
...@@ -491,8 +491,8 @@ export default class CorporateAnnualTarget extends Component { ...@@ -491,8 +491,8 @@ export default class CorporateAnnualTarget extends Component {
} }
data.push({ data.push({
"item_report_id": i[1], "item_report_id": i[1] == "" ? null : i[1],
"item_name": i[6] == "" ? null : String(i[6]), "item_name": String(i[6]),
"parent": i[2] == "" ? null : i[2], "parent": i[2] == "" ? null : i[2],
"weight": weightReal == null? String(i[7]) : weightReal, "weight": weightReal == null? String(i[7]) : weightReal,
"uom": String(i[8]), "uom": String(i[8]),
...@@ -556,9 +556,9 @@ export default class CorporateAnnualTarget extends Component { ...@@ -556,9 +556,9 @@ export default class CorporateAnnualTarget extends Component {
this.state.dataTable.map(i => { this.state.dataTable.map(i => {
// console.log(i[9] == null? "" : i[9].value) // console.log(i[9] == null? "" : i[9].value)
data.push({ data.push({
"item_report_id": i[1], "item_report_id": i[1] == "" ? null : i[1],
"item_name": i[1] == "" ? null : String(i[6]), "item_name": String(i[6]),
"parent": i[1] == "" ? null : i[2], "parent": i[2] == "" ? null : i[2],
"weight": String(i[7]), "weight": String(i[7]),
"uom": String(i[8]), "uom": String(i[8]),
"kpi_type": i[9] == null ? "" : i[9].value, "kpi_type": i[9] == null ? "" : i[9].value,
...@@ -636,6 +636,7 @@ export default class CorporateAnnualTarget extends Component { ...@@ -636,6 +636,7 @@ export default class CorporateAnnualTarget extends Component {
type: 'KPI_TYPE' type: 'KPI_TYPE'
} }
api.create().getAllSettingByType(body).then(response => { api.create().getAllSettingByType(body).then(response => {
// console.log(response)
if (response.data) { if (response.data) {
if (response.ok) { if (response.ok) {
if (response.data.status === 'success') { if (response.data.status === 'success') {
...@@ -650,6 +651,7 @@ export default class CorporateAnnualTarget extends Component { ...@@ -650,6 +651,7 @@ export default class CorporateAnnualTarget extends Component {
options: inputKPI, options: inputKPI,
getOptionLabel: (option) => titleCase(option.value), getOptionLabel: (option) => titleCase(option.value),
}; };
console.log(defaultProps)
this.setState({ kpiTypeList: defaultProps }) this.setState({ kpiTypeList: defaultProps })
} else { } else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => { this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
...@@ -1119,7 +1121,7 @@ export default class CorporateAnnualTarget extends Component { ...@@ -1119,7 +1121,7 @@ export default class CorporateAnnualTarget extends Component {
placeholder="" placeholder=""
defaultValue={value} defaultValue={value}
color={"#5198ea"} color={"#5198ea"}
disabled={this.props.isApprover ? true : ((this.props.lastStatus == 'SUBMIT' || this.props.lastStatus == 'REVISION') && this.props.prevRevision === false ? false : !handleAction(tableMeta.rowData[2]))} disabled={true}
onBlur={(event) => { onBlur={(event) => {
console.log(event.target.value) console.log(event.target.value)
// updateValue(event.target.value) // updateValue(event.target.value)
...@@ -1135,7 +1137,7 @@ export default class CorporateAnnualTarget extends Component { ...@@ -1135,7 +1137,7 @@ export default class CorporateAnnualTarget extends Component {
placeholder="" placeholder=""
defaultValue={value} defaultValue={value}
color={"#5198ea"} color={"#5198ea"}
disabled={this.props.isApprover ? true : ((this.props.lastStatus == 'SUBMIT' || this.props.lastStatus == 'REVISION') && this.props.prevRevision === false ? false : !handleAction(tableMeta.rowData[2]))} // disabled={this.props.isApprover ? true : ((this.props.lastStatus == 'SUBMIT' || this.props.lastStatus == 'REVISION') && this.props.prevRevision === false ? false : !handleAction(tableMeta.rowData[2]))}
onBlur={(event) => { onBlur={(event) => {
console.log(event.target.value) console.log(event.target.value)
// updateValue(event.target.value) // updateValue(event.target.value)
...@@ -1170,7 +1172,7 @@ export default class CorporateAnnualTarget extends Component { ...@@ -1170,7 +1172,7 @@ export default class CorporateAnnualTarget extends Component {
onChange={(event, newInputValue) => handleChangeDropdown(newInputValue, tableMeta)} onChange={(event, newInputValue) => handleChangeDropdown(newInputValue, tableMeta)}
debug debug
disableClearable disableClearable
disabled={this.props.isApprover ? true : ((this.props.lastStatus == 'SUBMIT' || this.props.lastStatus == 'REVISION') && this.props.prevRevision === false ? false : !handleAction(tableMeta.rowData[2]))} disabled={!handleAction(tableMeta.rowData[2])}
value={val} value={val}
style={{ padding: 0, margin: 0 }} style={{ padding: 0, margin: 0 }}
renderInput={(params) => renderInput={(params) =>
...@@ -1206,7 +1208,7 @@ export default class CorporateAnnualTarget extends Component { ...@@ -1206,7 +1208,7 @@ export default class CorporateAnnualTarget extends Component {
disableClearable disableClearable
value={val} value={val}
style={{ padding: 0, margin: 0 }} style={{ padding: 0, margin: 0 }}
disabled={this.props.isApprover ? true : ((this.props.lastStatus == 'SUBMIT' || this.props.lastStatus == 'REVISION') && this.props.prevRevision === false ? false : !handleAction(tableMeta.rowData[2]))} disabled={!handleAction(tableMeta.rowData[2])}
renderInput={(params) => renderInput={(params) =>
<div ref={params.InputProps.ref} style={{ padding: 0, margin: 0 }}> <div ref={params.InputProps.ref} style={{ padding: 0, margin: 0 }}>
<input style={{ borderColor: 'white', width: 96, textAlign: 'center', padding: 0, margin: 0, color: handleAction(tableMeta.rowData[2]) ? "#5198ea" : "black" }} type="text" {...params.inputProps} /> <input style={{ borderColor: 'white', width: 96, textAlign: 'center', padding: 0, margin: 0, color: handleAction(tableMeta.rowData[2]) ? "#5198ea" : "black" }} type="text" {...params.inputProps} />
...@@ -1243,7 +1245,7 @@ export default class CorporateAnnualTarget extends Component { ...@@ -1243,7 +1245,7 @@ export default class CorporateAnnualTarget extends Component {
debug debug
disableClearable disableClearable
value={val} value={val}
disabled={this.props.isApprover ? true : ((this.props.lastStatus == 'SUBMIT' || this.props.lastStatus == 'REVISION') && this.props.prevRevision === false ? false : !handleAction(tableMeta.rowData[2]))} disabled={!handleAction(tableMeta.rowData[2])}
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 }}>
...@@ -2229,7 +2231,7 @@ export default class CorporateAnnualTarget extends Component { ...@@ -2229,7 +2231,7 @@ export default class CorporateAnnualTarget extends Component {
</button> </button>
</div> </div>
{!this.props.isApprover && <div className="col-2" style={{ display: 'flex', justifyContent: 'flex-end', maxWidth: '100%' }}> {!this.props.isApprover && <div className="col-2" style={{ display: 'flex', justifyContent: 'flex-end', maxWidth: '100%' }}>
{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 }, () => {
...@@ -2244,7 +2246,7 @@ export default class CorporateAnnualTarget extends Component { ...@@ -2244,7 +2246,7 @@ export default class CorporateAnnualTarget extends Component {
<Typography style={{ fontSize: '11px', color: '#354960', textAlign: 'center' }}>Calculate</Typography> <Typography style={{ fontSize: '11px', color: '#354960', textAlign: 'center' }}>Calculate</Typography>
</div> </div>
</button>} </button>}
{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.buttonError}
...@@ -2270,7 +2272,7 @@ export default class CorporateAnnualTarget extends Component { ...@@ -2270,7 +2272,7 @@ export default class CorporateAnnualTarget extends Component {
<Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Save as Draft</Typography> <Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Save as Draft</Typography>
</div> </div>
</button>} </button>}
{this.props.lastStatus === 'SUBMIT' || this.props.lastStatus === 'REVISION' && <button {(this.props.lastStatus === 'SUBMIT' || this.props.lastStatus === 'REVISION') && <button
type="button" type="button"
style={{ style={{
backgroundColor: 'transparent', backgroundColor: 'transparent',
......
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