<template>
  <!-- <a-table :columns="columns" :data-source="data" bordered :pagination="ipagination2" rowKey="id"> -->
  <a-table :columns="columns" :data-source="data" bordered :pagination="false" rowKey="id">
  </a-table>
</template>
<script>
const columns = [
  {
    title: '物资编码',
    align:"center",
    dataIndex: 'wlbm',
    key: 'wlbm',
    customRender:function (t,r,index) {
        return {children: t,attrs: {rowSpan:r.rowSpan}};
    },
  },
  {
    title: '任务号',
    align:"center",
    dataIndex: 'rwh',
    key: 'rwh',
  },
  {
    title: '总数量',
    align:"center",
    dataIndex: 'zsl',
    key: 'zsl',
  },
  {
    title: '总金额',
    align:"center",
    key: 'zje',
    dataIndex: 'zje',
    // scopedSlots: { customRender: 'tags' },
  },
];

const data = [];

export default {
    props: {
        // 对比表格数据
        duibiclList: {
        type: Array,
        default: ()=>{},
        required: false
        }
    },
  data() {
    return {
      data,
      columns,
      /* 分页参数 */
      ipagination2:{
        current: 1,
        pageSize: 10,
        pageSizeOptions: ['10', '20', '30'],
        showTotal: (total, range) => {
          return range[0] + "-" + range[1] + " 共" + total + "条"
        },
        showQuickJumper: true,
        showSizeChanger: true,
        total: 0
      },
    };
  },
  created(){
    this.data = this.duibiclList
    this.getHebing()
  },
  methods: {
    getHebing(){
        let that = this
        let rowSpan = 0
        let wlbm = ''
        for (let i = that.data.length-1; i >= 0; i--) {
            // 任务号合并
            if (wlbm == '') {
                that.data[i].rowSpan = 0
                wlbm = that.data[i].wlbm
                rowSpan++
                } else {
                if(wlbm == that.data[i].wlbm){
                    that.data[i].rowSpan = 0
                    rowSpan++
                }else{
                    that.data[i+1].rowSpan = rowSpan
                    that.data[i].rowSpan = 0
                    rowSpan = 1
                    wlbm = that.data[i].wlbm
                }
            }
        }
        that.data[0].rowSpan = rowSpan
    }
  }
};
</script>