<script setup lang="ts">
import { ref, onMounted } from "vue";
import ActionTable from "./components/action-table.vue";
import EditModel from "./components/edit-dialog.vue";
import { usePermission } from "/@/hooks/usePermission";
const pageName = "menuOperator";
const actionTableRef = ref<InstanceType<typeof ActionTable>>(null);
const modelRef = ref<InstanceType<typeof EditModel>>(null);
const powers = ref([]);
//新建/编辑/查看
function handleAddChangeCheck(item: any, id: string, type: string) {
  modelRef.value.show(item, id, type);
}
const { permissions } = usePermission(pageName);
powers.value = permissions.value;
onMounted(() => {
  if (powers.value.some(i => i == "001")) {
    actionTableRef.value.onSearch();
  }
});
</script>

<template>
  <div class="main">
    <PageAuth :pageName="pageName">
      <ActionTable
        v-show="powers.some(i => i == '001')"
        ref="actionTableRef"
        @edit="handleAddChangeCheck"
        @create="handleAddChangeCheck"
        @view="handleAddChangeCheck"
      />
      <EditModel ref="modelRef" @reload="actionTableRef.onSearch()" />
    </PageAuth>
  </div>
</template>
