refactor: handle status

This commit is contained in:
Thanaphon Frappet 2024-12-18 11:49:26 +07:00
parent fa9b59680f
commit ed6a0cee3d
6 changed files with 23 additions and 15 deletions

View file

@ -364,4 +364,15 @@ defineEmits<{
--_fg: var(--gender-female);
}
}
.status-active {
--_branch-status-color: var(--green-6-hsl);
}
.status-inactive {
--_branch-status-color: var(--stone-5-hsl);
--_branch-badge-bg: var(--stone-5-hsl);
filter: grayscale(0.5);
opacity: 0.5;
}
</style>

View file

@ -1811,7 +1811,7 @@ watch(currentHq, () => {
style="position: absolute; z-index: 99999; top: 0; right: 0"
>
<div
v-if="formData.status !== 'INACTIVE'"
v-if="formData.status !== 'INACTIVE' || !currentId"
class="surface-1 row rounded"
>
<UndoButton

View file

@ -318,6 +318,7 @@ function onClose(excludeDialog?: boolean) {
infoDrawer.value = excludeDialog || false;
return;
}
modal.value = false;
hqId.value = '';
brId.value = '';
userCode.value = '';
@ -325,7 +326,6 @@ function onClose(excludeDialog?: boolean) {
profileFileImg.value = null;
infoDrawerEdit.value = false;
agencyFile.value = [];
modal.value = false;
isEdit.value = false;
statusToggle.value = true;
isImageEdit.value = false;
@ -443,12 +443,6 @@ async function onSubmit(excludeDialog?: boolean) {
} else {
if (!hqId.value) return;
if (statusToggle.value) {
formData.value.status = 'CREATED';
} else {
formData.value.status = 'INACTIVE';
}
formData.value.branchId = brId.value
? brId.value
: hqId.value
@ -1798,10 +1792,7 @@ watch(
'q-py-sm q-px-lg': !$q.screen.gt.sm,
}"
>
<div
v-if="formData.status !== 'INACTIVE'"
class="surface-1 row rounded"
>
<div class="surface-1 row rounded">
<SaveButton id="btn-info-basic-save" icon-only type="submit" />
</div>
</div>

View file

@ -1118,6 +1118,7 @@ async function submitService(notClose = false) {
const res = await createService(
{
...formDataProductService.value,
workflowId: currWorkflow.value?.id || '',
},
onCreateImageList.value,
@ -1197,7 +1198,11 @@ async function submitGroup() {
await editProductGroup(currentIdGroupTree.value, formDataGroup.value);
else await editProductGroup(currentIdGroup.value, formDataGroup.value);
} else {
const res = await createProductGroup(formDataGroup.value);
const res = await createProductGroup({
...formDataGroup.value,
status:
currentStatusGroupType.value === 'CREATED' ? undefined : 'INACTIVE',
});
if (res) {
allStat.value[0].count = allStat.value[0].count + 1;

View file

@ -164,7 +164,7 @@ const useProductServiceStore = defineStore('api-product-service', () => {
list: { url: string; imgFile: File | null; name: string }[];
},
) {
const { image, status, ...payload } = data;
const { image, ...payload } = data;
const res = await api.post<ProductCreate>('/product', {
...payload,
@ -271,7 +271,7 @@ const useProductServiceStore = defineStore('api-product-service', () => {
list: { url: string; imgFile: File | null; name: string }[];
},
) {
const { image, status, ...payload } = data;
const { image, ...payload } = data;
const res = await api.post<ServiceCreate & { imageUploadUrl: string }>(
'/service',

View file

@ -232,6 +232,7 @@ export interface ProductGroupCreate {
code: string;
shared?: boolean;
registeredBranchId: string;
status?: Status;
}
export interface ProductGroupUpdate {