djspTable.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. <!-- 电井商铺 -->
  2. <template>
  3. <div class='djsp-list'>
  4. <div class='eq-list-top'>
  5. <el-input
  6. placeholder='搜索电井间'
  7. size='small'
  8. @keyup.enter.native='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. @keyup.enter.native='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='180' 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. import store from '../../../store/index'
  48. export default {
  49. components: { Select, EqDetail },
  50. data() {
  51. return {
  52. tableData: [],
  53. floor: '',
  54. innerVisible: false, //详情弹框
  55. shopsnum: '',
  56. welldes: ''
  57. }
  58. },
  59. computed: {
  60. ...mapGetters(['floorSelect', 'plazaId'])
  61. },
  62. props: ['param'],
  63. methods: {
  64. objectSpanMethod({ row, column, rowIndex, columnIndex }) {
  65. if (columnIndex === 0) {
  66. if (row.col0count > 0) {
  67. return {
  68. rowspan: row.col0count,
  69. colspan: 1
  70. }
  71. } else {
  72. return {
  73. rowspan: 0,
  74. colspan: 0
  75. }
  76. }
  77. }
  78. },
  79. pageChanged(page) {
  80. this.currentPage = page
  81. this.getList()
  82. },
  83. getList() {
  84. let getParams = {
  85. orderBy: `floor,0;welldesm,1;meterbox,1;`,
  86. plazaId: this.plazaId
  87. }
  88. if (this.floor) {
  89. getParams.floor = this.floor
  90. }
  91. getParams.keyword = ''
  92. if (this.welldes) {
  93. getParams.keyword += `${this.welldes}:welldes;`
  94. }
  95. if (this.shopsnum) {
  96. getParams.keyword += `${this.shopsnum}:shopsnum;`
  97. }
  98. if (getParams.keyword == '') {
  99. delete getParams.keyword
  100. }
  101. queryShops({ getParams }).then(res => {
  102. console.log(res)
  103. this.tableData = []
  104. let floor = {}
  105. res.data &&
  106. res.data.forEach(i => {
  107. console.log(i)
  108. Object.keys(i).forEach(key => (floor[key] = 0)) // 初始化每一楼层个数为0
  109. Object.values(i).forEach(j => {
  110. Object.values(j).forEach(k => {
  111. console.log(k)
  112. this.tableData.push(k)
  113. })
  114. })
  115. })
  116. this.tableData.map(n => {
  117. if (floor[n.floor] === 0) {
  118. const count = this.tableData.filter(m => m.floor === n.floor).length
  119. floor[n.floor] = count
  120. n.col0count = count
  121. } else {
  122. n.col0count = 0
  123. }
  124. return n
  125. })
  126. })
  127. }
  128. },
  129. watch: {
  130. param(newV, oldV) {
  131. if (newV !== oldV) {
  132. this.getList()
  133. }
  134. },
  135. /* floor() {
  136. console.log('watch floor')
  137. this.getList()
  138. }, */
  139. // 监听 vuex 中currentFloor的变化,切换楼层后,更新下拉菜单
  140. '$store.state.currentFloor': {
  141. handler(newV, oldV) {
  142. if (newV.gname !== oldV.gname) {
  143. this.floor = newV.gname
  144. this.getList()
  145. }
  146. },
  147. deep: true
  148. }
  149. },
  150. mounted() {
  151. console.log('商铺电表数 mounted')
  152. this.floor = this.$cookie.get('floorMapId')
  153. console.log(this.floor)
  154. this.getList()
  155. }
  156. }
  157. </script>
  158. <style lang="less" scoped>
  159. .djsp-list {
  160. .eq-list-top {
  161. display: flex;
  162. margin-bottom: 12px;
  163. }
  164. td {
  165. overflow: hidden;
  166. text-overflow: ellipsis;
  167. white-space: nowrap;
  168. }
  169. .foot {
  170. height: 32px;
  171. display: flex;
  172. justify-content: flex-end;
  173. margin-top: 28px;
  174. }
  175. }
  176. </style>