refactor:header registered branch

This commit is contained in:
Thanaphon Frappet 2024-09-30 10:55:48 +07:00
parent c76dd473bb
commit 2fbf4edf36
3 changed files with 25 additions and 3 deletions

View file

@ -24,6 +24,7 @@ defineProps<{
dense?: boolean; dense?: boolean;
outlined?: boolean; outlined?: boolean;
readonly?: boolean; readonly?: boolean;
readOnlybranchOption?: boolean;
separator?: boolean; separator?: boolean;
isType?: boolean; isType?: boolean;
disableCode?: boolean; disableCode?: boolean;
@ -77,10 +78,11 @@ watch(
v-model="registeredBranchId" v-model="registeredBranchId"
id="input-source-nationality" id="input-source-nationality"
for="input-source-nationality" for="input-source-nationality"
:disable="!readonly"
:dense="dense" :dense="dense"
:readonly="readonly" :readonly="readonly || readOnlybranchOption"
:options="branchOptions" :options="branchOptions"
:hide-dropdown-icon="readonly" :hide-dropdown-icon="readonly || readOnlybranchOption"
:label="$t('productService.service.registeredBranch')" :label="$t('productService.service.registeredBranch')"
:rules="[ :rules="[
(val) => { (val) => {

View file

@ -95,7 +95,7 @@ const {
} = productServiceStore; } = productServiceStore;
const { workNameItems } = storeToRefs(productServiceStore); const { workNameItems } = storeToRefs(productServiceStore);
const readOnlybranchOption = ref<boolean>(false);
const allStat = ref<{ mode: string; count: number }[]>([]); const allStat = ref<{ mode: string; count: number }[]>([]);
const stat = ref< const stat = ref<
{ {
@ -847,6 +847,7 @@ function undoProductGroup() {
registeredBranchId: previousValue.value.registeredBranchId, registeredBranchId: previousValue.value.registeredBranchId,
}; };
isEdit.value = false; isEdit.value = false;
readOnlybranchOption.value = false;
flowStore.rotate(); flowStore.rotate();
} }
@ -863,6 +864,22 @@ async function assignFormDataGroup(data: ProductGroup) {
code: data.code, code: data.code,
registeredBranchId: data.registeredBranchId, registeredBranchId: data.registeredBranchId,
}; };
const tempValue = branchOption.value.find(
(v) => v.id === data.registeredBranchId,
);
if (tempValue !== undefined) {
readOnlybranchOption.value = false;
} else {
readOnlybranchOption.value = true;
branchOption.value = [
{
id: data.registeredBranch.id,
name: data.registeredBranch.name,
},
];
}
} }
const prevService = ref<ServiceCreate>({ const prevService = ref<ServiceCreate>({
@ -3175,10 +3192,12 @@ watch(
style="overflow-y: auto" style="overflow-y: auto"
> >
<!-- :isType="productMode === 'type'" --> <!-- :isType="productMode === 'type'" -->
<BasicInformation <BasicInformation
id="info-group" id="info-group"
dense dense
:readonly="!isEdit" :readonly="!isEdit"
:readOnlybranchOption="!readOnlybranchOption"
v-model:options-branch="branchOption" v-model:options-branch="branchOption"
v-model:registered-branch-id="formDataGroup.registeredBranchId" v-model:registered-branch-id="formDataGroup.registeredBranchId"
v-model:remark="formDataGroup.remark" v-model:remark="formDataGroup.remark"

View file

@ -196,6 +196,7 @@ export type ProductGroup = {
remark: string; remark: string;
status: Status; status: Status;
registeredBranchId: string; registeredBranchId: string;
registeredBranch: { id: string; name: string };
createdBy: CreatedBy; createdBy: CreatedBy;
createdAt: string; createdAt: string;
updatedBy: UpdatedBy; updatedBy: UpdatedBy;