<template>
  <div class="calculation">
    <div v-if="costVisible">
      <span style="font-weight: bold; padding: 0 10px">本页信息:</span>
      <span style="padding: 0 10px">总定价:{{ total_cost }}元</span>
    </div>
    <div v-else></div>
    <div class="block">
      <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page.sync="page.page"
        :page-sizes="page.pagesizes"
        layout="total, sizes, prev, pager, next, jumper"
        :total="page.total"
        :page-size.sync="page.list_row"
      ></el-pagination>
    </div>
  </div>
</template>

<script>
import { add } from "./../utils/Decimal";

export default {
  name:"erpTablePagination",
  props: {
    costVisible:{
      type: Boolean,
      default: () => {
        return false;
      },
    },
    currentPage4: {
      type: Number,
    },
    page: {
      type: Object,
      default: () => {
        return {};
      },
    },
    tableData: {
      default: () => {
        return [];
      },
    },
  },
  components: {},
  data() {
    return {};
  },
  computed: {
    // 机器总成本
    total_cost: function () {
      let priceNumber = 0;
      this.tableData.map((res, index) => {
        if(res.total_cost){
          priceNumber = add(priceNumber, res.total_cost);
        } 
      });
      return priceNumber.toFixed(2);
    },
  },
  methods: {
    //选择每页条数
    handleSizeChange(value) {
      this.$emit("handleSizeChange",value);
    },
    //点击页码
    handleCurrentChange(value) {
      this.$emit("handleCurrentChange",value);
    },
  },
};
</script>

<style scoped lang='scss'>
.calculation {
  height: 50px;
  border: 1px solid #ebeef5;
  padding: 10px;
  font-size: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #fff;

  ::v-deep .el-pagination .el-input__suffix {
    right: -18px;
  }
}
</style>