Commit 6f70d087 authored by Tình Trương's avatar Tình Trương

update

parent e6d011a0
...@@ -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',
} }
import { type } from 'os';
export type PaginationResponse<DataType> = { export type PaginationResponse<DataType> = {
pageIndex: null | number; pageIndex: null | number;
pageSize: null | number; pageSize: null | number;
......
...@@ -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: [
......
...@@ -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',
......
...@@ -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: 7rem" style="width: 9rem"
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,
}; };
}, },
}); });
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment