Compare commits

..

2 Commits

  1. 2
      package.json
  2. 192
      src/Components/Catalogos/CatTabulador/CatTabulador.tsx
  3. 2
      src/Interfaces/Catalogos/ITabulador.ts

@ -1,6 +1,6 @@
{ {
"name": "corresponsalfrontend", "name": "corresponsalfrontend",
"version": "2.0.0", "version": "2.0.1",
"private": true, "private": true,
"dependencies": { "dependencies": {
"@reduxjs/toolkit": "^1.9.5", "@reduxjs/toolkit": "^1.9.5",

@ -49,13 +49,15 @@ export default function CatTabuladores (props: IProps) {
const [show, setShowMsg] = useState(false) const [show, setShowMsg] = useState(false)
const [msg, setMsg] = useState('') const [msg, setMsg] = useState('')
const [DialogTabs, setDialogTabs] = useState(false) const [DialogTabs, setDialogTabs] = useState(false)
const [ConceptoDialogTabs, setConceptoDialogTabs] = useState(false)
const [Corresponsal, setCorresponsal] = useState(0) const [Corresponsal, setCorresponsal] = useState(0)
const [Corresponsales, setCorresponsales] = useState<ICatCorresponsales[]>([]) const [Corresponsales, setCorresponsales] = useState<ICatCorresponsales[]>([])
const [Tipo, setTipo] = useState(0)
const [Moneda, setMoneda] = useState(0)
const columnsConcepts = [ const columnsConcepts = [
{ {
name: 'Concepto', name: 'Concepto',
width: '85%', width: '55%',
selector: (row: ITabuladorConceptos) => row.concepto, selector: (row: ITabuladorConceptos) => row.concepto,
sortable: true, sortable: true,
}, },
@ -67,7 +69,7 @@ export default function CatTabuladores (props: IProps) {
id={row.id} id={row.id}
value={row.costo} value={row.costo}
postCost={(id, value) => { postCost={(id, value) => {
postCost(id, value, row.costoCorresponsal) postCost(id, value, row.costoCorresponsal, row.idConcepto)
}} }}
/> />
), ),
@ -80,11 +82,28 @@ export default function CatTabuladores (props: IProps) {
id={row.id} id={row.id}
value={row.costoCorresponsal} value={row.costoCorresponsal}
postCost={(id, value) => { postCost={(id, value) => {
postCost(id, row.costo, value) postCost(id, row.costo, value, row.idConcepto)
}} }}
/> />
), ),
}, },
{
name: 'Elimina',
width: '15%',
cell: (row: ITabuladorConceptos) => (
<div
style={{ textAlign: 'center', cursor: 'pointer' }}
onClick={() => {
setConcepto(row.id)
setConceptoDialogTabs(true)
}}
>
<IconContext.Provider value={{ color: 'red', size: '25px' }}>
<FaTimesCircle />
</IconContext.Provider>
</div>
),
},
] ]
const columnsTabs = [ const columnsTabs = [
@ -100,7 +119,7 @@ export default function CatTabuladores (props: IProps) {
}, },
{ {
name: 'Editar', name: 'Editar',
width: '10%', width: '15%',
cell: (row: ITabulador) => ( cell: (row: ITabulador) => (
<div <div
style={{ textAlign: 'center', cursor: 'pointer' }} style={{ textAlign: 'center', cursor: 'pointer' }}
@ -108,6 +127,8 @@ export default function CatTabuladores (props: IProps) {
setTabulador(row.id) setTabulador(row.id)
setNombreTabulador(row.nombre) setNombreTabulador(row.nombre)
setCorresponsal(row.idCorresponsal!) setCorresponsal(row.idCorresponsal!)
setTipo(row.tipo)
setMoneda(row.moneda)
}} }}
> >
<IconContext.Provider value={{ color: 'blue', size: '25px' }}> <IconContext.Provider value={{ color: 'blue', size: '25px' }}>
@ -118,6 +139,7 @@ export default function CatTabuladores (props: IProps) {
}, },
{ {
name: 'Elimina', name: 'Elimina',
width: '15%',
cell: (row: ITabulador) => ( cell: (row: ITabulador) => (
<div <div
style={{ textAlign: 'center', cursor: 'pointer' }} style={{ textAlign: 'center', cursor: 'pointer' }}
@ -135,11 +157,11 @@ export default function CatTabuladores (props: IProps) {
}, },
] ]
const postCost = (id: number, costoCliente: number, costoCorresponsal: number) => { const postCost = (id: number, costoCliente: number, costoCorresponsal: number, idConcepto: number) => {
const data: ITabuladorConceptos = { const data: ITabuladorConceptos = {
id: id, id: id,
idTabulador: Tabulador, idTabulador: Tabulador,
idConcepto: Concepto, idConcepto: idConcepto,
concepto: '', concepto: '',
costo: costoCliente, costo: costoCliente,
activo: 1, activo: 1,
@ -182,6 +204,19 @@ export default function CatTabuladores (props: IProps) {
}) })
} }
const deleteConcepto = () => {
CTabDetDataService.Delete(Concepto)
.then((resp) => {
if(resp.status === 200){
setHeader('Informativo')
setMsg(resp.data.respuesta)
setShowMsg(true)
setConceptoDialogTabs(false)
setDetalleConceptos(DetalleConceptos.filter(concepto => concepto.id != Concepto))
}
})
}
useEffect(() => { useEffect(() => {
CTabDetDataService.getAllConcepts() CTabDetDataService.getAllConcepts()
.then((response) => { .then((response) => {
@ -265,7 +300,9 @@ export default function CatTabuladores (props: IProps) {
id: Tabulador, id: Tabulador,
idCliente: Cliente, idCliente: Cliente,
nombre: NombreTabulador, nombre: NombreTabulador,
idCorresponsal:Corresponsal idCorresponsal:Corresponsal,
tipo: Tipo,
moneda: Moneda
} }
CTabDataService.Append(data) CTabDataService.Append(data)
.then((response) => { .then((response) => {
@ -303,20 +340,20 @@ export default function CatTabuladores (props: IProps) {
} }
} }
const addConcept = () => { const addConcept = (idConcepto: number) => {
if (Tabulador === 0) { if (Tabulador === 0) {
setHeader('Error') setHeader('Error')
setMsg('Por favor, primero seleccione el tabulador') setMsg('Por favor, primero seleccione el tabulador')
setShowMsg(true) setShowMsg(true)
return return
} }
if (Concepto === 0) { if (idConcepto === 0) {
setHeader('Error') setHeader('Error')
setMsg('Por favor, primero seleccione el concepto') setMsg('Por favor, primero seleccione el concepto')
setShowMsg(true) setShowMsg(true)
return return
} }
postCost(0, 0, 0) postCost(0, 0, 0, idConcepto)
} }
const clearForm = () => { const clearForm = () => {
@ -331,7 +368,6 @@ export default function CatTabuladores (props: IProps) {
<Card> <Card>
<Card.Body> <Card.Body>
<Card style={{ height: '100%' }}> <Card style={{ height: '100%' }}>
<Card.Header as='h4'>Tabuladores Clientes</Card.Header>
<Card.Body> <Card.Body>
<Container fluid> <Container fluid>
<Alert variant='primary'> <Alert variant='primary'>
@ -365,8 +401,9 @@ export default function CatTabuladores (props: IProps) {
</Row> </Row>
</Alert> </Alert>
<Row> <Row>
<Col xs={6}> <Col xs={5}>
<Card style={{}}> <Card style={{}}>
<Card.Header><h5>Tabuladores</h5></Card.Header>
<Card.Body> <Card.Body>
<Card.Subtitle className='mb-2 text-muted'> <Card.Subtitle className='mb-2 text-muted'>
<Row> <Row>
@ -379,12 +416,7 @@ export default function CatTabuladores (props: IProps) {
<FaEraser /> <FaEraser />
</IconContext.Provider> </IconContext.Provider>
</Col> </Col>
<Col xs={2} style={{ paddingTop: '5px' }}> <Col xs={10}>
<div>
<h5>Tabulador</h5>
</div>
</Col>
<Col xs={8}>
<h4> <h4>
<Form.Control <Form.Control
type='text' type='text'
@ -399,7 +431,7 @@ export default function CatTabuladores (props: IProps) {
/> />
</h4> </h4>
</Col> </Col>
<Col style={{ paddingTop: '5px' }}> <Col xs={1} style={{ paddingTop: '5px' }}>
<IconContext.Provider value={{ color: 'green', size: '30px' }}> <IconContext.Provider value={{ color: 'green', size: '30px' }}>
<FaSave onClick={() => saveForm()} style={{ cursor: 'pointer' }}/> <FaSave onClick={() => saveForm()} style={{ cursor: 'pointer' }}/>
</IconContext.Provider> </IconContext.Provider>
@ -418,13 +450,14 @@ export default function CatTabuladores (props: IProps) {
</Card.Body> </Card.Body>
</Card> </Card>
</Col> </Col>
<Col xs={6}> <Col xs={7}>
<Card style={{}}> <Card style={{}}>
<Card.Header><h5>Datos del Tabulador: {NombreTabulador}</h5></Card.Header>
<Card.Body> <Card.Body>
<Card.Subtitle className='mb-2 text-muted'> <Card.Subtitle className='mb-2 text-muted'>
<Row> <Row>
<Col xs={3} style={{ paddingTop: '5px' }}>Corresponsal:</Col> <Col xs={3} style={{ paddingTop: '5px' }}>Corresponsal</Col>
<Col xs={9}> <Col xs={8}>
<Form.Control <Form.Control
disabled={Tabulador===0} disabled={Tabulador===0}
as='select' as='select'
@ -447,17 +480,86 @@ export default function CatTabuladores (props: IProps) {
: null} : null}
</Form.Control> </Form.Control>
</Col> </Col>
<Col style={{ paddingTop: '5px' }}>
<IconContext.Provider value={{ color: 'green', size: '30px' }}>
<FaSave onClick={() => saveForm()} style={{ cursor: 'pointer' }}/>
</IconContext.Provider>
</Col>
</Row>
<Row style={{ paddingTop: '5px' }}>
<Col xs={6}>
<Row>
<Col xs={3}>Tipo: </Col>
<Col xs={9}>
<Form>
<Form.Check
type='radio'
id='radio-Impo'
value={1}
label='Impo'
inline
name='grupo'
onChange={e => setTipo(parseInt(e.target.value))}
checked={Tipo === 1}
disabled={Tabulador===0}
/>
<Form.Check
type='radio'
id='radio-Expo'
value={2}
label='Expo'
inline
name='grupo'
onChange={e => setTipo(parseInt(e.target.value))}
checked={Tipo === 2}
disabled={Tabulador===0}
/>
</Form>
</Col>
</Row>
</Col>
<Col xs={6}>
<Row>
<Col xs={4}>Moneda:</Col>
<Col xs={8}>
<Form>
<Form.Check
type='radio'
id='radio-USD'
value={1}
label='USD'
inline
name='grupo'
onChange={e => setMoneda(parseInt(e.target.value))}
checked={Moneda === 1}
disabled={Tabulador===0}
/>
<Form.Check
type='radio'
id='radio-MXN'
value={2}
label='MXN'
inline
name='grupo'
onChange={e => setMoneda(parseInt(e.target.value))}
checked={Moneda === 2}
disabled={Tabulador===0}
/>
</Form>
</Col>
</Row>
</Col>
</Row> </Row>
<hr /> <hr />
<Row> <Row>
<Col xs={2} style={{ paddingTop: '8px' }}> <Col xs={2} style={{ paddingTop: '8px' }}>
Conceptos Conceptos
</Col> </Col>
<Col xs={9}> <Col xs={10}>
<Form.Control <Form.Control
disabled={Tabulador===0} disabled={Tabulador===0}
as='select' as='select'
onChange={(e) => setConcepto(parseInt(e.target.value))} onChange={(e) => addConcept(parseInt(e.target.value))}
className='form-select form-select-sm' className='form-select form-select-sm'
style={{ fontSize: '17px' }} style={{ fontSize: '17px' }}
value={Concepto} value={Concepto}
@ -474,7 +576,7 @@ export default function CatTabuladores (props: IProps) {
: null} : null}
</Form.Control> </Form.Control>
</Col> </Col>
<Col style={{ paddingTop: '5px' }}> {/* <Col style={{ paddingTop: '5px' }}>
<Form.Label <Form.Label
onClick={() => { onClick={() => {
addConcept() addConcept()
@ -485,7 +587,7 @@ export default function CatTabuladores (props: IProps) {
<BsPlusSquareFill /> <BsPlusSquareFill />
</IconContext.Provider> </IconContext.Provider>
</Form.Label> </Form.Label>
</Col> </Col> */}
</Row> </Row>
</Card.Subtitle> </Card.Subtitle>
<DataTable <DataTable
@ -543,6 +645,42 @@ export default function CatTabuladores (props: IProps) {
</Row> </Row>
</Modal.Footer> </Modal.Footer>
</Modal> </Modal>
<Modal
show={ConceptoDialogTabs}
onHide={() => {
setConceptoDialogTabs(false)
}}
size='sm'
>
<Modal.Body>
¿Esta seguro de eliminar este concepto?
</Modal.Body>
<Modal.Footer>
<Row>
<Col xs={6} style={{ textAlign: 'left', paddingRight: '100px' }}>
<Button
variant='danger'
onClick={deleteConcepto}
size='sm'
style={{ paddingRight: '20px', paddingLeft: '20px' }}
>
Si
</Button>
</Col>
<Col xs={6} style={{ textAlign: 'right' }}>
<Button
variant='secondary'
onClick={() => {
setConceptoDialogTabs(false)
}}
size='sm'
>
Cerrar
</Button>
</Col>
</Row>
</Modal.Footer>
</Modal>
<MsgInformativo <MsgInformativo
show={show} show={show}
msg={msg} msg={msg}

@ -3,4 +3,6 @@ export default interface ITabulador {
idCliente: number idCliente: number
nombre: string nombre: string
idCorresponsal?: number idCorresponsal?: number
tipo: number
moneda: number
} }
Loading…
Cancel
Save