index.vue 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  1. <style scoped lang="scss">
  2. .system-container {
  3. :deep(.el-card__body) {
  4. display: flex;
  5. flex-direction: column;
  6. justify-content: space-between;
  7. flex: 1;
  8. overflow: auto;
  9. .el-table {
  10. flex: 1;
  11. }
  12. }
  13. }
  14. .page-content {
  15. margin-bottom: 20px;
  16. }
  17. .page-pager {
  18. background-color: #fff;
  19. height: 24px;
  20. }
  21. </style>
  22. <template>
  23. <div class="system-container layout-padding">
  24. <el-card shadow="hover" class="layout-padding-auto">
  25. <el-form
  26. :model="state.formQuery"
  27. ref="queryRef"
  28. size="default" label-width="0px" class="mt5 mb5">
  29. <el-input
  30. v-model="state.formQuery.stationName"
  31. placeholder="站点名称"
  32. clearable
  33. @blur="loadData(true)"
  34. class="wd150 mr10">
  35. </el-input>
  36. <el-button class="ml10" plain size="default" type="success" @click="loadData(true)">
  37. <SvgIcon name="ele-Search"/>
  38. 查询
  39. </el-button>
  40. </el-form>
  41. <el-card class="w100">
  42. <div class="order-summary">
  43. <span class="ml5">电量:</span>
  44. <el-tag type="success">{{state.extraData.totalPower}}Kwh</el-tag>
  45. <span class="ml5">实付服务费:</span>
  46. <el-tag type="success">{{u.fmt.fmtMoney(state.extraData.serviceMoney)}}元</el-tag>
  47. </div>
  48. </el-card>
  49. <el-table
  50. border
  51. stripe="stripe"
  52. :height="state.tableData.height"
  53. highlight-current-row
  54. current-row-key="id"
  55. row-key="id"
  56. :data="state.tableData.data"
  57. v-loading="state.tableData.loading"
  58. @selection-change="handleTableSelectionChange"
  59. @sort-change="handleTableSortChange">
  60. <template #empty>
  61. <el-empty></el-empty>
  62. </template>
  63. <el-table-column
  64. v-for="field in state.tableData.columns"
  65. :key="field.prop"
  66. :label="field.label"
  67. :column-key="field.prop"
  68. :width="field.width"
  69. :min-width="field.minWidth"
  70. :fixed="field.fixed"
  71. :sortable="field.sortable"
  72. :show-overflow-tooltip="!field.fixed&&field.width>150"
  73. >
  74. <template #default="{row}">
  75. <template v-if="field.prop==='expand'">
  76. <p style="padding-left: 2em;" v-html="row[field.prop]"></p>
  77. </template>
  78. <template v-else-if="'stationType'===field.prop">
  79. <ext-d-label type="Station.type" v-model="row[field.prop]"/>
  80. </template>
  81. <template v-else-if="'stationStatus'===field.prop">
  82. <ext-d-label type="Station.status" v-model="row[field.prop]"/>
  83. </template>
  84. <template v-else-if="'construction'===field.prop">
  85. <ext-d-label type="Station.construction" v-model="row[field.prop]"/>
  86. </template>
  87. <template v-else-if="'action'===field.prop">
  88. <el-button link type="primary" @click="handleGotoEndpoint(row)">查看电桩</el-button>
  89. </template>
  90. <template v-else>
  91. <div>{{row[field.prop]}}</div>
  92. </template>
  93. </template>
  94. </el-table-column>
  95. </el-table>
  96. <!-- <ext-page class="page-pager" v-model:value="state.pageQuery" @change="loadData(false)"/>-->
  97. </el-card>
  98. </div>
  99. <!-- <StationDialog ref="stationDialogRef" @refresh="loadData(true)"/>-->
  100. </template>
  101. <script setup lang="ts" name="StationList">
  102. import {defineAsyncComponent, reactive, onMounted, onBeforeMount, ref, getCurrentInstance, nextTick, onBeforeUnmount} from 'vue';
  103. import {$body,$get} from "/@/utils/request";
  104. import {Msg} from "/@/utils/message";
  105. import u from "/@/utils/u"
  106. import ExtPage from '/@/components/form/ExtPage.vue'
  107. import mittBus from '/@/utils/mitt';
  108. import ExtDLabel from "/@/components/form/ExtDLabel.vue";
  109. import {useRouter} from "vue-router";
  110. const router = useRouter();
  111. // const StationDialog = defineAsyncComponent(() => import("/@/views/page/StationDialog.vue"));
  112. //定义引用
  113. const queryRef = ref();
  114. const stationDialogRef = ref();
  115. //定义变量
  116. const state = reactive({
  117. formQuery: {},
  118. pageQuery: {
  119. pageNum: 1,
  120. pageSize: 10,
  121. total: 0
  122. },
  123. tableData: {
  124. height: 500,
  125. data: [] as Array < any >,
  126. loading: false,
  127. columns: [
  128. {label: 'en+充电站id', prop: 'stationId',width:160, resizable: true,fixed:'left'},
  129. // {label: 'en+运营商id', prop: 'operatorId', resizable: true},
  130. {label: '所属运营平台', prop: 'equipmentOwnerId', width:160,resizable: true,fixed:'left'},
  131. {label: '站点名称', prop: 'stationName',width:160, resizable: true},
  132. // {label: '充电中国家代码:CN', prop: 'countryCode', resizable: true},
  133. // {label: '充电站省市辖区编码', prop: 'areaCode', resizable: true},
  134. {label: '地址', prop: 'address',width:160, resizable: true},
  135. {label: '站点电话', prop: 'stationTel', width:120,resizable: true},
  136. {label: '服务电话', prop: 'serviceTel', width:140, resizable: true},
  137. {label: '站点类型', prop: 'stationType', width:120,resizable: true},
  138. {label: '站点状态', prop: 'stationStatus', width:120,resizable: true},
  139. {label: '充电车位数量', prop: 'parkingNum',width:160, resizable: true},
  140. // {label: '充电桩位置坐标', prop: 'location', resizable: true},
  141. // {label: '站点引导', prop: 'siteGuide', resizable: true},
  142. {label: '建设场所', prop: 'construction', width:160, resizable: true},
  143. {label: '使用车型描述', prop: 'matchCars', width:160,resizable: true},
  144. {label: '车位楼层及数量描述', prop: 'parkInfo',width:160, resizable: true},
  145. {label: '营业时间描述', prop: 'businessHours', width:160,resizable: true},
  146. {label: '充电费描述', prop: 'electricityFee', width:160, resizable: true},
  147. {label: '服务费率描述', prop: 'serviceFee', width:120,resizable: true},
  148. {label: '停车费', prop: 'parkFee', width:120, resizable: true},
  149. {label: '支付方式', prop: 'payment', width:120,resizable: true},
  150. {label: '是否支持预约', prop: 'supportOrder', width:120,resizable: true},
  151. {label: '备注', prop: 'remark', width:160,resizable: true},
  152. {
  153. label: '操作', prop: 'action', width: 180, align: 'center', fixed: 'right',
  154. }
  155. ],
  156. },
  157. extraData:{
  158. totalOrders:0,
  159. totalPower:0,
  160. elecMoney:0,
  161. serviceMoney:0,
  162. totalMoney:0,
  163. }
  164. })
  165. // 监听双向绑定 modelValue 的变化
  166. // watch(
  167. // () => state.pageIndex,
  168. // () => {
  169. //
  170. // }
  171. // );
  172. //生命周期钩子
  173. onBeforeMount(() => {
  174. })
  175. onMounted(() => {
  176. loadData();
  177. nextTick(() => {
  178. let bodyHeight = document.body.clientHeight;
  179. let queryHeight = queryRef.value.$el.clientHeight;
  180. state.tableData.height = bodyHeight - queryHeight - 220
  181. })
  182. mittBus.on("station.refresh", () => {
  183. loadData();
  184. })
  185. });
  186. onBeforeUnmount(() => {
  187. mittBus.off("station.refresh")
  188. })
  189. //region 方法区
  190. const handleGotoEndpoint = (row:any)=>{
  191. let {stationId} = row;
  192. if(!stationId){
  193. return;
  194. }
  195. router.push(`/station/endpoint/${stationId}`)
  196. }
  197. // 初始化表格数据
  198. const loadData = (refresh: boolean = false) => {
  199. if (refresh) {
  200. state.pageQuery.pageNum = 1;
  201. }
  202. state.tableData.loading = true;
  203. $get(`/station/listStation`, {...state.formQuery, ...state.pageQuery}).then((res: any) => {
  204. let list= res;
  205. state.tableData.data = list;
  206. // state.pageQuery.total = count;
  207. state.tableData.loading = false;
  208. }).catch(e => {
  209. console.error(e)
  210. state.tableData.loading = false;
  211. })
  212. };
  213. // 打开修改用户弹窗
  214. const onRowClick = (type: string, row: any) => {
  215. stationDialogRef.value.open(type, row);
  216. };
  217. // 删除用户
  218. const onRowDel = (row: any) => {
  219. Msg.confirm(`此操作将永久删除:『${row.name}』,是否继续?`).then(() => {
  220. $get(`/station/delete/${row.id}`).then(() => {
  221. Msg.message("删除成功", 'success')
  222. }).catch(() => {
  223. Msg.message("删除失败", 'error')
  224. })
  225. });
  226. };
  227. const handleTableSelectionChange = (selection: any) => {
  228. console.log("handleTableSelectionChange>>", selection)
  229. // emit("on-check-change", selection)
  230. }
  231. const handleTableSortChange = (column, prop, order) => {
  232. console.log("handleTableSortChange>>", column, prop, order)
  233. // emit("on-sort-change", column)
  234. }
  235. //endregion
  236. // 暴露变量
  237. // defineExpose({
  238. // loadData,
  239. // });
  240. </script>