3cbaea05775506e7011930598dd51d4a93f6c8cb.svn-base 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. <template>
  2. <div class="">
  3. <el-table
  4. :data="listData"
  5. :span-method="objectSpanMethod"
  6. class="tableArea"
  7. style="width: 100%"
  8. >
  9. <!-- <el-table :data="listData" class="tableArea" style="width: 100%"> -->
  10. <el-table-column prop="type" label="序号" align="center" width="200" />
  11. <el-table-column prop="sheetType" label="" />
  12. <el-table-column prop="taskKey" label="宝鸡1" />
  13. <el-table-column prop="templateUrl" label="宝鸡2" />
  14. <el-table-column label="操作">
  15. <template slot-scope="scope">
  16. <el-tooltip class="item" effect="dark" content="修改" placement="top-start">
  17. <i class="el-icon-edit-outline" @click="modify(scope)" />
  18. </el-tooltip>
  19. <el-tooltip class="item" effect="dark" content="删除" placement="top-start">
  20. <i class="el-icon-delete" @click="deleteData(scope)" />
  21. </el-tooltip>
  22. </template>
  23. </el-table-column>
  24. </el-table>
  25. </div>
  26. </template>
  27. <script>
  28. import { handleTableSpan, handleObjectSpanMethod } from '../../util.js'
  29. export default {
  30. name: 'MyNeedDeal',
  31. data() {
  32. return {
  33. listData: [],
  34. spanObj: {},
  35. mergekeys: ['type', 'sheetType', 'templateUrl']
  36. }
  37. },
  38. created() {
  39. },
  40. mounted() {
  41. this.queryData()
  42. },
  43. methods: {
  44. queryData() { // 查询操作
  45. this.listData = [
  46. {
  47. id: 1,
  48. type: 1,
  49. sheetType: '事件单',
  50. taskKey: 'shijian_01',
  51. templateUrl: '/shijian_01'
  52. },
  53. {
  54. id: 2,
  55. type: 1,
  56. sheetType: '事件单',
  57. taskKey: 'shijian_02',
  58. templateUrl: '/shijian_02'
  59. },
  60. {
  61. id: 3,
  62. type: 1,
  63. sheetType: '事件单',
  64. taskKey: 'shijian_02',
  65. templateUrl: '/shijian_03'
  66. },
  67. {
  68. id: 4,
  69. type: 2,
  70. sheetType: '问题单',
  71. taskKey: 'wenti_01',
  72. templateUrl: '/wenti_01'
  73. },
  74. {
  75. id: 5,
  76. type: 2,
  77. sheetType: '问题单',
  78. taskKey: 'wenti_02',
  79. templateUrl: '/wenti_02'
  80. },
  81. {
  82. id: 6,
  83. type: 2,
  84. sheetType: '问题单',
  85. taskKey: 'wenti_03',
  86. templateUrl: '/wenti_03'
  87. }
  88. ]
  89. this.handleSpan()
  90. },
  91. handleSpan() {
  92. this.mergekeys.forEach(key => {
  93. this.spanObj[key] = []
  94. let position = 0
  95. this.listData.forEach((item, index) => {
  96. if (index === 0) {
  97. this.spanObj[key].push(1)
  98. position = 0
  99. } else {
  100. if (this.listData[index][key] === this.listData[index - 1][key]) {
  101. this.spanObj[key][position] += 1
  102. this.spanObj[key].push(0)
  103. } else {
  104. this.spanObj[key].push(1)
  105. position = index
  106. }
  107. }
  108. })
  109. })
  110. },
  111. objectSpanMethod({ row, column, rowIndex, columnIndex }) {
  112. for (let i = 0; i < this.mergekeys.length; i++) {
  113. if (column.property === this.mergekeys[i]) {
  114. const _row = this.spanObj[this.mergekeys[i]][rowIndex]
  115. const _col = _row > 0 ? 1 : 0
  116. return {
  117. rowspan: _row,
  118. colspan: _col
  119. }
  120. }
  121. }
  122. }
  123. }
  124. }
  125. </script>