feat: 历史记录页面的产线编码-名称改为下拉选择 & 单设备监控刷新按钮

main
zhongwenkai 3 weeks ago
parent 8a2e5d9104
commit 4fc2af2444

@ -82,7 +82,7 @@
<ContentWrap> <ContentWrap>
<el-table <el-table
ref="tableRef" v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true" row-key="id" ref="tableRef" v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true" :max-height="planTableMaxHeight" row-key="id"
@selection-change="handleSelectionChange"> @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" reserve-selection /> <el-table-column type="selection" width="55" reserve-selection />
<el-table-column <el-table-column
@ -185,6 +185,7 @@ ref="tableRef" v-loading="loading" :data="list" :stripe="true" :show-overflow-to
</el-table-column> </el-table-column>
</el-table> </el-table>
<Pagination <Pagination
ref="planPaginationRef"
:total="total" v-model:page="queryParams.pageNo" v-model:limit="queryParams.pageSize" :total="total" v-model:page="queryParams.pageNo" v-model:limit="queryParams.pageSize"
@pagination="getList" /> @pagination="getList" />
</ContentWrap> </ContentWrap>
@ -207,6 +208,17 @@ const { t } = useI18n() // 国际化
const message = useMessage() // const message = useMessage() //
const tableRef = ref() const tableRef = ref()
const planTableMaxHeight = ref(520)
const planPaginationRef = ref<HTMLElement>()
const updatePlanTableMaxHeight = async () => {
await nextTick()
const tableTop = tableRef.value?.$el?.getBoundingClientRect().top ?? 0
const paginationHeight = planPaginationRef.value?.getBoundingClientRect().height ?? 72
const pageBottomGap = 56
const availableHeight = window.innerHeight - tableTop - paginationHeight - pageBottomGap
planTableMaxHeight.value = Math.min(window.innerHeight, Math.max(240, Math.floor(availableHeight)))
}
const props = defineProps<{ const props = defineProps<{
deviceId?: number // id deviceId?: number // id
@ -279,6 +291,7 @@ async function getList() {
total.value = data.total total.value = data.total
} finally { } finally {
loading.value = false loading.value = false
updatePlanTableMaxHeight()
} }
} }
@ -380,5 +393,11 @@ onMounted(async () => {
} catch { } catch {
typeList.value = [] typeList.value = []
} }
updatePlanTableMaxHeight()
window.addEventListener('resize', updatePlanTableMaxHeight)
})
onBeforeUnmount(() => {
window.removeEventListener('resize', updatePlanTableMaxHeight)
}) })
</script> </script>

@ -133,6 +133,7 @@
</el-table> </el-table>
<!-- 分页 --> <!-- 分页 -->
<Pagination <Pagination
ref="planPaginationRef"
:total="total" :total="total"
v-model:page="queryParams.pageNo" v-model:page="queryParams.pageNo"
v-model:limit="queryParams.pageSize" v-model:limit="queryParams.pageSize"

@ -27,20 +27,26 @@
/> />
</el-form-item> </el-form-item>
<el-form-item :label="t('DataCollection.HistoryData.searchLineCodeLabel')" prop="lineNode"> <el-form-item :label="t('DataCollection.HistoryData.searchLineCodeLabel')" prop="lineNode">
<el-input <el-tree-select
v-model="queryParams.lineNode" v-model="queryParams.lineNode"
:placeholder="t('DataCollection.HistoryData.searchLineCodePlaceholder')" :data="lineTreeData"
:props="{ label: 'code', value: 'code', children: 'children' }"
check-strictly
placeholder="请选择产线编码"
clearable clearable
@keyup.enter="handleQuery" filterable
class="!w-240px" class="!w-240px"
/> />
</el-form-item> </el-form-item>
<el-form-item :label="t('DataCollection.HistoryData.searchLineNameLabel')" prop="lineName" v-show="showAllFilters"> <el-form-item :label="t('DataCollection.HistoryData.searchLineNameLabel')" prop="lineName" v-show="showAllFilters">
<el-input <el-tree-select
v-model="queryParams.lineName" v-model="queryParams.lineName"
:placeholder="t('DataCollection.HistoryData.searchLineNamePlaceholder')" :data="lineTreeData"
:props="{ label: 'name', value: 'name', children: 'children' }"
check-strictly
placeholder="请选择产线名称"
clearable clearable
@keyup.enter="handleQuery" filterable
class="!w-240px" class="!w-240px"
/> />
</el-form-item> </el-form-item>
@ -130,6 +136,7 @@
</el-table-column> </el-table-column>
</el-table> </el-table>
<Pagination <Pagination
ref="planPaginationRef"
:total="total" :total="total"
v-model:page="queryParams.pageNo" v-model:page="queryParams.pageNo"
v-model:limit="queryParams.pageSize" v-model:limit="queryParams.pageSize"
@ -170,6 +177,7 @@
import { dateFormatter } from '@/utils/formatTime' import { dateFormatter } from '@/utils/formatTime'
import download from '@/utils/download' import download from '@/utils/download'
import { DeviceApi, LineDeviceVO, LineDevicePageParams } from '@/api/iot/device' import { DeviceApi, LineDeviceVO, LineDevicePageParams } from '@/api/iot/device'
import { DeviceLineApi, DeviceLineTreeVO } from '@/api/mes/deviceline'
import HistorySingleDeviceDialog from './HistorySingleDeviceDialog.vue' import HistorySingleDeviceDialog from './HistorySingleDeviceDialog.vue'
import {useRouter} from "vue-router"; import {useRouter} from "vue-router";
// //
@ -213,6 +221,21 @@ const queryParams = reactive({
}) })
const queryFormRef = ref() const queryFormRef = ref()
const lineTreeData = ref<DeviceLineTreeVO[]>([])
const lineTreeLoading = ref(false)
/** 获取产线树数据 */
const fetchLineTree = async () => {
lineTreeLoading.value = true
try {
const res = await DeviceLineApi.getDeviceLineTree()
lineTreeData.value = Array.isArray(res) ? res : (res?.data || res?.list || [])
} catch (e) {
console.error('获取产线树失败', e)
} finally {
lineTreeLoading.value = false
}
}
const selectedIds = ref<(string | number)[]>([]) const selectedIds = ref<(string | number)[]>([])
const handleSelectionChange = (rows: LineDeviceVO[]) => { const handleSelectionChange = (rows: LineDeviceVO[]) => {
@ -269,6 +292,8 @@ const handleQuery = () => {
const resetQuery = () => { const resetQuery = () => {
queryFormRef.value?.resetFields() queryFormRef.value?.resetFields()
queryParams.lineNode = undefined
queryParams.lineName = undefined
handleQuery() handleQuery()
} }
@ -313,6 +338,7 @@ const handleSingleAnalyseView = (row: LineDeviceVO) => {
onMounted(() => { onMounted(() => {
getList() getList()
fetchLineTree()
updatePlanTableMaxHeight() updatePlanTableMaxHeight()
window.addEventListener('resize', updatePlanTableMaxHeight) window.addEventListener('resize', updatePlanTableMaxHeight)
}) })

@ -3,7 +3,10 @@
<div class="single-device-dialog"> <div class="single-device-dialog">
<div class="single-device-dialog__header"> <div class="single-device-dialog__header">
<div>{{ t('DataCollection.RealTimeMonitoring.dialogDeviceNameLabel') }}{{ deviceName || '-' }}</div> <div>{{ t('DataCollection.RealTimeMonitoring.dialogDeviceNameLabel') }}{{ deviceName || '-' }}</div>
<div>{{ t('DataCollection.RealTimeMonitoring.dialogCollectionTimeLabel') }}{{ displayTime }}</div> <div class="single-device-dialog__header-right">
<el-button :icon="Refresh" :loading="loading" size="small" @click="fetchList"></el-button>
<span>{{ t('DataCollection.RealTimeMonitoring.dialogCollectionTimeLabel') }}{{ displayTime }}</span>
</div>
</div> </div>
<ContentWrap v-loading="loading"> <ContentWrap v-loading="loading">
<div v-if="sections.length" class="single-device-dialog__table-grid"> <div v-if="sections.length" class="single-device-dialog__table-grid">
@ -53,6 +56,7 @@ v-for="col in section.columns" :key="col.prop" :prop="col.prop" :label="col.labe
<script setup lang="ts"> <script setup lang="ts">
import { formatDate } from '@/utils/formatTime' import { formatDate } from '@/utils/formatTime'
import { Refresh } from '@element-plus/icons-vue'
import { DeviceApi } from '@/api/iot/device' import { DeviceApi } from '@/api/iot/device'
type SectionColumn = { type SectionColumn = {
@ -270,6 +274,12 @@ watch(
color: var(--el-text-color-primary); color: var(--el-text-color-primary);
} }
.single-device-dialog__header-right {
display: flex;
align-items: center;
gap: 8px;
}
.single-device-dialog__table-grid { .single-device-dialog__table-grid {
display: grid; display: grid;
grid-template-columns: repeat(1, minmax(0, 1fr)); grid-template-columns: repeat(1, minmax(0, 1fr));

@ -26,20 +26,26 @@
/> />
</el-form-item> </el-form-item>
<el-form-item :label="t('DataCollection.RealTimeMonitoring.searchLineCodeLabel')" prop="lineNode"> <el-form-item :label="t('DataCollection.RealTimeMonitoring.searchLineCodeLabel')" prop="lineNode">
<el-input <el-tree-select
v-model="queryParams.lineNode" v-model="queryParams.lineNode"
:placeholder="t('DataCollection.RealTimeMonitoring.searchLineCodePlaceholder')" :data="lineTreeData"
:props="{ label: 'code', value: 'code', children: 'children' }"
check-strictly
placeholder="请选择产线编码"
clearable clearable
@keyup.enter="handleQuery" filterable
class="!w-240px" class="!w-240px"
/> />
</el-form-item> </el-form-item>
<el-form-item :label="t('DataCollection.RealTimeMonitoring.searchLineNameLabel')" prop="lineName" v-show="showAllFilters"> <el-form-item :label="t('DataCollection.RealTimeMonitoring.searchLineNameLabel')" prop="lineName" v-show="showAllFilters">
<el-input <el-tree-select
v-model="queryParams.lineName" v-model="queryParams.lineName"
:placeholder="t('DataCollection.RealTimeMonitoring.searchLineNamePlaceholder')" :data="lineTreeData"
:props="{ label: 'name', value: 'name', children: 'children' }"
check-strictly
placeholder="请选择产线名称"
clearable clearable
@keyup.enter="handleQuery" filterable
class="!w-240px" class="!w-240px"
/> />
</el-form-item> </el-form-item>
@ -153,6 +159,7 @@ import { DICT_TYPE } from '@/utils/dict'
import { dateFormatter } from '@/utils/formatTime' import { dateFormatter } from '@/utils/formatTime'
import download from '@/utils/download' import download from '@/utils/download'
import { DeviceApi, LineDeviceVO } from '@/api/iot/device' import { DeviceApi, LineDeviceVO } from '@/api/iot/device'
import { DeviceLineApi, DeviceLineTreeVO } from '@/api/mes/deviceline'
import SingleDeviceMonitorDialog from './SingleDeviceMonitorDialog.vue' import SingleDeviceMonitorDialog from './SingleDeviceMonitorDialog.vue'
defineOptions({ name: 'RealTimeMonitoring' }) defineOptions({ name: 'RealTimeMonitoring' })
@ -195,6 +202,21 @@ const queryParams = reactive({
collectionTime: undefined collectionTime: undefined
}) })
const queryFormRef = ref() const queryFormRef = ref()
const lineTreeData = ref<DeviceLineTreeVO[]>([])
const lineTreeLoading = ref(false)
/** 获取产线树数据 */
const fetchLineTree = async () => {
lineTreeLoading.value = true
try {
const res = await DeviceLineApi.getDeviceLineTree()
lineTreeData.value = Array.isArray(res) ? res : (res?.data || res?.list || [])
} catch (e) {
console.error('获取产线树失败', e)
} finally {
lineTreeLoading.value = false
}
}
const selectedIds = ref<(string | number)[]>([]) const selectedIds = ref<(string | number)[]>([])
const handleSelectionChange = (rows: LineDeviceVO[]) => { const handleSelectionChange = (rows: LineDeviceVO[]) => {
@ -243,7 +265,9 @@ const handleQuery = () => {
} }
const resetQuery = () => { const resetQuery = () => {
queryFormRef.value.resetFields() queryFormRef.value?.resetFields()
queryParams.lineNode = undefined
queryParams.lineName = undefined
handleQuery() handleQuery()
} }
@ -277,6 +301,7 @@ const handleExport = async () => {
onMounted(() => { onMounted(() => {
getList() getList()
fetchLineTree()
updatePlanTableMaxHeight() updatePlanTableMaxHeight()
window.addEventListener('resize', updatePlanTableMaxHeight) window.addEventListener('resize', updatePlanTableMaxHeight)
}) })

Loading…
Cancel
Save