<script setup lang="ts">
import { ref } from "vue";
import Modal from "./components/modal.vue";
import contentConfig from "./config/content.config";
import searchConfig from "./config/search.config";
import { usePageSearch, type PageHooks, type PageEvents } from "/@/hooks/page";
import { httpAdd, httpUpdate } from "/@/api/serviceParam/paymentChannelManage";

import { ElMessage } from "element-plus"

const PageName = "workCompany";
const instance = ref<any>(null);

const disabled = ref(false)
const visible = ref(false)
const data = ref<any>("")

const hooks: PageHooks = {
  pageSearchHook: () => usePageSearch(undefined, undefined, searchConfig)
};

const events: PageEvents = {
  content: {
    create: () => {
      data.value = ""
      disabled.value = false
      visible.value = true
    },
    preview: ({ companyNo }) => {
      data.value = companyNo
      disabled.value = true
      visible.value = true
    },
    update: ({ companyNo }) => {
      data.value = companyNo
      disabled.value = false
      visible.value = true
    }
  }
};
</script>

<template>
  <PageAuth :pageName="PageName">
    <PageContainer
      :hooks="hooks"
      :events="events"
      :contentConfig="contentConfig"
      :search-config="searchConfig"
      :get-content-ref="ref => (instance = ref)"
    />
    <Modal v-model:visible="visible" v-model:data="data" :disabled="disabled" @refresh=" instance!.onSearch()"  />
  </PageAuth>
</template>
