index.vue 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276
  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>
  8. <el-form-item prop="name" style="width: 100%;">
  9. <el-col :xs="24" :sm="12" :md="8" :lg="6" :xl="6" class="mb20">
  10. <el-form-item label="加油站名称">
  11. <el-input v-model="state.filter.stationName" placeholder="请输入加油站名称" clearable></el-input>
  12. </el-form-item>
  13. </el-col>
  14. <el-col :xs="24" :sm="12" :md="8" :lg="6" :xl="4" class="mb20">
  15. <el-form-item label="石油公司">
  16. <el-input v-model="state.filter.OilCompanyName" placeholder="请输入石油公司" clearable></el-input>
  17. </el-form-item>
  18. </el-col>
  19. <el-col :xs="24" :sm="12" :md="8" :lg="6" :xl="4" class="mb20">
  20. <el-form-item label="序列号">
  21. <el-input v-model="state.filter.SerialNumber" placeholder="请输入序列号" clearable></el-input>
  22. </el-form-item>
  23. </el-col>
  24. <!-- <el-col :xs="24" :sm="12" :md="8" :lg="6" :xl="4" class="mb20">
  25. <el-form-item label="绑定加油机厂商">
  26. <el-input v-model="state.filter.BindingDispenserManufacturer" placeholder="单行输入" clearable></el-input>
  27. </el-form-item>
  28. </el-col> -->
  29. <el-col :xs="24" :sm="12" :md="8" :lg="6" :xl="4" class="mb20">
  30. <el-form-item label="安全装置状态">
  31. <el-select v-model="state.filter.DeviceStatus" placeholder="请输入在线状态">
  32. <el-option label="所有" :value="''"></el-option>
  33. <el-option v-for="(value, key) in FuelDispenserEnum" :key="key" :label="value" :value="key" />
  34. </el-select>
  35. </el-form-item>
  36. </el-col>
  37. <el-col :xs="24" :sm="12" :md="8" :lg="6" :xl="4" class="mb20">
  38. <el-form-item label="选择安装时间">
  39. <el-date-picker
  40. v-model="state.filter.FixTime"
  41. type="datetimerange"
  42. value-format="YYYY-MM-DD HH:mm:ss"
  43. range-separator="To"
  44. start-placeholder="开始日期"
  45. end-placeholder="结束日期"
  46. />
  47. </el-form-item>
  48. </el-col>
  49. <!-- <el-col :xs="24" :sm="12" :md="8" :lg="6" :xl="4" class="mb20">
  50. <el-form-item label="选择时间">
  51. <el-date-picker
  52. v-model="state.filter.SoldTime"
  53. type="datetimerange"
  54. value-format="YYYY-MM-DD HH:mm:ss"
  55. range-separator="To"
  56. start-placeholder="Start date"
  57. end-placeholder="End date"
  58. />
  59. </el-form-item>
  60. </el-col> -->
  61. </el-form-item>
  62. </el-form>
  63. <hr class="fenge">
  64. <div class="my-flex my-flex-start" >
  65. <!-- 按钮 -->
  66. <el-row justify="space-between" class="submit-button" style="margin-bottom:-6px">
  67. <el-row>
  68. <el-button type="primary" icon="ele-Search" @click="onQuery"> 查询 </el-button>
  69. <el-button type="primary" icon="ele-RefreshRight" @click="resetQuery"> 重置 </el-button>
  70. </el-row>
  71. </el-row>
  72. </div>
  73. </el-card>
  74. </el-col>
  75. <!--表格-->
  76. <el-col :xs="24" >
  77. <el-card style="height: 70vh" class="my-fill mt8" shadow="hover">
  78. <el-table v-loading="state.loading" stripe :data="state.tableModel" row-key="id" style="width: 100%">
  79. <el-table-column v-for="column in state.dynamicColumns" :key="column.prop" :prop="column.prop" :label="column.label" >
  80. <template #default="{ row }">
  81. <template v-if="column.prop === 'deviceStatus'">
  82. <StatusBox :status="row.deviceStatus" />
  83. </template>
  84. <template v-else>
  85. {{ row[column.prop] }}
  86. </template>
  87. </template>
  88. </el-table-column>
  89. </el-table>
  90. <div class="my-flex my-flex-end" style="margin-top: 20px">
  91. <el-pagination
  92. v-model:currentPage="pageState.pageInput.currentPage"
  93. v-model:page-size="pageState.pageInput.pageSize"
  94. :total="state.total"
  95. :page-sizes="[10, 15, 20, 50, 100]"
  96. small
  97. background
  98. @size-change="onSizeChange"
  99. @current-change="onCurrentChange"
  100. layout="total, sizes, prev, pager, next, jumper"
  101. />
  102. </div>
  103. </el-card>
  104. </el-col>
  105. </el-row>
  106. </div>
  107. </template>
  108. <script setup lang="ts">
  109. import {onBeforeMount, onMounted, reactive, ref, watch} from "vue";
  110. import eventBus from "/@/utils/mitt";
  111. import { PageInput,BlackBoxDto } from "/@/api/admin/reportManagement/BlackBox/BlackBoxdto";
  112. import {Api} from "/@/api/admin/reportManagement/BlackBox/BlackBoxapi";
  113. import StatusBox from "/@/components/StatusBox.vue";
  114. import { useDynamicPageSize } from "/@/composables/useDynamicPageSize";
  115. // 使用组合式函数获取分页状态
  116. const pageState = useDynamicPageSize(10, 15);
  117. // 在 script setup 的顶部定义枚举
  118. const FuelDispenserEnum = {
  119. unregister: '未备案',
  120. produce: '已生产',
  121. register: '已备案',
  122. bind: '已绑定油机',
  123. factory: '已出厂注册',
  124. enable: '已启用',
  125. disable: '维修中'
  126. } as const; // 使用 as const 确保类型安全
  127. /**数据对象*/
  128. const state = reactive({
  129. /**加载显示 */
  130. loading: false,
  131. /**条件查询模块 */
  132. filter: {
  133. /**石油公司 */
  134. OilCompanyName: "",
  135. /**序列号 */
  136. SerialNumber: "",
  137. /**绑定加油机厂商 */
  138. BindingDispenserManufacturer: "",
  139. /**安全装置状态 */
  140. DeviceStatus: "",
  141. /**安装时间 */
  142. FixTime: "",
  143. // 加油站名称
  144. stationName:"",
  145. /**出厂时间 */
  146. SoldTime: "",},
  147. /**表格信息 */
  148. tableModel: [] as BlackBoxDto,
  149. /**动态表头 */
  150. dynamicColumns: [
  151. { prop: 'stationName', label: '加油站名称' },
  152. { prop: 'oilCompanyName', label: '石油公司' },
  153. { prop: 'softwareVersion', label: '软件版本号' },
  154. { prop: 'hardwareVersion', label: '硬件版本号' },
  155. { prop: 'serialNumber', label: '序列号' },
  156. { prop: 'safetyDeviceManufacturer', label: '安全装置厂家' },
  157. { prop: 'dispenserNumber', label: '油机号' },
  158. { prop: 'nozzleNumber', label: '油枪号' },
  159. { prop: 'deviceStatus', label: '安全装置状态' },
  160. { prop: 'fixTime', label: '安装时间' },
  161. { prop: 'soldTime', label: '出厂时间' },
  162. { prop: 'bindingDispenserManufacturer', label: '绑定加油机厂商' },
  163. { prop: 'componentManufacturer', label: '部件出厂加油机厂商' },],
  164. /**分页标识 */
  165. pageInput:{
  166. currentPage: 1,
  167. pageSize: 10,
  168. } as PageInput,
  169. /**分页总数 */
  170. total: 0,
  171. })
  172. onMounted(() => {
  173. // 初始化分页大小
  174. state.pageInput.pageSize = pageState.pageInput.pageSize;
  175. init()
  176. eventBus.off('refreshView')
  177. eventBus.on('refreshView', async () => {
  178. await init()
  179. })
  180. console.log()
  181. })
  182. onBeforeMount(() => {
  183. eventBus.off('refreshView')
  184. })
  185. /**
  186. * 监听变换
  187. */
  188. watch(() => {})
  189. /**条件查询 */
  190. const onQuery = () => {
  191. init()
  192. }
  193. const init = async () => {
  194. state.loading = true;
  195. try {
  196. const res: any = await new Api().getList({
  197. ...state.pageInput, // 使用 state.pageInput 中的分页参数
  198. Filter: state.filter,
  199. });
  200. state.total = res?.data?.total ?? 0;
  201. state.tableModel = res?.data?.list ?? [];
  202. } catch (error) {
  203. console.error("数据加载失败:", error);
  204. } finally {
  205. state.loading = false;
  206. }
  207. };
  208. /**重置查询条件 */
  209. const resetQuery = () => {
  210. state.filter.OilCompanyName = ''
  211. state.filter.SerialNumber = ''
  212. state.filter.BindingDispenserManufacturer = ''
  213. state.filter.DeviceStatus = ''
  214. state.filter.FixTime = ''
  215. state.filter.stationName=''
  216. // state.filter.createTimeRange = null
  217. // 重置分页参数
  218. state.pageInput.currentPage = 1; // 回到第一页
  219. state.pageInput.pageSize = 10; // 恢复默认每页显示条数
  220. // 重新加载数据
  221. init();
  222. }
  223. /** 分页大小变化 */
  224. const onSizeChange = (size: number) => {
  225. state.pageInput.pageSize = size; // 更新每页显示条数
  226. state.pageInput.currentPage = 1; // 切换分页大小时回到第一页
  227. init(); // 重新加载数据
  228. };
  229. /** 当前页码变化 */
  230. const onCurrentChange = (page: number) => {
  231. state.pageInput.currentPage = page; // 更新当前页码
  232. init(); // 重新加载数据
  233. };
  234. </script>
  235. <style scoped lang="scss">
  236. .el-input,
  237. .el-select,
  238. {
  239. width: 240px;
  240. }
  241. .el-date-picker {
  242. width: 240px !important;
  243. }
  244. /* 输入框标签固定四个字符宽度 */
  245. ::v-deep .el-form-item__label {
  246. // 字体大小14,5个字符,12px右间距
  247. width: 14*6px+12px;
  248. justify-content: start;
  249. }
  250. /* 数据表头 设置灰色样式 */
  251. ::v-deep .el-table th.el-table__cell {
  252. background-color: #F6F6F6;
  253. }
  254. .fenge{
  255. margin-top:-35px
  256. }
  257. </style>