73cab418937290046f169dcfda664fa9bbfe7e40.svn-base 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. <template>
  2. <div id="app">
  3. <div class="content">
  4. <div class="data-container" style="width:98%;margin:0 auto;">
  5. <h3>各牧场设备统计表:</h3>
  6. <el-table ref="interfaceTable" :data="dataList" border :row-style="rowStyle" :cell-style="cellStyle" style="width: 100%" :span-method="colspanMethod" :show-header="showHeader">
  7. <el-table-column label="一级分类" prop="pasture" align="center" width="160" />
  8. <el-table-column label="二级分类" prop="pasture1" align="center" />
  9. <el-table-column label="三级分类" prop="pasture2" align="center" width="160" />
  10. <el-table-column label="类型" prop="type" align="center" />
  11. <el-table-column label="宝鸡1" prop="pastureName1" align="center" />
  12. <el-table-column label="宝鸡2" prop="pastureName2" align="center" width="160" />
  13. <!-- <el-table-column label="物流公司" prop="companyName" align="center" />
  14. <el-table-column label="物流单号" prop="logisticsNo" align="center" width="160" />
  15. <el-table-column label="发货时间" prop="deliveryTime" align="center" width="140" />
  16. <el-table-column label="包裹信息" align="center" prop="arr">
  17. <template slot-scope="scope">
  18. <div v-if="scope.row.packageLong">
  19. <div v-for="(item, index) in scope.row.arr" :key="index">{{ item.msg }}</div>
  20. </div>
  21. <div v-else>/</div>
  22. </template>
  23. </el-table-column>
  24. <el-table-column label="包材编号" prop="materialsCode" align="center" /> -->
  25. </el-table>
  26. </div>
  27. </div>
  28. </div>
  29. </template>
  30. <script>
  31. import datas from '../../data.js'
  32. import { handleTableSpan, handleObjectSpanMethod } from '../../util.js'
  33. export default {
  34. components: {},
  35. mixins: [],
  36. data() {
  37. return {
  38. border: false,
  39. showHeader: false,
  40. dataList: [],
  41. // 要合并的单元格的rowspan 数据
  42. rowspanObj: {},
  43. // 要纵向合并的单元格的key数组
  44. mergekeys: ['pasture', 'pasture1', 'pasture2', 'logisticsNo', 'arr', 'materialsCode'],
  45. rowStyle: { maxHeight: 30 + 'px', height: 30 + 'px' },
  46. cellStyle: { padding: 0 + 'px' }
  47. }
  48. },
  49. computed: {},
  50. watch: {
  51. dataList: function() {
  52. this.$nextTick(function() {
  53. this.$refs.interfaceTable.$el.background = 'red !important'
  54. console.log(this.$refs.interfaceTable.$el)
  55. console.log(this.$refs.interfaceTable)
  56. })
  57. }
  58. },
  59. created() {},
  60. mounted() {
  61. this.getDataList()
  62. },
  63. methods: {
  64. getDataList() {
  65. this.dataList = datas
  66. console.log()
  67. // 先处理一下数据,拿到要合并单元格的 rowspan 数据
  68. this.rowspanObj = handleTableSpan(this.mergekeys, this.dataList)
  69. console.log(this.rowspanObj)
  70. // const length = 'mm'
  71. // const weight = 'g'
  72. // const arr = []
  73. // datas.forEach((element, index) => {
  74. // element.arr = [
  75. // { msg: '长:' + element.packageLong + `${length}` },
  76. // { msg: '宽:' + element.packageWidth + `${length}` },
  77. // { msg: '高:' + element.packageHeight + `${length}` },
  78. // { msg: '重量:' + element.packageWeight + `${weight}` }
  79. // ]
  80. // element.expressPackCode = element.expressPackCode ? element.expressPackCode : '/'
  81. // element.companyName = element.companyName ? element.companyName : '/'
  82. // element.logisticsNo = element.logisticsNo ? element.logisticsNo : '/'
  83. // element.deliveryTime = element.deliveryTime ? element.deliveryTime : '/'
  84. // element.logisticsNo = element.logisticsNo ? element.logisticsNo : '/'
  85. // element.materialsCode = element.materialsCode ? element.materialsCode : '/'
  86. // })
  87. },
  88. colspanMethod(tableObj) {
  89. return handleObjectSpanMethod(tableObj, this.mergekeys, this.rowspanObj, true)
  90. }
  91. }
  92. }
  93. </script>
  94. <style lang="scss" scoped>
  95. </style>