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
fd18168c
Commit
fd18168c
authored
Feb 01, 2023
by
Kemm23
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix UI
parent
ef3630f7
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
454 additions
and
307 deletions
+454
-307
admin.vue
layouts/admin.vue
+2
-2
index.vue
pages/categories/index.vue
+337
-191
index.vue
pages/users/index.vue
+115
-114
No files found.
layouts/admin.vue
View file @
fd18168c
<
template
>
<
template
>
<
div
>
<
v-app
>
<NavBar
/>
<NavBar
/>
<nuxt
/>
<nuxt
/>
</
div
>
</
v-app
>
</
template
>
</
template
>
<
script
>
<
script
>
...
...
pages/categories/index.vue
View file @
fd18168c
<!-- eslint-disable vue/valid-v-slot -->
<
template
>
<
template
>
<v-app>
<div>
<div>
<b-breadcrumb>
<div>
<b-breadcrumb-item
href=
"/home"
>
<v-breadcrumbs
:items=
"items"
>
<b-icon
icon=
"house-fill"
scale=
"1.25"
shift-v=
"1.25"
aria-hidden=
"true"
></b-icon>
<template
#divider
>
Home
<v-icon>
mdi-chevron-right
</v-icon>
</b-breadcrumb-item>
<b-breadcrumb-item
href=
"/categories"
>
Category
</b-breadcrumb-item>
</b-breadcrumb>
<div
style=
"float: right"
>
<b-button
v-b-modal
.
modal-create
class=
"text-white"
>
New Category
</b-button>
</div>
<!-- create modal -->
<b-modal
id=
"modal-create"
title=
"Create Category"
class=
"modal fade"
>
<p
class=
"my-4"
>
<form
@
submit.prevent=
"createCategory"
>
<label>
Name :
</label>
<input
type=
"text"
class=
"form-control mb-2"
placeholder=
"name"
v-model=
"name"
max=
"255"
min=
"1"
required
/>
<label>
Parent :
</label>
<b-form-select
v-model=
"parent_id"
>
<option
v-for=
"item in categories"
:value=
"item.id"
v-if=
"item.parent_id == null"
>
{{
item
.
name
}}
</option>
</b-form-select>
<label>
Ordering :
</label>
<input
type=
"text"
class=
"form-control mb-2"
placeholder=
"Ordering"
v-model=
"ordering"
required
/>
<label>
Image :
</label>
<b-form-file
@
change=
"fileSelected"
v-model=
"image"
:state=
"Boolean(image)"
placeholder=
"Choose a image or drop it here..."
drop-placeholder=
"Drop file here..."
></b-form-file>
</form>
</p>
<template
#modal-footer
>
<button
v-b-modal
.
modal-close_visit
@
click=
"$bvModal.hide('modal-create')"
class=
"btn btn-danger btn-sm m-1"
>
Close
</button>
<button
@
click=
"createCategory"
v-b-modal
.
modal-close_visit
class=
"btn btn-success btn-sm m-1"
>
Submit
</button>
</
template
>
</
template
>
</b-modal>
</v-breadcrumbs>
<!-- edit-modal -->
</div>
<b-modal
id=
"modal-edit"
title=
"Edit Category"
class=
"modal fade"
>
<div
style=
"float: right"
>
<p
class=
"my-4"
>
<v-dialog
<form>
v-model=
"dialog1"
<label>
Name :
</label>
persistent
<input
type=
"text"
class=
"form-control mb-2"
placeholder=
"name"
v-model=
"eName"
max=
"255"
min=
"1"
max-width=
"600px"
value=
"this?.eName"
/>
@
submit.prevent=
"createUser"
<label>
Parent :
</label>
>
<b-form-select
v-model=
"eParentId"
>
<
template
#activator
="{
on
,
attrs
}"
>
<option
v-for=
"item in categories"
:value=
"item.id"
:key=
"item.id"
>
<v-btn
{{ item.name }}
color=
"primary"
</option>
dark
</b-form-select>
v-bind=
"attrs"
<label>
Ordering :
</label>
v-on=
"on"
<input
type=
"text"
class=
"form-control mb-2"
placeholder=
"Ordering"
v-model=
"eOrdering"
>
value=
"this?.eOrdering"
/>
New Category
<!-- <b-form-select v-model="selected" :options="options"></b-form-select> -->
</v-btn>
<label>
Image :
</label>
<b-form-file
v-model=
"eImage"
:state=
"Boolean(eImage)"
placeholder=
"Choose a image or drop it here..."
drop-placeholder=
"Drop file here..."
></b-form-file>
</form>
</p>
<
template
#modal-footer
>
<button
v-b-modal
.
modal-close_visit
@
click=
"$bvModal.hide('modal-edit')"
class=
"btn btn-danger btn-sm m-1"
>
Close
</button>
<button
@
click=
"updateCategory(this?.eID)"
v-b-modal
.
modal-close_visit
class=
"btn btn-success btn-sm m-1"
>
Submit
</button>
</
template
>
</
template
>
</b-modal>
<v-card>
<div>
<v-card-title>
<span
class=
"text-h5"
>
Create Category
</span>
</v-card-title>
<v-card-text>
<v-container>
<v-row>
<v-col
cols=
"12"
sm=
"6"
md=
"4"
>
<v-text-field
v-model=
"name"
label=
"Name"
required
/>
</v-col>
<v-col
cols=
"12"
>
<v-text-field
v-model=
"ordering"
label=
"Ordering"
type=
"number"
required
/>
</v-col>
<v-col
cols=
"12"
>
<v-select
v-model=
"parent_id"
:items=
"categories.filter(category => category.parent_id === null)"
item-text=
"name"
item-value=
"id"
label=
"Parent_id*"
/>
</v-col>
<v-col
cols=
"12"
>
<v-file-input
accept=
"image/*"
label=
"Image"
prepend-icon=
"mdi-camera"
@
change=
"testLog()"
/>
</v-col>
</v-row>
</v-container>
<small>
*indicates required field
</small>
</v-card-text>
<v-card-actions>
<v-spacer
/>
<v-btn
color=
"blue darken-1"
text
@
click=
"dialog1 = false"
>
Close
</v-btn>
<v-btn
color=
"blue darken-1"
text
type=
"submit"
@
click=
"dialog1 = false; createCategory();"
>
Save
</v-btn>
</v-card-actions>
</v-card>
</v-dialog>
</div>
<!-- modal-create -->
<v-dialog
v-model=
"dialog2"
persistent
max-width=
"600px"
>
<v-card>
<v-card-title>
<span
class=
"text-h5"
>
Category Edit
</span>
</v-card-title>
<v-card-text>
<v-container>
<v-row>
<v-col
cols=
"12"
>
<v-text-field
v-model=
"eID"
label=
"ID"
required
/>
</v-col>
<v-col
cols=
"12"
>
<v-text-field
v-model=
"eName"
label=
"Name"
required
/>
</v-col>
<v-col
cols=
"12"
>
<v-text-field
v-model=
"eOrdering"
label=
"Ordering"
required
/>
</v-col>
<v-col
cols=
"12"
>
<v-select
v-model=
"parent_id"
:items=
"categories.filter(category => category.parent_id === null)"
item-text=
"name"
item-value=
"id"
label=
"Parent_id"
@
input=
"testLog()"
/>
</v-col>
<v-col
cols=
"12"
>
<v-file-input
label=
"Image"
prepend-icon=
"mdi-camera"
/>
</v-col>
<v-col
cols=
"12"
>
<v-file-input
label=
"File input"
/>
</v-col>
</v-row>
</v-container>
<small>
*indicates required field
</small>
</v-card-text>
<v-card-actions>
<v-spacer
/>
<v-btn
color=
"blue darken-1"
text
@
click=
"dialog2 = false"
>
Close
</v-btn>
<v-btn
color=
"blue darken-1"
text
type=
"submit"
@
click=
"dialog2 = false; updateUser();"
>
Save
</v-btn>
</v-card-actions>
</v-card>
</v-dialog>
<v-data-table
:headers=
"headers"
:items=
"categories"
sort-by=
"calories"
class=
"elevation-1"
>
<v-data-table
:headers=
"headers"
:items=
"categories"
sort-by=
"calories"
class=
"elevation-1"
>
<
template
v-slot:
top
>
<
template
#
top
>
<v-toolbar
flat
>
<v-toolbar
flat
>
<v-toolbar-title>
Category Manage
</v-toolbar-title>
<v-toolbar-title>
Category Manage
</v-toolbar-title>
<v-divider
class=
"mx-4"
inset
vertical
></v-divider
>
<v-divider
class=
"mx-4"
inset
vertical
/
>
<v-spacer
></v-spacer
>
<v-spacer
/
>
<v-dialog
v-model=
"dialog"
max-width=
"500px"
>
<v-dialog
v-model=
"dialog"
max-width=
"500px"
>
<template
v-slot:activator=
"
{ on, attrs }">
</
template
>
<v-card>
<v-card>
<v-card-title>
<v-card-title>
<span
class=
"text-h5"
>
{{
formTitle
}}
</span>
<span
class=
"text-h5"
>
{{
formTitle
}}
</span>
...
@@ -82,55 +188,69 @@
...
@@ -82,55 +188,69 @@
<v-container>
<v-container>
<v-row>
<v-row>
<v-col
cols=
"12"
sm=
"6"
md=
"4"
>
<v-col
cols=
"12"
sm=
"6"
md=
"4"
>
<v-text-field
v-model=
"editedItem.name"
label=
"name"
></v-text-field
>
<v-text-field
v-model=
"editedItem.name"
label=
"name"
/
>
</v-col>
</v-col>
<v-col
cols=
"12"
sm=
"6"
md=
"4"
>
<v-col
cols=
"12"
sm=
"6"
md=
"4"
>
<v-text-field
v-model=
"editedItem.id"
label=
"id"
></v-text-field
>
<v-text-field
v-model=
"editedItem.id"
label=
"id"
/
>
</v-col>
</v-col>
<v-col
cols=
"12"
sm=
"6"
md=
"4"
>
<v-col
cols=
"12"
sm=
"6"
md=
"4"
>
<v-text-field
v-model=
"editedItem.ordering"
label=
"ordering"
></v-text-field
>
<v-text-field
v-model=
"editedItem.ordering"
label=
"ordering"
/
>
</v-col>
</v-col>
<v-col
cols=
"12"
sm=
"6"
md=
"4"
>
<v-col
cols=
"12"
sm=
"6"
md=
"4"
>
<v-text-field
v-model=
"editedItem.created_at"
label=
"created_at"
></v-text-field
>
<v-text-field
v-model=
"editedItem.created_at"
label=
"created_at"
/
>
</v-col>
</v-col>
<v-col
cols=
"12"
sm=
"6"
md=
"4"
>
<v-col
cols=
"12"
sm=
"6"
md=
"4"
>
<v-text-field
v-model=
"editedItem.updated_at"
label=
"updated_at"
></v-text-field
>
<v-text-field
v-model=
"editedItem.updated_at"
label=
"updated_at"
/
>
</v-col>
</v-col>
</v-row>
</v-row>
</v-container>
</v-container>
</v-card-text>
</v-card-text>
<v-card-actions>
<v-card-actions>
<v-spacer
></v-spacer
>
<v-spacer
/
>
<v-btn
color=
"blue darken-1"
text
@
click=
"close"
>
<v-btn
color=
"blue darken-1"
text
@
click=
"close"
>
Cancel
Cancel
</v-btn>
</v-btn>
<v-btn
color=
"blue darken-1"
text
@
click=
"save"
>
Save
</v-btn>
<v-btn
color=
"blue darken-1"
text
@
click=
"save"
>
Save
</v-btn>
</v-card-actions>
</v-card-actions>
</v-card>
</v-card>
</v-dialog>
</v-dialog>
<v-dialog
v-model=
"dialogDelete"
max-width=
"500px"
>
<v-dialog
v-model=
"dialogDelete"
max-width=
"500px"
>
<v-card>
<v-card>
<v-card-title
class=
"text-h5"
>
Are you sure you want to delete this item?
</v-card-title>
<v-card-title
class=
"text-h5"
>
Are you sure you want to delete this item?
</v-card-title>
<v-card-actions>
<v-card-actions>
<v-spacer></v-spacer>
<v-spacer
/>
<v-btn
color=
"blue darken-1"
text
@
click=
"closeDelete"
>
Cancel
</v-btn>
<v-btn
color=
"blue darken-1"
text
@
click=
"closeDelete"
>
<v-btn
color=
"blue darken-1"
text
@
click=
"deleteItemConfirm"
>
OK
</v-btn>
Cancel
<v-spacer></v-spacer>
</v-btn>
<v-btn
color=
"blue darken-1"
text
@
click=
"deleteItemConfirm"
>
OK
</v-btn>
<v-spacer
/>
</v-card-actions>
</v-card-actions>
</v-card>
</v-card>
</v-dialog>
</v-dialog>
</v-toolbar>
</v-toolbar>
</
template
>
</
template
>
<
template
v-slot:item.actions=
"{ item }"
>
<
template
#item.actions=
"{ item }"
>
<v-icon
small
class=
"mr-2"
@
click=
"editCategory(item)"
:id=
"item.id"
>
mdi-pencil
</v-icon>
<v-icon
:id=
"item.id"
small
class=
"mr-2"
@
click=
"dialog2 = true; editCategory(item)"
>
<v-icon
small
@
click=
"deleteCategory(item.id, item)"
:id=
"item.id"
>
mdi-delete
</v-icon>
mdi-pencil
</v-icon>
<v-icon
:id=
"item.id"
small
@
click=
"deleteCategory(item.id, item)"
>
mdi-delete
</v-icon>
</
template
>
</
template
>
<
template
v-slot:no-data
>
<
template
#no-data
>
<v-btn
color=
"primary"
@
click=
"initialize"
>
Reset
</v-btn>
<v-btn
color=
"primary"
@
click=
"initialize"
>
Reset
</v-btn>
</
template
>
</
template
>
</v-data-table>
</v-data-table>
</div>
</div>
</
div
>
</
v-app
>
</template>
</template>
<
script
>
<
script
>
export
default
{
export
default
{
...
@@ -143,7 +263,8 @@ export default {
...
@@ -143,7 +263,8 @@ export default {
ordering
:
''
,
ordering
:
''
,
image
:
null
,
image
:
null
,
error
:
''
,
error
:
''
,
dialog
:
false
,
dialog1
:
false
,
dialog2
:
false
,
dialogDelete
:
false
,
dialogDelete
:
false
,
options
:
[],
options
:
[],
headers
:
[
headers
:
[
...
@@ -151,14 +272,14 @@ export default {
...
@@ -151,14 +272,14 @@ export default {
text
:
'
Name
'
,
text
:
'
Name
'
,
align
:
'
start
'
,
align
:
'
start
'
,
sortable
:
false
,
sortable
:
false
,
value
:
'
name
'
,
value
:
'
name
'
},
},
{
text
:
'
id
'
,
value
:
'
id
'
},
{
text
:
'
id
'
,
value
:
'
id
'
},
{
text
:
'
ordering
'
,
value
:
'
ordering
'
},
{
text
:
'
ordering
'
,
value
:
'
ordering
'
},
{
text
:
'
parent
'
,
value
:
'
parent_id
'
,
sortable
:
false
},
{
text
:
'
parent
'
,
value
:
'
parent_id
'
,
sortable
:
false
},
{
text
:
'
created_at
'
,
value
:
'
created_at
'
},
{
text
:
'
created_at
'
,
value
:
'
created_at
'
},
{
text
:
'
updated_at
'
,
value
:
'
updated_at
'
},
{
text
:
'
updated_at
'
,
value
:
'
updated_at
'
},
{
text
:
'
Actions
'
,
value
:
'
actions
'
,
sortable
:
false
}
,
{
text
:
'
Actions
'
,
value
:
'
actions
'
,
sortable
:
false
}
],
],
categories
:
[],
categories
:
[],
eID
:
''
,
eID
:
''
,
...
@@ -174,7 +295,7 @@ export default {
...
@@ -174,7 +295,7 @@ export default {
ordering
:
''
,
ordering
:
''
,
parent_id
:
''
,
parent_id
:
''
,
created_at
:
''
,
created_at
:
''
,
updated_at
:
''
,
updated_at
:
''
},
},
defaultItem
:
{
defaultItem
:
{
name
:
''
,
name
:
''
,
...
@@ -182,61 +303,77 @@ export default {
...
@@ -182,61 +303,77 @@ export default {
ordering
:
''
,
ordering
:
''
,
status
:
''
,
status
:
''
,
created_at
:
''
,
created_at
:
''
,
updated_at
:
''
,
updated_at
:
''
},
items
:
[
{
icon
:
'
mdi-home
'
,
text
:
'
Home
'
,
disabled
:
false
,
href
:
'
/home
'
},
},
{
text
:
'
Category
'
,
disabled
:
false
,
href
:
'
/categories
'
}
]
}
}
},
},
computed
:
{
computed
:
{
formTitle
()
{
formTitle
()
{
return
this
.
editedIndex
===
-
1
?
'
New Item
'
:
'
Edit Item
'
return
this
.
editedIndex
===
-
1
?
'
New Item
'
:
'
Edit Item
'
}
,
}
},
},
watch
:
{
watch
:
{
dialog
(
val
)
{
dialog
(
val
)
{
val
||
this
.
close
()
val
||
this
.
close
()
},
},
dialogDelete
(
val
)
{
dialogDelete
(
val
)
{
val
||
this
.
closeDelete
()
val
||
this
.
closeDelete
()
}
},
},
},
created
()
{
created
()
{
this
.
initialize
()
this
.
initialize
()
this
.
getCategories
()
this
.
getCategories
()
},
},
methods
:
{
methods
:
{
initialize
()
{
testLog
()
{
console
.
log
(
this
.
image
)
},
initialize
()
{
this
.
users
=
[]
this
.
users
=
[]
this
.
categories
=
[]
this
.
categories
=
[]
},
},
editItem
(
item
)
{
editItem
(
item
)
{
this
.
editedIndex
=
this
.
categories
.
indexOf
(
item
)
this
.
editedIndex
=
this
.
categories
.
indexOf
(
item
)
this
.
editedItem
=
Object
.
assign
({},
item
)
this
.
editedItem
=
Object
.
assign
({},
item
)
this
.
dialog
=
true
this
.
dialog
=
true
},
},
deleteItem
(
item
)
{
deleteItem
(
item
)
{
this
.
editedIndex
=
this
.
categories
.
indexOf
(
item
)
this
.
editedIndex
=
this
.
categories
.
indexOf
(
item
)
this
.
editedItem
=
Object
.
assign
({},
item
)
this
.
editedItem
=
Object
.
assign
({},
item
)
this
.
dialogDelete
=
true
this
.
dialogDelete
=
true
},
},
deleteItemConfirm
()
{
deleteItemConfirm
()
{
this
.
categories
.
splice
(
this
.
editedIndex
,
1
)
this
.
categories
.
splice
(
this
.
editedIndex
,
1
)
this
.
closeDelete
()
this
.
closeDelete
()
},
},
close
()
{
close
()
{
this
.
dialog
=
false
this
.
dialog
=
false
this
.
$nextTick
(()
=>
{
this
.
$nextTick
(()
=>
{
this
.
editedItem
=
Object
.
assign
({},
this
.
defaultItem
)
this
.
editedItem
=
Object
.
assign
({},
this
.
defaultItem
)
this
.
editedIndex
=
-
1
this
.
editedIndex
=
-
1
})
})
},
},
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
()
{
if
(
this
.
editedIndex
>
-
1
)
{
if
(
this
.
editedIndex
>
-
1
)
{
Object
.
assign
(
this
.
categories
[
this
.
editedIndex
],
this
.
editedItem
)
Object
.
assign
(
this
.
categories
[
this
.
editedIndex
],
this
.
editedItem
)
}
else
{
}
else
{
...
@@ -244,38 +381,47 @@ export default {
...
@@ -244,38 +381,47 @@ export default {
}
}
this
.
close
()
this
.
close
()
},
},
getCategories
()
{
getCategories
()
{
this
.
$axios
this
.
$axios
.
get
(
"
/categories/
"
,
{
.
get
(
'
/categories/
'
,
{
headers
:
{
headers
:
{
'
Content-Type
'
:
'
application/json
'
,
'
Content-Type
'
:
'
application/json
'
,
Authorization
:
`Bearer
${
this
.
$auth
.
$storage
.
getUniversal
(
"
token
"
)}
`
,
Authorization
:
`Bearer
${
this
.
$auth
.
$storage
.
getUniversal
(
'
token
'
)}
`
}})
}
.
then
((
response
)
=>
(
this
.
categories
=
response
.
data
.
data
))
})
.
then
((
response
)
=>
{
this
.
categories
=
response
.
data
.
data
})
.
catch
(
function
(
error
)
{
.
catch
(
function
(
error
)
{
console
.
log
(
error
)
console
.
log
(
error
)
})
})
},
},
createCategory
()
{
createCategory
()
{
const
set
=
new
Set
([
this
.
image
])
const
set
=
new
Set
([
this
.
image
])
const
image
=
Array
.
from
(
set
)
const
image
=
Array
.
from
(
set
)
const
self
=
this
const
self
=
this
console
.
log
({
name
:
this
.
name
,
ordering
:
this
.
ordering
,
parent_id
:
this
.
parent_id
,
images
:
image
})
this
.
$axios
this
.
$axios
.
post
(
'
/categories/
'
,
.
post
(
'
/categories/
'
,
{
{
name
:
this
.
name
,
name
:
this
.
name
,
ordering
:
this
.
ordering
,
ordering
:
this
.
ordering
,
parent_id
:
this
.
parent_id
,
parent_id
:
this
.
parent_id
,
images
:
image
,
images
:
image
},
},
{
{
headers
:
{
headers
:
{
"
Content-Type
"
:
"
multipart/form-data
"
,
'
Content-Type
'
:
'
multipart/form-data
'
,
Authorization
:
`Bearer
${
this
.
$auth
.
$storage
.
getUniversal
(
"
token
"
)}
`
,
Authorization
:
`Bearer
${
this
.
$auth
.
$storage
.
getUniversal
(
'
token
'
)}
`
},
}
}
}
)
)
.
then
(
response
=>
{
.
then
((
response
)
=>
{
this
.
$bvModal
.
hide
(
'
modal-create
'
)
this
.
$bvModal
.
hide
(
'
modal-create
'
)
self
.
$toast
.
success
(
'
Category created successfully!
'
,
{
self
.
$toast
.
success
(
'
Category created successfully!
'
,
{
duration
:
3000
duration
:
3000
...
@@ -284,16 +430,16 @@ export default {
...
@@ -284,16 +430,16 @@ export default {
console
.
log
(
this
.
editedItem
)
console
.
log
(
this
.
editedItem
)
this
.
categories
.
push
(
this
.
editedItem
)
this
.
categories
.
push
(
this
.
editedItem
)
})
})
.
catch
(
errors
=>
{
.
catch
((
errors
)
=>
{
this
.
$bvModal
.
hide
(
'
modal-create
'
)
this
.
$bvModal
.
hide
(
'
modal-create
'
)
console
.
log
(
errors
.
response
.
data
.
message
)
console
.
log
(
errors
.
response
.
data
.
message
)
this
.
message
=
errors
.
response
.
data
.
message
this
.
message
=
errors
.
response
.
data
.
message
self
.
$toast
.
error
(
'
something went wrong while trying create!
'
,
{
self
.
$toast
.
error
(
'
something went wrong while trying create!
'
,
{
duration
:
3000
duration
:
3000
})
})
})
})
},
},
fileSelected
(
event
)
{
fileSelected
(
event
)
{
console
.
log
(
event
)
console
.
log
(
event
)
const
file
=
event
.
target
.
files
[
0
]
const
file
=
event
.
target
.
files
[
0
]
this
.
url
=
URL
.
createObjectURL
(
file
)
this
.
url
=
URL
.
createObjectURL
(
file
)
...
@@ -301,35 +447,34 @@ export default {
...
@@ -301,35 +447,34 @@ export default {
console
.
log
(
file
)
console
.
log
(
file
)
console
.
log
(
this
.
image
)
console
.
log
(
this
.
image
)
},
},
deleteCategory
(
ID
,
index
)
{
deleteCategory
(
ID
,
index
)
{
const
self
=
this
const
self
=
this
this
.
editedIndex
=
this
.
categories
.
indexOf
(
index
)
this
.
editedIndex
=
this
.
categories
.
indexOf
(
index
)
if
(
confirm
(
"
Do you really want to delete?
"
))
{
if
(
confirm
(
'
Do you really want to delete?
'
))
{
try
{
try
{
this
.
$axios
this
.
$axios
.
delete
(
`/categories/
${
ID
}
`
,
.
delete
(
`/categories/
${
ID
}
`
,
{
{
headers
:
{
headers
:
{
"
Content-Type
"
:
"
multipart/form-data
"
,
'
Content-Type
'
:
'
multipart/form-data
'
,
Authorization
:
`Bearer
${
this
.
$auth
.
$storage
.
getUniversal
(
"
token
"
)}
`
,
Authorization
:
`Bearer
${
this
.
$auth
.
$storage
.
getUniversal
(
'
token
'
)}
`
},
}
})
})
.
then
(
response
=>
{
.
then
((
response
)
=>
{
this
.
categories
.
splice
(
this
.
editedIndex
,
1
)
this
.
categories
.
splice
(
this
.
editedIndex
,
1
)
self
.
$toast
.
success
(
'
Category deleted successfully!
'
,
{
self
.
$toast
.
success
(
'
Category deleted successfully!
'
,
{
duration
:
3000
duration
:
3000
})
})
})
})
}
catch
(
error
)
{
}
catch
(
error
)
{
console
.
log
(
error
)
console
.
log
(
error
)
}
}
}
}
},
},
getID
(
item
)
{
getID
(
item
)
{
console
.
log
(
this
.
categories
.
indexOf
(
item
))
console
.
log
(
this
.
categories
.
indexOf
(
item
))
},
},
editCategory
(
item
)
{
editCategory
(
item
)
{
this
.
$bvModal
.
show
(
'
modal-edit
'
)
this
.
eID
=
item
.
id
this
.
eID
=
item
.
id
this
.
eName
=
item
.
name
this
.
eName
=
item
.
name
this
.
eOrdering
=
item
.
ordering
this
.
eOrdering
=
item
.
ordering
...
@@ -339,30 +484,31 @@ export default {
...
@@ -339,30 +484,31 @@ export default {
console
.
log
(
this
?.
eID
)
console
.
log
(
this
?.
eID
)
console
.
log
(
item
)
console
.
log
(
item
)
},
},
updateCategory
(
userID
)
{
updateCategory
(
userID
)
{
const
set
=
new
Set
([
this
.
eImage
])
const
set
=
new
Set
([
this
.
eImage
])
const
image
=
Array
.
from
(
set
)
const
image
=
Array
.
from
(
set
)
const
self
=
this
const
self
=
this
console
.
log
(
this
.
eName
)
console
.
log
(
this
.
eName
)
console
.
log
(
this
.
eOrdering
)
console
.
log
(
this
.
eOrdering
)
console
.
log
(
this
?.
eID
)
console
.
log
(
this
?.
eID
)
try
{
try
{
this
.
$axios
this
.
$axios
.
post
(
`categories/update/
${
this
?.
eID
}
`,
.
post
(
`categories/update/
${
this
?.
eID
}
`,
{
{
name: this.eName,
name: this.eName,
ordering: this.eOrdering,
ordering: this.eOrdering,
parent_id: this.eParentId,
parent_id: this.eParentId,
images: image },
images: image
},
{
{
headers: {
headers: {
"Content-Type": "multipart/form-data"
,
'Content-Type': 'multipart/form-data'
,
Authorization: `
Bearer
$
{
this
.
$auth
.
$storage
.
getUniversal
(
"
token
"
)}
`,
Authorization: `
Bearer
$
{
this
.
$auth
.
$storage
.
getUniversal
(
'
token
'
)}
`
}
}
}
}
)
)
.then(response
=> {
.then((response)
=> {
self.$toast.success('User updated successfully!',
{
self.$toast.success('User updated successfully!',
{
duration: 3000
duration: 3000
})
})
console.log(response)
console.log(response)
...
@@ -370,10 +516,10 @@ export default {
...
@@ -370,10 +516,10 @@ export default {
this.$bvModal.hide('modal-edit')
this.$bvModal.hide('modal-edit')
Object.assign(this.categories[this.editedIndex], this.editedItem)
Object.assign(this.categories[this.editedIndex], this.editedItem)
})
})
} catch
(error)
{
} catch
(error)
{
console.log(error)
console.log(error)
}
}
}
}
}
,
}
}
}
</
script
>
</
script
>
pages/users/index.vue
View file @
fd18168c
<!-- eslint-disable vue/valid-v-slot -->
<
template
>
<
template
>
<v-app>
<v-app>
<div>
<div>
<div
/>
<div>
<div>
<v-breadcrumbs
:items=
"items"
>
<v-breadcrumbs
:items=
"items"
>
<template
#divider
>
<template
#divider
>
...
@@ -155,6 +155,7 @@
...
@@ -155,6 +155,7 @@
<v-spacer
/>
<v-spacer
/>
</v-toolbar>
</v-toolbar>
</
template
>
</
template
>
// eslint-disable-next-line vue/valid-v-slot
<
template
#item.actions=
"{ item }"
>
<
template
#item.actions=
"{ item }"
>
<v-icon
:id=
"item.id"
small
class=
"mr-2"
@
click=
"dialog2 = true; editUser(item);"
>
<v-icon
:id=
"item.id"
small
class=
"mr-2"
@
click=
"dialog2 = true; editUser(item);"
>
mdi-pencil
mdi-pencil
...
@@ -170,7 +171,7 @@
...
@@ -170,7 +171,7 @@
</
template
>
</
template
>
</v-data-table>
</v-data-table>
</div>
</div>
</v-app>
</v-app>
</template>
</template>
<
script
>
<
script
>
export
default
{
export
default
{
...
...
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