Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Q
quasar-web-base
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
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
Nguyễn Hải Sơn
quasar-web-base
Commits
6f70d087
Commit
6f70d087
authored
May 12, 2021
by
Tình Trương
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
e6d011a0
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
166 additions
and
96 deletions
+166
-96
configurations.example.ts
src/assets/configurations.example.ts
+1
-0
type.ts
src/assets/type.ts
+0
-2
index.vue
src/components/add-update-post/index.vue
+134
-89
index.ts
src/i18n/vi/index.ts
+1
-0
index.vue
src/pages/bai-viet/index.vue
+30
-5
No files found.
src/assets/configurations.example.ts
View file @
6f70d087
...
@@ -70,4 +70,5 @@ export enum API_PATHS {
...
@@ -70,4 +70,5 @@ export enum API_PATHS {
deletePost
=
'post/delete'
,
deletePost
=
'post/delete'
,
detailCustomer
=
'customer/detail'
,
detailCustomer
=
'customer/detail'
,
updateCustomer
=
'customer/update'
,
updateCustomer
=
'customer/update'
,
getPostCategory
=
'postCategory'
,
}
}
src/assets/type.ts
View file @
6f70d087
import
{
type
}
from
'os'
;
export
type
PaginationResponse
<
DataType
>
=
{
export
type
PaginationResponse
<
DataType
>
=
{
pageIndex
:
null
|
number
;
pageIndex
:
null
|
number
;
pageSize
:
null
|
number
;
pageSize
:
null
|
number
;
...
...
src/components/add-update-post/index.vue
View file @
6f70d087
...
@@ -30,7 +30,33 @@
...
@@ -30,7 +30,33 @@
style=
"max-height: calc(100vh - 10rem)"
style=
"max-height: calc(100vh - 10rem)"
>
>
<div
class=
"row q-col-gutter-sm"
>
<div
class=
"row q-col-gutter-sm"
>
<div
class=
"col-5"
>
<div
class=
"col-12"
>
<q-tabs
v-model=
"tab"
dense
class=
"text-grey"
active-color=
"primary"
indicator-color=
"primary"
align=
"justify"
narrow-indicator
>
<q-tab
v-for=
"(info, index) in languageOptions"
:key=
"`$
{info.id}-${index}`"
:name="info.code"
:label="info.name"
no-caps
/>
</q-tabs>
<q-separator
/>
<q-tab-panels
v-model=
"tab"
animated
>
<q-tab-panel
v-for=
"(info, index) in languageOptions"
:key=
"`$
{info.id}-${index}`"
:name="info.code"
>
<div
class=
"row q-mt-sm flex-center"
>
<div
class=
"row q-mt-sm flex-center"
>
<div>
<div>
<q-card
style=
"margin-bottom: 8px"
v-if=
"image !== null"
>
<q-card
style=
"margin-bottom: 8px"
v-if=
"image !== null"
>
...
@@ -61,7 +87,7 @@
...
@@ -61,7 +87,7 @@
:size=
"'xs'"
:size=
"'xs'"
></q-icon>
></q-icon>
<div
class=
"q-mt-xs"
>
<div
class=
"q-mt-xs"
>
{{
$t
(
'uploadImage.uploadBanner
'
)
}}
{{
$t
(
'post.uploadImg
'
)
}}
</div>
</div>
</div>
</div>
...
@@ -75,8 +101,8 @@
...
@@ -75,8 +101,8 @@
</q-card>
</q-card>
</div>
</div>
</div>
</div>
</div>
<div
class=
"col-7
"
>
<div
class=
"q-pt-md
"
>
<q-input
<q-input
:model-value=
"name"
:model-value=
"name"
@
update:model-value=
"$emit('update:name', $event)"
@
update:model-value=
"$emit('update:name', $event)"
...
@@ -84,14 +110,14 @@
...
@@ -84,14 +110,14 @@
type=
"text"
type=
"text"
class=
"q-my-sm"
class=
"q-my-sm"
outlined
outlined
:rules=
"nameRules
"
:rules=
"tab === 'vn' ? nameRules : []
"
clearable
clearable
></q-input>
></q-input>
<q-select
<q-select
:model-value=
"category"
:model-value=
"category"
@
update:model-value=
"$emit('update:category', $event)"
@
update:model-value=
"$emit('update:category', $event)"
:label=
"$t('post.dialogLabel.postLabels.category')"
:label=
"$t('post.dialogLabel.postLabels.category')"
:rules=
"categoryRules
"
:rules=
"tab === 'vn' ? categoryRules : []
"
:options=
"categoryOptions"
:options=
"categoryOptions"
map-options
map-options
option-value=
"id"
option-value=
"id"
...
@@ -104,13 +130,13 @@
...
@@ -104,13 +130,13 @@
:model-value=
"content"
:model-value=
"content"
@
update:model-value=
"$emit('update:content', $event)"
@
update:model-value=
"$emit('update:content', $event)"
:label=
"$t('post.dialogLabel.postLabels.content')"
:label=
"$t('post.dialogLabel.postLabels.content')"
:rules=
"contentRules
"
:rules=
"tab === 'vn' ? contentRules : []
"
type=
"textarea"
type=
"textarea"
class=
"q-my-sm"
class=
"q-my-sm"
outlined
outlined
clearable
clearable
></q-input>
></q-input>
<div
class=
"q-pt-sm"
>
<div
>
<span
class=
"text-body1"
>
{{
<span
class=
"text-body1"
>
{{
$t
(
'post.dialogLabel.postLabels.status'
)
$t
(
'post.dialogLabel.postLabels.status'
)
}}
</span
}}
</span
...
@@ -122,7 +148,12 @@
...
@@ -122,7 +148,12 @@
/>
/>
</div>
</div>
</div>
</div>
</q-tab-panel>
</q-tab-panels>
</div>
</div>
</div>
<div
class=
"row q-col-gutter-sm"
></div>
</q-card-section>
</q-card-section>
<q-card-actions
align=
"right"
>
<q-card-actions
align=
"right"
>
<div>
<div>
...
@@ -149,7 +180,7 @@
...
@@ -149,7 +180,7 @@
</
template
>
</
template
>
<
script
lang=
"ts"
>
<
script
lang=
"ts"
>
import
{
defineComponent
,
ref
}
from
'vue'
;
import
{
defineComponent
,
PropType
,
ref
}
from
'vue'
;
import
{
i18n
}
from
'src/boot/i18n'
;
import
{
i18n
}
from
'src/boot/i18n'
;
// import UploadImage from '../../upload-image/index.vue';
// import UploadImage from '../../upload-image/index.vue';
export
default
defineComponent
({
export
default
defineComponent
({
...
@@ -168,6 +199,16 @@ export default defineComponent({
...
@@ -168,6 +199,16 @@ export default defineComponent({
categoryOptions
:
{
type
:
Array
,
required
:
true
},
categoryOptions
:
{
type
:
Array
,
required
:
true
},
content
:
{
type
:
String
,
required
:
true
},
content
:
{
type
:
String
,
required
:
true
},
status
:
{
type
:
Number
,
required
:
true
},
status
:
{
type
:
Number
,
required
:
true
},
languageOptions
:
{
type
:
Array
as
PropType
<
{
id
:
number
;
code
:
string
;
name
:
string
;
}[]
>
,
required
:
true
,
},
},
},
setup
(
_
,
context
)
{
setup
(
_
,
context
)
{
const
selectedFile
=
(
value
:
FileList
)
=>
{
const
selectedFile
=
(
value
:
FileList
)
=>
{
...
@@ -208,6 +249,9 @@ export default defineComponent({
...
@@ -208,6 +249,9 @@ export default defineComponent({
(
val
&&
val
.
trim
().
length
)
||
(
val
&&
val
.
trim
().
length
)
||
i18n
.
global
.
t
(
'post.validateMessages.requireName'
),
i18n
.
global
.
t
(
'post.validateMessages.requireName'
),
];
];
const
tab
=
ref
(
'vn'
);
tab
.
value
=
'vn'
;
return
{
return
{
contentRules
,
contentRules
,
nameRules
,
nameRules
,
...
@@ -217,6 +261,7 @@ export default defineComponent({
...
@@ -217,6 +261,7 @@ export default defineComponent({
upload
,
upload
,
uploadAvatar
,
uploadAvatar
,
deleteAvatar
,
deleteAvatar
,
tab
,
};
};
},
},
emits
:
[
emits
:
[
...
...
src/i18n/vi/index.ts
View file @
6f70d087
...
@@ -632,6 +632,7 @@ export default {
...
@@ -632,6 +632,7 @@ export default {
//bài viết
//bài viết
post
:
{
post
:
{
title
:
'Danh sách bài viết'
,
title
:
'Danh sách bài viết'
,
uploadImg
:
'Tải lên ảnh bài viết'
,
tableColumnsPost
:
{
tableColumnsPost
:
{
stt
:
'STT'
,
stt
:
'STT'
,
name
:
'Tên bài viết'
,
name
:
'Tên bài viết'
,
...
...
src/pages/bai-viet/index.vue
View file @
6f70d087
...
@@ -81,9 +81,9 @@
...
@@ -81,9 +81,9 @@
</q-td>
</q-td>
</
template
>
</
template
>
<
template
v-slot:body-cell-image=
"image"
>
<
template
v-slot:body-cell-image=
"image"
>
<q-td
style=
"padding: auto; height: 100%"
class=
"center"
>
<q-td
style=
"padding: auto; height: 100%"
class=
"
flex flex-
center"
>
<q-img
<q-img
style=
"width:
7
rem"
style=
"width:
9
rem"
fit=
"contain"
fit=
"contain"
:ratio=
"16 / 9"
:ratio=
"16 / 9"
:src=
"image.row.image"
:src=
"image.row.image"
...
@@ -129,6 +129,7 @@
...
@@ -129,6 +129,7 @@
v-model:image=
"image"
v-model:image=
"image"
v-model:content=
"content"
v-model:content=
"content"
v-model:status=
"status"
v-model:status=
"status"
:languageOptions=
"languageOptions"
:categoryOptions=
"categoryOptions"
:categoryOptions=
"categoryOptions"
isUpdate
isUpdate
@
SetAvatar=
"setAvatar($event)"
@
SetAvatar=
"setAvatar($event)"
...
@@ -143,6 +144,7 @@
...
@@ -143,6 +144,7 @@
v-model:image=
"image"
v-model:image=
"image"
v-model:content=
"content"
v-model:content=
"content"
v-model:status=
"status"
v-model:status=
"status"
:languageOptions=
"languageOptions"
:categoryOptions=
"categoryOptions"
:categoryOptions=
"categoryOptions"
@
SetAvatar=
"setAvatar($event)"
@
SetAvatar=
"setAvatar($event)"
@
deleteAvatar=
"deleteAvatar"
@
deleteAvatar=
"deleteAvatar"
...
@@ -158,7 +160,12 @@ import Pagination from 'components/pagination/index.vue';
...
@@ -158,7 +160,12 @@ import Pagination from 'components/pagination/index.vue';
import
{
API_PATHS
}
from
'src/assets/configurations'
;
import
{
API_PATHS
}
from
'src/assets/configurations'
;
import
{
AxiosResponse
}
from
'axios'
;
import
{
AxiosResponse
}
from
'axios'
;
import
{
api
,
BaseResponseBody
}
from
'src/boot/axios'
;
import
{
api
,
BaseResponseBody
}
from
'src/boot/axios'
;
import
{
PaginationResponse
,
Post
,
FileUploadType
}
from
'src/assets/type'
;
import
{
PaginationResponse
,
Post
,
FileUploadType
,
CategoryPostType
,
}
from
'src/assets/type'
;
import
{
config
}
from
'src/assets/configurations'
;
import
{
config
}
from
'src/assets/configurations'
;
import
{
PostStatus
}
from
'src/assets/enums'
;
import
{
PostStatus
}
from
'src/assets/enums'
;
import
AddUpdatePostDialog
from
'components/add-update-post/index.vue'
;
import
AddUpdatePostDialog
from
'components/add-update-post/index.vue'
;
...
@@ -282,6 +289,10 @@ export default defineComponent({
...
@@ -282,6 +289,10 @@ export default defineComponent({
const
namePost
=
ref
(
''
);
const
namePost
=
ref
(
''
);
const
avatarFile
:
Ref
<
File
|
null
>
=
ref
(
null
);
const
avatarFile
:
Ref
<
File
|
null
>
=
ref
(
null
);
const
avatarUploaded
:
Ref
<
string
|
null
>
=
ref
(
null
);
const
avatarUploaded
:
Ref
<
string
|
null
>
=
ref
(
null
);
const
languageOptions
=
ref
([
{
id
:
1
,
code
:
'vn'
,
name
:
'Tiếng Việt'
},
{
id
:
2
,
code
:
'en'
,
name
:
'Tiếng Anh'
},
]);
const
changePageSize
=
()
=>
{
const
changePageSize
=
()
=>
{
pageIndex
.
value
=
1
;
pageIndex
.
value
=
1
;
...
@@ -353,11 +364,10 @@ export default defineComponent({
...
@@ -353,11 +364,10 @@ export default defineComponent({
const
addNewPost
=
async
()
=>
{
const
addNewPost
=
async
()
=>
{
// const data = {
// const data = {
// name: name.value,
// name: name.value,
// description: description.value,
// status: status.value,
// status: status.value,
// };
// };
// const response = (await api({
// const response = (await api({
//
//
url: API_PATHS.addPost,
// url: API_PATHS.addPost,
// method: 'POST',
// method: 'POST',
// data,
// data,
// })) as AxiosResponse
<
BaseResponseBody
<
[]
>>
;
// })) as AxiosResponse
<
BaseResponseBody
<
[]
>>
;
...
@@ -443,8 +453,21 @@ export default defineComponent({
...
@@ -443,8 +453,21 @@ export default defineComponent({
image
.
value
=
null
;
image
.
value
=
null
;
};
};
//gọi api danh mục bv
const
getpostCategory
=
async
()
=>
{
const
response
=
(
await
api
({
url
:
API_PATHS
.
getPostCategory
,
method
:
'GET'
,
params
:
{},
}))
as
AxiosResponse
<
BaseResponseBody
<
CategoryPostType
[]
>>
;
if
(
response
.
data
.
error
.
code
===
config
.
API_RES_CODE
.
OK
.
code
)
{
categoryOptions
.
value
=
response
.
data
.
data
;
}
};
onMounted
(()
=>
{
onMounted
(()
=>
{
void
getListPost
();
void
getListPost
();
void
getpostCategory
();
});
});
return
{
return
{
pageIndex
,
pageIndex
,
...
@@ -470,11 +493,13 @@ export default defineComponent({
...
@@ -470,11 +493,13 @@ export default defineComponent({
updateNewPost
,
updateNewPost
,
namePost
,
namePost
,
content
,
content
,
languageOptions
,
image
,
image
,
postId
,
postId
,
setAvatar
,
setAvatar
,
callApiUploadAvatar
,
callApiUploadAvatar
,
deleteAvatar
,
deleteAvatar
,
getpostCategory
,
};
};
},
},
});
});
...
...
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