DeviceMaintainRecord.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487
  1. <template>
  2. <div class="device-maintain-record">
  3. <section class="library-workbench">
  4. <el-form
  5. ref="queryFormRef"
  6. :model="queryParams"
  7. inline
  8. size="default"
  9. class="library-search-form">
  10. <div class="library-workbench__header">
  11. <div class="library-header-main">
  12. <div class="workbench-title">
  13. <span class="workbench-title__icon">
  14. <Icon icon="ep:tools" />
  15. </span>
  16. <div>
  17. <h3>维修记录</h3>
  18. </div>
  19. </div>
  20. <el-form-item label="故障编码" prop="failureCode">
  21. <el-input
  22. v-model="queryParams.failureCode"
  23. class="library-search-input"
  24. clearable
  25. placeholder="请输入故障编码"
  26. @keyup.enter="handleQuery">
  27. <template #prefix>
  28. <Icon icon="ep:search" />
  29. </template>
  30. </el-input>
  31. </el-form-item>
  32. <el-form-item label="故障名称" prop="failureName">
  33. <el-input
  34. v-model="queryParams.failureName"
  35. class="library-search-input"
  36. clearable
  37. placeholder="请输入故障名称"
  38. @keyup.enter="handleQuery">
  39. <template #prefix>
  40. <Icon icon="ep:search" />
  41. </template>
  42. </el-input>
  43. </el-form-item>
  44. <el-form-item label="状态" prop="status">
  45. <el-select
  46. v-model="queryParams.status"
  47. class="library-search-input"
  48. clearable
  49. placeholder="请选择状态">
  50. <el-option
  51. v-for="dict in getStrDictOptions(DICT_TYPE.PMS_MAIN_STATUS)"
  52. :key="dict.value"
  53. :label="dict.label"
  54. :value="dict.value" />
  55. </el-select>
  56. </el-form-item>
  57. </div>
  58. <el-form-item class="library-actions">
  59. <el-button
  60. :type="showAdvancedSearch ? 'warning' : 'primary'"
  61. plain
  62. @click="toggleAdvancedSearch">
  63. <Icon :icon="showAdvancedSearch ? 'ep:arrow-up' : 'ep:arrow-down'" />
  64. {{ showAdvancedSearch ? '收起查询' : '更多查询' }}
  65. </el-button>
  66. <el-button type="primary" @click="handleQuery">
  67. <Icon icon="ep:search" />
  68. 搜索
  69. </el-button>
  70. <el-button @click="resetQuery">
  71. <Icon icon="ep:refresh" />
  72. 重置
  73. </el-button>
  74. </el-form-item>
  75. </div>
  76. <el-collapse-transition>
  77. <div v-show="showAdvancedSearch" class="advanced-search-panel">
  78. <el-form-item label="是否停机" prop="ifStop">
  79. <el-select
  80. v-model="queryParams.ifStop"
  81. class="library-search-input"
  82. clearable
  83. placeholder="请选择">
  84. <el-option
  85. v-for="dict in getBoolDictOptions(DICT_TYPE.INFRA_BOOLEAN_STRING)"
  86. :key="dict.value"
  87. :label="dict.label"
  88. :value="dict.value" />
  89. </el-select>
  90. </el-form-item>
  91. <el-form-item label="故障时间" prop="failureTime">
  92. <el-date-picker
  93. v-model="queryParams.failureTime"
  94. class="library-date-range"
  95. value-format="YYYY-MM-DD HH:mm:ss"
  96. type="daterange"
  97. start-placeholder="开始时间"
  98. end-placeholder="结束时间"
  99. :default-time="[new Date('1 00:00:00'), new Date('1 23:59:59')]" />
  100. </el-form-item>
  101. <el-form-item label="维修开始" prop="maintainStartTime">
  102. <el-date-picker
  103. v-model="queryParams.maintainStartTime"
  104. class="library-date-range"
  105. value-format="YYYY-MM-DD HH:mm:ss"
  106. type="daterange"
  107. start-placeholder="开始时间"
  108. end-placeholder="结束时间"
  109. :default-time="[new Date('1 00:00:00'), new Date('1 23:59:59')]" />
  110. </el-form-item>
  111. <el-form-item label="维修结束" prop="maintainEndTime">
  112. <el-date-picker
  113. v-model="queryParams.maintainEndTime"
  114. class="library-date-range"
  115. value-format="YYYY-MM-DD HH:mm:ss"
  116. type="daterange"
  117. start-placeholder="开始时间"
  118. end-placeholder="结束时间"
  119. :default-time="[new Date('1 00:00:00'), new Date('1 23:59:59')]" />
  120. </el-form-item>
  121. <el-form-item label="创建时间" prop="createTime">
  122. <el-date-picker
  123. v-model="queryParams.createTime"
  124. class="library-date-range"
  125. value-format="YYYY-MM-DD HH:mm:ss"
  126. type="daterange"
  127. start-placeholder="开始时间"
  128. end-placeholder="结束时间"
  129. :default-time="[new Date('1 00:00:00'), new Date('1 23:59:59')]" />
  130. </el-form-item>
  131. <el-form-item label="故障系统" prop="failureSystem">
  132. <el-input
  133. v-model="queryParams.failureSystem"
  134. class="library-search-input"
  135. clearable
  136. placeholder="请输入故障系统"
  137. @keyup.enter="handleQuery" />
  138. </el-form-item>
  139. <el-form-item label="故障影响" prop="failureInfluence">
  140. <el-input
  141. v-model="queryParams.failureInfluence"
  142. class="library-search-input"
  143. clearable
  144. placeholder="请输入故障影响"
  145. @keyup.enter="handleQuery" />
  146. </el-form-item>
  147. <el-form-item label="描述" prop="description">
  148. <el-input
  149. v-model="queryParams.description"
  150. class="library-search-input"
  151. clearable
  152. placeholder="请输入描述"
  153. @keyup.enter="handleQuery" />
  154. </el-form-item>
  155. </div>
  156. </el-collapse-transition>
  157. </el-form>
  158. <div class="library-table-wrap">
  159. <el-auto-resizer>
  160. <template #default="{ width, height }">
  161. <ZmTable
  162. :data="list"
  163. class="library-table"
  164. :loading="loading"
  165. :width="width"
  166. :height="height"
  167. :max-height="height"
  168. :column-max-width="420"
  169. row-key="id"
  170. empty-text="暂无数据"
  171. show-border>
  172. <ZmTableColumn
  173. label="故障编码"
  174. prop="failureCode"
  175. min-width="150"
  176. align="left"
  177. fixed="left">
  178. <template #default="{ row }">
  179. <span class="maintain-code">{{ row.failureCode || '-' }}</span>
  180. </template>
  181. </ZmTableColumn>
  182. <ZmTableColumn label="故障名称" prop="failureName" min-width="180" align="left">
  183. <template #default="{ row }">
  184. {{ row.failureName || '-' }}
  185. </template>
  186. </ZmTableColumn>
  187. <ZmTableColumn label="设备" prop="deviceName" min-width="160">
  188. <template #default="{ row }">
  189. {{ row.deviceName || '-' }}
  190. </template>
  191. </ZmTableColumn>
  192. <ZmTableColumn label="状态" prop="status" min-width="120">
  193. <template #default="{ row }">
  194. <dict-tag :type="DICT_TYPE.PMS_MAIN_STATUS" :value="row.status" />
  195. </template>
  196. </ZmTableColumn>
  197. <ZmTableColumn label="审核状态" prop="auditStatus" min-width="120">
  198. <template #default="{ row }">
  199. <dict-tag :type="DICT_TYPE.CRM_AUDIT_STATUS" :value="row.auditStatus" />
  200. </template>
  201. </ZmTableColumn>
  202. <ZmTableColumn label="是否停机" prop="ifStop" min-width="120">
  203. <template #default="{ row }">
  204. <dict-tag :type="DICT_TYPE.INFRA_BOOLEAN_STRING" :value="row.ifStop" />
  205. </template>
  206. </ZmTableColumn>
  207. <ZmTableColumn label="维修开始时间" prop="maintainStartTime" min-width="180">
  208. <template #default="{ row }">
  209. {{ formatRecordTime(row.maintainStartTime) }}
  210. </template>
  211. </ZmTableColumn>
  212. <ZmTableColumn label="故障时间" prop="failureTime" min-width="180">
  213. <template #default="{ row }">
  214. {{ formatRecordTime(row.failureTime) }}
  215. </template>
  216. </ZmTableColumn>
  217. <ZmTableColumn label="创建时间" prop="createTime" min-width="180">
  218. <template #default="{ row }">
  219. {{ formatRecordTime(row.createTime) }}
  220. </template>
  221. </ZmTableColumn>
  222. <ZmTableColumn label="操作" min-width="90" fixed="right">
  223. <template #default="{ row }">
  224. <el-button type="primary" link @click="view(row)"> 查看 </el-button>
  225. </template>
  226. </ZmTableColumn>
  227. </ZmTable>
  228. </template>
  229. </el-auto-resizer>
  230. </div>
  231. <div class="library-pagination">
  232. <Pagination
  233. v-model:page="queryParams.pageNo"
  234. v-model:limit="queryParams.pageSize"
  235. :total="total"
  236. @pagination="getList" />
  237. </div>
  238. </section>
  239. </div>
  240. </template>
  241. <script lang="ts" setup>
  242. import { reactive, ref, watch } from 'vue'
  243. import { IotMaintainApi, IotMaintainVO } from '@/api/pms/maintain'
  244. import { useTableComponents } from '@/components/ZmTable/useTableComponents'
  245. import { DICT_TYPE, getBoolDictOptions, getStrDictOptions } from '@/utils/dict'
  246. import { formatDate } from '@/utils/formatTime'
  247. defineOptions({ name: 'DeviceMaintainRecord' })
  248. const props = defineProps<{
  249. deviceId?: number
  250. }>()
  251. type MaintainRecordRow = IotMaintainVO & {
  252. createTime?: Date | string | number
  253. }
  254. const { ZmTable, ZmTableColumn } = useTableComponents<MaintainRecordRow>()
  255. const { push } = useRouter()
  256. const loading = ref(false)
  257. const list = ref<MaintainRecordRow[]>([])
  258. const total = ref(0)
  259. const queryFormRef = ref()
  260. const showAdvancedSearch = ref(false)
  261. const queryParams = reactive({
  262. pageNo: 1,
  263. pageSize: 10,
  264. failureCode: undefined as string | undefined,
  265. failureName: undefined as string | undefined,
  266. deviceId: undefined as number | undefined,
  267. status: undefined as string | undefined,
  268. ifStop: undefined as string | boolean | undefined,
  269. failureTime: [] as string[],
  270. failureInfluence: undefined as string | undefined,
  271. failureSystem: undefined as string | undefined,
  272. description: undefined as string | undefined,
  273. maintainStartTime: [] as string[],
  274. maintainEndTime: [] as string[],
  275. createTime: [] as string[]
  276. })
  277. const getList = async () => {
  278. if (!props.deviceId) return
  279. loading.value = true
  280. queryParams.deviceId = props.deviceId
  281. try {
  282. const data = await IotMaintainApi.getIotMaintainPage(queryParams)
  283. list.value = data?.list || []
  284. total.value = data?.total || 0
  285. } finally {
  286. loading.value = false
  287. }
  288. }
  289. const handleQuery = () => {
  290. queryParams.pageNo = 1
  291. getList()
  292. }
  293. const resetQuery = () => {
  294. queryFormRef.value?.resetFields()
  295. handleQuery()
  296. }
  297. const toggleAdvancedSearch = () => {
  298. showAdvancedSearch.value = !showAdvancedSearch.value
  299. }
  300. const formatRecordTime = (value?: Date | string | number) => {
  301. return value ? formatDate(value as Date) : '-'
  302. }
  303. const view = (row: MaintainRecordRow) => {
  304. if (!row?.id) return
  305. push({
  306. name: 'MaintainDetail',
  307. params: { id: row.id }
  308. })
  309. }
  310. watch(
  311. () => props.deviceId,
  312. () => {
  313. getList()
  314. },
  315. { immediate: true }
  316. )
  317. </script>
  318. <style scoped lang="scss">
  319. .device-maintain-record {
  320. display: grid;
  321. gap: 14px;
  322. }
  323. .library-workbench {
  324. padding: 14px;
  325. overflow: hidden;
  326. background: linear-gradient(180deg, #f8fbff 0, var(--el-bg-color) 96px), var(--el-bg-color);
  327. border: 1px solid var(--el-border-color-lighter);
  328. border-radius: 8px;
  329. }
  330. .library-search-form {
  331. :deep(.el-form-item) {
  332. margin-right: 10px;
  333. margin-bottom: 0;
  334. }
  335. :deep(.el-form-item:last-child) {
  336. margin-right: 0;
  337. }
  338. :deep(.el-button .app-iconify) {
  339. margin-right: 4px;
  340. }
  341. }
  342. .library-workbench__header {
  343. display: flex;
  344. gap: 16px;
  345. min-height: 56px;
  346. margin-bottom: 14px;
  347. align-items: center;
  348. justify-content: space-between;
  349. }
  350. .library-header-main {
  351. display: flex;
  352. gap: 10px;
  353. min-width: 0;
  354. align-items: center;
  355. flex: 1;
  356. flex-wrap: wrap;
  357. }
  358. .workbench-title {
  359. display: flex;
  360. gap: 12px;
  361. min-width: 0;
  362. align-items: center;
  363. h3 {
  364. margin: 0;
  365. font-size: 16px;
  366. font-weight: 700;
  367. line-height: 24px;
  368. color: var(--el-text-color-primary);
  369. }
  370. }
  371. .workbench-title__icon {
  372. display: flex;
  373. width: 38px;
  374. height: 38px;
  375. font-size: 18px;
  376. color: #3478f6;
  377. background: #eaf2ff;
  378. border-radius: 10px;
  379. flex: none;
  380. align-items: center;
  381. justify-content: center;
  382. }
  383. .library-search-input {
  384. width: 220px;
  385. }
  386. .library-date-range {
  387. width: 300px;
  388. }
  389. .library-actions {
  390. flex: none;
  391. }
  392. .advanced-search-panel {
  393. display: flex;
  394. padding: 12px 14px;
  395. margin-bottom: 14px;
  396. background: rgb(255 255 255 / 68%);
  397. border: 1px solid var(--el-border-color-lighter);
  398. border-radius: 8px;
  399. gap: 12px 4px;
  400. flex-wrap: wrap;
  401. }
  402. .library-table-wrap {
  403. height: 560px;
  404. min-width: 0;
  405. }
  406. .library-table {
  407. --el-table-header-bg-color: var(--el-fill-color-lighter);
  408. --el-table-row-hover-bg-color: #f6faff;
  409. overflow: hidden;
  410. border-radius: 8px;
  411. :deep(.el-table__cell) {
  412. padding: 9px 0;
  413. }
  414. }
  415. .maintain-code {
  416. display: inline-block;
  417. max-width: 100%;
  418. overflow: hidden;
  419. font-weight: 500;
  420. text-overflow: ellipsis;
  421. white-space: nowrap;
  422. }
  423. .library-pagination {
  424. display: flex;
  425. height: 40px;
  426. margin-top: 8px;
  427. align-items: center;
  428. justify-content: flex-end;
  429. }
  430. @media (width <= 767px) {
  431. .library-workbench__header {
  432. align-items: stretch;
  433. flex-direction: column;
  434. }
  435. .library-header-main {
  436. align-items: stretch;
  437. flex-direction: column;
  438. }
  439. .library-search-input {
  440. width: 100%;
  441. }
  442. }
  443. </style>