index.vue 7.1 KB

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