wuliaoList.vue 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <template>
  2. <a-table :columns="columns" :data-source="data" bordered :pagination="ipagination2" rowKey="id">
  3. </a-table>
  4. </template>
  5. <script>
  6. const columns = [
  7. {
  8. title: '物资编码',
  9. align:"center",
  10. dataIndex: 'wlbm',
  11. key: 'wlbm',
  12. customRender:function (t,r,index) {
  13. return {children: t,attrs: {rowSpan:r.rowSpan}};
  14. },
  15. },
  16. {
  17. title: '任务号',
  18. align:"center",
  19. dataIndex: 'rwh',
  20. key: 'rwh',
  21. },
  22. {
  23. title: '总数量',
  24. align:"center",
  25. dataIndex: 'zsl',
  26. key: 'zsl',
  27. },
  28. {
  29. title: '总金额',
  30. align:"center",
  31. key: 'zje',
  32. dataIndex: 'zje',
  33. // scopedSlots: { customRender: 'tags' },
  34. },
  35. ];
  36. const data = [];
  37. export default {
  38. props: {
  39. // 对比表格数据
  40. duibiclList: {
  41. type: Array,
  42. default: ()=>{},
  43. required: false
  44. }
  45. },
  46. data() {
  47. return {
  48. data,
  49. columns,
  50. /* 分页参数 */
  51. ipagination2:{
  52. current: 1,
  53. pageSize: 10,
  54. pageSizeOptions: ['10', '20', '30'],
  55. showTotal: (total, range) => {
  56. return range[0] + "-" + range[1] + " 共" + total + "条"
  57. },
  58. showQuickJumper: true,
  59. showSizeChanger: true,
  60. total: 0
  61. },
  62. };
  63. },
  64. created(){
  65. this.data = this.duibiclList
  66. this.getHebing()
  67. },
  68. methods: {
  69. getHebing(){
  70. let that = this
  71. let rowSpan = 0
  72. let wlbm = ''
  73. for (let i = that.data.length-1; i >= 0; i--) {
  74. // 任务号合并
  75. if (wlbm == '') {
  76. that.data[i].rowSpan = 0
  77. wlbm = that.data[i].wlbm
  78. rowSpan++
  79. } else {
  80. if(wlbm == that.data[i].wlbm){
  81. that.data[i].rowSpan = 0
  82. rowSpan++
  83. }else{
  84. that.data[i+1].rowSpan = rowSpan
  85. that.data[i].rowSpan = 0
  86. rowSpan = 1
  87. wlbm = that.data[i].wlbm
  88. }
  89. }
  90. }
  91. that.data[0].rowSpan = rowSpan
  92. }
  93. }
  94. };
  95. </script>