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
e108ebbb
Commit
e108ebbb
authored
Jan 18, 2024
by
tdgiang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update code
parent
52744883
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
382 additions
and
110 deletions
+382
-110
dropdown.js
src/app/apis/Functions/dropdown.js
+10
-0
url.js
src/app/apis/url.js
+1
-0
CreateField.jsx
src/app/components/dialog/CreateField.jsx
+47
-59
CreateFountain.jsx
src/app/components/dialog/CreateFountain.jsx
+227
-0
Create.js
src/app/views/GasStation/Create.js
+97
-51
No files found.
src/app/apis/Functions/dropdown.js
View file @
e108ebbb
...
...
@@ -54,3 +54,13 @@ export const dropdownMerchant = async (body) =>
GetData
(
url
.
dropdownMerchant
,
body
)
.
then
((
res
)
=>
res
)
.
catch
((
err
)
=>
null
)
export
const
dropdownProduct
=
async
(
body
)
=>
GetData
(
url
.
dropdownProduct
,
body
)
.
then
((
res
)
=>
res
)
.
catch
((
err
)
=>
null
)
export
const
dropdownProcutByType
=
async
(
id
)
=>
GetData
(
`
${
url
.
dropdownProcutByType
}
/
${
id
}
`
,
{})
.
then
((
res
)
=>
res
)
.
catch
((
err
)
=>
null
)
src/app/apis/url.js
View file @
e108ebbb
...
...
@@ -100,4 +100,5 @@ export default {
dropdownProduct
:
`
${
root
}
/dropdown/productList`
,
dropdownStore
:
`
${
root
}
/dropdown/listStore`
,
dropdownMerchant
:
`
${
root
}
/dropdown/listmerchant`
,
dropdownProcutByType
:
`
${
root
}
/dropdown/productListByType`
,
}
src/app/components/dialog/CreateField.jsx
View file @
e108ebbb
import
React
,
{
useState
,
useEffect
,
use
}
from
"react"
;
import
React
,
{
useState
,
useEffect
,
use
}
from
'react'
import
{
Button
,
FormControl
,
...
...
@@ -7,75 +7,63 @@ import {
Select
,
TextField
,
Typography
,
DialogActions
,
Dialog
,
DialogContent
,
DialogContentText
,
DialogTitle
,
IconButton
,
Icon
,
Tooltip
DialogActions
,
Dialog
,
DialogContent
,
DialogContentText
,
DialogTitle
,
IconButton
,
Icon
,
Tooltip
,
}
from
'@material-ui/core'
import
{
toast
}
from
'react-toastify'
import
{
useTranslation
}
from
'react-i18next'
import
{
hideLoading
,
showLoading
}
from
'app/redux/actions/loadingAction'
import
{
connect
}
from
'react-redux'
import
{
toast
}
from
'react-toastify'
import
{
useTranslation
}
from
'react-i18next'
import
{
hideLoading
,
showLoading
}
from
'app/redux/actions/loadingAction'
import
{
connect
}
from
'react-redux'
function
FormDialog
(
props
)
{
function
FormDialog
(
props
)
{
const
{
t
}
=
useTranslation
()
const
{
open
,
handleClose
,
data
,
onAgree
}
=
props
const
{
open
,
handleClose
,
data
,
onAgree
}
=
props
const
[
name
,
setName
]
=
useState
()
const
[
amount
,
setamount
]
=
useState
()
return
(
<
Dialog
open=
{
open
}
onClose=
{
handleClose
}
aria
-
labelledby=
"form-dialog-title"
>
<
DialogTitle
id=
"form-dialog-title"
>
Cập nhật CTV
</
DialogTitle
>
<
DialogContent
>
<
Dialog
open=
{
open
}
onClose=
{
handleClose
}
aria
-
labelledby=
"form-dialog-title"
>
<
DialogTitle
id=
"form-dialog-title"
>
Thêm trụ xăng
</
DialogTitle
>
<
DialogContent
>
<
TextField
style=
{
{
marginBttom
:
20
,
minWidth
:
400
}
}
variant=
"outlined"
autoFocus
margin=
"dense"
label=
"Lời nhuận chia sẻ %"
fullWidth
value=
{
amount
||
''
}
onChange=
{
(
event
)
=>
setamount
(
event
.
target
.
value
)
}
/>
</
DialogContent
>
<
DialogActions
>
<
Button
color=
"secondary"
onClick=
{
handleClose
}
>
Thoát
</
Button
>
<
Button
onClick=
{
onAgree
}
color=
"primary"
>
Đồng ý
</
Button
>
</
DialogActions
>
</
Dialog
>
style=
{
{
marginBttom
:
20
,
minWidth
:
400
}
}
variant=
"outlined"
autoFocus
margin=
"dense"
label=
"Tên trụ *"
fullWidth
value=
{
name
||
''
}
onChange=
{
(
event
)
=>
setName
(
event
.
target
.
value
)
}
/>
</
DialogContent
>
<
DialogActions
>
<
Button
color=
"secondary"
onClick=
{
handleClose
}
>
Thoát
</
Button
>
<
Button
onClick=
{
()
=>
{
onAgree
(
name
)
setName
(
''
)
}
}
color=
"primary"
>
Đồng ý
</
Button
>
</
DialogActions
>
</
Dialog
>
)
}
const
mapStateToProps
=
(
state
)
=>
{
return
{}
}
...
...
src/app/components/dialog/CreateFountain.jsx
0 → 100644
View file @
e108ebbb
import
React
,
{
useState
,
useEffect
}
from
'react'
import
{
Button
,
FormControl
,
Grid
,
InputLabel
,
Select
,
TextField
,
Typography
,
Radio
,
FormControlLabel
,
DialogActions
,
Dialog
,
DialogContent
,
DialogContentText
,
DialogTitle
,
IconButton
,
Icon
,
Tooltip
,
RadioGroup
,
MenuItem
,
}
from
'@material-ui/core'
import
{
toast
}
from
'react-toastify'
import
{
useTranslation
}
from
'react-i18next'
import
{
KeyboardDatePicker
}
from
'@material-ui/pickers'
import
{
convertDate
,
toPriceVndInput
,
convertViToEn
,
}
from
'app/config/Function'
import
{
TextValidator
,
ValidatorForm
,
SelectValidator
,
}
from
'react-material-ui-form-validator'
import
{
dropdownProductType
,
dropdownProcutByType
}
from
'app/apis/Functions/dropdown'
export
default
function
FormDialog
({
onCreate
})
{
const
[
open
,
setOpen
]
=
React
.
useState
(
false
)
const
{
t
}
=
useTranslation
()
const
[
state
,
setState
]
=
useState
({})
const
[
listType
,
setListType
]
=
useState
([])
const
[
listProduct
,
setListProduct
]
=
useState
([])
const
[
product
,
setProduct
]
=
useState
()
const
[
type
,
setType
]
=
useState
()
useEffect
(()
=>
{
setProduct
()
if
(
type
){
getDropdownProduct
(
type
)
}
},[
type
])
useEffect
(()
=>
{
getData
()
},
[])
const
getData
=
async
()
=>
{
const
res
=
await
dropdownProductType
({})
if
(
res
.
data
.
code
==
200
&&
res
.
data
.
data
)
{
const
newList
=
res
.
data
.
data
.
map
((
e
)
=>
{
return
{
...
e
,
name
:
e
.
type_name
,
value
:
e
.
id
}
})
setListType
(
newList
)
}
else
{
toast
.
error
(
'Lấy giữ liệu thất bại !'
,
{
theme
:
'colored'
,
})
}
}
const
getDropdownProduct
=
async
(
type
)
=>
{
const
res
=
await
dropdownProcutByType
(
type
)
if
(
res
.
data
.
code
==
200
&&
res
.
data
.
data
)
{
const
newList
=
res
.
data
.
data
.
map
((
e
)
=>
{
return
{
...
e
,
name
:
e
.
product_name
,
value
:
e
.
id
}
})
setListProduct
(
newList
)
}
else
{
toast
.
error
(
'Lấy giữ liệu thất bại !'
,
{
theme
:
'colored'
,
})
}
}
function
handleClickOpen
()
{
setOpen
(
true
)
}
function
handleClose
()
{
setOpen
(
false
)
}
const
handleSubmit
=
async
(
value
)
=>
{
console
.
log
(
'state'
,
state
)
onCreate
({...
state
,
type
})
}
const
handleChange
=
(
event
)
=>
{
event
.
persist
()
setState
({
...
state
,
[
event
.
target
.
name
]:
event
.
target
.
value
,
})
}
const
{
product_id
,
name
,
code
}
=
state
return
(
<>
<
Tooltip
title=
"Chuyển tiền đáo hạn"
>
<
IconButton
onClick=
{
handleClickOpen
}
>
<
Icon
style=
{
{
color
:
'#4caf50'
}
}
>
add_circle
</
Icon
>
</
IconButton
>
</
Tooltip
>
<
Dialog
open=
{
open
}
onClose=
{
handleClose
}
aria
-
labelledby=
"form-dialog-title"
>
<
DialogTitle
id=
"form-dialog-title"
>
Thêm vòi xăng
</
DialogTitle
>
<
DialogContent
>
<
Grid
container
spacing=
{
2
}
>
<
Grid
item
lg=
{
12
}
md=
{
12
}
sm=
{
12
}
xs=
{
12
}
>
<
TextValidator
className=
"mb-4 w-full"
label=
"Tên vòi xăng *"
onChange=
{
handleChange
}
variant=
"outlined"
type=
"text"
name=
"name"
value=
{
name
||
''
}
validators=
{
[
'required'
]
}
errorMessages=
{
[
'Không được để trống trường này'
,
]
}
/>
</
Grid
>
<
Grid
item
lg=
{
12
}
md=
{
12
}
sm=
{
12
}
xs=
{
12
}
>
<
TextValidator
className=
"mb-4 w-full"
label=
"Mã vòi xăng *"
onChange=
{
handleChange
}
variant=
"outlined"
type=
"text"
name=
"code"
value=
{
code
||
''
}
validators=
{
[
'required'
]
}
errorMessages=
{
[
'Không được để trống trường này'
,
]
}
/>
</
Grid
>
<
Grid
item
lg=
{
12
}
md=
{
12
}
sm=
{
12
}
xs=
{
12
}
>
<
SelectValidator
variant=
{
'outlined'
}
label=
{
'Loại nguyên liệu *'
}
className=
"mb-4 w-full"
value=
{
type
||
''
}
displayEmpty
name=
"merchan_id"
onChange=
{
(
event
)
=>
{
setType
(
event
.
target
.
value
)
}
}
validators=
{
[
'required'
]
}
errorMessages=
{
[
'Không được để trống trường này'
,
]
}
>
{
listType
.
map
((
e
)
=>
(
<
MenuItem
value=
{
e
.
id
}
>
{
e
.
name
}
</
MenuItem
>
))
}
</
SelectValidator
>
</
Grid
>
<
Grid
item
lg=
{
12
}
md=
{
12
}
sm=
{
12
}
xs=
{
12
}
>
<
SelectValidator
variant=
{
'outlined'
}
label=
{
'Loại xăng *'
}
className=
"mb-4 w-full"
value=
{
product_id
||
''
}
displayEmpty
name=
"product_id"
onChange=
{
handleChange
}
validators=
{
[
'required'
]
}
errorMessages=
{
[
'Không được để trống trường này'
,
]
}
>
{
listProduct
.
map
((
e
)
=>
(
<
MenuItem
value=
{
e
.
id
}
>
{
e
.
name
}
</
MenuItem
>
))
}
</
SelectValidator
>
</
Grid
>
</
Grid
>
</
DialogContent
>
<
DialogActions
>
<
Button
color=
"secondary"
onClick=
{
handleClose
}
>
Thoát
</
Button
>
<
Button
onClick=
{
handleSubmit
}
color=
"primary"
>
Đồng ý
</
Button
>
</
DialogActions
>
</
Dialog
>
</>
)
}
src/app/views/GasStation/Create.js
View file @
e108ebbb
...
...
@@ -13,7 +13,7 @@ import {
Icon
,
Tooltip
,
}
from
'@material-ui/core'
import
_
from
'lodash'
import
{
createFunction
}
from
'app/apis/Functions/function'
import
{
showLoading
,
hideLoading
}
from
'app/redux/actions/loadingAction'
import
{
toast
}
from
'react-toastify'
...
...
@@ -30,44 +30,14 @@ import TableHead from '@material-ui/core/TableHead'
import
TableRow
from
'@material-ui/core/TableRow'
import
Paper
from
'@material-ui/core/Paper'
import
CreateField
from
'app/components/dialog/CreateField'
import
CreateFountain
from
'app/components/dialog/CreateFountain'
const
SimpleForm
=
(
props
)
=>
{
const
[
state
,
setState
]
=
useState
({})
const
history
=
useHistory
()
const
[
listDrop
,
setListDrop
]
=
useState
([])
const
[
listField
,
setListField
]
=
useState
([
{
field_name
:
'Trụ 1'
,
gas_olines
:
[
{
product_id
:
'BDDD46BC-2264-43EF-21B7-08DC08411423'
,
name
:
'Vòi 1'
,
code
:
'A95'
,
},
{
product_id
:
'6D3A81A6-A189-4D83-BA47-08DC0CF4D4C3'
,
name
:
'Vòi 2'
,
code
:
'A99'
,
},
],
},
{
field_name
:
'Trụ 2'
,
gas_olines
:
[
{
product_id
:
'BDDD46BC-2264-43EF-21B7-08DC08411423'
,
name
:
'Vòi 1'
,
code
:
'A95'
,
},
{
product_id
:
'6D3A81A6-A189-4D83-BA47-08DC0CF4D4C3'
,
name
:
'Vòi 2'
,
code
:
'A99'
,
},
],
},
])
const
[
openCreate
,
setOpenCreate
]
=
useState
(
false
)
const
[
listField
,
setListField
]
=
useState
([])
useEffect
(()
=>
{
getData
()
...
...
@@ -128,13 +98,81 @@ const SimpleForm = (props) => {
setState
({
...
state
,
date
})
}
const
onCreateField
=
()
=>
{}
const
onCreateField
=
(
value
)
=>
{
if
(
value
)
{
console
.
log
(
'value'
,
value
)
if
(
listField
.
findIndex
((
e
)
=>
e
.
field_name
==
value
)
==
-
1
)
{
setListField
(
[
{
field_name
:
value
,
gas_olines
:
[],
},
].
concat
(
listField
)
)
setOpenCreate
(
false
)
toast
.
success
(
'Thêm trụ thành công!'
,
{
theme
:
'colored'
,
})
}
else
{
toast
.
warning
(
'Tên trụ xăng đã tồn tại'
,
{
theme
:
'colored'
,
})
}
}
else
{
toast
.
warning
(
'Bạn chưa nhập đầy đủ thông tin'
,
{
theme
:
'colored'
,
})
}
}
const
deletePillar
=
(
index
)
=>
{
let
arr
=
[...
listField
]
arr
.
splice
(
index
,
1
)
setListField
(
arr
)
toast
.
success
(
'Xoá trụ thành công!'
,
{
theme
:
'colored'
,
})
}
const
createFountain
=
(
data
,
index
)
=>
{
let
arr
=
[...
listField
]
let
newList
=
arr
.
map
((
e
,
i
)
=>
{
if
(
i
==
index
)
{
if
(
e
.
gas_olines
)
{
return
{
...
e
,
gas_olines
:
[
{
...
data
,
},
].
concat
(
e
.
gas_olines
),
}
}
else
{
return
{
...
e
,
gas_olines
:
[
{
...
data
,
},
],
}
}
}
else
return
{
...
e
}
})
console
.
log
(
'newList'
,
newList
)
setListField
(
newList
)
}
const
handleCloseCreate
=
()
=>
{
setOpenCreate
(
false
)
}
const
{
store_name
,
address
,
merchan_id
}
=
state
console
.
log
(
'listField'
,
listField
)
return
(
<
div
className
=
"m-sm-30"
>
<
div
className
=
"mb-sm-30"
>
...
...
@@ -150,7 +188,11 @@ const SimpleForm = (props) => {
/
>
<
/div
>
<
SimpleCard
>
<
ValidatorForm
onSubmit
=
{
handleSubmit
}
onError
=
{()
=>
null
}
>
<
ValidatorForm
id
=
"form-create"
onSubmit
=
{
handleSubmit
}
onError
=
{()
=>
null
}
>
<
Grid
container
spacing
=
{
3
}
>
<
Grid
xs
=
{
6
}
sm
=
{
6
}
item
>
<
SelectValidator
...
...
@@ -248,7 +290,8 @@ const SimpleForm = (props) => {
>
<
div
>
<
Typography
variant
=
"subtitle1"
>
S
ố
l
ượ
ng
v
ò
i
m
ỗ
i
tr
ụ
:
1
S
ố
l
ượ
ng
v
ò
i
m
ỗ
i
tr
ụ
:{
' '
}
{
listField
.
length
}
<
/Typography
>
<
Typography
variant
=
"subtitle1"
>
S
ố
l
ượ
ng
tr
ụ
:
3
...
...
@@ -256,18 +299,21 @@ const SimpleForm = (props) => {
<
/div
>
<
Button
style
=
{{
width
:
120
,
width
:
140
,
}}
onClick
=
{()
=>
{
setOpenCreate
(
true
)
}}
variant
=
"contained"
className
=
{
'bg-light-primary'
}
>
<
span
className
=
{
'text-primary'
}
>
Th
ê
m
m
ớ
i
Th
ê
m
m
ớ
i
tr
ụ
<
/span
>
<
/Button
>
<
/Grid
>
{
listField
.
map
((
item
)
=>
(
{
listField
.
map
((
item
,
index
)
=>
(
<
Grid
style
=
{{
border
:
'1px solid #B9B9B9'
,
...
...
@@ -294,6 +340,9 @@ const SimpleForm = (props) => {
{
item
.
field_name
}
<
/Typography
>
<
Button
onClick
=
{()
=>
{
deletePillar
(
index
)
}}
variant
=
"contained"
style
=
{{
backgroundColor
:
...
...
@@ -360,10 +409,10 @@ const SimpleForm = (props) => {
>
S
ả
n
ph
ẩ
m
<
/TableCell
>
<
TableCell
align
=
"center"
>
{
/*
<TableCell align="center">
Trạng thái hoạt
động
<
/TableCell
>
</TableCell>
*/
}
<
TableCell
style
=
{{
textAlign
:
...
...
@@ -441,7 +490,7 @@ const SimpleForm = (props) => {
row
?.
product_name
}
<
/TableCell
>
<
TableCell
{
/*
<TableCell
style={{
borderRight:
'0.05px solid #e0e0e0',
...
...
@@ -451,7 +500,7 @@ const SimpleForm = (props) => {
{
row?.status
}
<
/TableCell
>
</TableCell>
*/
}
<
TableCell
>
<
Tooltip
title
=
"Xoá"
>
...
...
@@ -483,14 +532,11 @@ const SimpleForm = (props) => {
<
/TableBody
>
<
/Table
>
<
/TableContainer
>
<
IconButton
onClick
=
{()
=>
{}}
aria
-
label
=
"edit"
>
<
Icon
color
=
"primary"
>
add_circle
<
/Icon
>
<
/IconButton
>
<
CreateFountain
onCreate
=
{(
data
)
=>
{
createFountain
(
data
,
index
)
}}
/
>
<
/Grid
>
<
/Grid
>
))}
...
...
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