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

View file

@ -41,6 +41,7 @@ import {
SaveButton,
UndoButton,
EditButton,
CancelButton,
} from 'src/components/button';
import { RequestWork } from 'src/stores/request-list/types';
import { storeToRefs } from 'pinia';
@ -893,6 +894,20 @@ function storeDataLocal() {
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(
() => pageState.mode,
() => toggleMode(pageState.mode),
@ -1267,7 +1282,15 @@ async function submitAccepted() {
{{ $t('general.view', { msg: $t('general.example') }) }}
</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
outlined
v-if="pageState.mode === 'edit'"