Commit 9b214793 by tdgiang

update code

parent 4e54ba3a
...@@ -94,3 +94,8 @@ export const dropdownStoreStatus = async (body) => ...@@ -94,3 +94,8 @@ export const dropdownStoreStatus = async (body) =>
GetData(url.dropdownStoreStatus, body) GetData(url.dropdownStoreStatus, body)
.then((res) => res) .then((res) => res)
.catch((err) => null) .catch((err) => null)
export const dropdownProvider = async (body) =>
GetData(url.dropdownProvider, body)
.then((res) => res)
.catch((err) => null)
...@@ -119,7 +119,7 @@ export default { ...@@ -119,7 +119,7 @@ export default {
changeStatusSupplier: `${root}/provider/changeStatus`, changeStatusSupplier: `${root}/provider/changeStatus`,
//reconciliation //reconciliation
listTransReconciliation: `${root}/reconciliation/list/trans`, listTransReconciliation: `${root}/paymentpartner/list/trans`,
//Log //Log
logAuth: `${root}/logging/listLogin`, logAuth: `${root}/logging/listLogin`,
...@@ -178,4 +178,5 @@ export default { ...@@ -178,4 +178,5 @@ export default {
dropdownNcc: `${root}/dropdown/getlistsuppliercontruct`, dropdownNcc: `${root}/dropdown/getlistsuppliercontruct`,
dropdownFuncitonPackge: `${root}/dropdown/getlistfunctionpk`, dropdownFuncitonPackge: `${root}/dropdown/getlistfunctionpk`,
dropdownStoreStatus: `${root}/dropdown/getlistStoreStatus`, dropdownStoreStatus: `${root}/dropdown/getlistStoreStatus`,
dropdownProvider: `${root}/dropdown/Provider`,
} }
...@@ -8,7 +8,7 @@ import { showLoading, hideLoading } from 'app/redux/actions/loadingAction' ...@@ -8,7 +8,7 @@ import { showLoading, hideLoading } from 'app/redux/actions/loadingAction'
import { toast } from 'react-toastify' import { toast } from 'react-toastify'
import useDebounce from 'app/hooks/useDebounce' import useDebounce from 'app/hooks/useDebounce'
import { useTranslation } from 'react-i18next' import { useTranslation } from 'react-i18next'
import { dropdownMerchant, dropdownStore } from 'app/apis/Functions/dropdown' import { dropdownProduct, dropdownProvider } from 'app/apis/Functions/dropdown'
const ToolNotificate = (props) => { const ToolNotificate = (props) => {
const [txtSearch, setTxtSearch] = useState('') const [txtSearch, setTxtSearch] = useState('')
...@@ -24,13 +24,21 @@ const ToolNotificate = (props) => { ...@@ -24,13 +24,21 @@ const ToolNotificate = (props) => {
const [data, setData] = useState([]) const [data, setData] = useState([])
const [type, setType] = useState() const [type, setType] = useState()
const [listType, setListType] = useState([]) const [listType, setListType] = useState([])
const [merchant, setMerchant] = useState() const [listProvide, setListProvide] = useState([])
const [listMerchant, setListMerchant] = useState([]) const [provide, setProvide] = useState()
const [store, setStore] = useState() const [listProduct, setListProduct] = useState([])
const [listStore, setListStore] = useState([]) const [product, setProduct] = useState()
const [status, setStatus] = useState()
useEffect(() => {
getData(false)
}, [pageIndex])
useEffect(() => { useEffect(() => {
getDataMerchant() getData(true)
}, [searchDebount, startDate, type, provide, product, status])
useEffect(() => {
getDataDropdown()
}, []) }, [])
const changeDateRange = (start, end) => { const changeDateRange = (start, end) => {
...@@ -38,6 +46,12 @@ const ToolNotificate = (props) => { ...@@ -38,6 +46,12 @@ const ToolNotificate = (props) => {
setEndDate(end) setEndDate(end)
} }
const renderStatusName = (status) => {
if (status == 3) return 'Đã đối soát'
if (status == 2) return 'Đang đối soát'
return 'Chưa đối soát'
}
const getData = async (init) => { const getData = async (init) => {
props.showLoading() props.showLoading()
let res let res
...@@ -48,10 +62,10 @@ const ToolNotificate = (props) => { ...@@ -48,10 +62,10 @@ const ToolNotificate = (props) => {
page_size: pageSize, page_size: pageSize,
date_from: startDate ? convertDate(startDate) : null, date_from: startDate ? convertDate(startDate) : null,
date_to: endDate ? convertDate(endDate) : null, date_to: endDate ? convertDate(endDate) : null,
product_code: null, product_code: product ? product : null,
payment_gate_code: null, payment_gate_code: provide ? provide : null,
statusReconciliation: 0, statusReconciliation: status ? status : 0,
type_payment: null, type_payment: type ? type : null,
}) })
} else { } else {
res = await listTransReconciliation({ res = await listTransReconciliation({
...@@ -59,18 +73,25 @@ const ToolNotificate = (props) => { ...@@ -59,18 +73,25 @@ const ToolNotificate = (props) => {
page_size: pageSize, page_size: pageSize,
date_from: startDate ? convertDate(startDate) : null, date_from: startDate ? convertDate(startDate) : null,
date_to: endDate ? convertDate(endDate) : null, date_to: endDate ? convertDate(endDate) : null,
product_code: null, product_code: product ? product : null,
payment_gate_code: null, payment_gate_code: provide ? provide : null,
statusReconciliation: 0, statusReconciliation: status ? status : 0,
type_payment: null, type_payment: type ? type : null,
}) })
} }
props.hideLoading() props.hideLoading()
if (res.data.code == 200 && res.data.data) { if (res.data.code == 200 && res.data.data) {
console.log(' res.data.data', res.data.data)
const newList = res.data.data?.data?.map((e, i) => { const newList = res.data.data?.data?.map((e, i) => {
return { ...e, index: i + 1 + pageIndex * pageSize } return {
...e,
statusReconciliationName: renderStatusName(
e?.statusReconciliation
),
index: i + 1 + pageIndex * pageSize,
}
}) })
setData(newList) setData(newList)
setTotalRecord(res.data.data.total_elements) setTotalRecord(res.data.data.total_elements)
...@@ -85,49 +106,21 @@ const ToolNotificate = (props) => { ...@@ -85,49 +106,21 @@ const ToolNotificate = (props) => {
} }
} }
useEffect(() => { const getDataDropdown = async () => {
getData(false) const res = await dropdownProvider({})
}, [pageIndex])
useEffect(() => {
getData(true)
}, [searchDebount, startDate, type, merchant, store])
useEffect(() => {
if (merchant) {
getDropdownStore(merchant)
}
setStore()
}, [merchant])
const getDataMerchant = async () => {
const res = await dropdownMerchant({})
if (res.data.code == 200 && res.data.data) { if (res.data.code == 200 && res.data.data) {
const newList = res.data.data.map((e) => { const newList = res.data.data.map((e) => {
return { ...e, name: e.merchant_name } return { ...e, id: e.code }
})
setListMerchant(newList)
} else {
toast.error(t(res.data.error), {
theme: 'colored',
}) })
setListProvide(newList)
} }
}
const getDropdownStore = async (id) => {
const res = await dropdownStore(id)
if (res.data.code == 200 && res.data.data) { const resPro = await dropdownProduct({})
console.log('res.data.data', res.data.data) if (resPro.data.code == 200 && resPro.data.data) {
const newList = res.data.data.map((e) => { const newList = resPro.data.data.map((e) => {
return { ...e, name: e.store_name } return { ...e, id: e.product_code, name: e?.product_name }
})
setListStore(newList)
} else {
toast.error(t(res.data.error), {
theme: 'colored',
}) })
setListProduct(newList)
} }
} }
...@@ -145,12 +138,14 @@ const ToolNotificate = (props) => { ...@@ -145,12 +138,14 @@ const ToolNotificate = (props) => {
type={type} type={type}
setType={setType} setType={setType}
listType={listType} listType={listType}
merchant={merchant} listProvide={listProvide}
setMerchant={setMerchant} listProduct={listProduct}
listMerchant={listMerchant} provide={provide}
store={store} setProvide={setProvide}
setStore={setStore} product={product}
listStore={listStore} setProduct={setProduct}
status={status}
setStatus={setStatus}
/> />
) )
} }
......
...@@ -12,13 +12,14 @@ import { ...@@ -12,13 +12,14 @@ import {
MenuItem, MenuItem,
Tooltip, Tooltip,
Icon, Icon,
Typography,
} from '@material-ui/core' } from '@material-ui/core'
import EditIcon from '@material-ui/icons/Edit' import EditIcon from '@material-ui/icons/Edit'
import DeleteIcon from '@material-ui/icons/Delete' import DeleteIcon from '@material-ui/icons/Delete'
import colors from 'app/assets/Color' import colors from 'app/assets/Color'
import useStyles from 'app/styles/Table' import useStyles from 'app/styles/Table'
import { Breadcrumb, SimpleCard } from 'app/components' import { Breadcrumb, SimpleCard } from 'app/components'
import { toPriceVnd } from 'app/config/Function'
const columns = [ const columns = [
{ {
id: 'index', id: 'index',
...@@ -26,38 +27,25 @@ const columns = [ ...@@ -26,38 +27,25 @@ const columns = [
align: 'center', align: 'center',
minWidth: 80, minWidth: 80,
}, },
{ {
id: 'store_name', id: 'created_date',
label: 'Cây xăng', label: 'Thời gian giao dịch',
align: 'left', align: 'left',
minWidth: 160, minWidth: 110,
}, },
// {
// id: 'application',
// label: 'Mã NV',
// align: 'left',
// minWidth: 140,
// },
{ {
id: 'order_code', id: 'order_code',
label: 'Mã hoá đơn', label: 'Mã hoá đơn',
align: 'left', align: 'left',
minWidth: 160, minWidth: 160,
}, },
{ {
id: 'created_date', id: 'store_name',
label: 'Ngày giao dịch', label: 'Cây xăng',
align: 'left', align: 'left',
minWidth: 110, minWidth: 160,
}, },
// {
// id: 'IP',
// label: 'Loại nhiên liệu',
// align: 'left',
// minWidth: 140,
// },
{ {
id: 'product_name', id: 'product_name',
label: 'Sản phẩm', label: 'Sản phẩm',
...@@ -69,19 +57,31 @@ const columns = [ ...@@ -69,19 +57,31 @@ const columns = [
label: 'Đơn giá', label: 'Đơn giá',
align: 'left', align: 'left',
minWidth: 80, minWidth: 80,
isMonney: true,
}, },
{ {
id: 'quantity', id: 'quantity',
label: 'Lượng nhiên liệu', label: 'Lượng nhiên liệu',
align: 'left', align: 'left',
minWidth: 80, minWidth: 80,
isMonney: true,
}, },
{ {
id: 'price', id: 'price',
label: 'Thành tiền', label: 'Thành tiền',
align: 'left', align: 'left',
minWidth: 80, minWidth: 80,
isMonney: true,
}, },
{
id: 'commission',
label: 'Hoa hồng',
align: 'left',
minWidth: 80,
isMonney: true,
},
{ {
id: 'type_payment', id: 'type_payment',
label: 'Phương thức thanh toán', label: 'Phương thức thanh toán',
...@@ -89,10 +89,10 @@ const columns = [ ...@@ -89,10 +89,10 @@ const columns = [
minWidth: 100, minWidth: 100,
}, },
{ {
id: 'status_text', id: 'payment_gate_code',
label: 'Trạng thái', label: 'Đối tác',
align: 'left', align: 'left',
minWidth: 100, minWidth: 80,
}, },
] ]
...@@ -117,6 +117,18 @@ function TableList(props) { ...@@ -117,6 +117,18 @@ function TableList(props) {
setPageSize(event.target.value) setPageSize(event.target.value)
} }
const renderStatusBg = (status) => {
if (status == 3) return '#ECFDF3'
if (status == 2) return '#FFDC98'
return '#F2F4F7'
}
const renderStatusColor = (status) => {
if (status == 3) return '#027A48'
if (status == 2) return '#F1AA1F'
return '#344054'
}
return ( return (
<Paper className={classes.root}> <Paper className={classes.root}>
<TableContainer className={classes.container}> <TableContainer className={classes.container}>
...@@ -135,6 +147,14 @@ function TableList(props) { ...@@ -135,6 +147,14 @@ function TableList(props) {
{column.label} {column.label}
</TableCell> </TableCell>
))} ))}
<TableCell
style={{
width: 110,
backgroundColor: colors.headerTable,
}}
>
Trng thái đối soát
</TableCell>
</TableRow> </TableRow>
</TableHead> </TableHead>
<TableBody className={classes.columnTable}> <TableBody className={classes.columnTable}>
...@@ -147,28 +167,47 @@ function TableList(props) { ...@@ -147,28 +167,47 @@ function TableList(props) {
key={row.id} key={row.id}
> >
{columns.map((column) => { {columns.map((column) => {
const avatar = row[column.id] const data = row[column.id]
return ( return (
<TableCell <TableCell
key={column.id} key={column.id}
align={column.align} align={column.align}
style={{
textAlign:
column.id === 'index'
? 'center'
: typeof data ==
'string'
? 'left'
: 'right',
}}
> >
{column.format ? ( {column.isMonney
<img ? toPriceVnd(data)
src={column.format( : data}
avatar
)}
className={
classes.image
}
/>
) : (
avatar
)}
</TableCell> </TableCell>
) )
})} })}
<TableCell
style={{
textAlign: 'center',
}}
>
<Typography
style={{
padding: 5,
backgroundColor: renderStatusBg(
row?.statusReconciliation
),
color: renderStatusColor(
row?.statusReconciliation
),
borderRadius: 10,
}}
>
{row?.statusReconciliationName}
</Typography>
</TableCell>
</TableRow> </TableRow>
) )
})} })}
......
...@@ -42,6 +42,14 @@ function CustomerView(props) { ...@@ -42,6 +42,14 @@ function CustomerView(props) {
store, store,
setStore, setStore,
listStore, listStore,
listProvide,
listProduct,
provide,
setProvide,
product,
setProduct,
status,
setStatus,
} = props } = props
const handleChange = (event) => { const handleChange = (event) => {
...@@ -64,14 +72,14 @@ function CustomerView(props) { ...@@ -64,14 +72,14 @@ function CustomerView(props) {
<Grid <Grid
style={{ style={{
padding: 10, padding: 10,
marginBottom: 20, marginBottom: 10,
}} }}
//justify={'space-between'} //justify={'space-between'}
alignItems={'center'} alignItems={'center'}
container container
spacing={3} spacing={3}
> >
<Grid item lg={3} md={3} sm={3} xs={3}> <Grid item lg={2} md={2} sm={3} xs={3}>
<TextField <TextField
variant="outlined" variant="outlined"
className="w-full" className="w-full"
...@@ -82,16 +90,15 @@ function CustomerView(props) { ...@@ -82,16 +90,15 @@ function CustomerView(props) {
}} }}
/> />
</Grid> </Grid>
<Grid item lg={2} md={2} sm={3} xs={3}>
<Grid item lg={3} md={3} sm={3} xs={3}>
<FormControl variant="outlined" fullWidth> <FormControl variant="outlined" fullWidth>
<InputLabel htmlFor="outlined-age-native-simple"> <InputLabel htmlFor="outlined-age-native-simple">
Phương thc thanh toán Đối tác
</InputLabel> </InputLabel>
<Select <Select
label="Phương thức thanh toán" label="Đối tác"
value={type} value={provide}
onChange={(e) => setType(e.target.value)} onChange={(e) => setProvide(e.target.value)}
inputProps={{ inputProps={{
name: 'age', name: 'age',
id: 'outlined-age-native-simple', id: 'outlined-age-native-simple',
...@@ -100,34 +107,21 @@ function CustomerView(props) { ...@@ -100,34 +107,21 @@ function CustomerView(props) {
<MenuItem value=""> <MenuItem value="">
<em>Tt c</em> <em>Tt c</em>
</MenuItem> </MenuItem>
{[ {listProvide.map((e) => (
{
id: 'QR',
name: 'QR',
},
{
id: 'CASH',
name: 'Tiền mặt',
},
{
id: 'DEBT',
name: 'Công nợ',
},
].map((e) => (
<MenuItem value={e.id}>{e.name}</MenuItem> <MenuItem value={e.id}>{e.name}</MenuItem>
))} ))}
</Select> </Select>
</FormControl> </FormControl>
</Grid> </Grid>
<Grid item lg={3} md={3} sm={3} xs={3}> <Grid item lg={2} md={2} sm={3} xs={3}>
<FormControl variant="outlined" fullWidth> <FormControl variant="outlined" fullWidth>
<InputLabel htmlFor="outlined-age-native-simple"> <InputLabel htmlFor="outlined-age-native-simple">
Pháp nhân Sn phm
</InputLabel> </InputLabel>
<Select <Select
label="Pháp nhân" label="Sản phẩm"
value={merchant} value={product}
onChange={(e) => setMerchant(e.target.value)} onChange={(e) => setProduct(e.target.value)}
inputProps={{ inputProps={{
name: 'age', name: 'age',
id: 'outlined-age-native-simple', id: 'outlined-age-native-simple',
...@@ -136,21 +130,22 @@ function CustomerView(props) { ...@@ -136,21 +130,22 @@ function CustomerView(props) {
<MenuItem value=""> <MenuItem value="">
<em>Tt c</em> <em>Tt c</em>
</MenuItem> </MenuItem>
{listMerchant.map((e) => ( {listProduct.map((e) => (
<MenuItem value={e.id}>{e.name}</MenuItem> <MenuItem value={e.id}>{e.name}</MenuItem>
))} ))}
</Select> </Select>
</FormControl> </FormControl>
</Grid> </Grid>
<Grid item lg={3} md={3} sm={3} xs={3}>
<Grid item lg={2} md={2} sm={3} xs={3}>
<FormControl variant="outlined" fullWidth> <FormControl variant="outlined" fullWidth>
<InputLabel htmlFor="outlined-age-native-simple"> <InputLabel htmlFor="outlined-age-native-simple">
Cây xăng PT thanh toán
</InputLabel> </InputLabel>
<Select <Select
label="Cây xăng" label="PT thanh toán"
value={store} value={type}
onChange={(e) => setStore(e.target.value)} onChange={(e) => setType(e.target.value)}
inputProps={{ inputProps={{
name: 'age', name: 'age',
id: 'outlined-age-native-simple', id: 'outlined-age-native-simple',
...@@ -159,13 +154,67 @@ function CustomerView(props) { ...@@ -159,13 +154,67 @@ function CustomerView(props) {
<MenuItem value=""> <MenuItem value="">
<em>Tt c</em> <em>Tt c</em>
</MenuItem> </MenuItem>
{listStore.map((e) => ( {[
{
id: 'QR',
name: 'QR',
},
{
id: 'CASH',
name: 'Tiền mặt',
},
{
id: 'DEBT',
name: 'Công nợ',
},
].map((e) => (
<MenuItem value={e.id}>{e.name}</MenuItem>
))}
</Select>
</FormControl>
</Grid>
<Grid item lg={2} md={2} sm={3} xs={3}>
<FormControl variant="outlined" fullWidth>
<InputLabel htmlFor="outlined-age-native-simple">
Trng thái
</InputLabel>
<Select
label="Trạng thái"
value={status}
onChange={(e) => setStatus(e.target.value)}
inputProps={{
name: 'age',
id: 'outlined-age-native-simple',
}}
>
<MenuItem value="">
<em>Tt c</em>
</MenuItem>
{[
{
name: 'Chưa đối soát',
value: 1,
id: 1,
},
{
name: 'Đang đối soát',
value: 2,
id: 2,
},
{
name: 'Đã đối soát',
value: 3,
id: 3,
},
].map((e) => (
<MenuItem value={e.id}>{e.name}</MenuItem> <MenuItem value={e.id}>{e.name}</MenuItem>
))} ))}
</Select> </Select>
</FormControl> </FormControl>
</Grid> </Grid>
<Grid item lg={3} md={3} sm={3} xs={3}>
<Grid item lg={2} md={2} sm={3} xs={3}>
<DateRange <DateRange
date={startDate} date={startDate}
changeDateRange={changeDateRange} changeDateRange={changeDateRange}
......
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