Commit 9b214793 by tdgiang

update code

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