index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360
  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="Data.Filter" @submit.stop.prevent>
  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="Data.Filter.CompanyName" 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="Data.Filter.name" 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-input v-model="Data.Filter.StationName" placeholder="请输入加油站名称" clearable></el-input>
  22. </el-form-item>
  23. </el-col>
  24. <el-col :xs="24" :sm="12" :md="8" :lg="8" :xl="6" class="mb20">
  25. <el-form-item label="在线状态">
  26. <el-select v-model="Data.Filter.onlineStatus" placeholder="请选择在线状态">
  27. <el-option v-for="(value, key) in selectList.Online" :key="key" :label="value" :value="value" />
  28. </el-select>
  29. </el-form-item>
  30. </el-col>
  31. <el-col :xs="24" :sm="12" :md="8" :lg="8" :xl="6" class="mb20">
  32. <el-form-item label="出厂时间">
  33. <el-date-picker v-model="Data.time1" type="datetimerange" value-format="YYYY-MM-DD HH:mm:ss"
  34. range-separator="To" start-placeholder="开始日期" end-placeholder="结束日期" />
  35. </el-form-item>
  36. </el-col>
  37. </el-form-item>
  38. </el-form>
  39. <hr>
  40. <!-- 按钮 -->
  41. <el-row justify="space-between" class="submit-button" style="margin-bottom:-6px">
  42. <el-row>
  43. <el-button type="primary" icon="ele-Search" @click="onQuery"> 查询 </el-button>
  44. <el-button type="primary" icon="ele-RefreshRight" @click="onReset"> 重置 </el-button>
  45. </el-row>
  46. </el-row>
  47. </el-card>
  48. </el-col>
  49. <!-- 表格区域 -->
  50. <el-col :xs="24">
  51. <el-card class="my-fill mt8" shadow="hover">
  52. <el-table
  53. ref="multipleTableRef"
  54. v-loading="Data.loading"
  55. stripe
  56. :data="Data.tableModel"
  57. row-key="id"
  58. style="width: 100%">
  59. <el-table-column
  60. v-for="column in Data.dynamicColumns"
  61. :key="column.prop"
  62. :prop="column.prop"
  63. :label="column.label">
  64. <template #default="{ row }">
  65. <!-- 状态列特殊处理 -->
  66. <template v-if="column.prop === 'onlineStatus'">
  67. <StatusBox :status="row.onlineStatus" />
  68. </template>
  69. <template v-else-if="column.prop === 'cheatStatus'">
  70. <StatusBox :status="row.cheatStatus" />
  71. </template>
  72. <template v-else-if="column.prop === 'alarming'">
  73. <StatusBox :status="row.alarming" />
  74. </template>
  75. <!-- 监控微处理器编号 - 跳转页面1 -->
  76. <template v-else-if="column.prop === 'monitoringUUID'">
  77. <el-link
  78. type="primary"
  79. :underline="false"
  80. @click="handleMonitoringJump(row)"
  81. >
  82. {{ row[column.prop] }}
  83. </el-link>
  84. </template>
  85. <!-- 加密显示屏编号 - 跳转页面2 -->
  86. <template v-else-if="column.prop === 'displayControlsUUID'">
  87. <el-link
  88. type="primary"
  89. :underline="false"
  90. @click="handleDisplayJump(row)"
  91. >
  92. {{ row[column.prop] }}
  93. </el-link>
  94. </template>
  95. <!-- 编码器编号 - 跳转页面3 -->
  96. <template v-else-if="column.prop === 'encoderControlsUUID'">
  97. <el-link
  98. type="primary"
  99. :underline="false"
  100. @click="handleEncoderJump(row)"
  101. >
  102. {{ row[column.prop] }}
  103. </el-link>
  104. </template>
  105. <!-- 普通列 -->
  106. <template v-else>
  107. {{ row[column.prop] }}
  108. </template>
  109. </template>
  110. </el-table-column>
  111. </el-table>
  112. <div class="my-flex my-flex-end" style="margin-top: 20px">
  113. <el-pagination v-model:currentPage="pageState.pageInput.currentPage" v-model:page-size="pageState.pageInput.pageSize"
  114. :total="Data.total" :page-sizes="[5, 10, 15, 20, 50, 100]" small background @size-change="onSizeChange"
  115. @current-change="onCurrentChange" layout="total, sizes, prev, pager, next, jumper" />
  116. </div>
  117. </el-card>
  118. </el-col>
  119. </el-row>
  120. </div>
  121. </template>
  122. <script setup lang="ts" name="partsManagement/oilGun">
  123. import { onMounted, reactive, watch, ref } from "vue";
  124. import { useRouter } from "vue-router";
  125. import { oilGunFilterModel_SearchFilter, oilGunFilterModel, PageInputoilGunFilterModel } from "/@/api/admin/reportManagement/oilGun/oilGunDto";
  126. import { OilGunApi } from "/@/api/admin/reportManagement/oilGun/oilGunApi";
  127. import StatusBox from "/@/components/StatusBox.vue";
  128. import { useDynamicPageSize } from "/@/composables/useDynamicPageSize";
  129. import { ElMessage } from "element-plus";
  130. // 初始化路由实例
  131. const router = useRouter();
  132. const multipleTableRef = ref<any>(null);
  133. // 使用组合式函数获取分页状态
  134. const pageState = useDynamicPageSize(10, 15);
  135. /** 页面路径配置 */
  136. const pagePaths = {
  137. monitoring: '/statement/taxcontrol/index', // 监控微处理器详情页路径
  138. display: '/statement/displayControl/index', // 加密显示屏详情页路径
  139. encoder: '/statement/encodercontrols/index' // 编码器详情页路径
  140. };
  141. /** 页面对象 */
  142. const Data = reactive({
  143. time1: [] as string[],
  144. /** 选择框列表 */
  145. statusList: [] as any,
  146. supplierList: [] as any,
  147. /** 加载显示 */
  148. loading: false,
  149. /** 条件查询模块 */
  150. Filter: {
  151. /** 油枪号 */
  152. name: "",
  153. /** 加油站名称 */
  154. StationName: "",
  155. /** 石油公司 */
  156. CompanyName: "",
  157. /** 在线状态 */
  158. onlineStatus: "",
  159. /** 出厂开始的时间 */
  160. OutBeginTime: "",
  161. /** 出厂结束的时间 */
  162. OutEndTime: "",
  163. // 作弊状态
  164. cheatStatus: "",
  165. // 自锁状态
  166. alarming: ""
  167. } as oilGunFilterModel_SearchFilter,
  168. /** 表格信息 */
  169. tableModel: [] as Array<oilGunFilterModel>,
  170. /** 动态表头 */
  171. dynamicColumns: [
  172. { prop: 'name', label: '油枪号' },
  173. { prop: 'companyName', label: '石油公司' },
  174. { prop: 'stationName', label: '加油站名称' },
  175. { prop: 'fuelName', label: '油品' },
  176. { prop: 'alarming', label: '自锁' },
  177. { prop: 'fuelId', label: '油机ID' },
  178. { prop: 'onlineStatus', label: '在线状态' },
  179. { prop: 'cheatStatus', label: '作弊状态' },
  180. { prop: 'monitoringUUID', label: '监控微处理器编号' },
  181. { prop: 'displayControlsUUID', label: '加密显示屏编号' },
  182. { prop: 'encoderControlsUUID', label: '编码器编号' },
  183. { prop: 'productTime', label: '出厂时间' },
  184. { prop: 'soldTime', label: '安装时间' },
  185. { prop: 'supplierName', label: '加油机厂商' },
  186. ],
  187. /** 分页总数 */
  188. total: 0,
  189. /** 分页标识 */
  190. pageInput: {
  191. currentPage: 1,
  192. pageSize: 10,
  193. } as PageInputoilGunFilterModel,
  194. })
  195. /** 选择框列表 */
  196. const selectList = reactive({
  197. Online: ["在线", "离线"],
  198. Device: [
  199. "启用",
  200. "备案",
  201. "维修",
  202. "出厂注册"
  203. ],
  204. Level: [1, 2, 3, 4, 5]
  205. })
  206. /** 监控微处理器编号跳转(传递UUID参数) */
  207. const handleMonitoringJump = (row: oilGunFilterModel) => {
  208. if (!row.monitoringUUID) {
  209. ElMessage.warning("该记录没有监控微处理器编号,无法跳转");
  210. return;
  211. }
  212. router.push({
  213. path: pagePaths.monitoring,
  214. query: {
  215. queryParam: row.monitoringUUID, // 传递监控微处理器编号
  216. source: 'monitoring' // 标识来源
  217. }
  218. });
  219. };
  220. /** 加密显示屏编号跳转 */
  221. const handleDisplayJump = (row: oilGunFilterModel) => {
  222. if (!row.displayControlsUUID) {
  223. ElMessage.warning("该记录没有加密显示屏编号,无法跳转");
  224. return;
  225. }
  226. router.push({
  227. path: pagePaths.display,
  228. query: {
  229. queryParam: row.displayControlsUUID,
  230. source: 'display'
  231. }
  232. });
  233. };
  234. /** 编码器编号跳转 */
  235. const handleEncoderJump = (row: oilGunFilterModel) => {
  236. if (!row.encoderControlsUUID) {
  237. ElMessage.warning("该记录没有编码器编号,无法跳转");
  238. return;
  239. }
  240. router.push({
  241. path: pagePaths.encoder,
  242. query: {
  243. queryParam: row.encoderControlsUUID,
  244. source: 'encoder'
  245. }
  246. });
  247. };
  248. onMounted(() => {
  249. // 初始化分页大小
  250. Data.pageInput.pageSize = pageState.pageInput.pageSize;
  251. init();
  252. })
  253. // 条件查询
  254. const init = async () => {
  255. Data.loading = true;
  256. try {
  257. const res: any = await new OilGunApi().getPage({
  258. ...Data.pageInput,
  259. filter: Data.Filter
  260. });
  261. Data.tableModel = res?.data?.list ?? [];
  262. Data.total = res?.data?.total ?? 0;
  263. } catch (error) {
  264. console.error('查询失败:', error);
  265. ElMessage.error('数据加载失败,请重试');
  266. } finally {
  267. Data.loading = false;
  268. }
  269. }
  270. const onQuery = () => {
  271. init();
  272. }
  273. /** 重置查询条件 */
  274. const resetQuery = () => {
  275. Data.Filter = {
  276. name: "",
  277. StationName: "",
  278. CompanyName: "",
  279. onlineStatus: "",
  280. OutBeginTime: "",
  281. OutEndTime: "",
  282. cheatStatus: "",
  283. alarming: ""
  284. };
  285. Data.time1 = [];
  286. Data.pageInput.currentPage = 1;
  287. Data.pageInput.pageSize = 10;
  288. }
  289. /** 重置 */
  290. const onReset = () => {
  291. resetQuery();
  292. init();
  293. }
  294. /** 页条变化 */
  295. const onSizeChange = (val: number) => {
  296. Data.pageInput.pageSize = val;
  297. init();
  298. }
  299. /** 页数变化 */
  300. const onCurrentChange = (val: number) => {
  301. Data.pageInput.currentPage = val;
  302. init();
  303. }
  304. /** 监听时间变换 */
  305. watch(() => Data.time1, (newVal) => {
  306. if (newVal && newVal.length === 2) {
  307. Data.Filter.OutBeginTime = newVal[0];
  308. Data.Filter.OutEndTime = newVal[1];
  309. } else {
  310. Data.Filter.OutBeginTime = "";
  311. Data.Filter.OutEndTime = "";
  312. }
  313. })
  314. </script>
  315. <style scoped lang="scss">
  316. .el-input,
  317. .el-select {
  318. width: 240px;
  319. }
  320. /* 输入框标签固定宽度 */
  321. ::v-deep .el-form-item__label {
  322. width: 14*4px + 12px;
  323. justify-content: start;
  324. }
  325. /* 数据表头样式 */
  326. ::v-deep .el-table th.el-table__cell {
  327. background-color: #F6F6F6;
  328. }
  329. /* 链接样式优化 */
  330. ::v-deep .el-link {
  331. cursor: pointer;
  332. &:hover {
  333. color: #4096ff;
  334. text-decoration: underline;
  335. }
  336. }
  337. </style>