Commit 6dc92ec6 by tdgiang

fix bug

parent 8814a3d1
......@@ -104,3 +104,13 @@ export const dropdownListPayType = async (body) =>
GetData(url.dropdownListPayType, body)
.then((res) => res)
.catch((err) => null)
export const dropdownStoreNew = async (id) =>
GetData(`${url.dropdownStore}`, {})
.then((res) => res)
.catch((err) => null)
export const dropdownPaymentType = async (body) =>
GetData(url.dropdownPaymentType, body)
.then((res) => res)
.catch((err) => null)
......@@ -192,4 +192,6 @@ export default {
dropdownStoreStatus: `${root}/dropdown/getlistStoreStatus`,
dropdownProvider: `${root}/dropdown/Provider`,
dropdownListPayType: `${root}/dropdown/getListPayType`,
dropdownPaymentType: `${root}/dropdown/paymentType`,
}
import React, {
useContext,
useEffect,
useState,
} from 'react'
import React, { useContext, useEffect, useState } from 'react'
import { Redirect, useLocation } from 'react-router-dom'
import AppContext from "../contexts/AppContext";
import AppContext from '../contexts/AppContext'
import useAuth from 'app/hooks/useAuth'
import { makeStyles, useTheme } from "@material-ui/core/styles";
import {
Backdrop,
CircularProgress,
} from "@material-ui/core";
import { connect } from "react-redux";
import { makeStyles, useTheme } from '@material-ui/core/styles'
import KEY from 'app/assets/Key'
import localStorageService from 'app/services/localStorageService'
const useStyles = makeStyles((theme) => ({
import { Backdrop, CircularProgress } from '@material-ui/core'
import { connect } from 'react-redux'
const useStyles = makeStyles((theme) => ({
backdrop: {
zIndex: theme.zIndex.drawer + 1,
color: "#fff",
color: '#fff',
},
}));
}))
const getUserRoleAuthStatus = (pathname, user) => {
const token = localStorageService.getItem(KEY.API_TOKEN)
if (token) {
//return true
if(pathname==='/dashboard/default' || pathname==='/' || pathname=="/dashboard" || pathname=="/my-profile" || pathname=="/change-password" )
if (
pathname === '/dashboard/default' ||
pathname === '/' ||
pathname == '/dashboard' ||
pathname == '/my-profile' ||
pathname == '/change-password'
)
return true
if(user){
if(user.is_sysadmin){
if (user) {
if (user.is_sysadmin) {
return true
}else{
let flag=false;
user.listPath.map(e=>{
if(e==pathname)
flag=true
} else {
let flag = false
user.listPath.map((e) => {
if (e == pathname) flag = true
})
return flag
}
}
return false
} else {
return false
}
}
};
const AuthGuard = ({ children,modalLoading }) => {
const classes = useStyles();
const {
isAuthenticated,
user
} = useAuth()
const AuthGuard = ({ children, modalLoading }) => {
const classes = useStyles()
const { isAuthenticated, user } = useAuth()
const [previouseRoute, setPreviousRoute] = useState(null)
const { pathname } = useLocation()
const isUserRoleAuthenticated = getUserRoleAuthStatus(pathname, user);
let authenticated = isAuthenticated && isUserRoleAuthenticated;
const isUserRoleAuthenticated = getUserRoleAuthStatus(pathname, user)
let authenticated = isAuthenticated && isUserRoleAuthenticated
// IF YOU NEED ROLE BASED AUTHENTICATION,
// UNCOMMENT ABOVE TWO LINES, getUserRoleAuthStatus METHOD AND user VARIABLE
// AND COMMENT OUT BELOW LINE
// let authenticated = isAuthenticated
useEffect(() => {
if (previouseRoute !== null) setPreviousRoute(pathname)
}, [pathname, previouseRoute])
if (authenticated)
return <>
return (
<>
<Backdrop
className={classes.backdrop}
open={modalLoading.isVisible}
......@@ -78,6 +75,7 @@ const AuthGuard = ({ children,modalLoading }) => {
</Backdrop>
{children}
</>
)
else {
return (
<Redirect
......@@ -90,11 +88,9 @@ const AuthGuard = ({ children,modalLoading }) => {
}
}
const mapStateToProps = (state) => {
return {
modalLoading: state.ModalLoadingReducer,
};
};
export default connect(mapStateToProps, {})(AuthGuard);
\ No newline at end of file
}
}
export default connect(mapStateToProps, {})(AuthGuard)
......@@ -372,18 +372,18 @@ const SimpleForm = (props) => {
name: '30 ngày',
value: 30,
},
{
name: '90 ngày',
value: 90,
},
{
name: '180 ngày',
value: 180,
},
{
name: '1 năm',
value: 365,
},
// {
// name: '90 ngày',
// value: 90,
// },
// {
// name: '180 ngày',
// value: 180,
// },
// {
// name: '1 năm',
// value: 365,
// },
].map((e) => (
<MenuItem value={e.value}>
{e.name}
......
......@@ -65,6 +65,7 @@ const ToolNotificate = (props) => {
res = await listTransReconciliation({
page_no: 0,
page_size: pageSize,
text: searchDebount,
date_from: startDate ? convertDate(startDate) : null,
date_to: endDate ? convertDate(endDate) : null,
product_code: product ? product : null,
......@@ -76,6 +77,7 @@ const ToolNotificate = (props) => {
res = await listTransReconciliation({
page_no: pageIndex + 1,
page_size: pageSize,
text: searchDebount,
date_from: startDate ? convertDate(startDate) : null,
date_to: endDate ? convertDate(endDate) : null,
product_code: product ? product : null,
......@@ -90,11 +92,6 @@ const ToolNotificate = (props) => {
const newList = res.data.data?.data?.map((e, i) => {
return {
...e,
statusReconciliationName: renderStatusName(
e?.statusReconciliation
),
index: i + 1 + pageIndex * pageSize,
}
})
......
......@@ -35,7 +35,7 @@ const columns = [
},
{
id: 'order_code',
label: 'Mã hoá đơn',
label: 'Mã giao dịch',
align: 'left',
minWidth: 160,
},
......@@ -197,15 +197,15 @@ function TableList(props) {
style={{
padding: 5,
backgroundColor: renderStatusBg(
row?.statusReconciliation
row?.status_reconciliation
),
color: renderStatusColor(
row?.statusReconciliation
row?.status_reconciliation
),
borderRadius: 10,
}}
>
{row?.statusReconciliationName}
{row?.status_reconciliation_name}
</Typography>
</TableCell>
</TableRow>
......
......@@ -24,6 +24,7 @@ const ToolNotificate = (props) => {
const [listGroup, setListGroup] = useState([])
const [group, setGroup] = useState()
const { user } = useAuth()
const [type, setType] = useState()
const [data, setData] = useState([])
......@@ -54,7 +55,7 @@ const ToolNotificate = (props) => {
page_no: 0,
page_size: pageSize,
status,
// type: 3,
type: type ? type : 0,
})
} else {
res = await listProviderSetting({
......@@ -62,7 +63,7 @@ const ToolNotificate = (props) => {
page_no: pageIndex + 1,
page_size: pageSize,
status,
// type: 3,
type: type ? type : 0,
})
}
......@@ -88,7 +89,7 @@ const ToolNotificate = (props) => {
}, [pageIndex])
useEffect(() => {
getData(true)
}, [searchDebount, status, store, group])
}, [searchDebount, status, store, group, type])
const removeItem = async (id) => {
// props.showLoading()
......@@ -132,6 +133,8 @@ const ToolNotificate = (props) => {
listGroup={listGroup}
group={group}
setGroup={setGroup}
type={type}
setType={setType}
/>
)
}
......
......@@ -28,6 +28,8 @@ import {
convertDate,
convertTimeApi,
replaceItemInArray,
toPriceVnd,
toPriceVndInput,
} from 'app/config/Function'
import { connect } from 'react-redux'
......@@ -137,7 +139,7 @@ const SimpleForm = (props) => {
if (res.data.code == 200) {
history.push('/reconciliation/setting')
if (res.data.code == 200) {
toast.success('Cập nhật nhà cung cấp thiết bị thành công!', {
toast.success('Cập nhật cấu hình đối soát thành công!', {
theme: 'colored',
})
}
......@@ -172,7 +174,13 @@ const SimpleForm = (props) => {
event.target.name == 'money' ||
event.target.name == 'length'
) {
const inputValue = event.target.value
let inputValue
if (event.target.name == 'money') {
inputValue = event.target.value.split('.').join('')
} else {
inputValue = event.target.value
}
console.log('inputValue', inputValue)
// Kiểm tra nếu input là số nguyên hoặc số thập phân
const regex = /^-?\d*\.?\d*$/
if (regex.test(inputValue)) {
......@@ -180,7 +188,7 @@ const SimpleForm = (props) => {
let newList = [...listMoney]
const temp = {
...listMoney[index],
[event.target.name]: event.target.value,
[event.target.name]: inputValue,
}
newList = replaceItemInArray(newList, index, temp)
setListMoney(newList)
......@@ -306,11 +314,11 @@ const SimpleForm = (props) => {
onChange={handleChange}
type="text"
name="percent"
value={percent || ''}
validators={['required']}
validators={['isFloat']}
errorMessages={[
'Không được để trống trường này',
'Trường này phải nhập số ',
]}
value={percent || ''}
/>
</Grid>
) : (
......@@ -377,9 +385,9 @@ const SimpleForm = (props) => {
label="Hoa hồng *"
fullWidth
name="money"
value={
value={toPriceVndInput(
listMoney[index].money
}
)}
variant="outlined"
InputProps={{
endAdornment: (
......@@ -431,16 +439,12 @@ const SimpleForm = (props) => {
<Grid xs={6} sm={6} item>
<SelectValidator
variant={'outlined'}
label={'Chu kỳ đối soát *'}
label={'Chu kỳ đối soát'}
className="mb-4 w-full"
value={reconciliationCycle || ''}
displayEmpty
name="reconciliationCycle"
onChange={handleChange}
validators={['required']}
errorMessages={[
'Không được để trống trường này',
]}
>
{[
{
......
......@@ -32,14 +32,8 @@ function CustomerView(props) {
pageIndex,
totalRecords,
status,
setStatus,
store,
setStore,
listDrop,
listGroup,
group,
setGroup,
type,
setType,
} = props
const handleChange = (event) => {
setAge(event.target.value)
......@@ -93,7 +87,44 @@ function CustomerView(props) {
}}
/>
</Grid>
<Grid item lg={4} md={4} sm={4} xs={4}>
<FormControl variant="outlined" fullWidth>
<InputLabel htmlFor="outlined-age-native-simple">
Loi hoa hng
</InputLabel>
<Select
label="Loại hoa hồng"
value={type}
onChange={(e) => setType(e.target.value)}
inputProps={{
name: 'age',
id: 'outlined-age-native-simple',
}}
>
<MenuItem value="">
<em>Tt c</em>
</MenuItem>
{[
{
name: 'Số tiền cố định',
value: 2,
id: 2,
},
{
name: 'Theo phần trăm',
value: 1,
id: 1,
},
].map((e) => (
<MenuItem value={e.id}>
{e.name}
</MenuItem>
))}
</Select>
</FormControl>
</Grid>
</Grid>
{/* {checkRole(user, '/reconciliation/setting/create') ? (
<Link to="/reconciliation/setting/create">
<Button
......
......@@ -220,27 +220,11 @@ const SimpleForm = (props) => {
color: '#000000',
fontSize: 16,
marginBottom: 10,
height: 65,
}}
>
{idPaymentPartner}
</Typography>
<Typography
style={{
color: '#344054',
fontSize: 14,
}}
>
Người to
</Typography>
<Typography
style={{
color: '#000000',
fontSize: 14,
}}
>
{create_by}
</Typography>
</Card>
</Grid>
<Grid item lg={4} md={4} sm={6} xs={6}>
......
......@@ -56,8 +56,13 @@ const DialogActions = withStyles((theme) => ({
}))(MuiDialogActions)
const CustomizedDialogs = (props) => {
const { onSelectCustomer, cusomterSelect, idPaymentPartner, onAddTrans } =
props
const {
onSelectCustomer,
cusomterSelect,
idPaymentPartner,
onAddTrans,
id,
} = props
const [open, setOpen] = useState(false)
const handleClickOpen = () => {
......@@ -112,6 +117,7 @@ const CustomizedDialogs = (props) => {
onAddTrans(list)
handleClose()
}}
id={id}
/>
</DialogContent>
</Dialog>
......
......@@ -8,10 +8,16 @@ 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 {
dropdownMerchant,
dropdownStoreNew,
dropdownPaymentType,
} from 'app/apis/Functions/dropdown'
import useAuth from 'app/hooks/useAuth'
const ToolNotificate = (props) => {
const { customSelect, handleClose, idPaymentPartner, onAddTrans } = props
const { customSelect, handleClose, idPaymentPartner, onAddTrans, id } =
props
const [listSelected, setListSelected] = useState([])
const [txtSearch, setTxtSearch] = useState('')
const [applications, setApplications] = useState('')
......@@ -26,6 +32,15 @@ const ToolNotificate = (props) => {
const [data, setData] = useState([])
const [type, setType] = useState()
const [listType, setListType] = useState([])
const [store, setStore] = useState()
const [listStore, setListStore] = useState([])
const [listMedthodPay, setListMethodPay] = useState([])
const { user } = useAuth()
useEffect(() => {
getDropdownStore()
}, [])
const changeDateRange = (start, end) => {
setStartDate(start)
......@@ -47,9 +62,9 @@ const ToolNotificate = (props) => {
payment_gate_code: props?.idPaymentPartner,
order_code: searchDebount,
type_payment: type || type,
reconciliation_id: id,
})
console.log('res.data', res.data)
props.hideLoading()
if (res.data.code == 200 && res.data.data) {
const newList = res.data.data?.map((e, i) => {
......@@ -81,6 +96,26 @@ const ToolNotificate = (props) => {
}
}
const getDropdownStore = async () => {
const res = await dropdownStoreNew()
if (res.data.code == 200 && res.data.data) {
const newList = res.data.data.map((e) => {
return { ...e, name: e.store_name }
})
setListStore(newList)
}
const res2 = await dropdownPaymentType()
if (res2.data.code == 200 && res2.data.data) {
const newList = res2.data.data.map((e) => {
return { ...e, id: e.code }
})
setListMethodPay(newList)
}
}
return (
<LogAuth
data={data}
......@@ -100,6 +135,10 @@ const ToolNotificate = (props) => {
listSelected={listSelected}
setListSelected={setListSelected}
onAdd={onAdd}
store={store}
setStore={setStore}
listStore={listStore}
listMedthodPay={listMedthodPay}
/>
)
}
......
......@@ -48,6 +48,7 @@ function CustomerView(props) {
listSelected,
setListSelected,
onAdd,
listMedthodPay,
} = props
const handleChange = (event) => {
......@@ -94,20 +95,31 @@ 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) => (
{listMedthodPay.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>
<Select
label="Cây xăng"
value={store}
onChange={(e) => setStore(e.target.value)}
inputProps={{
name: 'age',
id: 'outlined-age-native-simple',
}}
>
<MenuItem value="">
<em>Tt c</em>
</MenuItem>
{listStore.map((e) => (
<MenuItem value={e.id}>{e.name}</MenuItem>
))}
</Select>
......
......@@ -45,7 +45,7 @@ const ToolNotificate = (props) => {
if (init) {
setPageIndex(0)
res = await listSheetReconciliation({
order_code: searchDebount,
text: searchDebount,
page_no: 0,
page_size: pageSize,
date_from: startDate ? convertDate(startDate) : null,
......@@ -55,7 +55,7 @@ const ToolNotificate = (props) => {
})
} else {
res = await listSheetReconciliation({
order_code: searchDebount,
text: searchDebount,
page_no: pageIndex + 1,
page_size: pageSize,
from_date: startDate ? convertDate(startDate) : null,
......
......@@ -204,6 +204,7 @@ const ToolNotificate = (props) => {
removeItem={removeItem}
onAddTrans={onAddTrans}
total={total}
id={props.id}
/>
)
}
......
......@@ -37,7 +37,7 @@ const columns = [
{
id: 'order_code',
label: 'Mã hoá đơn',
label: 'Mã giao dịch',
align: 'left',
minWidth: 170,
},
......
......@@ -50,6 +50,7 @@ function CustomerView(props) {
removeItem,
onAddTrans,
total,
id,
} = props
const handleChange = (event) => {
......@@ -104,6 +105,7 @@ function CustomerView(props) {
<DialogTrans
idPaymentPartner={idPaymentPartner}
onAddTrans={onAddTrans}
id={id}
/>
</Grid>
) : null}
......
......@@ -137,7 +137,7 @@ function TableList(props) {
))}
<TableCell
style={{
width: 100,
width: 120,
backgroundColor: colors.headerTable,
}}
>
......
......@@ -74,8 +74,6 @@ const SimpleForm = (props) => {
props.showLoading()
const res = await updateSheetReconciliation({
...newValue,
status: 1,
})
props.hideLoading()
......@@ -102,10 +100,7 @@ const SimpleForm = (props) => {
}
console.log('state', state)
const { code, idPaymentPartner, note } = state
console.log(
'location.state?.idPaymentPartner',
location.state?.idPaymentPartner
)
console.log('location.state', location.state.id)
return (
<div className="m-sm-30">
<div className="mb-sm-30">
......@@ -219,6 +214,7 @@ const SimpleForm = (props) => {
idPaymentPartner={
location.state?.idPaymentPartner
}
id={location.state.id}
/>
</Grid>
</Grid>
......
......@@ -99,17 +99,17 @@ function CustomerView(props) {
<em>Tt c</em>
</MenuItem>
{[
{
name: 'Nháp',
value: 1,
id: 1,
},
// {
// name: 'Nháp',
// value: 1,
// id: 1,
// },
{
name: 'Chưa đối soát',
value: 2,
id: 2,
},
// {
// name: 'Chưa đối soát',
// value: 2,
// id: 2,
// },
{
name: 'Đang đối soát',
value: 3,
......
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