update

parent 3a2e60f7
...@@ -134,5 +134,6 @@ export enum API_PATHS { ...@@ -134,5 +134,6 @@ export enum API_PATHS {
getListDeposit = 'deposit', getListDeposit = 'deposit',
formalityDeposit = 'common/formalityDeposit', // danh sách hình thức đặt cọc formalityDeposit = 'common/formalityDeposit', // danh sách hình thức đặt cọc
configHomeProduct = 'config/home/product', configHomeProduct = 'config/home/product',
artistFeaturedProduct= 'artist/featuredProduct' artistFeaturedProduct= 'artist/featuredProduct',
homeProductNotActive = 'config/home/productNotActive'
} }
...@@ -79,10 +79,26 @@ export type ArtistInfoType = { ...@@ -79,10 +79,26 @@ export type ArtistInfoType = {
mnIns: string | null; mnIns: string | null;
mnWhatsapp: string | null; mnWhatsapp: string | null;
favoriteScore: number; favoriteScore: number;
listProductNotActivess: listProductNotActives[];
artistOwner: { artistOwner: {
name: string; name: string;
}; };
}; };
export type listProductNotActives = {
artistId: number;
artistName: {
artistName: string;
id: number;
};
code: string;
embeddedUrl: string;
id: number;
imageUrl: number;
isFeaturedOnHomepage: number;
name: string;
};
export type ProvinceType = { export type ProvinceType = {
name: string; name: string;
fullname: string; fullname: string;
......
<template>
<q-dialog persistent :model-value="isOpened">
<q-card style="min-width: 1200px" bordered>
<q-form greedy @submit.prevent="handleConfirmAdd">
<q-card-section style="padding-bottom: 10px">
<q-item style="padding-left: 10px">
<q-item-section>
<q-item-label class="text-h6 text-weight-regular"
>Danh sách sản phẩm</q-item-label
>
</q-item-section>
</q-item>
</q-card-section>
<div class="col-12 q-mt-sm">
<q-table
:rows="bannerTableRows"
:columns="bannerTableColumns"
row-key="id"
wrap-cells
:no-data-label="$t('emptyData')"
:rows-per-page-label="$t('recordPerPage')"
:pagination="{
rowsPerPage: 0,
}"
hide-pagination
style="max-height: calc(100vh - 17rem)"
:selected-rows-label="getSelectedString"
selection="multiple"
v-model:selected="selected"
>
<template v-slot:body-cell-imageUrl="image">
<q-td style="padding: auto; height: 100%; text-align: center">
<q-img
style="width: 18rem; height: 6rem"
:src="configImg.API_IMAGE_ENDPOINT + image.row.imageUrl"
></q-img>
</q-td>
</template>
<template v-slot:body-cell-artistName="item">
<q-td style="padding: auto; height: 100%; text-align: center">
{{ item.row.artistName.artistName }}
</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="listProductNotActive"
/>
</div>
<q-card-actions align="right">
<q-btn @click="handleTogle" color="grey" no-caps style="width: 90px" label="Hủy" />
<q-btn
type="submit"
color="primary"
no-caps
style="width: 90px"
label="Ok"
/>
</q-card-actions>
</q-form>
</q-card>
</q-dialog>
</template>
<script lang="ts">
import { i18n } from 'src/boot/i18n';
import { defineComponent, PropType, Ref, ref, watch } from 'vue';
import { Dialog, Notify } from 'quasar';
import { API_PATHS, config } from 'src/assets/configurations.example';
import { AxiosResponse } from 'axios';
import { api, BaseResponseBody } from 'src/boot/axios';
import Pagination from 'components/pagination/index.vue';
import { listProductNotActives, PaginationResponse } from 'src/assets/type';
import { emit } from 'cluster';
export default defineComponent({
components: {
Pagination,
// AddUpdateBannerDialog,
},
props: {
isOpened: {
type: Boolean,
required: true,
},
},
setup(props, context) {
watch(
() => props.isOpened,
(value) => {
if (value) {
selected.value = []
void listProductNotActive();
}
}
);
const bannerTableColumns = [
{
name: 'name',
field: 'name',
required: true,
label: 'Tên sản phẩm',
headerStyle: 'text-align: center !important; width: 20%',
align: 'left',
sortable: false,
},
{
name: 'code',
field: 'code',
required: true,
label: 'Mã sản phẩm',
align: 'center',
headerStyle: 'width: 10%',
sortable: false,
},
{
name: 'artistName',
field: 'artistName',
required: true,
label: 'Tên nghệ sỹ',
align: 'center',
headerStyle: 'width: 10%',
sortable: false,
},
{
name: 'embeddedUrl',
field: 'embeddedUrl',
required: true,
label: i18n.global.t('artist.hotProduct.tableColumnsProduct.urlEmbed'),
headerStyle: 'text-align: center !important; width: 25%',
align: 'left',
sortable: false,
},
{
name: 'imageUrl',
field: 'imageUrl',
required: true,
label: i18n.global.t(
'artist.hotProduct.tableColumnsProduct.productImage'
),
align: 'center',
sortable: false,
headerStyle: 'width: 25%',
},
];
const configImg = config;
const selected = ref([]);
const getSelectedString = () => {
return selected.value.length === 0
? ''
: `${selected.value.length} sản phẩm đã được chọn `;
};
const changePageSize = () => {
pageIndex.value = 1;
void listProductNotActive();
};
const handleConfirmAdd = () => {
console.log(selected.value)
context.emit('update:isOpened', false);
}
const handleTogle = () => {
context.emit('update:isOpened', false);
}
const pageIndex = ref(1);
const pageSize = ref(20);
const totalPage = ref(1);
const bannerTableRows: Ref<unknown[]> = ref([]);
const listProductNotActive = async () => {
try {
const response = (await api({
url: API_PATHS.homeProductNotActive,
method: 'GET',
params: {
pageIndex: pageIndex.value,
pageSize: pageSize.value,
name: '',
artistName: '',
},
})) as AxiosResponse<
BaseResponseBody<
PaginationResponse<BaseResponseBody<listProductNotActives[]>>
>
>;
if (response.data.error.code === config.API_RES_CODE.OK.code) {
bannerTableRows.value = response.data.data.data;
totalPage.value = response.data.data.totalPages;
}
} catch (error) {}
};
return {
bannerTableRows,
bannerTableColumns,
pageIndex,
pageSize,
totalPage,
configImg,
selected,
changePageSize,
// hàm
// handleConfim,
listProductNotActive,
getSelectedString,
handleConfirmAdd,
handleTogle,
};
},
emits: ['update:isOpened'],
});
</script>
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
@update:model-value="$emit('update:isOpened', $event)" @update:model-value="$emit('update:isOpened', $event)"
> >
<q-card class="full-width" style="max-width: 85.71rem" bordered> <q-card class="full-width" style="max-width: 85.71rem" bordered>
<q-form <q-form
greedy greedy
@submit.prevent=" @submit.prevent="
...@@ -138,15 +139,9 @@ ...@@ -138,15 +139,9 @@
option-label="name" option-label="name"
class="q-my-sm" class="q-my-sm"
outlined outlined
use-chips
clearable clearable
><template v-slot:no-option> ></q-select
<q-item>
<q-item-section class="text-grey">
{{ $t('managingUnitAdd.noDataTable') }}
</q-item-section>
</q-item>
</template></q-select
> >
<div class="q-pt-sm q-pl-sm"> <div class="q-pt-sm q-pl-sm">
<span class="text-body1">{{ <span class="text-body1">{{
...@@ -642,11 +637,7 @@ export default defineComponent({ ...@@ -642,11 +637,7 @@ export default defineComponent({
'managingUnit.validateMessages.requireLengthRepresentative' 'managingUnit.validateMessages.requireLengthRepresentative'
), ),
]; ];
const fieldsRules = [
(val?: Array<unknown>) =>
val?.length ||
i18n.global.t('managingUnit.validateMessages.requireFields'),
];
const phoneNumberRules = [ const phoneNumberRules = [
(val?: string) => (val?: string) =>
(val && val.trim().length) || (val && val.trim().length) ||
...@@ -921,7 +912,7 @@ export default defineComponent({ ...@@ -921,7 +912,7 @@ export default defineComponent({
addressRules, addressRules,
phoneNumberRules, phoneNumberRules,
emailRules, emailRules,
fieldsRules,
artistOptions, artistOptions,
artistTableColumns, artistTableColumns,
artistField, artistField,
......
...@@ -5,6 +5,8 @@ ...@@ -5,6 +5,8 @@
<q-separator vertical spaced /> <q-separator vertical spaced />
</div> </div>
<q-space></q-space> <q-space></q-space>
<q-btn color="primary" label="Thêm mới" @click="openAddDialog = true">
</q-btn>
<div class="col-12 q-mt-sm"> <div class="col-12 q-mt-sm">
<q-table <q-table
:rows="bannerTableRows" :rows="bannerTableRows"
...@@ -60,17 +62,10 @@ ...@@ -60,17 +62,10 @@
/> />
</div> </div>
<!-- <AddUpdateBannerDialog <AddDialog
v-model:isOpened="addBannerDialogIsOpened" v-model:isOpened="openAddDialog"
v-model:name="name"
v-model:image="image"
v-model:numIndex="numIndex"
v-model:status="status"
@SetAvatar="setAvatar($event)"
@deleteAvatar="deleteAvatar"
isUpdate
@saveBannerInfo="addBanner" @saveBannerInfo="addBanner"
/> --> />
</div> </div>
</template> </template>
...@@ -89,7 +84,7 @@ import { ...@@ -89,7 +84,7 @@ import {
} from 'src/assets/type'; } from 'src/assets/type';
import { config, API_PATHS } from 'src/assets/configurations.example'; import { config, API_PATHS } from 'src/assets/configurations.example';
import { BannerStatus } from 'src/assets/enums'; import { BannerStatus } from 'src/assets/enums';
// import AddUpdateBannerDialog from 'components/add-update-banner/index.vue'; import AddDialog from 'components/danh-sach-san-pham-noi-bat-chua-chon/add.vue';
import { Dialog, Notify } from 'quasar'; import { Dialog, Notify } from 'quasar';
export type AvatarType = { export type AvatarType = {
...@@ -100,6 +95,7 @@ export type AvatarType = { ...@@ -100,6 +95,7 @@ export type AvatarType = {
export default defineComponent({ export default defineComponent({
components: { components: {
Pagination, Pagination,
AddDialog,
// AddUpdateBannerDialog, // AddUpdateBannerDialog,
}, },
setup() { setup() {
...@@ -172,6 +168,7 @@ export default defineComponent({ ...@@ -172,6 +168,7 @@ export default defineComponent({
}; };
const bannerTableRows: Ref<unknown[]> = ref([]); const bannerTableRows: Ref<unknown[]> = ref([]);
const addBannerDialogIsOpened = ref(false); const addBannerDialogIsOpened = ref(false);
const openAddDialog = ref(false);
const name = ref(''); const name = ref('');
const image: Ref<string | null> = ref(null); const image: Ref<string | null> = ref(null);
const numIndex: Ref<number | undefined> = ref(undefined); const numIndex: Ref<number | undefined> = ref(undefined);
...@@ -359,6 +356,7 @@ export default defineComponent({ ...@@ -359,6 +356,7 @@ export default defineComponent({
configImg, configImg,
avatarUploaded, avatarUploaded,
bannerId, bannerId,
openAddDialog,
}; };
}, },
}); });
......
...@@ -288,11 +288,13 @@ export default defineComponent({ ...@@ -288,11 +288,13 @@ export default defineComponent({
const unitNameKeyword = ref(''); const unitNameKeyword = ref('');
const fieldsOptions: Ref<ClassificationOptions[]> = ref([]); const fieldsOptions: Ref<ClassificationOptions[]> = ref([]);
const fieldsAddOptions: Ref<FieldType[]> = ref([]); const fieldsAddOptions: Ref<FieldType[]> = ref([]);
const fieldSelected: Ref<FieldType | undefined> = ref(); const fieldSelected: Ref<FieldType | undefined> = ref();
const addUnitDialogIsOpened = ref(false); const addUnitDialogIsOpened = ref(false);
const updateUnitDialogIsOpened = ref(false); const updateUnitDialogIsOpened = ref(false);
const unitField: Ref<unknown[]> = ref([]);
const unitField: Ref<ClassificationOptions[]> = ref([]);
const unitCode = ref(''); const unitCode = ref('');
const unitName = ref(''); const unitName = ref('');
const unitRepresentative = ref(''); const unitRepresentative = ref('');
...@@ -338,7 +340,6 @@ export default defineComponent({ ...@@ -338,7 +340,6 @@ export default defineComponent({
unitPassword.value = ''; unitPassword.value = '';
unitStatus.value = UnitStatus.active; unitStatus.value = UnitStatus.active;
addUnitDialogIsOpened.value = true; addUnitDialogIsOpened.value = true;
}; };
const openUpdateUnitDialog = (id: number) => { const openUpdateUnitDialog = (id: number) => {
...@@ -365,6 +366,7 @@ export default defineComponent({ ...@@ -365,6 +366,7 @@ export default defineComponent({
unitAddress.value = response.data.data.address; unitAddress.value = response.data.data.address;
unitStatus.value = response.data.data.status; unitStatus.value = response.data.data.status;
unitArtistList.value = response.data.data.contracts; unitArtistList.value = response.data.data.contracts;
unitField.value = response.data.data.classification; unitField.value = response.data.data.classification;
unitUserName.value = response.data.data.userName; unitUserName.value = response.data.data.userName;
unitPassword.value = response.data.data.password; unitPassword.value = response.data.data.password;
...@@ -419,7 +421,7 @@ export default defineComponent({ ...@@ -419,7 +421,7 @@ export default defineComponent({
}; };
//gọi api lĩnh vực //gọi api lĩnh vực
const getFieldAddOptions = async () => { const getFieldAddOptions = async () => {
const response = (await api({ const response = (await api({
url: API_PATHS.getFieldOptions, url: API_PATHS.getFieldOptions,
method: 'GET', method: 'GET',
...@@ -427,15 +429,9 @@ export default defineComponent({ ...@@ -427,15 +429,9 @@ export default defineComponent({
})) as AxiosResponse<BaseResponseBody<FieldType[]>>; })) as AxiosResponse<BaseResponseBody<FieldType[]>>;
if (response.data.error.code === config.API_RES_CODE.OK.code) { if (response.data.error.code === config.API_RES_CODE.OK.code) {
fieldsAddOptions.value = response.data.data; fieldsAddOptions.value = response.data.data;
} }
}; };
const getFieldOptions = async () => { const getFieldOptions = async () => {
const response = (await api({ const response = (await api({
url: API_PATHS.getClassificationOptions, url: API_PATHS.getClassificationOptions,
...@@ -448,7 +444,6 @@ export default defineComponent({ ...@@ -448,7 +444,6 @@ export default defineComponent({
}; };
const updateNewUnit = async () => { const updateNewUnit = async () => {
const data = { const data = {
id: unitId.value, id: unitId.value,
name: unitName.value, name: unitName.value,
...@@ -482,8 +477,7 @@ export default defineComponent({ ...@@ -482,8 +477,7 @@ export default defineComponent({
}; };
//add //add
const addNewUnit = async () => { const addNewUnit = async () => {
let hasError = false; let hasError = false;
if (hasError === false) { if (hasError === false) {
...@@ -495,7 +489,7 @@ export default defineComponent({ ...@@ -495,7 +489,7 @@ export default defineComponent({
email: unitEmail.value, email: unitEmail.value,
phoneNumber: unitPhoneNumber.value, phoneNumber: unitPhoneNumber.value,
status: unitStatus.value, status: unitStatus.value,
classification: unitField.value === null ? null : unitField.value , classification: unitField.value.length === 0 ? null : unitField.value,
userName: unitUserName.value, userName: unitUserName.value,
password: unitPassword.value, password: unitPassword.value,
contracts: unitArtistList.value, contracts: unitArtistList.value,
...@@ -522,7 +516,7 @@ export default defineComponent({ ...@@ -522,7 +516,7 @@ export default defineComponent({
onMounted(() => { onMounted(() => {
void getListUnits(); void getListUnits();
void getFieldOptions(); void getFieldOptions();
void getFieldAddOptions() void getFieldAddOptions();
}); });
return { return {
check_artistList, check_artistList,
......
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