2025-03-17 15:24:14 +08:00
|
|
|
|
<template>
|
2025-03-17 19:31:38 +08:00
|
|
|
|
<el-config-provider :locale="zhCn">
|
|
|
|
|
|
<el-container class="content">
|
|
|
|
|
|
<div class="work-area">
|
|
|
|
|
|
<fieldset class="search-area">
|
|
|
|
|
|
<el-form ref="searchQueryFormRef" :model="searchQueryFormEntity" :label-position="labelPosition"
|
|
|
|
|
|
label-width="158px" style="max-width: 100%" status-icon>
|
|
|
|
|
|
<div style="display: flex;justify-content: space-between;">
|
|
|
|
|
|
<el-row>
|
2025-03-18 21:32:44 +08:00
|
|
|
|
<el-form-item label="料号">
|
|
|
|
|
|
<el-input v-model="searchQueryFormEntity.goodsId" clearable />
|
2025-03-17 19:31:38 +08:00
|
|
|
|
</el-form-item>
|
2025-03-18 21:32:44 +08:00
|
|
|
|
<el-form-item label="载具号">
|
|
|
|
|
|
<el-input v-model="searchQueryFormEntity.vehicleId" clearable />
|
2025-03-17 19:31:38 +08:00
|
|
|
|
</el-form-item>
|
|
|
|
|
|
</el-row>
|
|
|
|
|
|
<div style="align-content: center;">
|
|
|
|
|
|
<el-row>
|
|
|
|
|
|
<el-button type="primary" class="btn-search" @click="search()">查询</el-button>
|
|
|
|
|
|
<el-button type="warning" class="btn-search" @click="clearQuery()">清除输入</el-button>
|
|
|
|
|
|
</el-row>
|
|
|
|
|
|
<el-row>
|
|
|
|
|
|
<el-button type="success" class="btn-search"
|
|
|
|
|
|
@click="exportExcel()">导出excel</el-button>
|
|
|
|
|
|
</el-row>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</el-form>
|
|
|
|
|
|
</fieldset>
|
|
|
|
|
|
<div class="table-area">
|
|
|
|
|
|
<el-table :data="tableData" stripe border v-loading="tableLoading" class="table-class"
|
|
|
|
|
|
:max-height="maxHeight" highlight-current-row @row-click="getCurrentRow"
|
|
|
|
|
|
:header-cell-style="{ 'text-align': 'center' }" :cell-style="{ 'text-align': 'center' }"
|
|
|
|
|
|
@sort-change="handleSortChange">
|
|
|
|
|
|
<el-table-column width="65px" fixed="left">
|
|
|
|
|
|
<template v-slot="scope">
|
2025-03-18 21:32:44 +08:00
|
|
|
|
<el-radio :label="scope.row.updateId" v-model="updateId"> </el-radio>
|
2025-03-17 19:31:38 +08:00
|
|
|
|
</template>
|
|
|
|
|
|
</el-table-column>
|
2025-03-18 21:32:44 +08:00
|
|
|
|
<el-table-column prop="updateId" label="数据编号" fixed="left" min-width="120px" sortable="custom"
|
2025-03-17 19:31:38 +08:00
|
|
|
|
show-overflow-tooltip />
|
2025-03-18 21:32:44 +08:00
|
|
|
|
<el-table-column prop="goodsId" label="料号" fixed="left" min-width="120px" sortable="custom"
|
2025-03-17 19:31:38 +08:00
|
|
|
|
show-overflow-tooltip />
|
2025-03-18 21:32:44 +08:00
|
|
|
|
<el-table-column prop="vehicleId" label="箱号" fixed="left" min-width="120px" sortable="custom"
|
2025-03-17 19:31:38 +08:00
|
|
|
|
show-overflow-tooltip />
|
2025-03-18 21:32:44 +08:00
|
|
|
|
<el-table-column prop="firstInTime" label="初次入库时间" :formatter="timeFormat" min-width="120px"
|
2025-03-17 19:31:38 +08:00
|
|
|
|
sortable="custom" show-overflow-tooltip />
|
2025-03-18 21:32:44 +08:00
|
|
|
|
<el-table-column prop="beforeNum" label="原数量" min-width="120px" sortable="custom"
|
2025-03-17 19:31:38 +08:00
|
|
|
|
show-overflow-tooltip />
|
2025-03-18 21:32:44 +08:00
|
|
|
|
<el-table-column prop="afterNum" label="新数量" min-width="120px" sortable="custom"
|
2025-03-17 19:31:38 +08:00
|
|
|
|
show-overflow-tooltip />
|
2025-03-18 21:32:44 +08:00
|
|
|
|
<el-table-column prop="reason" label="原因" min-width="120px" sortable="custom"
|
2025-03-17 19:31:38 +08:00
|
|
|
|
show-overflow-tooltip />
|
2025-03-18 21:32:44 +08:00
|
|
|
|
<el-table-column prop="updateTime" label="更新时间" :formatter="timeFormat" min-width="120px"
|
2025-03-17 19:31:38 +08:00
|
|
|
|
sortable="custom" show-overflow-tooltip />
|
2025-03-18 21:32:44 +08:00
|
|
|
|
<el-table-column prop="updateUser" label="更新用户" min-width="120px" sortable="custom"
|
|
|
|
|
|
show-overflow-tooltip />
|
2025-03-17 19:31:38 +08:00
|
|
|
|
</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"
|
|
|
|
|
|
:total="baseTableQuery.total" />
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</el-container>
|
|
|
|
|
|
</el-config-provider>
|
2025-03-17 15:24:14 +08:00
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<script setup>
|
|
|
|
|
|
import store from '@/store'
|
|
|
|
|
|
import zhCn from 'element-plus/dist/locale/zh-cn.mjs'
|
2025-03-18 21:32:44 +08:00
|
|
|
|
import { queryStockUpdateByPage } from '@/api/stock.js'
|
|
|
|
|
|
import { dateFormatter, timeFormatter } from '@/utils/formatter.js'
|
2025-03-17 19:31:38 +08:00
|
|
|
|
import { ref, reactive, onMounted, nextTick, onBeforeUnmount } from 'vue'
|
|
|
|
|
|
import { ElMessage } from 'element-plus'
|
|
|
|
|
|
import { genTableRequest } from '@/utils/generator.js'
|
|
|
|
|
|
import { labelPosition } from '@/constant/form.js'
|
|
|
|
|
|
import { loading } from '@/utils/loading'
|
2025-03-18 21:32:44 +08:00
|
|
|
|
import { exportStockUpdateExcel } from '@/api/excel.js'
|
2025-03-17 19:31:38 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 常量定义
|
|
|
|
|
|
*/
|
|
|
|
|
|
const STAND_ID = store.getters.getStandId
|
|
|
|
|
|
const USER_NAME = store.getters.getUserName
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 变量定义
|
|
|
|
|
|
*/
|
|
|
|
|
|
let maxHeight = ref(window.innerHeight * 0.55)
|
|
|
|
|
|
let tableLoading = ref(false)
|
|
|
|
|
|
let tableData = ref([])
|
|
|
|
|
|
let baseTableQuery = reactive({
|
|
|
|
|
|
currentPage: 1,
|
|
|
|
|
|
pageSize: 10,
|
|
|
|
|
|
total: 0,
|
2025-03-18 21:32:44 +08:00
|
|
|
|
sortBy: new Map([['updateTime', false]]),// 按照成品号顺序排序
|
2025-03-17 19:31:38 +08:00
|
|
|
|
standId: STAND_ID,
|
|
|
|
|
|
userName: USER_NAME
|
|
|
|
|
|
})
|
|
|
|
|
|
let searchQueryFormEntity = reactive({
|
2025-03-18 21:32:44 +08:00
|
|
|
|
vehicleId: '',
|
|
|
|
|
|
goodsId: ''
|
2025-03-17 19:31:38 +08:00
|
|
|
|
})
|
|
|
|
|
|
let searchQueryFormRef = ref()
|
2025-03-18 21:32:44 +08:00
|
|
|
|
let updateId = ''
|
2025-03-17 19:31:38 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 系统方法
|
|
|
|
|
|
*/
|
|
|
|
|
|
onMounted(() => {
|
|
|
|
|
|
nextTick(() => {
|
|
|
|
|
|
window.addEventListener('resize', resizeHeight)
|
|
|
|
|
|
search()
|
|
|
|
|
|
})
|
|
|
|
|
|
})
|
|
|
|
|
|
onBeforeUnmount(() => {
|
|
|
|
|
|
nextTick(() => {
|
|
|
|
|
|
window.removeEventListener('resize', resizeHeight)
|
|
|
|
|
|
})
|
|
|
|
|
|
})
|
|
|
|
|
|
const resizeHeight = () => {
|
|
|
|
|
|
maxHeight.value = window.innerHeight * 0.55
|
|
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 自定义方法
|
|
|
|
|
|
*/
|
|
|
|
|
|
// 查询
|
|
|
|
|
|
const search = () => {
|
|
|
|
|
|
tableLoading.value = true
|
|
|
|
|
|
let request = genTableRequest(baseTableQuery)
|
|
|
|
|
|
// 设定查询参数
|
2025-03-18 21:32:44 +08:00
|
|
|
|
request.goodsId = searchQueryFormEntity.goodsId.trim()
|
|
|
|
|
|
request.vehicleId = searchQueryFormEntity.vehicleId.trim()
|
|
|
|
|
|
queryStockUpdateByPage(request).then((res) => {
|
2025-03-17 19:31:38 +08:00
|
|
|
|
const response = res.data
|
|
|
|
|
|
if (response.code == 0) {
|
|
|
|
|
|
const data = response.data
|
|
|
|
|
|
if (data != null) {
|
|
|
|
|
|
tableData.value = data.lists
|
|
|
|
|
|
baseTableQuery.total = data.total
|
|
|
|
|
|
} else {
|
|
|
|
|
|
tableData.value = []
|
|
|
|
|
|
baseTableQuery.total = 0
|
2025-03-17 15:24:14 +08:00
|
|
|
|
}
|
2025-03-17 19:31:38 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
ElMessage.error(response.message)
|
|
|
|
|
|
}
|
|
|
|
|
|
}).catch(err => {
|
|
|
|
|
|
console.log(err)
|
|
|
|
|
|
ElMessage.error('查询数据异常。')
|
|
|
|
|
|
}).finally(() => {
|
|
|
|
|
|
tableLoading.value = false
|
|
|
|
|
|
})
|
2025-03-17 15:24:14 +08:00
|
|
|
|
}
|
2025-03-17 19:31:38 +08:00
|
|
|
|
const clearQuery = () => {
|
2025-03-18 21:32:44 +08:00
|
|
|
|
searchQueryFormEntity.goodsId = ''
|
|
|
|
|
|
searchQueryFormEntity.vehicleId = ''
|
2025-03-17 15:24:14 +08:00
|
|
|
|
}
|
2025-03-17 19:31:38 +08:00
|
|
|
|
const handleSortChange = (data) => {
|
|
|
|
|
|
if (baseTableQuery.sortBy.has(data.prop)) {
|
|
|
|
|
|
baseTableQuery.sortBy.delete(data.prop)
|
|
|
|
|
|
}
|
|
|
|
|
|
baseTableQuery.sortBy.set(data.prop, data.order == 'ascending')
|
|
|
|
|
|
search()
|
2025-03-17 15:24:14 +08:00
|
|
|
|
}
|
2025-03-17 19:31:38 +08:00
|
|
|
|
const getCurrentRow = (row) => {
|
2025-03-18 21:32:44 +08:00
|
|
|
|
updateId = row.updateId
|
2025-03-17 19:31:38 +08:00
|
|
|
|
}
|
|
|
|
|
|
const timeFormat = (row, column, cellValue, index) => {
|
|
|
|
|
|
return timeFormatter(cellValue)
|
|
|
|
|
|
}
|
|
|
|
|
|
const exportExcel = () => {
|
|
|
|
|
|
const params = {
|
2025-03-18 21:32:44 +08:00
|
|
|
|
goodsId: searchQueryFormEntity.goodsId.trim(),
|
|
|
|
|
|
vehicleId: searchQueryFormEntity.vehicleId.trim(),
|
2025-03-17 19:31:38 +08:00
|
|
|
|
standId: STAND_ID,
|
|
|
|
|
|
userName: USER_NAME
|
|
|
|
|
|
}
|
2025-03-18 21:32:44 +08:00
|
|
|
|
exportStockUpdateExcel(params).then(res => {
|
2025-03-17 19:31:38 +08:00
|
|
|
|
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]; //拆解获取文件名,如果后端有给返回文件名的话
|
2025-03-18 21:32:44 +08:00
|
|
|
|
let _fileName = '库存更新记录' + dateFormatter(new Date) + '.xlsx'
|
2025-03-17 19:31:38 +08:00
|
|
|
|
link.style.display = 'none'//隐藏
|
2025-03-17 15:24:14 +08:00
|
|
|
|
|
2025-03-17 19:31:38 +08:00
|
|
|
|
// 兼容不同浏览器的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) {
|
|
|
|
|
|
console.log(e)
|
|
|
|
|
|
ElMessage.error('下载文件失败')
|
|
|
|
|
|
}
|
|
|
|
|
|
}).catch(err => {
|
|
|
|
|
|
console.log(err)
|
|
|
|
|
|
ElMessage.error('导出失败')
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
// 编辑弹框
|
|
|
|
|
|
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
|
|
|
|
|
|
// 弹出框
|
|
|
|
|
|
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
|
|
|
|
|
|
}
|
|
|
|
|
|
loading.open('更新中...')
|
|
|
|
|
|
updateKateWorks(request).then(res => {
|
|
|
|
|
|
if (res.data.code == 0) {
|
|
|
|
|
|
ElMessage.success('更新数据成功。')
|
|
|
|
|
|
rowEditFlag.value = false
|
|
|
|
|
|
search()
|
|
|
|
|
|
} else {
|
|
|
|
|
|
ElMessage.error('更新数据失败。')
|
|
|
|
|
|
}
|
|
|
|
|
|
}).catch(err => {
|
|
|
|
|
|
console.log(err)
|
|
|
|
|
|
ElMessage.error('更新数据异常。')
|
|
|
|
|
|
}).finally(() => {
|
|
|
|
|
|
loading.close()
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
</script>
|
|
|
|
|
|
<style scoped>
|
|
|
|
|
|
.content {
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
width: 100%;
|
2025-03-17 15:24:14 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-03-17 19:31:38 +08:00
|
|
|
|
.work-area {
|
|
|
|
|
|
width: 100%;
|
|
|
|
|
|
/* padding: 5px; */
|
2025-03-17 15:24:14 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-03-17 19:31:38 +08:00
|
|
|
|
.search-area {
|
2025-03-17 15:24:14 +08:00
|
|
|
|
margin: auto;
|
2025-03-17 19:31:38 +08:00
|
|
|
|
min-height: fit-content;
|
|
|
|
|
|
max-height: 40%;
|
|
|
|
|
|
margin-bottom: 10px;
|
|
|
|
|
|
min-width: inherit;
|
|
|
|
|
|
border: solid 1px;
|
|
|
|
|
|
border-radius: 10px;
|
|
|
|
|
|
box-shadow: 0px 15px 10px -15px #000;
|
|
|
|
|
|
overflow: auto;
|
|
|
|
|
|
padding: 10px;
|
2025-03-17 15:24:14 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-03-17 19:31:38 +08:00
|
|
|
|
.table-area {
|
|
|
|
|
|
margin: auto;
|
|
|
|
|
|
min-height: fit-content;
|
|
|
|
|
|
max-height: 60%;
|
2025-03-17 15:24:14 +08:00
|
|
|
|
margin-bottom: 10px;
|
|
|
|
|
|
min-width: inherit;
|
|
|
|
|
|
border: solid 1px;
|
|
|
|
|
|
border-radius: 10px;
|
|
|
|
|
|
box-shadow: 0px 15px 10px -15px #000;
|
|
|
|
|
|
overflow: auto;
|
|
|
|
|
|
padding: 10px;
|
|
|
|
|
|
}
|
2025-03-17 19:31:38 +08:00
|
|
|
|
|
|
|
|
|
|
.el-form-item {
|
|
|
|
|
|
margin: 5px 5px 5px 5px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.el-form-item .el-input {
|
|
|
|
|
|
width: 196px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.el-form-item .el-input-number {
|
|
|
|
|
|
width: 196px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.el-form-item .el-select-v2 {
|
|
|
|
|
|
width: 196px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.table-class {
|
|
|
|
|
|
margin: 5px 5px 5px 5px;
|
|
|
|
|
|
width: inherit;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.el-pagination {
|
|
|
|
|
|
padding-left: 5px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.my-autocomplete li {
|
|
|
|
|
|
width: 196px;
|
|
|
|
|
|
line-height: normal;
|
|
|
|
|
|
padding: 7px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.my-autocomplete li .name {
|
|
|
|
|
|
text-overflow: ellipsis;
|
|
|
|
|
|
overflow: hidden;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.my-autocomplete li .addr {
|
|
|
|
|
|
font-size: 12px;
|
|
|
|
|
|
color: #b4b4b4;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.my-autocomplete li .highlighted .addr {
|
|
|
|
|
|
color: #ddd;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.my-autocomplete li .goods_id {
|
|
|
|
|
|
color: brown;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.my-autocomplete li .goods_name {
|
|
|
|
|
|
color: cornflowerblue;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.btn-search {
|
|
|
|
|
|
height: 30px;
|
|
|
|
|
|
width: 80px;
|
|
|
|
|
|
margin: auto 5px 5px auto;
|
|
|
|
|
|
color: black;
|
|
|
|
|
|
}
|
2025-03-17 15:24:14 +08:00
|
|
|
|
</style>
|