Commit 11820750 authored by hong-IT-99's avatar hong-IT-99

update code

parent 4765c90f
import { defineComponent } from 'vue'; import { defineComponent, Ref, ref, watch } from 'vue';
// import { i18n } from 'src/boot/i18n'; // import { i18n } from 'src/boot/i18n';
// import { isEmail } from '../../../boot/functions'; // import { isEmail } from '../../../boot/functions';
// import { isMobilePhone } from '../../../boot/functions'; // import { isMobilePhone } from '../../../boot/functions';
import UploadImage from '../../upload-image/index.vue';
export default defineComponent({ export default defineComponent({
components: {
UploadImage
},
props: { props: {
openAddHotProduct: { openAddHotProduct: {
type: Boolean, type: Boolean,
requied: true requied: true
}, },
status: { type: Boolean || Number, required: false },
}, },
setup() {
setup(props, context) {
const file: Ref<File | string> = ref('')
const code: Ref<string> = ref('')
const embeddedUrl: Ref<string> = ref('')
const urlFileLocal: Ref<string> = ref('')
const status: Ref<number> = ref(2)
const uploadAvatar = (value: FileList) => {
urlFileLocal.value = URL.createObjectURL(value[0])
file.value = value[0]
};
watch(
() => props.openAddHotProduct,
(value) => {
if (value) {
ResetData()
}
}
);
const ResetData = () => {
file.value = ''
code.value = ''
embeddedUrl.value = ''
urlFileLocal.value = ''
status.value = 2
}
const SubbmitData = () => {
context.emit('click:CloseBtnAddHotProduct')
context.emit('insertData', {
file: file.value,
code: code.value,
status: status.value,
embeddedUrl: embeddedUrl.value,
imageUrl: urlFileLocal.value
})
}
return { return {
uploadAvatar,
SubbmitData,
urlFileLocal,
file,
code,
embeddedUrl,
status,
ResetData
}; };
}, },
emits: [ emits: [
'insertData',
'update:openAddHotProduct', 'update:openAddHotProduct',
'update:status', 'update:statusHotProduct',
'selectedFile',
'click:CloseBtnAddHotProduct' 'click:CloseBtnAddHotProduct'
], ],
}); });
...@@ -4,7 +4,8 @@ ...@@ -4,7 +4,8 @@
:model-value="openAddHotProduct" :model-value="openAddHotProduct"
@update:model-value="$emit('update:openAddHotProduct', $event)" @update:model-value="$emit('update:openAddHotProduct', $event)"
> >
<q-card style="min-width: 700px" bordered> <q-card style="min-width: 600px" bordered>
<q-form greedy > <q-form greedy >
<q-card-section> <q-card-section>
<q-item> <q-item>
...@@ -20,27 +21,21 @@ ...@@ -20,27 +21,21 @@
<q-card-section> <q-card-section>
<div class="row q-col-gutter-sm"> <div class="row q-col-gutter-sm">
<div class="col-12"> <div class="col-12">
<q-card flat style="max-height:200px" v-if="urlFileLocal">
<div align=center>
<q-img :src="urlFileLocal" style="max-height:200px;aspect-ratio: 16/9;" >
</q-img>
</div>
</q-card>
<UploadImage
class="q-mt-md"
:isBtn="true"
@selectedFile="uploadAvatar"
></UploadImage>
<q-input <q-input
:label=" v-model="code"
$t('artist.artistInformation.titleDataField.artistCode') label="
" Mã sản phẩm
type="text"
class="q-my-sm"
outlined
hide-bottom-space
clearable
></q-input>
<q-input
:label="$t('artist.artistInformation.titleDataField.fullName')"
hide-bottom-space
type="text"
class="q-my-sm"
outlined
clearable
></q-input>
<q-input
:label="
$t('artist.artistInformation.titleDataField.artistName')
" "
type="text" type="text"
class="q-my-sm" class="q-my-sm"
...@@ -49,21 +44,15 @@ ...@@ -49,21 +44,15 @@
clearable clearable
></q-input> ></q-input>
<q-input <q-input
:label="$t('artist.artistInformation.titleDataField.birthday')" v-model="embeddedUrl"
type="text" label="Url embed"
class="q-my-sm"
outlined
hide-bottom-space hide-bottom-space
clearable
></q-input>
<q-input
:label="$t('artist.artistInformation.titleDataField.email')"
type="text" type="text"
class="q-my-sm" class="q-my-sm"
outlined outlined
hide-bottom-space
clearable clearable
></q-input> ></q-input>
</div> </div>
<div style="padding-top: 13px; padding-left: 12px"> <div style="padding-top: 13px; padding-left: 12px">
<span class="text-body1">{{ <span class="text-body1">{{
...@@ -71,8 +60,9 @@ ...@@ -71,8 +60,9 @@
}}</span }}</span
> >
<q-toggle <q-toggle
v-model="status"
:model-value="status" :false-value="2"
:true-value="1"
/> />
</div> </div>
...@@ -88,11 +78,12 @@ ...@@ -88,11 +78,12 @@
@click="$emit('click:CloseBtnAddHotProduct')" @click="$emit('click:CloseBtnAddHotProduct')"
/> />
<q-btn <q-btn
type="submit"
color="primary" color="primary"
no-caps no-caps
style="width: 90px" style="width: 90px"
:label="$t('customer.crudActions.save')" :label="$t('customer.crudActions.save')"
@click="SubbmitData"
/> />
</q-card-actions> </q-card-actions>
</q-form> </q-form>
......
...@@ -7,8 +7,9 @@ export default defineComponent({ ...@@ -7,8 +7,9 @@ export default defineComponent({
}, },
props: { props: {
products: { type: Array, required: true }, products: { type: Array, required: true },
// DataInsertHotProduct: { type: Object, requied: false }
}, },
setup() { setup(_, context) {
const userTableColumnsHotProduct = [ const userTableColumnsHotProduct = [
{ {
name: 'STT', name: 'STT',
...@@ -62,6 +63,7 @@ export default defineComponent({ ...@@ -62,6 +63,7 @@ export default defineComponent({
sortable: false, sortable: false,
}, },
]; ];
const userTableRowsHotProduct: Ref<unknown[]> = ref([]); const userTableRowsHotProduct: Ref<unknown[]> = ref([]);
const pageIndex = ref(1); const pageIndex = ref(1);
const pageSize = ref(20); const pageSize = ref(20);
...@@ -90,6 +92,12 @@ export default defineComponent({ ...@@ -90,6 +92,12 @@ export default defineComponent({
void getListHotProduct(); void getListHotProduct();
}; };
const clickAdd = () => {
context.emit('click:addHotProduct');
}
const deleteRow = (index: number) => {
context.emit('deleteRow', index)
}
onMounted(() => { onMounted(() => {
void getListHotProduct(); void getListHotProduct();
}); });
...@@ -99,10 +107,11 @@ export default defineComponent({ ...@@ -99,10 +107,11 @@ export default defineComponent({
pageIndex, pageIndex,
pageSize, pageSize,
totalPage, totalPage,
deleteRow,
getListHotProduct, getListHotProduct,
changePageSize, changePageSize,
clickAdd,
}; };
}, },
emits: ['click:addHotProduct'] emits: ['click:addHotProduct', 'reset', 'deleteRow']
}); });
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
<q-space></q-space> <q-space></q-space>
<div class="col-auto"> <div class="col-auto">
<q-btn <q-btn
@click="$emit('click:addHotProduct')" @click="clickAdd"
color="primary" color="primary"
no-caps no-caps
style="width: 100px" style="width: 100px"
...@@ -39,7 +39,7 @@ ...@@ -39,7 +39,7 @@
</q-td> </q-td>
</template> </template>
<template v-slot:body-cell-action> <template v-slot:body-cell-action="item">
<q-td style="padding: 0; height: 100%"> <q-td style="padding: 0; height: 100%">
<div align="center"> <div align="center">
<q-btn flat round color="primary" icon="mdi-circle-edit-outline"> <q-btn flat round color="primary" icon="mdi-circle-edit-outline">
...@@ -47,7 +47,7 @@ ...@@ -47,7 +47,7 @@
Sửa Sửa
</q-tooltip> </q-tooltip>
</q-btn> </q-btn>
<q-btn flat round color="primary" icon="mdi-delete-outline"> <q-btn flat round color="primary" @click="deleteRow(item.rowIndex)" icon="mdi-delete-outline">
<q-tooltip> <q-tooltip>
Xóa Xóa
</q-tooltip> </q-tooltip>
......
...@@ -86,6 +86,9 @@ ...@@ -86,6 +86,9 @@
</q-tab-panel> </q-tab-panel>
<q-tab-panel name="hotProduct"> <q-tab-panel name="hotProduct">
<HotProduct <HotProduct
@deleteRow="confirmDeleteRow($event)"
@reset="resetOldData"
:DataInsertHotProduct="DataInsertHotProduct"
@click:addHotProduct="openAddHotProduct = true" @click:addHotProduct="openAddHotProduct = true"
:products="products" :products="products"
></HotProduct> ></HotProduct>
...@@ -123,7 +126,8 @@ ...@@ -123,7 +126,8 @@
@click:CloseBtn="isOpenDialogEmbed = false" @click:CloseBtn="isOpenDialogEmbed = false"
></UploadEmbedDialog> ></UploadEmbedDialog>
<AddHotProductDialog <AddHotProductDialog
v-model:status="status" @insertData="pushData"
v-model:status-hot-product="statusHotProduct"
v-model:open-add-hot-product="openAddHotProduct" v-model:open-add-hot-product="openAddHotProduct"
@click:CloseBtnAddHotProduct="openAddHotProduct = false" @click:CloseBtnAddHotProduct="openAddHotProduct = false"
></AddHotProductDialog> ></AddHotProductDialog>
......
import { defineComponent, onMounted, ref, Ref } from 'vue'; import { defineComponent, onMounted, ref, Ref, } from 'vue';
import PersonalInformation from '../../components/artist-information/personal-information/index.vue'; import PersonalInformation from '../../components/artist-information/personal-information/index.vue';
import VabAccount from '../../components/artist-information/VAB-account/index.vue'; import VabAccount from '../../components/artist-information/VAB-account/index.vue';
import BankAccount from '../../components/artist-information/bank-account/index.vue'; import BankAccount from '../../components/artist-information/bank-account/index.vue';
...@@ -153,6 +153,11 @@ export default defineComponent({ ...@@ -153,6 +153,11 @@ export default defineComponent({
const isDefault: Ref<number | undefined> = ref(1); const isDefault: Ref<number | undefined> = ref(1);
const rowBankAccIdx: Ref<number> = ref(0); const rowBankAccIdx: Ref<number> = ref(0);
//satate hot product
const statusHotProduct: Ref<number> = ref(2)
const DataInsertHotProduct: Ref<ProductType | null> = ref(null)
const getInformationArtist = async () => { const getInformationArtist = async () => {
const response = (await api({ const response = (await api({
url: API_PATHS.getDetailArtist, url: API_PATHS.getDetailArtist,
...@@ -340,6 +345,33 @@ export default defineComponent({ ...@@ -340,6 +345,33 @@ export default defineComponent({
isOpenEditAccountBankDialog.value = false; isOpenEditAccountBankDialog.value = false;
}; };
const pushData = (value: ProductType) => {
products.value.push(value)
}
const reset = ref(null);
const resetOldData = () => {
document.getElementById('reset')?.click()
}
const confirmDeleteRow = (value: number) => {
Dialog.create({
title: i18n.global.t(
'artist.bankAccount.confirmActionsTitle.confirmDeleteAccBankTitle'
),
message: i18n.global.t(
'artist.bankAccount.confirmActionsTitle.confirmDeleteAccBankContent'
),
cancel: i18n.global.t(
'artist.bankAccount.confirmActionsTitle.confirmDeleteAccBankBtnLabel'
),
color: 'negative',
}).onOk(() => {
deleteRowItem(value);
});
};
const deleteRowItem = (index: number) => {
products.value.splice(index, 1)
}
onMounted(() => { onMounted(() => {
void getInformationArtist(); void getInformationArtist();
void getFieldOptions(); void getFieldOptions();
...@@ -414,6 +446,13 @@ export default defineComponent({ ...@@ -414,6 +446,13 @@ export default defineComponent({
openDialogEditAccBank, openDialogEditAccBank,
editAccBank, editAccBank,
rowBankAccIdx, rowBankAccIdx,
statusHotProduct,
DataInsertHotProduct,
pushData,
resetOldData,
reset,
deleteRowItem,
confirmDeleteRow
}; };
}, },
}); });
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