fix: dataTreeFormatted
This commit is contained in:
parent
13005eaa5c
commit
1da8ce8d49
4 changed files with 22 additions and 20 deletions
|
|
@ -4,7 +4,7 @@ import { useCounterMixin } from "@/stores/mixin";
|
||||||
import { useQuasar } from "quasar";
|
import { useQuasar } from "quasar";
|
||||||
import { ref, watch, reactive } from "vue";
|
import { ref, watch, reactive } from "vue";
|
||||||
import type { QTableProps } from "quasar";
|
import type { QTableProps } from "quasar";
|
||||||
import CardPosition from "@/modules/05_placement/components/PersonalList/CardPosition.vue";
|
|
||||||
import http from "@/plugins/http";
|
import http from "@/plugins/http";
|
||||||
import config from "@/app.config";
|
import config from "@/app.config";
|
||||||
|
|
||||||
|
|
@ -389,7 +389,7 @@ async function onClickSelectPos(id: string) {
|
||||||
positionId.value = id;
|
positionId.value = id;
|
||||||
selectedPos.value = [];
|
selectedPos.value = [];
|
||||||
const position: DataPositionNo = positionData.value.find(
|
const position: DataPositionNo = positionData.value.find(
|
||||||
(e: DataPositionNo) => e.id === id
|
(e: DataPositionNo) => e.id === id,
|
||||||
);
|
);
|
||||||
|
|
||||||
// หาตำแหน่ง
|
// หาตำแหน่ง
|
||||||
|
|
@ -397,7 +397,7 @@ async function onClickSelectPos(id: string) {
|
||||||
rowsPosition.value = position.positions;
|
rowsPosition.value = position.positions;
|
||||||
if (seletcId.value) {
|
if (seletcId.value) {
|
||||||
selectedPos.value = rowsPosition.value.filter(
|
selectedPos.value = rowsPosition.value.filter(
|
||||||
(e) => e.id === seletcId.value
|
(e) => e.id === seletcId.value,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -448,7 +448,7 @@ watch(
|
||||||
expanded.value = [];
|
expanded.value = [];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
|
|
@ -457,7 +457,7 @@ watch(
|
||||||
if (value !== oldVal) {
|
if (value !== oldVal) {
|
||||||
getDataTable(nodeId.value, nodeLevel.value);
|
getDataTable(nodeId.value, nodeLevel.value);
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
|
|
@ -466,7 +466,7 @@ watch(
|
||||||
if (value !== oldVal) {
|
if (value !== oldVal) {
|
||||||
getDataTable(nodeId.value, nodeLevel.value);
|
getDataTable(nodeId.value, nodeLevel.value);
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
|
|
@ -475,11 +475,11 @@ watch(
|
||||||
if (n) {
|
if (n) {
|
||||||
onClickSelectPos(n);
|
onClickSelectPos(n);
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
function onSubmit() {
|
function onSubmit() {
|
||||||
const dataPosMaster = posMasterMain.value?.find(
|
const dataPosMaster = posMasterMain.value?.find(
|
||||||
(e: any) => e.id === positionId.value
|
(e: any) => e.id === positionId.value,
|
||||||
);
|
);
|
||||||
|
|
||||||
console.log(dataPosMaster);
|
console.log(dataPosMaster);
|
||||||
|
|
@ -650,7 +650,6 @@ function onSubmit() {
|
||||||
map-options
|
map-options
|
||||||
:options="columns"
|
:options="columns"
|
||||||
option-value="name"
|
option-value="name"
|
||||||
|
|
||||||
style="min-width: 140px"
|
style="min-width: 140px"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,6 @@ import { useCounterMixin } from "@/stores/mixin";
|
||||||
import { useQuasar } from "quasar";
|
import { useQuasar } from "quasar";
|
||||||
import { ref, watch, reactive } from "vue";
|
import { ref, watch, reactive } from "vue";
|
||||||
import type { QTableProps } from "quasar";
|
import type { QTableProps } from "quasar";
|
||||||
import CardPosition from "@/modules/05_placement/components/PersonalList/CardPosition.vue";
|
|
||||||
import http from "@/plugins/http";
|
import http from "@/plugins/http";
|
||||||
import config from "@/app.config";
|
import config from "@/app.config";
|
||||||
|
|
||||||
|
|
@ -368,7 +367,7 @@ async function onClickSelectPos(id: string) {
|
||||||
positionId.value = id;
|
positionId.value = id;
|
||||||
selectedPos.value = [];
|
selectedPos.value = [];
|
||||||
const position: DataPositionNo = positionData.value.find(
|
const position: DataPositionNo = positionData.value.find(
|
||||||
(e: DataPositionNo) => e.id === id
|
(e: DataPositionNo) => e.id === id,
|
||||||
);
|
);
|
||||||
|
|
||||||
// หาตำแหน่ง
|
// หาตำแหน่ง
|
||||||
|
|
@ -376,7 +375,7 @@ async function onClickSelectPos(id: string) {
|
||||||
rowsPosition.value = position.positions;
|
rowsPosition.value = position.positions;
|
||||||
if (seletcId.value) {
|
if (seletcId.value) {
|
||||||
selectedPos.value = rowsPosition.value.filter(
|
selectedPos.value = rowsPosition.value.filter(
|
||||||
(e) => e.id === seletcId.value
|
(e) => e.id === seletcId.value,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -427,7 +426,7 @@ watch(
|
||||||
expanded.value = [];
|
expanded.value = [];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
|
|
@ -436,7 +435,7 @@ watch(
|
||||||
if (value !== oldVal) {
|
if (value !== oldVal) {
|
||||||
getDataTable(nodeId.value, nodeLevel.value);
|
getDataTable(nodeId.value, nodeLevel.value);
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
|
|
@ -445,7 +444,7 @@ watch(
|
||||||
if (value !== oldVal) {
|
if (value !== oldVal) {
|
||||||
getDataTable(nodeId.value, nodeLevel.value);
|
getDataTable(nodeId.value, nodeLevel.value);
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
|
|
@ -454,11 +453,11 @@ watch(
|
||||||
if (n) {
|
if (n) {
|
||||||
onClickSelectPos(n);
|
onClickSelectPos(n);
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
function onSubmit() {
|
function onSubmit() {
|
||||||
const dataPosMaster = posMasterMain.value?.find(
|
const dataPosMaster = posMasterMain.value?.find(
|
||||||
(e: any) => e.id === positionId.value
|
(e: any) => e.id === positionId.value,
|
||||||
);
|
);
|
||||||
|
|
||||||
console.log(dataPosMaster);
|
console.log(dataPosMaster);
|
||||||
|
|
@ -629,7 +628,6 @@ function onSubmit() {
|
||||||
map-options
|
map-options
|
||||||
:options="columns"
|
:options="columns"
|
||||||
option-value="name"
|
option-value="name"
|
||||||
|
|
||||||
style="min-width: 140px"
|
style="min-width: 140px"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -75,6 +75,7 @@ interface DataTree {
|
||||||
responsibility: string;
|
responsibility: string;
|
||||||
isDeputy: boolean;
|
isDeputy: boolean;
|
||||||
labelName: string;
|
labelName: string;
|
||||||
|
children?: DataTree[];
|
||||||
}
|
}
|
||||||
|
|
||||||
interface DataProfile {
|
interface DataProfile {
|
||||||
|
|
|
||||||
|
|
@ -97,7 +97,11 @@ async function fetchDataTree(id: string) {
|
||||||
.get(config.API.orgByid(id.toString()))
|
.get(config.API.orgByid(id.toString()))
|
||||||
.then(async (res) => {
|
.then(async (res) => {
|
||||||
const data = await res.data.result;
|
const data = await res.data.result;
|
||||||
nodeTree.value.push(...data);
|
const dataTreeFormatted = data.map((item: DataTree) => {
|
||||||
|
const { children, ...itemWithoutChildren } = item;
|
||||||
|
return itemWithoutChildren;
|
||||||
|
});
|
||||||
|
nodeTree.value.push(...dataTreeFormatted);
|
||||||
|
|
||||||
if (data.length === 1) {
|
if (data.length === 1) {
|
||||||
selectedOrg(data[0].orgTreeId);
|
selectedOrg(data[0].orgTreeId);
|
||||||
|
|
@ -309,7 +313,7 @@ onMounted(async () => {
|
||||||
class="q-pa-sm q-gutter-sm"
|
class="q-pa-sm q-gutter-sm"
|
||||||
dense
|
dense
|
||||||
:nodes="nodeTree"
|
:nodes="nodeTree"
|
||||||
node-key="labelName"
|
node-key="orgRootName"
|
||||||
label-key="labelName"
|
label-key="labelName"
|
||||||
:filter="filter?.trim()"
|
:filter="filter?.trim()"
|
||||||
no-results-label="ไม่พบข้อมูลที่ค้นหา"
|
no-results-label="ไม่พบข้อมูลที่ค้นหา"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue