refactor: delete btn test
This commit is contained in:
parent
0b7d94f6dc
commit
a9d58748fe
1 changed files with 31 additions and 14 deletions
|
|
@ -7,7 +7,9 @@ import useOptionStore from 'stores/options';
|
||||||
|
|
||||||
import { Status } from 'stores/types';
|
import { Status } from 'stores/types';
|
||||||
import { CustomerBranch, CustomerType } from 'stores/customer/types';
|
import { CustomerBranch, CustomerType } from 'stores/customer/types';
|
||||||
|
import { useI18n } from 'vue-i18n';
|
||||||
|
|
||||||
|
import { dialog } from 'stores/utils';
|
||||||
import ButtonAddComponent from 'components/ButtonAddCompoent.vue';
|
import ButtonAddComponent from 'components/ButtonAddCompoent.vue';
|
||||||
import SideMenu from 'components/SideMenu.vue';
|
import SideMenu from 'components/SideMenu.vue';
|
||||||
import { DialogFormContainer, DialogHeader } from 'components/dialog';
|
import { DialogFormContainer, DialogHeader } from 'components/dialog';
|
||||||
|
|
@ -32,6 +34,7 @@ import {
|
||||||
} from './components';
|
} from './components';
|
||||||
|
|
||||||
const flowStore = useFlowStore();
|
const flowStore = useFlowStore();
|
||||||
|
const { t } = useI18n();
|
||||||
|
|
||||||
const customerStore = useCustomerStore();
|
const customerStore = useCustomerStore();
|
||||||
const { fetchListCustomeBranch } = customerStore;
|
const { fetchListCustomeBranch } = customerStore;
|
||||||
|
|
@ -141,6 +144,29 @@ const branchFieldSelected = ref<
|
||||||
)[]
|
)[]
|
||||||
>(fieldDisplay.value);
|
>(fieldDisplay.value);
|
||||||
|
|
||||||
|
async function deleteBranchById(id: string) {
|
||||||
|
return await new Promise((resolve) => {
|
||||||
|
dialog({
|
||||||
|
color: 'negative',
|
||||||
|
icon: 'mdi-alert',
|
||||||
|
title: t('deleteConfirmTitle'),
|
||||||
|
actionText: t('ok'),
|
||||||
|
persistent: true,
|
||||||
|
message: t('deleteConfirmMessage'),
|
||||||
|
action: async () => {
|
||||||
|
await customerStore.deleteBranchById(id);
|
||||||
|
await fetchList();
|
||||||
|
flowStore.rotate();
|
||||||
|
resolve(true);
|
||||||
|
customerBranchFormState.value.dialogModal = false;
|
||||||
|
},
|
||||||
|
cancel: () => {
|
||||||
|
resolve(false);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
async function fetchList() {
|
async function fetchList() {
|
||||||
if (!customerId.value) return;
|
if (!customerId.value) return;
|
||||||
|
|
||||||
|
|
@ -449,20 +475,6 @@ watch([customerId, inputSearch, currentStatus], async () => {
|
||||||
}
|
}
|
||||||
"
|
"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<q-btn
|
|
||||||
label="test"
|
|
||||||
size="sm"
|
|
||||||
dense
|
|
||||||
round
|
|
||||||
flat
|
|
||||||
@click="
|
|
||||||
() => {
|
|
||||||
currentBtnOpen[props.rowIndex] =
|
|
||||||
!currentBtnOpen[props.rowIndex];
|
|
||||||
}
|
|
||||||
"
|
|
||||||
/>
|
|
||||||
</q-td>
|
</q-td>
|
||||||
</q-tr>
|
</q-tr>
|
||||||
|
|
||||||
|
|
@ -559,6 +571,11 @@ watch([customerId, inputSearch, currentStatus], async () => {
|
||||||
<DeleteButton
|
<DeleteButton
|
||||||
icon-only
|
icon-only
|
||||||
v-if="customerBranchFormState.dialogType === 'info'"
|
v-if="customerBranchFormState.dialogType === 'info'"
|
||||||
|
@click="
|
||||||
|
() => {
|
||||||
|
deleteBranchById(customerBranchFormData.id || '');
|
||||||
|
}
|
||||||
|
"
|
||||||
/>
|
/>
|
||||||
<UndoButton
|
<UndoButton
|
||||||
icon-only
|
icon-only
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue