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
9
Issues
9
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
d4e780bb
Commit
d4e780bb
authored
a year ago
by
tdgiang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update code
parent
58add8ae
master
…
dev
dev_3
ladingpage
No related merge requests found
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
347 additions
and
60 deletions
+347
-60
Create.js
src/app/views/Merchant/Create.js
+20
-26
Index.js
src/app/views/Merchant/Index.js
+1
-1
Table.js
src/app/views/Merchant/Table.js
+5
-5
Update.js
src/app/views/Merchant/Update.js
+321
-28
No files found.
src/app/views/Merchant/Create.js
View file @
d4e780bb
...
...
@@ -27,32 +27,26 @@ const SimpleForm = (props) => {
const
handleSubmit
=
async
(
event
)
=>
{
const
newValue
=
trimObject
(
state
)
console
.
log
(
'newValue'
,
newValue
)
console
.
log
(
'isStore'
,
isStore
)
console
.
log
(
'invoice'
,
invoice
)
console
.
log
(
'payment'
,
payment
)
//props.showLoading()
props
.
showLoading
()
const
res
=
await
createMerchant
({
...
newValue
,
is_admin_store
:
tru
e
,
is_connect_hddt
:
tru
e
,
is_connect_qr
:
true
,
is_admin_store
:
isStor
e
,
is_connect_hddt
:
invoic
e
,
is_connect_qr
:
payment
,
})
//props.hideLoading()
console
.
log
(
'res'
,
res
)
// if (res.data.code == 200) {
// history.push('/merchant')
// if (res.data.code == 200) {
// toast.success('Tạo pháp nhân thành công!', {
// theme: 'colored',
// })
// }
// } else {
// toast.error(t(res.data.error), {
// theme: 'colored',
// })
// }
props
.
hideLoading
()
if
(
res
.
data
.
code
==
200
)
{
history
.
push
(
'/merchant'
)
if
(
res
.
data
.
code
==
200
)
{
toast
.
success
(
'Tạo pháp nhân thành công!'
,
{
theme
:
'colored'
,
})
}
}
else
{
toast
.
error
(
t
(
res
.
data
.
error
),
{
theme
:
'colored'
,
})
}
}
const
handleChange
=
(
event
)
=>
{
...
...
@@ -64,7 +58,7 @@ const SimpleForm = (props) => {
}
const
{
merchan_name
,
merchan
t
_name
,
tax_code
,
address
,
email
,
...
...
@@ -105,8 +99,8 @@ const SimpleForm = (props) => {
label
=
"Tên pháp nhân *"
onChange
=
{
handleChange
}
type
=
"text"
name
=
"merchan_name"
value
=
{
merchan_name
||
''
}
name
=
"merchan
t
_name"
value
=
{
merchan
t
_name
||
''
}
validators
=
{[
'required'
]}
errorMessages
=
{[
'Không được để trống trường này'
,
...
...
This diff is collapsed.
Click to expand it.
src/app/views/Merchant/Index.js
View file @
d4e780bb
...
...
@@ -30,7 +30,7 @@ const ToolNotificate = (props) => {
const
handeChangeActive
=
async
(
id
,
status_id
)
=>
{
props
.
showLoading
()
const
res
=
await
changeStatusMerchant
({
id
,
status_id
})
const
res
=
await
changeStatusMerchant
({
id
Guid
:
id
,
status_id
})
props
.
hideLoading
()
if
(
res
.
data
.
code
==
200
)
{
getData
()
...
...
This diff is collapsed.
Click to expand it.
src/app/views/Merchant/Table.js
View file @
d4e780bb
...
...
@@ -210,14 +210,14 @@ function TableList(props) {
<
/Select
>
<
/TableCell
>
<
TableCell
>
{
checkRole
(
user
,
'/
function
/delete'
)
?
(
{
checkRole
(
user
,
'/
merchant
/delete'
)
?
(
<
Tooltip
title
=
"Xoá"
>
<
IconButton
onClick
=
{()
=>
{
setSelected
({
...
row
,
title
:
'Xóa
chức năng
'
,
content
:
`Bạn có muốn xóa
chức năng
${
row
.
name
}
hay không?`
,
title
:
'Xóa
pháp nhân
'
,
content
:
`Bạn có muốn xóa
pháp nhân
${
row
.
merchant_
name
}
hay không?`
,
})
setOpen
(
true
)
}}
...
...
@@ -230,13 +230,13 @@ function TableList(props) {
<
/IconButton
>
<
/Tooltip
>
)
:
null
}
{
checkRole
(
user
,
'/
function
/update'
)
?
(
{
checkRole
(
user
,
'/
merchant
/update'
)
?
(
<
Tooltip
title
=
"Cập nhật"
>
<
IconButton
onClick
=
{()
=>
{
history
.
push
({
pathname
:
'/
function
/update'
,
'/
merchant
/update'
,
state
:
row
.
id
,
})
}}
...
...
This diff is collapsed.
Click to expand it.
src/app/views/Merchant/Update.js
View file @
d4e780bb
import
React
,
{
useState
,
useEffect
}
from
'react'
import
{
ValidatorForm
,
TextValidator
}
from
'react-material-ui-form-validator'
import
{
Button
,
Grid
}
from
'@material-ui/core'
import
{
Button
,
Grid
,
FormControlLabel
,
Checkbox
,
Typography
,
}
from
'@material-ui/core'
import
{
detailFunction
,
updateFunction
}
from
'app/apis/Functions/function
'
import
{
updateMerchant
,
detailMerchant
}
from
'app/apis/Functions/merchant
'
import
{
showLoading
,
hideLoading
}
from
'app/redux/actions/loadingAction'
import
{
toast
}
from
'react-toastify'
import
{
Breadcrumb
,
SimpleCard
}
from
'app/components'
import
{
Link
,
useHistory
,
useLocation
}
from
'react-router-dom'
import
{
trimObject
}
from
'app/config/Function'
import
{
connect
}
from
'react-redux'
import
localStorageService
from
'app/services/localStorageService
'
import
{
useTranslation
}
from
'react-i18next
'
const
SimpleForm
=
(
props
)
=>
{
const
[
state
,
setState
]
=
useState
({})
const
history
=
useHistory
()
const
[
isStore
,
setIsStore
]
=
useState
(
false
)
const
[
invoice
,
setInvoice
]
=
useState
(
false
)
const
[
payment
,
setPayment
]
=
useState
(
false
)
const
{
t
}
=
useTranslation
()
const
location
=
useLocation
()
useEffect
(()
=>
{
getData
()
},
[])
useEffect
(()
=>
{
if
(
!
invoice
)
{
setState
({
...
state
,
hddt_tax_code
:
''
,
hddt_username
:
''
,
hddt_password
:
''
,
hddt_character
:
''
,
})
}
},
[
invoice
])
useEffect
(()
=>
{
if
(
!
payment
)
{
setState
({
...
state
,
qr_merchant_code
:
''
,
qr_api_key
:
''
,
qr_secret_key
:
''
,
})
}
},
[
payment
])
const
getData
=
async
()
=>
{
props
.
showLoading
()
const
res
=
await
detail
Function
(
location
.
state
,
{})
const
res
=
await
detail
Merchant
(
location
.
state
,
{})
props
.
hideLoading
()
if
(
res
.
data
.
code
==
200
&&
res
.
data
.
data
)
{
console
.
log
(
res
.
data
.
data
)
setState
(
res
.
data
.
data
)
setInvoice
(
res
.
data
.
data
?.
is_connect_hddt
)
setPayment
(
res
.
data
.
data
?.
is_connect_qr
)
setIsStore
(
res
.
data
.
data
?.
is_admin_store
)
}
else
if
(
res
.
data
.
code
==
401
)
{
localStorageService
.
removeToken
()
setTimeout
(()
=>
{
history
.
push
(
'/'
)
},
100
)
}
else
{
toast
.
error
(
'Lấy thông tin bản ghi thất bại!'
,
{
toast
.
error
(
t
(
res
.
data
.
error
)
,
{
theme
:
'colored'
,
})
}
...
...
@@ -39,22 +76,24 @@ const SimpleForm = (props) => {
const
handleSubmit
=
async
(
event
)
=>
{
const
newValue
=
trimObject
(
state
)
props
.
showLoading
()
const
res
=
await
update
Function
({
const
res
=
await
update
Merchant
({
...
newValue
,
status
:
1
,
is_default
:
true
,
is_admin_store
:
isStore
,
is_connect_hddt
:
invoice
,
is_connect_qr
:
payment
,
})
props
.
hideLoading
()
if
(
res
.
data
.
code
==
200
)
{
history
.
push
(
'/merchant'
)
if
(
res
.
data
.
code
==
200
)
{
toast
.
success
(
'
Cập nhật hành động
thành công!'
,
{
toast
.
success
(
'
Tạo pháp nhân
thành công!'
,
{
theme
:
'colored'
,
})
}
}
else
{
toast
.
error
(
'Cập nhật hành động thất bại!'
,
{
toast
.
error
(
t
(
res
.
data
.
error
)
,
{
theme
:
'colored'
,
})
}
...
...
@@ -68,11 +107,23 @@ const SimpleForm = (props) => {
})
}
const
handleDateChange
=
(
date
)
=>
{
setState
({
...
state
,
date
})
}
const
{
description
,
name
,
code
,
url
}
=
state
const
{
merchant_name
,
tax_code
,
address
,
email
,
phone_number
,
representative
,
username
,
password
,
hddt_tax_code
,
hddt_username
,
hddt_password
,
hddt_character
,
qr_merchant_code
,
qr_api_key
,
qr_secret_key
,
}
=
state
return
(
<
div
className
=
"m-sm-30"
>
...
...
@@ -98,8 +149,8 @@ const SimpleForm = (props) => {
label
=
"Tên pháp nhân *"
onChange
=
{
handleChange
}
type
=
"text"
name
=
"name"
value
=
{
name
||
''
}
name
=
"
merchant_
name"
value
=
{
merchant_
name
||
''
}
validators
=
{[
'required'
]}
errorMessages
=
{[
'Không được để trống trường này'
,
...
...
@@ -110,11 +161,11 @@ const SimpleForm = (props) => {
<
TextValidator
variant
=
"outlined"
className
=
"mb-4 w-full"
label
=
"Mã
code
*"
label
=
"Mã
số thuế
*"
onChange
=
{
handleChange
}
type
=
"text"
name
=
"code"
value
=
{
code
||
''
}
name
=
"
tax_
code"
value
=
{
tax_
code
||
''
}
validators
=
{[
'required'
]}
errorMessages
=
{[
'Không được để trống trường này'
,
...
...
@@ -126,32 +177,274 @@ const SimpleForm = (props) => {
<
TextValidator
variant
=
"outlined"
className
=
"mb-4 w-full"
label
=
"Đ
ường dẫn
*"
label
=
"Đ
ịa chỉ
*"
onChange
=
{
handleChange
}
type
=
"text"
name
=
"
url
"
value
=
{
url
||
''
}
name
=
"
address
"
value
=
{
address
||
''
}
validators
=
{[
'required'
]}
errorMessages
=
{[
'Không được để trống trường này'
,
]}
/
>
<
/Grid
>
<
Grid
item
lg
=
{
6
}
md
=
{
6
}
sm
=
{
12
}
xs
=
{
12
}
>
<
TextValidator
variant
=
"outlined"
className
=
"mb-4 w-full"
label
=
"
Mô tả
"
label
=
"
Email *
"
onChange
=
{
handleChange
}
type
=
"text"
name
=
"
description
"
value
=
{
description
||
''
}
//validators={['required
']}
name
=
"
email
"
value
=
{
email
||
''
}
validators
=
{[
'required'
,
'isEmail
'
]}
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
=
"Tên người đại diện *"
onChange
=
{
handleChange
}
type
=
"text"
name
=
"representative"
value
=
{
representative
||
''
}
validators
=
{[
'required'
]}
errorMessages
=
{[
'Không được để trống trường này'
,
]}
/
>
<
/Grid
>
<
Grid
item
lg
=
{
6
}
md
=
{
6
}
sm
=
{
12
}
xs
=
{
12
}
>
<
TextValidator
variant
=
"outlined"
className
=
"mb-4 w-full"
label
=
"Số điện thoại liên hệ *"
onChange
=
{
handleChange
}
type
=
"text"
name
=
"phone_number"
value
=
{
phone_number
||
''
}
validators
=
{[
'required'
,
'isNumber'
,
'minStringLength:10'
,
'maxStringLength:15'
,
]}
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ố'
,
]}
/
>
<
/Grid
>
<
Grid
item
lg
=
{
6
}
md
=
{
6
}
sm
=
{
12
}
xs
=
{
12
}
>
<
TextValidator
variant
=
"outlined"
className
=
"mb-4 w-full"
disabled
=
{
true
}
label
=
"Tên đăng nhập *"
onChange
=
{
handleChange
}
type
=
"text"
name
=
"username"
value
=
{
username
||
''
}
validators
=
{[
'required'
]}
errorMessages
=
{[
'Không được để trống trường này'
,
]}
/
>
<
/Grid
>
<
Grid
lg
=
{
12
}
md
=
{
12
}
sm
=
{
12
}
xs
=
{
12
}
item
>
<
FormControlLabel
className
=
"min-w-288"
control
=
{
<
Checkbox
size
=
"small"
color
=
"primary"
onChange
=
{(
event
)
=>
{
console
.
log
(
event
.
target
.
checked
)
setIsStore
(
event
.
target
.
checked
)
}}
checked
=
{
isStore
}
/
>
}
label
=
"Pháp nhân là chủ cửa hàng"
/>
<
/Grid
>
<
Grid
lg
=
{
12
}
md
=
{
12
}
sm
=
{
12
}
xs
=
{
12
}
item
>
<
Typography
variant
=
"h6"
>
Th
ô
ng
tin
t
í
ch
h
ợ
p
<
/Typography
>
<
/Grid
>
<
Grid
lg
=
{
12
}
md
=
{
12
}
sm
=
{
12
}
xs
=
{
12
}
item
>
<
FormControlLabel
className
=
"min-w-288"
control
=
{
<
Checkbox
size
=
"small"
name
=
{
'he1'
}
color
=
"primary"
onChange
=
{(
event
)
=>
{
setInvoice
(
event
.
target
.
checked
)
}}
checked
=
{
invoice
}
/
>
}
label
=
"Tích hợp hóa đơn"
/>
<
/Grid
>
{
invoice
?
(
<
Grid
item
lg
=
{
6
}
md
=
{
6
}
sm
=
{
12
}
xs
=
{
12
}
>
<
TextValidator
variant
=
"outlined"
className
=
"mb-4 w-full"
label
=
"Mã số thuế hoá đơn *"
onChange
=
{
handleChange
}
type
=
"text"
name
=
"hddt_tax_code"
value
=
{
hddt_tax_code
||
''
}
validators
=
{[
'required'
]}
errorMessages
=
{[
'Không được để trống trường này'
,
]}
/
>
<
/Grid
>
)
:
null
}
{
invoice
?
(
<
Grid
item
lg
=
{
6
}
md
=
{
6
}
sm
=
{
12
}
xs
=
{
12
}
>
<
TextValidator
variant
=
"outlined"
className
=
"mb-4 w-full"
label
=
"Tài khoản hoá đơn *"
onChange
=
{
handleChange
}
type
=
"text"
name
=
"hddt_username"
value
=
{
hddt_username
||
''
}
validators
=
{[
'required'
]}
errorMessages
=
{[
'Không được để trống trường này'
,
]}
/
>
<
/Grid
>
)
:
null
}
{
invoice
?
(
<
Grid
item
lg
=
{
6
}
md
=
{
6
}
sm
=
{
12
}
xs
=
{
12
}
>
<
TextValidator
variant
=
"outlined"
className
=
"mb-4 w-full"
label
=
"Mật khẩu hoá đơn *"
onChange
=
{
handleChange
}
type
=
"text"
name
=
"hddt_password"
value
=
{
hddt_password
||
''
}
validators
=
{[
'required'
]}
errorMessages
=
{[
'Không được để trống trường này'
,
]}
/
>
<
/Grid
>
)
:
null
}
{
invoice
?
(
<
Grid
item
lg
=
{
6
}
md
=
{
6
}
sm
=
{
12
}
xs
=
{
12
}
>
<
TextValidator
variant
=
"outlined"
className
=
"mb-4 w-full"
label
=
"Chữ ký hoá đơn *"
onChange
=
{
handleChange
}
type
=
"text"
name
=
"hddt_character"
value
=
{
hddt_character
||
''
}
validators
=
{[
'required'
]}
errorMessages
=
{[
'Không được để trống trường này'
,
]}
/
>
<
/Grid
>
)
:
null
}
<
Grid
lg
=
{
12
}
md
=
{
12
}
sm
=
{
12
}
xs
=
{
12
}
item
>
<
FormControlLabel
className
=
"min-w-288"
control
=
{
<
Checkbox
size
=
"small"
color
=
"primary"
name
=
{
'he2'
}
onChange
=
{(
event
)
=>
{
setPayment
(
event
.
target
.
checked
)
}}
checked
=
{
payment
}
/
>
}
label
=
"Tích hợp thanh toán"
/>
<
/Grid
>
{
payment
?
(
<
Grid
item
lg
=
{
6
}
md
=
{
6
}
sm
=
{
12
}
xs
=
{
12
}
>
<
TextValidator
variant
=
"outlined"
className
=
"mb-4 w-full"
label
=
"Mã QR code *"
onChange
=
{
handleChange
}
type
=
"text"
name
=
"qr_merchant_code"
value
=
{
qr_merchant_code
||
''
}
validators
=
{[
'required'
]}
errorMessages
=
{[
'Không được để trống trường này'
,
]}
/
>
<
/Grid
>
)
:
null
}
{
payment
?
(
<
Grid
item
lg
=
{
6
}
md
=
{
6
}
sm
=
{
12
}
xs
=
{
12
}
>
<
TextValidator
variant
=
"outlined"
className
=
"mb-4 w-full"
label
=
"API QR key *"
onChange
=
{
handleChange
}
type
=
"text"
name
=
"qr_api_key"
value
=
{
qr_api_key
||
''
}
validators
=
{[
'required'
]}
errorMessages
=
{[
'Không được để trống trường này'
,
]}
/
>
<
/Grid
>
)
:
null
}
{
payment
?
(
<
Grid
item
lg
=
{
6
}
md
=
{
6
}
sm
=
{
12
}
xs
=
{
12
}
>
<
TextValidator
variant
=
"outlined"
className
=
"mb-4 w-full"
label
=
"Mật khẩu QR *"
onChange
=
{
handleChange
}
type
=
"text"
name
=
"qr_secret_key"
value
=
{
qr_secret_key
||
''
}
validators
=
{[
'required'
]}
errorMessages
=
{[
'Không được để trống trường này'
,
]}
/
>
<
/Grid
>
)
:
null
}
<
/Grid
>
<
Grid
container
justify
=
{
'flex-end'
}
>
<
Link
to
=
"merchant"
>
...
...
This diff is collapsed.
Click to expand it.
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