refactor: add registered branch to product group

This commit is contained in:
Methapon Metanipat 2024-09-10 13:35:53 +07:00
parent 01c5592f7d
commit 67d360c92b
5 changed files with 92 additions and 144 deletions

View file

@ -246,6 +246,7 @@ const formDataGroup = ref<ProductGroupCreate>({
detail: '',
name: '',
code: '',
registeredBranchId: '',
});
const formDataProduct = ref<ProductCreate>({
@ -719,7 +720,7 @@ async function triggerChangeStatus(
: t('dialog.message.confirmChangeStatusOn'),
action: async () => {
if (type === 'group' || productMode.value === 'group') {
const res = await toggleStatusGroup(id, status as Status)
await toggleStatusGroup(id, status as Status)
.then(resolve)
.catch(reject);
} else if (type === 'service') {
@ -847,21 +848,24 @@ function undoProductGroup() {
detail: previousValue.value.detail,
name: previousValue.value.name,
code: previousValue.value.code,
registeredBranchId: previousValue.value.registeredBranchId,
};
isEdit.value = false;
flowStore.rotate();
}
function assignFormDataGroup(data: ProductGroup) {
async function assignFormDataGroup(data: ProductGroup) {
previousValue.value = data;
currentStatusGroupType.value = data.status;
currentIdGroupType.value = data.id;
await fetchListOfOptionBranch();
formDataGroup.value = {
remark: data.remark,
detail: data.detail,
name: data.name,
code: data.code,
registeredBranchId: data.registeredBranchId,
};
}
@ -981,6 +985,7 @@ function clearFormGroup() {
detail: '',
name: '',
code: '',
registeredBranchId: '',
};
currentStatusGroupType.value = 'CREATED';
dialogInputForm.value = false;
@ -1481,8 +1486,9 @@ watch(productMode, async () => {
external-label
label-position="left"
@click="
() => {
async () => {
clearFormGroup();
await fetchListOfOptionBranch();
dialogInputForm = true;
}
"
@ -1640,12 +1646,12 @@ watch(productMode, async () => {
}
"
@view="
(v: (typeof treeProductTypeAndGroup)[number]) => {
async (v: (typeof treeProductTypeAndGroup)[number]) => {
if (v.type === 'group') {
editByTree = 'group';
currentStatusProduct = v.status === 'INACTIVE';
clearFormGroup();
assignFormDataGroup(v);
await assignFormDataGroup(v);
isEdit = false;
currentIdGropTree = v.id;
drawerInfo = true;
@ -1653,11 +1659,11 @@ watch(productMode, async () => {
}
"
@edit="
(v: (typeof treeProductTypeAndGroup)[number]) => {
async (v: (typeof treeProductTypeAndGroup)[number]) => {
editByTree = v.type as typeof editByTree;
if (v.type === 'group') {
clearFormGroup();
assignFormDataGroup(v);
await assignFormDataGroup(v);
isEdit = true;
currentIdGropTree = v.id;
drawerInfo = true;
@ -1980,13 +1986,13 @@ watch(productMode, async () => {
round
flat
@click.stop="
() => {
async () => {
if (productMode === 'group') {
editByTree = 'group';
currentStatusProduct =
props.row.status === 'INACTIVE';
clearFormGroup();
assignFormDataGroup(props.row);
await assignFormDataGroup(props.row);
isEdit = false;
currentIdGrop = props.row.id;
drawerInfo = true;
@ -2000,13 +2006,13 @@ watch(productMode, async () => {
:status="props.row.status"
:idName="props.row.name"
@view="
() => {
async () => {
if (productMode === 'group') {
editByTree = 'group';
currentStatusProduct =
props.row.status === 'INACTIVE';
clearFormGroup();
assignFormDataGroup(props.row);
await assignFormDataGroup(props.row);
isEdit = false;
currentIdGrop = props.row.id;
drawerInfo = true;
@ -2014,11 +2020,11 @@ watch(productMode, async () => {
}
"
@edit="
() => {
async () => {
if (productMode === 'group') {
editByTree = 'group';
clearFormGroup();
assignFormDataGroup(props.row);
await assignFormDataGroup(props.row);
isEdit = true;
currentIdGrop = props.row.id;
@ -2072,13 +2078,13 @@ watch(productMode, async () => {
triggerChangeStatus(props.row.id, props.row.status)
"
@viewCard="
() => {
async () => {
if (productMode === 'group') {
editByTree = 'group';
currentStatusProduct =
props.row.status === 'INACTIVE';
clearFormGroup();
assignFormDataGroup(props.row);
await assignFormDataGroup(props.row);
isEdit = false;
currentIdGrop = props.row.id;
drawerInfo = true;
@ -2086,10 +2092,10 @@ watch(productMode, async () => {
}
"
@updateCard="
() => {
async () => {
if (productMode === 'group') {
clearFormGroup();
assignFormDataGroup(props.row);
await assignFormDataGroup(props.row);
isEdit = true;
currentIdGrop = props.row.id;
@ -2971,9 +2977,11 @@ watch(productMode, async () => {
<BasicInformation
ide="form-group"
dense
v-model:options-branch="branchOption"
v-model:remark="formDataGroup.remark"
v-model:name="formDataGroup.name"
v-model:detail="formDataGroup.detail"
v-model:registered-branch-id="formDataGroup.registeredBranchId"
/>
</div>
</div>
@ -3140,6 +3148,8 @@ watch(productMode, async () => {
id="info-group"
dense
:readonly="!isEdit"
v-model:options-branch="branchOption"
v-model:registered-branch-id="formDataGroup.registeredBranchId"
v-model:remark="formDataGroup.remark"
v-model:name="formDataGroup.name"
v-model:code="formDataGroup.code"
@ -3755,10 +3765,6 @@ watch(productMode, async () => {
v-if="serviceTab === 1"
dense
service
v-model:options-branch="branchOption"
v-model:registered-branch-id="
formDataProductService.registeredBranchId
"
v-model:service-code="formDataProductService.code"
v-model:service-description="formDataProductService.detail"
v-model:service-name-th="formDataProductService.name"
@ -4057,10 +4063,6 @@ watch(productMode, async () => {
dense
service
disableCode
v-model:options-branch="branchOption"
v-model:registered-branch-id="
formDataProductService.registeredBranchId
"
v-model:service-code="formDataProductService.code"
v-model:service-description="formDataProductService.detail"
v-model:service-name-th="formDataProductService.name"
@ -4141,12 +4143,11 @@ watch(productMode, async () => {
async () => {
if (!currentNode) return;
await fetchListOfOptionBranch();
if (currentNode.type === 'group') {
editByTree = 'group';
currentStatusProduct = currentNode.status === 'INACTIVE';
clearFormGroup();
assignFormDataGroup(currentNode);
await assignFormDataGroup(currentNode);
isEdit = false;
currentIdGrop = currentNode.id;
drawerInfo = true;
@ -4168,12 +4169,12 @@ watch(productMode, async () => {
v-ripple
v-close-popup
@click.stop="
() => {
async () => {
if (!currentNode) return;
editByTree = currentNode.type as 'type' | 'group';
if (currentNode.type === 'group') {
clearFormGroup();
assignFormDataGroup(currentNode);
await assignFormDataGroup(currentNode);
isEdit = true;
currentIdGrop = currentNode.id;