<template>
  <Search :name="'客户名称'" @handleSearch="handleSearch"/>
  <view class="c-card">
    <StatisticCard :list="list" />
    <view class="detail">
      <view v-for="(item, index) in billList" :key="index" @click="getDetail(item)">
        <text>{{ item.supplierName }}</text>
        <text class="num">¥{{ item.unPayTotalPrice }} <text class="tip">欠</text></text>
      </view>
      <u-empty v-if="billList.length === 0" mode="data" icon="http://cdn.uviewui.com/uview/empty/data.png">
      </u-empty>
    </view>
  </view>
</template>
<script setup lang="ts">
import Search from "@/components/Search/index.vue";
import StatisticCard from "@/components/StatisticCard/index.vue";
import { ShipmentApi } from "@/services";
const list = reactive([
  {
    num: 0,
    name: "欠款客户",
  },
  {
    num: 0,
    name: "欠款金额",
  },
]);
const getDetail = (item: any) => {
  uni.navigateTo({
    url: "/pagesStatistics/billDetail?type=2&id=" + item.userId +`&name=${item.supplierName}`, // 要跳转到的页面路径
  });
};
const handleSearch = (v:string) => {
  getList(v)
}
const billList = ref<any>([])
const getList = (v: string) => {
  ShipmentApi.getReconciliation({userName: v}).then((res:any) => {
    if (res.code === 200) {
      list[0].num = res.data.supplierNum
      list[1].num = res.data.unPayTotalPrice
      billList.value = res.data.unPaySupplierVos
    }
  })
}
onMounted(() => {
  getList('')
})
</script>
<style lang="scss" scoped>
.c-card {
  background: #ffffff;
  box-shadow: 0rpx 0rpx 10rpx 0rpx rgba(5, 68, 37, 0.12);
  border-radius: 13rpx;
  margin: 30rpx 25rpx;
}
.detail {
  border-top: 18rpx solid #f8f8f8;
  padding: 20rpx;
  font-family: Source Han Sans CN;
  font-weight: 400;
  font-size: 28rpx;
  color: #000000;
  > view {
    display: flex;
    justify-content: space-between;
    padding: 20rpx 10rpx;
    .num {
      color: #EC0F3E;
    }
    .tip {
      color: $u-primary;
      margin-left: 20rpx;
      font-weight: 500;
      font-size: 24rpx;
    }
  }
  > view + view {
    border-top: 1px solid rgba(233, 233, 233, 0.76);
  }
}
</style>