<script setup lang="ts">
import { ref, reactive, onMounted, watch } from "vue";
import { useQuasar } from "quasar";
import { storeToRefs } from "pinia";

import http from "@/plugins/http";
import config from "@/app.config";
import { usePermissionsStore } from "@/modules/02_users/stores/permissions";
import { useCounterMixin } from "@/stores/mixin";
import { tokenParsed } from "@/plugins/auth";
import { usekeycloakPosition } from "@/stores/keycloakPosition";

/** importType*/
import type { QTableProps } from "quasar";
import type { Pagination } from "@/modules/02_users/interface/index/Main";
import type { FilterReqMaster } from "@/modules/02_users/interface/request/Main";
import type {
  NodeTree,
  PosMaster,
  Position,
} from "@/modules/02_users/interface/response/Main";

/** importComponents*/
import DialogAdd from "@/modules/02_users/components/Permissions/DialogAdd.vue";
import PopupPersonal from "@/modules/02_users/components/RoleOrganization/DialogPersonal.vue";

/** use*/
const $q = useQuasar();
const store = usePermissionsStore();
const { dataPosition } = storeToRefs(usekeycloakPosition());
const { showLoader, hideLoader, messageError, success, dialogRemove } =
  useCounterMixin();

/** Tree*/
const filter = ref<string>(""); // ค้นหาข้อมูลโครงาสร้าง
const nodes = ref<Array<NodeTree>>([store.defaultOrganizationalNode]); // ข้อมูลโครงสร้าง
const lazy = ref(nodes);
const expanded = ref<string[]>([]); // แสดงข้อมูลในโหนดที่เลือก
const nodeId = ref<string>(""); // id โหนด

/** Table*/
const visibleColumns = ref<string[]>([
  "no",
  "posMasterNo",
  "positionName",
  "posTypeName",
  "posLevelName",
  "positionIsSelected",
  "authRoleName",
]);
const columns = ref<QTableProps["columns"]>([
  {
    name: "no",
    align: "left",
    label: "ลำดับ",
    sortable: false,
    field: (row) =>
      (reqMaster.page - 1) * reqMaster.pageSize +
      posMaster.value.indexOf(row) +
      1,
    headerStyle: "font-size: 14px",
    style: "font-size: 14px",
  },
  {
    name: "posMasterNo",
    align: "left",
    label: "เลขที่ตำแหน่ง",
    sortable: false,
    field: (row) =>
      row.orgShortname +
      (row.posMasterNoPrefix ? row.posMasterNoPrefix : "") +
      (row.posMasterNo ? row.posMasterNo : "") +
      (row.posMasterNoSuffix ? row.posMasterNoSuffix : "") +
      (row.isSit ? "(ทับที่)" : ""),
    headerStyle: "font-size: 14px",
    style: "font-size: 14px",
  },
  {
    name: "positionName",
    align: "left",
    label: "ตำแหน่งในสายงาน",
    field: (row) => (row.isSit ? row.profilePosition : row.positionName),
    sortable: false,
    headerStyle: "font-size: 14px",
    style: "font-size: 14px",
  },
  {
    name: "posTypeName",
    align: "left",
    label: "ประเภทตำแหน่ง",
    sortable: false,
    field: (row) => (row.isSit ? row.profilePostype : row.posTypeName),
    headerStyle: "font-size: 14px",
    style: "font-size: 14px",
  },
  {
    name: "posLevelName",
    align: "left",
    label: "ระดับตำแหน่ง",
    sortable: false,
    field: (row) => (row.isSit ? row.profilePoslevel : row.posLevelName),
    headerStyle: "font-size: 14px",
    style: "font-size: 14px",
  },
  {
    name: "positionIsSelected",
    align: "left",
    label: "คนครอง",
    sortable: false,
    field: (row) =>
      store.typeOrganizational === "draft" && row.fullNameNextHolder !== null
        ? row.fullNameNextHolder
        : store.typeOrganizational !== "draft" &&
          row.fullNameCurrentHolder !== null
        ? row.fullNameCurrentHolder
        : "ว่าง",
    headerStyle: "font-size: 14px",
    style: "font-size: 14px",
  },
  {
    name: "authRoleName",
    align: "left",
    label: "สิทธิ์",
    sortable: false,
    field: "authRoleName",
    headerStyle: "font-size: 14px",
    style: "font-size: 14px",
  },
]);
const columnsExpand = ref<QTableProps["columns"]>([
  {
    name: "no",
    align: "left",
    label: "ลำดับ",
    sortable: false,
    field: "no",
    headerStyle: "font-size: 14px",
    style: "font-size: 14px",
  },
  {
    name: "positionName",
    align: "left",
    label: "ตำแหน่งในสายงาน",
    sortable: false,
    field: "positionName",
    headerStyle: "font-size: 14px",
    style: "font-size: 14px",
  },
  {
    name: "positionField",
    align: "left",
    label: "สายงาน",
    sortable: false,
    field: "positionField",
    headerStyle: "font-size: 14px",
    style: "font-size: 14px",
  },
  {
    name: "posTypeName",
    align: "left",
    label: "ประเภทตำเเหน่ง",
    sortable: false,
    field: "posTypeName",
    headerStyle: "font-size: 14px",
    style: "font-size: 14px",
  },
  {
    name: "posLevelName",
    align: "left",
    label: "ระดับตำแหน่ง",
    sortable: false,
    field: "posLevelName",
    headerStyle: "font-size: 14px",
    style: "font-size: 14px",
  },
  {
    name: "posExecutiveName",
    align: "left",
    label: "ตำแหน่งทางการบริหาร",
    sortable: false,
    field: "posExecutiveName",
    headerStyle: "font-size: 14px",
    style: "font-size: 14px",
  },
  {
    name: "positionExecutiveField",
    align: "left",
    label: "ด้านทางการบริหาร",
    sortable: false,
    field: "positionExecutiveField",
    headerStyle: "font-size: 14px",
    style: "font-size: 14px",
  },
  {
    name: "positionArea",
    align: "left",
    label: "ด้าน/สาขา",
    sortable: false,
    field: "positionArea",
    headerStyle: "font-size: 14px",
    style: "font-size: 14px",
  },
]);
// ฟอร์มค้นหาตำแหน่ง
const reqMaster = reactive<FilterReqMaster>({
  id: null,
  type: 0,
  isAll: true,
  isBlank: false,
  page: 1,
  pageSize: 10,
  keyword: "",
  revisionId: "",
});
const maxPage = ref<number>(0);
const totalRow = ref<number>(0);
const posMaster = ref<PosMaster[]>([]); // ข้อมูลรายการตำแหน่ง
const dataPosMaster = ref<PosMaster>(); // ข้อมูลตำแหน่ง
const pagination = ref<Pagination>({
  page: reqMaster.page,
  rowsPerPage: reqMaster.pageSize,
});

const modalDialogAdd = ref<boolean>(false); // popup จัดการสิทธิ์

/**  function เรียกข้อมูลโครงสร้าง แบบปัจุบันและ แบบร่าง */
async function fetchOrganizationActive() {
  showLoader();
  await http
    .get(config.API.activeOrganization)
    .then(async (res) => {
      const data = res.data.result;
      if (data) {
        store.activeId = data.activeId;
        store.draftId = data.draftId;

        const id =
          store.typeOrganizational === "current"
            ? store.activeId
            : store.draftId;
        await fetchDataTree(id);
      }
    })
    .catch((err) => {
      messageError($q, err);
    })
    .finally(() => {
      hideLoader();
    });
}

const tokenParsedData = ref<string[]>([]);
/**
 * function fetch ข้อมูลของ Tree
 * @param id id โครงสร้าง
 */
async function fetchDataTree(id: string) {
  const isSuperAdmin = tokenParsedData.value.includes("SUPER_ADMIN");
  if (!isSuperAdmin) {
    nodes.value = [];
  } else {
    nodes.value = [store.defaultOrganizationalNode];
  }
  showLoader();
  await http
    .get(config.API.orgByid(id.toString()))
    .then(async (res) => {
      const data = await res.data.result;
      nodes.value.push(...data);
      nodes.value[0].orgRevisionId = id;
      nodeId.value = nodes.value[0].orgTreeId;
      await fetchDataTable(nodeId.value, id, nodes.value[0].orgLevel);
    })
    .catch((err) => {
      messageError($q, err);
    })
    .finally(() => {
      hideLoader();
    });
}

/**
 * function fetch ข้อรายการตำแหน่ง
 * @param id  idTree
 * @param level  levelTree
 */
async function fetchDataTable(
  id: string | null,
  revisionId: string,
  level: number,
) {
  showLoader();
  reqMaster.id = id === "" ? null : id;
  reqMaster.revisionId = revisionId;
  reqMaster.type = level;
  await http
    .post(config.API.orgPosMasterList, reqMaster)
    .then(async (res) => {
      posMaster.value = [];
      const dataMain: PosMaster[] = [];
      maxPage.value = Math.ceil(res.data.result.total / reqMaster.pageSize);
      totalRow.value = res.data.result.total;

      await res.data.result.data.forEach((e: PosMaster) => {
        const p = e.positions;
        if (p.length !== 0) {
          const a = p.find((el: Position) => el.positionIsSelected === true);
          const { id, ...rest } = a ? a : p[0];
          const pos = { ...e, ...rest };
          dataMain.push(pos);
        }
      });
      posMaster.value = dataMain;
    })
    .catch((err) => {
      messageError($q, err);
      posMaster.value = [];
    })
    .finally(() => {
      hideLoader();
    });
}

/**
 *  function เลือกข้อมูลโครางสร่้าง
 * @param data
 */
function updateSelected(data: NodeTree) {
  reqMaster.isAll = data.orgTreeId === "" ? true : reqMaster.isAll;
  nodeId.value = data.orgTreeId;
  fetchDataTable(data.orgTreeId, data.orgRevisionId, data.orgLevel);
}

/**
 * function updatePagination
 * @param newPagination ข้อมูล Pagination ใหม่
 */
function updatePagination(newPagination: Pagination) {
  reqMaster.pageSize = newPagination.rowsPerPage;
  reqMaster.page = 1;
}

function onClickAddRole(data: PosMaster) {
  modalDialogAdd.value = true;
  dataPosMaster.value = data;
}

/**
 * ยืนยันการลบสิทธิ์
 * @param id ตำแหน่ง
 */
function onDeleteRole(id: string) {
  dialogRemove(
    $q,
    async () => {
      showLoader();
      await http
        .post(config.API.managementPermission, {
          authRoleId: "",
          posMasterId: id,
        })
        .then(async () => {
          await fetchDataTable(
            reqMaster.id,
            reqMaster.revisionId,
            reqMaster.type,
          );
          success($q, "ลบข้อมูลสำเร็จ");
        })
        .catch((err) => {
          messageError($q, err);
        })
        .finally(() => {
          hideLoader();
        });
    },
    "ยืนยันการลบสิทธิ์",
    "ต้องการยืนยันการลบสิทธิ์นี้หรือไม่ ?",
  );
}

const modalPersonal = ref<boolean>(false);
const personId = ref<string>("");

function onOpenModalPersonal(id: string) {
  personId.value = id;
  modalPersonal.value = true;
}

function updatemodalPersonal(modal: boolean) {
  modalPersonal.value = modal;
}

/** callblck function ทำการ fetch ข้อมูล tree เมื่อมีการเปลี่ยน Tab ปัจจับัน,แบบร่าง*/
watch(
  () => store.typeOrganizational,
  async () => {
    const id =
      store.typeOrganizational === "current" ? store.activeId : store.draftId;
    nodeId.value = "";
    posMaster.value = [];
    reqMaster.id = null;
    reqMaster.type = 0;
    reqMaster.isAll = false;
    reqMaster.page = 1;
    reqMaster.pageSize = 10;
    reqMaster.keyword = "";
    reqMaster.revisionId = "";
    filter.value = "";
    await fetchDataTree(id);
  },
);

/** callblck function ทำการ fetch ข้อมูล Table เมื่อมีการเปลี่ยนหน้า*/
watch([() => reqMaster.pageSize], () => {
  fetchDataTable(reqMaster.id, reqMaster.revisionId, reqMaster.type);
});

function isUpload() {
  reqMaster.page = 1;
  fetchDataTable(reqMaster.id, reqMaster.revisionId, reqMaster.type);
}

/**
 *  ตรวจสอบการแสดงปุ่ม action
 * @param current_holderId id ผู้ครองตำแหน่งปัจจุบัน
 * @returns true หากผู้ใช้งานมีสิทธิ์ในการดำเนินการ
 */
function checkhideBtnAction(current_holderId: string) {
  if (
    dataPosition.value?.profileId === current_holderId &&
    tokenParsedData.value.includes("ADMIN") &&
    !tokenParsedData.value.includes("SUPER_ADMIN")
  ) {
    return false;
  } else {
    return true;
  }
}

onMounted(async () => {
  const token = await tokenParsed();
  tokenParsedData.value = token.role || [];
  await fetchOrganizationActive();
});
</script>

<template>
  <div class="row items-center">
    <div class="toptitle text-dark row items-center q-py-xs">กำหนดสิทธิ์</div>
  </div>

  <q-card flast bordered>
    <q-card-section>
      <q-toolbar class="q-gutter-md items-center" style="padding: 0px">
        <q-btn-group outline>
          <q-btn
            dense
            class="q-px-md"
            :outline="store.typeOrganizational === 'current' ? false : true"
            color="blue"
            label="ปัจจุบัน"
            :disable="store.activeId == '' || store.activeId == null"
            @click="store.typeOrganizational = 'current'"
          />

          <q-btn
            dense
            class="q-px-md"
            :outline="store.typeOrganizational === 'draft' ? false : true"
            color="blue"
            label="แบบร่าง"
            :disable="store.draftId == '' || store.draftId == null"
            @click="store.typeOrganizational = 'draft'"
          />
        </q-btn-group>
        <div
          v-if="store.typeOrganizational === 'draft'"
          class="q-pl-sm text-red"
        >
          *สิทธิ์ที่กำหนดในแบบร่างจะใช้งานได้เมื่อเผยแพร่โครงสร้างเป็นปัจจุบันแล้วเท่านั้น
        </div>
      </q-toolbar>
    </q-card-section>
    <q-separator />
    <q-card-section style="padding: 0px">
      <div class="col-12">
        <q-card bordered class="col-12 row caedNone">
          <!-- Tree -->
          <div class="col-xs-12 col-sm-3 row">
            <div class="col-12 row no-wrap bg-grey-1">
              <div class="col-12 q-py-sm q-px-sm">
                <div class="q-gutter-sm">
                  <div class="row q-col-gutter-sm q-pl-sm">
                    <div class="col-12">
                      <q-input dense outlined v-model="filter" label="ค้นหา">
                        <template v-slot:append>
                          <q-icon name="search" />
                        </template>
                      </q-input>
                    </div>
                  </div>
                  <div class="bg-white tree-container q-pa-xs">
                    <q-tree
                      class="q-pa-sm q-gutter-sm"
                      dense
                      default-expand-all
                      :nodes="lazy"
                      node-key="orgTreeId"
                      label-key="labelName"
                      :filter="filter"
                      no-results-label="ไม่พบข้อมูลที่ค้นหา"
                      no-nodes-label="ไม่มีข้อมูล"
                      v-model:expanded="expanded"
                    >
                      <template v-slot:default-header="prop">
                        <q-item
                          @click.stop="updateSelected(prop.node)"
                          :active="nodeId == prop.node.orgTreeId"
                          clickable
                          active-class="my-list-link text-primary text-weight-medium"
                          class="row col-12 items-center text-dark q-py-xs q-pl-sm rounded-borders my-list"
                        >
                          <div>
                            <div
                              :class="
                                prop.node.isOfficer
                                  ? 'text-weight-medium text-blue'
                                  : 'text-weight-medium'
                              "
                            >
                              <div
                                v-if="
                                  prop.node.isDeputy == true &&
                                  prop.node.orgLevel == 0
                                "
                                class="text-info"
                              >
                                {{ prop.node.orgTreeName }}
                              </div>
                              <div v-else>
                                {{ prop.node.orgTreeName }}
                              </div>
                              {{ prop.node.isOfficer ? "(สกจ.)" : "" }}
                            </div>
                            <div class="text-weight-light text-grey-8">
                              {{
                                prop.node.orgCode == null
                                  ? null
                                  : prop.node.orgCode
                              }}
                              {{
                                prop.node.orgTreeShortName == null
                                  ? null
                                  : prop.node.orgTreeShortName
                              }}
                            </div>
                          </div>
                        </q-item>
                      </template>
                    </q-tree>
                  </div>
                </div>
              </div>
            </div>
            <div class="col-12 row">
              <q-separator :vertical="!$q.screen.lt.md" />
            </div>
          </div>

          <!-- TOOLBAR -->
          <div
            class="col-xs-12 col-sm-9 q-pa-md row scroll"
            style="height: 75vh"
          >
            <div class="col-12">
              <q-toolbar style="padding: 0">
                <q-space />
                <div class="row q-gutter-md">
                  <div>
                    <q-checkbox
                      keep-color
                      v-model="reqMaster.isBlank"
                      label="แสดงเฉพาะตำแหน่งว่าง"
                      color="primary"
                      @update:model-value="isUpload"
                    >
                      <q-tooltip>แสดงเฉพาะตำแหน่งว่าง</q-tooltip>
                    </q-checkbox>
                  </div>

                  <div>
                    <q-checkbox
                      :disable="nodeId ? false : true"
                      keep-color
                      v-model="reqMaster.isAll"
                      label="แสดงตำแหน่งทั้งหมด"
                      color="primary"
                      @update:model-value="isUpload"
                    >
                      <q-tooltip
                        >แสดงตำแหน่งทั้งหมดภายใต้หน่วยงาน/ส่วนราชการที่เลือก</q-tooltip
                      >
                    </q-checkbox>
                  </div>
                  <div>
                    <q-input
                      outlined
                      dense
                      v-model="reqMaster.keyword"
                      label="ค้นหา"
                      @keydown.enter.prevent="
                        (reqMaster.page = 1),
                          fetchDataTable(
                            reqMaster.id,
                            reqMaster.revisionId,
                            reqMaster.type,
                          )
                      "
                    >
                      <template v-slot:append>
                        <q-icon name="search" />
                      </template>
                    </q-input>
                  </div>

                  <div>
                    <q-select
                      v-model="visibleColumns"
                      multiple
                      outlined
                      dense
                      options-dense
                      :display-value="$q.lang.table.columns"
                      emit-value
                      map-options
                      :options="columns"
                      option-value="name"
                      style="min-width: 140px"
                    />
                  </div>
                </div>
              </q-toolbar>
              <d-table
                ref="table"
                :columns="columns"
                :rows="posMaster"
                :paging="true"
                row-key="id"
                flat
                bordered
                dense
                :rows-per-page-options="[10, 25, 50, 100]"
                @update:pagination="updatePagination"
                v-model:pagination="pagination"
                :visible-columns="visibleColumns"
              >
                <template v-slot:header="props">
                  <q-tr :props="props">
                    <q-th auto-width></q-th>
                    <q-th
                      v-for="col in props.cols"
                      :key="col.name"
                      :props="props"
                    >
                      <span class="text-weight-medium">{{ col.label }}</span>
                    </q-th>
                    <q-th auto-width></q-th>
                  </q-tr>
                </template>
                <template v-slot:body="props">
                  <q-tr :props="props" class="cursor-pointer">
                    <q-td>
                      <q-btn
                        flat
                        size="14px"
                        color="primary"
                        round
                        dense
                        @click="props.expand = !props.expand"
                        :icon="
                          props.expand ? 'mdi-menu-down' : 'mdi-menu-right'
                        "
                      />
                    </q-td>
                    <q-td
                      v-for="col in props.cols"
                      :key="col.name"
                      :props="props"
                    >
                      <div v-if="col.name === 'positionIsSelected'">
                        {{ col.value ? col.value : "-" }}
                        <q-btn
                          v-if="col.value !== 'ว่าง'"
                          flat
                          dense
                          color="info"
                          icon="info"
                          round
                          @click.prevent="
                            onOpenModalPersonal(
                              store.typeOrganizational === 'draft'
                                ? props.row.profileIdNextHolder
                                : props.row.profileIdCurrentHolder,
                            )
                          "
                        >
                          <q-tooltip>ดูข้อมูล</q-tooltip>
                        </q-btn>
                      </div>
                      <div v-else-if="col.name === 'posMasterNo'">
                        {{ col.value }}
                        <q-icon
                          name="mdi-star"
                          color="primary"
                          v-if="props.row.isDirector"
                        >
                          <q-tooltip>ผู้อำนวยการ/หัวหน้า</q-tooltip>
                        </q-icon>
                      </div>
                      <div v-else>
                        {{ col.value ? col.value : "-" }}
                      </div>
                    </q-td>
                    <q-td auto-width>
                      <q-btn
                        v-if="checkhideBtnAction(props.row.current_holderId)"
                        flat
                        dense
                        icon="mdi-dots-vertical"
                        class="q-pa-none q-ml-xs"
                        color="grey-13"
                        size="12px"
                      >
                        <q-menu>
                          <q-list dense style="min-width: 150px">
                            <q-item
                              clickable
                              v-close-popup
                              @click="onClickAddRole(props.row)"
                            >
                              <q-item-section>
                                <div class="row items-center">
                                  <q-icon
                                    color="blue-9"
                                    size="17px"
                                    name="mdi-account-group"
                                  />
                                  <div class="q-pl-md">กำหนดสิทธิ์</div>
                                </div>
                              </q-item-section>
                            </q-item>
                          </q-list>
                          <q-list dense style="min-width: 150px">
                            <q-item
                              clickable
                              v-close-popup
                              @click="onDeleteRole(props.row.id)"
                            >
                              <q-item-section>
                                <div class="row items-center">
                                  <q-icon
                                    color="red"
                                    size="17px"
                                    name="delete"
                                  />
                                  <div class="q-pl-md">ลบสิทธิ์</div>
                                </div>
                              </q-item-section>
                            </q-item>
                          </q-list>
                        </q-menu>
                      </q-btn>
                    </q-td>
                  </q-tr>

                  <q-tr v-show="props.expand" :props="props">
                    <q-td colspan="100%" class="bg-grey-1">
                      <q-card flat bordered class="text-left q-ma-sm">
                        <d-table
                          flat
                          :columns="columnsExpand"
                          :rows="props.row.positions"
                          table-class="text-grey-9"
                          row-key="id"
                          dense
                          bordered
                          separator="vertical"
                          class="custom-header-table-expand"
                        >
                          <template v-slot:header="props">
                            <q-tr :props="props" class="bg-grey-2">
                              <q-th
                                v-for="col in props.cols"
                                :key="col.name"
                                :props="props"
                              >
                                <span class="q-px-sm text-body2 text-black">{{
                                  col.label
                                }}</span>
                              </q-th>
                            </q-tr>
                          </template>
                          <template v-slot:body="props">
                            <q-tr :props="props" class="cursor-pointer">
                              <q-td
                                v-for="col in props.cols"
                                :key="col.name"
                                :props="props"
                              >
                                <div v-if="col.name == 'no'" class="text-body2">
                                  {{ props.rowIndex + 1 }}
                                </div>

                                <div v-else-if="col.name === 'positionName'">
                                  {{ col.value ? col.value : "-" }}
                                  <q-icon
                                    v-if="props.row.positionIsSelected"
                                    name="check"
                                    color="primary"
                                  />
                                </div>
                                <div
                                  v-else-if="col.name === 'posExecutiveName'"
                                  class="text-body2"
                                >
                                  {{ col.value ? col.value : "-" }}
                                </div>

                                <div
                                  v-else-if="
                                    col.name === 'positionExecutiveField'
                                  "
                                  class="text-body2"
                                >
                                  {{ col.value ? col.value : "-" }}
                                </div>

                                <div
                                  v-else-if="col.name === 'positionArea'"
                                  class="text-body2"
                                >
                                  {{ col.value ? col.value : "-" }}
                                </div>

                                <div v-else class="text-body2">
                                  {{ col.value }}
                                </div>
                              </q-td>
                            </q-tr>
                          </template>
                        </d-table>
                      </q-card>
                    </q-td>
                  </q-tr>
                </template>
                <template v-slot:pagination="scope">
                  ทั้งหมด {{ totalRow }} รายการ
                  <q-pagination
                    v-model="reqMaster.page"
                    active-color="primary"
                    color="dark"
                    :max="maxPage"
                    :max-pages="5"
                    size="sm"
                    boundary-links
                    direction-links
                    @update:model-value="
                      fetchDataTable(
                        reqMaster.id,
                        reqMaster.revisionId,
                        reqMaster.type,
                      )
                    "
                  ></q-pagination>
                </template>
              </d-table>
            </div>
          </div>
        </q-card>
      </div>
    </q-card-section>
  </q-card>

  <DialogAdd
    v-model:modal="modalDialogAdd"
    v-model:reqMaster="reqMaster"
    :dataPosMaster="dataPosMaster as PosMaster"
    :fetchDataTable="fetchDataTable"
  />

  <PopupPersonal
    :modal="modalPersonal"
    :id="personId"
    @update:modal="updatemodalPersonal"
  />
</template>

<style scoped>
.tree-container {
  overflow: auto;
  height: 70vh;
  border: 1px solid #e6e6e7;
  border-radius: 10px;
}

.my-list-link {
  color: rgb(118, 168, 222);
  border-radius: 5px;
  background: #a3d3fb48 !important;
  font-weight: 600;
  border: 1px solid rgba(175, 185, 196, 0.217);
}
</style>
