<script setup lang="ts">
import { computed, onMounted, ref } from "vue";
import { useAsync } from "/@/hooks";
import { useRoute, useRouter } from "vue-router";
import RelatedOrder from "../basic-claim/related-order.vue";
import { httpPayAdd } from "/@/api/InvoiceSales/capitalClaim";

const { query } = useRoute();
const { push } = useRouter();
const tradNo = computed(() => query.id as string);

const treadOrderList = ref<Array<Record<string, string>>>([]);

const { run: createSaleRun } = useAsync({
  success: () => push("/InvoiceSales/capitalClaim")
});

//新增销售单付款
const requesetCreateSalePay = orderArr => {
  createSaleRun(
    httpPayAdd({
      tradNo: tradNo.value,
      orderArr
    })
  );
};

function initalData() {
  if (!tradNo.value) return;
}

//传入id初始化详情
onMounted(() => initalData());
</script>

<template>
  <div>
    <RelatedOrder
      :trade-order-list="treadOrderList"
      @create-btn-click="requesetCreateSalePay"
    />
  </div>
</template>
