index.vue 8.9 KB

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