调整设备点检记录左右布局
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 15:48:54 +08:00
parent b52919aab4
commit 494a2f8680
3 changed files with 211 additions and 50 deletions

View File

@@ -1257,7 +1257,10 @@
"unit": "Inspection Unit", "unit": "Inspection Unit",
"inspection_value": "Inspection Value", "inspection_value": "Inspection Value",
"enter_inspection_value": "Enter inspection value", "enter_inspection_value": "Enter inspection value",
"inspection_items_empty": "No inspection items. Please configure them first." "inspection_items_empty": "No inspection items. Please configure them first.",
"enter_device_category_name": "Enter device category name",
"current_device_category": "Current Device Category",
"no_data": "No Data"
}, },
"inspection_logs": { "inspection_logs": {
"search": "Search", "search": "Search",

View File

@@ -1257,7 +1257,10 @@
"unit": "点检单位", "unit": "点检单位",
"inspection_value": "点检值", "inspection_value": "点检值",
"enter_inspection_value": "请输入点检值", "enter_inspection_value": "请输入点检值",
"inspection_items_empty": "设备点检项目为空,请先配置" "inspection_items_empty": "设备点检项目为空,请先配置",
"enter_device_category_name": "请输入设备类别名称",
"current_device_category": "当前设备类别",
"no_data": "无数据"
}, },
"inspection_logs": { "inspection_logs": {
"search": "查询", "search": "查询",

View File

@@ -1,43 +1,77 @@
<template> <template>
<d2-container> <d2-container>
<template #header> <div class="inspection-records-page">
<div class="search-bar"> <aside class="category-panel" v-loading="treeLoading">
<el-form :inline="true" :model="search" size="mini"> <el-input
<el-form-item :label="$t(key('device_category'))"> v-model.trim="categoryFilter"
<el-select v-model="search.device_category_id" :placeholder="$t(key('please_select_device_category'))" clearable filterable style="width:210px"> size="mini"
<el-option v-for="item in deviceCategoryOptions" :key="item.value" :label="item.label" :value="item.value" /> :placeholder="$t(key('enter_device_category_name'))"
</el-select> clearable
</el-form-item> class="category-filter"
<el-form-item :label="$t(key('device_code'))"> />
<el-input v-model.trim="search.device_code" :placeholder="$t(key('enter_device_code'))" clearable style="width:210px" @keyup.enter.native="onSearch" /> <el-tree
</el-form-item> v-if="deviceCategoryTree.length"
<el-form-item :label="$t(key('device_name'))"> ref="categoryTree"
<el-input v-model.trim="search.device_name" :placeholder="$t(key('enter_device_name'))" clearable style="width:210px" @keyup.enter.native="onSearch" /> :data="deviceCategoryTree"
</el-form-item> show-checkbox
<el-form-item> highlight-current
<el-button type="primary" icon="el-icon-search" @click="onSearch">{{ $t(key('search')) }}</el-button> default-expand-all
<el-button icon="el-icon-refresh" @click="onReset">{{ $t(key('reset')) }}</el-button> node-key="id"
</el-form-item> :expand-on-click-node="false"
</el-form> :default-checked-keys="currentCategoryId ? [currentCategoryId] : []"
</div> :current-node-key="currentCategoryId"
</template> :filter-node-method="filterCategoryNode"
@node-click="handleCategoryClick"
@check-change="handleCategoryCheckChange"
>
<template #default="{ node, data }">
<span class="category-node">
<span>{{ node.label }}</span>
<span class="category-code">({{ data.code || '-' }})</span>
</span>
</template>
</el-tree>
<el-result v-else icon="info" :title="$t(key('no_data'))" sub-title="" />
</aside>
<page-table <section class="records-panel">
ref="pageTable" <div class="records-context">
:columns="columns" <span class="context-label">{{ $t(key('current_device_category')) }}</span>
:data="tableData" <strong>{{ currentCategoryLabel || '-' }}</strong>
:loading="loading" </div>
:toolbar-buttons="toolbarButtons" <div class="search-bar">
:row-buttons="rowButtons" <el-form :inline="true" :model="search" size="mini">
:pagination="pagination" <el-form-item :label="$t(key('device_code'))">
auto-height <el-input v-model.trim="search.device_code" :placeholder="$t(key('enter_device_code'))" clearable style="width:210px" @keyup.enter.native="onSearch" />
@page-change="onPageChange" </el-form-item>
> <el-form-item :label="$t(key('device_name'))">
<template #col-check_result="{ row }"> <el-input v-model.trim="search.device_name" :placeholder="$t(key('enter_device_name'))" clearable style="width:210px" @keyup.enter.native="onSearch" />
<el-tag v-if="row.check_result" :type="row.check_result === 'OK' ? 'success' : 'danger'" size="mini">{{ row.check_result }}</el-tag> </el-form-item>
<span v-else>-</span> <el-form-item>
</template> <el-button type="primary" icon="el-icon-search" @click="onSearch">{{ $t(key('search')) }}</el-button>
</page-table> <el-button icon="el-icon-refresh" @click="onReset">{{ $t(key('reset')) }}</el-button>
</el-form-item>
</el-form>
</div>
<page-table
ref="pageTable"
:columns="columns"
:data="tableData"
:loading="loading"
:toolbar-buttons="toolbarButtons"
:row-buttons="rowButtons"
:pagination="pagination"
auto-height
@page-change="onPageChange"
>
<template #col-check_result="{ row }">
<el-tag v-if="row.check_result" :type="row.check_result === 'OK' ? 'success' : 'danger'" size="mini">{{ row.check_result }}</el-tag>
<span v-else>-</span>
</template>
</page-table>
</section>
</div>
<el-dialog :title="dialogTitleText" :visible.sync="dialogVisible" width="980px" :close-on-click-modal="false" @close="resetDialog"> <el-dialog :title="dialogTitleText" :visible.sync="dialogVisible" width="980px" :close-on-click-modal="false" @close="resetDialog">
<el-form ref="recordForm" :model="recordForm" :rules="recordRules" inline size="mini" label-width="90px"> <el-form ref="recordForm" :model="recordForm" :rules="recordRules" inline size="mini" label-width="90px">
@@ -109,8 +143,16 @@ function readList (res) {
return [] return []
} }
function toOptions (list) { function normalizeCategories (list) {
return (Array.isArray(list) ? list : []).map(item => ({ label: item.name || item.label, value: item.id || item.value, raw: item })) return (Array.isArray(list) ? list : []).map((item, index) => ({
id: item.id || item.value,
value: item.id || item.value,
label: item.name || item.label,
name: item.name || item.label,
code: item.code || '',
index,
children: []
}))
} }
export default { export default {
@@ -120,11 +162,15 @@ export default {
data () { data () {
return { return {
loading: false, loading: false,
treeLoading: false,
submitting: false, submitting: false,
itemsLoading: false, itemsLoading: false,
tableData: [], tableData: [],
deviceCategoryOptions: [], categoryFilter: '',
search: { device_category_id: '', device_code: '', device_name: '' }, deviceCategoryTree: [],
currentCategoryId: '',
currentCategory: null,
search: { device_code: '', device_name: '' },
pagination: { current: 1, size: 10, total: 0 }, pagination: { current: 1, size: 10, total: 0 },
dialogVisible: false, dialogVisible: false,
currentDevice: null, currentDevice: null,
@@ -141,11 +187,20 @@ export default {
} }
}, },
computed: { computed: {
currentCategoryLabel () {
if (!this.currentCategory) return ''
return `${this.currentCategory.label}${this.currentCategory.code ? ` (${this.currentCategory.code})` : ''}`
},
dialogTitleText () { dialogTitleText () {
const name = this.currentDevice ? `${this.currentDevice.device_code || ''} ${this.currentDevice.device_name || ''}`.trim() : '' const name = this.currentDevice ? `${this.currentDevice.device_code || ''} ${this.currentDevice.device_name || ''}`.trim() : ''
return `${this.$t(this.key('add_inspection_record'))}${name ? ` - ${name}` : ''}` return `${this.$t(this.key('add_inspection_record'))}${name ? ` - ${name}` : ''}`
} }
}, },
watch: {
categoryFilter (val) {
if (this.$refs.categoryTree) this.$refs.categoryTree.filter(val)
}
},
created () { created () {
this.columns = useTableColumns([ this.columns = useTableColumns([
{ prop: 'device_code', label: this.key('device_code'), minWidth: 140, fixed: 'left' }, { prop: 'device_code', label: this.key('device_code'), minWidth: 140, fixed: 'left' },
@@ -166,17 +221,62 @@ export default {
this.toolbarButtons = btns.toolbarButtons this.toolbarButtons = btns.toolbarButtons
this.rowButtons = btns.rowButtons this.rowButtons = btns.rowButtons
this.loadDeviceCategories() this.loadDeviceCategories()
this.fetchData()
}, },
methods: { methods: {
async loadDeviceCategories () { async loadDeviceCategories () {
const res = await getEquipmentCategoryALL({}) this.treeLoading = true
this.deviceCategoryOptions = toOptions((res && res.data) || res) try {
const res = await getEquipmentCategoryALL({ no_denglu_sign: 'no' })
const list = normalizeCategories((res && res.data) || res)
this.deviceCategoryTree = list
if (list.length) {
this.setCurrentCategory(list[0], false)
this.$nextTick(() => {
if (this.$refs.categoryTree) {
this.$refs.categoryTree.setCheckedKeys([this.currentCategoryId])
this.$refs.categoryTree.setCurrentKey(this.currentCategoryId)
}
})
this.fetchData()
}
} finally {
this.treeLoading = false
}
},
setCurrentCategory (category, shouldFetch = true) {
this.currentCategory = category
this.currentCategoryId = category ? category.id : ''
this.pagination.current = 1
if (shouldFetch) this.fetchData()
},
filterCategoryNode (value, data) {
if (!value) return true
const text = String(value).toLowerCase()
return String(data.label || '').toLowerCase().includes(text) || String(data.code || '').toLowerCase().includes(text)
},
handleCategoryClick (data) {
this.setCurrentCategory(data)
this.$nextTick(() => {
if (this.$refs.categoryTree) this.$refs.categoryTree.setCheckedKeys([data.id])
})
},
handleCategoryCheckChange (data, checked) {
if (!checked) return
if (this.$refs.categoryTree) this.$refs.categoryTree.setCheckedKeys([data.id])
if (String(data.id) !== String(this.currentCategoryId)) this.setCurrentCategory(data)
},
buildSearchParams () {
return { ...this.search, device_category_id: this.currentCategoryId }
}, },
async fetchData () { async fetchData () {
if (!this.currentCategoryId) {
this.tableData = []
this.pagination.total = 0
return
}
this.loading = true this.loading = true
try { try {
const res = await getList({ ...this.search, page_no: this.pagination.current, page_size: this.pagination.size }) const res = await getList({ ...this.buildSearchParams(), page_no: this.pagination.current, page_size: this.pagination.size })
const page = readPageData(res) const page = readPageData(res)
this.tableData = page.list this.tableData = page.list
this.pagination.total = page.total this.pagination.total = page.total
@@ -189,7 +289,7 @@ export default {
this.fetchData() this.fetchData()
}, },
onReset () { onReset () {
this.search = { device_category_id: '', device_code: '', device_name: '' } this.search = { device_code: '', device_name: '' }
this.pagination.current = 1 this.pagination.current = 1
this.fetchData() this.fetchData()
}, },
@@ -261,6 +361,61 @@ export default {
</script> </script>
<style scoped> <style scoped>
.search-bar { padding: 10px 0; } .inspection-records-page {
/deep/ .el-form-item--mini.el-form-item { margin-bottom: 4px; } display: flex;
gap: 16px;
height: 100%;
min-height: 560px;
}
.category-panel {
flex: 0 0 260px;
min-width: 220px;
border-right: 1px solid #ebeef5;
padding: 10px 14px 10px 0;
overflow: auto;
}
.category-filter {
margin-bottom: 12px;
}
.category-node {
display: inline-flex;
align-items: center;
gap: 4px;
max-width: 190px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.category-code {
color: #909399;
font-size: 12px;
}
.records-panel {
flex: 1;
min-width: 0;
display: flex;
flex-direction: column;
}
.records-context {
display: flex;
align-items: center;
gap: 8px;
min-height: 30px;
margin-bottom: 8px;
color: #303133;
}
.context-label {
color: #909399;
}
.search-bar {
padding-bottom: 8px;
border-bottom: 1px solid #ebeef5;
margin-bottom: 10px;
}
/deep/ .el-form-item--mini.el-form-item {
margin-bottom: 4px;
}
/deep/ .d2-container-full__body {
overflow: hidden;
}
</style> </style>