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
Hide 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 @@
...
@@ -195,8 +195,7 @@
<
script
>
<
script
>
import
Nav
from
"
@/components/Nav
"
;
import
Nav
from
"
@/components/Nav
"
;
import
axios
from
"
axios
"
;
import
axios
from
"
axios
"
;
import
Toasted
from
'
vue-toasted
'
;
import
{
ModalPlugin
}
from
'
bootstrap-vue
'
;
export
default
{
export
default
{
layout
:
"
admin
"
,
layout
:
"
admin
"
,
...
@@ -225,6 +224,7 @@ export default {
...
@@ -225,6 +224,7 @@ export default {
{
text
:
'
Actions
'
,
value
:
'
actions
'
,
sortable
:
false
},
{
text
:
'
Actions
'
,
value
:
'
actions
'
,
sortable
:
false
},
],
],
users
:
[],
users
:
[],
eIndex
:
[],
eID
:
''
,
eID
:
''
,
eEmail
:
''
,
eEmail
:
''
,
eName
:
''
,
eName
:
''
,
...
@@ -235,10 +235,8 @@ export default {
...
@@ -235,10 +235,8 @@ export default {
name
:
""
,
name
:
""
,
id
:
""
,
id
:
""
,
email
:
""
,
email
:
""
,
status
:
""
,
created_at
:
""
,
created_at
:
""
,
updated_at
:
""
,
updated_at
:
""
,
},
},
defaultItem
:
{
defaultItem
:
{
name
:
""
,
name
:
""
,
...
@@ -269,7 +267,8 @@ export default {
...
@@ -269,7 +267,8 @@ export default {
},
},
methods
:
{
methods
:
{
initialize
()
{
initialize
()
{
this
.
users
=
[];
this
.
users
=
[],
this
.
editedItem
=
{}
},
},
editItem
(
item
)
{
editItem
(
item
)
{
this
.
editedIndex
=
this
.
users
.
indexOf
(
item
);
this
.
editedIndex
=
this
.
users
.
indexOf
(
item
);
...
@@ -294,9 +293,9 @@ export default {
...
@@ -294,9 +293,9 @@ export default {
},
},
closeDelete
()
{
closeDelete
()
{
this
.
dialogDelete
=
false
;
this
.
dialogDelete
=
false
;
this
.
$nextTick
(()
=>
{
this
.
$nextTick
(()
=>
{
this
.
editedItem
=
Object
.
assign
({},
this
.
defaultItem
);
this
.
editedItem
=
Object
.
assign
({},
this
.
defaultItem
);
this
.
editedIndex
=
-
1
;
this
.
editedIndex
=
-
1
;
});
});
},
},
save
()
{
save
()
{
...
@@ -328,10 +327,15 @@ export default {
...
@@ -328,10 +327,15 @@ export default {
})
})
.
then
(
response
=>
{
.
then
(
response
=>
{
// $bvModal.hide('modal-login');
// $bvModal.hide('modal-login');
this
.
$bvModal
.
hide
(
'
modal-login
'
)
self
.
$toast
.
success
(
'
User created successfully!
'
,{
self
.
$toast
.
success
(
'
User created successfully!
'
,{
duration
:
3000
duration
:
3000
});
});
console
.
log
(
response
);
console
.
log
(
response
)
this
.
editedItem
=
response
.
data
.
data
console
.
log
(
this
.
editedItem
)
this
.
users
.
push
(
this
.
editedItem
)
})
})
.
catch
(
errors
=>
{
.
catch
(
errors
=>
{
this
.
$bvModal
.
hide
(
'
modal-login
'
)
this
.
$bvModal
.
hide
(
'
modal-login
'
)
...
@@ -343,13 +347,19 @@ export default {
...
@@ -343,13 +347,19 @@ export default {
});
});
},
},
deleteUser
(
userID
,
index
)
{
deleteUser
(
userID
,
index
)
{
const
self
=
this
this
.
editedIndex
=
this
.
users
.
indexOf
(
index
);
this
.
editedIndex
=
this
.
users
.
indexOf
(
index
);
if
(
confirm
(
"
Do you really want to delete?
"
)){
if
(
confirm
(
"
Do you really want to delete?
"
)){
try
{
try
{
axios
axios
.
delete
(
`http://127.0.0.1:8000/api/users/
${
userID
}
`
)
.
delete
(
`http://127.0.0.1:8000/api/users/
${
userID
}
`
)
.
then
(
response
=>
{
.
then
(
response
=>
{
console
.
log
(
response
.
data
)
this
.
users
.
splice
(
this
.
editedIndex
,
1
);
this
.
users
.
splice
(
this
.
editedIndex
,
1
);
self
.
$toast
.
success
(
'
User deleted successfully!
'
,{
duration
:
3000
});
})
})
}
catch
(
error
){
}
catch
(
error
){
console
.
log
(
error
)
console
.
log
(
error
)
...
@@ -361,6 +371,7 @@ export default {
...
@@ -361,6 +371,7 @@ export default {
this
.
eID
=
user
.
id
;
this
.
eID
=
user
.
id
;
this
.
eEmail
=
user
.
email
;
this
.
eEmail
=
user
.
email
;
this
.
eName
=
user
.
name
;
this
.
eName
=
user
.
name
;
this
.
editedIndex
=
this
.
users
.
indexOf
(
user
);
console
.
log
(
this
?.
eID
);
console
.
log
(
this
?.
eID
);
},
},
updateUser
(
userID
)
{
updateUser
(
userID
)
{
...
@@ -379,7 +390,10 @@ export default {
...
@@ -379,7 +390,10 @@ export default {
self.$toast.success('User updated successfully!',{
self.$toast.success('User updated successfully!',{
duration: 3000
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){
} catch(error){
console.log(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