From 24b40d76c55b892ee809db9c00929f63628cff20 Mon Sep 17 00:00:00 2001 From: Al Garcia Date: Tue, 13 Sep 2022 17:56:05 -0500 Subject: [PATCH] Se empieza con nuevo display de master detail definido hoy en la reunion --- src/App.tsx | 4 +- src/Components/Catalogos/CatServicios.tsx | 238 +++++++ src/Components/Operaciones/OpMonitor.tsx | 8 +- src/Components/Operaciones/OpViajes.tsx | 525 ---------------- src/Components/Operaciones/Viaje/Viaje.tsx | 589 ++++++++++-------- .../ViajesServicios/ViajesServicios.tsx | 12 +- src/DTOs/Operaciones/DTOViajesServicios.ts | 6 +- src/Interfaces/Catalogos/ICatServicios.ts | 2 +- src/css/generalStyles.css | 14 + 9 files changed, 593 insertions(+), 805 deletions(-) create mode 100644 src/Components/Catalogos/CatServicios.tsx delete mode 100644 src/Components/Operaciones/OpViajes.tsx create mode 100644 src/css/generalStyles.css diff --git a/src/App.tsx b/src/App.tsx index 1c350f6..20cd483 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -2,7 +2,6 @@ import 'bootstrap/dist/css/bootstrap.min.css' import { BrowserRouter, Route, Routes } from 'react-router-dom' import './App.css' import { Login } from './Components/Login/Login' -import { OpViajes } from './Components/Operaciones/OpViajes' import { Home } from './Components/Home/Home' import { useEffect } from 'react' import { useSelector } from 'react-redux' @@ -16,6 +15,7 @@ import { CatTipoUnidades } from './Components/Catalogos/CatTipoUnidades' import { CatUbicaciones } from './Components/Catalogos/CatUbicaciones' import { CatRutas } from './Components/Catalogos/CatRutas' import { OpMonitor } from './Components/Operaciones/OpMonitor' +import { CatServicios } from './Components/Catalogos/CatServicios' function App() { const UserLogued = useSelector((state: RootState) => state.UserProfile.UserProfile.logueado) @@ -41,9 +41,9 @@ function App() { }> }> }> - } /> } /> } /> + } /> } /> } /> } /> diff --git a/src/Components/Catalogos/CatServicios.tsx b/src/Components/Catalogos/CatServicios.tsx new file mode 100644 index 0000000..57b27ab --- /dev/null +++ b/src/Components/Catalogos/CatServicios.tsx @@ -0,0 +1,238 @@ +import React, { FC, useState } from 'react' +import { Alert, Button, Card, Col, Form, Modal, Row } from 'react-bootstrap' +import DataTable from 'react-data-table-component' +import { IconContext } from 'react-icons' +import { useDispatch, useSelector } from 'react-redux' +import ICatServicios from '../../Interfaces/Catalogos/ICatServicios' +import { RootState } from '../../store/store' +import { BsFillPencilFill, BsFillTrashFill, BsSave } from 'react-icons/bs' +import DSCatServicios from '../../Services/Catalogos/CatServicios.Service' +import { updateCatServicios, deleteCatServicios } from '../../store/features/Catalogos/CatServiciosSlice' + +interface IProps {} + +export const CatServicios: FC = (props) => { + const dispatch = useDispatch() + const mCatServicios = useSelector((state: RootState) => state.CatServicios.CatServicios) + const [showCatClientesDialog, setShowCatClientesDialog] = useState(false) + const [deleteCatClientesDialog, setDeleteCatClientesDialog] = useState(false) + const [IDServicio, setIDServicio] = useState(0) + const [Servicio, setServicio] = useState('') + const [Search, setSearch] = useState('') + const columnsConcepts = [ + { + name: 'id', + width: '80px', + selector: (row: ICatServicios) => row.id, + sortable: true, + }, + { + name: 'Servicio', + width: '450px', + selector: (row: ICatServicios) => row.servicio, + sortable: true, + }, + { + name: 'Editar', + width: '100px', + cell: (row: ICatServicios) => ( +
{ + showInfo(row) + }} + > + + + +
+ ), + sortable: true, + }, + { + name: 'Elimina', + width: '100px', + cell: (row: ICatServicios) => ( +
{ + confirmDelete(row) + }} + > + + + +
+ ), + sortable: true, + }, + ] + + const showInfo = (data: ICatServicios) => { + setIDServicio(data.id) + setServicio(data.servicio) + setShowCatClientesDialog(true) + } + + const confirmDelete = (data: ICatServicios) => { + setIDServicio(data.id) + setServicio(data.servicio) + setDeleteCatClientesDialog(true) + } + + const deleteInfo = () => { + DSCatServicios.Delete(IDServicio) + .then((response) => { + dispatch(deleteCatServicios(IDServicio)) + }) + .catch((e: Error) => {}) + setDeleteCatClientesDialog(false) + } + + const saveInfo = () => { + const data: ICatServicios = { + id: IDServicio, + servicio: Servicio, + activo: 1, + } + DSCatServicios.Append(data) + .then((response) => { + dispatch(updateCatServicios(response.data)) + }) + .catch((e: Error) => {}) + setShowCatClientesDialog(false) + } + + return ( +
+ + + + + + Servicios + + + + { + setSearch(e.target.value) + }} + /> + + + + + + + + + + + + { + setShowCatClientesDialog(false) + }} + > + + Catalogo: Clientes + + + + No cliente + + + + +
+ + Cliente + + { + setServicio(e.target.value) + }} + /> + + +
+ + + +   + + + + + +
+ { + setDeleteCatClientesDialog(false) + }} + > + + Catalogo: Clientes + + +
+ + + + ¿Esta seguro de que desea eliminar el servicio:
+ {Servicio}? +
+ +
+
+ + + +   + + + + + +
+
+ ) +} diff --git a/src/Components/Operaciones/OpMonitor.tsx b/src/Components/Operaciones/OpMonitor.tsx index 1ca8508..99ca95a 100644 --- a/src/Components/Operaciones/OpMonitor.tsx +++ b/src/Components/Operaciones/OpMonitor.tsx @@ -10,6 +10,7 @@ import { ViajesServicios } from './ViajesServicios/ViajesServicios' import { populateOpViajes, updateOpViajes } from '../../store/features/Operaciones/OpViajesSlice' import { Viaje } from './Viaje/Viaje' import '../../css/masterDetail.css' +import '../../css/generalStyles.css' import { populateOpViajesServicios, updateOpViajesServicios, @@ -317,7 +318,7 @@ export const OpMonitor: FC = (props) => { - + ) : ( @@ -337,8 +338,11 @@ export const OpMonitor: FC = (props) => { onHide={() => { setShowTripDialog(false) }} + size={'lg'} > - + + Informacion del viaje + diff --git a/src/Components/Operaciones/OpViajes.tsx b/src/Components/Operaciones/OpViajes.tsx deleted file mode 100644 index 25d997d..0000000 --- a/src/Components/Operaciones/OpViajes.tsx +++ /dev/null @@ -1,525 +0,0 @@ -import React, { FC, useEffect, useState } from 'react' -import { Alert, Button, Card, Col, Form, Modal, Row } from 'react-bootstrap' -import DataTable from 'react-data-table-component' -import { IconContext } from 'react-icons' -import { BsFillPencilFill, BsPatchPlusFill, BsPlusSquareFill } from 'react-icons/bs' -import { useSelector } from 'react-redux' -import { setOriginalNode } from 'typescript' -import DTOOpViajes from '../../DTOs/Operaciones/DTOViajes' -import DSOpViajes from '../../Services/Operaciones/OpViajes.Services' -import { RootState } from '../../store/store' - -interface IProps {} - -export const OpViajes: FC = (props) => { - const Info = JSON.parse(localStorage.getItem('tokenInfo') || '[]') - const UserID = Info.UserId - const CatClientes = useSelector((state: RootState) => state.CatClientes.CatClientes) - const CatProveedores = useSelector((state: RootState) => state.CatProveedores.CatProveedores) - const CatTipoUnidades = useSelector((state: RootState) => state.CatTipoUnidades.CatTipoUnidades) - const CatUbicaciones = useSelector((state: RootState) => state.CatUbicaciones.CatUbicaciones) - const CatServicios = useSelector((state: RootState) => state.CatServicios.CatServicios) - const [OpViajes, setOpViajes] = useState([]) - const [showTripDialog, setShowTripDialog] = useState(false) - const [NoCaja, setNoCaja] = useState('') - const [IDViaje, setIDViaje] = useState(0) - const [IDCliente, setIDCliente] = useState(0) - const [IDProveedor, setIDProveedor] = useState(0) - const [IDServicio, setIDServicio] = useState(0) - const [IDTipoUnidad, setIDTipoUnidad] = useState(0) - const [IDOrigen, setIDOrigen] = useState(0) - const [IDDestino, setIDDestino] = useState(0) - const [RefAA, setRefAA] = useState('') - const [PickUpNumber, setPickUpNumber] = useState('') - const [Hazmat, setHazmat] = useState(0) - const [Search, setSearch] = useState('') - const dataConcepts = [ - { - name: 'id', - width: '70px', - selector: (row: DTOOpViajes) => row.id, - sortable: true, - }, - { - name: 'Cliente', - width: '250px', - selector: (row: DTOOpViajes) => row.sCliente, - sortable: true, - }, - { - name: 'Servicio', - width: '150px', - selector: (row: DTOOpViajes) => row.sServicio, - sortable: true, - }, - { - name: 'Proveedor', - width: '250px', - selector: (row: DTOOpViajes) => row.sProveedor, - sortable: true, - }, - { - name: 'Origen', - width: '150px', - selector: (row: DTOOpViajes) => row.sOrigen, - sortable: true, - }, - { - name: 'Destino', - width: '150px', - selector: (row: DTOOpViajes) => row.sDestino, - sortable: true, - }, - { - name: 'Tipo Unidad', - width: '150px', - selector: (row: DTOOpViajes) => row.sTipoUnidad, - sortable: true, - }, - { - name: 'NoCaja', - width: '150px', - selector: (row: DTOOpViajes) => row.noCaja, - sortable: true, - }, - { - name: 'Hazmat', - width: '90px', - selector: (row: DTOOpViajes) => (row.hazmat === 1 ? 'Si' : 'No'), - sortable: true, - }, - { - name: 'Ref A.A.', - width: '110px', - selector: (row: DTOOpViajes) => row.refAgenciaAduanal, - sortable: true, - }, - { - name: 'PickUp No', - width: '110px', - selector: (row: DTOOpViajes) => row.pickUpNumber, - sortable: true, - }, - { - name: 'Editar', - width: '80px', - cell: (row: DTOOpViajes) => ( -
{ - showInfo(row) - }} - > - - - -
- ), - sortable: true, - }, - ] - - const showInfo = (row: DTOOpViajes) => { - setIDViaje(row.id) - setRefAA(row.refAgenciaAduanal) - setIDCliente(row.cliente) - setIDServicio(row.servicio) - setIDProveedor(row.proveedor) - setIDTipoUnidad(row.tipoUnidad) - setNoCaja(row.noCaja) - setIDOrigen(row.origen) - setIDDestino(row.destino) - setHazmat(row.hazmat) - setPickUpNumber(row.pickUpNumber) - setShowTripDialog(true) - } - - const newTrip = () => { - setIDViaje(0) - setRefAA('') - setIDCliente(0) - setIDServicio(0) - setIDProveedor(0) - setIDTipoUnidad(0) - setNoCaja('') - setIDOrigen(0) - setIDDestino(0) - setHazmat(0) - setPickUpNumber('') - setShowTripDialog(true) - } - - const saveInfo = () => { - const data: DTOOpViajes = { - id: IDViaje, - fAlta: '', - usuario: UserID, - fCruce: '', - refAgenciaAduanal: RefAA, - cliente: IDCliente, - sCliente: '', - proveedor: IDProveedor, - sProveedor: '', - tipoUnidad: IDTipoUnidad, - sTipoUnidad: '', - servicio: IDServicio, - sServicio: '', - origen: IDOrigen, - sOrigen: '', - destino: IDDestino, - sDestino: '', - hazmat: Hazmat, - noCaja: NoCaja, - pickUpNumber: PickUpNumber, - max: true, - } - DSOpViajes.Append(data) - .then((response) => { - loadTrips() - }) - .catch((e: Error) => {}) - } - - useEffect(() => { - loadTrips() - }, []) - - /* useEffect(() => { - console.log(UserID) - }, [UserID]) */ - - const loadTrips = () => { - DSOpViajes.Get() - .then((response) => { - setOpViajes(response.data) - }) - .catch((e: Error) => {}) - } - - return ( -
- - - - - - AOL : Monitor de viajes - - -
{ - newTrip() - }} - title='De un click aqui para crear un nuevo viaje' - > - - - -
- - -
-
-
-
- -   - - - - { - setSearch(e.target.value) - }} - /> - - - - - - - - { - setShowTripDialog(false) - }} - > - - - - - Informacion del viaje - - - - - No viaje - - - - - - Ref AA - - - { - setRefAA(e.target.value) - }} - /> - - - - - Cliente - - - { - setIDCliente(parseInt(e.target.value)) - }} - value={IDCliente} - className='form-select form-select-sm' - > - - {CatClientes - ? CatClientes.map((c) => { - return ( - - ) - }) - : null} - - - - - - Servicio - - - { - setIDServicio(parseInt(e.target.value)) - }} - value={IDServicio} - className='form-select form-select-sm' - > - - {CatServicios - ? CatServicios.map((c) => { - return ( - - ) - }) - : null} - - - - - - Tipo Unidad - - - { - setIDTipoUnidad(parseInt(e.target.value)) - }} - value={IDTipoUnidad} - className='form-select form-select-sm' - > - - {CatTipoUnidades - ? CatTipoUnidades.map((c) => { - return ( - - ) - }) - : null} - - - Caja - - { - setNoCaja(e.target.value) - }} - /> - - - - - Proveedor - - - { - setIDProveedor(parseInt(e.target.value)) - }} - value={IDProveedor} - className='form-select form-select-sm' - > - - {CatProveedores - ? CatProveedores.map((c) => { - return ( - - ) - }) - : null} - - - - - - Origen - - - { - setIDOrigen(parseInt(e.target.value)) - }} - value={IDOrigen} - className='form-select form-select-sm' - > - - {CatUbicaciones - ? CatUbicaciones.map((c) => { - if (c.clasificacion === 1) { - return ( - - ) - } - }) - : null} - - - - - - Destino - - - { - setIDDestino(parseInt(e.target.value)) - }} - value={IDDestino} - className='form-select form-select-sm' - > - - {CatUbicaciones - ? CatUbicaciones.map((c) => { - if (c.clasificacion === 2) { - return ( - - ) - } - }) - : null} - - - - - - HAZMAT - - - { - setHazmat(parseInt(e.target.value)) - }} - value={Hazmat} - className='form-select form-select-sm' - > - - - - - Pickup no - - { - setPickUpNumber(e.target.value) - }} - /> - - - - - - -   - - - - - - -
- ) -} diff --git a/src/Components/Operaciones/Viaje/Viaje.tsx b/src/Components/Operaciones/Viaje/Viaje.tsx index 9d31978..14df006 100644 --- a/src/Components/Operaciones/Viaje/Viaje.tsx +++ b/src/Components/Operaciones/Viaje/Viaje.tsx @@ -1,5 +1,5 @@ import React, { FC, useEffect, useState } from 'react' -import { Alert, Button, Col, Form, Modal, Row } from 'react-bootstrap' +import { Alert, Button, Card, Col, Form, Modal, Row } from 'react-bootstrap' import { useDispatch, useSelector } from 'react-redux' import DTOOpViajes from '../../../DTOs/Operaciones/DTOViajes' import DSOpViajes from '../../../Services/Operaciones/OpViajes.Services' @@ -7,6 +7,7 @@ import { updateOpViajes } from '../../../store/features/Operaciones/OpViajesSlic import { RootState } from '../../../store/store' import { populateOpViajesServicios } from '../../../store/features/Operaciones/OpViajesServiciosSlice' import DTOViajesServicios from '../../../DTOs/Operaciones/DTOViajesServicios' +import { ViajesServicios } from '../ViajesServicios/ViajesServicios' interface IProps { IDViaje: number @@ -37,6 +38,11 @@ export const Viaje: FC = (props) => { const [RefAA, setRefAA] = useState('') const [PickUpNumber, setPickUpNumber] = useState('') const [Hazmat, setHazmat] = useState(0) + const [Pedimento, setPedimento] = useState('') + const [TipoOperacion, setTipoOperacion] = useState(1) + const [Comentarios, setComentarios] = useState('') + const [Aduana, setAduana] = useState(0) + const [DisableAduana, setDisableAduana] = useState(true) useEffect(() => { let selectedRow = mAllTrips.filter((row) => { @@ -59,12 +65,21 @@ export const Viaje: FC = (props) => { // console.log(JSON.stringify(selectedRow) + ' ' + props.IDViaje) }, [props.IDViaje]) + useEffect(() => { + if (IDNuevoServicio === 1 || IDNuevoServicio === 2 || IDNuevoServicio === 22) setDisableAduana(false) + else setDisableAduana(true) + }, [IDNuevoServicio]) + const addService = () => { const data: DTOViajesServicios = { id: 0, + idViaje: props.IDViaje, idServicio: IDNuevoServicio, sServicio: '', - idViaje: props.IDViaje, + aduana: Aduana, + comentarios: Comentarios, + idProveedor: IDProveedor, + sProveedor: '', } DSOpViajes.AppendServices(data) .then((responsed) => { @@ -108,286 +123,318 @@ export const Viaje: FC = (props) => { } return ( -
- - - Informacion del viaje - - - - - No viaje - - - - - - Ref AA - - - { - setRefAA(e.target.value) - }} - /> - - - - - Cliente - - - { - setIDCliente(parseInt(e.target.value)) - }} - value={IDCliente} - className='form-select form-select-sm' - > - - {CatClientes - ? CatClientes.map((c) => { - return ( - - ) - }) - : null} - - - - - - Servicio - - - { - setIDServicio(parseInt(e.target.value)) - }} - value={IDServicio} - className='form-select form-select-sm' - > - - {CatServicios - ? CatServicios.map((c) => { - return ( - - ) - }) - : null} - - - - - - Tipo Unidad - - - { - setIDTipoUnidad(parseInt(e.target.value)) - }} - value={IDTipoUnidad} - className='form-select form-select-sm' - > - - {CatTipoUnidades - ? CatTipoUnidades.map((c) => { - return ( - - ) - }) - : null} - - - Caja - - { - setNoCaja(e.target.value) - }} - /> - - - - - Proveedor - - - { - setIDProveedor(parseInt(e.target.value)) - }} - value={IDProveedor} - className='form-select form-select-sm' - > - - {CatProveedores - ? CatProveedores.map((c) => { - return ( - - ) - }) - : null} - - - - - - Origen - - - { - setIDOrigen(parseInt(e.target.value)) - }} - value={IDOrigen} - className='form-select form-select-sm' - > - - {CatUbicaciones - ? CatUbicaciones.map((c) => { - if (c.clasificacion === 1) { - return ( - - ) - } - }) - : null} - - - - - - Destino - - - { - setIDDestino(parseInt(e.target.value)) - }} - value={IDDestino} - className='form-select form-select-sm' - > - - {CatUbicaciones - ? CatUbicaciones.map((c) => { - if (c.clasificacion === 2) { - return ( - - ) - } - }) - : null} - - - - - - HAZMAT - - - { - setHazmat(parseInt(e.target.value)) - }} - value={Hazmat} - className='form-select form-select-sm' - > - - - - - Pickup no +
+ + + + No viaje + + + + Ref AA + + { + setRefAA(e.target.value) + }} + /> + + + + + + + Cliente + + { + setIDCliente(parseInt(e.target.value)) + }} + value={IDCliente} + className='form-select form-select-sm dialogLabel' + > + + {CatClientes + ? CatClientes.map((c) => { + return ( + + ) + }) + : null} + + + + + Tipo Unidad + + { + setIDTipoUnidad(parseInt(e.target.value)) + }} + value={IDTipoUnidad} + className='form-select form-select-sm dialogLabel' + > + + {CatTipoUnidades + ? CatTipoUnidades.map((c) => { + return ( + + ) + }) + : null} + + + Caja + + { + setNoCaja(e.target.value) + }} + /> + + + + Origen + + { + setIDOrigen(parseInt(e.target.value)) + }} + value={IDOrigen} + className='form-select form-select-sm dialogLabel' + > + + {CatUbicaciones + ? CatUbicaciones.map((c) => { + if (c.clasificacion === 1) { + return ( + + ) + } + }) + : null} + + + Destino + + { + setIDDestino(parseInt(e.target.value)) + }} + value={IDDestino} + className='form-select form-select-sm dialogLabel' + > + + {CatUbicaciones + ? CatUbicaciones.map((c) => { + if (c.clasificacion === 2) { + return ( + + ) + } + }) + : null} + + + + + HAZMAT + + { + setHazmat(parseInt(e.target.value)) + }} + value={Hazmat} + className='form-select form-select-sm dialogLabel' + > + + + + + T. operacion + + { + setTipoOperacion(parseInt(e.target.value)) + }} + value={TipoOperacion} + className='form-select form-select-sm dialogLabel' + > + + + + + + +   + {/* Pickup no { setPickUpNumber(e.target.value) }} /> - - - - - - - - - { - setIDNuevoServicio(parseInt(e.target.value)) - }} - value={IDNuevoServicio} - className='form-select form-select-sm' - > - - {CatServicios - ? CatServicios.map((c) => { - return ( - - ) - }) - : null} - - + */} + + + Pedimento + + { + setPedimento(e.target.value) + }} + /> + + + + + + + - - - -   - - - - - + + + + Servicio + + { + setIDNuevoServicio(parseInt(e.target.value)) + }} + value={IDNuevoServicio} + className='form-select form-select-sm dialogLabel' + > + + {CatServicios + ? CatServicios.map((c) => { + return ( + + ) + }) + : null} + + + + { + setAduana(parseInt(e.target.value)) + }} + value={Aduana} + disabled={DisableAduana} + className='form-select form-select-sm dialogLabel' + > + + + + + + + + Comentarios + + { + setComentarios(e.target.value) + }} + /> + + + + Proveedor + + { + setIDProveedor(parseInt(e.target.value)) + }} + value={IDProveedor} + className='form-select form-select-sm dialogLabel' + > + + {CatProveedores + ? CatProveedores.map((c) => { + return ( + + ) + }) + : null} + + + + + + + + + + + + +
+ +
+
+
+
+ {/* + */}
) } diff --git a/src/Components/Operaciones/ViajesServicios/ViajesServicios.tsx b/src/Components/Operaciones/ViajesServicios/ViajesServicios.tsx index 33249dd..a26f9b2 100644 --- a/src/Components/Operaciones/ViajesServicios/ViajesServicios.tsx +++ b/src/Components/Operaciones/ViajesServicios/ViajesServicios.tsx @@ -10,7 +10,7 @@ import DSOpViajes from '../../../Services/Operaciones/OpViajes.Services' import { deleteOpViajesServicios } from '../../../store/features/Operaciones/OpViajesServiciosSlice' interface IProps { - DataMaster: DTOOpViajes + IDMaster: number } export const ViajesServicios: FC = (props) => { @@ -32,14 +32,17 @@ export const ViajesServicios: FC = (props) => { id - Servicio + Servicio + Aduana + Proveedor + Comentarios {AllTripsServices ? AllTripsServices.filter(function (service) { - return service.idViaje === props.DataMaster.id + return service.idViaje === props.IDMaster }).map(function (service) { return ( = (props) => { > {service.id} {service.sServicio} + {service.aduana} + {service.sProveedor} + {service.comentarios}