feat: add btn cancel

This commit is contained in:
Thanaphon Frappet 2025-02-24 16:49:10 +07:00
parent f12c9e9df6
commit b36caa48e2
2 changed files with 37 additions and 16 deletions

View file

@ -54,7 +54,7 @@ import {
SaveButton, SaveButton,
EditButton, EditButton,
UndoButton, UndoButton,
CloseButton, CancelButton,
MainButton, MainButton,
} from 'components/button'; } from 'components/button';
import QuotationFormReceipt from './QuotationFormReceipt.vue'; import QuotationFormReceipt from './QuotationFormReceipt.vue';
@ -2233,14 +2233,9 @@ async function formDownload() {
</article> </article>
<footer class="surface-1 q-pa-md full-width"> <footer class="surface-1 q-pa-md full-width">
<div <div class="row full-width justify-end">
class="row full-width"
:class="{
'justify-between': view !== View.InvoicePre,
'justify-end': view === View.InvoicePre,
}"
>
<MainButton <MainButton
class="q-mr-auto"
v-if=" v-if="
view !== View.InvoicePre && view !== View.InvoicePre &&
view !== View.PaymentPre && view !== View.PaymentPre &&
@ -2255,6 +2250,14 @@ async function formDownload() {
{{ $t('general.view', { msg: $t('general.example') }) }} {{ $t('general.view', { msg: $t('general.example') }) }}
</MainButton> </MainButton>
<CancelButton
outlined
id="btn-close"
@click="closeTab()"
:label="$t('dialog.action.close')"
v-if="quotationFormState.mode === 'info' && closeAble()"
/>
<div <div
v-if=" v-if="
view === View.Accepted && view === View.Accepted &&
@ -2293,6 +2296,7 @@ async function formDownload() {
</template> </template>
<div <div
class="q-ml-sm"
v-if=" v-if="
view === View.Invoice && view === View.Invoice &&
((quotationFormData.quotationStatus !== 'PaymentPending' && ((quotationFormData.quotationStatus !== 'PaymentPending' &&
@ -2317,7 +2321,7 @@ async function formDownload() {
</div> </div>
<div <div
class="row" class="row q-ml-sm"
style="gap: var(--size-2)" style="gap: var(--size-2)"
v-if=" v-if="
(view === View.Quotation && (view === View.Quotation &&
@ -2332,12 +2336,6 @@ async function formDownload() {
id="btn-undo" id="btn-undo"
v-if="quotationFormState.mode === 'edit'" v-if="quotationFormState.mode === 'edit'"
/> />
<CloseButton
outlined
id="btn-close"
@click="closeTab()"
v-if="quotationFormState.mode === 'info' && closeAble()"
/>
<SaveButton <SaveButton
type="submit" type="submit"
id="btn-save" id="btn-save"

View file

@ -41,6 +41,7 @@ import {
SaveButton, SaveButton,
UndoButton, UndoButton,
EditButton, EditButton,
CancelButton,
} from 'src/components/button'; } from 'src/components/button';
import { RequestWork } from 'src/stores/request-list/types'; import { RequestWork } from 'src/stores/request-list/types';
import { storeToRefs } from 'pinia'; import { storeToRefs } from 'pinia';
@ -893,6 +894,20 @@ function storeDataLocal() {
window.open(url, '_blank'); window.open(url, '_blank');
} }
async function closeTab() {
dialogWarningClose(t, {
message: t('dialog.message.close'),
action: () => {
window.close();
},
cancel: () => {},
});
}
function closeAble() {
return window.opener !== null;
}
watch( watch(
() => pageState.mode, () => pageState.mode,
() => toggleMode(pageState.mode), () => toggleMode(pageState.mode),
@ -1267,7 +1282,15 @@ async function submitAccepted() {
{{ $t('general.view', { msg: $t('general.example') }) }} {{ $t('general.view', { msg: $t('general.example') }) }}
</MainButton> </MainButton>
<div class="row q-gutter-x-sm"> <CancelButton
outlined
id="btn-close"
@click="closeTab()"
:label="$t('dialog.action.close')"
v-if="pageState.mode === 'info' && closeAble()"
/>
<div class="row q-gutter-x-sm q-ml-xs">
<UndoButton <UndoButton
outlined outlined
v-if="pageState.mode === 'edit'" v-if="pageState.mode === 'edit'"