Commit 8e228715 by tdgiang

update code

parent 9b214793
...@@ -6,3 +6,33 @@ export const listTransReconciliation = async (body) => ...@@ -6,3 +6,33 @@ export const listTransReconciliation = async (body) =>
PostData(url.listTransReconciliation, body) PostData(url.listTransReconciliation, body)
.then((res) => res) .then((res) => res)
.catch((err) => null) .catch((err) => null)
export const listSheetReconciliation = async (body) =>
PostData(url.listSheetReconciliation, body)
.then((res) => res)
.catch((err) => null)
export const listProviderSetting = async (body) =>
PostData(url.listProviderSetting, body)
.then((res) => res)
.catch((err) => null)
export const detailProviderSetting = async (id, body) =>
GetURL(`${url.detailProviderSetting}/${id}`, body)
.then((res) => res)
.catch((err) => null)
export const updateProviderSetting = async (body) =>
PostData(url.updateProviderSetting, body)
.then((res) => res)
.catch((err) => null)
export const detailSheetReconciliation = async (id, body) =>
GetURL(`${url.detailSheetReconciliation}/${id}`, body)
.then((res) => res)
.catch((err) => null)
export const updateSheetReconciliation = async (body) =>
PostData(url.updateSheetReconciliation, body)
.then((res) => res)
.catch((err) => null)
...@@ -120,6 +120,12 @@ export default { ...@@ -120,6 +120,12 @@ export default {
//reconciliation //reconciliation
listTransReconciliation: `${root}/paymentpartner/list/trans`, listTransReconciliation: `${root}/paymentpartner/list/trans`,
listSheetReconciliation: `${root}/reconciliation/list`,
detailSheetReconciliation: `${root}/reconciliation`,
updateSheetReconciliation: `${root}/reconciliation/update`,
listProviderSetting: `${root}/provider/paging/setting`,
detailProviderSetting: `${root}/reconciliation/setting`,
updateProviderSetting: `${root}/reconciliation/setting/create`,
//Log //Log
logAuth: `${root}/logging/listLogin`, logAuth: `${root}/logging/listLogin`,
......
export const listHour = [
{
name: '00:00',
value: '00:00',
},
{
name: '01:00',
value: '01:00',
},
{
name: '02:00',
value: '02:00',
},
{
name: '03:00',
value: '03:00',
},
{
name: '04:00',
value: '04:00',
},
{
name: '05:00',
value: '05:00',
},
{
name: '06:00',
value: '06:00',
},
{
name: '07:00',
value: '07:00',
},
{
name: '08:00',
value: '08:00',
},
{
name: '09:00',
value: '09:00',
},
{
name: '10:00',
value: '10:00',
},
{
name: '11:00',
value: '11:00',
},
{
name: '12:00',
value: '12:00',
},
{
name: '13:00',
value: '13:00',
},
{
name: '14:00',
value: '14:00',
},
{
name: '15:00',
value: '15:00',
},
{
name: '16:00',
value: '16:00',
},
{
name: '17:00',
value: '17:00',
},
{
name: '18:00',
value: '18:00',
},
{
name: '19:00',
value: '19:00',
},
{
name: '20:00',
value: '20:00',
},
{
name: '21:00',
value: '21:00',
},
{
name: '22:00',
value: '22:00',
},
{
name: '23:00',
value: '23:00',
},
]
export const listWeek = [
{
name: 'Thứ 2',
value: 1,
},
{
name: 'Thứ 3',
value: 2,
},
{
name: 'Thứ 4',
value: 3,
},
{
name: 'Thứ 5',
value: 4,
},
{
name: 'Thứ 6',
value: 5,
},
{
name: 'Thứ 7',
value: 6,
},
{
name: 'Chủ nhật',
value: 7,
},
]
export const listMonth = [
{
name: 'Ngày 1',
value: 1,
},
{
name: 'Ngày 2',
value: 2,
},
{
name: 'Ngày 3',
value: 3,
},
{
name: 'Ngày 4',
value: 4,
},
{
name: 'Ngày 5',
value: 5,
},
{
name: 'Ngày 6',
value: 6,
},
{
name: 'Ngày 7',
value: 7,
},
{
name: 'Ngày 8',
value: 8,
},
{
name: 'Ngày 9',
value: 9,
},
{
name: 'Ngày 10',
value: 10,
},
{
name: 'Ngày 11',
value: 11,
},
{
name: 'Ngày 12',
value: 12,
},
{
name: 'Ngày 13',
value: 13,
},
{
name: 'Ngày 14',
value: 14,
},
{
name: 'Ngày 15',
value: 15,
},
{
name: 'Ngày 16',
value: 16,
},
{
name: 'Ngày 17',
value: 17,
},
{
name: 'Ngày 18',
value: 18,
},
{
name: 'Ngày 19',
value: 19,
},
{
name: 'Ngày 20',
value: 20,
},
{
name: 'Ngày 21',
value: 21,
},
{
name: 'Ngày 22',
value: 22,
},
{
name: 'Ngày 23',
value: 23,
},
{
name: 'Ngày 24',
value: 24,
},
{
name: 'Ngày 25',
value: 25,
},
{
name: 'Ngày 26',
value: 26,
},
{
name: 'Ngày 27',
value: 27,
},
{
name: 'Ngày 28',
value: 28,
},
{
name: 'Ngày 29',
value: 29,
},
{
name: 'Ngày 30',
value: 30,
},
{
name: 'Ngày 31',
value: 31,
},
]
...@@ -354,7 +354,6 @@ ...@@ -354,7 +354,6 @@
"ERROR_NAME_IS_EXISTS":"Tên sản phẩm đã tồn tại", "ERROR_NAME_IS_EXISTS":"Tên sản phẩm đã tồn tại",
"ERROR_MERCHAN_STORE_CODE_EXIST":"Mã cây xăng đã tồn tại", "ERROR_MERCHAN_STORE_CODE_EXIST":"Mã cây xăng đã tồn tại",
"ERROR_CODE_IS_EXITS":"Mã code đã tồn tại", "ERROR_CODE_IS_EXITS":"Mã code đã tồn tại",
"ERROR_NAME_IS_EXITS":"Tên sản phẩm đã tồn tại", "ERROR_NAME_IS_EXITS":"Tên sản phẩm đã tồn tại",
"ERROR_MERCHAN_STORE_CODE":"Mã cây xăng đã tồn tại", "ERROR_MERCHAN_STORE_CODE":"Mã cây xăng đã tồn tại",
...@@ -364,8 +363,12 @@ ...@@ -364,8 +363,12 @@
"ERROR_NAME_PACKAGE_IS_EXITS":"Tên gói đã tồn tại", "ERROR_NAME_PACKAGE_IS_EXITS":"Tên gói đã tồn tại",
"ERROR_NAME_FUNCTION_IS_EXITS":"Tên chức năng đã tồn tại", "ERROR_NAME_FUNCTION_IS_EXITS":"Tên chức năng đã tồn tại",
"ERROR_USER_GROUP_EXISTS_DATA":"Nhóm quyền đã có dữ liệu", "ERROR_USER_GROUP_EXISTS_DATA":"Nhóm quyền đã có dữ liệu",
"ERROR_DATE_INVALID":"Thời gian không hợp lệ",
"ERROR_DATE_INVALID":"Thời gian không hợp lệ" "ERROR_NOT_PAYMENTGATE": "chưa truyền code đối tác thanh toán",
"ERROR_FORMAT_HOUR": "Sai định dang giờ",
"ERROR_FORMAT_DAYOFWEEK": "Sai định dang ngày trong tuần",
"ERROR_FORMAT_DATEOFMONTH": "Sai định dang ngày trong tháng"
} }
import React, { useState, useEffect } from 'react' import React, { useState, useEffect } from 'react'
import ToolUserView from './View' import ToolUserView from './View'
import { import { listProviderSetting } from 'app/apis/Functions/reconciliation'
getListSupplier,
deleteSupplier,
changeStatusSupplier,
} from 'app/apis/Functions/supplier'
import { useHistory } from 'react-router-dom' import { useHistory } from 'react-router-dom'
import KEY from 'app/assets/Key' import KEY from 'app/assets/Key'
import { connect } from 'react-redux' import { connect } from 'react-redux'
...@@ -32,19 +28,19 @@ const ToolNotificate = (props) => { ...@@ -32,19 +28,19 @@ const ToolNotificate = (props) => {
const [data, setData] = useState([]) const [data, setData] = useState([])
const handeChangeActive = async (id, status_id) => { const handeChangeActive = async (id, status_id) => {
props.showLoading() // props.showLoading()
const res = await changeStatusSupplier({ id, status_id }) // const res = await changeStatusSupplier({ id, status_id })
props.hideLoading() // props.hideLoading()
if (res.data.code == 200) { // if (res.data.code == 200) {
getData() // getData()
toast.success('Thay đổi trạng thái thành công!', { // toast.success('Thay đổi trạng thái thành công!', {
theme: 'colored', // theme: 'colored',
}) // })
} else { // } else {
toast.error('Thay đổi trạng thái thất bại!', { // toast.error('Thay đổi trạng thái thất bại!', {
theme: 'colored', // theme: 'colored',
}) // })
} // }
} }
console.log('user', user) console.log('user', user)
...@@ -53,20 +49,20 @@ const ToolNotificate = (props) => { ...@@ -53,20 +49,20 @@ const ToolNotificate = (props) => {
let res let res
if (isInit) { if (isInit) {
setPageIndex(0) setPageIndex(0)
res = await getListSupplier({ res = await listProviderSetting({
provider_name: searchDebount, provider_name: searchDebount,
page_no: 0, page_no: 0,
page_size: pageSize, page_size: pageSize,
status, status,
type: 3, // type: 3,
}) })
} else { } else {
res = await getListSupplier({ res = await listProviderSetting({
provider_name: searchDebount, provider_name: searchDebount,
page_no: pageIndex + 1, page_no: pageIndex + 1,
page_size: pageSize, page_size: pageSize,
status, status,
type: 3, // type: 3,
}) })
} }
...@@ -95,24 +91,24 @@ const ToolNotificate = (props) => { ...@@ -95,24 +91,24 @@ const ToolNotificate = (props) => {
}, [searchDebount, status, store, group]) }, [searchDebount, status, store, group])
const removeItem = async (id) => { const removeItem = async (id) => {
props.showLoading() // props.showLoading()
const res = await deleteSupplier({ id }) // const res = await deleteSupplier({ id })
props.hideLoading() // props.hideLoading()
if (res.data.code == 200) { // if (res.data.code == 200) {
getData(true) // getData(true)
toast.success('Xoá bản ghi thành công!', { // toast.success('Xoá bản ghi thành công!', {
theme: 'colored', // theme: 'colored',
}) // })
} else if (res.data.code == 401) { // } else if (res.data.code == 401) {
localStorage.removeItem(KEY.API_TOKEN) // localStorage.removeItem(KEY.API_TOKEN)
setTimeout(() => { // setTimeout(() => {
history.push('/') // history.push('/')
}, 100) // }, 100)
} else { // } else {
toast.error('Xoá bản ghi thất bại!', { // toast.error('Xoá bản ghi thất bại!', {
theme: 'colored', // theme: 'colored',
}) // })
} // }
} }
return ( return (
......
...@@ -39,38 +39,31 @@ const columns = [ ...@@ -39,38 +39,31 @@ const columns = [
}, },
{ {
id: 'provider_code', id: 'provider_code',
label: 'Mã nhà cung cấp', label: 'Đối tác',
align: 'center', align: 'center',
minWidth: 150, minWidth: 150,
}, },
{ {
id: 'provider_name', id: 'type_comission',
label: 'Tên nhà cung cấp', label: 'Loại hoa hồng',
align: 'left', align: 'left',
minWidth: 200, minWidth: 200,
}, },
{ {
id: 'phone', id: 'type_Name',
label: 'Số điện thoại', label: 'ĐVT',
align: 'left', align: 'left',
minWidth: 'auto', minWidth: 'auto',
minWidth: 100, minWidth: 100,
}, },
{ {
id: 'email', id: 'reconciliation_cycle_name',
label: 'Email', label: 'Chu ký đối soát',
align: 'left', align: 'left',
minWidth: 'auto', minWidth: 'auto',
minWidth: 150, minWidth: 150,
}, },
{
id: 'address',
label: 'Địa chỉ',
align: 'left',
minWidth: 'auto',
minWidth: 250,
},
] ]
function TableList(props) { function TableList(props) {
...@@ -126,21 +119,11 @@ function TableList(props) { ...@@ -126,21 +119,11 @@ function TableList(props) {
{column.label} {column.label}
</TableCell> </TableCell>
))} ))}
<TableCell
style={{
backgroundColor: colors.headerTable,
width: 145,
}}
>
Trạng thái
</TableCell>
<TableCell <TableCell
style={{ style={{
textAlign: 'center', textAlign: 'center',
backgroundColor: colors.headerTable, backgroundColor: colors.headerTable,
width: 120, width: 60,
}} }}
> >
Hành động Hành động
...@@ -178,53 +161,10 @@ function TableList(props) { ...@@ -178,53 +161,10 @@ function TableList(props) {
</TableCell> </TableCell>
) )
})} })}
<TableCell className={classes.border}>
<Select
variant={'outlined'}
labelId="demo-simple-select-placeholder-label-label"
id="demo-simple-select-placeholder-label"
onChange={(e) =>
handeChangeActive(
row.id,
e.target.value
)
}
displayEmpty
defaultValue={row.status}
className={classes.formControl}
>
<MenuItem value={1}>
Hot động
</MenuItem>
<MenuItem value={2}>Khóa</MenuItem>
</Select>
</TableCell>
<TableCell> <TableCell>
{checkRole(user, '/ncc/delete') ? (
<Tooltip title="Xoá">
<IconButton
onClick={() => {
setSelected({
...row,
title: 'Xóa NCC thiết bị',
content: `Bạn có muốn xóa NCC thiết bị ${row.provider_name} hay không?`,
})
setOpen(true)
}}
className={classes.button}
aria-label="Delete"
>
<Icon color="error">
delete
</Icon>
</IconButton>
</Tooltip>
) : null}
{checkRole( {checkRole(
user, user,
'/reconciliation/setting/update' '/reconciliation/setting'
) ? ( ) ? (
<Tooltip title="Cập nhật"> <Tooltip title="Cập nhật">
<IconButton <IconButton
...@@ -232,7 +172,7 @@ function TableList(props) { ...@@ -232,7 +172,7 @@ function TableList(props) {
history.push({ history.push({
pathname: pathname:
'/reconciliation/setting/update', '/reconciliation/setting/update',
state: row.id, state: row.provider_code,
}) })
}} }}
className={classes.button} className={classes.button}
......
...@@ -79,11 +79,12 @@ function CustomerView(props) { ...@@ -79,11 +79,12 @@ function CustomerView(props) {
sm={8} sm={8}
xs={8} xs={8}
> >
<Grid item lg={3} md={3} sm={3} xs={3}> <Grid item lg={4} md={4} sm={6} xs={6}>
<TextField <TextField
variant="outlined" variant="outlined"
className="w-full" className="w-full"
label="Nhập từ khoá" label="Nhập từ khoá"
fullWidth
onChange={(e) => { onChange={(e) => {
const text = e.target.value const text = e.target.value
setTimeout(() => { setTimeout(() => {
...@@ -92,41 +93,6 @@ function CustomerView(props) { ...@@ -92,41 +93,6 @@ function CustomerView(props) {
}} }}
/> />
</Grid> </Grid>
<Grid item lg={3} md={3} 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>
{[
{
id: 1,
name: 'Hoạt động',
},
{
id: 2,
name: 'Khoá',
},
].map((e) => (
<MenuItem value={e.id}>
{e.name}
</MenuItem>
))}
</Select>
</FormControl>
</Grid>
</Grid> </Grid>
{/* {checkRole(user, '/reconciliation/setting/create') ? ( {/* {checkRole(user, '/reconciliation/setting/create') ? (
<Link to="/reconciliation/setting/create"> <Link to="/reconciliation/setting/create">
......
import React, { useState, useEffect } from 'react' import React, { useState, useEffect } from 'react'
import LogAuth from './View' import LogAuth from './View'
import { listTransaction } from 'app/apis/Functions/transaction' import { listSheetReconciliation } from 'app/apis/Functions/reconciliation'
import { useHistory } from 'react-router-dom' import { useHistory } from 'react-router-dom'
import { toPriceVnd, convertDate } from 'app/config/Function' import { toPriceVnd, convertDate } from 'app/config/Function'
import { connect } from 'react-redux' import { connect } from 'react-redux'
...@@ -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 { dropdownMerchant, dropdownProvider } from 'app/apis/Functions/dropdown'
const ToolNotificate = (props) => { const ToolNotificate = (props) => {
const [txtSearch, setTxtSearch] = useState('') const [txtSearch, setTxtSearch] = useState('')
...@@ -22,15 +22,13 @@ const ToolNotificate = (props) => { ...@@ -22,15 +22,13 @@ const ToolNotificate = (props) => {
const [endDate, setEndDate] = useState() const [endDate, setEndDate] = useState()
const { t } = useTranslation() const { t } = useTranslation()
const [data, setData] = useState([]) const [data, setData] = useState([])
const [type, setType] = useState()
const [listType, setListType] = useState([]) const [status, setStatus] = useState()
const [merchant, setMerchant] = useState() const [listProvide, setListProvide] = useState([])
const [listMerchant, setListMerchant] = useState([]) const [provide, setProvide] = useState()
const [store, setStore] = useState()
const [listStore, setListStore] = useState([])
useEffect(() => { useEffect(() => {
getDataMerchant() getDataDropdown()
}, []) }, [])
const changeDateRange = (start, end) => { const changeDateRange = (start, end) => {
...@@ -43,32 +41,24 @@ const ToolNotificate = (props) => { ...@@ -43,32 +41,24 @@ const ToolNotificate = (props) => {
let res let res
if (init) { if (init) {
setPageIndex(0) setPageIndex(0)
res = await listTransaction({ res = await listSheetReconciliation({
order_code: searchDebount, order_code: searchDebount,
applications,
page_no: 0, page_no: 0,
page_size: pageSize, page_size: pageSize,
from_date: startDate ? convertDate(startDate) : null, date_from: startDate ? convertDate(startDate) : null,
to_date: endDate ? convertDate(endDate) : null, date_to: endDate ? convertDate(endDate) : null,
type_code: type, status: status ? status : 0,
merchant_id: merchant, idPaymentPartner: provide ? provide : null,
store_id: store,
// gasoline_id: '57dd1a73-d847-4d73-9791-08dc0841e7a9',
}) })
} else { } else {
res = await listTransaction({ res = await listSheetReconciliation({
order_code: searchDebount, order_code: searchDebount,
applications,
page_no: pageIndex + 1, page_no: pageIndex + 1,
page_size: pageSize, page_size: pageSize,
from_date: startDate ? convertDate(startDate) : null, from_date: startDate ? convertDate(startDate) : null,
to_date: endDate ? convertDate(endDate) : null, to_date: endDate ? convertDate(endDate) : null,
type_code: type, status: status ? status : 0,
merchant_id: merchant, idPaymentPartner: provide ? provide : null,
store_id: store,
// gasoline_id: '57dd1a73-d847-4d73-9791-08dc0841e7a9',
}) })
} }
...@@ -96,43 +86,15 @@ const ToolNotificate = (props) => { ...@@ -96,43 +86,15 @@ const ToolNotificate = (props) => {
useEffect(() => { useEffect(() => {
getData(true) getData(true)
}, [searchDebount, startDate, type, merchant, store]) }, [searchDebount, startDate, status, provide])
useEffect(() => {
if (merchant) {
getDropdownStore(merchant)
}
setStore()
}, [merchant])
const getDataMerchant = async () => {
const res = await dropdownMerchant({})
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',
})
}
}
const getDropdownStore = async (id) => {
const res = await dropdownStore(id)
const getDataDropdown = async () => {
const res = await dropdownProvider({})
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.map((e) => { const newList = res.data.data.map((e) => {
return { ...e, name: e.store_name } return { ...e, id: e.code }
})
setListStore(newList)
} else {
toast.error(t(res.data.error), {
theme: 'colored',
}) })
setListProvide(newList)
} }
} }
...@@ -147,15 +109,11 @@ const ToolNotificate = (props) => { ...@@ -147,15 +109,11 @@ const ToolNotificate = (props) => {
applications={applications} applications={applications}
startDate={startDate} startDate={startDate}
changeDateRange={changeDateRange} changeDateRange={changeDateRange}
type={type} listProvide={listProvide}
setType={setType} provide={provide}
listType={listType} setProvide={setProvide}
merchant={merchant} status={status}
setMerchant={setMerchant} setStatus={setStatus}
listMerchant={listMerchant}
store={store}
setStore={setStore}
listStore={listStore}
/> />
) )
} }
......
...@@ -39,49 +39,55 @@ const ToolNotificate = (props) => { ...@@ -39,49 +39,55 @@ const ToolNotificate = (props) => {
} }
const getData = async (init) => { const getData = async (init) => {
props.showLoading() if (props?.idReconciliation) {
let res props.showLoading()
if (init) { let res
setPageIndex(0) if (init) {
res = await listTransReconciliation({ setPageIndex(0)
page_no: 0, res = await listTransReconciliation({
page_size: pageSize, page_no: 0,
date_from: startDate ? convertDate(startDate) : null, page_size: pageSize,
date_to: endDate ? convertDate(endDate) : null, date_from: startDate ? convertDate(startDate) : null,
product_code: null, date_to: endDate ? convertDate(endDate) : null,
payment_gate_code: null, product_code: null,
statusReconciliation: 0, payment_gate_code: null,
type_payment: null, statusReconciliation: 0,
}) type_payment: null,
} else { idReconciliation: props?.idReconciliation,
res = await listTransReconciliation({ is_reconciliation: true,
page_no: pageIndex + 1, })
page_size: pageSize, } else {
date_from: startDate ? convertDate(startDate) : null, res = await listTransReconciliation({
date_to: endDate ? convertDate(endDate) : null, page_no: pageIndex + 1,
product_code: null, page_size: pageSize,
payment_gate_code: null, date_from: startDate ? convertDate(startDate) : null,
statusReconciliation: 0, date_to: endDate ? convertDate(endDate) : null,
type_payment: null, product_code: null,
}) payment_gate_code: null,
} statusReconciliation: 0,
type_payment: null,
idReconciliation: props?.idReconciliation,
is_reconciliation: true,
})
}
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) 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, index: i + 1 + pageIndex * pageSize }
}) })
setData(newList) setData(newList)
setTotalRecord(res.data.data.total_elements) setTotalRecord(res.data.data.total_elements)
} else if (res.data.code == 401) { } else if (res.data.code == 401) {
setTimeout(() => { setTimeout(() => {
history.push('/') history.push('/')
}, 100) }, 100)
} else { } else {
toast.error(t(res.data.error), { toast.error(t(res.data.error), {
theme: 'colored', theme: 'colored',
}) })
}
} }
} }
......
...@@ -12,13 +12,17 @@ import { ...@@ -12,13 +12,17 @@ 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'
import { checkRole } from 'app/config/Function'
import useAuth from 'app/hooks/useAuth'
import { useHistory } from 'react-router-dom'
const columns = [ const columns = [
{ {
id: 'index', id: 'index',
...@@ -26,73 +30,44 @@ const columns = [ ...@@ -26,73 +30,44 @@ const columns = [
align: 'center', align: 'center',
minWidth: 80, minWidth: 80,
}, },
{ {
id: 'store_name', id: 'code',
label: 'Cây xăng', label: 'Mã phiếu đối soát',
align: 'left', align: 'left',
minWidth: 160, minWidth: 160,
}, },
// {
// id: 'application',
// label: 'Mã NV',
// align: 'left',
// minWidth: 140,
// },
{ {
id: 'order_code', id: 'idPaymentPartner',
label: 'Mã hoá đơn', label: 'Đối tác',
align: 'left', align: 'left',
minWidth: 160, minWidth: 80,
},
{
id: 'created_date',
label: 'Ngày giao dịch',
align: 'left',
minWidth: 110,
}, },
// {
// id: 'IP',
// label: 'Loại nhiên liệu',
// align: 'left',
// minWidth: 140,
// },
{ {
id: 'product_name', id: 'create_date',
label: 'Sản phẩm', label: 'Ngày tạo phiếu',
align: 'left', align: 'left',
minWidth: 120, minWidth: 110,
}, },
{ {
id: 'unit_price', id: 'update_date',
label: 'Đơn giá', label: 'Ngày cập nhật',
align: 'left', align: 'left',
minWidth: 80, minWidth: 110,
}, },
{ {
id: 'quantity', id: 'date_reconciliation',
label: 'Lượng nhiên liệu', label: 'Ngày đối soát',
align: 'left', align: 'left',
minWidth: 80, minWidth: 110,
}, },
{ {
id: 'price', id: 'totalCommission',
label: 'Thành tiền', label: 'Hoa hồng',
align: 'left', align: 'left',
minWidth: 80, minWidth: 80,
}, isMonney: true,
{
id: 'type_payment',
label: 'Phương thức thanh toán',
align: 'left',
minWidth: 100,
},
{
id: 'status_text',
label: 'Trạng thái',
align: 'left',
minWidth: 100,
}, },
] ]
...@@ -109,14 +84,26 @@ function TableList(props) { ...@@ -109,14 +84,26 @@ function TableList(props) {
pageIndex, pageIndex,
totalRecords, totalRecords,
} = props } = props
let history = useHistory()
const handleChangePage = (event, newPage) => { const handleChangePage = (event, newPage) => {
setPageIndex(newPage) setPageIndex(newPage)
} }
const handleChangeRowsPerPage = (event) => { const handleChangeRowsPerPage = (event) => {
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'
}
const { user } = useAuth()
return ( return (
<Paper className={classes.root}> <Paper className={classes.root}>
<TableContainer className={classes.container}> <TableContainer className={classes.container}>
...@@ -135,6 +122,23 @@ function TableList(props) { ...@@ -135,6 +122,23 @@ function TableList(props) {
{column.label} {column.label}
</TableCell> </TableCell>
))} ))}
<TableCell
style={{
width: 110,
backgroundColor: colors.headerTable,
}}
>
Trng thái
</TableCell>
<TableCell
style={{
textAlign: 'center',
backgroundColor: colors.headerTable,
width: 60,
}}
>
Hành động
</TableCell>
</TableRow> </TableRow>
</TableHead> </TableHead>
<TableBody className={classes.columnTable}> <TableBody className={classes.columnTable}>
...@@ -147,28 +151,71 @@ function TableList(props) { ...@@ -147,28 +151,71 @@ 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?.status
),
color: renderStatusColor(
row?.status
),
borderRadius: 10,
}}
>
{row?.status_name}
</Typography>
</TableCell>
<TableCell>
{checkRole(
user,
'/reconciliation/sheet'
) ? (
<Tooltip title="Cập nhật">
<IconButton
onClick={() => {
history.push({
pathname:
'/reconciliation/sheet/update',
state: row.id,
})
}}
className={classes.button}
aria-label="edit"
>
<Icon color="primary">
edit
</Icon>
</IconButton>
</Tooltip>
) : null}
</TableCell>
</TableRow> </TableRow>
) )
})} })}
......
...@@ -14,7 +14,7 @@ import { ...@@ -14,7 +14,7 @@ import {
TextField, TextField,
Icon, Icon,
} from '@material-ui/core' } from '@material-ui/core'
import { createFunction } from 'app/apis/Functions/function'
import { showLoading, hideLoading } from 'app/redux/actions/loadingAction' import { showLoading, hideLoading } from 'app/redux/actions/loadingAction'
import { toast } from 'react-toastify' import { toast } from 'react-toastify'
import { Breadcrumb, SimpleCard } from 'app/components' import { Breadcrumb, SimpleCard } from 'app/components'
...@@ -28,27 +28,51 @@ import { ...@@ -28,27 +28,51 @@ import {
dropdownStore, dropdownStore,
} from 'app/apis/Functions/dropdown' } from 'app/apis/Functions/dropdown'
import PickerImage from 'app/components/Input/PickerImage' import PickerImage from 'app/components/Input/PickerImage'
import { createSupplier } from 'app/apis/Functions/supplier' import {
detailSheetReconciliation,
updateSheetReconciliation,
} from 'app/apis/Functions/reconciliation'
import { useTranslation } from 'react-i18next' import { useTranslation } from 'react-i18next'
import useAuth from 'app/hooks/useAuth' import useAuth from 'app/hooks/useAuth'
import ListTrans from './ListTrans/Index' import ListTrans from './ListTrans/Index'
const SimpleForm = (props) => { const SimpleForm = (props) => {
const location = useLocation()
const [state, setState] = useState({}) const [state, setState] = useState({})
const [listDrop, setListDrop] = useState([]) const [listDrop, setListDrop] = useState([])
const [listAction, setListAction] = useState([]) const [listAction, setListAction] = useState([])
useEffect(() => {
getDataDefault()
}, [])
const { user } = useAuth() const { user } = useAuth()
const { t } = useTranslation() const { t } = useTranslation()
const history = useHistory() const history = useHistory()
const getDataDefault = async () => {
props.showLoading()
try {
const res = await detailSheetReconciliation(location.state, {})
if (res.data.data) {
setState({ ...res.data.data })
}
} catch (err) {
toast.error(t(err), {
theme: 'colored',
})
}
props.hideLoading()
}
const handleSubmit = async (event) => { const handleSubmit = async (event) => {
const newValue = trimObject(state) const newValue = trimObject(state)
props.showLoading() props.showLoading()
const res = await createSupplier({ const res = await updateSheetReconciliation({
...newValue, ...newValue,
type: '3', type: '3',
status: 1, status: 1,
...@@ -76,8 +100,8 @@ const SimpleForm = (props) => { ...@@ -76,8 +100,8 @@ const SimpleForm = (props) => {
[event.target.name]: event.target.value, [event.target.name]: event.target.value,
}) })
} }
console.log('state', state)
const { provider_code, provider_name, phone, email, address } = state const { code, idPaymentPartner, note } = state
return ( return (
<div className="m-sm-30"> <div className="m-sm-30">
<div className="mb-sm-30"> <div className="mb-sm-30">
...@@ -139,8 +163,8 @@ const SimpleForm = (props) => { ...@@ -139,8 +163,8 @@ const SimpleForm = (props) => {
onChange={handleChange} onChange={handleChange}
disabled={true} disabled={true}
type="text" type="text"
name="provider_code" name="code"
value={provider_code || ''} value={code || ''}
validators={['required']} validators={['required']}
errorMessages={[ errorMessages={[
'Không được để trống trường này', 'Không được để trống trường này',
...@@ -155,8 +179,8 @@ const SimpleForm = (props) => { ...@@ -155,8 +179,8 @@ const SimpleForm = (props) => {
disabled={true} disabled={true}
onChange={handleChange} onChange={handleChange}
type="text" type="text"
name="provider_code" name="idPaymentPartner"
value={provider_code || ''} value={idPaymentPartner || ''}
validators={['required']} validators={['required']}
errorMessages={[ errorMessages={[
'Không được để trống trường này', 'Không được để trống trường này',
...@@ -171,8 +195,8 @@ const SimpleForm = (props) => { ...@@ -171,8 +195,8 @@ const SimpleForm = (props) => {
label="Ghi chú" label="Ghi chú"
onChange={handleChange} onChange={handleChange}
type="text" type="text"
name="address" name="note"
value={address || ''} value={note || ''}
/> />
</Grid> </Grid>
...@@ -185,7 +209,10 @@ const SimpleForm = (props) => { ...@@ -185,7 +209,10 @@ const SimpleForm = (props) => {
container container
spacing={2} spacing={2}
> >
<ListTrans isDetail={false} /> <ListTrans
isDetail={false}
idReconciliation={location.state}
/>
</Grid> </Grid>
</Grid> </Grid>
</ValidatorForm> </ValidatorForm>
......
...@@ -33,15 +33,12 @@ function CustomerView(props) { ...@@ -33,15 +33,12 @@ function CustomerView(props) {
applications, applications,
startDate, startDate,
changeDateRange, changeDateRange,
type,
setType, status,
listType, setStatus,
listMerchant, provide,
setMerchant, setProvide,
merchant, listProvide,
store,
setStore,
listStore,
} = props } = props
const handleChange = (event) => { const handleChange = (event) => {
...@@ -71,7 +68,7 @@ function CustomerView(props) { ...@@ -71,7 +68,7 @@ function CustomerView(props) {
container container
spacing={3} spacing={3}
> >
<Grid item lg={3} md={3} sm={3} xs={3}> <Grid item lg={3} md={3} sm={4} xs={4}>
<TextField <TextField
variant="outlined" variant="outlined"
className="w-full" className="w-full"
...@@ -86,12 +83,12 @@ function CustomerView(props) { ...@@ -86,12 +83,12 @@ function CustomerView(props) {
<Grid item lg={3} md={3} 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 Trng thái
</InputLabel> </InputLabel>
<Select <Select
label="Phương thức thanh toán" label="Trạng thái"
value={type} value={status}
onChange={(e) => setType(e.target.value)} onChange={(e) => setStatus(e.target.value)}
inputProps={{ inputProps={{
name: 'age', name: 'age',
id: 'outlined-age-native-simple', id: 'outlined-age-native-simple',
...@@ -102,16 +99,25 @@ function CustomerView(props) { ...@@ -102,16 +99,25 @@ function CustomerView(props) {
</MenuItem> </MenuItem>
{[ {[
{ {
id: 'QR', name: 'Nháp',
name: 'QR', value: 1,
id: 1,
},
{
name: 'Chưa đối soát',
value: 2,
id: 2,
}, },
{ {
id: 'CASH', name: 'Đang đối soát',
name: 'Tiền mặt', value: 3,
id: 3,
}, },
{ {
id: 'DEBT', name: 'Đã đối soát',
name: 'Công nợ', value: 4,
id: 4,
}, },
].map((e) => ( ].map((e) => (
<MenuItem value={e.id}>{e.name}</MenuItem> <MenuItem value={e.id}>{e.name}</MenuItem>
...@@ -122,35 +128,12 @@ function CustomerView(props) { ...@@ -122,35 +128,12 @@ function CustomerView(props) {
<Grid item lg={3} md={3} 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áp nhân Đối tác
</InputLabel>
<Select
label="Pháp nhân"
value={merchant}
onChange={(e) => setMerchant(e.target.value)}
inputProps={{
name: 'age',
id: 'outlined-age-native-simple',
}}
>
<MenuItem value="">
<em>Tt c</em>
</MenuItem>
{listMerchant.map((e) => (
<MenuItem value={e.id}>{e.name}</MenuItem>
))}
</Select>
</FormControl>
</Grid>
<Grid item lg={3} md={3} sm={3} xs={3}>
<FormControl variant="outlined" fullWidth>
<InputLabel htmlFor="outlined-age-native-simple">
Cây xăng
</InputLabel> </InputLabel>
<Select <Select
label="Cây xăng" label="Đối tác"
value={store} value={provide}
onChange={(e) => setStore(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',
...@@ -159,12 +142,13 @@ function CustomerView(props) { ...@@ -159,12 +142,13 @@ function CustomerView(props) {
<MenuItem value=""> <MenuItem value="">
<em>Tt c</em> <em>Tt c</em>
</MenuItem> </MenuItem>
{listStore.map((e) => ( {listProvide.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={3} md={3} sm={3} xs={3}>
<DateRange <DateRange
date={startDate} date={startDate}
......
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