refactor(org): add ROOT_CODE and CHILD_CODE fields for org hierarchy

This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2026-06-16 10:43:31 +07:00
parent 72cbe6a8dc
commit 06ddc1c970
3 changed files with 145 additions and 12 deletions

View file

@ -89,6 +89,11 @@ const formData = reactive<FormDataAgency>({
DIVISION_CODE: "", DIVISION_CODE: "",
SECTION_CODE: "", SECTION_CODE: "",
JOB_CODE: "", JOB_CODE: "",
ROOT_CODE: "",
CHILD1_CODE: "",
CHILD2_CODE: "",
CHILD3_CODE: "",
CHILD4_CODE: "",
}); });
/** /**
@ -160,6 +165,11 @@ function onSubmit() {
DIVISION_CODE: formData.DIVISION_CODE, DIVISION_CODE: formData.DIVISION_CODE,
SECTION_CODE: formData.SECTION_CODE, SECTION_CODE: formData.SECTION_CODE,
JOB_CODE: formData.JOB_CODE, JOB_CODE: formData.JOB_CODE,
ROOT_CODE: formData.ROOT_CODE,
CHILD1_CODE: formData.CHILD1_CODE,
CHILD2_CODE: formData.CHILD2_CODE,
CHILD3_CODE: formData.CHILD3_CODE,
CHILD4_CODE: formData.CHILD4_CODE,
}; };
// //
@ -189,18 +199,20 @@ function onSubmit() {
body body
) )
.then(async () => { .then(async () => {
await props.fetchDataTree(store.draftId); await Promise.all([
await props.edit?.( await props.fetchDataTree(store.draftId),
props.dataNode?.orgTreeId, await props.edit?.(
type, props.dataNode?.orgTreeId,
body, type,
props.dataNode?.orgRootCode body,
); props.dataNode?.orgRootCode
await props.fetchDataTable( ),
props?.dataNode?.orgTreeId, await props.fetchDataTable(
props?.dataNode?.orgLevel, props?.dataNode?.orgTreeId,
false props?.dataNode?.orgLevel,
); false
),
]);
await success($q, "บันทึกข้อมูลสำเร็จ"); await success($q, "บันทึกข้อมูลสำเร็จ");
closeClear(); closeClear();
}) })
@ -231,6 +243,11 @@ function closeClear() {
formData.isCommission = false; formData.isCommission = false;
formData.isInformation = false; formData.isInformation = false;
formData.misId = ""; formData.misId = "";
formData.ROOT_CODE = "";
formData.CHILD1_CODE = "";
formData.CHILD2_CODE = "";
formData.CHILD3_CODE = "";
formData.CHILD4_CODE = "";
formData.DEPARTMENT_CODE = ""; formData.DEPARTMENT_CODE = "";
formData.DIVISION_CODE = ""; formData.DIVISION_CODE = "";
formData.SECTION_CODE = ""; formData.SECTION_CODE = "";
@ -456,6 +473,7 @@ watch(
else { else {
props.dataNode?.orgLevel === 1 && checkOfficer(); props.dataNode?.orgLevel === 1 && checkOfficer();
if (props.dataNode) { if (props.dataNode) {
console.log(props.dataNode);
formData.orgName = props.dataNode.orgTreeName; formData.orgName = props.dataNode.orgTreeName;
formData.orgShortName = props.dataNode.orgTreeShortName; formData.orgShortName = props.dataNode.orgTreeShortName;
formData.orgCode = props.dataNode.orgTreeCode; formData.orgCode = props.dataNode.orgTreeCode;
@ -474,6 +492,11 @@ watch(
formData.DIVISION_CODE = props.dataNode.DIVISION_CODE; formData.DIVISION_CODE = props.dataNode.DIVISION_CODE;
formData.SECTION_CODE = props.dataNode.SECTION_CODE; formData.SECTION_CODE = props.dataNode.SECTION_CODE;
formData.JOB_CODE = props.dataNode.JOB_CODE; formData.JOB_CODE = props.dataNode.JOB_CODE;
formData.ROOT_CODE = props.dataNode.ROOT_CODE;
formData.CHILD1_CODE = props.dataNode.CHILD1_CODE;
formData.CHILD2_CODE = props.dataNode.CHILD2_CODE;
formData.CHILD3_CODE = props.dataNode.CHILD3_CODE;
formData.CHILD4_CODE = props.dataNode.CHILD4_CODE;
orgLevelOption.value = orgLevelOption.value =
props.dataNode.orgTreeRank === "DEPARTMENT" props.dataNode.orgTreeRank === "DEPARTMENT"
? orgLevelOptionMain.value ? orgLevelOptionMain.value
@ -730,6 +753,66 @@ watch(
</div> </div>
</div> </div>
</div> </div>
<div class="col-12">
<div class="col-12 row q-col-gutter-sm">
<div class="col">
<q-input
v-model="formData.ROOT_CODE"
dense
outlined
label="ROOT CODE"
hide-bottom-space
:class="classInput(false)"
maxlength="3"
/>
</div>
<div class="col">
<q-input
v-model="formData.CHILD1_CODE"
dense
outlined
label="CHILD1 CODE"
hide-bottom-space
:class="classInput(false)"
maxlength="3"
/>
</div>
<div class="col">
<q-input
v-model="formData.CHILD2_CODE"
dense
outlined
label="CHILD2 CODE"
hide-bottom-space
:class="classInput(false)"
maxlength="3"
/>
</div>
<div class="col">
<q-input
v-model="formData.CHILD3_CODE"
dense
outlined
label="CHILD3 CODE"
hide-bottom-space
:class="classInput(false)"
maxlength="3"
/>
</div>
<div class="col">
<q-input
v-model="formData.CHILD4_CODE"
dense
outlined
label="CHILD4 CODE"
hide-bottom-space
:class="classInput(false)"
maxlength="3"
/>
</div>
</div>
</div>
<div class="col-12"> <div class="col-12">
<q-input <q-input
v-model="formData.responsibility" v-model="formData.responsibility"

View file

@ -36,6 +36,11 @@ const formData = reactive({
responsibility: "", // responsibility: "", //
isCommission: "", // isCommission: "", //
isDeputy: "", // . isDeputy: "", // .
rootCode: "", //ROOT CODE
child1Code: "", //CHILD1 CODE
child2Code: "", //CHILD2 CODE
child3Code: "", //CHILD3 CODE
child4Code: "", //CHILD4 CODE
}); });
/** /**
@ -76,6 +81,11 @@ async function fetchDetailTree(id: string, type: string) {
formData.responsibility = data.responsibility ? data.responsibility : "-"; formData.responsibility = data.responsibility ? data.responsibility : "-";
formData.isDeputy = data.isDeputy ? "ใช่" : "-"; formData.isDeputy = data.isDeputy ? "ใช่" : "-";
formData.isCommission = data.isCommission ? "ใช่" : "-"; formData.isCommission = data.isCommission ? "ใช่" : "-";
formData.rootCode = data.ROOT_CODE ? data.ROOT_CODE : "-";
formData.child1Code = data.CHILD1_CODE ? data.CHILD1_CODE : "-";
formData.child2Code = data.CHILD2_CODE ? data.CHILD2_CODE : "-";
formData.child3Code = data.CHILD3_CODE ? data.CHILD3_CODE : "-";
formData.child4Code = data.CHILD4_CODE ? data.CHILD4_CODE : "-";
}) })
.catch((err) => { .catch((err) => {
messageError($q, err); messageError($q, err);
@ -208,6 +218,41 @@ watch(
</div> </div>
</div> </div>
<div class="row q-col-gutter-sm q-mb-xs">
<div class="col-4 text-bold">ROOT CODE</div>
<div class="col-8 text-grey-8">
<p>{{ formData.rootCode }}</p>
</div>
</div>
<div class="row q-col-gutter-sm q-mb-xs">
<div class="col-4 text-bold">CHILD1 CODE</div>
<div class="col-8 text-grey-8">
<p>{{ formData.child1Code }}</p>
</div>
</div>
<div class="row q-col-gutter-sm q-mb-xs">
<div class="col-4 text-bold">CHILD2 CODE</div>
<div class="col-8 text-grey-8">
<p>{{ formData.child2Code }}</p>
</div>
</div>
<div class="row q-col-gutter-sm q-mb-xs">
<div class="col-4 text-bold">CHILD3 CODE</div>
<div class="col-8 text-grey-8">
<p>{{ formData.child3Code }}</p>
</div>
</div>
<div class="row q-col-gutter-sm q-mb-xs">
<div class="col-4 text-bold">CHILD4 CODE</div>
<div class="col-8 text-grey-8">
<p>{{ formData.child4Code }}</p>
</div>
</div>
<div class="row q-col-gutter-sm q-mb-xs"> <div class="row q-col-gutter-sm q-mb-xs">
<div class="col-4 text-bold">หนาทความรบผดชอบ</div> <div class="col-4 text-bold">หนาทความรบผดชอบ</div>
<div class="col-8 text-grey-8"> <div class="col-8 text-grey-8">

View file

@ -44,6 +44,11 @@ interface FormDataAgency {
DIVISION_CODE: string; DIVISION_CODE: string;
SECTION_CODE: string; SECTION_CODE: string;
JOB_CODE: string; JOB_CODE: string;
ROOT_CODE: string;
CHILD1_CODE: string;
CHILD2_CODE: string;
CHILD3_CODE: string;
CHILD4_CODE: string;
} }
interface FormDataPosition { interface FormDataPosition {