Commit 52744883 by tdgiang

update code

parent f006fbb8
import React, { useState, useEffect,use } from "react";
import {
Button,
FormControl,
Grid,
InputLabel,
Select,
TextField,
Typography,
DialogActions,Dialog,DialogContent,DialogContentText,DialogTitle,IconButton,Icon,Tooltip
} from '@material-ui/core'
import { toast } from 'react-toastify'
import { useTranslation } from 'react-i18next'
import { hideLoading, showLoading } from 'app/redux/actions/loadingAction'
import { connect } from 'react-redux'
function FormDialog(props) {
const { t } = useTranslation()
const {open,handleClose,data,onAgree}=props
const [amount,setamount]=useState()
return (
<Dialog
open={open}
onClose={handleClose}
aria-labelledby="form-dialog-title"
>
<DialogTitle id="form-dialog-title">Cập nhật CTV</DialogTitle>
<DialogContent>
<TextField
style={{marginBttom:20,minWidth:400}}
variant="outlined"
autoFocus
margin="dense"
label="Lời nhuận chia sẻ %"
fullWidth
value={amount || ''}
onChange={(event)=>setamount(event.target.value)}
/>
</DialogContent>
<DialogActions>
<Button
color="secondary"
onClick={handleClose}
>
Thoát
</Button>
<Button onClick={onAgree} color="primary">
Đồng ý
</Button>
</DialogActions>
</Dialog>
)
}
const mapStateToProps = (state) => {
return {}
}
export default connect(mapStateToProps, { showLoading, hideLoading })(
FormDialog
)
...@@ -4,7 +4,15 @@ import { ...@@ -4,7 +4,15 @@ import {
TextValidator, TextValidator,
SelectValidator, SelectValidator,
} from 'react-material-ui-form-validator' } from 'react-material-ui-form-validator'
import { Button, Grid, MenuItem, Typography } from '@material-ui/core' import {
Button,
Grid,
MenuItem,
Typography,
IconButton,
Icon,
Tooltip,
} from '@material-ui/core'
import { createFunction } from 'app/apis/Functions/function' import { createFunction } from 'app/apis/Functions/function'
import { showLoading, hideLoading } from 'app/redux/actions/loadingAction' import { showLoading, hideLoading } from 'app/redux/actions/loadingAction'
...@@ -14,11 +22,52 @@ import { Link, useHistory, useLocation } from 'react-router-dom' ...@@ -14,11 +22,52 @@ import { Link, useHistory, useLocation } from 'react-router-dom'
import { trimObject } from 'app/config/Function' import { trimObject } from 'app/config/Function'
import { connect } from 'react-redux' import { connect } from 'react-redux'
import { dropdownMerchant } from 'app/apis/Functions/dropdown' import { dropdownMerchant } from 'app/apis/Functions/dropdown'
import Table from '@material-ui/core/Table'
import TableBody from '@material-ui/core/TableBody'
import TableCell from '@material-ui/core/TableCell'
import TableContainer from '@material-ui/core/TableContainer'
import TableHead from '@material-ui/core/TableHead'
import TableRow from '@material-ui/core/TableRow'
import Paper from '@material-ui/core/Paper'
import CreateField from 'app/components/dialog/CreateField'
const SimpleForm = (props) => { const SimpleForm = (props) => {
const [state, setState] = useState({}) const [state, setState] = useState({})
const history = useHistory() const history = useHistory()
const [listDrop, setListDrop] = useState([]) const [listDrop, setListDrop] = useState([])
const [listField, setListField] = useState([
{
field_name: 'Trụ 1',
gas_olines: [
{
product_id: 'BDDD46BC-2264-43EF-21B7-08DC08411423',
name: 'Vòi 1',
code: 'A95',
},
{
product_id: '6D3A81A6-A189-4D83-BA47-08DC0CF4D4C3',
name: 'Vòi 2',
code: 'A99',
},
],
},
{
field_name: 'Trụ 2',
gas_olines: [
{
product_id: 'BDDD46BC-2264-43EF-21B7-08DC08411423',
name: 'Vòi 1',
code: 'A95',
},
{
product_id: '6D3A81A6-A189-4D83-BA47-08DC0CF4D4C3',
name: 'Vòi 2',
code: 'A99',
},
],
},
])
const [openCreate, setOpenCreate] = useState(false)
useEffect(() => { useEffect(() => {
getData() getData()
...@@ -79,6 +128,11 @@ const SimpleForm = (props) => { ...@@ -79,6 +128,11 @@ const SimpleForm = (props) => {
setState({ ...state, date }) setState({ ...state, date })
} }
const onCreateField = () => {}
const handleCloseCreate = () => {
setOpenCreate(false)
}
const { store_name, address, merchan_id } = state const { store_name, address, merchan_id } = state
return ( return (
...@@ -193,21 +247,33 @@ const SimpleForm = (props) => { ...@@ -193,21 +247,33 @@ const SimpleForm = (props) => {
justify="space-between" justify="space-between"
> >
<div> <div>
<Typography> <Typography variant="subtitle1">
S lượng vòi mi tr:1 S lượng vòi mi tr:1
</Typography> </Typography>
<Typography>S lượng tr:3</Typography> <Typography variant="subtitle1">
</div> S lượng tr:3
<Typography variant="h6">
Thêm tr
</Typography> </Typography>
</div>
<Button
style={{
width: 120,
}}
variant="contained"
className={'bg-light-primary'}
>
<span className={'text-primary'}>
Thêm mi
</span>
</Button>
</Grid> </Grid>
{listField.map((item) => (
<Grid <Grid
style={{ style={{
border: '1px solid #B9B9B9', border: '1px solid #B9B9B9',
borderRadius: 5, borderRadius: 5,
padding: 10, padding: 10,
marginTop: 10, marginTop: 20,
}} }}
lg={12} lg={12}
md={12} md={12}
...@@ -218,19 +284,216 @@ const SimpleForm = (props) => { ...@@ -218,19 +284,216 @@ const SimpleForm = (props) => {
<div <div
style={{ style={{
alignItems: 'center', alignItems: 'center',
justifyContent: 'space-between', justifyContent:
'space-between',
display: 'flex', display: 'flex',
marginBottom: 10,
}} }}
> >
<Typography variant="h6"> <Typography variant="h6">
TR 1 {item.field_name}
</Typography>
<Typography variant="h6">
Xoá tr
</Typography> </Typography>
<Button
variant="contained"
style={{
backgroundColor:
'#FC2B05',
color: 'white',
}}
>
<span>Xoá tr</span>
</Button>
</div> </div>
<TableContainer component={Paper}>
<Table aria-label="simple table">
<TableHead>
<TableRow
style={{
backgroundColor:
'#F3F3F3',
}}
>
<TableCell
style={{
borderRight:
'0.05px solid #e0e0e0',
width: 100,
}}
align="center"
>
STT
</TableCell>
<TableCell
style={{
borderRight:
'0.05px solid #e0e0e0',
}}
align="center"
>
Vòi
</TableCell>
<TableCell
style={{
borderRight:
'0.05px solid #e0e0e0',
}}
align="center"
>
Mã vòi
</TableCell>
<TableCell
style={{
borderRight:
'0.05px solid #e0e0e0',
}}
align="center"
>
Loi nhiên liu
</TableCell>
<TableCell
style={{
borderRight:
'0.05px solid #e0e0e0',
}}
align="center"
>
Sn phm
</TableCell>
<TableCell align="center">
Trng thái hot
động
</TableCell>
<TableCell
style={{
textAlign:
'center',
width: 120,
}}
align="center"
>
Hành động
</TableCell>
</TableRow>
</TableHead>
<TableBody>
{item?.gas_olines.map(
(row, index) => (
<TableRow
key={
row.name
}
>
<TableCell
component="th"
scope="row"
style={{
borderRight:
'0.05px solid #e0e0e0',
}}
align="center"
>
{index +
1}
</TableCell>
<TableCell
style={{
borderRight:
'0.05px solid #e0e0e0',
}}
align="right"
>
{
row?.name
}
</TableCell>
<TableCell
style={{
borderRight:
'0.05px solid #e0e0e0',
}}
align="right"
>
{
row?.code
}
</TableCell>
<TableCell
style={{
borderRight:
'0.05px solid #e0e0e0',
}}
align="right"
>
{
row?.type_name
}
</TableCell>
<TableCell
style={{
borderRight:
'0.05px solid #e0e0e0',
}}
align="right"
>
{
row?.product_name
}
</TableCell>
<TableCell
style={{
borderRight:
'0.05px solid #e0e0e0',
}}
align="right"
>
{
row?.status
}
</TableCell>
<TableCell>
<Tooltip title="Xoá">
<IconButton
onClick={() => {}}
//className={classes.button}
aria-label="Delete"
>
<Icon color="primary">
edit
</Icon>
</IconButton>
</Tooltip>
<Tooltip title="Xoá">
<IconButton
onClick={() => {}}
//className={classes.button}
aria-label="Delete"
>
<Icon color="error">
delete
</Icon>
</IconButton>
</Tooltip>
</TableCell>
</TableRow>
)
)}
</TableBody>
</Table>
</TableContainer>
<IconButton
onClick={() => {}}
aria-label="edit"
>
<Icon color="primary">
add_circle
</Icon>
</IconButton>
</Grid> </Grid>
</Grid> </Grid>
))}
</Grid> </Grid>
</Grid> </Grid>
<Grid <Grid
...@@ -260,6 +523,11 @@ const SimpleForm = (props) => { ...@@ -260,6 +523,11 @@ const SimpleForm = (props) => {
<span className="capitalize">Thêm mi</span> <span className="capitalize">Thêm mi</span>
</Button> </Button>
</Grid> </Grid>
<CreateField
open={openCreate}
handleClose={handleCloseCreate}
onAgree={onCreateField}
/>
</ValidatorForm> </ValidatorForm>
</SimpleCard> </SimpleCard>
</div> </div>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment