添加站台监控报表

This commit is contained in:
李宇奇 2025-06-11 10:10:33 +08:00
parent eee9970f05
commit 01257597c8
2 changed files with 196 additions and 156 deletions

View File

@ -1,8 +1,8 @@
import request from "@/http/request";
const getStandsByPage = (params) => {
const getAllStands = (params) => {
return request({
url: '/stand/getStandsByPage',
url: '/stand/getAllStands',
method: 'post',
data: params
})
@ -17,6 +17,6 @@ const updateStandInfo = (params) => {
}
export {
getStandsByPage,
getAllStands,
updateStandInfo
}

View File

@ -7,21 +7,13 @@
label-width="158px" style="max-width: 100%" status-icon>
<div style="display: flex;justify-content: space-between;">
<el-row>
<el-form-item label="锁定状态">
<el-select-v2 style="width: 196px;" v-model="searchQueryFormEntity.isLock" placeholder="锁定状态"
:options="addAllOptionOfOptions(lockOptions)"
<el-form-item label="站台类型">
<el-select-v2 style="width: 196px;" v-model="searchQueryFormEntity.standType" placeholder="站台类型"
:options="addAllOptionOfOptions(standTypeOptions)"
@change="search()"></el-select-v2>
</el-form-item>
<el-form-item label="占用状态">
<el-select-v2 style="width: 196px;" v-model="searchQueryFormEntity.isOccupy" placeholder="占用状态"
:options="addAllOptionOfOptions(occupyOptions)"
@change="search()"></el-select-v2>
</el-form-item>
<el-form-item label="库位号">
<el-input v-model="searchQueryFormEntity.locationId" @keyup.enter="search()" clearable/>
</el-form-item>
<el-form-item label="箱号">
<el-input v-model="searchQueryFormEntity.vehicleId" @keyup.enter="search()" clearable/>
<el-form-item label="站台ID">
<el-input v-model="searchQueryFormEntity.standId" @keyup.enter="search()" clearable/>
</el-form-item>
</el-row>
<div style="align-content: center;">
@ -40,121 +32,81 @@
@sort-change="handleSortChange">
<el-table-column width="65px" fixed="left">
<template v-slot="scope">
<el-radio :label="scope.row.locationId" v-model="locationId">&nbsp;</el-radio>
<el-radio :label="scope.row.standId" v-model="standId">&nbsp;</el-radio>
</template>
</el-table-column>
<el-table-column prop="locationId" label="库位号" fixed="left" min-width="120px" sortable="custom"
<el-table-column prop="standId" label="站台ID" fixed="left" min-width="120px" sortable="custom"
show-overflow-tooltip/>
<el-table-column prop="vehicleId" label="箱号" min-width="120px" sortable="custom"
<el-table-column prop="standName" label="站台名称" min-width="150px" sortable="custom"
show-overflow-tooltip/>
<el-table-column prop="isLock" label="锁定状态" min-width="120px" :formatter="isLockFormat"
<el-table-column prop="standType" label="站台类型" min-width="120px" :formatter="standTypeFormat"
sortable="custom"
show-overflow-tooltip/>
<el-table-column prop="isOccupy" label="占用状态" :formatter="isOccupyFormat"
<el-table-column prop="standStatus" label="站台状态" :formatter="standStatusFormat"
min-width="120px" sortable="custom"
show-overflow-tooltip/>
<el-table-column prop="equipmentId" label="设备号" min-width="120px" sortable="custom"
<el-table-column prop="standIp" label="站台IP" min-width="150px" sortable="custom"
show-overflow-tooltip/>
<el-table-column prop="tunnelId" label="巷道号" min-width="120px" sortable="custom"
<el-table-column prop="standDesc" label="站台描述" min-width="180px" sortable="custom"
show-overflow-tooltip/>
<el-table-column prop="lRow" label="排" min-width="120px" sortable="custom"
<el-table-column prop="lastUpdateTime" label="最后更新时间" min-width="180px" sortable="custom"
:formatter="timeFormat" show-overflow-tooltip/>
<el-table-column prop="lastUpdateUser" label="最后更新人" min-width="120px" sortable="custom"
show-overflow-tooltip/>
<el-table-column prop="lCol" label="列"
min-width="120px" sortable="custom" show-overflow-tooltip/>
<el-table-column prop="lLayer" label="层" min-width="120px" sortable="custom"
show-overflow-tooltip/>
<el-table-column prop="lDepth" label="深度" min-width="120px"
sortable="custom" show-overflow-tooltip/>
<el-table-column prop="subArea" label="子区域" min-width="120px" sortable="custom"
show-overflow-tooltip/>
<!-- <el-table-column fixed="right" label="操作" width="170px">
<el-table-column fixed="right" label="操作" width="170px">
<template v-slot="scope">
<div style="display: inline-block; align-content: center;">
<el-button type="primary"
@click="editCurrentRowFormEntity(scope.row)">编辑</el-button>
</div>
</template>
</el-table-column> -->
</el-table-column>
</el-table>
<br/>
<el-pagination v-model:current-page="baseTableQuery.currentPage"
v-model:page-size="baseTableQuery.pageSize" :page-sizes="[10, 25, 50]" :small="false"
:disabled="false" :background="false" :default-page-size="10" @size-change="search"
@current-change="search" layout="total, sizes, prev, pager, next, jumper"
:disabled="false" :background="false" :default-page-size="10" @size-change="handlePageSizeChange"
@current-change="processTableData" layout="total, sizes, prev, pager, next, jumper"
:total="baseTableQuery.total"/>
</div>
<el-dialog v-model="rowEditFlag" title="工作信息" width="40%" draggable :show-close="false">
<el-dialog v-model="rowEditFlag" title="站台信息" width="40%" draggable :show-close="false">
<el-form ref="rowEditFormRef" :model="rowFormEntity" :label-position="labelPosition"
label-width="100px" style="max-width: 100%" status-icon>
<el-row :gutter="16">
<el-col :span="12" :offset="0">
<el-form-item label="工作编号">
<el-input v-model="rowFormEntity.workIndex" disabled/>
<el-form-item label="站台ID">
<el-input v-model="rowFormEntity.standId" disabled/>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="工单号">
<el-input v-model="rowFormEntity.workOrder" disabled/>
<el-form-item label="站台名称">
<el-input v-model="rowFormEntity.standName"/>
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="16">
<el-col :span="12" :offset="0">
<el-form-item label="总成号">
<el-input v-model="rowFormEntity.productId" disabled/>
<el-form-item label="站台类型">
<el-select-v2 v-model="rowFormEntity.standType" placeholder="请选择站台类型"
:options="standTypeOptions"></el-select-v2>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="成品号">
<el-input v-model="rowFormEntity.singleProductId" disabled/>
<el-form-item label="站台状态">
<el-select-v2 v-model="rowFormEntity.standStatus" placeholder="请选择站台状态"
:options="standStatusOptions"></el-select-v2>
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="16">
<el-col :span="12" :offset="0">
<el-form-item label="料盒号">
<el-input v-model="rowFormEntity.boxNo" disabled/>
<el-form-item label="站台IP">
<el-input v-model="rowFormEntity.standIp"/>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="料号">
<el-input v-model="rowFormEntity.goodsId" disabled/>
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="16">
<el-col :span="12" :offset="0">
<el-form-item label="需求数量">
<el-input-number v-model.number="rowFormEntity.needNum" controls-position="right"
:min="0" disabled/>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="已完成数量">
<el-input-number v-model.number="rowFormEntity.finishNum" controls-position="right"
:min="0" :max="rowFormEntity.needNum" clearable/>
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="16">
<el-col :span="12" :offset="0">
<el-form-item label="已分配数量">
<el-input-number v-model.number="rowFormEntity.distributeNum"
controls-position="right" :min="0" :max="rowFormEntity.needNum" clearable/>
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="16">
<el-col :span="12" :offset="0">
<el-form-item label="工作状态">
<el-select-v2 v-model="rowFormEntity.workStatus" placeholder="请选择工作状态"
:options="workStatusOptions"></el-select-v2>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="缺料状态">
<el-select-v2 v-model="rowFormEntity.lackStatus" placeholder="请选择缺料状态"
:options="lackStatusOptions"></el-select-v2>
<el-form-item label="站台描述">
<el-input v-model="rowFormEntity.standDesc"/>
</el-form-item>
</el-col>
</el-row>
@ -182,37 +134,48 @@ import {ElMessage} from 'element-plus'
import {genTableRequest, addAllOptionOfOptions} from '@/utils/generator.js'
import {labelPosition} from '@/constant/form.js'
import {loading} from '@/utils/loading'
import {queryLocationsByPage} from "@/api/location";
import {lockOptions, occupyOptions} from "@/constant/options";
import {getAllStands, updateStandInfo} from "@/api/stand";
/**
* 常量定义
*/
const STAND_ID = store.getters.getStandId
const USER_NAME = store.getters.getUserName
//
const standTypeOptions = [
{ value: 1, label: '拣选站台' },
{ value: 2, label: '入库站台' }
]
//
const standStatusOptions = [
{ value: 0, label: '可用' },
{ value: 1, label: '不可用' }
]
/**
* 变量定义
*/
let maxHeight = ref(window.innerHeight * 0.55)
let tableLoading = ref(false)
let tableData = ref([])
let allTableData = ref([]) //
let baseTableQuery = reactive({
currentPage: 1,
pageSize: 10,
total: 0,
sortBy: new Map([['lDepth', true], ['lLayer', true], ['lCol', true], ['lRow', true]]),//
sortBy: new Map([['standId', true]]),// ID
standId: STAND_ID,
userName: USER_NAME
})
let searchQueryFormEntity = reactive({
locationId: '',
vehicleId: '',
isLock: -99,
isOccupy: -99
standId: '',
standType: -99
})
let searchQueryFormRef = ref()
let rowEditFlag = ref(false)
let locationId = ''
let standId = ''
let rowEditFormRef = ref()
let rowFormEntity = reactive({})
/**
@ -238,20 +201,26 @@ const resizeHeight = () => {
//
const search = () => {
tableLoading.value = true
let request = genTableRequest(baseTableQuery)
let request = {}
//
request.locationId = searchQueryFormEntity.locationId.trim()
request.vehicleId = searchQueryFormEntity.vehicleId.trim()
request.isLock = searchQueryFormEntity.isLock === -99 ? null : searchQueryFormEntity.isLock
request.isOccupy = searchQueryFormEntity.isOccupy === -99 ? null : searchQueryFormEntity.isOccupy
queryLocationsByPage(request).then((res) => {
if (searchQueryFormEntity.standId.trim()) {
request.standId = searchQueryFormEntity.standId.trim()
}
if (searchQueryFormEntity.standType !== -99) {
request.standType = searchQueryFormEntity.standType
}
getAllStands(request).then((res) => {
const response = res.data
if (response.code === 0) {
const data = response.data
if (data != null) {
tableData.value = data.lists
baseTableQuery.total = data.total
allTableData.value = data
baseTableQuery.total = data.length
//
processTableData()
} else {
allTableData.value = []
tableData.value = []
baseTableQuery.total = 0
}
@ -265,82 +234,153 @@ const search = () => {
tableLoading.value = false
})
}
const clearQuery = () => {
searchQueryFormEntity.locationId = ''
searchQueryFormEntity.vehicleId = ''
}
const handleSortChange = (data) => {
if (baseTableQuery.sortBy.has(data.prop)) {
baseTableQuery.sortBy.delete(data.prop)
//
const processTableData = () => {
let data = [...allTableData.value]
//
if (baseTableQuery.sortBy.size > 0) {
data = sortTableData(data, baseTableQuery.sortBy)
}
baseTableQuery.sortBy.set(data.prop, data.order.toLowerCase() === 'ascending')
//
const startIndex = (baseTableQuery.currentPage - 1) * baseTableQuery.pageSize
const endIndex = startIndex + baseTableQuery.pageSize
tableData.value = data.slice(startIndex, endIndex)
}
//
const sortTableData = (data, sortBy) => {
if (sortBy.size === 0) {
return data
}
return data.slice().sort((a, b) => {
for (const [key, ascending] of sortBy) {
let aValue = a[key]
let bValue = b[key]
// null/undefined
if (aValue == null && bValue == null) continue
if (aValue == null) return ascending ? 1 : -1 // null
if (bValue == null) return ascending ? -1 : 1
//
if (key === 'lastUpdateTime') {
aValue = new Date(aValue).getTime()
bValue = new Date(bValue).getTime()
}
// standType, standStatus
if (typeof aValue === 'number' && typeof bValue === 'number') {
if (aValue !== bValue) {
return ascending ? aValue - bValue : bValue - aValue
}
continue
}
//
if (typeof aValue === 'string' && typeof bValue === 'string') {
aValue = aValue.toLowerCase()
bValue = bValue.toLowerCase()
}
//
aValue = String(aValue)
bValue = String(bValue)
if (aValue < bValue) {
return ascending ? -1 : 1
}
if (aValue > bValue) {
return ascending ? 1 : -1
}
}
return 0
})
}
const clearQuery = () => {
searchQueryFormEntity.standId = ''
searchQueryFormEntity.standType = -99
//
baseTableQuery.currentPage = 1
//
baseTableQuery.sortBy.clear()
baseTableQuery.sortBy.set('standId', true) // ID
search()
}
//
const handlePageSizeChange = () => {
//
baseTableQuery.currentPage = 1
processTableData()
}
const handleSortChange = (data) => {
//
console.log('handleSortChange called with:', data)
console.log('allTableData length:', allTableData.value.length)
//
baseTableQuery.sortBy.clear()
// null
if (data.order) {
const isAscending = data.order.toLowerCase() === 'ascending'
baseTableQuery.sortBy.set(data.prop, isAscending)
console.log('Setting sort:', data.prop, isAscending)
} else {
// ordernull
baseTableQuery.sortBy.set('standId', true)
console.log('Resetting to default sort: standId')
}
//
baseTableQuery.currentPage = 1
processTableData()
}
const getCurrentRow = (row) => {
locationId = row.locationId
standId = row.standId
}
const timeFormat = (row, column, cellValue, index) => {
return timeFormatter(cellValue)
}
const isLockFormat = (row, column, cellValue, index) => {
return cellValue === 1 ? '已锁定' : '未锁定'
const standTypeFormat = (row, column, cellValue, index) => {
const typeMap = {
1: '拣选站台',
2: '入库站台'
}
return typeMap[cellValue] || '未知'
}
const isOccupyFormat = (row, column, cellValue, index) => {
return cellValue === 1 ? '占用' : '空闲'
const standStatusFormat = (row, column, cellValue, index) => {
return cellValue === 1 ? '可用' : '不可用'
}
//
const editCurrentRowFormEntity = (row) => {
// form
rowFormEntity.workIndex = row.workIndex
rowFormEntity.workOrder = row.workOrder
rowFormEntity.productId = row.productId
rowFormEntity.singleProductId = row.singleProductId
rowFormEntity.boxNo = row.boxNo
rowFormEntity.goodsId = row.goodsId
rowFormEntity.needNum = row.needNum
rowFormEntity.distributeNum = row.distributeNum
rowFormEntity.finishNum = row.finishNum
rowFormEntity.workStatus = row.workStatus
rowFormEntity.lackStatus = row.lackStatus
rowFormEntity.standId = row.standId
rowFormEntity.standName = row.standName
rowFormEntity.standType = row.standType
rowFormEntity.standStatus = row.standStatus
rowFormEntity.standIp = row.standIp
rowFormEntity.standDesc = row.standDesc
//
rowEditFlag.value = true
}
//
const closeLackWork = (row) => {
const request = {
workIndex: row.workIndex,
standId: STAND_ID,
userName: USER_NAME
}
loading.open('关闭中...')
closeCurrentWorks(request).then(res => {
const response = res.data
if (response.code == 0) {
ElMessage.success(response.message)
search()
} else {
ElMessage.error(response.message)
}
}).catch(err => {
console.log(err)
ElMessage.error('请求异常。')
}).finally(() => {
loading.close()
})
}
//
const submitUpdateRow = (rowFormEntity) => {
const request = {
workIndex: rowFormEntity.workIndex,
distributeNum: rowFormEntity.distributeNum,
finishNum: rowFormEntity.finishNum,
workStatus: rowFormEntity.workStatus,
lackStatus: rowFormEntity.lackStatus,
standId: STAND_ID,
userName: USER_NAME
standId: rowFormEntity.standId,
standName: rowFormEntity.standName,
standType: rowFormEntity.standType,
standStatus: rowFormEntity.standStatus,
standIp: rowFormEntity.standIp,
standDesc: rowFormEntity.standDesc,
userName: 'wms-web'
}
loading.open('更新中...')
updateKateWorks(request).then(res => {
updateStandInfo(request).then(res => {
if (res.data.code == 0) {
ElMessage.success('更新数据成功。')
rowEditFlag.value = false