Commit 21bee4ca by tdgiang

update code

parent 834910cd
...@@ -15,6 +15,7 @@ import TransactionRouters from './views/Transaction/TransactionRouters' ...@@ -15,6 +15,7 @@ import TransactionRouters from './views/Transaction/TransactionRouters'
import FeeRouters from './views/Fee/FeeRouters' import FeeRouters from './views/Fee/FeeRouters'
import MerchantRoutes from './views/Merchant/MerchantRoutes' import MerchantRoutes from './views/Merchant/MerchantRoutes'
import GasStationRoutes from './views/GasStation/GasStationRoutes' import GasStationRoutes from './views/GasStation/GasStationRoutes'
import ListRequestRoutes from './views/ListRequest/routes'
const redirectRoute = [ const redirectRoute = [
{ {
path: '/', path: '/',
...@@ -30,6 +31,7 @@ const errorRoute = [ ...@@ -30,6 +31,7 @@ const errorRoute = [
] ]
const routes = [ const routes = [
...ListRequestRoutes,
...GasStationRoutes, ...GasStationRoutes,
...MerchantRoutes, ...MerchantRoutes,
...FeeRouters, ...FeeRouters,
......
...@@ -64,3 +64,8 @@ export const dropdownProcutByType = async (id) => ...@@ -64,3 +64,8 @@ export const dropdownProcutByType = async (id) =>
GetData(`${url.dropdownProcutByType}/${id}`, {}) GetData(`${url.dropdownProcutByType}/${id}`, {})
.then((res) => res) .then((res) => res)
.catch((err) => null) .catch((err) => null)
export const dropdownListSupplier = async (body) =>
GetData(url.dropdownListSupplier, body)
.then((res) => res)
.catch((err) => null)
/* eslint-disable handle-callback-err */
import { PostData, GetURL } from '../helpers'
import url from '../url'
export const listRequest = async (body) =>
PostData(url.listRequest, body)
.then((res) => res)
.catch((err) => null)
export const updateStatusRequest = async (body) =>
PostData(url.updateStatusRequest, body)
.then((res) => res)
.catch((err) => null)
const root = 'http://petrolpay.tasvietnam.vn:9985/api' const root = 'http://petrolpay.tasvietnam.vn:9985/api'
//const root = 'https://apigw.petropos.vn/api'
export default { export default {
//Dang nhap,thong tin ca nhan //Dang nhap,thong tin ca nhan
...@@ -92,6 +93,8 @@ export default { ...@@ -92,6 +93,8 @@ export default {
listFee: `${root}/discountFee/list`, listFee: `${root}/discountFee/list`,
listRequest: `${root}/customerCare/list`,
updateStatusRequest: `${root}/customerCare/changeStatus`,
//dropdown //dropdown
dropdownFuntions: `${root}/dropdown/function`, dropdownFuntions: `${root}/dropdown/function`,
dropdownPermission: `${root}/function/getFunctionTree`, dropdownPermission: `${root}/function/getFunctionTree`,
...@@ -104,4 +107,5 @@ export default { ...@@ -104,4 +107,5 @@ export default {
dropdownStore: `${root}/dropdown/listStore`, dropdownStore: `${root}/dropdown/listStore`,
dropdownMerchant: `${root}/dropdown/listmerchant`, dropdownMerchant: `${root}/dropdown/listmerchant`,
dropdownProcutByType: `${root}/dropdown/productListByType`, dropdownProcutByType: `${root}/dropdown/productListByType`,
dropdownListSupplier: `${root}/dropdown/listSupplier`,
} }
...@@ -355,6 +355,8 @@ ...@@ -355,6 +355,8 @@
"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_IMAGE_NOT_VALID":"Ảnh không đúng dịnh dạng"
} }
...@@ -36,7 +36,7 @@ const Brand = ({ children }) => { ...@@ -36,7 +36,7 @@ const Brand = ({ children }) => {
[classes.hideOnCompact]: mode === 'compact', [classes.hideOnCompact]: mode === 'compact',
})} })}
> >
Petrol PetroPos
</span> </span>
</div> </div>
<div <div
......
...@@ -60,7 +60,13 @@ export const navigations = [ ...@@ -60,7 +60,13 @@ export const navigations = [
id: 'LIST-FEE', id: 'LIST-FEE',
hide: true, hide: true,
}, },
{
name: 'Danh sách yêu cầu',
path: '/list-request',
icon: 'schedule_send',
id: 'LIST-REQUEST',
hide: true,
},
{ {
name: 'Quản lý hệ thống', name: 'Quản lý hệ thống',
icon: 'wb_iridescent', icon: 'wb_iridescent',
...@@ -183,6 +189,13 @@ export const navigationsAdmin = [ ...@@ -183,6 +189,13 @@ export const navigationsAdmin = [
id: 'DASHBOARD', id: 'DASHBOARD',
hide: false, hide: false,
}, },
{
name: 'Danh sách yêu cầu',
path: '/list-request',
icon: 'schedule_send',
id: 'LIST-REQUEST',
hide: false,
},
{ {
name: 'Quản lý hệ thống', name: 'Quản lý hệ thống',
......
...@@ -110,6 +110,7 @@ const SimpleForm = (props) => { ...@@ -110,6 +110,7 @@ const SimpleForm = (props) => {
store_name: newValue?.store_name, store_name: newValue?.store_name,
address: newValue?.address, address: newValue?.address,
gas_fields: listField, gas_fields: listField,
store_code: newValue?.store_code,
}) })
props.hideLoading() props.hideLoading()
if (res.data.code == 200) { if (res.data.code == 200) {
......
import React, { useState, useEffect } from 'react'
import ToolUserView from './View'
import { listRequest, updateStatusRequest } from 'app/apis/Functions/request'
import { useHistory } from 'react-router-dom'
import KEY from '../../assets/Key'
import { connect } from 'react-redux'
import { showLoading, hideLoading } from 'app/redux/actions/loadingAction'
import { toast } from 'react-toastify'
import useDebounce from 'app/hooks/useDebounce'
import { useTranslation } from 'react-i18next'
const ToolNotificate = (props) => {
const [txtSearch, setTxtSearch] = useState('')
const searchDebount = useDebounce(txtSearch, 1000)
const [activeSelected, setActiveSeleted] = useState(null)
const [changeActive, setChangeActive] = useState(1)
const [status, setStatus] = useState()
const [pageIndex, setPageIndex] = useState(0)
const [pageSize] = useState(10)
const [totalRecords, setTotalRecord] = useState(0)
const history = useHistory()
const { t } = useTranslation()
const [data, setData] = useState([])
const [permissions, setPermissions] = useState([])
const handeChangeActive = async (id, status_id) => {
props.showLoading()
const res = await updateStatusRequest({ id: id, status_id })
props.hideLoading()
if (res.data.code == 200) {
getData()
toast.success('Thay đổi trạng thái thành công!', {
theme: 'colored',
})
} else {
toast.error(t(res.data.error), {
theme: 'colored',
})
}
}
const getData = async (isInit) => {
props.showLoading()
let res
if (isInit) {
setPageIndex(0)
res = await listRequest({
cus_name: searchDebount,
page_no: 0,
page_size: pageSize,
status,
})
} else {
res = await listRequest({
cus_name: searchDebount,
page_no: pageIndex + 1,
page_size: pageSize,
status,
})
}
props.hideLoading()
console.log('res', res)
if (res.data.code == 200 && res.data.data) {
console.log(res.data)
const newList = res.data.data.data.map((e, i) => {
return { ...e, index: i + 1 + pageIndex * pageSize }
})
setData(newList)
setTotalRecord(res.data.data.total_elements)
} else {
toast.error(t(res.data.error), {
theme: 'colored',
})
}
}
useEffect(() => {
getData(true)
}, [searchDebount, status])
useEffect(() => {
getData(false)
}, [pageIndex])
const removeItem = async (id) => {}
return (
<ToolUserView
data={data}
removeItem={removeItem}
setTxtSearch={setTxtSearch}
setActiveSeleted={setActiveSeleted}
pageIndex={pageIndex}
changeActive={changeActive}
setChangeActive={setChangeActive}
setPageIndex={setPageIndex}
activeSelected={activeSelected}
handeChangeActive={handeChangeActive}
totalRecords={totalRecords}
permissions={permissions}
status={status}
setStatus={setStatus}
/>
)
}
const mapStateToProps = (state) => {
return {}
}
export default connect(mapStateToProps, { showLoading, hideLoading })(
ToolNotificate
)
import React, { useState } from 'react'
import {
Paper,
Table,
TableBody,
TableCell,
TableHead,
TableContainer,
TablePagination,
TableRow,
IconButton,
MenuItem,
Select,
Modal,
Fade,
Grid,
Backdrop,
Link,
Button,
Tooltip,
Icon,
} from '@material-ui/core'
import EditIcon from '@material-ui/icons/Edit'
import DeleteIcon from '@material-ui/icons/Delete'
import colors from '../../assets/Color'
import useStyles from '../../styles/Table'
import { Breadcrumb, SimpleCard } from 'app/components'
import DialogTransition from 'app/components/dialog/DialogTransition'
import { useHistory } from 'react-router-dom'
import useAuth from 'app/hooks/useAuth'
import { checkRole } from 'app/config/Function'
const columns = [
{
id: 'index',
label: 'STT',
align: 'center',
minWidth: 50,
},
{
id: 'cus_name',
label: 'Họ và tên',
align: 'left',
minWidth: 'auto',
},
{
id: 'phone',
label: 'Số điện thoại',
align: 'left',
minWidth: 'auto',
},
{
id: 'email',
label: 'Email',
align: 'left',
minWidth: 'auto',
},
{
id: 'tax',
label: 'Mã số thuế',
align: 'left',
minWidth: 'auto',
},
{
id: 'company_name',
label: 'Doanh nghiệp/Đơn vị ',
align: 'left',
minWidth: 'auto',
},
{
id: 'city',
label: 'Tỉnh/ Thành phố',
align: 'left',
minWidth: 'auto',
},
]
function TableList(props) {
const {
data,
handeChangeActive,
removeItem,
changeActive,
setChangeActive,
setPageIndex,
setPageSize,
pageIndex,
totalRecords,
permissions,
} = props
const classes = useStyles()
let history = useHistory()
const [selected, setSelected] = useState({
name: '',
id: '',
title: '',
content: '',
})
const [open, setOpen] = React.useState(false)
const { user } = useAuth()
const handleChangePage = (event, newPage) => {
setPageIndex(newPage)
}
const handleChangeRowsPerPage = (event) => {
setPageSize(event.target.value)
}
const handleClose = () => {
setOpen(false)
}
return (
<Paper className={classes.root}>
<TableContainer className={classes.container}>
<Table stickyHeader aria-label="sticky table">
<TableHead>
<TableRow>
{columns.map((column) => (
<TableCell
key={column.id}
align={'center'}
style={{
width: column.minWidth,
backgroundColor: colors.headerTable,
}}
>
{column.label}
</TableCell>
))}
{checkRole(user, '/merchant/changeStatus') && (
<TableCell
style={{
backgroundColor: colors.headerTable,
width: 150,
}}
>
Trạng thái
</TableCell>
)}
</TableRow>
</TableHead>
<TableBody className={classes.columnTable}>
{data.map((row) => {
return (
<TableRow
hover
role="checkbox"
tabIndex={-1}
key={row.id}
>
{columns.map((column) => {
const imageUrl = row[column.id]
return (
<TableCell
key={column.id}
align={column.align}
>
{column.format ? (
<img
src={column.format(
imageUrl
)}
className={
classes.image
}
/>
) : (
imageUrl
)}
</TableCell>
)
})}
{checkRole(
user,
'/merchant/changeStatus'
) && (
<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}
style={{
width: 130,
}}
>
<MenuItem value={1}>
Ch tư vn
</MenuItem>
<MenuItem value={2}>
Đang tư vn
</MenuItem>
<MenuItem value={3}>
Đã tư vn
</MenuItem>
</Select>
</TableCell>
)}
</TableRow>
)
})}
</TableBody>
</Table>
</TableContainer>
<DialogTransition
data={selected}
open={open}
handleClose={handleClose}
onAgree={() => {
removeItem(selected.id)
handleClose()
}}
/>
<TablePagination
component="div"
page={pageIndex}
count={totalRecords}
rowsPerPage={10}
rowsPerPageOptions={[]}
onChangePage={handleChangePage}
onChangeRowsPerPage={handleChangeRowsPerPage}
/>
</Paper>
)
}
export default TableList
import React, { Fragment, useState, useEffect } from 'react'
import {
TextField,
Icon,
Button,
StepLabel,
Step,
Stepper,
Grid,
FormControl,
InputLabel,
Select,
MenuItem,
} from '@material-ui/core'
import Table from './Table'
import { Breadcrumb } from 'app/components'
import { Link } from 'react-router-dom'
import { Autocomplete, createFilterOptions } from '@material-ui/lab'
import useAuth from 'app/hooks/useAuth'
import { checkRole } from 'app/config/Function'
function CustomerView(props) {
const {
data,
updateItem,
removeItem,
setTxtSearch,
changeActive,
setChangeActive,
handeChangeActive,
setPageIndex,
pageIndex,
totalRecords,
permissions,
status,
setStatus,
} = props
const [age, setAge] = React.useState('')
const { user } = useAuth()
const handleChange = (event) => {
setAge(event.target.value)
}
return (
<Fragment>
<div className="m-sm-30">
<div className="mb-sm-30">
<Breadcrumb
routeSegments={[
{
name: 'Danh sách yêu cầu',
path: '/list-request',
},
]}
/>
</div>
<Grid
style={{
padding: 10,
marginBottom: 20,
}}
justify={'space-between'}
alignItems={'center'}
container
spacing={3}
>
<Grid
container
spacing={3}
item
lg={8}
md={8}
sm={8}
xs={8}
>
<Grid item lg={5} md={5} sm={5} xs={5}>
<TextField
variant="outlined"
className="w-full"
label="Tên pháp nhân"
onChange={(e) => {
const text = e.target.value
setTimeout(() => {
setTxtSearch(text)
}, 1000)
}}
/>
</Grid>
<Grid item lg={5} md={5} sm={5} xs={5}>
<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: 'Chờ tư vấn',
},
{
id: 2,
name: 'Đang tư vấn',
},
{
id: 3,
name: 'Đã tư vấn',
},
].map((e) => (
<MenuItem value={e.id}>
{e.name}
</MenuItem>
))}
</Select>
</FormControl>
</Grid>
</Grid>
</Grid>
<Table
data={data}
changeActive={changeActive}
setChangeActive={setChangeActive}
handeChangeActive={handeChangeActive}
updateItem={updateItem}
removeItem={removeItem}
pageIndex={pageIndex}
setPageIndex={setPageIndex}
totalRecords={totalRecords}
permissions={permissions}
/>
</div>
</Fragment>
)
}
export default CustomerView
import React from 'react'
const ListRequestRoutes = [
{
path: '/list-request',
component: React.lazy(() => import('./Index')),
},
]
export default ListRequestRoutes
...@@ -54,9 +54,9 @@ const Analytics = () => { ...@@ -54,9 +54,9 @@ const Analytics = () => {
</Grid> </Grid>
))} ))}
<Grid item xs={12} md={6}> {/* <Grid item xs={12} md={6}>
<StatCards list={list} /> <StatCards list={list} />
</Grid> </Grid> */}
</Grid> </Grid>
</div> </div>
) )
......
...@@ -22,7 +22,7 @@ const StatCards = ({ list }) => { ...@@ -22,7 +22,7 @@ const StatCards = ({ list }) => {
<Grid container spacing={3} className="mb-3"> <Grid container spacing={3} className="mb-3">
{list.map((item, index) => ( {list.map((item, index) => (
<Grid item xs={12} md={6} key={index}> <Grid item xs={12} md={6} key={index}>
<Link to={item.params}> {/* <Link to={item.params}> */}
<Card <Card
className="flex flex-wrap justify-between items-center p-sm-24 bg-paper cursor-pointer" className="flex flex-wrap justify-between items-center p-sm-24 bg-paper cursor-pointer"
elevation={6} elevation={6}
...@@ -41,7 +41,7 @@ const StatCards = ({ list }) => { ...@@ -41,7 +41,7 @@ const StatCards = ({ list }) => {
</IconButton> </IconButton>
</Tooltip> </Tooltip>
</Card> </Card>
</Link> {/* </Link> */}
</Grid> </Grid>
))} ))}
</Grid> </Grid>
......
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