Commit 970bf0b5 authored by d.arizona's avatar d.arizona

apdet wiken

parent 963725e6
......@@ -267,13 +267,21 @@ export default class BudgetTahunan extends Component {
api.create().getPeriodeTransaction().then(response => {
// let dateNow = new Date
// 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.status === "success") {
let data = []
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)
}
} else {
if ((item >= 2000) && (item == this.state.lastPeriod || item < this.state.lastPeriod)) {
data.push(item)
}
}
})
let periodeData = data.map((item) => {
return {
......@@ -284,7 +292,11 @@ export default class BudgetTahunan extends Component {
options: periodeData,
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] }, () => {
if (this.state.isApprover === true) {
this.getCompanySubmitted()
......@@ -913,7 +925,7 @@ export default class BudgetTahunan extends Component {
<div style={{ width: '50%' }}>
<Typography style={{ fontSize: '16px', color: '#4b4b4b', fontWeight: 'bold' }}>Attachment: </Typography>
</div>
{!this.state.isApprover && (
{!this.state.isApprover && (this.state.lastStatus !== 'SUBMITTED' && this.state.lastStatus !== 'APPROVED') && (
<div style={{ width: '50%' }}>
<button
style={{
......@@ -959,7 +971,7 @@ export default class BudgetTahunan extends Component {
: null
}
</div>
{!this.state.isApprover && (
{!this.state.isApprover && (this.state.lastStatus !== 'SUBMITTED' && this.state.lastStatus !== 'APPROVED') && (
<div style={{ width: '50%' }}>
{this.state.listAttachment.length > 0 ?
this.state.listAttachment.map((item) => {
......
......@@ -86,10 +86,10 @@ export default class CorporateAnnualTarget extends Component {
componentDidMount() {
this.getItemHierarki()
this.getLatestUpdate()
console.log(this.props.lastStatus);
this.getKPIType()
this.getMaxAch()
this.getLatestUpdate()
console.log(this.props.lastStatus);
}
......@@ -119,7 +119,7 @@ export default class CorporateAnnualTarget extends Component {
item.level,
"",
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.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 },
......@@ -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_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(),
strategic: i[23] === undefined ? "" : reg.test(String(i[23])) === false ? "" : String(i[23]).trim(),
pic: i[24] === undefined ? "" : reg.test(String(i[24])) === false ? "" : String(i[24]).trim()
strategic: i[23] === undefined ? "" : String(i[23]).trim(),
pic: i[24] === undefined ? "" : String(i[24]).trim()
})
}
})
......@@ -491,8 +491,8 @@ export default class CorporateAnnualTarget extends Component {
}
data.push({
"item_report_id": i[1],
"item_name": i[6] == "" ? null : String(i[6]),
"item_report_id": i[1] == "" ? null : i[1],
"item_name": String(i[6]),
"parent": i[2] == "" ? null : i[2],
"weight": weightReal == null? String(i[7]) : weightReal,
"uom": String(i[8]),
......@@ -556,9 +556,9 @@ export default class CorporateAnnualTarget extends Component {
this.state.dataTable.map(i => {
// console.log(i[9] == null? "" : i[9].value)
data.push({
"item_report_id": i[1],
"item_name": i[1] == "" ? null : String(i[6]),
"parent": i[1] == "" ? null : i[2],
"item_report_id": i[1] == "" ? null : i[1],
"item_name": String(i[6]),
"parent": i[2] == "" ? null : i[2],
"weight": String(i[7]),
"uom": String(i[8]),
"kpi_type": i[9] == null ? "" : i[9].value,
......@@ -636,6 +636,7 @@ export default class CorporateAnnualTarget extends Component {
type: 'KPI_TYPE'
}
api.create().getAllSettingByType(body).then(response => {
// console.log(response)
if (response.data) {
if (response.ok) {
if (response.data.status === 'success') {
......@@ -650,6 +651,7 @@ export default class CorporateAnnualTarget extends Component {
options: inputKPI,
getOptionLabel: (option) => titleCase(option.value),
};
console.log(defaultProps)
this.setState({ kpiTypeList: defaultProps })
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
......@@ -1119,7 +1121,7 @@ export default class CorporateAnnualTarget extends Component {
placeholder=""
defaultValue={value}
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) => {
console.log(event.target.value)
// updateValue(event.target.value)
......@@ -1135,7 +1137,7 @@ export default class CorporateAnnualTarget extends Component {
placeholder=""
defaultValue={value}
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) => {
console.log(event.target.value)
// updateValue(event.target.value)
......@@ -1170,7 +1172,7 @@ export default class CorporateAnnualTarget extends Component {
onChange={(event, newInputValue) => handleChangeDropdown(newInputValue, tableMeta)}
debug
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}
style={{ padding: 0, margin: 0 }}
renderInput={(params) =>
......@@ -1206,7 +1208,7 @@ export default class CorporateAnnualTarget extends Component {
disableClearable
value={val}
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) =>
<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} />
......@@ -1243,7 +1245,7 @@ export default class CorporateAnnualTarget extends Component {
debug
disableClearable
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 }}
renderInput={(params) =>
<div ref={params.InputProps.ref} style={{ padding: 0, margin: 0 }}>
......@@ -2229,7 +2231,7 @@ export default class CorporateAnnualTarget extends Component {
</button>
</div>
{!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"
onClick={() =>
this.setState({ loading: true }, () => {
......@@ -2244,7 +2246,7 @@ export default class CorporateAnnualTarget extends Component {
<Typography style={{ fontSize: '11px', color: '#354960', textAlign: 'center' }}>Calculate</Typography>
</div>
</button>}
{this.props.lastStatus === 'SUBMIT' || this.props.lastStatus === 'REVISION' && <button
{(this.props.lastStatus === 'SUBMIT' || this.props.lastStatus === 'REVISION') && <button
className="button"
type="button"
disabled={this.state.buttonError}
......@@ -2270,7 +2272,7 @@ export default class CorporateAnnualTarget extends Component {
<Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Save as Draft</Typography>
</div>
</button>}
{this.props.lastStatus === 'SUBMIT' || this.props.lastStatus === 'REVISION' && <button
{(this.props.lastStatus === 'SUBMIT' || this.props.lastStatus === 'REVISION') && <button
type="button"
style={{
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