修复生产监控分页和设备监控筛选
This commit is contained in:
@@ -169,9 +169,9 @@
|
||||
-->
|
||||
<div ref="footer" class="page-table__footer" v-if="pagination">
|
||||
<el-pagination
|
||||
:current-page="pagination.current"
|
||||
:page-size="pagination.size || 10"
|
||||
:total="pagination.total"
|
||||
:current-page="paginationCurrent"
|
||||
:page-size="paginationSize"
|
||||
:total="paginationTotal"
|
||||
:page-sizes="[10, 25, 50, 100, 250, 500]"
|
||||
:disabled="loading"
|
||||
layout="total, sizes, prev, pager, next, jumper"
|
||||
@@ -361,6 +361,21 @@ export default {
|
||||
return this.tableSelected.length
|
||||
},
|
||||
|
||||
paginationCurrent () {
|
||||
if (!this.pagination) return 1
|
||||
return Number(this.pagination.current || this.pagination.currentPage || 1)
|
||||
},
|
||||
|
||||
paginationSize () {
|
||||
if (!this.pagination) return 10
|
||||
return Number(this.pagination.size || this.pagination.pageSize || 10)
|
||||
},
|
||||
|
||||
paginationTotal () {
|
||||
if (!this.pagination) return 0
|
||||
return Number(this.pagination.total || 0)
|
||||
},
|
||||
|
||||
/**
|
||||
* 表头样式:浅灰背景 + 黑色加粗文字
|
||||
*/
|
||||
@@ -424,16 +439,20 @@ export default {
|
||||
onSizeChange (size) {
|
||||
this.$emit('page-change', {
|
||||
current: 1,
|
||||
currentPage: 1,
|
||||
size,
|
||||
total: this.pagination.total
|
||||
pageSize: size,
|
||||
total: this.paginationTotal
|
||||
})
|
||||
},
|
||||
|
||||
onCurrentChange (current) {
|
||||
this.$emit('page-change', {
|
||||
current,
|
||||
size: this.pagination.size,
|
||||
total: this.pagination.total
|
||||
currentPage: current,
|
||||
size: this.paginationSize,
|
||||
pageSize: this.paginationSize,
|
||||
total: this.paginationTotal
|
||||
})
|
||||
},
|
||||
|
||||
|
||||
@@ -2896,7 +2896,11 @@
|
||||
"current_process": "Current Process"
|
||||
},
|
||||
"equipment_monitoring": {
|
||||
"query": "Search",
|
||||
"reset": "Reset",
|
||||
"device_total": "Total Devices",
|
||||
"device_category": "Device Category",
|
||||
"select_device_category": "Please select device category",
|
||||
"device_code": "Device Code",
|
||||
"device_name": "Device Name",
|
||||
"area": "Plant Area",
|
||||
|
||||
@@ -2896,7 +2896,11 @@
|
||||
"current_process": "当前工序"
|
||||
},
|
||||
"equipment_monitoring": {
|
||||
"query": "查询",
|
||||
"reset": "重置",
|
||||
"device_total": "设备总数",
|
||||
"device_category": "设备类别",
|
||||
"select_device_category": "请选择设备类别",
|
||||
"device_code": "设备编码",
|
||||
"device_name": "设备名称",
|
||||
"area": "厂区",
|
||||
|
||||
@@ -1,6 +1,35 @@
|
||||
<template>
|
||||
<d2-container>
|
||||
<template #header>
|
||||
<div class="search-bar">
|
||||
<el-form :inline="true" size="mini">
|
||||
<el-form-item :label="$t(key('device_category'))">
|
||||
<el-select
|
||||
v-model="search.device_category_id"
|
||||
:placeholder="$t(key('select_device_category'))"
|
||||
clearable
|
||||
filterable
|
||||
style="width:220px"
|
||||
@change="onSearch"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in deviceCategoryOptions"
|
||||
:key="item.value"
|
||||
:label="item.label"
|
||||
:value="item.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" icon="el-icon-search" :disabled="loading" @click="onSearch">
|
||||
{{ $t(key('query')) }}
|
||||
</el-button>
|
||||
<el-button icon="el-icon-refresh" :disabled="loading" @click="onReset">
|
||||
{{ $t(key('reset')) }}
|
||||
</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</div>
|
||||
<div class="status-board">
|
||||
<el-card
|
||||
:class="['status-card', 'status-card--all', { 'is-active': activeStatus === '' }]"
|
||||
@@ -53,6 +82,7 @@ import { useTableColumns } from '@/composables/useTableColumns'
|
||||
import { i18nMixin } from '@/composables/useI18n'
|
||||
import PageTable from '@/components/page-table'
|
||||
import { getDeviceAll } from '@/api/planning-production/equipment-monitoring'
|
||||
import { getDeviceCategoryAll } from '@/api/production-master-data/device-category'
|
||||
|
||||
const STATUS_META = {
|
||||
FINISH: { label: 'finished', color: '#409EFF', className: 'finish' },
|
||||
@@ -73,6 +103,10 @@ export default {
|
||||
activeStatus: '',
|
||||
tableData: [],
|
||||
statusNum: [],
|
||||
deviceCategoryOptions: [],
|
||||
search: {
|
||||
device_category_id: ''
|
||||
},
|
||||
refreshTimer: null
|
||||
}
|
||||
},
|
||||
@@ -112,6 +146,7 @@ export default {
|
||||
}
|
||||
},
|
||||
mounted () {
|
||||
this.loadDeviceCategoryOptions()
|
||||
this.fetchData()
|
||||
this.refreshTimer = setInterval(() => {
|
||||
this.fetchData(false)
|
||||
@@ -128,11 +163,47 @@ export default {
|
||||
this.activeStatus = status === 'all' ? '' : status
|
||||
this.fetchData()
|
||||
},
|
||||
normalizePayload (res) {
|
||||
const payload = res && res.data !== undefined ? res.data : (res || {})
|
||||
if (Array.isArray(payload)) {
|
||||
return { data: payload, status_num: [] }
|
||||
}
|
||||
if (payload && payload.data && !Array.isArray(payload.data) && (payload.data.data || payload.data.status_num)) {
|
||||
return payload.data
|
||||
}
|
||||
return payload || {}
|
||||
},
|
||||
normalizeList (res) {
|
||||
const payload = this.normalizePayload(res)
|
||||
if (Array.isArray(payload)) return payload
|
||||
if (Array.isArray(payload.data)) return payload.data
|
||||
if (Array.isArray(payload.list)) return payload.list
|
||||
return []
|
||||
},
|
||||
async loadDeviceCategoryOptions () {
|
||||
try {
|
||||
const res = await getDeviceCategoryAll()
|
||||
this.deviceCategoryOptions = this.normalizeList(res).map(item => ({
|
||||
value: item.id || item.device_category_id,
|
||||
label: item.name || item.device_category_name || item.code
|
||||
})).filter(item => item.value !== undefined && item.label)
|
||||
} catch { /* 类别加载失败不影响监控列表 */ }
|
||||
},
|
||||
onReset () {
|
||||
this.search.device_category_id = ''
|
||||
this.fetchData()
|
||||
},
|
||||
onSearch () {
|
||||
this.fetchData()
|
||||
},
|
||||
async fetchData (showLoading = true) {
|
||||
if (showLoading) this.loading = true
|
||||
try {
|
||||
const res = await getDeviceAll({ status: this.activeStatus })
|
||||
const payload = res && res.data ? res.data : (res || {})
|
||||
const res = await getDeviceAll({
|
||||
status: this.activeStatus,
|
||||
device_category_id: this.search.device_category_id
|
||||
})
|
||||
const payload = this.normalizePayload(res)
|
||||
this.statusNum = Array.isArray(payload.status_num) ? payload.status_num : []
|
||||
this.tableData = Array.isArray(payload.data) ? payload.data : []
|
||||
} finally {
|
||||
@@ -152,6 +223,10 @@ export default {
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.search-bar {
|
||||
padding: 0 0 10px;
|
||||
}
|
||||
|
||||
.status-board {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
|
||||
|
||||
Reference in New Issue
Block a user