修复设备点检日志查询分页和导出
Some checks failed
Release pipeline / publish (push) Has been cancelled
Release pipeline / Always run job (push) Has been cancelled

This commit is contained in:
sheng
2026-06-26 16:38:19 +08:00
parent 0e6379b0bb
commit 06c81370ff

View File

@@ -23,6 +23,7 @@
<el-form-item>
<el-button type="primary" icon="el-icon-search" @click="onSearch">{{ $t(key('search')) }}</el-button>
<el-button icon="el-icon-refresh" @click="onReset">{{ $t(key('reset')) }}</el-button>
<el-button type="success" icon="el-icon-download" @click="handleExport">{{ $t(key('export')) }}</el-button>
</el-form-item>
</el-form>
</div>
@@ -33,8 +34,8 @@
:columns="columns"
:data="tableData"
:loading="loading"
:toolbar-buttons="toolbarButtons"
:row-buttons="rowButtons"
:toolbar-buttons="[]"
:row-buttons="[]"
:pagination="pagination"
auto-height
@page-change="onPageChange"
@@ -43,53 +44,16 @@
<el-tag :type="row.result === 'OK' ? 'success' : 'danger'" size="mini">{{ row.result }}</el-tag>
</template>
</page-table>
<el-dialog :title="detailsTitle" :visible.sync="detailsVisible" width="1050px" :close-on-click-modal="false">
<div class="details-search">
<el-form :inline="true" :model="detailsSearch" size="mini">
<el-form-item :label="$t(key('inspection_item_name'))">
<el-input v-model.trim="detailsSearch.device_check_items_name" :placeholder="$t(key('enter_inspection_item_name'))" clearable style="width:220px" @keyup.enter.native="loadDetails" />
</el-form-item>
<el-form-item>
<el-button icon="el-icon-search" @click="loadDetails">{{ $t(key('search')) }}</el-button>
<el-button icon="el-icon-refresh" @click="resetDetailsSearch">{{ $t(key('reset')) }}</el-button>
</el-form-item>
</el-form>
</div>
<el-table v-loading="detailsLoading" :data="detailsData" border height="430" size="mini">
<el-table-column prop="id" label="ID" width="80" />
<el-table-column prop="device_check_items_name" :label="$t(key('inspection_item_name'))" min-width="150" />
<el-table-column prop="result" :label="$t(key('inspection_result'))" width="100">
<template #default="{ row }">
<el-tag :type="row.result === 'OK' ? 'success' : 'danger'" size="mini">{{ row.result }}</el-tag>
</template>
</el-table-column>
<el-table-column prop="val" :label="$t(key('inspection_value'))" min-width="110" />
<el-table-column prop="standard" :label="$t(key('standard'))" min-width="140" show-overflow-tooltip />
<el-table-column prop="check_method" :label="$t(key('check_method'))" min-width="130" show-overflow-tooltip />
<el-table-column prop="unit" :label="$t(key('unit'))" width="90" />
<el-table-column prop="frequentness" :label="$t(key('frequentness'))" width="110" />
<el-table-column prop="example" :label="$t(key('example'))" width="110" />
<el-table-column prop="class_please" :label="$t(key('class_please'))" width="100" />
<el-table-column prop="implementation_people" :label="$t(key('implementation_people'))" min-width="120" />
<el-table-column prop="username" :label="$t(key('operator'))" min-width="120" />
<el-table-column prop="create_time" :label="$t(key('inspection_time'))" min-width="160" />
</el-table>
<span slot="footer">
<el-button @click="detailsVisible = false">{{ $t(key('close')) }}</el-button>
</span>
</el-dialog>
</d2-container>
</template>
<script>
import { useTableColumns } from '@/composables/useTableColumns'
import { useTableButtons } from '@/composables/useTableButtons'
import { i18nMixin } from '@/composables/useI18n'
import { confirmMixin } from '@/composables/useConfirmHandle'
import PageTable from '@/components/page-table'
import { getUserList } from '@/api/system-administration/user'
import { getDetails, getDetailsList, createExportTask } from '@/api/equipment-management/inspection-logs'
import { getDetailsList, createExportTask } from '@/api/equipment-management/inspection-logs'
function readPageData (res) {
const data = res && res.data !== undefined ? res.data : res
@@ -99,13 +63,6 @@ function readPageData (res) {
return { list: [], total: 0 }
}
function readList (res) {
const data = res && res.data !== undefined ? res.data : res
if (Array.isArray(data)) return data
if (data && Array.isArray(data.data)) return data.data
return []
}
function compactParams (params) {
const next = { ...params }
if (!Array.isArray(next.create_time) || !next.create_time.length) delete next.create_time
@@ -122,24 +79,11 @@ export default {
data () {
return {
loading: false,
detailsLoading: false,
tableData: [],
detailsData: [],
detailsVisible: false,
currentDetailRow: null,
userOptions: [],
search: { device_code: '', device_name: '', device_check_items_name: '', user_id: '', create_time: [] },
detailsSearch: { device_check_items_name: '' },
pagination: { current: 1, size: 10, total: 0 },
columns: [],
toolbarButtons: [],
rowButtons: []
}
},
computed: {
detailsTitle () {
const deviceName = this.currentDetailRow ? (this.currentDetailRow.device_name || '') : ''
return deviceName ? `${this.$t(this.key('device'))}${deviceName}${this.$t(this.key('inspection_details'))}` : this.$t(this.key('details_title'))
columns: []
}
},
created () {
@@ -159,19 +103,8 @@ export default {
{ prop: 'class_please', label: this.key('class_please'), width: 100 },
{ prop: 'implementation_people', label: this.key('implementation_people'), minWidth: 120 },
{ prop: 'username', label: this.key('operator'), minWidth: 120 },
{ prop: 'create_time', label: this.key('inspection_time'), minWidth: 160 },
{ prop: '_actions', label: this.key('operation'), width: 120, fixed: 'right' }
{ prop: 'create_time', label: this.key('inspection_time'), minWidth: 160 }
], { selectionWidth: 0 })
const btns = useTableButtons({
toolbar: [
{ key: 'export', label: this.key('export'), icon: 'el-icon-download', type: 'primary', auth: '/device_management/device_check/device_check_items_log/export', onClick: this.handleExport }
],
row: [
{ key: 'details', label: this.key('details'), icon: 'el-icon-view', auth: '/device_management/device_check/device_check_items_log/details', onClick: this.openDetails }
]
}, this.$permission)
this.toolbarButtons = btns.toolbarButtons
this.rowButtons = btns.rowButtons
this.loadUsers()
this.fetchData()
},
@@ -190,7 +123,15 @@ export default {
async fetchData () {
this.loading = true
try {
const res = await getDetailsList({ ...this.buildSearchParams(), page_no: this.pagination.current, page_size: this.pagination.size })
const pageNo = Number(this.pagination.current) || 1
const pageSize = Number(this.pagination.size) || 10
const res = await getDetailsList({
...this.buildSearchParams(),
page_no: pageNo,
page_size: pageSize,
page: pageNo,
size: pageSize
})
const page = readPageData(res)
this.tableData = page.list
this.pagination.total = page.total
@@ -208,33 +149,10 @@ export default {
this.fetchData()
},
onPageChange (page) {
this.pagination.current = page.current
this.pagination.size = page.size
this.pagination.current = Number(page.current || page.currentPage || 1)
this.pagination.size = Number(page.size || page.pageSize || this.pagination.size || 10)
this.fetchData()
},
async openDetails (row) {
this.currentDetailRow = row
this.detailsSearch = { device_check_items_name: '' }
this.detailsVisible = true
await this.loadDetails()
},
async loadDetails () {
if (!this.currentDetailRow) return
this.detailsLoading = true
try {
const res = await getDetails({
...compactParams(this.detailsSearch),
device_check_items_log_id: this.currentDetailRow.device_check_items_log_id || this.currentDetailRow.id
})
this.detailsData = readList(res)
} finally {
this.detailsLoading = false
}
},
resetDetailsSearch () {
this.detailsSearch = { device_check_items_name: '' }
this.loadDetails()
},
async handleExport () {
const cancelled = await this.$confirmAction(
{ message: this.key('confirm_export'), title: this.key('tip'), confirmButtonText: this.key('confirm'), cancelButtonText: this.key('cancel') },
@@ -250,9 +168,6 @@ export default {
.search-bar {
padding: 10px 0;
}
.details-search {
padding-bottom: 8px;
}
/deep/ .el-form-item--mini.el-form-item {
margin-bottom: 4px;
}