<script setup lang="ts">
import { computed, onMounted, ref } from "vue";
import BasicSettings from "../basic-settings.vue";
import { good_detail_columns } from "./config/configs";
import { useResponseHandle } from "/@/hooks";
import { useRoute } from "vue-router";

import {
  type IGoodDetail,
  httpDetail
} from "/@/api/InvoiceSaleSettings/commodityCost";

const { query } = useRoute();
const spuCode = computed(() => query.id);
const goodDetail = ref<IGoodDetail | null>(null);
const responseHandle = useResponseHandle();

//请求商品详情
async function requesetGoodDetail() {
  const { code, message, data } = await httpDetail({ spuCode: spuCode.value });
  responseHandle({
    code,
    message,
    handler: () => (goodDetail.value = data)
  });
}

onMounted(() => requesetGoodDetail());
</script>

<template>
  <BasicSettings
    title="咨询成交类目设置" 
    back-route="/supplyInvoiceSaleSettings/supplyConsultingChildCost" 
    :detail="goodDetail"
    :columns="good_detail_columns" 
    @refresh="requesetGoodDetail()" 
    pageName="supplyConsultingChildCostDetail" 
    :isZx="true"
  />
</template>
