nurkomalasari
2 years ago
4 changed files with 710 additions and 469 deletions
@ -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; |
||||
|
Loading…
Reference in new issue