Commit c2ff51bc authored by Deni Rinaldi's avatar Deni Rinaldi

Merge branch 'deni-dev(pc)' into 'master'

Deni dev(pc)

See merge request !136
parents 84f5d3ae 7c5516c4
...@@ -513,6 +513,7 @@ export default class CreateParameter extends Component { ...@@ -513,6 +513,7 @@ export default class CreateParameter extends Component {
value={this.state.tempData === null ? '' : this.state.tempData.value} value={this.state.tempData === null ? '' : this.state.tempData.value}
type={"number"} type={"number"}
inputProps={{ inputProps={{
min: 0,
style: { style: {
fontSize: 11 fontSize: 11
} }
...@@ -538,6 +539,7 @@ export default class CreateParameter extends Component { ...@@ -538,6 +539,7 @@ export default class CreateParameter extends Component {
type={"number"} type={"number"}
value={this.state.tempData === null ? '' : this.state.tempData.min_value} value={this.state.tempData === null ? '' : this.state.tempData.min_value}
inputProps={{ inputProps={{
min: 0,
style: { style: {
fontSize: 11 fontSize: 11
} }
...@@ -646,6 +648,7 @@ export default class CreateParameter extends Component { ...@@ -646,6 +648,7 @@ export default class CreateParameter extends Component {
type={"number"} type={"number"}
value={this.state.tempData === null ? '' : this.state.tempData.order} value={this.state.tempData === null ? '' : this.state.tempData.order}
inputProps={{ inputProps={{
min: 0,
style: { style: {
fontSize: 11 fontSize: 11
} }
...@@ -671,6 +674,7 @@ export default class CreateParameter extends Component { ...@@ -671,6 +674,7 @@ export default class CreateParameter extends Component {
type={"number"} type={"number"}
value={this.state.tempData === null ? '' : this.state.tempData.max_value} value={this.state.tempData === null ? '' : this.state.tempData.max_value}
inputProps={{ inputProps={{
min: 0,
style: { style: {
fontSize: 11 fontSize: 11
} }
...@@ -840,10 +844,12 @@ export default class CreateParameter extends Component { ...@@ -840,10 +844,12 @@ export default class CreateParameter extends Component {
value={this.state.value === null ? '' : this.state.value} value={this.state.value === null ? '' : this.state.value}
type={"number"} type={"number"}
inputProps={{ inputProps={{
min: 0,
style: { style: {
fontSize: 11 fontSize: 11
} }
}} }}
InputLabelProps={{ InputLabelProps={{
style: { style: {
fontSize: 11, fontSize: 11,
...@@ -865,6 +871,7 @@ export default class CreateParameter extends Component { ...@@ -865,6 +871,7 @@ export default class CreateParameter extends Component {
type={"number"} type={"number"}
value={this.state.minValue === null ? '' : this.state.minValue} value={this.state.minValue === null ? '' : this.state.minValue}
inputProps={{ inputProps={{
min: 0,
style: { style: {
fontSize: 11 fontSize: 11
} }
...@@ -983,6 +990,7 @@ export default class CreateParameter extends Component { ...@@ -983,6 +990,7 @@ export default class CreateParameter extends Component {
type={"number"} type={"number"}
value={this.state.order === null ? '' : this.state.order} value={this.state.order === null ? '' : this.state.order}
inputProps={{ inputProps={{
min: 0,
style: { style: {
fontSize: 11 fontSize: 11
} }
...@@ -1008,6 +1016,7 @@ export default class CreateParameter extends Component { ...@@ -1008,6 +1016,7 @@ export default class CreateParameter extends Component {
type={"number"} type={"number"}
value={this.state.maxValue === null ? '' : this.state.maxValue} value={this.state.maxValue === null ? '' : this.state.maxValue}
inputProps={{ inputProps={{
min: 0,
style: { style: {
fontSize: 11 fontSize: 11
} }
......
...@@ -42,6 +42,7 @@ export default class Parameter extends Component { ...@@ -42,6 +42,7 @@ export default class Parameter extends Component {
getAllParameter() { getAllParameter() {
api.create().getAllParameter().then(response => { api.create().getAllParameter().then(response => {
if (response.data) {
if (response.data.status === "success") { if (response.data.status === "success") {
console.log(response); console.log(response);
let data = response.data.data let data = response.data.data
...@@ -61,7 +62,10 @@ export default class Parameter extends Component { ...@@ -61,7 +62,10 @@ export default class Parameter extends Component {
}) })
this.setState({ dataTable: listData, data: response.data.data }) this.setState({ dataTable: listData, data: response.data.data })
} else { } else {
alert(response.data.message) this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' })
}
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
} }
}) })
} }
...@@ -83,6 +87,7 @@ export default class Parameter extends Component { ...@@ -83,6 +87,7 @@ export default class Parameter extends Component {
updateParameter = (payload) => { updateParameter = (payload) => {
this.setState({ visibleEdit: false }) this.setState({ visibleEdit: false })
api.create().updateParameter(payload).then(response => { api.create().updateParameter(payload).then(response => {
console.log(response);
if (response.data) { if (response.data) {
if (response.data.status == 'success') { if (response.data.status == 'success') {
this.getAllParameter() this.getAllParameter()
......
import React, { Component } from "react"; import React, { Component } from "react";
import { createMuiTheme, MuiThemeProvider } from '@material-ui/core/styles'; import { createMuiTheme, MuiThemeProvider, withStyles } from '@material-ui/core/styles';
import Images from "../../assets/Images"; import Images from "../../assets/Images";
import MUIDataTable from "mui-datatables"; import MUIDataTable from "mui-datatables";
import { InputBase } from "@material-ui/core"; import { InputBase, Snackbar } from "@material-ui/core";
import { ExcelRenderer } from 'react-excel-renderer'; import { ExcelRenderer } from 'react-excel-renderer';
import UploadFile from "../../library/Upload"; import UploadFile from "../../library/Upload";
import MuiAlert from '@material-ui/lab/Alert';
import CreateReportItems from "./formReportItems/CreateReportItems"; import CreateReportItems from "./formReportItems/CreateReportItems";
import EditReportItems from "./formReportItems/EditReportItems"; import EditReportItems from "./formReportItems/EditReportItems";
import VisualReportItems from "./formReportItems/VisualReportItems"; import VisualReportItems from "./formReportItems/VisualReportItems";
...@@ -17,6 +18,9 @@ const getMuiTheme = () => createMuiTheme(ct.customTable()); ...@@ -17,6 +18,9 @@ const getMuiTheme = () => createMuiTheme(ct.customTable());
const options = ct.customOptions(); const options = ct.customOptions();
const options2 = ct.customOptions2(); const options2 = ct.customOptions2();
const Alert = withStyles({
})((props) => <MuiAlert elevation={6} variant="filled" {...props} />);
export default class ReportItems extends Component { export default class ReportItems extends Component {
constructor(props) { constructor(props) {
super(props) super(props)
...@@ -32,7 +36,10 @@ export default class ReportItems extends Component { ...@@ -32,7 +36,10 @@ export default class ReportItems extends Component {
dataLoaded: false, dataLoaded: false,
cols: null, cols: null,
rows: null, rows: null,
popupError: false popupError: false,
alert: false,
tipeAlert: '',
messageAlert: ''
} }
this.fileHandler = this.fileHandler.bind(this); this.fileHandler = this.fileHandler.bind(this);
...@@ -450,6 +457,7 @@ export default class ReportItems extends Component { ...@@ -450,6 +457,7 @@ export default class ReportItems extends Component {
getData() { getData() {
api.create().getReportItems().then((response) => { api.create().getReportItems().then((response) => {
console.log(response) console.log(response)
if (response.data) {
if (response.data.status == 'success') { if (response.data.status == 'success') {
let data = response.data.data let data = response.data.data
let listData = data.sort((a, b) => a.item_report_id - b.item_report_id).map((item, index) => { let listData = data.sort((a, b) => a.item_report_id - b.item_report_id).map((item, index) => {
...@@ -457,7 +465,10 @@ export default class ReportItems extends Component { ...@@ -457,7 +465,10 @@ export default class ReportItems extends Component {
}) })
this.setState({ dataTable: listData, listData: response.data.data }) this.setState({ dataTable: listData, listData: response.data.data })
} else { } else {
alert(response.data.message) this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' })
}
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
} }
}) })
} }
...@@ -482,6 +493,7 @@ export default class ReportItems extends Component { ...@@ -482,6 +493,7 @@ export default class ReportItems extends Component {
} }
api.create().searchReportItems(body).then(response => { api.create().searchReportItems(body).then(response => {
// console.log(response.data); // console.log(response.data);
if (response.data) {
if (response.data.status == 'success') { if (response.data.status == 'success') {
let data = response.data.data let data = response.data.data
let listData = data.map((item, index) => { let listData = data.map((item, index) => {
...@@ -489,7 +501,10 @@ export default class ReportItems extends Component { ...@@ -489,7 +501,10 @@ export default class ReportItems extends Component {
}) })
this.setState({ dataTable: listData, listData: response.data.data }) this.setState({ dataTable: listData, listData: response.data.data })
} else { } else {
alert(response.data.message) this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' })
}
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
} }
}) })
} }
...@@ -497,10 +512,15 @@ export default class ReportItems extends Component { ...@@ -497,10 +512,15 @@ export default class ReportItems extends Component {
createReportItems = (payload) => { createReportItems = (payload) => {
this.setState({ add: false }) this.setState({ add: false })
api.create().createReportItems(payload).then(response => { api.create().createReportItems(payload).then(response => {
if (response.data) {
if (response.data.status == 'success') { if (response.data.status == 'success') {
this.getData() this.getData()
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'success' })
} else { } else {
alert(response.data.message) this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' })
}
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
} }
}) })
} }
...@@ -538,10 +558,15 @@ export default class ReportItems extends Component { ...@@ -538,10 +558,15 @@ export default class ReportItems extends Component {
updateReportItems = (payload) => { updateReportItems = (payload) => {
this.setState({ edit: false }) this.setState({ edit: false })
api.create().updateReportItems(payload).then(response => { api.create().updateReportItems(payload).then(response => {
if (response.data) {
if (response.data.status == 'success') { if (response.data.status == 'success') {
this.getData() this.getData()
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'success' })
} else { } else {
alert(response.data.message) this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' })
}
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
} }
}) })
} }
...@@ -550,15 +575,22 @@ export default class ReportItems extends Component { ...@@ -550,15 +575,22 @@ export default class ReportItems extends Component {
api.create().uploadReportItems(this.state.payload).then(response => { api.create().uploadReportItems(this.state.payload).then(response => {
if (response.data) { if (response.data) {
if (response.data.status === "success") { if (response.data.status === "success") {
console.log(response)
alert(response.data.message) alert(response.data.message)
this.getData() this.getData()
this.setState({ itemReport: true }) this.setState({ itemReport: true, alert: true, messageAlert: response.data.message, tipeAlert: 'success' })
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' })
} }
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
} }
}) })
} }
closeAlert() {
this.setState({ alert: false })
}
render() { render() {
const columns = [{ const columns = [{
name: "Action", name: "Action",
...@@ -716,6 +748,11 @@ export default class ReportItems extends Component { ...@@ -716,6 +748,11 @@ export default class ReportItems extends Component {
<div style={{ height: this.props.height }}> <div style={{ height: this.props.height }}>
{/* <Row> */} {/* <Row> */}
<div className={"main-color"} style={{ height: 199, width: '100%' }} /> <div className={"main-color"} style={{ height: 199, width: '100%' }} />
<Snackbar open={this.state.alert} autoHideDuration={6000} onClose={() => this.closeAlert()}>
<Alert onClose={() => this.closeAlert()} severity={this.state.tipeAlert}>
{this.state.messageAlert}
</Alert>
</Snackbar>
{this.state.itemReport === true ? {this.state.itemReport === true ?
<div> <div>
<div style={{ display: 'flex', flexDirection: 'row', justifyContent: 'space-between', paddingRight: 25, paddingLeft: 25, marginTop: -150 }}> <div style={{ display: 'flex', flexDirection: 'row', justifyContent: 'space-between', paddingRight: 25, paddingLeft: 25, marginTop: -150 }}>
......
import React, { Component } from 'react'; import React, { Component } from 'react';
import { TextField, Typography } from '@material-ui/core'; import { TextField, Typography, withStyles, Snackbar } from '@material-ui/core';
import { DatePicker } from '@material-ui/pickers'; import { DatePicker } from '@material-ui/pickers';
import format from "date-fns/format"; import format from "date-fns/format";
import Autocomplete from '@material-ui/lab/Autocomplete'; import Autocomplete from '@material-ui/lab/Autocomplete';
import MuiAlert from '@material-ui/lab/Alert';
import api from '../../../api'; import api from '../../../api';
import * as R from 'ramda' import * as R from 'ramda'
import { titleCase } from '../../../library/Utils'; import { titleCase } from '../../../library/Utils';
import Images from '../../../assets/Images'; import Images from '../../../assets/Images';
const Alert = withStyles({
})((props) => <MuiAlert elevation={6} variant="filled" {...props} />);
export default class EditReportItems extends Component { export default class EditReportItems extends Component {
constructor(props) { constructor(props) {
...@@ -23,7 +26,7 @@ export default class EditReportItems extends Component { ...@@ -23,7 +26,7 @@ export default class EditReportItems extends Component {
order: null, order: null,
description: '', description: '',
uom: '', uom: '',
weight: null, weight: "",
formula: '', formula: '',
realVal: '', realVal: '',
condition: null, condition: null,
...@@ -51,7 +54,10 @@ export default class EditReportItems extends Component { ...@@ -51,7 +54,10 @@ export default class EditReportItems extends Component {
disabledFormula: true, disabledFormula: true,
disabledCondt: true, disabledCondt: true,
disabledValue: true, disabledValue: true,
options: ['WARNING', 'STOPPER'] options: ['WARNING', 'STOPPER'],
alert: false,
tipeAlert: '',
messageAlert: ''
} }
} }
...@@ -160,26 +166,20 @@ export default class EditReportItems extends Component { ...@@ -160,26 +166,20 @@ export default class EditReportItems extends Component {
"end_date": this.state.tempData.end_date "end_date": this.state.tempData.end_date
} }
console.log(payload) console.log(payload)
api.create().updateReportItems(payload).then((response) => { this.props.updateReportItems(payload)
console.log(response);
if (response.data) {
if (response.data.status === 'success') {
this.props.onClickClose()
this.props.refresh()
} else {
alert(response.data.message)
}
}
})
} }
getDetailReportItems() { getDetailReportItems() {
api.create().getDetailReportItems(this.props.data[1]).then((response) => { api.create().getDetailReportItems(this.props.data[1]).then((response) => {
if (response.data) {
if (response.data.status === 'success') { if (response.data.status === 'success') {
this.setState({ tempData: response.data.data }, () => this.getInputType(), this.getPerusahaan(), this.getReportType(),) this.setState({ tempData: response.data.data }, () => this.getInputType(), this.getPerusahaan(), this.getReportType(),)
console.log(response.data.data) console.log(response.data.data)
} else { } else {
alert(response.data.message) this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' })
}
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
} }
}) })
} }
...@@ -187,6 +187,7 @@ export default class EditReportItems extends Component { ...@@ -187,6 +187,7 @@ export default class EditReportItems extends Component {
getInputType() { getInputType() {
api.create().getInputType().then((response) => { api.create().getInputType().then((response) => {
// console.log(response) // console.log(response)
if (response.data) {
if (response.data.status === 'success') { if (response.data.status === 'success') {
let data = response.data.data let data = response.data.data
let inputData = data.map((item) => { let inputData = data.map((item) => {
...@@ -203,7 +204,10 @@ export default class EditReportItems extends Component { ...@@ -203,7 +204,10 @@ export default class EditReportItems extends Component {
let index = inputData.findIndex((val) => val.type_report_id === this.state.tempData.type_report_id) let index = inputData.findIndex((val) => val.type_report_id === this.state.tempData.type_report_id)
this.setState({ listInputType: defaultProps, InputType: index === -1 ? null : inputData[index] }) this.setState({ listInputType: defaultProps, InputType: index === -1 ? null : inputData[index] })
} else { } else {
alert(response.data.message) this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' })
}
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
} }
}) })
} }
...@@ -211,6 +215,7 @@ export default class EditReportItems extends Component { ...@@ -211,6 +215,7 @@ export default class EditReportItems extends Component {
getPerusahaan() { getPerusahaan() {
api.create().getPerusahaanActive().then((response) => { api.create().getPerusahaanActive().then((response) => {
console.log(response) console.log(response)
if (response.data) {
if (response.data.status === 'success') { if (response.data.status === 'success') {
let data = response.data.data let data = response.data.data
let companyData = data.map((item) => { let companyData = data.map((item) => {
...@@ -227,7 +232,10 @@ export default class EditReportItems extends Component { ...@@ -227,7 +232,10 @@ export default class EditReportItems extends Component {
let index = companyData.findIndex((val) => val.company_id === this.state.tempData.company_id) let index = companyData.findIndex((val) => val.company_id === this.state.tempData.company_id)
this.setState({ listCompany: defaultProps, company: index === -1 ? null : companyData[index] }, () => this.getParent()) this.setState({ listCompany: defaultProps, company: index === -1 ? null : companyData[index] }, () => this.getParent())
} else { } else {
alert(response.data.message) this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' })
}
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
} }
}) })
} }
...@@ -235,6 +243,7 @@ export default class EditReportItems extends Component { ...@@ -235,6 +243,7 @@ export default class EditReportItems extends Component {
getReportType() { getReportType() {
api.create().getReportType().then((response) => { api.create().getReportType().then((response) => {
console.log(response) console.log(response)
if (response.data) {
if (response.data.status === 'success') { if (response.data.status === 'success') {
let data = response.data.data let data = response.data.data
let reportTypeData = data.map((item) => { let reportTypeData = data.map((item) => {
...@@ -251,7 +260,10 @@ export default class EditReportItems extends Component { ...@@ -251,7 +260,10 @@ export default class EditReportItems extends Component {
let index = reportTypeData.findIndex((val) => val.report_id === this.state.tempData.report_id) let index = reportTypeData.findIndex((val) => val.report_id === this.state.tempData.report_id)
this.setState({ listReportType: defaultProps, reportType: index === -1 ? null : reportTypeData[index] }, () => this.getParent()) this.setState({ listReportType: defaultProps, reportType: index === -1 ? null : reportTypeData[index] }, () => this.getParent())
} else { } else {
alert(response.data.message) this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' })
}
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
} }
}) })
} }
...@@ -264,6 +276,7 @@ export default class EditReportItems extends Component { ...@@ -264,6 +276,7 @@ export default class EditReportItems extends Component {
} }
api.create().getReportParent(payload).then((response) => { api.create().getReportParent(payload).then((response) => {
console.log(response) console.log(response)
if (response.data) {
if (response.data.status === 'success') { if (response.data.status === 'success') {
let data = response.data.data let data = response.data.data
let parentData = data.map((item) => { let parentData = data.map((item) => {
...@@ -279,7 +292,10 @@ export default class EditReportItems extends Component { ...@@ -279,7 +292,10 @@ export default class EditReportItems extends Component {
let index = parentData.findIndex((val) => val.item_report_id === this.state.tempData.parent) let index = parentData.findIndex((val) => val.item_report_id === this.state.tempData.parent)
this.setState({ listParent: defaultProps, parent: index == -1 ? null : parentData[index] }) this.setState({ listParent: defaultProps, parent: index == -1 ? null : parentData[index] })
} else { } else {
alert(response.data.message) this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' })
}
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
} }
}) })
} }
...@@ -294,6 +310,10 @@ export default class EditReportItems extends Component { ...@@ -294,6 +310,10 @@ export default class EditReportItems extends Component {
}) })
} }
closeAlert() {
this.setState({ alert: false })
}
render() { render() {
return ( return (
...@@ -315,6 +335,11 @@ export default class EditReportItems extends Component { ...@@ -315,6 +335,11 @@ export default class EditReportItems extends Component {
</button> </button>
</div> </div>
</div> </div>
<Snackbar open={this.state.alert} autoHideDuration={6000} onClose={() => this.closeAlert()}>
<Alert onClose={() => this.closeAlert()} severity={this.state.tipeAlert}>
{this.state.messageAlert}
</Alert>
</Snackbar>
<div className="grid grid-2x grid-mobile-none gap-15px" style={{ paddingLeft: 20, paddingRight: 20 }}> <div className="grid grid-2x grid-mobile-none gap-15px" style={{ paddingLeft: 20, paddingRight: 20 }}>
<div className="column-1"> <div className="column-1">
...@@ -398,11 +423,13 @@ export default class EditReportItems extends Component { ...@@ -398,11 +423,13 @@ export default class EditReportItems extends Component {
id="order" id="order"
label="Order" label="Order"
name="order" name="order"
type="number"
value={this.state.tempData === null ? '' : this.state.tempData.order} value={this.state.tempData === null ? '' : this.state.tempData.order}
error={this.state.errorOrder} error={this.state.errorOrder}
helperText={this.state.msgErrorOrder} helperText={this.state.msgErrorOrder}
onChange={(e) => this.handleChange(e, '')} onChange={(e) => this.handleChange(e, '')}
inputProps={{ inputProps={{
min: 0,
style: { style: {
fontSize: 11, fontSize: 11,
fontFamily: 'Nunito Sans, sans-serif' fontFamily: 'Nunito Sans, sans-serif'
......
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