<template>
  <div class="content">
    <div>
      <byTable
        :source="sourceList.data"
        :pagination="sourceList.pagination"
        :config="config"
        :loading="loading"
        highlight-current-row
        :selectConfig="[]"
        :table-events="{}"
        :action-list="[]"
        @get-list="getList"
        :hideSearch="true"
      >
        <template #advanceCharge="{ item }">
          <div>
            {{ item.currency
            }}{{ moneyFormat(item.advanceCharge, 2) }}（预付款比列：{{
              item.advanceRatio
            }}%）
          </div>
        </template>
        <template #buyContactName="{ item }">
          <div>
            客户联系人：<span style="cursor: pointer; color: #409eff">{{
              item.buyContactName
            }}</span>
          </div>
        </template>
      </byTable>
    </div>
  </div>
</template>
  
<script setup>
import byTable from "@/components/byTable/index";
const props = defineProps({
  customerId: {
    type: String,
  },
});
const loading = ref(false);
const sourceList = ref({
  data: [],
  pagination: {
    total: 3,
    pageNum: 1,
    pageSize: 10,
  },
});
const { proxy } = getCurrentInstance();
const selectConfig = reactive([]);
const config = computed(() => {
  return [
    {
      attrs: {
        label: "时间",
        prop: "createTime",
      },
    },
    // {
    //   attrs: {
    //     label: "样品单",
    //     prop: "type",
    //   },
    //   render(type) {
    //     return type == 10 ? "报价单" : type == 20 ? "合同" : "";
    //   },
    // },
    {
      attrs: {
        label: "业务员",
        prop: "userName",
      },
    },
    {
      attrs: {
        label: "预付款",
        prop: "advanceCharge",
        slot: "advanceCharge",
      },
    },
    {
      attrs: {
        label: "客户",
        prop: "buyContactName",
        slot: "buyContactName",
      },
    },
  ];
});
const getData = () => {
  loading.value = true;
  proxy
    .post("/saleQuotation/saleDetail", { id: props.customerId })
    .then((res) => {
      sourceList.value.data = res.rows;
      sourceList.value.pagination.total = res.total;
      setTimeout(() => {
        loading.value = false;
      }, 200);
    });
};
onMounted(() => {
  if (props.customerId) {
    getData();
  }
});
</script>
  
<style lang="scss" scoped>
.content {
  padding: 10px;
}
</style>