index.vue 8.6 KB

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