chargingStation.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. <template>
  2. <div class="app-container">
  3. <div class="search-container">
  4. <el-form :inline="true" :model="searchForm" size="mini" class="demo-form-inline">
  5. <el-form-item label="门店">
  6. <lazy-tree
  7. ref="addTree"
  8. input-width="400px"
  9. style="margin-bottom: 0;display:flex;width:100%"
  10. @handleSelectGroup="selectGroup"
  11. />
  12. </el-form-item>
  13. <el-form-item>
  14. <el-checkbox v-model="searchForm.is_all_level" :true-label="1" :false-label="0">包含所有门店</el-checkbox>
  15. </el-form-item>
  16. <el-form-item label="充电站名称">
  17. <el-input v-model="searchForm.name" placeholder="充电站名称" clearable style="width: 160px;" />
  18. </el-form-item>
  19. <el-form-item label="状态">
  20. <el-select v-model="searchForm.status" clearable placeholder="状态" size="mini" style="width: 150px;">
  21. <el-option label="启用" value="ENABLED" />
  22. <el-option label="禁用" value="DISABLED" />
  23. </el-select>
  24. </el-form-item>
  25. <el-form-item>
  26. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleCurrentChange()">查询</el-button>
  27. <el-button type="success" icon="el-icon-plus" size="mini" @click="handleAdd">新增</el-button>
  28. </el-form-item>
  29. <el-form-item>
  30. <el-tooltip content="表格字段设置" effect="dark">
  31. <img
  32. class="table-cfg-icon"
  33. src="https://qiniu.bms16.com/menu_header_config.png"
  34. @click="loadFieldDialog"
  35. >
  36. </el-tooltip>
  37. </el-form-item>
  38. </el-form>
  39. </div>
  40. <el-table
  41. v-loading="loading"
  42. ref="multipleTable"
  43. :data="tableData"
  44. :key="JSON.stringify(fieldDefsData)"
  45. border
  46. style="width: 100%"
  47. @row-dblclick="handleUpdate"
  48. @header-dragend="onHeaderDragend"
  49. >
  50. <el-table-column v-for="(item, index) in fieldDefsData" :key="index" v-bind="item" >
  51. <template slot-scope="scope">
  52. <div v-if="item.prop === 'status'">
  53. <el-tag v-if="scope.row.status === 'ENABLED'" type="success">启用</el-tag>
  54. <el-tag v-if="scope.row.status === 'DISABLED'" type="danger">禁用</el-tag>
  55. </div>
  56. <div v-else-if="item.prop === 'contacts'">
  57. {{ scope.row.contacts }} {{ '/' + scope.row.phone }}
  58. </div>
  59. <div v-else>{{ scope.row[item.prop] }}</div>
  60. </template>
  61. </el-table-column>
  62. <el-table-column label="操作" align="center" width="100">
  63. <template slot-scope="scope">
  64. <el-button type="text" size="mini" @click="handleUpdate(scope.row)">修改</el-button>
  65. <el-button type="text" size="mini" @click="showDetail(scope.row)">详情</el-button>
  66. </template>
  67. </el-table-column>
  68. </el-table>
  69. <el-pagination
  70. :current-page="searchForm.page"
  71. :page-size="searchForm.limit"
  72. :total="records"
  73. style="margin-top: 10px;"
  74. background
  75. layout="total, sizes, prev, pager, next, jumper"
  76. @current-change="handleCurrentChange"
  77. @size-change="handleSizeChange"
  78. />
  79. <TableFieldCfg
  80. ref="TableFieldCfg"
  81. :default-column-defs="fieldDefs"
  82. @success="getTableListFieldDefs"
  83. />
  84. </div>
  85. </template>
  86. <script>
  87. import { apiQueryChargerGroupList } from '@/api/deviceCfg'
  88. import TableFieldCfg from '@/common/components/TableFieldCfg'
  89. import LazyTree from '@/components/LazyTree'
  90. import tableFields from '@/common/components/TableFieldCfg/index.mixin.js'
  91. export default {
  92. name: 'ChargingStation',
  93. components: {
  94. TableFieldCfg,
  95. LazyTree
  96. },
  97. mixins: [tableFields],
  98. data() {
  99. return {
  100. loading: false,
  101. records: 0,
  102. searchForm: {
  103. is_all_level: 1,
  104. page: 1,
  105. limit: 10
  106. },
  107. tableData: [],
  108. fieldDefs: [
  109. { label: '充电站名称', prop: 'group_name', align: 'center', minWidth: 150 },
  110. { label: '所在城市', prop: 'cityname', align: 'center' },
  111. { label: '充电站地址', prop: 'address', align: 'center', minWidth: 200 },
  112. { label: '订单量', prop: 'order_count', align: 'center' },
  113. { label: '联系人', prop: 'contacts', align: 'center' },
  114. { label: '状态', prop: 'status', align: 'center' }
  115. ]
  116. }
  117. },
  118. beforeRouteEnter(to, from, next) {
  119. next(vm => {
  120. if (to.meta.refresh) {
  121. vm.queryList()
  122. }
  123. })
  124. },
  125. created() {
  126. const { refresh } = this.$route.meta
  127. !refresh && this.queryList()
  128. },
  129. methods: {
  130. selectGroup(group) {
  131. this.searchForm.admin_id = group.shop_id
  132. },
  133. handleAdd() {
  134. this.$router.push({ path: '/add-chargingStation' })
  135. },
  136. handleUpdate(row) {
  137. this.$router.push({ path: `/edit-chargingStation?id=${row.group_id}` })
  138. },
  139. handleCurrentChange(val = 1) {
  140. this.searchForm.page = val
  141. this.queryList()
  142. },
  143. handleSizeChange(val) {
  144. this.searchForm.limit = val
  145. this.queryList()
  146. },
  147. queryList() {
  148. this.loading = true
  149. apiQueryChargerGroupList(this.searchForm).then(res => {
  150. const { data, code } = res.data
  151. this.loading = false
  152. if (code === 200) {
  153. this.tableData = data.list
  154. this.records = +data.total
  155. }
  156. }).catch(() => {
  157. this.loading = false
  158. })
  159. },
  160. showDetail(row) {
  161. this.$router.push(`/chargingStationDetail?id=${row.group_id}`)
  162. }
  163. }
  164. }
  165. </script>