index.vue 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287
  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. <ext-d-select
  30. type="Connector.status"
  31. v-model="state.formQuery.status"
  32. placeholder="状态"
  33. clearable
  34. @change="loadData(true)"
  35. class="wd150 mr10"/>
  36. <ext-select
  37. v-model="state.formQuery.stationId"
  38. placeholder="站点"
  39. clearable
  40. url="station/listStation"
  41. urlMethod="get"
  42. label-key="stationName"
  43. value-key="stationId"
  44. @on-change="loadData(true)"
  45. class="wd150 mr10">
  46. </ext-select>
  47. <el-input
  48. v-model="state.formQuery.equipmentId"
  49. placeholder="充电桩编号/序列号"
  50. clearable
  51. @change="loadData(true)"
  52. class="wd150 mr10">
  53. </el-input>
  54. <el-button class="ml10" plain size="default" type="success" @click="loadData(true)">
  55. <SvgIcon name="ele-Search"/>
  56. 查询
  57. </el-button>
  58. </el-form>
  59. <el-table
  60. border
  61. stripe="stripe"
  62. :height="state.tableData.height"
  63. highlight-current-row
  64. current-row-key="id"
  65. row-key="id"
  66. :data="state.tableData.data"
  67. v-loading="state.tableData.loading"
  68. @selection-change="handleTableSelectionChange"
  69. @sort-change="handleTableSortChange">
  70. <template #empty>
  71. <el-empty></el-empty>
  72. </template>
  73. <el-table-column
  74. v-for="field in state.tableData.columns"
  75. :key="field.prop"
  76. :label="field.label"
  77. :column-key="field.prop"
  78. :width="field.width"
  79. :min-width="field.minWidth"
  80. :fixed="field.fixed"
  81. :sortable="field.sortable"
  82. :show-overflow-tooltip="!field.fixed&&field.width>150"
  83. >
  84. <template #default="{row}">
  85. <template v-if="field.prop==='expand'">
  86. <p style="padding-left: 2em;" v-html="row[field.prop]"></p>
  87. </template>
  88. <template v-else-if="'equipmentType'===field.prop">
  89. <ext-d-label type="Equipment.type" v-model="row[field.prop]"/>
  90. </template>
  91. <template v-else-if="'status'===field.prop">
  92. <ext-d-label type="Connector.status" v-model="row[field.prop]"/>
  93. </template>
  94. <!-- <template v-else-if="'netStatus'===field.prop">-->
  95. <!-- <ext-d-label type="Equipment.netStatus" v-model="row[field.prop]"/>-->
  96. <!-- </template>-->
  97. <template v-else-if="'equipmentId'===field.prop">
  98. <el-button link type="primary" @click="handleGotoOrder(row)">{{row[field.prop]}} </el-button>
  99. </template>
  100. <template v-else-if="'shortId'===field.prop">
  101. <el-button link type="primary" @click="handleGotoOrder(row)">{{row[field.prop]}} </el-button>
  102. </template>
  103. <template v-else>
  104. <div>{{ row[field.prop] }}</div>
  105. </template>
  106. </template>
  107. </el-table-column>
  108. </el-table>
  109. <ext-page class="page-pager" v-model:value="state.pageQuery" @change="loadData(false)"/>
  110. </el-card>
  111. </div>
  112. <!-- <EquipmentInfoDialog ref="equipmentInfoDialogRef" @refresh="loadData(true)"/>-->
  113. </template>
  114. <script setup lang="ts" name="EquipmentInfoList">
  115. import {defineAsyncComponent, reactive, onMounted, onBeforeMount, ref, getCurrentInstance, nextTick, onBeforeUnmount} from 'vue';
  116. import {$body, $get} from "/@/utils/request";
  117. import {Msg} from "/@/utils/message";
  118. import {useRoute} from "vue-router";
  119. const route = useRoute();
  120. import ExtPage from '/@/components/form/ExtPage.vue'
  121. import mittBus from '/@/utils/mitt';
  122. import ExtDLabel from "/@/components/form/ExtDLabel.vue";
  123. import ExtDSelect from "/@/components/form/ExtDSelect.vue";
  124. import ExtSelect from "/@/components/form/ExtSelect.vue";
  125. import {useRouter} from "vue-router";
  126. const router = useRouter();
  127. // const EquipmentInfoDialog = defineAsyncComponent(() => import("/@/views/page/EquipmentInfoDialog.vue"));
  128. //定义引用
  129. const queryRef = ref();
  130. const equipmentInfoDialogRef = ref();
  131. //定义变量
  132. const state = reactive({
  133. formQuery: {
  134. stationId: ''
  135. },
  136. pageQuery: {
  137. pageNum: 1,
  138. pageSize: 10,
  139. total: 0
  140. },
  141. tableData: {
  142. height: 500,
  143. data: [] as Array<any>,
  144. loading: false,
  145. columns: [
  146. {label: '站点ID', prop: 'stationId', resizable: true, width: 100, fixed: 'left'},
  147. {label: '站点编号', prop: 'stationNo', resizable: true, width: 100, fixed: 'left'},
  148. {label: '站点名称', prop: 'stationName', resizable: true, width: 200, fixed: 'left'},
  149. {label: '充电桩编号', prop: 'shortId', resizable: true, width: 110, fixed: 'left'},
  150. {label: '车位编号', prop: 'parkingNo', resizable: true, width: 90, fixed: 'left'},
  151. {label: '充电桩序列号', prop: 'equipmentId', width: 180, resizable: true},
  152. {label: '充电桩接口编号', prop: 'connectorId', width: 180, resizable: true},
  153. // {label: '设备型号', prop: 'equipmentModel', width: 150, resizable: true},
  154. // {label: '服务状态', prop: 'status', resizable: true, width: 130},
  155. // {label: '设备类型', prop: 'equipmentType', resizable: true, width: 130},
  156. // {label: '位置坐标', prop: 'location', resizable: true, width: 150},
  157. // {label: '网络状态', prop: 'netStatus', resizable: true, width: 130},
  158. {label: '状态', prop: 'status', resizable: true, width: 130},
  159. // {label: '设备生产商组织机构代码', prop: 'manufacturerId', width: 200, resizable: true},
  160. // {label: '设备生产商名称', prop: 'manufacturerName', width: 160, resizable: true},
  161. // {label: '设备生产日期', prop: 'productionDate', width: 160, resizable: true},
  162. {label: '更新时间', prop: 'updateTime', sortable: 'custom', resizable: true, width: 180},
  163. /*{
  164. label: '操作', prop: 'action', width: 1, align: 'center', fixed: 'right',
  165. }*/
  166. ],
  167. },
  168. })
  169. // 监听双向绑定 modelValue 的变化
  170. // watch(
  171. // () => state.pageIndex,
  172. // () => {
  173. //
  174. // }
  175. // );
  176. //生命周期钩子
  177. onBeforeMount(() => {
  178. })
  179. onMounted(() => {
  180. var params = route.params;
  181. console.log(route.params, route.query)
  182. let {id} = route.params;
  183. if (!isNaN(Number(id))) {
  184. state.formQuery.stationId = id;
  185. }
  186. loadData();
  187. nextTick(() => {
  188. let bodyHeight = document.body.clientHeight;
  189. let queryHeight = queryRef.value.$el.clientHeight;
  190. state.tableData.height = bodyHeight - queryHeight - 320
  191. })
  192. mittBus.on("equipmentInfo.refresh", () => {
  193. loadData();
  194. })
  195. });
  196. onBeforeUnmount(() => {
  197. mittBus.off("equipmentInfo.refresh")
  198. })
  199. //region 方法区
  200. const handleGotoOrder =(row:any)=>{
  201. router.push(`/ordering?connectorId=${row.equipmentId}`)
  202. }
  203. // 初始化表格数据
  204. const loadData = (refresh: boolean = false) => {
  205. if (refresh) {
  206. state.pageQuery.pageNum = 1;
  207. }
  208. state.tableData.loading = true;
  209. $get(`/connector/listConnectors`, {...state.formQuery, ...state.pageQuery}).then((res: any) => {
  210. let {list, total} = res;
  211. state.tableData.data = list;
  212. state.pageQuery.total = total;
  213. state.tableData.loading = false;
  214. }).catch(e => {
  215. console.error(e)
  216. state.tableData.loading = false;
  217. })
  218. };
  219. // 打开修改用户弹窗
  220. const onRowClick = (type: string, row: any) => {
  221. equipmentInfoDialogRef.value.open(type, row);
  222. };
  223. // 删除用户
  224. const onRowDel = (row: any) => {
  225. Msg.confirm(`此操作将永久删除:『${row.name}』,是否继续?`).then(() => {
  226. $get(`/equipmentInfo/delete/${row.id}`).then(() => {
  227. Msg.message("删除成功", 'success')
  228. }).catch(() => {
  229. Msg.message("删除失败", 'error')
  230. })
  231. });
  232. };
  233. const handleTableSelectionChange = (selection: any) => {
  234. console.log("handleTableSelectionChange>>", selection)
  235. // emit("on-check-change", selection)
  236. }
  237. const handleTableSortChange = (column, prop, order) => {
  238. console.log("handleTableSortChange>>", column, prop, order)
  239. // emit("on-sort-change", column)
  240. }
  241. //endregion
  242. // 暴露变量
  243. // defineExpose({
  244. // loadData,
  245. // });
  246. </script>