importExcelSaleOrder.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. <template>
  2. <div>
  3. <el-table
  4. :data="tableData1"
  5. :span-method="objectSpanMethod"
  6. border
  7. highlight-current-row
  8. >
  9. <el-table-column
  10. property="receiveName"
  11. label="下单客户"
  12. width="200"
  13. ></el-table-column>
  14. <el-table-column property="truckNo" label="车序号"></el-table-column>
  15. <el-table-column
  16. property="materialName"
  17. label="物资名称"
  18. ></el-table-column>
  19. <el-table-column
  20. property="materialSpecification"
  21. label="物资规格"
  22. ></el-table-column>
  23. <el-table-column
  24. property="materialModel"
  25. label="物资型号"
  26. ></el-table-column>
  27. <el-table-column property="steelMeters" label="米数"></el-table-column>
  28. <el-table-column
  29. property="materialNumber"
  30. label="物资件数"
  31. ></el-table-column>
  32. <el-table-column property="province" label="省"></el-table-column>
  33. <el-table-column property="district" label="市"></el-table-column>
  34. <el-table-column property="town" label="县"></el-table-column>
  35. <el-table-column property="place" label="具体收货地址"></el-table-column>
  36. <el-table-column
  37. property="isSelfMention"
  38. label="是否自提"
  39. width="150"
  40. ></el-table-column>
  41. <el-table-column
  42. property="saleRemark"
  43. label="摘要"
  44. width="150"
  45. ></el-table-column>
  46. <el-table-column
  47. property="saleOrderReceiveCustomer"
  48. label="收款客户"
  49. width="150"
  50. ></el-table-column>
  51. <el-table-column
  52. property="truckRemark"
  53. label="车号备注"
  54. ></el-table-column>
  55. <el-table-column
  56. property="saleOrderConsigneeTel"
  57. label="收货方电话"
  58. ></el-table-column>
  59. <el-table-column
  60. property="saleDateOfReceipt"
  61. label="截止日期"
  62. ></el-table-column>
  63. <el-table-column
  64. property="isPoundSale"
  65. label="是否磅重交货"
  66. ></el-table-column>
  67. <el-table-column
  68. property="shipperName"
  69. label="发货单位"
  70. width="150"
  71. ></el-table-column>
  72. </el-table>
  73. </div>
  74. </template>
  75. <script>
  76. export default {
  77. name: "ExcelSaleOrder",
  78. props: {
  79. tableData: {
  80. type: Array,
  81. default: () => []
  82. }
  83. },
  84. data() {
  85. return {
  86. columnIndexList: [0, 1, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16],
  87. spanArr: [],
  88. tableData1: this.tableData
  89. };
  90. },
  91. mounted() {
  92. this.getSpanArr(this.tableData1);
  93. },
  94. methods: {
  95. //记录每一行的合并数
  96. getSpanArr(data) {
  97. //每次调用方法初始化
  98. this.spanArr = [];
  99. for (var i = 0; i < data.length; i++) {
  100. if (i === 0) {
  101. this.spanArr.push(1);
  102. this.pos = 0;
  103. data[i].group = i;
  104. } else {
  105. // 判断当前元素与上一个元素是否相同
  106. if (data[i].truckNo === data[i - 1].truckNo) {
  107. this.spanArr[this.pos] += 1;
  108. this.spanArr.push(0);
  109. data[i].group = data[i - 1].group;
  110. } else {
  111. this.spanArr.push(1);
  112. this.pos = i;
  113. data[i].group = data[i - 1].group + 1;
  114. }
  115. }
  116. }
  117. },
  118. objectSpanMethod({ row, column, rowIndex, columnIndex }) {
  119. if (this.columnIndexList.indexOf(columnIndex) != -1) {
  120. const _row = this.spanArr[rowIndex];
  121. const _col = _row > 0 ? 1 : 0;
  122. return {
  123. rowspan: _row,
  124. colspan: _col
  125. };
  126. }
  127. }
  128. }
  129. };
  130. </script>