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

update

parent f9adb60e
......@@ -107,4 +107,7 @@ export enum API_PATHS {
addConfigPartner = 'config/home/partner/add',
getDetailConfigPartner = 'config/home/partner/detail',
updateConfigPartner = 'config/home/partner/update',
getListConfigHotProduct = 'config/home/product',
getDetailConfigHotProduct = 'config/home/product/detail',
updateConfigHotProduct = 'config/home/product/update/salient',
}
......@@ -667,3 +667,31 @@ export type addConfigPartnerConfig = {
updateBy: string;
updateTime: string;
};
export type ListConfigHotProduct = {
id: number;
code: string;
name: string;
artistName: string;
embeddedUrl: string;
imageUrl: string;
salientStatus: number;
};
export type DetailConfigHotProduct = {
id: number;
code: string;
name: string;
artistName: string;
embeddedUrl: string;
imageUrl: string;
salientStatus: number;
};
export type UpdateConfigHotProduct = {
id: number;
code: string;
name: string;
artistName: string;
embeddedUrl: string;
imageUrl: string;
salientStatus: number;
};
......@@ -30,7 +30,7 @@
style="max-height: calc(100vh - 15rem)"
>
<div class="row q-col-gutter-sm">
<div class="col-6">
<div class="col-6 q-mt-sm">
<div class="row flex-center">
<div>
<q-card class="q-mb-sm" v-if="image !== null">
......
......@@ -4,7 +4,7 @@
:model-value="isOpened"
@update:model-value="$emit('update:isOpened', $event)"
>
<q-card style="min-width: 80rem" bordered>
<q-card class="full-width" style="max-width: 80rem" bordered>
<q-form
greedy
@submit.prevent="
......@@ -27,23 +27,39 @@
</q-card-section>
<q-separator />
<q-card-section>
<q-card-section
class="overflow-auto"
style="max-height: calc(100vh - 15rem)"
>
<div class="row q-col-gutter-sm">
<div class="col-6 q-py-md">
<div class="col-6 q-mt-sm">
<div class="row flex-center">
<q-card v-if="image !== null">
<div>
<q-card class="q-mb-sm" v-if="imageUrl !== null">
<q-img
@click="uploadImg"
:src="image"
style="height: 13.75rem; width: 18.75rem; cursor: pointer"
@click="uploadAvatar"
:src="imageUrl"
style="height: 290px; width: 450px; cursor: pointer"
></q-img>
<q-icon
name="mdi-close-circle"
color="red"
style="
position: absolute;
right: 0;
font-size: 18px;
cursor: pointer;
"
@click="deleteAvatar"
></q-icon>
</q-card>
<div
@click="uploadImg"
@click="uploadAvatar"
v-else
class="q-mb-sm"
style="
height: 13.75rem;
width: 18.75rem;
height: 290px;
width: 450px;
border: 2px dashed #5d319e;
border-radius: 4px;
cursor: pointer;
......@@ -51,7 +67,8 @@
>
<div
style="
height: 100%;
height: 290px;
width: 450px;
display: flex;
align-items: center;
justify-content: center;
......@@ -70,153 +87,57 @@
<input
ref="upload"
hidden
@change="selectedFile($event.target.files)"
type="file"
accept="image/png, image/jpeg"
@change="selectedFile($event.target.files)"
/>
</div>
</div>
</div>
</div>
<div class="col-6">
<q-input
:model-value="title"
@update:model-value="$emit('update:title', $event)"
:label="$t('listHotProduct.dialogLabel.fieldLabels.title')"
:model-value="artistName"
@update:model-value="$emit('update:artistName', $event)"
:label="$t('listHotProduct.dialogLabel.fieldLabels.artistName')"
class="q-my-sm"
type="text"
outlined
:rules="titleRules"
:rules="artistNameRules"
clearable
></q-input>
<q-input
:model-value="urlTarget"
@update:model-value="$emit('update:urlTarget', $event)"
:label="$t('listHotProduct.dialogLabel.fieldLabels.urlTarget')"
:model-value="name"
@update:model-value="$emit('update:name', $event)"
:label="$t('listHotProduct.dialogLabel.fieldLabels.name')"
class="q-my-sm"
type="text"
outlined
:rules="urlTargetRules"
:rules="nameRules"
clearable
></q-input>
<q-input
:model-value="location"
@update:model-value="$emit('update:location', $event)"
:label="$t('listHotProduct.dialogLabel.fieldLabels.location')"
:model-value="embeddedUrl"
@update:model-value="$emit('update:embeddedUrl', $event)"
:label="
$t('listHotProduct.dialogLabel.fieldLabels.embeddedUrl')
"
class="q-my-sm"
type="text"
outlined
:rules="embeddedUrlRules"
clearable
></q-input>
<div class="q-pt-sm">
<span class="text-body1">{{
$t('listHotProduct.dialogLabel.fieldLabels.status')
$t('listHotProduct.dialogLabel.fieldLabels.salientStatus')
}}</span
><q-toggle
:model-value="status"
:model-value="salientStatus"
:true-value="SystemHotProductStatus.active"
:false-value="SystemHotProductStatus.inactive"
@update:model-value="$emit('update:status', $event)"
/>
</div>
</div>
<div class="col-12">
<div>
<q-editor
:model-value="content"
@update:model-value="$emit('update:content', $event)"
ref="editorRef"
placeholder="Nội dung *"
toolbar-text-color="white"
toolbar-toggle-color="yellow-8"
toolbar-bg="primary"
style="height: 20rem"
:toolbar="[
[
{
label: $q.lang.editor.align,
icon: $q.iconSet.editor.align,
fixedLabel: true,
list: 'only-icons',
options: ['left', 'center', 'right', 'justify'],
},
],
[
'bold',
'italic',
'strike',
'underline',
'subscript',
'superscript',
],
['token', 'hr', 'link', 'custom_btn'],
['print', 'fullscreen'],
[
{
label: $q.lang.editor.formatting,
icon: $q.iconSet.editor.formatting,
list: 'no-icons',
options: [
'p',
'h1',
'h2',
'h3',
'h4',
'h5',
'h6',
'code',
],
},
{
label: $q.lang.editor.fontSize,
icon: $q.iconSet.editor.fontSize,
fixedLabel: true,
fixedIcon: true,
list: 'no-icons',
options: [
'size-1',
'size-2',
'size-3',
'size-4',
'size-5',
'size-6',
'size-7',
],
},
{
label: $q.lang.editor.defaultFont,
icon: $q.iconSet.editor.font,
fixedIcon: true,
list: 'no-icons',
options: [
'default_font',
'arial',
'arial_black',
'comic_sans',
'courier_new',
'impact',
'lucida_grande',
'times_new_roman',
'verdana',
],
},
'removeFormat',
],
['quote', 'unordered', 'ordered', 'outdent', 'indent'],
['undo', 'redo'],
['viewsource'],
]"
:fonts="{
arial: 'Arial',
arial_black: 'Arial Black',
comic_sans: 'Comic Sans MS',
courier_new: 'Courier New',
impact: 'Impact',
lucida_grande: 'Lucida Grande',
times_new_roman: 'Times New Roman',
verdana: 'Verdana',
}"
@update:model-value="$emit('update:salientStatus', $event)"
/>
</div>
</div>
......@@ -254,57 +175,64 @@ export default defineComponent({
required: true,
},
isUpdate: { type: Boolean, default: false },
image: { type: String, required: true },
title: { type: String, required: true },
location: { type: String, required: true },
content: { type: String, required: true },
urlTarget: { type: String, required: true },
status: { type: Number, required: true },
imageUrl: { type: String, required: true },
name: { type: String, required: true },
artistName: { type: String, required: true },
embeddedUrl: { type: String, required: true },
salientStatus: { type: Number, required: true },
},
setup(props, context) {
setup(_, context) {
const selectedFile = (value: FileList) => {
if (value.length !== 0) {
context.emit('SetAvatar', {
file: value[0],
url: URL.createObjectURL(value[0]),
});
}
};
const deleteAvatar = () => {
context.emit('deleteAvatar');
};
const upload = ref(null);
const uploadImg = () => {
const uploadAvatar = () => {
// eslint-disable-next-line
// @ts-ignore
// eslint-disable-next-line
upload.value?.click();
};
const titleRules = [
const nameRules = [
(val?: string) =>
(val && val.trim().length) ||
i18n.global.t('listHotProduct.validateMessages.requireName'),
];
const artistNameRules = [
(val?: string) =>
(val && val.trim().length) ||
i18n.global.t('listHotProduct.validateMessages.requireTitle'),
i18n.global.t('listHotProduct.validateMessages.requireArtistName'),
];
const urlTargetRules = [
const embeddedUrlRules = [
(val?: string) =>
(val && val.trim().length) ||
i18n.global.t('listHotProduct.validateMessages.requireUrlTarget'),
i18n.global.t('listHotProduct.validateMessages.requireEmbeddedUrl'),
];
return {
upload,
titleRules,
urlTargetRules,
nameRules,
artistNameRules,
embeddedUrlRules,
SystemHotProductStatus,
uploadImg,
selectedFile,
deleteAvatar,
uploadAvatar,
upload,
};
},
emits: [
'update:isOpened',
'update:image',
'update:title',
'update:location',
'update:content',
'update:urlTarget',
'update:status',
'update:imageUrl',
'update:name',
'update:artistName',
'update:embeddedUrl',
'update:salientStatus',
'SetAvatar',
'deleteAvatar',
'saveHotProductInfo',
],
});
......
......@@ -1144,47 +1144,40 @@ export default {
toolTipMessageDelete: 'Xóa',
title: 'Cấu hình Sản phẩm nổi bật',
titleColumnsTable: {
stt: 'STT',
image: 'Ảnh sản phẩm',
title: 'Tiêu đề',
content: 'Nội dung',
location: 'Vị trí',
urlTarget: 'Url target',
createTime: 'Người tạo',
createBy: 'T.G tạo',
updateTime: 'Người Cập nhật',
updateBy: 'T.G Cập nhật',
status: 'Trạng thái',
artistName: 'Tên nghệ sỹ',
name: 'Tên sản phẩm',
imageUrl: 'Ảnh sản phẩm',
embeddedUrl: 'Link Embed',
salientStatus: 'Trạng thái',
action: 'Chức năng',
},
dialogLabel: {
titleUpdate: 'Cập nhật Sản phẩm nổi bật',
titleAdd: 'Thêm Sản phẩm nổi bật',
fieldLabels: {
avatar: 'Ảnh sản phẩm',
urlTarget: 'Url target',
title: 'Tiêu đề',
content: 'Nội dung',
location: 'Vị trí',
status: 'Trạng thái',
artistName: 'Tên nghệ sỹ *',
name: 'Tên sản phẩm *',
embeddedUrl: 'Link Embed *',
salientStatus: 'Trạng thái',
},
},
validateMessages: {
requireTitle: 'Vui lòng nhập Tiêu đề',
requireUrlTarget: 'Vui lòng nhập Url target',
requireArtistName: 'Vui lòng nhập Tên nghệ sỹ',
requireName: 'Vui lòng nhập Tên sản phẩm',
requireEmbeddedUrl: 'Vui lòng nhập Link embed',
},
crudActions: {
save: 'Lưu',
cancel: 'Đóng',
},
statusLabel: {
active: 'Hoạt động',
inactive: 'Ngừng hoạt động',
active: 'Hiển thị',
inactive: 'Không hiển thị',
},
actionMessages: {
addSuccess: 'Thêm Sản phẩm nổi bật thành công',
updateSuccess: 'Cập nhật Sản phẩm nổi bật thành công',
deleteSuccess: 'Xóa Sản phẩm nổi bật thành công',
addSuccess: 'Thêm cấu hính sản phẩm nổi bật thành công',
updateSuccess: 'Cập nhật cấu hính sản phẩm nổi bật thành công',
deleteSuccess: 'Xóa cấu hình sản phẩm nổi bật thành công',
},
},
......
......@@ -7,10 +7,10 @@
<q-space></q-space>
<div class="col-2 sreach">
<q-input
v-model="sreachTitle"
v-model="name_artist"
dense
outlined
:label="$t('listHotProduct.titleColumnsTable.title')"
:label="$t('listHotProduct.titleColumnsTable.artistName')"
clearable
></q-input>
</div>
......@@ -21,6 +21,7 @@
color="primary"
no-caps
:label="$t('crudActions.search')"
@click="getListConfigHotProduct"
style="width: 100px"
>
</q-btn>
......@@ -63,37 +64,24 @@
$t('listHotProduct.toolTipMessageUpdate')
}}</q-tooltip>
</q-btn>
</q-td>
</template>
<template v-slot:body-cell-stt="item">
<q-td :item="item" style="text-align: center">
{{ 1 + item.rowIndex + pageSize * (pageIndex - 1) }}
</q-td>
</template>
<template v-slot:body-cell-content="item">
<td>
<div class="ellipsis-3-lines">
{{ !item.row.content ? '' : item.row.content }}
<q-tooltip :offset="[10, 10]" max-width="30%">{{
!item.row.content ? '' : item.row.content
<q-btn flat round color="primary" icon="mdi-delete-outline">
<!-- @click="confirmDeleteConfig(item.row.id)" -->
<q-tooltip :offset="[20, 10]">{{
$t('listHotProduct.toolTipMessageDelete')
}}</q-tooltip>
</div>
</td>
</q-btn>
</q-td>
</template>
<template v-slot:body-cell-image="image">
<q-td style="padding: auto; height: 100%" class="flex flex-center">
<template v-slot:body-cell-imageUrl="imageUrl">
<q-td style="padding: auto; height: 100%; text-align: center">
<q-img
style="width: 9rem"
fit="contain"
:ratio="16 / 9"
:src="configImg.API_IMAGE_ENDPOINT + image.row.image"
style="width: 12rem; height: 8rem"
:src="configImg.API_IMAGE_ENDPOINT + imageUrl.row.imageUrl"
></q-img>
</q-td>
</template>
<template v-slot:body-cell-status="rowData">
<template v-slot:body-cell-salientStatus="rowData">
<q-td>
<div align="center">
<q-chip
......@@ -114,30 +102,51 @@
</div>
</q-td>
</template>
<template v-slot:body-cell-embeddedUrl="rowData">
<q-td>
<div align="center">
<a
:href="rowData.row.embeddedUrl"
target="_blank"
style="max-width: 10rem"
>{{ rowData.row.embeddedUrl }}</a
>
</div>
</q-td>
</template>
</q-table>
</div>
<div class="col-12 q-mt-sm">
<Pagination
v-model:currentPage="pageIndex"
v-model:pageSize="pageSize"
:totalPage="totalPage"
@update:pageSize="changePageSize"
@update:currentPage="getListConfigHotProduct"
/>
</div>
<AddUpdateHotProductDialog
v-model:isOpened="showDialogAdd"
v-model:title="title"
v-model:content="content"
v-model:location="location"
v-model:url-target="urlTarget"
v-model:status="status"
v-model:image="image"
v-model:name="name"
v-model:embeddedUrl="embeddedUrl"
v-model:artistName="artistName"
v-model:salientStatus="salientStatus"
v-model:imageUrl="imageUrl"
@SetAvatar="setAvatar($event)"
@deleteAvatar="deleteAvatar"
isUpdate
@saveHotProductInfo="addProduct"
/>
<AddUpdateHotProductDialog
v-model:isOpened="showDialogUpdate"
v-model:title="title"
v-model:content="content"
v-model:location="location"
v-model:url-target="urlTarget"
v-model:status="status"
v-model:image="image"
v-model:name="name"
v-model:embeddedUrl="embeddedUrl"
v-model:artistName="artistName"
v-model:salientStatus="salientStatus"
v-model:imageUrl="imageUrl"
@SetAvatar="setAvatar($event)"
@deleteAvatar="deleteAvatar"
@saveHotProductInfo="updateHotProduct"
/>
</div>
......@@ -151,112 +160,67 @@ export type AvatarType = {
import AddUpdateHotProductDialog from 'components/hotProduct/index.vue';
import { SystemHotProductStatus } from 'src/assets/enums';
import { i18n } from 'src/boot/i18n';
import Pagination from 'components/pagination/index.vue';
import { defineComponent, onMounted, Ref, ref } from 'vue';
import { config } from 'src/assets/configurations';
import { config, API_PATHS } from 'src/assets/configurations';
import { AxiosResponse } from 'axios';
import { Notify } from 'quasar';
import { api, BaseResponseBody } from 'src/boot/axios';
import { FileUploadType } from 'src/assets/type';
import {
PaginationResponse,
FileUploadType,
ListConfigHotProduct,
DetailConfigHotProduct,
UpdateConfigHotProduct,
} from 'src/assets/type';
export default defineComponent({
components: {
Pagination,
AddUpdateHotProductDialog,
},
setup() {
const tableColumnsNews = [
{
name: 'stt',
field: 'stt',
required: true,
label: i18n.global.t('listHotProduct.titleColumnsTable.stt'),
headerStyle: 'text-align: center !important; width: 5%',
align: 'center',
sortable: false,
},
{
name: 'image',
field: 'image',
name: 'artistName',
field: 'artistName',
required: true,
label: i18n.global.t('listHotProduct.titleColumnsTable.image'),
label: i18n.global.t('listHotProduct.titleColumnsTable.artistName'),
align: 'left',
headerStyle: 'text-align: center !important; width: 10%',
headerStyle: 'text-align: center !important; width: 15%',
sortable: false,
},
{
name: 'title',
field: 'title',
name: 'name',
field: 'name',
required: true,
label: i18n.global.t('listHotProduct.titleColumnsTable.title'),
label: i18n.global.t('listHotProduct.titleColumnsTable.name'),
align: 'left',
headerStyle: 'text-align: center !important; width: 15%',
sortable: false,
},
{
name: 'content',
field: 'content',
name: 'imageUrl',
field: 'imageUrl',
required: true,
label: i18n.global.t('listHotProduct.titleColumnsTable.content'),
headerStyle: 'text-align: center !important; width: 20%',
label: i18n.global.t('listHotProduct.titleColumnsTable.imageUrl'),
align: 'left',
sortable: false,
},
{
name: 'location',
field: 'location',
required: true,
label: i18n.global.t('listHotProduct.titleColumnsTable.location'),
headerStyle: 'text-align: center !important; width: 5%',
align: 'center',
sortable: false,
},
{
name: 'urlTarget',
field: 'urlTarget',
required: true,
label: i18n.global.t('listHotProduct.titleColumnsTable.urlTarget'),
headerStyle: 'text-align: center !important; width: 10%',
align: 'center',
sortable: false,
},
{
name: 'createTime',
field: 'createTime',
required: true,
label: i18n.global.t('listHotProduct.titleColumnsTable.createTime'),
headerStyle: 'text-align: center !important; width: 8%',
align: 'left',
sortable: false,
},
{
name: 'createBy',
field: 'createBy',
required: true,
label: i18n.global.t('listHotProduct.titleColumnsTable.createBy'),
headerStyle: 'text-align: center !important; width: 8%',
align: 'left',
sortable: false,
},
{
name: 'updateTime',
field: 'updateTime',
required: true,
label: i18n.global.t('listHotProduct.titleColumnsTable.updateTime'),
headerStyle: 'text-align: center !important; width: 8%',
align: 'left',
sortable: false,
},
{
name: 'updateBy',
field: 'updateBy',
name: 'embeddedUrl',
field: 'embeddedUrl',
required: true,
label: i18n.global.t('listHotProduct.titleColumnsTable.updateBy'),
headerStyle: 'text-align: center !important; width: 12%',
label: i18n.global.t('listHotProduct.titleColumnsTable.embeddedUrl'),
align: 'left',
headerStyle: 'text-align: center !important; width: 15%',
sortable: false,
},
{
name: 'status',
field: 'status',
name: 'salientStatus',
field: 'salientStatus',
required: true,
label: i18n.global.t('listHotProduct.titleColumnsTable.status'),
label: i18n.global.t('listHotProduct.titleColumnsTable.salientStatus'),
headerStyle: 'text-align: center !important; width: 8%',
align: 'center',
sortable: false,
......@@ -272,64 +236,53 @@ export default defineComponent({
},
];
const listHotProduct: Ref<unknown[]> = ref([
// {
// stt: 1,
// image: '',
// title: 'Tiêu đề',
// content: 'Tiêu đề....',
// location: 1,
// urlTarget: 'www.aaa.vn',
// createTime: '10/10/2021 00:00:00',
// createBy: '10/10/2021 00:00:00',
// updateTime: '10/10/2021 00:00:00',
// updateBy: '10/10/2021 00:00:00',
// status: 1,
// },
]);
const listHotProduct: Ref<unknown[]> = ref([]);
const sreachTitle = ref('');
const name_artist = ref('');
const pageIndex = ref(1);
const pageSize = ref(20);
const totalPage = ref(1);
const changePageSize = () => {
pageIndex.value = 1;
void getlistHotProduct();
void getListConfigHotProduct();
};
const showDialogAdd = ref(false);
const showDialogUpdate = ref(false);
const title: Ref<string | null> = ref(null);
const location: Ref<string | null> = ref(null);
const content: Ref<string | null> = ref(null);
const urlTarget: Ref<string | null> = ref(null);
const status: Ref<number> = ref(SystemHotProductStatus.active);
const image: Ref<string | null> = ref(null);
const name: Ref<string | null> = ref(null);
const artistName: Ref<string | null> = ref(null);
const embeddedUrl: Ref<string | null> = ref(null);
const salientStatus: Ref<number> = ref(SystemHotProductStatus.active);
const imageUrl: Ref<string | null> = ref(null);
const avatarFile: Ref<File | null> = ref(null);
const avatarUploaded: Ref<string> = ref('');
const imageChange: Ref<string> = ref('');
const configImg = config;
const configHotProductId: Ref<number | undefined> = ref(undefined);
const getlistHotProduct = async () => {
// try {
// const response = (await api({
// url: API_PATHS.getlistHotProduct,
// method: 'GET',
// params: {
// pageIndex: pageIndex.value,
// pageSize: pageSize.value,
// },
// })) as AxiosResponse<BaseResponseBody<PaginationResponse<listHotProduct>>>;
// if (response.data.error.code === config.API_RES_CODE.OK.code) {
// listHotProduct.value = response.data.data.data;
// }
// } catch (error) {}
const getListConfigHotProduct = async () => {
const response = (await api({
url: API_PATHS.getListConfigHotProduct,
method: 'GET',
params: {
pageIndex: pageIndex.value,
pageSize: pageSize.value,
artistName: name_artist.value,
},
})) as AxiosResponse<
BaseResponseBody<PaginationResponse<ListConfigHotProduct[]>>
>;
if (response.data.error.code === config.API_RES_CODE.OK.code) {
listHotProduct.value = response.data.data.data;
totalPage.value = response.data.data.totalPages;
}
};
const openAddDialog = () => {
title.value = null;
urlTarget.value = null;
location.value = null;
content.value = null;
image.value = null;
status.value = SystemHotProductStatus.active;
name.value = '';
artistName.value = '';
embeddedUrl.value = '';
imageUrl.value = null;
salientStatus.value = SystemHotProductStatus.active;
showDialogAdd.value = true;
};
......@@ -360,62 +313,71 @@ export default defineComponent({
};
const openUpdateDialog = (id: number) => {
void getDetailPolicy(id);
void getDetailConfigHotProduct(id);
showDialogUpdate.value = true;
};
// eslint-disable-next-line @typescript-eslint/require-await
const getDetailPolicy = async (id: number) => {
const getDetailConfigHotProduct = async (id: number) => {
try {
console.log(id);
showDialogUpdate.value = true;
const response = (await api({
url: API_PATHS.getDetailConfigHotProduct,
method: 'GET',
params: {
id: id,
},
})) as AxiosResponse<BaseResponseBody<DetailConfigHotProduct>>;
if (response.data.error.code === config.API_RES_CODE.OK.code) {
configHotProductId.value = response.data.data.id;
name.value = response.data.data.name;
artistName.value = response.data.data.artistName;
salientStatus.value = response.data.data.salientStatus;
embeddedUrl.value = response.data.data.embeddedUrl;
imageUrl.value =
config.API_IMAGE_ENDPOINT + response.data.data.imageUrl;
imageChange.value = response.data.data.imageUrl;
}
} catch (error) {}
};
// const getDetailContact = async (id: number) => {
// try {
// const response = (await api({
// url: API_PATHS.detailContact,
// method: 'GET',
// params: {
// id: id,
// },
// })) as AxiosResponse<BaseResponseBody<ContactType>>;
// if (response.data.error.code === config.API_RES_CODE.OK.code) {
// customerInfo.value = response.data.data;
// showDialogUpdate.value = true;
// }
// } catch (error) {}
// };
const updateHotProduct = async () => {
if (avatarFile.value) {
avatarUploaded.value = await callApiUploadAvatar(avatarFile.value);
void updateConfigHotProduct(avatarUploaded.value);
} else {
void updateConfigHotProduct(imageChange.value);
}
};
const updateHotProduct = () => {
const updateConfigHotProduct = async (imageUrl: string) => {
const data = {
id: configHotProductId.value,
name: name.value,
artistName: artistName.value,
salientStatus: salientStatus.value,
embeddedUrl: embeddedUrl.value,
imageUrl,
};
const response = (await api({
url: API_PATHS.updateConfigHotProduct,
method: 'POST',
data,
})) as AxiosResponse<BaseResponseBody<UpdateConfigHotProduct[]>>;
if (response.data.error.code === config.API_RES_CODE.OK.code) {
showDialogUpdate.value = false;
Notify.create({
type: 'positive',
message: i18n.global.t(
'configPartner.actionMessages.updateConfigPartnerAccess'
),
actions: [{ icon: 'close', color: 'white' }],
});
void getListConfigHotProduct();
}
};
// const updateContact = async (item: ContactType) => {
// try {
// const response = (await api({
// url: API_PATHS.updateContact,
// method: 'POST',
// data: {
// id: item.id,
// content: item.content,
// status: item.status,
// },
// })) as AxiosResponse<BaseResponseBody<unknown>>;
// if (response.data.error.code === config.API_RES_CODE.OK.code) {
// Notify.create({
// type: 'positive',
// message: i18n.global.t('listHotProduct.actionMessages.updateAccess'),
// });
// void getlistHotProduct();
// showDialogUpdate.value = false;
// }
// } catch (error) {}
// };
const setAvatar = (value: { file?: File; url?: string }) => {
avatarFile.value = value.file as File;
image.value = value.url as string;
imageUrl.value = value.url as string;
};
const callApiUploadAvatar = async (file: File) => {
......@@ -437,35 +399,42 @@ export default defineComponent({
return '';
}
};
const deleteAvatar = () => {
imageUrl.value = null;
};
onMounted(() => {
void getlistHotProduct();
void getListConfigHotProduct();
});
return {
image,
imageUrl,
setAvatar,
callApiUploadAvatar,
configImg,
sreachTitle,
name_artist,
listHotProduct,
tableColumnsNews,
pageIndex,
pageSize,
totalPage,
changePageSize,
getDetailPolicy,
getDetailConfigHotProduct,
SystemHotProductStatus,
showDialogUpdate,
showDialogAdd,
title,
content,
location,
urlTarget,
status,
name,
artistName,
embeddedUrl,
salientStatus,
openUpdateDialog,
updateConfigHotProduct,
updateHotProduct,
openAddDialog,
addProduct,
getListConfigHotProduct,
configHotProductId,
avatarUploaded,
deleteAvatar,
};
},
});
......
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