forked from BaoKaiWms/202501-Wms-Kate-Wuxi
455 lines
19 KiB
Vue
455 lines
19 KiB
Vue
<template>
|
||
<el-config-provider :locale="zhCn">
|
||
<el-container class="content">
|
||
<div class="work-area">
|
||
<fieldset class="search-area">
|
||
<el-form ref="relationQueryFormRef" :model="relationQueryFormEntity" :label-position="labelPosition"
|
||
label-width="158px" style="max-width: 100%" status-icon>
|
||
<div style="display: flex;justify-content: space-between;">
|
||
<el-row>
|
||
<el-form-item label="机型">
|
||
<el-input v-model="relationQueryFormEntity.model" @keyup.enter="search()" clearable />
|
||
</el-form-item>
|
||
<el-form-item label="总成号">
|
||
<el-input v-model="relationQueryFormEntity.productId" @keyup.enter="search()" clearable />
|
||
</el-form-item>
|
||
<el-form-item label="单片号">
|
||
<el-input v-model="relationQueryFormEntity.singleProductId" @keyup.enter="search()" clearable />
|
||
</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 style="background-color: #00CED1;" class="btn-search"
|
||
@click="openUploadDialog()">导入数据</el-button>
|
||
<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="displayRelationList" 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">
|
||
<el-radio :label="scope.row.recordId" v-model="recordId"> </el-radio>
|
||
</template>
|
||
</el-table-column>
|
||
<el-table-column prop="model" label="机型" min-width="120px" sortable="custom"
|
||
show-overflow-tooltip />
|
||
<el-table-column prop="productId" label="总成号" min-width="120px" sortable="custom"
|
||
show-overflow-tooltip />
|
||
<el-table-column prop="singleProductId" label="单片号" min-width="120px" sortable="custom"
|
||
show-overflow-tooltip />
|
||
<!-- <el-table-column fixed="right" label="操作" width="120px">
|
||
<template v-slot="scope">
|
||
<el-button plain type="primary" @click="editCurrentRowStock(scope.row)">编辑</el-button>
|
||
</template>
|
||
</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"
|
||
:total="baseTableQuery.total" />
|
||
</div>
|
||
<!-- <el-dialog v-model="dialogVisible" title="库存信息" width="40%" draggable :show-close="false">
|
||
<el-form ref="stockFormRef" :model="stockFormEntity" :label-position="labelPosition"
|
||
label-width="100px" style="max-width: 100%" :rules="rules" status-icon>
|
||
<el-row :gutter="16">
|
||
<el-col :span="12" :offset="0">
|
||
<el-form-item label="库存编号" prop="stockId">
|
||
<el-input v-model="stockFormEntity.stockId" disabled />
|
||
</el-form-item>
|
||
</el-col>
|
||
<el-col :span="12">
|
||
<el-form-item label="箱号" prop="vehicleId">
|
||
<el-input v-model="stockFormEntity.vehicleId" disabled />
|
||
</el-form-item>
|
||
</el-col>
|
||
</el-row>
|
||
<el-row :gutter="16">
|
||
<el-col :span="12" :offset="0">
|
||
<el-form-item label="料号" prop="goodsId">
|
||
<el-input v-model="stockFormEntity.goodsId" disabled />
|
||
</el-form-item>
|
||
</el-col>
|
||
<el-col :span="12">
|
||
<el-form-item label="料名" prop="goodsName">
|
||
<el-input v-model="stockFormEntity.goodsName" disabled />
|
||
</el-form-item>
|
||
</el-col>
|
||
</el-row>
|
||
<el-row :gutter="16">
|
||
<el-col :span="12" :offset="0">
|
||
<el-form-item label="入库数量" prop="totalNum">
|
||
<el-input-number v-model.number="stockFormEntity.totalNum" controls-position="right"
|
||
:min="0" disabled />
|
||
</el-form-item>
|
||
</el-col>
|
||
<el-col :span="12">
|
||
<el-form-item label="剩余数量(为0时删除库存)" prop="remainNum">
|
||
<el-input-number v-model.number="stockFormEntity.remainNum"
|
||
controls-position="right" :min="0" :max="stockFormEntity.totalNum" clearable />
|
||
</el-form-item>
|
||
</el-col>
|
||
</el-row>
|
||
<el-row :gutter="16">
|
||
<el-col :span="12" :offset="0">
|
||
<el-form-item label="库位" prop="locationId">
|
||
<el-input v-model="stockFormEntity.locationId" clearable />
|
||
</el-form-item>
|
||
</el-col>
|
||
<el-col :span="12">
|
||
<el-form-item label="未使用天数" prop="noUseDays">
|
||
<el-input-number v-model.number="stockFormEntity.noUseDays"
|
||
controls-position="right" :min="0" disabled />
|
||
</el-form-item>
|
||
</el-col>
|
||
</el-row>
|
||
<el-row :gutter="16">
|
||
<el-col :span="12" :offset="0">
|
||
<el-form-item label="库存状态" prop="stockStatus">
|
||
<el-select-v2 v-model="stockFormEntity.stockStatus" placeholder="请选择库存状态"
|
||
:options="stockStatusOptions"></el-select-v2>
|
||
</el-form-item>
|
||
</el-col>
|
||
<el-col :span="12">
|
||
<el-form-item label="物料状态" prop="goodsStatus">
|
||
<el-select-v2 v-model="stockFormEntity.goodsStatus" placeholder="请选择物料状态"
|
||
:options="goodsStatusOptions"></el-select-v2>
|
||
</el-form-item>
|
||
</el-col>
|
||
</el-row>
|
||
<el-row :gutter="16">
|
||
<el-col :span="12" :offset="0">
|
||
<el-form-item label="盘点任务号" prop="inventoryTaskId">
|
||
<el-input v-model="stockFormEntity.inventoryTaskId" disabled />
|
||
</el-form-item>
|
||
</el-col>
|
||
<el-col :span="12">
|
||
<el-form-item label="是否盘点" prop="isInventory">
|
||
<el-input v-model="stockFormEntity.isInventory" disabled />
|
||
</el-form-item>
|
||
</el-col>
|
||
</el-row>
|
||
<el-row :gutter="16">
|
||
<el-col :span="12" :offset="0">
|
||
<el-form-item label="创建时间" prop="createTime">
|
||
<el-input v-model="stockFormEntity.createTime" disabled />
|
||
</el-form-item>
|
||
</el-col>
|
||
<el-col :span="12">
|
||
<el-form-item label="最近更新时间" prop="lastUpdateTime">
|
||
<el-input v-model="stockFormEntity.lastUpdateTime" disabled />
|
||
</el-form-item>
|
||
</el-col>
|
||
</el-row>
|
||
<el-row :gutter="16">
|
||
<el-col :span="12" :offset="0">
|
||
<el-form-item label="最近更新用户" prop="lastUpdateUser">
|
||
<el-input v-model="stockFormEntity.lastUpdateUser" disabled />
|
||
</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="submitStockInfo(stockFormEntity)">
|
||
确定
|
||
</el-button>
|
||
</span>
|
||
</template>
|
||
</el-dialog> -->
|
||
<el-dialog v-model="showRelationUploadDialog" title="上传配对关系" width="40%" draggable :show-close="true">
|
||
<fieldset class="search-area">
|
||
<legend>导入总成-单片对应</legend>
|
||
<UploadExcelProductExtend></UploadExcelProductExtend>
|
||
</fieldset>
|
||
</el-dialog>
|
||
</div>
|
||
</el-container>
|
||
</el-config-provider>
|
||
</template>
|
||
|
||
<script setup>
|
||
import store from '@/store'
|
||
import zhCn from 'element-plus/dist/locale/zh-cn.mjs'
|
||
import UploadExcelProductExtend from '@/excel/UploadExcelProductExtend.vue'
|
||
import { queryRelationByPage } from '@/api/kateWork.js'
|
||
import { dateFormatter, timeFormatter } from '@/utils/formatter.js'
|
||
import { ref, reactive, onMounted, nextTick, onBeforeUnmount } from 'vue'
|
||
import { ElMessage } from 'element-plus'
|
||
import { genTableRequest } from '@/utils/generator.js'
|
||
import { labelPosition } from '@/constant/form'
|
||
import { exportKittingBomRelationWithExcel } from '@/api/excel.js'
|
||
/**
|
||
* 常量定义
|
||
*/
|
||
/**
|
||
* 变量定义
|
||
*/
|
||
let maxHeight = ref(window.innerHeight * 0.55)
|
||
let tableLoading = ref(false)
|
||
let displayRelationList = ref([])
|
||
let baseTableQuery = reactive({
|
||
currentPage: 1,
|
||
pageSize: 10,
|
||
total: 0,
|
||
sortBy: new Map([['productId', true]]),// 按照成品号顺序排序
|
||
standId: store.getters.getStandId,
|
||
userName: store.getters.getUserName
|
||
})
|
||
let relationQueryFormEntity = reactive({
|
||
model: '',
|
||
productId: '',
|
||
singleProductId: ''
|
||
})
|
||
let relationQueryFormRef = ref()
|
||
let showRelationAddFlag = ref(false)
|
||
let recordId = ''
|
||
let relationAddFormRef = ref()
|
||
let relationAddFormEntity = reactive({})
|
||
let showRelationUploadDialog = ref(false)
|
||
/**
|
||
* 系统方法
|
||
*/
|
||
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)
|
||
// 设定查询参数
|
||
request.model = relationQueryFormEntity.model.trim()
|
||
request.productId = relationQueryFormEntity.productId.trim()
|
||
request.singleProductId = relationQueryFormEntity.singleProductId.trim()
|
||
queryRelationByPage(request).then((res) => {
|
||
const response = res.data
|
||
if (response.code == 0) {
|
||
const data = response.data
|
||
if (data != null) {
|
||
displayRelationList.value = data.lists
|
||
baseTableQuery.total = data.total
|
||
} else {
|
||
displayRelationList.value = []
|
||
baseTableQuery.total = 0
|
||
}
|
||
} else {
|
||
ElMessage.error(response.message)
|
||
}
|
||
}).catch(err => {
|
||
console.log(err)
|
||
ElMessage.error('查询对应关系异常。')
|
||
}).finally(() => {
|
||
tableLoading.value = false
|
||
})
|
||
}
|
||
const clearQuery = () => {
|
||
relationQueryFormEntity.model = ''
|
||
relationQueryFormEntity.productId = ''
|
||
relationQueryFormEntity.singleProductId = ''
|
||
}
|
||
const handleSortChange = (data) => {
|
||
if (baseTableQuery.sortBy.has(data.prop)) {
|
||
baseTableQuery.sortBy.delete(data.prop)
|
||
}
|
||
baseTableQuery.sortBy.set(data.prop, data.order == 'ascending')
|
||
search()
|
||
}
|
||
const getCurrentRow = (row) => {
|
||
recordId = row.recordId
|
||
}
|
||
const exportExcel = () => {
|
||
const params = {
|
||
model: relationQueryFormEntity.model,
|
||
productId: relationQueryFormEntity.productId,
|
||
singleProductId: relationQueryFormEntity.singleProductId
|
||
}
|
||
exportKittingBomRelationWithExcel(params).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]; //拆解获取文件名,如果后端有给返回文件名的话
|
||
let _fileName = "配对关系" + dateFormatter(new Date) + ".xlsx"
|
||
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) {
|
||
console.log(e)
|
||
ElMessage.error('下载文件失败')
|
||
}
|
||
}).catch(err => {
|
||
console.log(err)
|
||
ElMessage.error('导出失败')
|
||
})
|
||
}
|
||
const editCurrentRowStock = (row) => {
|
||
this.stockFormEntity = {
|
||
stockId: row.stockId,
|
||
locationId: row.locationId,
|
||
vehicleId: row.vehicleId,
|
||
stockStatus: row.stockStatus,
|
||
createTime: row.createTime,
|
||
lastUpdateTime: row.lastUpdateTime,
|
||
lastUpdateUser: row.lastUpdateUser,
|
||
isInventory: row.isInventory,
|
||
inventoryTaskId: row.inventoryTaskId,
|
||
noUseDays: row.noUseDays,
|
||
goodsId: row.goodsId,
|
||
goodsName: row.goodsName,
|
||
goodsStatus: row.goodsStatus,
|
||
remainNum: row.remainNum,
|
||
totalNum: row.totalNum
|
||
}
|
||
this.dialogVisible = true
|
||
}
|
||
const submitStockInfo = () => {
|
||
const request = {
|
||
stockId: this.stockFormEntity.stockId,
|
||
locationId: this.stockFormEntity.locationId,
|
||
vehicleId: this.stockFormEntity.vehicleId,
|
||
stockStatus: this.stockFormEntity.stockStatus,
|
||
goodsId: this.stockFormEntity.goodsId,
|
||
goodsStatus: this.stockFormEntity.goodsStatus,
|
||
remainNum: this.stockFormEntity.remainNum,
|
||
userName: store.getters.getUserName
|
||
}
|
||
updateStockInfo(request).then(res => {
|
||
if (res.data.code == 0) {
|
||
this.dialogVisible = false
|
||
ElMessage.success('更新库存成功')
|
||
this.search()
|
||
} else {
|
||
errorBox(res.data.message)
|
||
}
|
||
}).catch(err => {
|
||
console.log(err)
|
||
errorBox('更新库存失败')
|
||
})
|
||
}
|
||
const openUploadDialog = () => {
|
||
showRelationUploadDialog.value = true
|
||
}
|
||
</script>
|
||
<style scoped>
|
||
.content {
|
||
display: flex;
|
||
width: 100%;
|
||
}
|
||
|
||
.work-area {
|
||
width: 100%;
|
||
/* padding: 5px; */
|
||
}
|
||
|
||
.search-area {
|
||
margin: auto;
|
||
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;
|
||
}
|
||
|
||
.table-area {
|
||
margin: auto;
|
||
min-height: fit-content;
|
||
max-height: 60%;
|
||
margin-bottom: 10px;
|
||
min-width: inherit;
|
||
border: solid 1px;
|
||
border-radius: 10px;
|
||
box-shadow: 0px 15px 10px -15px #000;
|
||
overflow: auto;
|
||
padding: 10px;
|
||
}
|
||
|
||
.el-form-item {
|
||
margin: 5px 5px 5px 5px;
|
||
}
|
||
|
||
.el-form-item .el-input {
|
||
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;
|
||
}
|
||
</style> |