2024-07-19 13:46:52 +08:00
|
|
|
|
<template>
|
|
|
|
|
|
<div style="margin-bottom: 10px">
|
|
|
|
|
|
<el-config-provider :locale="zhCn">
|
2024-08-04 23:06:03 +08:00
|
|
|
|
<el-row>
|
|
|
|
|
|
<el-input v-model="queryKey" style="width: 256px; margin-right: 10px;" placeholder="箱号"
|
|
|
|
|
|
:suffix-icon="Search" />
|
2024-07-19 13:46:52 +08:00
|
|
|
|
<!-- <div v-if="selVehicle == null"><uploadVehicles></uploadVehicles></div> -->
|
2024-08-04 23:06:03 +08:00
|
|
|
|
<!-- <el-input v-model="queryKey" style="width: 196px; margin-left: auto; margin-right: 10px;" placeholder="箱号" /> -->
|
2024-07-19 13:46:52 +08:00
|
|
|
|
<el-button type="primary" @click="search()">搜索</el-button>
|
|
|
|
|
|
<el-button type="warning" @click="reset()">重置</el-button>
|
|
|
|
|
|
<el-button type="success" @click="exportExcel()" v-if="selVehicle == null">导出信息</el-button>
|
|
|
|
|
|
</el-row>
|
|
|
|
|
|
<br />
|
2024-08-04 23:06:03 +08:00
|
|
|
|
<el-table :data="vehicles" stripe border v-loading="loading" class="table-class" max-height="550px"
|
2024-07-19 13:46:52 +08:00
|
|
|
|
highlight-current-row @row-click="getCurrentRow" :header-cell-style="{ 'text-align': 'center' }"
|
|
|
|
|
|
:cell-style="{ 'text-align': 'center' }">
|
|
|
|
|
|
<el-table-column width="65px" fixed="left">
|
|
|
|
|
|
<template v-slot="scope">
|
|
|
|
|
|
<el-radio :label="scope.row.vehicleId" v-model="vehicleId"> </el-radio>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
</el-table-column>
|
|
|
|
|
|
<el-table-column prop="vehicleId" label="托盘号" fixed="left" min-width="120px" />
|
2024-08-04 23:06:03 +08:00
|
|
|
|
<el-table-column prop="currentLocation" label="库位" fixed="left" :formatter="locationFormat" min-width="120px" show-overflow-tooltip />
|
2024-07-19 13:46:52 +08:00
|
|
|
|
<el-table-column prop="vehicleStatus" label="状态" :formatter="vehicleStatusFormat" min-width="120px" />
|
|
|
|
|
|
<el-table-column prop="isEmpty" label="空托" :formatter="isEmptyFormat" min-width="120px" />
|
2024-08-04 23:06:03 +08:00
|
|
|
|
<el-table-column prop="lastInTime" label="最近入库时间" :formatter="timeFormat" min-width="120px" />
|
2024-07-19 13:46:52 +08:00
|
|
|
|
<el-table-column fixed="right" label="操作" width="120px" v-if="selVehicle == null">
|
|
|
|
|
|
<template v-slot="scope">
|
|
|
|
|
|
<el-button plain type="primary" @click="editCurrentRowVehicle(scope.row)">编辑</el-button>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
</el-table-column>
|
|
|
|
|
|
</el-table>
|
|
|
|
|
|
<br />
|
|
|
|
|
|
<el-pagination v-model:current-page="currentPage" v-model:page-size="pageSize" :page-sizes="[10, 25, 50]"
|
|
|
|
|
|
:small="false" :disabled="false" :background="false" :default-page-size="10"
|
|
|
|
|
|
layout="total, sizes, prev, pager, next, jumper" :total="total" @size-change="search"
|
|
|
|
|
|
@current-change="search" />
|
2024-08-04 23:06:03 +08:00
|
|
|
|
<el-dialog v-model="dialogVisible" title="料箱信息" width="40%" draggable :show-close="false">
|
2024-07-19 13:46:52 +08:00
|
|
|
|
<el-form ref="vehicleFormRef" :model="vehicleFormEntity" :label-position="labelPosition" label-width="100px"
|
|
|
|
|
|
style="max-width: 100%" :rules="rules" status-icon>
|
|
|
|
|
|
<el-row :gutter="16">
|
|
|
|
|
|
<el-col :span="12" :offset="0">
|
2024-08-04 23:06:03 +08:00
|
|
|
|
<el-form-item label="箱号" prop="vehicleId">
|
2024-07-19 13:46:52 +08:00
|
|
|
|
<el-input v-model="vehicleFormEntity.vehicleId" disabled />
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
</el-col>
|
|
|
|
|
|
<el-col :span="12">
|
|
|
|
|
|
<el-form-item label="库位" prop="locationId">
|
|
|
|
|
|
<el-input v-model="vehicleFormEntity.currentLocation" placeholder="请输入库位号" />
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
</el-col>
|
|
|
|
|
|
</el-row>
|
|
|
|
|
|
<el-row :gutter="16">
|
|
|
|
|
|
<el-col :span="12" :offset="0">
|
2024-08-04 23:06:03 +08:00
|
|
|
|
<el-form-item label="空箱" prop="isEmpty">
|
2024-07-19 13:46:52 +08:00
|
|
|
|
<el-select-v2 v-model="vehicleFormEntity.isEmpty" placeholder="请选择是否空托"
|
|
|
|
|
|
:options="isEmptyOptions"></el-select-v2>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
</el-col>
|
|
|
|
|
|
<el-col :span="12">
|
2024-08-04 23:06:03 +08:00
|
|
|
|
<el-form-item label="状态" prop="vehicleStatus">
|
2024-07-19 13:46:52 +08:00
|
|
|
|
<el-select-v2 v-model="vehicleFormEntity.vehicleStatus" placeholder="请选择托盘状态"
|
|
|
|
|
|
:options="vehicleStatusOptions"></el-select-v2>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
</el-col>
|
|
|
|
|
|
</el-row>
|
|
|
|
|
|
</el-form>
|
|
|
|
|
|
<template #footer>
|
|
|
|
|
|
<span class="dialog-footer">
|
|
|
|
|
|
<el-button @click="dialogVisible = false">取消</el-button>
|
|
|
|
|
|
<el-button type="primary" @click="submitVehicleInfo(vehicleFormEntity)">
|
|
|
|
|
|
确定
|
|
|
|
|
|
</el-button>
|
|
|
|
|
|
</span>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
</el-dialog>
|
|
|
|
|
|
</el-config-provider>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<script setup>
|
|
|
|
|
|
import { getAllVehicles, updateVehicleInfo } from '@/api/vehicle'
|
|
|
|
|
|
import zhCn from 'element-plus/dist/locale/zh-cn.mjs'
|
2024-09-12 16:56:20 +08:00
|
|
|
|
import { errorBox, successBox } from '@/utils/myMessageBox.js'
|
2024-08-04 23:06:03 +08:00
|
|
|
|
import { Search } from '@element-plus/icons-vue'
|
2024-07-19 13:46:52 +08:00
|
|
|
|
import { ref, reactive } from 'vue'
|
2024-08-01 16:39:00 +08:00
|
|
|
|
import { vehicleStatusFormatter, locationFormatter, dateFormatter, timeFormatter } from '@/utils/formatter.js'
|
2024-07-19 13:46:52 +08:00
|
|
|
|
// import uploadVehicles from '@/excel/uploadVehicles.vue'
|
|
|
|
|
|
import { downloadVehicleExcel } from '@/api/excel.js'
|
2024-08-12 16:38:52 +08:00
|
|
|
|
import store from '@/store'
|
2024-07-19 13:46:52 +08:00
|
|
|
|
</script>
|
|
|
|
|
|
<script>
|
|
|
|
|
|
export default {
|
|
|
|
|
|
name: 'vehicle',
|
|
|
|
|
|
props: ['selVehicle'],
|
|
|
|
|
|
emits: ['update:selVehicle'],
|
|
|
|
|
|
data() {
|
|
|
|
|
|
return {
|
|
|
|
|
|
vehicles: [],
|
|
|
|
|
|
currentPage: 1,
|
|
|
|
|
|
pageSize: 10,
|
|
|
|
|
|
total: 0,
|
|
|
|
|
|
queryKey: '',
|
|
|
|
|
|
loading: true,
|
|
|
|
|
|
dialogVisible: false,
|
|
|
|
|
|
vehicleId: '',
|
|
|
|
|
|
vehicleFormEntity: reactive({}),
|
|
|
|
|
|
labelPosition: 'top',
|
|
|
|
|
|
vehicleFormRef: ref(),
|
|
|
|
|
|
rules: reactive({
|
|
|
|
|
|
vehicleId: [
|
2024-08-04 23:06:03 +08:00
|
|
|
|
{ required: true, message: '请输入箱号' }
|
2024-07-19 13:46:52 +08:00
|
|
|
|
],
|
|
|
|
|
|
currentLocation: [
|
|
|
|
|
|
{ required: true, message: '请输入库位' }
|
|
|
|
|
|
]
|
|
|
|
|
|
}),
|
|
|
|
|
|
// 物料高度
|
|
|
|
|
|
isEmptyOptions: [
|
|
|
|
|
|
{
|
|
|
|
|
|
value: 0,
|
|
|
|
|
|
label: '带料'
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
value: 1,
|
|
|
|
|
|
label: '空托'
|
|
|
|
|
|
}
|
|
|
|
|
|
],
|
|
|
|
|
|
// 托盘状态
|
|
|
|
|
|
vehicleStatusOptions: [
|
|
|
|
|
|
{
|
|
|
|
|
|
value: 1,
|
|
|
|
|
|
label: '在库中'
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
value: 2,
|
|
|
|
|
|
label: '在站台'
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
value: 3,
|
|
|
|
|
|
label: '移动中'
|
|
|
|
|
|
}
|
|
|
|
|
|
]
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
mounted() {
|
|
|
|
|
|
this.search()
|
|
|
|
|
|
},
|
|
|
|
|
|
methods: {
|
|
|
|
|
|
search() {
|
|
|
|
|
|
this.loading = true
|
|
|
|
|
|
const tableRequest = {
|
|
|
|
|
|
pageNo: this.currentPage,
|
|
|
|
|
|
pageSize: this.pageSize,
|
2024-08-11 20:09:45 +08:00
|
|
|
|
vehicleId: this.queryKey.trim(),
|
|
|
|
|
|
userName: store.getters.getUserName
|
2024-07-19 13:46:52 +08:00
|
|
|
|
}
|
|
|
|
|
|
getAllVehicles(tableRequest).then(res => {
|
|
|
|
|
|
const tableResponse = res.data
|
2024-08-04 23:06:03 +08:00
|
|
|
|
if (tableResponse.code == 0) {
|
|
|
|
|
|
this.vehicles = tableResponse.returnData.lists
|
|
|
|
|
|
this.total = tableResponse.returnData.total
|
|
|
|
|
|
} else {
|
2024-09-12 16:56:20 +08:00
|
|
|
|
errorBox(tableResponse.message)
|
2024-07-19 13:46:52 +08:00
|
|
|
|
}
|
|
|
|
|
|
}).catch(err => {
|
2024-09-12 16:56:20 +08:00
|
|
|
|
console.log(err)
|
|
|
|
|
|
errorBox('查询料箱信息错误')
|
2024-07-19 13:46:52 +08:00
|
|
|
|
})
|
|
|
|
|
|
this.loading = false
|
|
|
|
|
|
},
|
|
|
|
|
|
vehicleStatusFormat: (row, column, cellValue, index) => {
|
|
|
|
|
|
return vehicleStatusFormatter(cellValue)
|
|
|
|
|
|
},
|
|
|
|
|
|
locationFormat: (row, column, cellValue, index) => {
|
|
|
|
|
|
return locationFormatter(cellValue)
|
|
|
|
|
|
},
|
2024-08-01 16:39:00 +08:00
|
|
|
|
timeFormat: (row, column, cellValue, index) => {
|
|
|
|
|
|
return timeFormatter(cellValue)
|
|
|
|
|
|
},
|
2024-07-19 13:46:52 +08:00
|
|
|
|
isEmptyFormat: (row, column, cellValue, index) => {
|
|
|
|
|
|
if (cellValue == 0) {
|
|
|
|
|
|
return '带料'
|
|
|
|
|
|
}
|
|
|
|
|
|
if (cellValue == 1) {
|
2024-08-04 23:06:03 +08:00
|
|
|
|
return '空箱'
|
2024-07-19 13:46:52 +08:00
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
reset() {
|
|
|
|
|
|
this.queryKey = ''
|
|
|
|
|
|
this.search()
|
|
|
|
|
|
},
|
|
|
|
|
|
editCurrentRowVehicle(row) {
|
2024-08-04 23:06:03 +08:00
|
|
|
|
this.vehicleFormEntity = {
|
|
|
|
|
|
vehicleId: row.vehicleId,
|
|
|
|
|
|
currentLocation: row.currentLocation,
|
|
|
|
|
|
isEmpty: row.isEmpty,
|
|
|
|
|
|
vehicleStatus: row.vehicleStatus,
|
|
|
|
|
|
lastInTime: row.lastInTime
|
|
|
|
|
|
}
|
2024-07-19 13:46:52 +08:00
|
|
|
|
this.dialogVisible = true
|
|
|
|
|
|
},
|
|
|
|
|
|
submitVehicleInfo(formData) {
|
|
|
|
|
|
const request = {
|
|
|
|
|
|
vehicleId: formData.vehicleId,
|
|
|
|
|
|
currentLocation: formData.currentLocation,
|
|
|
|
|
|
isEmpty: formData.isEmpty,
|
2024-08-04 23:06:03 +08:00
|
|
|
|
vehicleStatus: formData.vehicleStatus,
|
2024-08-11 20:09:45 +08:00
|
|
|
|
lastInTime: row.lastInTime,
|
|
|
|
|
|
userName: store.getters.getUserName
|
2024-07-19 13:46:52 +08:00
|
|
|
|
}
|
|
|
|
|
|
updateVehicleInfo(request).then(res => {
|
|
|
|
|
|
if (res.data.code == 0) {
|
|
|
|
|
|
this.dialogVisible = false
|
2024-09-12 16:56:20 +08:00
|
|
|
|
successBox('更新料箱信息成功')
|
2024-07-19 13:46:52 +08:00
|
|
|
|
this.search()
|
|
|
|
|
|
} else {
|
2024-09-12 16:56:20 +08:00
|
|
|
|
errorBox(res.data.message)
|
2024-07-19 13:46:52 +08:00
|
|
|
|
}
|
|
|
|
|
|
}).catch(err => {
|
2024-09-12 16:56:20 +08:00
|
|
|
|
console.log(err)
|
|
|
|
|
|
errorBox('更新料箱信息失败')
|
2024-07-19 13:46:52 +08:00
|
|
|
|
})
|
|
|
|
|
|
},
|
|
|
|
|
|
getCurrentRow(row) {
|
|
|
|
|
|
this.vehicleId = row.vehicleId
|
|
|
|
|
|
this.$emit('update:selVehicle', row)
|
|
|
|
|
|
},
|
|
|
|
|
|
exportExcel() {
|
|
|
|
|
|
const request = {
|
|
|
|
|
|
vehicleId: formData.vehicleId,
|
|
|
|
|
|
currentLocation: formData.currentLocation,
|
|
|
|
|
|
isEmpty: formData.isEmpty,
|
2024-08-11 20:09:45 +08:00
|
|
|
|
vehicleStatus: formData.vehicleStatus,
|
|
|
|
|
|
userName: store.getters.getUserName
|
2024-07-19 13:46:52 +08:00
|
|
|
|
}
|
|
|
|
|
|
downloadVehicleExcel(request).then(res => {
|
|
|
|
|
|
const link = document.createElement('a');//创建a标签
|
|
|
|
|
|
try {
|
|
|
|
|
|
// let blob = new Blob([res.data],{type: 'application/vnd.ms-excel'}); //如果后台返回的不是blob对象类型,先定义成blob对象格式,该type导出为xls格式,
|
|
|
|
|
|
let blob = res.data //如果后台返回的直接是blob对象类型,直接获取数据
|
|
|
|
|
|
// let _fileName = res.headers['content-disposition'].split(';')[1].split('=')[1]; //拆解获取文件名,如果后端有给返回文件名的话
|
2024-08-04 23:06:03 +08:00
|
|
|
|
let _fileName = "导出料箱信息" + dateFormatter(new Date) + ".xlsx"
|
2024-07-19 13:46:52 +08:00
|
|
|
|
link.style.display = 'none'//隐藏
|
|
|
|
|
|
|
|
|
|
|
|
// 兼容不同浏览器的URL对象
|
|
|
|
|
|
const url = window.URL || window.webkitURL || window.moxURL
|
|
|
|
|
|
link.href = url.createObjectURL(blob)
|
|
|
|
|
|
link.setAttribute('download', _fileName.substring(_fileName.lastIndexOf('_') + 1))
|
|
|
|
|
|
document.body.appendChild(link)
|
|
|
|
|
|
link.click()
|
|
|
|
|
|
document.body.removeChild(link)
|
|
|
|
|
|
url.revokeObjectURL(link.href)//移除url对象
|
|
|
|
|
|
} catch (e) {
|
2024-09-12 16:56:20 +08:00
|
|
|
|
console.log(e)
|
|
|
|
|
|
errorBox('下载文件失败')
|
2024-07-19 13:46:52 +08:00
|
|
|
|
}
|
|
|
|
|
|
}).catch(err => {
|
2024-09-12 16:56:20 +08:00
|
|
|
|
console.log(err)
|
|
|
|
|
|
errorBox('导出失败')
|
2024-07-19 13:46:52 +08:00
|
|
|
|
})
|
|
|
|
|
|
},
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
<style scoped>
|
|
|
|
|
|
.el-pagination {
|
|
|
|
|
|
padding-left: 5px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.el-row .el-button {
|
|
|
|
|
|
width: 72px;
|
|
|
|
|
|
margin-left: 0px;
|
|
|
|
|
|
margin-right: 5px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.table-class {
|
|
|
|
|
|
width: 100%;
|
|
|
|
|
|
/* font-size: 5px; */
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.el-row .el-form-item {
|
|
|
|
|
|
width: 10% inherit;
|
|
|
|
|
|
justify-content: center;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.el-row .el-form-item .el-select-v2 {
|
|
|
|
|
|
width: 100% !important;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.el-row .el-form-item .el-input-number {
|
|
|
|
|
|
width: 100% !important;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.el-row .el-form-item .el-button {
|
|
|
|
|
|
margin: auto;
|
|
|
|
|
|
}
|
|
|
|
|
|
</style>
|