Browse Source

bug fix export

pull/2/head
nurkomalasari 2 years ago
parent
commit
68b06b9027
  1. 2
      src/views/Master/RoleProject/index.js
  2. 870
      src/views/SimproV2/ResourceMaterial/DialogForm.js
  3. 200
      src/views/SimproV2/ResourceMaterial/index.js
  4. 107
      src/views/SimproV2/ResourceWorker/index.js

2
src/views/Master/RoleProject/index.js

@ -271,7 +271,7 @@ export default class index extends Component {
"orders": { "columns": ["id"], "ascending": false }
}
const result = await axios
.post(PROJECT_ROLE_SEARCH, payload)
.post(PROJECT_ROLE_SEARCH, payload, config)
.then(res => res)
.catch((error) => error.response);
if (result && result.data && result.statusText == "OK") {

870
src/views/SimproV2/ResourceMaterial/DialogForm.js

@ -1,427 +1,443 @@
import React, { useEffect, useState } from 'react'
import {
Modal, ModalHeader, ModalBody, ModalFooter,
Button, Form, FormGroup, Label, Input, Col, Row
} from 'reactstrap';
import { DatePicker, Tooltip, Select } from 'antd';
import { formatRupiah, formatNumber } from '../../../const/CustomFunc'
import moment from 'moment';
import 'antd/dist/antd.css';
const { Option } = Select
const DialogForm = ({openDialog, closeDialog, toggleDialog, typeDialog, dataEdit}) => {
const [id, setId] = useState(0)
const [materialName, setMaterialName] = useState('')
const [uom, setUom] = useState('')
const [description, setDescription] = useState('')
const [unitPrice, setUnitPrice] = useState('')
const [priceReq, setPriceReq] = useState('')
const [status, setStatus] = useState('')
const [requiredDate, setRequiredDate] = useState(null)
const [qty, setQty] = useState('')
const [qtyReceived, setQtyReceived] = useState('')
const [fomDate, setFomDate] = useState(null)
const [prDate, setPrDate] = useState(null)
const [poDate, setPoDate] = useState(null)
const [receivedDate, setReceivedDate] = useState(null)
const [deliveryDate, setDeliveryDate] = useState(null)
useEffect(()=> {
if(typeDialog==="Edit"){
console.log("cel data Edit", dataEdit)
setId(dataEdit.id)
setQty(dataEdit.qty)
setDescription(dataEdit.description)
setUnitPrice(dataEdit.unit_price)
setUom(dataEdit.uom)
setMaterialName(dataEdit.name)
setStatus(dataEdit.status)
}
else if (typeDialog === 'EditMatReq') {
console.log("cel data EditMatReq", dataEdit)
setId(dataEdit.id)
setDescription(dataEdit.description)
setUnitPrice(dataEdit.unit_price)
setUom(dataEdit.uom)
setStatus(dataEdit.status)
setRequiredDate(dataEdit.required_date ? moment(dataEdit.required_date) : null)
setQty(dataEdit.qty)
setQtyReceived(dataEdit.qty_received)
setFomDate(dataEdit.fom_date ? moment(dataEdit.fom_date) : null)
setPrDate(dataEdit.pr_date ? moment(dataEdit.pr_date) : null)
setPoDate(dataEdit.po_date ? moment(dataEdit.po_date) : null)
setReceivedDate(dataEdit.received_date ? moment(dataEdit.received_date) : null)
setDeliveryDate(dataEdit.delivery_date ? moment(dataEdit.delivery_date) : null)
}
else if (typeDialog === 'EditMatDelv') {
console.log("cel data EditMatDelv", dataEdit)
setId(dataEdit.id)
setDescription(dataEdit.description)
setUnitPrice(dataEdit.unit_price)
setUom(dataEdit.uom)
setStatus(dataEdit.status)
setRequiredDate(dataEdit.required_date ? moment(dataEdit.required_date) : null)
setQty(dataEdit.qty)
setQtyReceived(dataEdit.qty_received)
setFomDate(dataEdit.fom_date ? moment(dataEdit.fom_date) : null)
setPrDate(dataEdit.pr_date ? moment(dataEdit.pr_date) : null)
setPoDate(dataEdit.po_date ? moment(dataEdit.po_date) : null)
setReceivedDate(dataEdit.received_date ? moment(dataEdit.received_date) : null)
setDeliveryDate(dataEdit.delivery_date ? moment(dataEdit.delivery_date) : null)
}
else if (typeDialog === 'Save'){
setId(0)
}
},[dataEdit,openDialog])
const handleSave = () => {
let data = '';
if(typeDialog==="Save"){
data = {
name: materialName,
qty,
uom,
description,
unit_price: typeof(unitPrice) === 'string' && unitPrice !== '' && unitPrice.includes('.') ? parseInt(unitPrice.replace(/\./g,'')) : unitPrice,
status
}
closeDialog('save', data);
}
else if (typeDialog === 'Edit') {
console.log('typeof', typeof(unitPrice));
data = {
id,
name: materialName,
qty,
uom,
description,
unit_price: typeof(unitPrice) === 'string' && unitPrice !== '' && unitPrice.includes('.') ? parseInt(unitPrice.replace(/\./g,'')) : unitPrice,
status
}
closeDialog('edit', data);
}
else if (typeDialog === 'EditMatReq') {
data = {
id,
uom,
description,
status,
required_date: requiredDate,
qty,
qty_received: qtyReceived,
fom_date: fomDate,
pr_date: prDate,
po_date: poDate,
received_date: receivedDate,
delivery_date: deliveryDate,
price: typeof(priceReq) === 'string' && priceReq !== '' && priceReq.includes('.') ? parseInt(priceReq.replace(/\./g,'')) : priceReq,
}
closeDialog('EditMatReq', data);
}
else if (typeDialog === 'EditMatDelv') {
data = {
id,
uom,
description,
status,
required_date: requiredDate,
qty,
qty_received: qtyReceived,
fom_date: fomDate,
pr_date: prDate,
po_date: poDate,
received_date: receivedDate,
delivery_date: deliveryDate
}
closeDialog('EditMatDelv', data);
}
setId(0)
setDescription('')
}
const handleCancel = () => {
closeDialog('cancel', 'none')
setId(0)
setDescription('')
}
const renderForm = () => {
if (typeDialog === 'Save' || typeDialog === 'Edit') {
return(
<Form>
<Row>
<Col md={12}>
<FormGroup>
<Label className="capitalize">Material Name</Label>
<Input type="text" value={materialName} onChange={(e)=> setMaterialName(e.target.value)} placeholder={`Input material name...`}/>
</FormGroup>
</Col>
</Row>
<Row>
<Col md={6}>
<FormGroup>
<Label className="capitalize">QTY</Label>
<Input type="text" value={qty} onChange={(e)=> setQty(e.target.value)} placeholder={`Input qty...`} />
</FormGroup>
</Col>
<Col md={6}>
<FormGroup>
<Label className="capitalize">UOM</Label>
<Input type="text" value={uom} onChange={(e)=> setUom(e.target.value)} placeholder={`Input uom...`} />
</FormGroup>
</Col>
</Row>
<Row>
<Col md={6}>
<FormGroup>
<Label className="capitalize">Unit Price</Label>
<Input type="text" value={unitPrice} onChange={(e)=> setUnitPrice(formatNumber(e.target.value))} placeholder={`Unit Price...`} />
</FormGroup>
</Col>
<Col md={6}>
<FormGroup>
<Label className="capitalize">Status</Label>
<Input type="text" value={status} onChange={(e)=> setStatus(e.target.value)} placeholder={`Status ...`} />
</FormGroup>
</Col>
</Row>
<Row>
<Col md={12}>
<FormGroup>
<Label className="capitalize">Description</Label>
<Input row="2" type="textarea" value={description} onChange={(e)=> setDescription(e.target.value)} placeholder={`Description ...`} />
</FormGroup>
</Col>
</Row>
</Form>
)
}
else if (typeDialog === 'EditMatReq') {
return (
<Form>
<Row>
<Col md={6}>
<FormGroup>
<Label className="capitalize">Status</Label>
<Select showSearch value={status} defaultValue={status} onChange={(val) => setStatus(val)} placeholder="Select status" style={{ width: '100%' }}>
<Option value="fom">FOM (Form Order Material)</Option>
<Option value="PO">PO (Pre Order)</Option>
<Option value="PO approve">PO approve</Option>
<Option value="PO supplier">PO supplier</Option>
<Option value="material deliver to warehouse">Material Deliver to Warehouse</Option>
<Option value="receipt to warehouse">Receipt to Warehouse</Option>
<Option value="receipt to site">Receipt to Site</Option>
</Select>
</FormGroup>
</Col>
<Col md={6}>
<FormGroup>
<Label className="capitalize">Price</Label>
<Input type="text" value={priceReq} onChange={(e) => setPriceReq(formatNumber(e.target.value))} placeholder={`Input Price ...`} />
</FormGroup>
</Col>
</Row>
<Row>
<Col md={6}>
<FormGroup>
<Label className="capitalize">Description</Label>
<Input row="2" type="textarea" value={description} onChange={(e)=> setDescription(e.target.value)} placeholder={`Description ...`} />
</FormGroup>
</Col>
<Col md={6}>
<FormGroup>
<Label className="capitalize">Required Date</Label>
<DatePicker style={{ width: "100%" }} value={requiredDate} onChange={(date, dateString) => setRequiredDate(date)} />
</FormGroup>
</Col>
</Row>
<Row>
<Col md={6}>
<FormGroup>
<Label className="capitalize">QTY</Label>
<Input type="number" value={qty} onChange={(e) => setQty(e.target.value)} placeholder={`Input QTY...`} disabled />
</FormGroup>
</Col>
<Col md={6}>
<FormGroup>
<Label className="capitalize">UOM</Label>
<Input type="text" value={uom} onChange={(e) => setUom(e.target.value)} placeholder={`Input UOM...`} disabled />
</FormGroup>
</Col>
</Row>
<Row>
<Col md={6}>
<FormGroup>
<Label className="capitalize">QTY Received</Label>
<Input type="number" min="0" max={qty} value={qtyReceived} onChange={(e) => setQtyReceived(e.target.value)} placeholder={`Input QTY Received...`} />
</FormGroup>
</Col>
<Col md={6}>
<FormGroup>
<Label className="capitalize">FOM Date</Label>
<DatePicker style={{ width: "100%" }} value={fomDate} onChange={(date, dateString) => setFomDate(date)} />
</FormGroup>
</Col>
</Row>
<Row>
<Col md={6}>
<FormGroup>
<Label className="capitalize">PR Date</Label>
<DatePicker style={{ width: "100%" }} value={prDate} onChange={(date, dateString) => setPrDate(date)} />
</FormGroup>
</Col>
<Col md={6}>
<FormGroup>
<Label className="capitalize">PO Date</Label>
<DatePicker style={{ width: "100%" }} value={poDate} onChange={(date, dateString) => setPoDate(date)} />
</FormGroup>
</Col>
</Row>
<Row>
<Col md={6}>
<FormGroup>
<Label className="capitalize">Received to Warehouse Date</Label>
<DatePicker style={{ width: "100%" }} value={receivedDate} onChange={(date, dateString) => setReceivedDate(date)} />
</FormGroup>
</Col>
<Col md={6}>
<FormGroup>
<Label className="capitalize">Delivery to Site Date</Label>
<DatePicker style={{ width: "100%" }} value={deliveryDate} onChange={(date, dateString) => setDeliveryDate(date)} />
</FormGroup>
</Col>
</Row>
</Form>
)
}
else if (typeDialog === 'EditMatDelv') {
return (
<Form>
<Row>
<Col md={12}>
<FormGroup>
<Label className="capitalize">Status</Label>
<Select showSearch value={status} defaultValue={status} onChange={(val) => setStatus(val)} placeholder="Select status" style={{ width: '100%' }}>
<Option value="receipt to warehouse">Receipt to Warehouse</Option>
<Option value="receipt to site">Receipt to Site</Option>
</Select>
</FormGroup>
</Col>
</Row>
<Row>
<Col md={6}>
<FormGroup>
<Label className="capitalize">Description</Label>
<Input row="2" type="textarea" value={description} onChange={(e)=> setDescription(e.target.value)} placeholder={`Description ...`} />
</FormGroup>
</Col>
<Col md={6}>
<FormGroup>
<Label className="capitalize">Required Date</Label>
<DatePicker style={{ width: "100%" }} value={requiredDate} onChange={(date, dateString) => setRequiredDate(date)} />
</FormGroup>
</Col>
</Row>
<Row>
<Col md={6}>
<FormGroup>
<Label className="capitalize">QTY</Label>
<Input type="number" value={qty} onChange={(e) => setQty(e.target.value)} placeholder={`Input QTY...`} disabled />
</FormGroup>
</Col>
<Col md={6}>
<FormGroup>
<Label className="capitalize">UOM</Label>
<Input type="text" value={uom} onChange={(e) => setUom(e.target.value)} placeholder={`Input UOM...`} disabled />
</FormGroup>
</Col>
</Row>
<Row>
<Col md={6}>
<FormGroup>
<Label className="capitalize">QTY Received</Label>
<Input type="number" min="0" max={qty} value={qtyReceived} onChange={(e) => setQtyReceived(e.target.value)} placeholder={`Input QTY Received...`} />
</FormGroup>
</Col>
<Col md={6}>
<FormGroup>
<Label className="capitalize">FOM Date</Label>
<DatePicker style={{ width: "100%" }} value={fomDate} onChange={(date, dateString) => setFomDate(date)} />
</FormGroup>
</Col>
</Row>
<Row>
<Col md={6}>
<FormGroup>
<Label className="capitalize">PR Date</Label>
<DatePicker style={{ width: "100%" }} value={prDate} onChange={(date, dateString) => setPrDate(date)} />
</FormGroup>
</Col>
<Col md={6}>
<FormGroup>
<Label className="capitalize">PO Date</Label>
<DatePicker style={{ width: "100%" }} value={poDate} onChange={(date, dateString) => setPoDate(date)} />
</FormGroup>
</Col>
</Row>
<Row>
<Col md={6}>
<FormGroup>
<Label className="capitalize">Received Date</Label>
<DatePicker style={{ width: "100%" }} value={receivedDate} onChange={(date, dateString) => setReceivedDate(date)} />
</FormGroup>
</Col>
<Col md={6}>
<FormGroup>
<Label className="capitalize">Delivery Date</Label>
<DatePicker style={{ width: "100%" }} value={deliveryDate} onChange={(date, dateString) => setDeliveryDate(date)} />
</FormGroup>
</Col>
</Row>
</Form>
)
}
}
return (
<>
<Modal size="lg" isOpen={openDialog} toggle={toggleDialog}>
<ModalHeader className="capitalize" toggle={closeDialog}>{typeDialog=="Save" ? `Add` : "Edit"} Resource</ModalHeader>
<ModalBody>
{renderForm()}
</ModalBody>
<ModalFooter>
<Button color="primary" onClick={() => handleSave()}>{typeDialog === 'Save' ? 'Save' : 'Edit'}</Button>{' '}
<Button className="capitalize" color="secondary" onClick={() => handleCancel()}>Batal</Button>
</ModalFooter>
</Modal>
{/* <DialogMap
openDialog={openDialogMap}
closeDialog={handleCloseDialogMap}
toggleDialog={() => toggleMapDialog}
dataEdit={dataEdit}
workArea_={workArea}
lat_={lat}
lon_={lon}
radius_={radius}
/> */}
</>
)
}
export default DialogForm;
import React, { useEffect, useState } from 'react'
import {
Modal, ModalHeader, ModalBody, ModalFooter,
Button, Form, FormGroup, Label, Input, Col, Row
} from 'reactstrap';
import { DatePicker, Tooltip, Select } from 'antd';
import { formatRupiah, formatNumber } from '../../../const/CustomFunc'
import moment from 'moment';
import 'antd/dist/antd.css';
const { Option } = Select
const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdit, dataUom }) => {
const [id, setId] = useState(0)
const [materialName, setMaterialName] = useState('')
const [uom, setUom] = useState('')
const [description, setDescription] = useState('')
const [unitPrice, setUnitPrice] = useState('')
const [priceReq, setPriceReq] = useState('')
const [status, setStatus] = useState('')
const [requiredDate, setRequiredDate] = useState(null)
const [qty, setQty] = useState('')
const [qtyReceived, setQtyReceived] = useState('')
const [fomDate, setFomDate] = useState(null)
const [prDate, setPrDate] = useState(null)
const [poDate, setPoDate] = useState(null)
const [receivedDate, setReceivedDate] = useState(null)
const [deliveryDate, setDeliveryDate] = useState(null)
useEffect(() => {
if (typeDialog === "Edit") {
console.log("cel data Edit", dataEdit)
setId(dataEdit.id)
setQty(dataEdit.qty)
setDescription(dataEdit.description)
setUnitPrice(dataEdit.unit_price)
setUom(dataEdit.uom)
setMaterialName(dataEdit.name)
setStatus(dataEdit.status)
}
else if (typeDialog === 'EditMatReq') {
console.log("cel data EditMatReq", dataEdit)
setId(dataEdit.id)
setDescription(dataEdit.description)
setUnitPrice(dataEdit.unit_price)
setUom(dataEdit.uom)
setStatus(dataEdit.status)
setRequiredDate(dataEdit.required_date ? moment(dataEdit.required_date) : null)
setQty(dataEdit.qty)
setQtyReceived(dataEdit.qty_received)
setFomDate(dataEdit.fom_date ? moment(dataEdit.fom_date) : null)
setPrDate(dataEdit.pr_date ? moment(dataEdit.pr_date) : null)
setPoDate(dataEdit.po_date ? moment(dataEdit.po_date) : null)
setReceivedDate(dataEdit.received_date ? moment(dataEdit.received_date) : null)
setDeliveryDate(dataEdit.delivery_date ? moment(dataEdit.delivery_date) : null)
}
else if (typeDialog === 'EditMatDelv') {
console.log("cel data EditMatDelv", dataEdit)
setId(dataEdit.id)
setDescription(dataEdit.description)
setUnitPrice(dataEdit.unit_price)
setUom(dataEdit.uom)
setStatus(dataEdit.status)
setRequiredDate(dataEdit.required_date ? moment(dataEdit.required_date) : null)
setQty(dataEdit.qty)
setQtyReceived(dataEdit.qty_received)
setFomDate(dataEdit.fom_date ? moment(dataEdit.fom_date) : null)
setPrDate(dataEdit.pr_date ? moment(dataEdit.pr_date) : null)
setPoDate(dataEdit.po_date ? moment(dataEdit.po_date) : null)
setReceivedDate(dataEdit.received_date ? moment(dataEdit.received_date) : null)
setDeliveryDate(dataEdit.delivery_date ? moment(dataEdit.delivery_date) : null)
}
else if (typeDialog === 'Save') {
setId(0)
}
}, [dataEdit, openDialog])
const handleSave = () => {
let data = '';
if (typeDialog === "Save") {
data = {
name: materialName,
qty,
uom,
description,
unit_price: typeof (unitPrice) === 'string' && unitPrice !== '' && unitPrice.includes('.') ? parseInt(unitPrice.replace(/\./g, '')) : unitPrice,
status
}
closeDialog('save', data);
}
else if (typeDialog === 'Edit') {
console.log('typeof', typeof (unitPrice));
data = {
id,
name: materialName,
qty,
uom,
description,
unit_price: typeof (unitPrice) === 'string' && unitPrice !== '' && unitPrice.includes('.') ? parseInt(unitPrice.replace(/\./g, '')) : unitPrice,
status
}
closeDialog('edit', data);
}
else if (typeDialog === 'EditMatReq') {
data = {
id,
uom,
description,
status,
required_date: requiredDate,
qty,
qty_received: qtyReceived,
fom_date: fomDate,
pr_date: prDate,
po_date: poDate,
received_date: receivedDate,
delivery_date: deliveryDate,
price: typeof (priceReq) === 'string' && priceReq !== '' && priceReq.includes('.') ? parseInt(priceReq.replace(/\./g, '')) : priceReq,
}
closeDialog('EditMatReq', data);
}
else if (typeDialog === 'EditMatDelv') {
data = {
id,
uom,
description,
status,
required_date: requiredDate,
qty,
qty_received: qtyReceived,
fom_date: fomDate,
pr_date: prDate,
po_date: poDate,
received_date: receivedDate,
delivery_date: deliveryDate
}
closeDialog('EditMatDelv', data);
}
setId(0)
setDescription('')
}
const handleCancel = () => {
closeDialog('cancel', 'none')
setId(0)
setDescription('')
}
const setupSelectUom = () => {
return (
<>
{dataUom.map((val, index) => {
return (
<Option key={index} value={val.id}>{val.name}</Option>
)
})}
</>
)
}
const renderForm = () => {
if (typeDialog === 'Save' || typeDialog === 'Edit') {
return (
<Form>
<Row>
<Col md={12}>
<FormGroup>
<Label className="capitalize">Material Name</Label>
<Input type="text" value={materialName} onChange={(e) => setMaterialName(e.target.value)} placeholder={`Input material name...`} />
</FormGroup>
</Col>
</Row>
<Row>
<Col md={6}>
<FormGroup>
<Label className="capitalize">QTY</Label>
<Input type="number" value={qty} onChange={(e) => setQty(e.target.value)} placeholder={`Input qty...`} />
</FormGroup>
</Col>
<Col md={6}>
<FormGroup>
<Label className="capitalize">UOM</Label>
<Select showSearch defaultValue={uom} onChange={(val) => setUom(val)} placeholder="Select Uom" style={{ width: '100%' }}>
{setupSelectUom()}
</Select>
</FormGroup>
<Col md={6}>
</Col>
</Col>
</Row>
<Row>
<Col md={6}>
<FormGroup>
<Label className="capitalize">Unit Price</Label>
<Input type="text" value={unitPrice} onChange={(e) => setUnitPrice(formatNumber(e.target.value))} placeholder={`Unit Price...`} />
</FormGroup>
</Col>
<Col md={6}>
<FormGroup>
<Label className="capitalize">Status</Label>
<Input type="text" value={status} onChange={(e) => setStatus(e.target.value)} placeholder={`Status ...`} />
</FormGroup>
</Col>
</Row>
<Row>
<Col md={12}>
<FormGroup>
<Label className="capitalize">Description</Label>
<Input row="2" type="textarea" value={description} onChange={(e) => setDescription(e.target.value)} placeholder={`Description ...`} />
</FormGroup>
</Col>
</Row>
</Form>
)
}
else if (typeDialog === 'EditMatReq') {
return (
<Form>
<Row>
<Col md={6}>
<FormGroup>
<Label className="capitalize">Status</Label>
<Select showSearch value={status} defaultValue={status} onChange={(val) => setStatus(val)} placeholder="Select status" style={{ width: '100%' }}>
<Option value="fom">FOM (Form Order Material)</Option>
<Option value="PO">PO (Pre Order)</Option>
<Option value="PO approve">PO approve</Option>
<Option value="PO supplier">PO supplier</Option>
<Option value="material deliver to warehouse">Material Deliver to Warehouse</Option>
<Option value="receipt to warehouse">Receipt to Warehouse</Option>
<Option value="receipt to site">Receipt to Site</Option>
</Select>
</FormGroup>
</Col>
<Col md={6}>
<FormGroup>
<Label className="capitalize">Price</Label>
<Input type="text" value={priceReq} onChange={(e) => setPriceReq(formatNumber(e.target.value))} placeholder={`Input Price ...`} />
</FormGroup>
</Col>
</Row>
<Row>
<Col md={6}>
<FormGroup>
<Label className="capitalize">Description</Label>
<Input row="2" type="textarea" value={description} onChange={(e) => setDescription(e.target.value)} placeholder={`Description ...`} />
</FormGroup>
</Col>
<Col md={6}>
<FormGroup>
<Label className="capitalize">Required Date</Label>
<DatePicker style={{ width: "100%" }} value={requiredDate} onChange={(date, dateString) => setRequiredDate(date)} />
</FormGroup>
</Col>
</Row>
<Row>
<Col md={6}>
<FormGroup>
<Label className="capitalize">QTY</Label>
<Input type="number" min="0" value={qty} onChange={(e) => setQty(e.target.value)} placeholder={`Input QTY...`} disabled />
</FormGroup>
</Col>
<Col md={6}>
<FormGroup>
<Label className="capitalize">UOM</Label>
<Input type="text" value={uom} onChange={(e) => setUom(e.target.value)} placeholder={`Input UOM...`} disabled />
</FormGroup>
</Col>
</Row>
<Row>
<Col md={6}>
<FormGroup>
<Label className="capitalize">QTY Received</Label>
<Input type="number" min="0" max={qty} value={qtyReceived} onChange={(e) => setQtyReceived(e.target.value)} placeholder={`Input QTY Received...`} />
</FormGroup>
</Col>
<Col md={6}>
<FormGroup>
<Label className="capitalize">FOM Date</Label>
<DatePicker style={{ width: "100%" }} value={fomDate} onChange={(date, dateString) => setFomDate(date)} />
</FormGroup>
</Col>
</Row>
<Row>
<Col md={6}>
<FormGroup>
<Label className="capitalize">PR Date</Label>
<DatePicker style={{ width: "100%" }} value={prDate} onChange={(date, dateString) => setPrDate(date)} />
</FormGroup>
</Col>
<Col md={6}>
<FormGroup>
<Label className="capitalize">PO Date</Label>
<DatePicker style={{ width: "100%" }} value={poDate} onChange={(date, dateString) => setPoDate(date)} />
</FormGroup>
</Col>
</Row>
<Row>
<Col md={6}>
<FormGroup>
<Label className="capitalize">Received to Warehouse Date</Label>
<DatePicker style={{ width: "100%" }} value={receivedDate} onChange={(date, dateString) => setReceivedDate(date)} />
</FormGroup>
</Col>
<Col md={6}>
<FormGroup>
<Label className="capitalize">Delivery to Site Date</Label>
<DatePicker style={{ width: "100%" }} value={deliveryDate} onChange={(date, dateString) => setDeliveryDate(date)} />
</FormGroup>
</Col>
</Row>
</Form>
)
}
else if (typeDialog === 'EditMatDelv') {
return (
<Form>
<Row>
<Col md={12}>
<FormGroup>
<Label className="capitalize">Status</Label>
<Select showSearch value={status} defaultValue={status} onChange={(val) => setStatus(val)} placeholder="Select status" style={{ width: '100%' }}>
<Option value="receipt to warehouse">Receipt to Warehouse</Option>
<Option value="receipt to site">Receipt to Site</Option>
</Select>
</FormGroup>
</Col>
</Row>
<Row>
<Col md={6}>
<FormGroup>
<Label className="capitalize">Description</Label>
<Input row="2" type="textarea" value={description} onChange={(e) => setDescription(e.target.value)} placeholder={`Description ...`} />
</FormGroup>
</Col>
<Col md={6}>
<FormGroup>
<Label className="capitalize">Required Date</Label>
<DatePicker style={{ width: "100%" }} value={requiredDate} onChange={(date, dateString) => setRequiredDate(date)} />
</FormGroup>
</Col>
</Row>
<Row>
<Col md={6}>
<FormGroup>
<Label className="capitalize">QTY</Label>
<Input type="number" value={qty} onChange={(e) => setQty(e.target.value)} placeholder={`Input QTY...`} disabled />
</FormGroup>
</Col>
<Col md={6}>
<FormGroup>
<Label className="capitalize">UOM</Label>
<Input type="text" value={uom} onChange={(e) => setUom(e.target.value)} placeholder={`Input UOM...`} disabled />
</FormGroup>
</Col>
</Row>
<Row>
<Col md={6}>
<FormGroup>
<Label className="capitalize">QTY Received</Label>
<Input type="number" min="0" max={qty} value={qtyReceived} onChange={(e) => setQtyReceived(e.target.value)} placeholder={`Input QTY Received...`} />
</FormGroup>
</Col>
<Col md={6}>
<FormGroup>
<Label className="capitalize">FOM Date</Label>
<DatePicker style={{ width: "100%" }} value={fomDate} onChange={(date, dateString) => setFomDate(date)} />
</FormGroup>
</Col>
</Row>
<Row>
<Col md={6}>
<FormGroup>
<Label className="capitalize">PR Date</Label>
<DatePicker style={{ width: "100%" }} value={prDate} onChange={(date, dateString) => setPrDate(date)} />
</FormGroup>
</Col>
<Col md={6}>
<FormGroup>
<Label className="capitalize">PO Date</Label>
<DatePicker style={{ width: "100%" }} value={poDate} onChange={(date, dateString) => setPoDate(date)} />
</FormGroup>
</Col>
</Row>
<Row>
<Col md={6}>
<FormGroup>
<Label className="capitalize">Received Date</Label>
<DatePicker style={{ width: "100%" }} value={receivedDate} onChange={(date, dateString) => setReceivedDate(date)} />
</FormGroup>
</Col>
<Col md={6}>
<FormGroup>
<Label className="capitalize">Delivery Date</Label>
<DatePicker style={{ width: "100%" }} value={deliveryDate} onChange={(date, dateString) => setDeliveryDate(date)} />
</FormGroup>
</Col>
</Row>
</Form>
)
}
}
return (
<>
<Modal size="lg" isOpen={openDialog} toggle={toggleDialog}>
<ModalHeader className="capitalize" toggle={closeDialog}>{typeDialog == "Save" ? `Add` : "Edit"} Resource</ModalHeader>
<ModalBody>
{renderForm()}
</ModalBody>
<ModalFooter>
<Button color="primary" onClick={() => handleSave()}>{typeDialog === 'Save' ? 'Save' : 'Edit'}</Button>{' '}
<Button className="capitalize" color="secondary" onClick={() => handleCancel()}>Batal</Button>
</ModalFooter>
</Modal>
{/* <DialogMap
openDialog={openDialogMap}
closeDialog={handleCloseDialogMap}
toggleDialog={() => toggleMapDialog}
dataEdit={dataEdit}
workArea_={workArea}
lat_={lat}
lon_={lon}
radius_={radius}
/> */}
</>
)
}
export default DialogForm;

200
src/views/SimproV2/ResourceMaterial/index.js

@ -14,7 +14,7 @@ import {
PROYEK_ADD, PROYEK_SEARCH, PROYEK_EDIT, PROYEK_DELETE,
MATERIAL_RESOURCE_ADD, MATERIAL_RESOURCE_EDIT, MATERIAL_RESOURCE_DELETE, MATERIAL_RESOURCE_SEARCH,
REQUEST_MATERIAL_SEARCH, REQUEST_MATERIAL_EDIT,
REQUEST_MATERIAL_UPDATE_WAREHOUSE_SITE
REQUEST_MATERIAL_UPDATE_WAREHOUSE_SITE, SATUAN_SEARCH
} from '../../../const/ApiConst';
const { TabPane } = Tabs;
@ -52,6 +52,7 @@ const Resource = ({ params }) => {
const [dataExport, setDataExport] = useState([])
const [dataReqMaterial, setDataReqMaterial] = useState([])
const [dataTable, setDatatable] = useState([])
const [dataSatuan, setDatasatuan] = useState([])
const [idDelete, setIdDelete] = useState(0)
const [openDialog, setOpenDialog] = useState(false)
const [rowsPerPage, setRowsPerPage] = useState(10)
@ -62,6 +63,7 @@ const Resource = ({ params }) => {
useEffect(() => {
getDataReqMaterial()
getDataSatuan()
}, [])
useEffect(() => {
@ -71,7 +73,9 @@ const Resource = ({ params }) => {
useEffect(() => {
const cekData = dataExport || []
if (cekData.length > 0) {
exportExcel()
exportExcelRequestMaterial()
exportExcelMaterialResource()
}
}, [dataExport])
@ -159,6 +163,53 @@ const Resource = ({ params }) => {
}
}
const getDataSatuan = async () => {
let start = 0;
if (currentPage !== 1 && currentPage > 1) {
start = (currentPage * rowsPerPage) - rowsPerPage
}
const payload = {
"columns": [
{
"name": "name",
"logic_operator": "ilike",
"value": search,
"operator": "AND"
},
{
"name": "description",
"logic_operator": "ilike",
"value": search,
"operator": "AND"
}
],
"orders": {
"ascending": true,
"columns": [
'id'
]
},
"paging": {
"length": rowsPerPage,
"start": start
}
}
const result = await axios
.post(SATUAN_SEARCH, payload, HEADER)
.then(res => res)
.catch((error) => error.response);
if (result && result.data && result.data.code == 200) {
setDatasatuan(result.data.data);
setTotalPage(result.data.totalRecord);
} else {
NotificationManager.error('Gagal Mengambil Data!!', 'Failed');
}
}
const handleSearch = e => {
const value = e.target.value
setSearch(value);
@ -170,9 +221,9 @@ const Resource = ({ params }) => {
setTypeDialog(type)
}
const exportExcel = () => {
const exportExcelRequestMaterial = () => {
const dataExcel = dataExport || [];
const fileName = `Data ${pageName}.xlsx`;
const fileName = `Data Request Material.xlsx`;
const ws = XLSX.utils.json_to_sheet(dataExcel);
const wb = XLSX.utils.book_new();
XLSX.utils.book_append_sheet(wb, ws, `Data ${pageName}`);
@ -180,24 +231,72 @@ const Resource = ({ params }) => {
setDataExport([])
}
const exportExcelMaterialResource = () => {
const dataExcel = dataExport || [];
const fileName = `Data MaterialResource.xlsx`;
const ws = XLSX.utils.json_to_sheet(dataExcel);
const wb = XLSX.utils.book_new();
XLSX.utils.book_append_sheet(wb, ws, `Data ${pageName}`);
XLSX.writeFile(wb, fileName);
setDataExport([])
}
const handleExportExcel = async () => {
const handleExportExcelMaterialDel = async () => {
const payload = {
"paging": { "start": 0, "length": -1 },
"joins": [],
"orders": { "columns": ["id"], "ascending": false }
"columns": [
{ "name": "description", "logic_operator": "ilike", "value": "", "operator": "AND" },
],
"joins": [
{ "name": "m_proyek", "column_join": "proyek_id", "column_results": ["kode_sortname", "nama"] }
],
"orders": { "columns": ["id"], "ascending": true },
"paging": { "start": 0, "length": -1 }
}
if (parseInt(role_id) !== 1) {
payload["columns"] = [
{ "name": "id", "logic_operator": "=", "value": proyek_id, "operator": "AND" }
]
const result = await axios
.post(REQUEST_MATERIAL_SEARCH, payload, HEADER)
.then(res => res)
.catch((error) => error.response);
if (result && result.data && result.data.code == 200) {
let resData = result.data.data;
const excelData = [];
resData.map((n, index) => {
let dataRow = {
"Nama Material": n.description,
"Quantity": n.qty,
"Status": n.status,
"Price": n.price,
"Uom": n.uom,
}
excelData.push(dataRow)
})
await setDataExport(excelData);
} else {
NotificationManager.error('Gagal Export Data!!', 'Failed');
}
}
const handleExportExcelRequestMaterial = async () => {
const payload = {
"columns": [
{ "name": "description", "logic_operator": "ilike", "value": "", "operator": "AND" },
],
"joins": [
{ "name": "m_proyek", "column_join": "proyek_id", "column_results": ["kode_sortname", "nama"] }
],
"orders": { "columns": ["id"], "ascending": true },
"paging": { "start": 0, "length": -1 }
}
const result = await axios
.post(PROYEK_SEARCH, payload, HEADER)
.post(REQUEST_MATERIAL_SEARCH, payload, HEADER)
.then(res => res)
.catch((error) => error.response);
@ -207,12 +306,68 @@ const Resource = ({ params }) => {
const excelData = [];
resData.map((n, index) => {
let dataRow = {
"Nama Proyek": n.nama,
"Biaya": n.biaya,
"Color Progress": n.color_progress,
"Jumlah Pekerja": n.jumlah_pekerja,
"Tanggal Mulai": n.mulai_proyek ? moment(n.mulai_proyek).format(format) : "-",
"Tanggal Selesai": n.akhir_proyek ? moment(n.akhir_proyek).format(format) : "-",
"Nama Material": n.description,
"Quantity": n.qty,
"Status": n.status,
"Price": n.price,
"Uom": n.uom,
}
excelData.push(dataRow)
})
await setDataExport(excelData);
} else {
NotificationManager.error('Gagal Export Data!!', 'Failed');
}
}
const handleExportExcelMatResource = async () => {
let start = 0;
if (currentPage !== 1 && currentPage > 1) {
start = (currentPage * rowsPerPage) - rowsPerPage
}
const payload = {
"columns": [
{
"name": "name",
"logic_operator": "ilike",
"value": search,
"operator": "AND"
}
],
"orders": {
"ascending": true,
"columns": [
'id'
]
},
"paging": {
"length": -1,
"start": start
}
}
const result = await axios
.post(MATERIAL_RESOURCE_SEARCH, payload, HEADER)
.then(res => res)
.catch((error) => error.response);
if (result && result.data && result.data.code == 200) {
let resData = result.data.data;
const excelData = [];
resData.map((n, index) => {
let dataRow = {
"Nama Material": n.name,
"Quantity": n.qty,
"Status": n.status,
"Unit Price": n.unit_price,
"Uom": n.uom,
}
excelData.push(dataRow)
})
@ -507,7 +662,7 @@ const Resource = ({ params }) => {
<Button style={{ background: "#4caf50", color: "#fff" }} onClick={() => handleOpenDialog('Save')}><i className="fa fa-plus"></i></Button>
</Tooltip>
<Tooltip title="Export Excel">
<Button style={{ marginLeft: "5px" }} onClick={() => handleExportExcel()}><i className="fa fa-print"></i></Button>
<Button style={{ marginLeft: "5px" }} onClick={() => handleExportExcelMatResource()}><i className="fa fa-print"></i></Button>
</Tooltip>
</Col>
</Row>
@ -540,7 +695,7 @@ const Resource = ({ params }) => {
</Col>
<Col>
<Tooltip title="Export Excel">
<Button style={{ marginLeft: "5px" }} onClick={() => handleExportExcel()}><i className="fa fa-print"></i></Button>
<Button style={{ marginLeft: "5px" }} onClick={() => handleExportExcelRequestMaterial()}><i className="fa fa-print"></i></Button>
</Tooltip>
</Col>
</Row>
@ -565,7 +720,7 @@ const Resource = ({ params }) => {
</Col>
<Col>
<Tooltip title="Export Excel">
<Button style={{ marginLeft: "5px" }} onClick={() => handleExportExcel()}><i className="fa fa-print"></i></Button>
{/* <Button style={{ marginLeft: "5px" }} onClick={() => handleExportExcel()}><i className="fa fa-print"></i></Button> */}
</Tooltip>
</Col>
</Row>
@ -603,6 +758,7 @@ const Resource = ({ params }) => {
dataEdit={dataEdit}
clickOpenModal={clickOpenModal}
dataParent={allDataMenu}
dataUom={dataSatuan}
/>
<Tabs defaultActiveKey="1">
<TabPane tab="Material Resource Pool" key="1">

107
src/views/SimproV2/ResourceWorker/index.js

@ -231,23 +231,92 @@ const ResourceWorker = ({ params }) => {
const handleExportExcel = async () => {
const payload = {
"paging": { "start": 0, "length": -1 },
"columns": [
{ "name": "name", "logic_operator": "ilike", "value": search, "operator": "AND" }
],
"joins": [],
"orders": { "columns": ["id"], "ascending": false }
}
let start = 0;
if (parseInt(role_id) !== 1) {
payload["columns"] = [
{ "name": "id", "logic_operator": "=", "value": proyek_id, "operator": "AND" }
]
if (currentPage !== 1 && currentPage > 1) {
start = (currentPage * rowsPerPage) - rowsPerPage
}
const payload = {
"paging": {
"start": start,
"length": -1
},
"columns": [],
"group_column": {
"operator": "AND",
"group_operator": "OR",
"where": [
{
"name": "name",
"logic_operator": "~*",
"value": search
},
{
"name": "ktp_number",
"logic_operator": "~*",
"value": search
},
{
"name": "name",
"logic_operator": "~*",
"value": search,
"table_name": "m_divisi"
},
{
"name": "employee_type",
"logic_operator": "~*",
"value": search
},
{
"name": "name",
"logic_operator": "~*",
"value": search,
"table_name": "m_roles"
},
{
"name": "phone_number",
"logic_operator": "~*",
"value": search
},
{
"name": "email",
"logic_operator": "~*",
"value": search
},
{
"name": "status_resource",
"logic_operator": "~*",
"value": search
},
]
},
"joins": [
{
"name": "m_roles",
"column_join": "role_id",
"column_results": [
"name",
"description"
]
},
{
"name": "m_divisi",
"column_join": "divisi_id",
"column_results": [
"name"
]
}
],
"orders": {
"columns": [
"id"
],
"ascending": false
}
}
const result = await axios
.post(PROYEK_SEARCH, payload, HEADER)
.post(USER_SEARCH, payload, HEADER)
.then(res => res)
.catch((error) => error.response);
@ -256,12 +325,12 @@ const ResourceWorker = ({ params }) => {
const excelData = [];
resData.map((n, index) => {
let dataRow = {
"Nama Proyek": n.nama,
"Biaya": n.biaya,
"Color Progress": n.color_progress,
"Jumlah Pekerja": n.jumlah_pekerja,
"Tanggal Mulai": n.mulai_proyek ? moment(n.mulai_proyek).format(format) : "-",
"Tanggal Selesai": n.akhir_proyek ? moment(n.akhir_proyek).format(format) : "-",
"NIK (Nomor Induk Karyawan)": n.ktp_number,
"Employee Name": n.name,
"Divisi": n.join_second_name,
"Employee Type": n.employee_type,
"Role": n.join_first_name,
"Phone No": n.phone_number,
}
excelData.push(dataRow)
})

Loading…
Cancel
Save