<template>
  <ContractDetail v-if="contract_id" :contract_id="contract_id" :account-list="accountList"
    :customer-list="customerList" />
</template>

<script lang="ts" setup>

import { getCustomerList } from '@/api/biz/customer';
import { getStaffList } from '@/api/biz/staff';
import ContractDetail from '@/pages/project/components/detail/contract-detail.vue'
import { Customer } from '@/types/customer';

const contract_id = ref();
const accountList = ref<{ id: string, name: string }[]>()
const customerList = ref<Customer[]>()

// 获取客户列表
const getCustomers = async (name?: string) => {
  try {
    const params = {
      page_no: 1,
      page_size: 9999,
      name
    }
    const { list } = await getCustomerList(params)
    customerList.value = list
  } catch (e) {
    console.error(e)
  }
}

// 获取主责人账号信息
const getAccounts = async () => {
  const { list } = await getStaffList({ page_no: 1, page_size: 9999 })
  accountList.value = list
}

onLoad(async (option) => {
  contract_id.value = option?.id
  getAccounts()
  getCustomers()
});
</script>

<style scoped></style>