index.vue 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284
  1. <template>
  2. <div class="layout-pd">
  3. <el-row>
  4. <!--操作-->
  5. <el-col :xs="24" >
  6. <el-card class="mt8" shadow="hover" >
  7. <el-form :model="state.filter" :inline="true" @submit.stop.prevent style="margin-bottom: -3vh;">
  8. <el-form-item prop="name" style="width: 100%">
  9. <el-col :xs="24" :sm="12" :md="8" :lg="8" :xl="6" class="mb20">
  10. <el-form-item label="石油公司">
  11. <el-input v-model="state.filter.oilCompanyName" placeholder="请输入石油公司" clearable></el-input>
  12. </el-form-item>
  13. </el-col>
  14. <el-col :xs="24" :sm="12" :md="8" :lg="8" :xl="6" class="mb20">
  15. <el-form-item label="站点名称">
  16. <el-input v-model="state.filter.stationName" placeholder="请输入站点名称" clearable></el-input>
  17. </el-form-item>
  18. </el-col>
  19. <el-col :xs="24" :sm="12" :md="8" :lg="8" :xl="6" class="mb20">
  20. <el-form-item label="计控主板状态">
  21. <el-select v-model="state.filter.deviceStatus" placeholder="请选择计控主板状态">
  22. <el-option v-for="option in deviceStatusList" :key="option.value" :label="option.label" :value="option.value"></el-option>
  23. </el-select>
  24. </el-form-item>
  25. </el-col>
  26. <el-col :xs="24" :sm="12" :md="8" :lg="8" :xl="6" class="mb20">
  27. <el-form-item label="在线状态">
  28. <el-select v-model="state.filter.onlineStatus" placeholder="请选择在线状态">
  29. <el-option v-for="option in onlineStatusList" :key="option.value" :label="option.label" :value="option.value"></el-option>
  30. </el-select>
  31. </el-form-item>
  32. </el-col>
  33. <el-col :xs="24" :sm="12" :md="8" :lg="8" :xl="6" class="mb20">
  34. <el-form-item label="选择安装时间">
  35. <el-date-picker
  36. v-model="state.time"
  37. type="datetimerange"
  38. value-format="YYYY-MM-DD HH:mm:ss"
  39. range-separator="To"
  40. start-placeholder="开始日期"
  41. end-placeholder="结束日期"
  42. />
  43. </el-form-item>
  44. </el-col>
  45. </el-form-item>
  46. </el-form>
  47. <hr>
  48. <el-row class="submit-button" style="margin-bottom: -1vh;">
  49. <el-button type="primary" icon="ele-Search" @click="onQuery"> 查询 </el-button>
  50. <el-button type="primary" icon="ele-RefreshRight" @click="onReset"> 重置 </el-button>
  51. </el-row>
  52. </el-card>
  53. </el-col>
  54. <!--表格-->
  55. <el-col :xs="24" >
  56. <el-card style="height: 70vh" class="my-fill mt8" shadow="hover">
  57. <el-table v-loading="state.loading" stripe :data="state.tableModel" row-key="id" style="width: 100%">
  58. <el-table-column
  59. v-for="column in state.dynamicColumns"
  60. :key="column.prop"
  61. :prop="column.prop"
  62. :label="column.label">
  63. <template #default="{ row }">
  64. <template v-if="column.prop === 'onlineStatus'">
  65. <StatusBox :status="row.onlineStatus" />
  66. </template>
  67. <template v-else-if="column.prop === 'deviceStatus'">
  68. <StatusBox :status="row.deviceStatus" />
  69. </template>
  70. <template v-else>
  71. {{ row[column.prop] }}
  72. </template>
  73. </template>
  74. </el-table-column>
  75. <el-table-column label="操作" fixed="right" header-align="center" align="center" class="right-operation" width="140">
  76. <template #default="{ row }" >
  77. <el-link
  78. class="my-el-link mr12 ml12"
  79. type="primary"
  80. icon="ele-Upload"
  81. @click="toPage(row)"
  82. :underline="false"
  83. target="_blank"
  84. >油机详情</el-link>
  85. </template>
  86. </el-table-column>
  87. </el-table>
  88. <div class="my-flex my-flex-end" style="margin-top: 20px">
  89. <el-pagination
  90. v-model:currentPage="pageState.pageInput.currentPage"
  91. v-model:page-size="pageState.pageInput.pageSize"
  92. :total="state.total"
  93. :page-sizes="[10, 15, 20, 50, 100]"
  94. small
  95. background
  96. @size-change="onSizeChange"
  97. @current-change="onCurrentChange"
  98. layout="total, sizes, prev, pager, next, jumper"
  99. />
  100. </div>
  101. </el-card>
  102. </el-col>
  103. </el-row>
  104. </div>
  105. </template>
  106. <script setup lang="ts">
  107. import {onBeforeMount, onMounted, reactive, ref, watch} from "vue";
  108. import eventBus from "/@/utils/mitt";
  109. import {Api} from "/@/api/admin/PCBA/jikongzhuban";
  110. import { EncodercontrolsDto } from "/@/api/admin/PCBA/jikongzhubanDto";
  111. import type { FilterType, pageInput } from "/@/api/admin/PCBA/jikongzhubanDto";
  112. import { useDynamicPageSize } from "/@/composables/useDynamicPageSize";
  113. import StatusBox from "/@/components/StatusBox.vue";
  114. import router from "/@/router";
  115. // 使用组合式函数获取分页状态
  116. const pageState = useDynamicPageSize(10, 15);
  117. /**数据对象*/
  118. const state = reactive({
  119. time:[] as string[],
  120. /**加载显示 */
  121. loading: false,
  122. /**条件查询模块 */
  123. filter: {
  124. /**石油公司 */
  125. oilCompanyName: "",
  126. /**站点名称 */
  127. stationName: "",
  128. /**状态 */
  129. deviceStatus: "",
  130. /**在线状态 */
  131. onlineStatus: "",
  132. /**安装时间 */
  133. edate: null,
  134. sdate: null
  135. } as unknown as FilterType,
  136. /**表格信息 */
  137. tableModel: [] as EncodercontrolsDto,
  138. /**动态表头 */
  139. dynamicColumns: [
  140. { prop: 'oilCompanyName', label: '石油公司' },
  141. { prop: 'stationName', label: '加油站名称' },
  142. { prop: 'serialNumber', label: '序列号' },
  143. { prop: 'softwareVersion', label: '软件版本号' },
  144. { prop: 'hardwareVersion', label: '硬件版本号' },
  145. { prop: 'deviceStatus', label: '计控主板状态' },
  146. { prop: 'onlineStatus', label: '在线状态' },
  147. { prop: 'fixTime', label: '安装时间' },
  148. { prop: 'soldTime', label: '出厂时间' },
  149. { prop: 'bindingDispenserManufacturer', label: '绑定加油机厂商' },
  150. ],
  151. /**分页标识 */
  152. pageInput:{
  153. CurrentPage: 1,
  154. PageSize: 10,
  155. } as pageInput,
  156. /**分页总数 */
  157. total: 0,
  158. })
  159. const onlineStatusList = [
  160. {label:'所有', value:''},
  161. {label:'在线', value:"online"},
  162. {label:'离线', value: 'offline'},
  163. ]
  164. const deviceStatusList = [
  165. {label:'所有', value:''},
  166. {label:'启用', value:'启动'},
  167. {label:'已注册', value:'已注册'},
  168. {label:'未知', value:'未知'},
  169. {label:'禁用', value:'禁用'},
  170. ]
  171. onMounted(() => {
  172. state.pageInput.PageSize = pageState.pageInput.pageSize
  173. init()
  174. eventBus.off('refreshView')
  175. eventBus.on('refreshView', async () => {
  176. await init()
  177. })
  178. console.log()
  179. })
  180. onBeforeMount(() => {
  181. eventBus.off('refreshView')
  182. })
  183. /**
  184. * 监听变换
  185. */
  186. watch(() => state.time, (newVal) => {
  187. if (newVal && newVal.length === 2) {
  188. state.filter.sdate = newVal[0];
  189. state.filter.edate = newVal[1];
  190. } else {
  191. state.filter.sdate = null;
  192. state.filter.edate = null;
  193. }
  194. })
  195. /**条件查询 */
  196. const onQuery = () => {
  197. init()
  198. }
  199. /**初始化 */
  200. const init = async () => {
  201. state.loading = true;
  202. console.log('发送的过滤条件:', {
  203. ...pageState.pageInput,
  204. Filter: {
  205. ...state.filter,
  206. }
  207. });
  208. const res = await new Api().getList({
  209. ...pageState.pageInput,
  210. Filter: state.filter
  211. });
  212. state.tableModel = res?.data?.list ?? [];
  213. state.total = res?.data?.total ?? 0;
  214. state.loading = false;
  215. }
  216. /**详情 */
  217. const toPage = (row: { fuelId: any; }) => {
  218. router.push({ path: `/statement/${row.fuelId}` })
  219. }
  220. /**
  221. * 页条变化
  222. * @param val
  223. */
  224. const onSizeChange = (val: number) => {
  225. state.pageInput.PageSize = val
  226. onQuery()
  227. }
  228. /**
  229. * 页数变化
  230. * @param val
  231. */
  232. const onCurrentChange = (val: number) => {
  233. state.pageInput.CurrentPage = val
  234. onQuery()
  235. }
  236. const onReset = () => {
  237. state.time = [],
  238. state.filter = {
  239. stationName: '',
  240. oilCompanyName: '',
  241. deviceStatus: '',
  242. onlineStatus: '',
  243. sdate: null,
  244. edate: null,
  245. }
  246. init()
  247. }
  248. </script>
  249. <style scoped lang="scss">
  250. .el-input,
  251. .el-select {
  252. width: 240px;
  253. }
  254. /* 输入框标签固定四个字符宽度 */
  255. ::v-deep .el-form-item__label {
  256. // 字体大小14,4个字符,12px右间距
  257. width: 14*6px+12px;
  258. justify-content: start;
  259. }
  260. /* 数据表头 设置灰色样式 */
  261. ::v-deep .el-table th.el-table__cell {
  262. background-color: #F6F6F6;
  263. }
  264. </style>