mejojas requeridas de quitar fecha en nea bienes y pecosa bienes, ordenamiento de bienes en reportes
parent
69bad80367
commit
4d8b00817a
@ -1,397 +1,416 @@
|
||||
|
||||
// Argon Dashboard 2 MUI components
|
||||
import ArgonBox from "components/ArgonBox";
|
||||
import { InputText } from "primereact/inputtext";
|
||||
import { Toast } from 'primereact/toast';
|
||||
import PropTypes from 'prop-types'; // Importa PropTypes
|
||||
import { Toast } from "primereact/toast";
|
||||
import PropTypes from "prop-types"; // Importa PropTypes
|
||||
|
||||
import { Button } from 'primereact/button';
|
||||
import { Button } from "primereact/button";
|
||||
import { InputNumber } from "primereact/inputnumber";
|
||||
|
||||
import { Dialog } from 'primereact/dialog';
|
||||
import { Dropdown } from 'primereact/dropdown';
|
||||
import { InputTextarea } from 'primereact/inputtextarea';
|
||||
import { Column } from 'primereact/column';
|
||||
import { DataTable } from 'primereact/datatable';
|
||||
import "./stylesBienes.css"
|
||||
import { Dialog } from "primereact/dialog";
|
||||
import { Dropdown } from "primereact/dropdown";
|
||||
import { InputTextarea } from "primereact/inputtextarea";
|
||||
import { Column } from "primereact/column";
|
||||
import { DataTable } from "primereact/datatable";
|
||||
import "./stylesBienes.css";
|
||||
// Data
|
||||
import React, { useState, useEffect, useRef } from 'react';
|
||||
import { useMountEffect } from 'primereact/hooks';
|
||||
import React, { useState, useEffect, useRef } from "react";
|
||||
import { useMountEffect } from "primereact/hooks";
|
||||
|
||||
import { useNavigate, useParams } from "react-router-dom";
|
||||
|
||||
import { Message } from 'primereact/message';
|
||||
|
||||
import { apiPostNeaBienes, apiPostPecosaInventarioBienes, apiListInventarioBienesConStock, apiGetMedidaEnable } from "config/api";
|
||||
import { Message } from "primereact/message";
|
||||
|
||||
import {
|
||||
apiPostNeaBienes,
|
||||
apiPostPecosaInventarioBienes,
|
||||
apiListInventarioBienesConStock,
|
||||
apiGetMedidaEnable,
|
||||
} from "config/api";
|
||||
import axios from "axios";
|
||||
|
||||
function CrearInventarioBienes({ visible, onHide, rowData, onSaveSuccess }) {
|
||||
const toast = useRef(null);
|
||||
const msgs = useRef(null);
|
||||
|
||||
|
||||
const [errores, setErrores] = useState({});
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [dataEnable, setDataEnable] = useState([])
|
||||
const [selectedMedida, setSelectedMedida] = useState([]);
|
||||
const [bienesSeleccionados, setBienesSeleccionados] = useState([]);
|
||||
const [bienesSeleccionado, setBienesSeleccionado] = useState(null);
|
||||
|
||||
async function getDataEnable() {
|
||||
try {
|
||||
const token = sessionStorage.getItem("token");
|
||||
|
||||
const response = await axios.get(`${apiListInventarioBienesConStock}`, {
|
||||
headers: { Authorization: `Bearer ${token}` },
|
||||
})
|
||||
if (response.status === 201) {
|
||||
setDataEnable(response.data.data)
|
||||
}
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
|
||||
}
|
||||
const toast = useRef(null);
|
||||
const msgs = useRef(null);
|
||||
|
||||
const [errores, setErrores] = useState({});
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [dataEnable, setDataEnable] = useState([]);
|
||||
const [selectedMedida, setSelectedMedida] = useState([]);
|
||||
const [bienesSeleccionados, setBienesSeleccionados] = useState([]);
|
||||
const [bienesSeleccionado, setBienesSeleccionado] = useState(null);
|
||||
const hoy = new Date().toLocaleDateString("en-CA");
|
||||
|
||||
async function getDataEnable() {
|
||||
try {
|
||||
const token = sessionStorage.getItem("token");
|
||||
|
||||
const response = await axios.get(`${apiListInventarioBienesConStock}`, {
|
||||
headers: { Authorization: `Bearer ${token}` },
|
||||
});
|
||||
if (response.status === 201) {
|
||||
setDataEnable(response.data.data);
|
||||
}
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
|
||||
async function getDataMedidasEnable() {
|
||||
try {
|
||||
const token = sessionStorage.getItem("token");
|
||||
|
||||
const response = await axios.get(`${apiGetMedidaEnable}`, {
|
||||
headers: { Authorization: `Bearer ${token}` },
|
||||
})
|
||||
if (response.status === 201) {
|
||||
setSelectedMedida(response.data.data)
|
||||
}
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
async function getDataMedidasEnable() {
|
||||
try {
|
||||
const token = sessionStorage.getItem("token");
|
||||
|
||||
const response = await axios.get(`${apiGetMedidaEnable}`, {
|
||||
headers: { Authorization: `Bearer ${token}` },
|
||||
});
|
||||
if (response.status === 201) {
|
||||
setSelectedMedida(response.data.data);
|
||||
}
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
getDataEnable();
|
||||
getDataMedidasEnable();
|
||||
}, [rowData])
|
||||
|
||||
useEffect(() => {
|
||||
setBienesSeleccionados([]);
|
||||
}, [rowData?.id])
|
||||
|
||||
|
||||
|
||||
const agregarProducto = () => {
|
||||
if (
|
||||
bienesSeleccionado &&
|
||||
!bienesSeleccionados.some((p) => p.id === bienesSeleccionado.id)
|
||||
) {
|
||||
setBienesSeleccionados([
|
||||
...bienesSeleccionados,
|
||||
{
|
||||
...bienesSeleccionado,
|
||||
cantidad_salida: 1,
|
||||
descripcion_pecosa_bien: null,
|
||||
observaciones: 'Inventario',
|
||||
medida_salida: null,
|
||||
fecha_registro: "",
|
||||
},
|
||||
]);
|
||||
}
|
||||
};
|
||||
|
||||
const actualizarCampo = (id, campo, valor) => {
|
||||
setBienesSeleccionados(
|
||||
bienesSeleccionados.map((p) =>
|
||||
p.id === id ? { ...p, [campo]: valor } : p
|
||||
)
|
||||
);
|
||||
};
|
||||
|
||||
const quitarProducto = (id) => {
|
||||
setBienesSeleccionados(bienesSeleccionados.filter((p) => p.id !== id));
|
||||
};
|
||||
|
||||
const enviarData = async () => {
|
||||
console.log(bienesSeleccionados.id);
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
getDataEnable();
|
||||
getDataMedidasEnable();
|
||||
}, [rowData]);
|
||||
|
||||
useEffect(() => {
|
||||
setBienesSeleccionados([]);
|
||||
}, [rowData?.id]);
|
||||
|
||||
const agregarProducto = () => {
|
||||
if (bienesSeleccionado && !bienesSeleccionados.some((p) => p.id === bienesSeleccionado.id)) {
|
||||
setBienesSeleccionados([
|
||||
...bienesSeleccionados,
|
||||
{
|
||||
...bienesSeleccionado,
|
||||
cantidad_salida: 1,
|
||||
descripcion_pecosa_bien: null,
|
||||
observaciones: "Inventario",
|
||||
medida_salida: null,
|
||||
fecha_registro: hoy,
|
||||
},
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
async function submitBienes(e) {
|
||||
e.preventDefault();
|
||||
const token = sessionStorage.getItem("token")
|
||||
|
||||
setLoading(true);
|
||||
if (bienesSeleccionados.length === 0) {
|
||||
setLoading(false);
|
||||
toast.current.show({ severity: 'error', summary: 'Error', detail: 'Debe agregar al menos un bien', life: 3000 });
|
||||
return;
|
||||
}
|
||||
const body = bienesSeleccionados.map((bien) => ({
|
||||
id_pecosa_pedido: rowData?.id,
|
||||
id_inventario_inicial: bien.id,
|
||||
descripcion: bien.descripcion_pecosa_bien,
|
||||
cantidad: bien.cantidad_salida,
|
||||
id_unidad_medida: bien.medida_salida,
|
||||
observaciones: bien.observaciones,
|
||||
fecha: bien.fecha_registro,
|
||||
}));
|
||||
|
||||
try {
|
||||
|
||||
const response = await axios.post(apiPostPecosaInventarioBienes, { registros: body }, {
|
||||
headers: { Authorization: `Bearer ${token}` },
|
||||
});
|
||||
|
||||
if (response.status === 201) {
|
||||
setLoading(false);
|
||||
setBienesSeleccionados([]);
|
||||
toast.current.show({ severity: 'success', summary: 'Exito', detail: 'Creado con exito', life: 3000 });
|
||||
onSaveSuccess(); // Llama a la función para actualizar la tabla
|
||||
onHide(); // Cierra el modal
|
||||
|
||||
}
|
||||
} catch (error) {
|
||||
// setLoading(false)
|
||||
|
||||
if (error.status === 403) {
|
||||
setLoading(false);
|
||||
toast.current.show({
|
||||
unstyled: true, // Desactiva los estilos por defecto
|
||||
summary: "Aviso",
|
||||
detail: error.response.data.error,
|
||||
life: 5000,
|
||||
style: {
|
||||
backgroundColor: "#ff6b35", // Naranja fuerte
|
||||
color: "#fff", // Texto en blanco para buen contraste
|
||||
padding: "12px",
|
||||
borderRadius: "8px",
|
||||
fontWeight: "bold",
|
||||
boxShadow: "0px 4px 10px rgba(0, 0, 0, 0.2)",
|
||||
},
|
||||
});
|
||||
}
|
||||
if(error.response.status === 400){
|
||||
setLoading(false)
|
||||
toast.current.show({ severity: 'error', summary: 'Error', detail: 'Error Stock Insuficiente revise los datos', life: 3000 });
|
||||
|
||||
}
|
||||
if (error.response && error.response.status === 422) {
|
||||
// Captura los errores de validación
|
||||
setLoading(false)
|
||||
|
||||
// console.log(error.response.data.errors);
|
||||
const erroresValidacion = error.response.data.errors;
|
||||
setErrores(erroresValidacion);
|
||||
} else if (error.response && error.response.status === 500) {
|
||||
setLoading(false)
|
||||
|
||||
// Captura errores del servidor
|
||||
toast.current.show({ severity: 'error', summary: 'Error', detail: error.response.data.error, life: 3000 });
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
const actualizarCampo = (id, campo, valor) => {
|
||||
setBienesSeleccionados(
|
||||
bienesSeleccionados.map((p) => (p.id === id ? { ...p, [campo]: valor } : p))
|
||||
);
|
||||
};
|
||||
|
||||
const quitarProducto = (id) => {
|
||||
setBienesSeleccionados(bienesSeleccionados.filter((p) => p.id !== id));
|
||||
};
|
||||
|
||||
const enviarData = async () => {
|
||||
console.log(bienesSeleccionados.id);
|
||||
};
|
||||
|
||||
async function submitBienes(e) {
|
||||
e.preventDefault();
|
||||
const token = sessionStorage.getItem("token");
|
||||
|
||||
setLoading(true);
|
||||
if (bienesSeleccionados.length === 0) {
|
||||
setLoading(false);
|
||||
toast.current.show({
|
||||
severity: "error",
|
||||
summary: "Error",
|
||||
detail: "Debe agregar al menos un bien",
|
||||
life: 3000,
|
||||
});
|
||||
return;
|
||||
}
|
||||
const body = bienesSeleccionados.map((bien) => ({
|
||||
id_pecosa_pedido: rowData?.id,
|
||||
id_inventario_inicial: bien.id,
|
||||
descripcion: bien.descripcion_pecosa_bien,
|
||||
cantidad: bien.cantidad_salida,
|
||||
id_unidad_medida: bien.medida_salida,
|
||||
observaciones: bien.observaciones,
|
||||
fecha: bien.fecha_registro,
|
||||
}));
|
||||
|
||||
try {
|
||||
const response = await axios.post(
|
||||
apiPostPecosaInventarioBienes,
|
||||
{ registros: body },
|
||||
{
|
||||
headers: { Authorization: `Bearer ${token}` },
|
||||
}
|
||||
);
|
||||
|
||||
function cerrarModal() {
|
||||
if (response.status === 201) {
|
||||
setLoading(false);
|
||||
setBienesSeleccionados([]);
|
||||
onHide();
|
||||
toast.current.show({
|
||||
severity: "success",
|
||||
summary: "Exito",
|
||||
detail: "Creado con exito",
|
||||
life: 3000,
|
||||
});
|
||||
onSaveSuccess(); // Llama a la función para actualizar la tabla
|
||||
onHide(); // Cierra el modal
|
||||
}
|
||||
} catch (error) {
|
||||
// setLoading(false)
|
||||
|
||||
if (error.status === 403) {
|
||||
setLoading(false);
|
||||
toast.current.show({
|
||||
unstyled: true, // Desactiva los estilos por defecto
|
||||
summary: "Aviso",
|
||||
detail: error.response.data.error,
|
||||
life: 5000,
|
||||
style: {
|
||||
backgroundColor: "#ff6b35", // Naranja fuerte
|
||||
color: "#fff", // Texto en blanco para buen contraste
|
||||
padding: "12px",
|
||||
borderRadius: "8px",
|
||||
fontWeight: "bold",
|
||||
boxShadow: "0px 4px 10px rgba(0, 0, 0, 0.2)",
|
||||
},
|
||||
});
|
||||
}
|
||||
if (error.response.status === 400) {
|
||||
setLoading(false);
|
||||
toast.current.show({
|
||||
severity: "error",
|
||||
summary: "Error",
|
||||
detail: "Error Stock Insuficiente revise los datos",
|
||||
life: 3000,
|
||||
});
|
||||
}
|
||||
if (error.response && error.response.status === 422) {
|
||||
// Captura los errores de validación
|
||||
setLoading(false);
|
||||
|
||||
// console.log(error.response.data.errors);
|
||||
const erroresValidacion = error.response.data.errors;
|
||||
setErrores(erroresValidacion);
|
||||
} else if (error.response && error.response.status === 500) {
|
||||
setLoading(false);
|
||||
|
||||
// Captura errores del servidor
|
||||
toast.current.show({
|
||||
severity: "error",
|
||||
summary: "Error",
|
||||
detail: error.response.data.error,
|
||||
life: 3000,
|
||||
});
|
||||
}
|
||||
}
|
||||
return (
|
||||
<>
|
||||
<Toast ref={toast} />
|
||||
<Dialog
|
||||
|
||||
header={rowData?.id ? `CODIGO PECOSA: ${rowData.codigo}` : "Agregar Bienes"}
|
||||
visible={visible}
|
||||
style={{ width: '80vw' }}
|
||||
onHide={onHide}
|
||||
footer={
|
||||
<div>
|
||||
{rowData?.id && bienesSeleccionados.length > 0 ?
|
||||
<Button label="Agregar Bienes" type="submit"
|
||||
loading={loading}
|
||||
icon="pi pi-check" onClick={submitBienes} autoFocus />
|
||||
: null
|
||||
}
|
||||
<Button label="Cancelar" icon="pi pi-times" onClick={cerrarModal} className="p-button-text" />
|
||||
</div>
|
||||
}
|
||||
>
|
||||
<ArgonBox>
|
||||
{errores.bienes_id && <small className="p-error">{errores.bienes_id[0]}</small>}
|
||||
{/* <Message severity="success" text="Success Message" /> */}
|
||||
<Message severity="warn" text="Si se muestra este color, es que no hay stock" />
|
||||
<div className="formgrid grid">
|
||||
<div className="field col-12 md:col-11">
|
||||
<label >Agregar bienes de Inevtario</label>
|
||||
|
||||
<Dropdown value={bienesSeleccionado}
|
||||
onChange={(e) => {
|
||||
setBienesSeleccionado(e.value)
|
||||
}
|
||||
}
|
||||
filter
|
||||
options={dataEnable}
|
||||
optionLabel={(option) => `${option.descripcion} -- ${option.nombre_medida}`}
|
||||
placeholder="Seleccione"
|
||||
virtualScrollerOptions={{ itemSize: 38 }}
|
||||
|
||||
className="text-base text-color surface-overlay p-2 border-1 border-solid surface-border-900 border-round appearance-none outline-none focus:border-primary w-full"
|
||||
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="field col-12 md:col-1">
|
||||
<label >-</label>
|
||||
|
||||
<Button
|
||||
onClick={agregarProducto}
|
||||
icon="pi pi-plus"
|
||||
className="w-full"
|
||||
|
||||
/>
|
||||
|
||||
</div>
|
||||
|
||||
{bienesSeleccionados.length > 0 && (
|
||||
<div className="field col-12 md:col-12">
|
||||
|
||||
|
||||
<table border="1" cellPadding="5" className="styled-table">
|
||||
<thead>
|
||||
<tr >
|
||||
<th>Descripción Bien</th>
|
||||
<th style={{ width: "130px" }}>Cantidad Stock</th>
|
||||
<th style={{ width: "130px" }}>Cantidad Salida</th>
|
||||
<th >U. Medida de Nea</th>
|
||||
<th >U. Medida Salida</th>
|
||||
<th style={{ width: "220px" }}>Descripcion Adicional</th>
|
||||
<th style={{ width: "220px" }}>Observacion</th>
|
||||
<th>Fecha</th>
|
||||
<th>Acción</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{bienesSeleccionados.map((bien, index) => (
|
||||
<tr key={bien.id}
|
||||
style={{ background: Number(bien.cantidad) === 0 ? '#eadfb3' : 'transparent' }}
|
||||
>
|
||||
<td>{bien.descripcion}</td>
|
||||
<td>{bien.cantidad}</td>
|
||||
<td>
|
||||
<input
|
||||
type="text"
|
||||
value={bien.cantidad_salida}
|
||||
onChange={(e) => {
|
||||
actualizarCampo(bien.id, "cantidad_salida", e.target.value);
|
||||
setErrores("");
|
||||
}
|
||||
}
|
||||
className="text-base text-color surface-overlay p-2 border-1 border-solid surface-border border-round appearance-none outline-none focus:border-primary w-full"
|
||||
/>
|
||||
{errores[`registros.${index}.cantidad`] && (
|
||||
<small className="p-error">{errores[`registros.${index}.cantidad`][0]}</small>
|
||||
)}
|
||||
</td>
|
||||
<td>{bien.nombre_medida}</td>
|
||||
|
||||
<td>
|
||||
<Dropdown
|
||||
value={bien.medida_salida}
|
||||
options={selectedMedida}
|
||||
optionLabel="nombre"
|
||||
optionValue="id"
|
||||
filter
|
||||
placeholder="Seleccionar medida"
|
||||
virtualScrollerOptions={{ itemSize: 38 }}
|
||||
onChange={(e) => {
|
||||
actualizarCampo(bien.id, "medida_salida", e.target.value)
|
||||
|
||||
setErrores("")
|
||||
}
|
||||
}
|
||||
style={{ width: "100%" }}
|
||||
/>
|
||||
{errores[`registros.${index}.id_unidad_medida`] && (
|
||||
<small className="p-error">{errores[`registros.${index}.id_unidad_medida`][0]}</small>
|
||||
)}
|
||||
</td>
|
||||
<td>
|
||||
<InputTextarea
|
||||
rows={5} cols={30}
|
||||
type="text"
|
||||
value={bien.descripcion_pecosa_bien}
|
||||
onChange={(e) => {
|
||||
actualizarCampo(bien.id, "descripcion_pecosa_bien", e.target.value)
|
||||
setErrores("")
|
||||
}
|
||||
}
|
||||
className="text-base text-color surface-overlay p-2 border-1 border-solid surface-border border-round appearance-none outline-none focus:border-primary w-full"
|
||||
/>
|
||||
{errores[`registros.${index}.descripcion`] && (
|
||||
<small className="p-error">{errores[`registros.${index}.descripcion`][0]}</small>
|
||||
)}
|
||||
</td>
|
||||
<td>
|
||||
<InputTextarea
|
||||
rows={5} cols={30}
|
||||
type="text"
|
||||
value={bien.observaciones}
|
||||
onChange={(e) => {
|
||||
actualizarCampo(bien.id, "observaciones", e.target.value)
|
||||
setErrores("")
|
||||
}}
|
||||
className="text-base text-color surface-overlay p-2 border-1 border-solid surface-border border-round appearance-none outline-none focus:border-primary w-full"
|
||||
/>
|
||||
{errores[`registros.${index}.observaciones`] && (
|
||||
<small className="p-error">{errores[`registros.${index}.observaciones`][0]}</small>
|
||||
)}
|
||||
</td>
|
||||
<td>
|
||||
<input
|
||||
type="date"
|
||||
value={bien.fecha_registro}
|
||||
onChange={(e) => {
|
||||
actualizarCampo(bien.id, "fecha_registro", e.target.value)
|
||||
setErrores("")
|
||||
}}
|
||||
className="text-base text-color surface-overlay p-2 border-1 border-solid surface-border border-round appearance-none outline-none focus:border-primary w-full"
|
||||
/>
|
||||
{errores[`registros.${index}.fecha`] && (
|
||||
<small className="p-error">{errores[`registros.${index}.fecha`][0]}</small>
|
||||
)}
|
||||
</td>
|
||||
<td>
|
||||
<Button
|
||||
icon="pi pi-trash"
|
||||
className="p-button-danger p-button-sm"
|
||||
onClick={() => quitarProducto(bien.id)}
|
||||
/>
|
||||
</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
)}
|
||||
|
||||
|
||||
</div>
|
||||
</ArgonBox>
|
||||
|
||||
</Dialog>
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
function cerrarModal() {
|
||||
setBienesSeleccionados([]);
|
||||
onHide();
|
||||
}
|
||||
return (
|
||||
<>
|
||||
<Toast ref={toast} />
|
||||
<Dialog
|
||||
header={rowData?.id ? `CODIGO PECOSA: ${rowData.codigo}` : "Agregar Bienes"}
|
||||
visible={visible}
|
||||
style={{ width: "80vw" }}
|
||||
onHide={onHide}
|
||||
footer={
|
||||
<div>
|
||||
{rowData?.id && bienesSeleccionados.length > 0 ? (
|
||||
<Button
|
||||
label="Agregar Bienes"
|
||||
type="submit"
|
||||
loading={loading}
|
||||
icon="pi pi-check"
|
||||
onClick={submitBienes}
|
||||
autoFocus
|
||||
/>
|
||||
) : null}
|
||||
<Button
|
||||
label="Cancelar"
|
||||
icon="pi pi-times"
|
||||
onClick={cerrarModal}
|
||||
className="p-button-text"
|
||||
/>
|
||||
</div>
|
||||
}
|
||||
>
|
||||
<ArgonBox>
|
||||
{errores.bienes_id && <small className="p-error">{errores.bienes_id[0]}</small>}
|
||||
{/* <Message severity="success" text="Success Message" /> */}
|
||||
<Message severity="warn" text="Si se muestra este color, es que no hay stock" />
|
||||
<div className="formgrid grid">
|
||||
<div className="field col-12 md:col-11">
|
||||
<label>Agregar bienes de Inevtario</label>
|
||||
|
||||
<Dropdown
|
||||
value={bienesSeleccionado}
|
||||
onChange={(e) => {
|
||||
setBienesSeleccionado(e.value);
|
||||
}}
|
||||
filter
|
||||
options={dataEnable}
|
||||
optionLabel={(option) => `${option.descripcion} -- ${option.nombre_medida}`}
|
||||
placeholder="Seleccione"
|
||||
virtualScrollerOptions={{ itemSize: 38 }}
|
||||
className="text-base text-color surface-overlay p-2 border-1 border-solid surface-border-900 border-round appearance-none outline-none focus:border-primary w-full"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="field col-12 md:col-1">
|
||||
<label>-</label>
|
||||
|
||||
<Button onClick={agregarProducto} icon="pi pi-plus" className="w-full" />
|
||||
</div>
|
||||
|
||||
{bienesSeleccionados.length > 0 && (
|
||||
<div className="field col-12 md:col-12">
|
||||
<table border="1" cellPadding="5" className="styled-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Descripción Bien</th>
|
||||
<th style={{ width: "130px" }}>Cantidad Stock</th>
|
||||
<th style={{ width: "130px" }}>Cantidad Salida</th>
|
||||
<th>U. Medida de Nea</th>
|
||||
<th>U. Medida Salida</th>
|
||||
<th style={{ width: "220px" }}>Descripcion Adicional</th>
|
||||
<th style={{ width: "220px" }}>Observacion</th>
|
||||
{/* <th>Fecha</th> */}
|
||||
<th>Acción</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{bienesSeleccionados.map((bien, index) => (
|
||||
<tr
|
||||
key={bien.id}
|
||||
style={{
|
||||
background: Number(bien.cantidad) === 0 ? "#eadfb3" : "transparent",
|
||||
}}
|
||||
>
|
||||
<td>{bien.descripcion}</td>
|
||||
<td>{bien.cantidad}</td>
|
||||
<td>
|
||||
<input
|
||||
type="text"
|
||||
value={bien.cantidad_salida}
|
||||
onChange={(e) => {
|
||||
actualizarCampo(bien.id, "cantidad_salida", e.target.value);
|
||||
setErrores("");
|
||||
}}
|
||||
className="text-base text-color surface-overlay p-2 border-1 border-solid surface-border border-round appearance-none outline-none focus:border-primary w-full"
|
||||
/>
|
||||
{errores[`registros.${index}.cantidad`] && (
|
||||
<small className="p-error">
|
||||
{errores[`registros.${index}.cantidad`][0]}
|
||||
</small>
|
||||
)}
|
||||
</td>
|
||||
<td>{bien.nombre_medida}</td>
|
||||
|
||||
<td>
|
||||
<Dropdown
|
||||
value={bien.medida_salida}
|
||||
options={selectedMedida}
|
||||
optionLabel="nombre"
|
||||
optionValue="id"
|
||||
filter
|
||||
placeholder="Seleccionar medida"
|
||||
virtualScrollerOptions={{ itemSize: 38 }}
|
||||
onChange={(e) => {
|
||||
actualizarCampo(bien.id, "medida_salida", e.target.value);
|
||||
|
||||
setErrores("");
|
||||
}}
|
||||
style={{ width: "100%" }}
|
||||
/>
|
||||
{errores[`registros.${index}.id_unidad_medida`] && (
|
||||
<small className="p-error">
|
||||
{errores[`registros.${index}.id_unidad_medida`][0]}
|
||||
</small>
|
||||
)}
|
||||
</td>
|
||||
<td>
|
||||
<InputTextarea
|
||||
rows={5}
|
||||
cols={30}
|
||||
type="text"
|
||||
value={bien.descripcion_pecosa_bien}
|
||||
onChange={(e) => {
|
||||
actualizarCampo(bien.id, "descripcion_pecosa_bien", e.target.value);
|
||||
setErrores("");
|
||||
}}
|
||||
className="text-base text-color surface-overlay p-2 border-1 border-solid surface-border border-round appearance-none outline-none focus:border-primary w-full"
|
||||
/>
|
||||
{errores[`registros.${index}.descripcion`] && (
|
||||
<small className="p-error">
|
||||
{errores[`registros.${index}.descripcion`][0]}
|
||||
</small>
|
||||
)}
|
||||
</td>
|
||||
<td>
|
||||
<InputTextarea
|
||||
rows={5}
|
||||
cols={30}
|
||||
type="text"
|
||||
value={bien.observaciones}
|
||||
onChange={(e) => {
|
||||
actualizarCampo(bien.id, "observaciones", e.target.value);
|
||||
setErrores("");
|
||||
}}
|
||||
className="text-base text-color surface-overlay p-2 border-1 border-solid surface-border border-round appearance-none outline-none focus:border-primary w-full"
|
||||
/>
|
||||
{errores[`registros.${index}.observaciones`] && (
|
||||
<small className="p-error">
|
||||
{errores[`registros.${index}.observaciones`][0]}
|
||||
</small>
|
||||
)}
|
||||
</td>
|
||||
{/* <td>
|
||||
<input
|
||||
type="date"
|
||||
value={bien.fecha_registro}
|
||||
onChange={(e) => {
|
||||
actualizarCampo(bien.id, "fecha_registro", e.target.value);
|
||||
setErrores("");
|
||||
}}
|
||||
className="text-base text-color surface-overlay p-2 border-1 border-solid surface-border border-round appearance-none outline-none focus:border-primary w-full"
|
||||
/>
|
||||
{errores[`registros.${index}.fecha`] && (
|
||||
<small className="p-error">
|
||||
{errores[`registros.${index}.fecha`][0]}
|
||||
</small>
|
||||
)}
|
||||
</td> */}
|
||||
<td>
|
||||
<Button
|
||||
icon="pi pi-trash"
|
||||
className="p-button-danger p-button-sm"
|
||||
onClick={() => quitarProducto(bien.id)}
|
||||
/>
|
||||
</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</ArgonBox>
|
||||
</Dialog>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
// Define las prop-types
|
||||
CrearInventarioBienes.propTypes = {
|
||||
visible: PropTypes.bool.isRequired, // 'visible' es un booleano y es requerido
|
||||
onHide: PropTypes.func.isRequired, // 'onHide' es una función y es requerida
|
||||
rowData: PropTypes.object, // 'rowData' es un objeto (puede ser opcional)
|
||||
onSaveSuccess: PropTypes.func.isRequired, // 'onHide' es una función y es requerida
|
||||
|
||||
visible: PropTypes.bool.isRequired, // 'visible' es un booleano y es requerido
|
||||
onHide: PropTypes.func.isRequired, // 'onHide' es una función y es requerida
|
||||
rowData: PropTypes.object, // 'rowData' es un objeto (puede ser opcional)
|
||||
onSaveSuccess: PropTypes.func.isRequired, // 'onHide' es una función y es requerida
|
||||
};
|
||||
|
||||
export default CrearInventarioBienes;
|
||||
export default CrearInventarioBienes;
|
||||
|
||||
Loading…
Reference in New Issue