djspTable.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. <!-- 电井商铺 -->
  2. <template>
  3. <div class='djsp-list'>
  4. <div class='eq-list-top'>
  5. <el-input
  6. placeholder='搜索电井间'
  7. size='small'
  8. @change='getList'
  9. prefix-icon='el-icon-search'
  10. v-model='welldes'
  11. clearable
  12. style='width:192px;margin-right:12px'
  13. ></el-input>
  14. <el-input
  15. placeholder='搜索商铺编号'
  16. size='small'
  17. @change='getList'
  18. prefix-icon='el-icon-search'
  19. v-model='shopsnum'
  20. clearable
  21. style='width:192px;margin-right:12px'
  22. ></el-input>
  23. <Select @change='getList' v-model='floor' width='120' tipPlace='top' caption='楼层 :' :selectdata='floorSelect'></Select>
  24. </div>
  25. <el-table :data='tableData' :span-method='objectSpanMethod' :border='true' style='width: 100%' @row-click='innerVisible = true'>
  26. <el-table-column prop='floor' label='楼层' width='50'>
  27. <template slot-scope='{row}'>{{row.floor || '--'}}</template>
  28. </el-table-column>
  29. <el-table-column prop='welldes' label='电井间' width="120">
  30. <template slot-scope='{row}'>{{row.welldes || '--'}}</template>
  31. </el-table-column>
  32. <el-table-column prop='meterbox' label='商铺电表数' width='200'>
  33. <template slot-scope='{row}'>{{row.meterbox || '--'}}</template>
  34. </el-table-column>
  35. <el-table-column prop='shopsnum' label='商铺编号' >
  36. <template slot-scope='{row}'>{{row.shopsnumList || '--'}}</template>
  37. </el-table-column>
  38. </el-table>
  39. <div class='foot'></div>
  40. </div>
  41. </template>
  42. <script>
  43. import { Select } from 'meri-design'
  44. import EqDetail from './eqDetaileDialog'
  45. import { queryShops } from '@/api/equipmentList.js'
  46. import { mapGetters } from 'vuex'
  47. export default {
  48. components: { Select, EqDetail },
  49. data() {
  50. return {
  51. tableData: [],
  52. floor: '',
  53. innerVisible: false, //详情弹框
  54. shopsnum: '',
  55. welldes: ''
  56. }
  57. },
  58. computed: {
  59. ...mapGetters(['floorSelect'])
  60. },
  61. props: ['param'],
  62. methods: {
  63. objectSpanMethod({ row, column, rowIndex, columnIndex }) {
  64. if (columnIndex === 0) {
  65. if (row.col0count > 0) {
  66. return {
  67. rowspan: row.col0count,
  68. colspan: 1
  69. }
  70. } else {
  71. return {
  72. rowspan: 0,
  73. colspan: 0
  74. }
  75. }
  76. }
  77. },
  78. pageChanged(page) {
  79. this.currentPage = page
  80. this.getList()
  81. },
  82. getList() {
  83. let getParams = {
  84. orderBy: `floor,0;welldesm,1;meterbox,1;`
  85. }
  86. if (this.floor) {
  87. getParams.floor = this.floor
  88. }
  89. getParams.keyword = ''
  90. if (this.welldes) {
  91. getParams.keyword += `${this.welldes}:welldes;`
  92. }
  93. if (this.shopsnum) {
  94. getParams.keyword += `${this.shopsnum}:shopsnum;`
  95. }
  96. if (getParams.keyword == '') {
  97. delete getParams.keyword
  98. }
  99. queryShops({ getParams }).then(res => {
  100. console.log(res)
  101. this.tableData = []
  102. let floor = {}
  103. res.data.forEach(i => {
  104. console.log(i)
  105. Object.keys(i).forEach(key => (floor[key] = 0)) // 初始化每一楼层个数为0
  106. Object.values(i).forEach(j => {
  107. Object.values(j).forEach(k => {
  108. console.log(k)
  109. this.tableData.push(k)
  110. })
  111. })
  112. })
  113. this.tableData.map(n => {
  114. if (floor[n.floor] === 0) {
  115. const count = this.tableData.filter(m => m.floor === n.floor).length
  116. floor[n.floor] = count
  117. n.col0count = count
  118. } else {
  119. n.col0count = 0
  120. }
  121. return n
  122. })
  123. })
  124. }
  125. },
  126. watch: {
  127. param(newV, oldV) {
  128. if (newV !== oldV) {
  129. this.getList()
  130. }
  131. },
  132. floor(){
  133. this.getList()
  134. }
  135. },
  136. mounted() {
  137. this.getList()
  138. }
  139. }
  140. </script>
  141. <style lang="less" scoped>
  142. .djsp-list {
  143. .eq-list-top {
  144. display: flex;
  145. margin-bottom: 12px;
  146. }
  147. td {
  148. overflow: hidden;
  149. text-overflow: ellipsis;
  150. white-space: nowrap;
  151. }
  152. .foot {
  153. height: 32px;
  154. display: flex;
  155. justify-content: flex-end;
  156. margin-top: 28px;
  157. }
  158. }
  159. </style>