update

parent 3a2e60f7
......@@ -134,5 +134,6 @@ export enum API_PATHS {
getListDeposit = 'deposit',
formalityDeposit = 'common/formalityDeposit', // danh sách hình thức đặt cọc
configHomeProduct = 'config/home/product',
artistFeaturedProduct= 'artist/featuredProduct'
artistFeaturedProduct= 'artist/featuredProduct',
homeProductNotActive = 'config/home/productNotActive'
}
......@@ -79,10 +79,26 @@ export type ArtistInfoType = {
mnIns: string | null;
mnWhatsapp: string | null;
favoriteScore: number;
listProductNotActivess: listProductNotActives[];
artistOwner: {
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 = {
name: 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 @@
@update:model-value="$emit('update:isOpened', $event)"
>
<q-card class="full-width" style="max-width: 85.71rem" bordered>
<q-form
greedy
@submit.prevent="
......@@ -138,15 +139,9 @@
option-label="name"
class="q-my-sm"
outlined
use-chips
clearable
><template v-slot:no-option>
<q-item>
<q-item-section class="text-grey">
{{ $t('managingUnitAdd.noDataTable') }}
</q-item-section>
</q-item>
</template></q-select
></q-select
>
<div class="q-pt-sm q-pl-sm">
<span class="text-body1">{{
......@@ -642,11 +637,7 @@ export default defineComponent({
'managingUnit.validateMessages.requireLengthRepresentative'
),
];
const fieldsRules = [
(val?: Array<unknown>) =>
val?.length ||
i18n.global.t('managingUnit.validateMessages.requireFields'),
];
const phoneNumberRules = [
(val?: string) =>
(val && val.trim().length) ||
......@@ -921,7 +912,7 @@ export default defineComponent({
addressRules,
phoneNumberRules,
emailRules,
fieldsRules,
artistOptions,
artistTableColumns,
artistField,
......
......@@ -5,6 +5,8 @@
<q-separator vertical spaced />
</div>
<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">
<q-table
:rows="bannerTableRows"
......@@ -60,17 +62,10 @@
/>
</div>
<!-- <AddUpdateBannerDialog
v-model:isOpened="addBannerDialogIsOpened"
v-model:name="name"
v-model:image="image"
v-model:numIndex="numIndex"
v-model:status="status"
@SetAvatar="setAvatar($event)"
@deleteAvatar="deleteAvatar"
isUpdate
<AddDialog
v-model:isOpened="openAddDialog"
@saveBannerInfo="addBanner"
/> -->
/>
</div>
</template>
......@@ -89,7 +84,7 @@ import {
} from 'src/assets/type';
import { config, API_PATHS } from 'src/assets/configurations.example';
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';
export type AvatarType = {
......@@ -100,6 +95,7 @@ export type AvatarType = {
export default defineComponent({
components: {
Pagination,
AddDialog,
// AddUpdateBannerDialog,
},
setup() {
......@@ -172,6 +168,7 @@ export default defineComponent({
};
const bannerTableRows: Ref<unknown[]> = ref([]);
const addBannerDialogIsOpened = ref(false);
const openAddDialog = ref(false);
const name = ref('');
const image: Ref<string | null> = ref(null);
const numIndex: Ref<number | undefined> = ref(undefined);
......@@ -359,6 +356,7 @@ export default defineComponent({
configImg,
avatarUploaded,
bannerId,
openAddDialog,
};
},
});
......
......@@ -288,11 +288,13 @@ export default defineComponent({
const unitNameKeyword = ref('');
const fieldsOptions: Ref<ClassificationOptions[]> = ref([]);
const fieldsAddOptions: Ref<FieldType[]> = ref([]);
const fieldSelected: Ref<FieldType | undefined> = ref();
const addUnitDialogIsOpened = ref(false);
const updateUnitDialogIsOpened = ref(false);
const unitField: Ref<unknown[]> = ref([]);
const unitField: Ref<ClassificationOptions[]> = ref([]);
const unitCode = ref('');
const unitName = ref('');
const unitRepresentative = ref('');
......@@ -338,7 +340,6 @@ export default defineComponent({
unitPassword.value = '';
unitStatus.value = UnitStatus.active;
addUnitDialogIsOpened.value = true;
};
const openUpdateUnitDialog = (id: number) => {
......@@ -365,6 +366,7 @@ export default defineComponent({
unitAddress.value = response.data.data.address;
unitStatus.value = response.data.data.status;
unitArtistList.value = response.data.data.contracts;
unitField.value = response.data.data.classification;
unitUserName.value = response.data.data.userName;
unitPassword.value = response.data.data.password;
......@@ -419,7 +421,7 @@ export default defineComponent({
};
//gọi api lĩnh vực
const getFieldAddOptions = async () => {
const getFieldAddOptions = async () => {
const response = (await api({
url: API_PATHS.getFieldOptions,
method: 'GET',
......@@ -427,15 +429,9 @@ export default defineComponent({
})) as AxiosResponse<BaseResponseBody<FieldType[]>>;
if (response.data.error.code === config.API_RES_CODE.OK.code) {
fieldsAddOptions.value = response.data.data;
}
};
const getFieldOptions = async () => {
const response = (await api({
url: API_PATHS.getClassificationOptions,
......@@ -448,7 +444,6 @@ export default defineComponent({
};
const updateNewUnit = async () => {
const data = {
id: unitId.value,
name: unitName.value,
......@@ -482,8 +477,7 @@ export default defineComponent({
};
//add
const addNewUnit = async () => {
const addNewUnit = async () => {
let hasError = false;
if (hasError === false) {
......@@ -495,7 +489,7 @@ export default defineComponent({
email: unitEmail.value,
phoneNumber: unitPhoneNumber.value,
status: unitStatus.value,
classification: unitField.value === null ? null : unitField.value ,
classification: unitField.value.length === 0 ? null : unitField.value,
userName: unitUserName.value,
password: unitPassword.value,
contracts: unitArtistList.value,
......@@ -522,7 +516,7 @@ export default defineComponent({
onMounted(() => {
void getListUnits();
void getFieldOptions();
void getFieldAddOptions()
void getFieldAddOptions();
});
return {
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