<!--
  @description: 供应商-服务费单-订单列表
  @author: 王俊楠
  @routerPath:/procurement/procurementOrderServeFeeDeliverList
  @date： 2020-7-30 23:04:01
-->
<template>
  <table-crud
    ref="tableCrud"
    :menu="true"
    :tabs="supplierSeverTabs"
    :search-form="searchForm"
    search-label-width="100px"
    @on-load="loadData"
  >
    <!--标题-->
    <template v-slot:header>
      供应商服务费单管理
    </template>
    <template v-slot:search="search">
      <!--收款单号-->
      <el-form-item ref="voucherCode" label="收款单号" prop="voucherCode">
        <el-input
          v-model.trim="searchForm.voucherCode"
          placeholder="收款单号"
          @keyup.enter.native="search.onSearch"
        />
      </el-form-item>
      <!--订单编号-->
      <el-form-item ref="orderCode" label="订单编号" prop="orderCode">
        <el-input
          v-model.trim="searchForm.orderCode"
          placeholder="订单编号"
          @keyup.enter.native="search.onSearch"
        />
      </el-form-item>
    </template>
    <template v-slot:GXTable>
      <!-- 待缴费 -->
      <wait-pay-list v-if="tabData==='00'" :table-data="tableData" />
      <!-- 已缴费 -->
      <done-pay-list v-if="tabData==='01'" :table-data="tableData" />
    </template>
  </table-crud>
</template>

<script>
/* api接口*/
import { getPageServiceInfoLists, getPageVoucherInfoLists } from '@/api/procurement/procurementOrder'
import { orderServeFeeMixins } from '@/views/procurement/procurementOrder/mixins/orderServeFeeMixins.js'
// 组件
import waitPayList from './procurementOrderWaitPayTableComp'
import donePayList from './procurementOrderDonePayTableComp'
export default {
  name: 'OrderManagementList',
  components: {
    waitPayList,
    donePayList
  },
  mixins: [orderServeFeeMixins],
  data() {
    return {
      tableData: [],
      loading: false,
      tabData: '00',
      searchForm: {
        supplierId: this.$store.getters.info.companyId,
        orderCode: '', // 订单编号
        voucherCode: '' // 收款单号
      }
    }
  },
  methods: {
    // 获取数据
    loadData(params, callback, tabData) {
      this.tabData = tabData.index
      this.tableData = []
      // 待缴费
      if (tabData.index === '00') {
        this.loading = true
        getPageVoucherInfoLists(params).then(response => {
          this.loading = false
          this.tableData = response.data.records
          callback(response.data.total)
        }).catch(() => {
          this.loading = false
        })
      }
      // 已缴费
      if (tabData.index === '01') {
        this.loading = true
        getPageServiceInfoLists(params).then(response => {
          this.loading = false
          this.tableData = response.data.records
          callback(response.data.total)
        }).catch(() => {
          this.loading = false
        })
      }
    }
  }
}
</script>

<style lang="less" scoped></style>

