<template>
  <div class="center">
    <div class="center_css">
      <div class="top_css">
        <el-row>
          <el-col :span="14">
          <el-date-picker class='date' v-model="value1" value-format="yyyy-MM-dd" @change="dateChange" type="daterange"
              range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期">
          </el-date-picker>
          </el-col>
          <el-col :span="10">
          <div class="screen">
            <el-input class='find' v-model="searchkeyWord" @keyup.enter.native="find" placeholder="可按司机姓名和订单编号查找" clearable />
            <el-button class="search" @click="find"><img width="16" height="16" style="margin-left: -8px"
                  src="../../../public/img/sousuo.png"></el-button>
          </div>
          </el-col>
        </el-row>
        <el-row>
          <el-col>
            <div class="search_btn">
              <div :class="search == '' ? 'search' : 'searchNo'" class="search_item search_block"
                @click="searchBtn('')">
                全部
              </div>
              <div :class="search == 1 ? 'search' : 'searchNo'" class="search_item" @click="searchBtn(1)">
                待还款
              </div>
              <div :class="search == 2 ? 'search' : 'searchNo'" class="search_item" @click="searchBtn(2)">
                已还款
              </div>

            </div>
          </el-col>
        </el-row>
      </div>
      <el-table :data="tableData" style="width: 98%; margin: 0 auto; border-radius: 10px" height="68vh" border highlight-current-row>
        <!-- <el-table-column prop="index" label="序号" >
          <template slot-scope="scope">
            {{scope.row.$index}}
          </el-table-column>
        </el-table-column> -->
        <el-table-column type="index" width="60"  label="序号" align="center">
            <template scope="scope">
                <span>{{scope.$index + 1}}</span>
                <!-- <span v-else>{{scope.$index}}</span> -->
            </template>
        </el-table-column>
        <el-table-column prop="orderNo" label="订单编号" />
        <el-table-column prop="cargoOwnerName" label="货主" />
         <el-table-column prop="accountNumber" label="账号" />
        <el-table-column prop="affiliatedEnterprise" label="所属企业" />
        <el-table-column prop="padmoney" label="垫付金额（元）" />
        <el-table-column prop="overdueFee" label="超期金额（元）" />
        <el-table-column prop="totalRepayable" label="合计应还（元）" />
        <el-table-column prop="alreadyRepaid" label="已还金额（元）" />
        <el-table-column prop="notRepaid" label="未还金额（元）" />
        <el-table-column prop="repaymentDate" label="还款时间" />
        <el-table-column prop="status" label="状态" >
          <template scope="scope">
            <span>{{scope.row.status}}</span>
          </template>
        </el-table-column>
      </el-table>
    </div>
    <el-pagination :current-page="currentPage" style="text-align: center; margin-top: 10px"
      :page-size="deptCircularPage.pageSize" layout="total, sizes, prev, pager, next, jumper" :total="deptBudgetTotal"
      @size-change="handleSizeChange" @current-change="handleCurrentChange" />
  </div>
</template>
<script>
import {
  getListpadsettleaccounts
} from '@/api/settlementManagement'
  export default {
    data() {
      return {
        startDate: '',
        endDate: '',
         value1: '',
        tableData: [],
        // 分页
        searchkeyWord: '',
        currentPage: 1,
        pageSize: 10,
        deptBudgetTotal: 0,
        deptCircularPage: {},
        search: '1',
        disabled: false,
      }
    },
    mounted() {
      this.getPassYearFormatDate()
      this.getList()
    },
    methods: {
      dateChange(e) {
        this.startDate = e[0]
        this.endDate = e[1]
        this.getList()
      },
      searchBtn(status){
        this.search=status
        this.getList()
      },
      // 默认日期
      getPassYearFormatDate() {
        var nowDate = new Date()
        var _date = new Date()
        var year = nowDate.getFullYear()-1
        var year1 = _date.getFullYear()
        var month = nowDate.getMonth() + 1
        var month1 = _date.getMonth() + 1
        var strDate = nowDate.getDate()
        var strDate1 = _date.getDate()
        if (month >= 1 && month <= 9) {
          month = '0' + month
        }
        if (month1 >= 1 && month1 <= 9) {
          month1 = '0' + month1
        }

        if (strDate >= 0 && strDate <= 9) {
          strDate = '0' + strDate
        }
        if (strDate1 >= 0 && strDate1 <= 9) {
          strDate1 = '0' + strDate1
        }
        this.startDate = year + '-' + month + '-' + strDate
        this.endDate = year1 + '-' + month1 + '-' + strDate1
        this.value1 = [this.startDate, this.endDate]
      },
      getList() {
        this.loading = true
        const _obj = {}
        _obj.currentPage = this.currentPage
        _obj.pageSize = this.pageSize
        _obj.searchKeyWord = this.searchkeyWord
        _obj.startDate =  this.startDate
        _obj.endDate= this.endDate
        _obj.searchType = this.search
        console.log(_obj)
        getListpadsettleaccounts(_obj).then(response => {
          if(response.data.records.length>0){
            for (let i = 0; i < response.data.records.length; i++) {
              response.data.records[i].padmoney=response.data.records[i].serviceCharge+response.data.records[i].freight
              
            }
          }
            this.tableData = response.data.records
            this.deptBudgetTotal = response.data.total
            this.listLoading = false
          })
          .catch(() => {
            this.loading = false
          })
      },
      find() {
        this.currentPage = 1
        this.getList()
      },
      handleSizeChange(val) {
        console.log(`每页 ${val} 条`)
        this.pageSize = val
        this.getList()
      },
      handleCurrentChange(val) {
        this.currentPage = val
        console.log(`当前页: ${val}`)
        this.getList()
      }
    }
  }
</script>
<style lang="scss" scoped>
  .center {
    padding: 10px 20px;
    background: #f5f6f7;
    min-height: calc(100vh - 50px);

    .top_css {
      padding: 10px;

      .search_btn {
        display: flex;
        margin-top: 20px;

        .search_item {
          text-align: center;
          font-size: 14px;
          font-weight: 600;
          line-height: 40px;
          width: 112px;
          height: 40px;
          background: #f7f8f9;
          cursor: pointer
        }

        .searchNo {
          color: #323233;
        }

        .search {
          color: #2f53eb;
          background: #ffffff;
        }
      }
    }

    .ask_css {
      position: absolute;
      margin: 3px 0 0 10px;
    }

    .center_css {
      background: #ffffff;
      border-radius: 1px;
      margin-top: 10px;
      padding-bottom: 10px;
    }

    .screen {
      display: flex;

      .search {
        width: 40px;
        height: 40px;
        background: #2f53eb;
        border-radius: 0px 2px 2px 0px;
        border: 1px solid #DCDFE6;
        margin-left:-1px;
      }

      .count_css {
        width: 80px;
        text-align: center;
        line-height: 40px;
        color: #666666;
      }
    }

    .el-button {
      padding: 10px 20px !important;
    }

    .center_css {

      ::v-deep .el-table th,
      ::v-deep .el-table td {
        text-align: center;
      }

      .fujian {
        font-size: 24px;
        color: #409eff;
      }

      .warning {
        font-size: 14px;
        color: #ed1d1d;
      }
    }
  }

  .car_css {
    width: 50%;
    display: inline-block;
    text-align: center;
    margin-top: 30px;
    position: relative;

    .status_css {
      background: #3AC602;
      width: 50px;
      height: 17px;
      position: absolute;
      top: 0px;
      right: 15px;
      border-radius: 3px;
    }

    .carno_css {
      padding: 1px 5px;
      background-color: #F5F6F7;
      color: #666666;
      border-radius: 12px;
      text-align: center;
      width: 100px;
      margin: 10px auto 0;
    }

    .carborder_css {
      border: 1px solid #F0F1F2;
      margin: 15px auto 0;
      width: 90%;
    }
  }

  .tips {
    color: #999999;
    font-size: 14px;
  }

  .car_item {
    width: 200px;
    height: 160px;
    border-radius: 5px;
  }

  .user {
    margin-bottom: 20px;

    .id_css {
      font-size: 14px;
    }

    .id_css,
    .name_css {
      margin: 5px 0;
      color: #0D0D0D;
    }

    .pay_name {
      color: #9D9D9D;
      font-size: 14px;
    }

    .name_css {
      font-size: 16px;
    }

    .user_item {
      margin: 25px 0;
      width: 450px;
      height: 300px;
    }

    .border_css {
      width: 100%;
      border: 1px solid #F0F1F2;
    }
  }

  ::v-deep .el-table--border .el-table__header th {
    background: #f7f8f9;
  }

  .btn_css {
    color: #409EFF;
    cursor: pointer
  }

  .btn_css1 {
    margin-left: -20px;
  }

  .sign {
    font-size: 14px;
    color: red;
  }

  .form_css {
    width: 100%;
    margin: 20px auto 20px;

    ::v-deep .el-checkbox {
      width: 40%;
      height: 30px;
    }

    // ::v-deep .el-dialog__body{
    // 	padding: 10px 20px;
    // }
    ::v-deep .el-dialog__title {
      font-size: 16px;
    }

    ::v-deep .el-textarea__inner {
      background: #F0F1F2;
    }

    .form_btn {
      text-align: right;
      margin-top: 10px;
    }
  }

  //发送信息
  .Info_css {
    .Info_title {
      color: #323233;
      font-size: 16px;
    }

    .Info_item {
      margin: 20px 0;
    }

    .Info_btn {
      text-align: right;
      margin-top: 10px;
    }
  }

  //附件
  .file {
    .fujian_css {
      width: 631px;
      display: flex;
      margin: 0 auto;
      text-align: center;
      line-height: 32px;
      border: 1px solid #F0F1F2;
      border-right: 0px;
      border-radius: 2px 0px 0px 2px;

      .fujian_item {
        cursor: pointer;
        width: 90px;
        height: 32px;
        border-right: 1px solid #F0F1F2;
      }

      .file_btn {
        color: #2F53EB;
        background-color: #CFDBFE;
      }
    }

    .file_img {
      width: 525px;
      height: 332px;
      margin: 20px auto;
    }

    .img_css {
      width: 525px;
      height: 332px;
    }

    .btn {
      width: 400px;
      margin: 0 auto;
    }
  }
  .date{
    margin:0 10px;
  }
  .find::v-deep input.el-input__inner{
    border-radius:0;
  }
</style>
