<template>
  <div class="app-container">
    <!-- 筛选条件 -->
    <div>
      <el-form
        ref="searchForm"
        :model="searchForm"
        label-width="100px"
        size="small"
        label-position="left"
      >
        <el-row :gutter="20">
          <el-col :xs="24" :sm="12" :lg="6">
            <el-form-item label="经销商名称" prop="">
              <el-input
                v-model="searchForm.customerName"
                placeholder="请输入经销商名称"
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="24" :sm="12" :lg="6">
            <el-form-item label="经销商编码" prop="">
              <el-input
                v-model="searchForm.customerNumber"
                placeholder="请输入"
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="24" :sm="24" :lg="24">
            <el-form-item label="" class="fr">
              <el-button size="small">清空</el-button>
              <el-button size="small" type="primary" @click="searchFn"
                >搜索</el-button
              >
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
    </div>
    <!-- 按钮 -->
    <div class="btn-group clearfix">
      <div class="fr">
        <el-button type="primary" size="small">导出</el-button>
      </div>
    </div>
    <!-- 列表 -->
    <div class="mymain-container">
      <div class="table">
        <el-table
          v-loading="listLoading"
          :data="dataList"
          element-loading-text="Loading"
          border
          fit
          highlight-current-row
          stripe
        >
          <el-table-column
            align="center"
            label="经销商编码"
            prop="customerNumber"
            min-width="160"
            show-overflow-tooltip
          ></el-table-column>
          <el-table-column
            align="center"
            label="经销商名称"
            prop="customerName"
            min-width="160"
            show-overflow-tooltip
          ></el-table-column>
          <el-table-column
            align="center"
            label="总金额"
            prop="total"
            min-width="160"
            show-overflow-tooltip
          ></el-table-column>
          <el-table-column
            align="center"
            label="更新时间"
            prop="theTime"
            min-width="160"
            show-overflow-tooltip
          ></el-table-column>

          <el-table-column
            align="center"
            label="操作"
            min-width="160"
            show-overflow-tooltip
            fixed="right"
          >
            <template v-slot="{ row }">
              <el-button
                type="text"
                class="textColor"
                @click="walletFn(row.customerId)"
              >
                余额
              </el-button>
              <el-button
                type="text"
                class="textColor"
                @click="seeFN(row.customerName, row.customerNumber)"
              >
                明细
              </el-button>
            </template>
          </el-table-column>
        </el-table>
      </div>
      <!-- 分页
      <div class="fr">
        <el-pagination
          :current-page="currentPage"
          :page-sizes="[10, 20, 30, 50]"
          :page-size="10"
          layout="total, sizes, prev, pager, next, jumper"
          :total="listTotal"
        >
        </el-pagination>
      </div> -->
    </div>
  </div>
</template>

<script>
import { getFinanceTotalCustomer } from "@/api/finance/blance_sum";
export default {
  data() {
    return {
      // currentPage: 1, // 当前页码
      // pageSize: 10, // 每页数量
      // listTotal: 0, // 列表总数
      dataList: [], // 列表数据
      searchForm: {
        customerName: "",
        customerNumber: "",
      }, //搜索表单
      listLoading: false, // 列表加载loading
    };
  },
  created() {
    this.getDataList();
  },
  methods: {
    //搜索
    searchFn() {
      this.getDataList(this.searchForm);
    },
    //获取列表数据
    async getDataList(data) {
      const res = await getFinanceTotalCustomer(data);
      console.log(res);
      this.dataList = res.data;
    },
    //余额
    walletFn(v) {
      this.$router.push({
        path: "/finance/wallet",
        query: {
          id: v,
        },
      });
    },
    //明细
    seeFN(customerName, customerNumber) {
      this.$router.push({
        path: "/finance/standbook_list",
        query: {
          customerName,
          customerNumber,
        },
      });
    },
  },
};
</script>

<style></style>
