Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
CmsPetrolPay
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
11
Issues
11
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Giang Tran
CmsPetrolPay
Commits
1be034e5
Commit
1be034e5
authored
Sep 12, 2024
by
tdgiang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update code
parent
7d28f6b0
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
281 additions
and
57 deletions
+281
-57
App.css
src/app/App.css
+1
-0
Function.js
src/app/config/Function.js
+8
-0
Update.js
src/app/views/Reconciliation/Setting/Update.js
+270
-55
View.js
src/app/views/Reconciliation/Setting/View.js
+2
-2
No files found.
src/app/App.css
View file @
1be034e5
...
...
@@ -61,4 +61,5 @@ p.MuiFormHelperText-root.MuiFormHelperText-contained.Mui-error.MuiFormHelperText
.MuiInputBase-input.Mui-disabled
{
color
:
black
!important
;
background-color
:
#f6f6f6
!important
;
}
src/app/config/Function.js
View file @
1be034e5
...
...
@@ -147,6 +147,14 @@ export const convertTimeApi = (date) => {
const
time
=
moment
(
temp
).
format
(
'YYYY-MM-DD'
)
return
time
}
export
function
replaceItemInArray
(
array
,
index
,
newValue
)
{
if
(
index
>=
0
&&
index
<
array
.
length
)
{
array
[
index
]
=
newValue
}
else
{
console
.
log
(
'Index out of bounds'
)
}
return
array
}
export
const
convertDate
=
(
date
)
=>
{
const
time
=
moment
(
date
).
format
(
'DD/MM/YYYY'
)
...
...
src/app/views/Reconciliation/Setting/Update.js
View file @
1be034e5
...
...
@@ -11,6 +11,12 @@ import {
FormControlLabel
,
Checkbox
,
Typography
,
RadioGroup
,
Radio
,
IconButton
,
TextField
,
Icon
,
InputAdornment
,
}
from
'@material-ui/core'
import
{
showLoading
,
hideLoading
}
from
'app/redux/actions/loadingAction'
import
{
toast
}
from
'react-toastify'
...
...
@@ -21,6 +27,7 @@ import {
encryString
,
convertDate
,
convertTimeApi
,
replaceItemInArray
,
}
from
'app/config/Function'
import
{
connect
}
from
'react-redux'
...
...
@@ -32,6 +39,13 @@ const SimpleForm = (props) => {
const
location
=
useLocation
()
const
[
image
,
setImage
]
=
useState
()
const
{
user
}
=
useAuth
()
const
[
type
,
setType
]
=
useState
(
'percent'
)
const
[
listMoney
,
setListMoney
]
=
useState
([
{
condition
:
0
,
money
:
0
,
},
])
const
[
date
,
setDate
]
=
useState
(
null
)
const
{
t
}
=
useTranslation
()
...
...
@@ -83,8 +97,69 @@ const SimpleForm = (props) => {
[
event
.
target
.
name
]:
event
.
target
.
value
,
})
}
const
handleChangeList
=
(
event
,
index
)
=>
{
event
.
persist
()
if
(
event
.
target
.
name
==
'condition'
||
event
.
target
.
name
==
'money'
||
event
.
target
.
name
==
'length'
)
{
console
.
log
(
'hêlo'
,
event
.
target
.
name
)
console
.
log
(
'value'
,
event
.
target
.
value
)
const
inputValue
=
event
.
target
.
value
// 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
))
{
console
.
log
(
'run'
,
inputValue
)
let
newList
=
[...
listMoney
]
const
temp
=
{
...
listMoney
[
index
],
[
event
.
target
.
name
]:
event
.
target
.
value
,
}
newList
=
replaceItemInArray
(
newList
,
index
,
temp
)
setListMoney
(
newList
)
}
else
{
let
newList
=
[...
listMoney
]
setListMoney
(
newList
)
}
}
else
{
let
newList
=
[...
listMoney
]
const
temp
=
{
...
listMoney
[
index
],
[
event
.
target
.
name
]:
event
.
target
.
value
,
}
newList
=
replaceItemInArray
(
newList
,
index
,
temp
)
setListMoney
(
newList
)
}
}
const
onAdd
=
()
=>
{
setListMoney
(
listMoney
.
concat
([
{
condition
:
0
,
money
:
0
,
},
])
)
}
const
{
provider_code
,
provider_name
,
phone
,
email
,
address
}
=
state
const
deleteTank
=
(
index
)
=>
{
if
(
listMoney
.
length
>
1
)
{
let
arr
=
[...
listMoney
]
arr
.
splice
(
index
,
1
)
setListMoney
(
arr
)
toast
.
success
(
'Xoá điều kiện thành công!'
,
{
theme
:
'colored'
,
})
}
else
{
toast
.
warning
(
'Phải có ít nhất một điều kiện!'
,
{
theme
:
'colored'
,
})
}
}
const
{
provider_code
,
provider_name
,
phone
,
email
,
merchant_id
}
=
state
return
(
<
div
className
=
"m-sm-30"
>
<
div
className
=
"mb-sm-30"
>
...
...
@@ -106,7 +181,7 @@ const SimpleForm = (props) => {
<
TextValidator
variant
=
"outlined"
className
=
"mb-4 w-full"
label
=
"
Mã nhà cung cấp *
"
label
=
"
Đối tác
"
onChange
=
{
handleChange
}
type
=
"text"
name
=
"provider_code"
...
...
@@ -118,71 +193,211 @@ const SimpleForm = (props) => {
]}
/
>
<
/Grid
>
<
Grid
item
lg
=
{
6
}
md
=
{
6
}
sm
=
{
12
}
xs
=
{
12
}
>
<
TextValidator
variant
=
"outlined"
className
=
"mb-4 w-full"
label
=
"Tên nhà cung cấp *"
onChange
=
{
handleChange
}
type
=
"text"
name
=
"provider_name"
value
=
{
provider_name
||
''
}
validators
=
{[
'required'
]}
errorMessages
=
{[
'Không được để trống trường này'
,
]}
/
>
<
Grid
style
=
{{
alignItems
:
'center'
}}
row
item
lg
=
{
6
}
md
=
{
6
}
sm
=
{
12
}
xs
=
{
12
}
>
<
RadioGroup
row
value
=
{
type
}
onChange
=
{(
event
)
=>
{
setType
(
event
.
target
.
value
)
}}
>
<
FormControlLabel
value
=
{
'percent'
}
control
=
{
<
Radio
/>
}
label
=
"Theo %"
style
=
{{
marginRight
:
100
,
}}
/
>
<
FormControlLabel
value
=
{
'cost'
}
control
=
{
<
Radio
/>
}
label
=
"Số tiền cố định"
/>
<
/RadioGroup
>
<
/Grid
>
<
Grid
item
lg
=
{
6
}
md
=
{
6
}
sm
=
{
12
}
xs
=
{
12
}
>
<
TextValidator
variant
=
"outlined"
{
type
==
'percent'
?
(
<
Grid
item
lg
=
{
6
}
md
=
{
6
}
sm
=
{
12
}
xs
=
{
12
}
>
<
TextValidator
variant
=
"outlined"
className
=
"mb-4 w-full"
label
=
"Giá trị (%)"
onChange
=
{
handleChange
}
type
=
"text"
name
=
"provider_code"
value
=
{
provider_code
||
''
}
validators
=
{[
'required'
]}
errorMessages
=
{[
'Không được để trống trường này'
,
]}
/
>
<
/Grid
>
)
:
(
<
Grid
item
lg
=
{
12
}
md
=
{
12
}
sm
=
{
12
}
xs
=
{
12
}
>
{
listMoney
.
map
((
item
,
index
)
=>
(
<
Grid
lg
=
{
12
}
md
=
{
12
}
sm
=
{
12
}
xs
=
{
12
}
container
spacing
=
{
3
}
>
<
Grid
item
lg
=
{
5
}
md
=
{
5
}
sm
=
{
5
}
xs
=
{
5
}
>
<
TextField
label
=
"Điều kiện"
fullWidth
disabled
=
{
index
==
0
?
true
:
false
}
InputProps
=
{{
style
:
{
backgroundColor
:
index
==
0
?
'#f6f6f6'
:
'#fff'
,
},
startAdornment
:
(
<
InputAdornment
position
=
"start"
>
>=
<
/InputAdornment
>
),
}}
variant
=
"outlined"
name
=
"condition"
value
=
{
listMoney
[
index
]
.
condition
}
onChange
=
{(
event
)
=>
handleChangeList
(
event
,
index
)
}
/
>
<
/Grid
>
<
Grid
item
lg
=
{
5
}
md
=
{
5
}
sm
=
{
5
}
xs
=
{
5
}
>
<
TextField
label
=
"Hoa hồng *"
fullWidth
name
=
"money"
value
=
{
listMoney
[
index
].
money
}
variant
=
"outlined"
InputProps
=
{{
endAdornment
:
(
<
InputAdornment
position
=
"end"
>
VND
<
/InputAdornment
>
),
}}
onChange
=
{(
event
)
=>
handleChangeList
(
event
,
index
)
}
/
>
<
/Grid
>
<
Grid
item
lg
=
{
2
}
md
=
{
2
}
sm
=
{
2
}
xs
=
{
2
}
>
<
IconButton
onClick
=
{()
=>
{
deleteTank
(
index
)
}}
color
=
"error"
>
<
Icon
color
=
"error"
>
cancel
<
/Icon
>
<
/IconButton
>
<
/Grid
>
<
/Grid
>
))}
<
Button
onClick
=
{
onAdd
}
variant
=
"contained"
color
=
"primary"
>
<
Icon
style
=
{{
color
:
'white'
}}
>
add_circle
<
/Icon
>
<
/Button
>
<
/Grid
>
)}
<
Grid
xs
=
{
6
}
sm
=
{
6
}
item
>
<
SelectValidator
variant
=
{
'outlined'
}
label
=
{
'Chu kỳ đối soát *'
}
className
=
"mb-4 w-full"
label
=
"Số điện thoại *"
value
=
{
merchant_id
||
''
}
displayEmpty
name
=
"merchant_id"
onChange
=
{
handleChange
}
type
=
"text"
name
=
"phone"
value
=
{
phone
||
''
}
validators
=
{[
'required'
,
'isNumber'
,
'minStringLength:10'
,
'maxStringLength:15'
,
]}
validators
=
{[
'required'
]}
errorMessages
=
{[
'Không được để trống trường này'
,
'Trường này phải nhập số '
,
'Số điện thoại phải có ít nhất 10 chữ số'
,
'Số điện thoại nhiều nhất chỉ có 15 chữ số'
,
]}
/
>
>
{[].
map
((
e
)
=>
(
<
MenuItem
value
=
{
e
.
id
}
>
{
e
.
name
}
<
/MenuItem
>
))}
<
/SelectValidator
>
<
/Grid
>
<
Grid
item
lg
=
{
6
}
md
=
{
6
}
sm
=
{
12
}
xs
=
{
12
}
>
<
TextValidator
variant
=
"outlined"
<
Grid
xs
=
{
6
}
sm
=
{
6
}
item
>
<
SelectValidator
variant
=
{
'outlined'
}
label
=
{
'Thời điểm đối soát *'
}
className
=
"mb-4 w-full"
label
=
"Email *"
value
=
{
merchant_id
||
''
}
displayEmpty
name
=
"merchant_id"
onChange
=
{
handleChange
}
type
=
"text"
name
=
"email"
value
=
{
email
||
''
}
validators
=
{[
'required'
,
'isEmail'
]}
validators
=
{[
'required'
]}
errorMessages
=
{[
'Không được để trống trường này'
,
'Email không hợp lệ'
,
]}
/
>
<
/Grid
>
<
Grid
item
lg
=
{
6
}
md
=
{
6
}
sm
=
{
12
}
xs
=
{
12
}
>
<
TextValidator
variant
=
"outlined"
className
=
"mb-4 w-full"
label
=
"Địa chỉ"
onChange
=
{
handleChange
}
type
=
"text"
name
=
"address"
value
=
{
address
||
''
}
/
>
>
{[].
map
((
e
)
=>
(
<
MenuItem
value
=
{
e
.
id
}
>
{
e
.
name
}
<
/MenuItem
>
))}
<
/SelectValidator
>
<
/Grid
>
<
/Grid
>
<
Grid
...
...
src/app/views/Reconciliation/Setting/View.js
View file @
1be034e5
...
...
@@ -128,7 +128,7 @@ function CustomerView(props) {
<
/FormControl
>
<
/Grid
>
<
/Grid
>
{
checkRole
(
user
,
'/reconciliation/setting/create'
)
?
(
{
/* {
checkRole(user, '/reconciliation/setting/create') ? (
<Link to="/reconciliation/setting/create">
<Button
variant="contained"
...
...
@@ -137,7 +137,7 @@ function CustomerView(props) {
<span className={'text-primary'}>Thêm mới</span>
</Button>
</Link>
)
:
null
}
) : null}
*/
}
<
/Grid
>
<
Table
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment