feat: 01 dialog confirm change status
This commit is contained in:
parent
d290777e5e
commit
9b8f0b1139
3 changed files with 49 additions and 30 deletions
|
|
@ -9,6 +9,10 @@ export default {
|
||||||
confirmLogoutTitle: 'Confirm Logout',
|
confirmLogoutTitle: 'Confirm Logout',
|
||||||
confirmLogoutMessage: 'Do you want to log out?',
|
confirmLogoutMessage: 'Do you want to log out?',
|
||||||
|
|
||||||
|
confirmChangeStatusTitle: 'Confirm Status Change',
|
||||||
|
confirmChangeStatusOnMessage: 'Do you want to open?',
|
||||||
|
confirmChangeStatusOffMessage: 'Do you want to close?',
|
||||||
|
|
||||||
// Backend
|
// Backend
|
||||||
productGroupNotFound: 'Product group cannot be found.',
|
productGroupNotFound: 'Product group cannot be found.',
|
||||||
productGroupInUsed: 'Product group is in used.',
|
productGroupInUsed: 'Product group is in used.',
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,10 @@ export default {
|
||||||
confirmLogoutTitle: 'ยืนยันการออกจากระบบ',
|
confirmLogoutTitle: 'ยืนยันการออกจากระบบ',
|
||||||
confirmLogoutMessage: 'คุณต้องการออกจากระบบ ใช่หรือไม่',
|
confirmLogoutMessage: 'คุณต้องการออกจากระบบ ใช่หรือไม่',
|
||||||
|
|
||||||
|
confirmChangeStatusTitle: 'ยืนยันการเปลี่ยนสถานะ',
|
||||||
|
confirmChangeStatusOnMessage: 'คุณต้องการเปิดใช่หรือไม่',
|
||||||
|
confirmChangeStatusOffMessage: 'คุณต้องการปิดใช่หรือไม่',
|
||||||
|
|
||||||
// Backend
|
// Backend
|
||||||
productGroupNotFound: 'ไม่พบกลุ่มสินค้า',
|
productGroupNotFound: 'ไม่พบกลุ่มสินค้า',
|
||||||
productGroupInUsed: 'กลุ่มสินค้าที่ใช้งานอยู่',
|
productGroupInUsed: 'กลุ่มสินค้าที่ใช้งานอยู่',
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ import type { QTableProps } from 'quasar';
|
||||||
|
|
||||||
import useBranchStore from 'stores/branch';
|
import useBranchStore from 'stores/branch';
|
||||||
import useFlowStore from 'src/stores/flow';
|
import useFlowStore from 'src/stores/flow';
|
||||||
import { BranchWithChildren, BranchCreate } from 'stores/branch/types';
|
import { BranchWithChildren, BranchCreate, Branch } from 'stores/branch/types';
|
||||||
import { Status } from 'src/stores/types';
|
import { Status } from 'src/stores/types';
|
||||||
|
|
||||||
import useUtilsStore, { dialog } from 'src/stores/utils';
|
import useUtilsStore, { dialog } from 'src/stores/utils';
|
||||||
|
|
@ -411,6 +411,32 @@ function triggerDelete(id: string) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function triggerChangeStatus(
|
||||||
|
id: string,
|
||||||
|
status: string,
|
||||||
|
): Promise<Branch & { qrCodeImageUploadUrl: string; imageUploadUrl: string }> {
|
||||||
|
return await new Promise((resolve) => {
|
||||||
|
dialog({
|
||||||
|
color: 'warning',
|
||||||
|
icon: 'mdi-alert',
|
||||||
|
title: t('confirmChangeStatusTitle'),
|
||||||
|
actionText:
|
||||||
|
status !== 'INACTIVE' ? t('switchOffLabel') : t('switchOnLabel'),
|
||||||
|
message:
|
||||||
|
status !== 'INACTIVE'
|
||||||
|
? t('confirmChangeStatusOffMessage')
|
||||||
|
: t('confirmChangeStatusOnMessage'),
|
||||||
|
action: async () => {
|
||||||
|
const res = await branchStore.editById(id, {
|
||||||
|
status: status !== 'INACTIVE' ? 'INACTIVE' : 'ACTIVE',
|
||||||
|
});
|
||||||
|
if (res) resolve(res);
|
||||||
|
},
|
||||||
|
cancel: () => {},
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
async function onSubmit() {
|
async function onSubmit() {
|
||||||
if (formType.value === 'edit') {
|
if (formType.value === 'edit') {
|
||||||
delete formData.value['codeHeadOffice'];
|
delete formData.value['codeHeadOffice'];
|
||||||
|
|
@ -622,7 +648,7 @@ watch(
|
||||||
</q-btn>
|
</q-btn>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="col full-width">
|
<div class="col full-width scroll">
|
||||||
<div class="q-pa-md">
|
<div class="q-pa-md">
|
||||||
<q-tree
|
<q-tree
|
||||||
:nodes="treeData"
|
:nodes="treeData"
|
||||||
|
|
@ -862,15 +888,9 @@ watch(
|
||||||
@click="
|
@click="
|
||||||
async () => {
|
async () => {
|
||||||
const res =
|
const res =
|
||||||
await branchStore.editById(
|
await triggerChangeStatus(
|
||||||
node.id,
|
node.id,
|
||||||
{
|
node.status,
|
||||||
status:
|
|
||||||
node.status !==
|
|
||||||
'INACTIVE'
|
|
||||||
? 'INACTIVE'
|
|
||||||
: 'ACTIVE',
|
|
||||||
},
|
|
||||||
);
|
);
|
||||||
if (res)
|
if (res)
|
||||||
node.status = res.status;
|
node.status = res.status;
|
||||||
|
|
@ -1151,6 +1171,7 @@ watch(
|
||||||
<q-td>
|
<q-td>
|
||||||
<q-btn
|
<q-btn
|
||||||
icon="mdi-dots-vertical"
|
icon="mdi-dots-vertical"
|
||||||
|
:id="`btn-dots-${props.row.code}`"
|
||||||
size="sm"
|
size="sm"
|
||||||
dense
|
dense
|
||||||
round
|
round
|
||||||
|
|
@ -1270,16 +1291,11 @@ watch(
|
||||||
@click="
|
@click="
|
||||||
async () => {
|
async () => {
|
||||||
const res =
|
const res =
|
||||||
await branchStore.editById(
|
await triggerChangeStatus(
|
||||||
props.row.id,
|
props.row.id,
|
||||||
{
|
props.row.status,
|
||||||
status:
|
|
||||||
props.row.status !==
|
|
||||||
'INACTIVE'
|
|
||||||
? 'INACTIVE'
|
|
||||||
: 'ACTIVE',
|
|
||||||
},
|
|
||||||
);
|
);
|
||||||
|
|
||||||
if (res)
|
if (res)
|
||||||
props.row.status = res.status;
|
props.row.status = res.status;
|
||||||
}
|
}
|
||||||
|
|
@ -1481,16 +1497,11 @@ watch(
|
||||||
@click="
|
@click="
|
||||||
async () => {
|
async () => {
|
||||||
const res =
|
const res =
|
||||||
await branchStore.editById(
|
await triggerChangeStatus(
|
||||||
props.row.id,
|
props.row.id,
|
||||||
{
|
props.row.status,
|
||||||
status:
|
|
||||||
props.row.status !==
|
|
||||||
'INACTIVE'
|
|
||||||
? 'INACTIVE'
|
|
||||||
: 'ACTIVE',
|
|
||||||
},
|
|
||||||
);
|
);
|
||||||
|
|
||||||
if (res)
|
if (res)
|
||||||
props.row.status = res.status;
|
props.row.status = res.status;
|
||||||
}
|
}
|
||||||
|
|
@ -1815,10 +1826,10 @@ watch(
|
||||||
@click="
|
@click="
|
||||||
async () => {
|
async () => {
|
||||||
if (!currentNode) return;
|
if (!currentNode) return;
|
||||||
const res = await branchStore.editById(currentNode.id, {
|
const res = await triggerChangeStatus(
|
||||||
status:
|
currentNode.id,
|
||||||
currentNode.status !== 'INACTIVE' ? 'INACTIVE' : 'ACTIVE',
|
currentNode.status,
|
||||||
});
|
);
|
||||||
if (res) currentNode.status = res.status;
|
if (res) currentNode.status = res.status;
|
||||||
}
|
}
|
||||||
"
|
"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue