<template>
  <div class="summarizedCalculation">
    <LTable ref="table" :defaultFetch="true" :columns="columns" :dataSource="tableData" :options="options" :fetch="fetchTableData" :pagination="pagination" />
  </div>
</template>

<script>
import { columns, options, data } from './summarizedCalculation'
import { getSummaryData, sumCalculate } from '@/api/carrierStandard/carrierSailingMaterialConsumeRecord'
export default {
  name: 'SummarizedCalculation',
  components: {},
  data() {
    // 这里存放数据
    return {
      columns: columns(this),
      options,
      // 分页
      pagination: {
        total: 0,
        pageIndex: 1,
        pageSize: 20
      },
      tableData: []
    }
  },
  methods: {
    async fetchTableData() {
      if (this.$refs.table) {
        this.$refs.table.clearSelection()
      }
      const { pageIndex, pageSize } = this.pagination
      const { consumeDataId } = this.$route.params
      try {
        await sumCalculate({ consumeDataId })
        const {
          data: { list, totalCount }
        } = await getSummaryData({
          consumeDataId,
          pageIndex,
          pageSize
        })
        this.tableData = list
        this.pagination.total = totalCount
      } catch (error) {}
    }
  }
}
</script>

<style lang="scss">
@import './index.scss';
</style>
