Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Sign in
Toggle navigation
K
kiaisoft_tuananh_nuxt
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Boards
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
TTS Tran Viet Anh
kiaisoft_tuananh_nuxt
Commits
feefefc1
Commit
feefefc1
authored
Jan 18, 2023
by
TTS Kieu Tuan Anh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update & create user CRUD
parent
c8b6574d
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
10 deletions
+24
-10
users.vue
pages/home/users.vue
+24
-10
No files found.
pages/home/users.vue
View file @
feefefc1
...
...
@@ -195,8 +195,7 @@
<
script
>
import
Nav
from
"
@/components/Nav
"
;
import
axios
from
"
axios
"
;
import
Toasted
from
'
vue-toasted
'
;
import
{
ModalPlugin
}
from
'
bootstrap-vue
'
;
export
default
{
layout
:
"
admin
"
,
...
...
@@ -225,6 +224,7 @@ export default {
{
text
:
'
Actions
'
,
value
:
'
actions
'
,
sortable
:
false
},
],
users
:
[],
eIndex
:
[],
eID
:
''
,
eEmail
:
''
,
eName
:
''
,
...
...
@@ -235,10 +235,8 @@ export default {
name
:
""
,
id
:
""
,
email
:
""
,
status
:
""
,
created_at
:
""
,
updated_at
:
""
,
},
defaultItem
:
{
name
:
""
,
...
...
@@ -269,7 +267,8 @@ export default {
},
methods
:
{
initialize
()
{
this
.
users
=
[];
this
.
users
=
[],
this
.
editedItem
=
{}
},
editItem
(
item
)
{
this
.
editedIndex
=
this
.
users
.
indexOf
(
item
);
...
...
@@ -328,10 +327,15 @@ export default {
})
.
then
(
response
=>
{
// $bvModal.hide('modal-login');
this
.
$bvModal
.
hide
(
'
modal-login
'
)
self
.
$toast
.
success
(
'
User created successfully!
'
,{
duration
:
3000
});
console
.
log
(
response
);
console
.
log
(
response
)
this
.
editedItem
=
response
.
data
.
data
console
.
log
(
this
.
editedItem
)
this
.
users
.
push
(
this
.
editedItem
)
})
.
catch
(
errors
=>
{
this
.
$bvModal
.
hide
(
'
modal-login
'
)
...
...
@@ -343,13 +347,19 @@ export default {
});
},
deleteUser
(
userID
,
index
)
{
const
self
=
this
this
.
editedIndex
=
this
.
users
.
indexOf
(
index
);
if
(
confirm
(
"
Do you really want to delete?
"
)){
try
{
axios
.
delete
(
`http://127.0.0.1:8000/api/users/
${
userID
}
`
)
.
then
(
response
=>
{
console
.
log
(
response
.
data
)
this
.
users
.
splice
(
this
.
editedIndex
,
1
);
self
.
$toast
.
success
(
'
User deleted successfully!
'
,{
duration
:
3000
});
})
}
catch
(
error
){
console
.
log
(
error
)
...
...
@@ -361,6 +371,7 @@ export default {
this
.
eID
=
user
.
id
;
this
.
eEmail
=
user
.
email
;
this
.
eName
=
user
.
name
;
this
.
editedIndex
=
this
.
users
.
indexOf
(
user
);
console
.
log
(
this
?.
eID
);
},
updateUser
(
userID
)
{
...
...
@@ -379,7 +390,10 @@ export default {
self.$toast.success('User updated successfully!',{
duration: 3000
});
console.log(response);
console.log(response)
this.editedItem = response.data.data
this.$bvModal.hide('modal-edit')
Object.assign(this.users[this.editedIndex], this.editedItem)
})
} catch(error){
console.log(error)
...
...
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