feat(wms): 重构逻辑库位选择为多选并优化数据获取逻辑
- 将仓库选择组件替换为支持多选的el-select组件 - 使用warehouseQueryMap和warehouseIds动态生成查询参数 - 优化数据获取逻辑,使用flatMap处理多仓库查询结果
This commit is contained in:
@@ -19,8 +19,11 @@
|
|||||||
@keyup.enter.native="handleQuery" />
|
@keyup.enter.native="handleQuery" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="逻辑库位" prop="endTime">
|
<el-form-item label="逻辑库位" prop="endTime">
|
||||||
<warehouse-select v-model="queryParams.warehouseId" placeholder="请选择仓库/库区/库位"
|
<!-- <warehouse-select v-model="queryParams.warehouseId" placeholder="请选择仓库/库区/库位"
|
||||||
style="width: 100%; display: inline-block; width: 200px;" clearable />
|
style="width: 100%; display: inline-block; width: 200px;" clearable /> -->
|
||||||
|
<el-select v-model="warehouseIds" collapse-tags multiple placeholder="请选择逻辑库位" style="width: 200px;">
|
||||||
|
<el-option v-for="item in warehouseOptions" :key="item.value" :label="item.label" :value="item.value" />
|
||||||
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="产品名称" prop="endTime">
|
<el-form-item label="产品名称" prop="endTime">
|
||||||
<el-input style="width: 200px;" v-model="queryParams.itemName" placeholder="请输入产品名称" clearable
|
<el-input style="width: 200px;" v-model="queryParams.itemName" placeholder="请输入产品名称" clearable
|
||||||
@@ -109,7 +112,7 @@ export default {
|
|||||||
},
|
},
|
||||||
dicts: ['product_coil_status', 'coil_material', 'coil_itemname', 'coil_manufacturer'],
|
dicts: ['product_coil_status', 'coil_material', 'coil_itemname', 'coil_manufacturer'],
|
||||||
data() {
|
data() {
|
||||||
// 工具函数:个位数补零,保证格式统一(比如 9 → 09,5 → 05)
|
// 工具函数:个位数补零,保证格式统一(比如 9 → 09,5 → 05)
|
||||||
const addZero = (num) => num.toString().padStart(2, '0')
|
const addZero = (num) => num.toString().padStart(2, '0')
|
||||||
|
|
||||||
const now = new Date() // 当前本地北京时间
|
const now = new Date() // 当前本地北京时间
|
||||||
@@ -148,6 +151,40 @@ export default {
|
|||||||
itemManufacturer: '',
|
itemManufacturer: '',
|
||||||
},
|
},
|
||||||
loading: false,
|
loading: false,
|
||||||
|
warehouseIds: [
|
||||||
|
'1988150099140866050',
|
||||||
|
'1988150263284953089',
|
||||||
|
'1988150545175736322',
|
||||||
|
'1988150150521090049',
|
||||||
|
],
|
||||||
|
warehouseOptions: [
|
||||||
|
{ label: '酸连轧成品库', value: '1988150099140866050' },
|
||||||
|
{ label: '镀锌原料库', value: '1988150263284953089' },
|
||||||
|
{ label: '脱脂原料库', value: '1988150545175736322' },
|
||||||
|
{ label: '酸连轧纵剪分条原料库', value: '1988150150521090049' },
|
||||||
|
],
|
||||||
|
warehouseQueryMap: {
|
||||||
|
'1988150099140866050': {
|
||||||
|
selectType: 'product',
|
||||||
|
createBy: 'suanzhakuguan',
|
||||||
|
warehouseId: '1988150099140866050'
|
||||||
|
},
|
||||||
|
'1988150263284953089': {
|
||||||
|
selectType: 'raw_material',
|
||||||
|
createBy: 'suanzhakuguan',
|
||||||
|
warehouseId: '1988150263284953089'
|
||||||
|
},
|
||||||
|
'1988150545175736322': {
|
||||||
|
selectType: 'raw_material',
|
||||||
|
createBy: 'suanzhakuguan',
|
||||||
|
warehouseId: '1988150545175736322'
|
||||||
|
},
|
||||||
|
'1988150150521090049': {
|
||||||
|
selectType: 'raw_material',
|
||||||
|
createBy: 'suanzhakuguan',
|
||||||
|
warehouseId: '1988150150521090049'
|
||||||
|
},
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
@@ -166,49 +203,61 @@ export default {
|
|||||||
methods: {
|
methods: {
|
||||||
getList() {
|
getList() {
|
||||||
this.loading = true
|
this.loading = true
|
||||||
Promise.all([
|
Promise.all(
|
||||||
// 酸连轧成品库
|
this.warehouseIds.map(warehouseId => {
|
||||||
listCoilWithIds({
|
const params = this.warehouseQueryMap[warehouseId]
|
||||||
...this.queryParams,
|
return listCoilWithIds({
|
||||||
pageSize: 9999,
|
...this.queryParams,
|
||||||
pageNum: 1,
|
pageSize: 9999,
|
||||||
// dataType: 1,
|
pageNum: 1,
|
||||||
createBy: 'suanzhakuguan',
|
// dataType: 1,
|
||||||
warehouseId: '1988150099140866050'
|
...params
|
||||||
}),
|
})
|
||||||
// 镀锌原料库
|
})
|
||||||
listCoilWithIds({
|
// [
|
||||||
...this.queryParams,
|
// // 酸连轧成品库
|
||||||
pageSize: 9999,
|
// listCoilWithIds({
|
||||||
pageNum: 1,
|
// ...this.queryParams,
|
||||||
// dataType: 1,
|
// pageSize: 9999,
|
||||||
selectType: 'raw_material',
|
// pageNum: 1,
|
||||||
createBy: 'suanzhakuguan',
|
// // dataType: 1,
|
||||||
warehouseId: '1988150263284953089'
|
// createBy: 'suanzhakuguan',
|
||||||
}),
|
// warehouseId: '1988150099140866050'
|
||||||
// 脱脂原料库
|
// }),
|
||||||
listCoilWithIds({
|
// // 镀锌原料库
|
||||||
...this.queryParams,
|
// listCoilWithIds({
|
||||||
pageSize: 9999,
|
// ...this.queryParams,
|
||||||
pageNum: 1,
|
// pageSize: 9999,
|
||||||
// dataType: 1,
|
// pageNum: 1,
|
||||||
selectType: 'raw_material',
|
// // dataType: 1,
|
||||||
createBy: 'suanzhakuguan',
|
// selectType: 'raw_material',
|
||||||
warehouseId: '1988150545175736322'
|
// createBy: 'suanzhakuguan',
|
||||||
}),
|
// warehouseId: '1988150263284953089'
|
||||||
// 酸连轧纵剪分条原料库1988150150521090049
|
// }),
|
||||||
listCoilWithIds({
|
// // 脱脂原料库
|
||||||
...this.queryParams,
|
// listCoilWithIds({
|
||||||
pageSize: 9999,
|
// ...this.queryParams,
|
||||||
pageNum: 1,
|
// pageSize: 9999,
|
||||||
// dataType: 1,
|
// pageNum: 1,
|
||||||
selectType: 'raw_material',
|
// // dataType: 1,
|
||||||
createBy: 'suanzhakuguan',
|
// selectType: 'raw_material',
|
||||||
warehouseId: '1988150150521090049'
|
// createBy: 'suanzhakuguan',
|
||||||
}),
|
// warehouseId: '1988150545175736322'
|
||||||
]).then(([res1, res2, res3, res4]) => {
|
// }),
|
||||||
console.log(res1, res2, res3, res4)
|
// // 酸连轧纵剪分条原料库1988150150521090049
|
||||||
const list = [...res1.rows, ...res2.rows, ...res3.rows, ...res4.rows]
|
// listCoilWithIds({
|
||||||
|
// ...this.queryParams,
|
||||||
|
// pageSize: 9999,
|
||||||
|
// pageNum: 1,
|
||||||
|
// // dataType: 1,
|
||||||
|
// selectType: 'raw_material',
|
||||||
|
// createBy: 'suanzhakuguan',
|
||||||
|
// warehouseId: '1988150150521090049'
|
||||||
|
// }),
|
||||||
|
// ]
|
||||||
|
).then((resList) => {
|
||||||
|
console.log(resList)
|
||||||
|
const list = resList.flatMap(res => res.rows)
|
||||||
// 按照createTime 降序排序
|
// 按照createTime 降序排序
|
||||||
this.list = list.sort(
|
this.list = list.sort(
|
||||||
(a, b) => new Date(b.createTime) - new Date(a.createTime)
|
(a, b) => new Date(b.createTime) - new Date(a.createTime)
|
||||||
|
|||||||
@@ -19,8 +19,11 @@
|
|||||||
@keyup.enter.native="handleQuery" />
|
@keyup.enter.native="handleQuery" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="逻辑库位" prop="endTime">
|
<el-form-item label="逻辑库位" prop="endTime">
|
||||||
<warehouse-select v-model="queryParams.warehouseId" placeholder="请选择仓库/库区/库位"
|
<!-- <warehouse-select v-model="queryParams.warehouseId" placeholder="请选择仓库/库区/库位"
|
||||||
style="width: 100%; display: inline-block; width: 200px;" clearable />
|
style="width: 100%; display: inline-block; width: 200px;" clearable /> -->
|
||||||
|
<el-select v-model="warehouseIds" collapse-tags multiple placeholder="请选择逻辑库位" style="width: 200px;">
|
||||||
|
<el-option v-for="item in warehouseOptions" :key="item.value" :label="item.label" :value="item.value" />
|
||||||
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="产品名称" prop="endTime">
|
<el-form-item label="产品名称" prop="endTime">
|
||||||
<el-input style="width: 200px;" v-model="queryParams.itemName" placeholder="请输入产品名称" clearable
|
<el-input style="width: 200px;" v-model="queryParams.itemName" placeholder="请输入产品名称" clearable
|
||||||
@@ -148,6 +151,26 @@ export default {
|
|||||||
itemManufacturer: '',
|
itemManufacturer: '',
|
||||||
},
|
},
|
||||||
loading: false,
|
loading: false,
|
||||||
|
warehouseIds: [
|
||||||
|
'1988150323162836993',
|
||||||
|
'1988150487185289217',
|
||||||
|
],
|
||||||
|
warehouseOptions: [
|
||||||
|
{ value: '1988150323162836993', label: '镀锌成品库' },
|
||||||
|
{ value: '1988150487185289217', label: '镀锌纵剪分条原料库' },
|
||||||
|
],
|
||||||
|
warehouseQueryMap: {
|
||||||
|
'1988150323162836993': {
|
||||||
|
selectType: 'product',
|
||||||
|
// createBy: 'suanzhakuguan',
|
||||||
|
warehouseId: '1988150323162836993'
|
||||||
|
},
|
||||||
|
'1988150487185289217': {
|
||||||
|
selectType: 'raw_material',
|
||||||
|
// createBy: 'suanzhakuguan',
|
||||||
|
warehouseId: '1988150487185289217'
|
||||||
|
},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
@@ -167,29 +190,36 @@ export default {
|
|||||||
getList() {
|
getList() {
|
||||||
this.loading = true
|
this.loading = true
|
||||||
Promise.all([
|
Promise.all([
|
||||||
// 镀锌成品库
|
...this.warehouseIds.map(warehouseId => listCoilWithIds({
|
||||||
listCoilWithIds({
|
...this.queryParams,
|
||||||
...this.queryParams,
|
...this.warehouseQueryMap[warehouseId],
|
||||||
pageSize: 9999,
|
pageSize: 9999,
|
||||||
pageNum: 1,
|
pageNum: 1,
|
||||||
// dataType: 1,
|
// dataType: 1,
|
||||||
selectType: 'product',
|
}))
|
||||||
// createBy: 'suanzhakuguan',
|
// // 镀锌成品库
|
||||||
warehouseId: '1988150323162836993'
|
// listCoilWithIds({
|
||||||
}),
|
// ...this.queryParams,
|
||||||
// 镀锌纵剪分条原料库
|
// pageSize: 9999,
|
||||||
listCoilWithIds({
|
// pageNum: 1,
|
||||||
...this.queryParams,
|
// // dataType: 1,
|
||||||
pageSize: 9999,
|
// selectType: 'product',
|
||||||
pageNum: 1,
|
// // createBy: 'suanzhakuguan',
|
||||||
// dataType: 1,
|
// warehouseId: '1988150323162836993'
|
||||||
selectType: 'raw_material',
|
// }),
|
||||||
// createBy: 'suanzhakuguan',
|
// // 镀锌纵剪分条原料库
|
||||||
warehouseId: '1988150487185289217'
|
// listCoilWithIds({
|
||||||
}),
|
// ...this.queryParams,
|
||||||
]).then(([res1, res2]) => {
|
// pageSize: 9999,
|
||||||
console.log(res1, res2)
|
// pageNum: 1,
|
||||||
const list = [...res1.rows, ...res2.rows]
|
// // dataType: 1,
|
||||||
|
// selectType: 'raw_material',
|
||||||
|
// // createBy: 'suanzhakuguan',
|
||||||
|
// warehouseId: '1988150487185289217'
|
||||||
|
// }),
|
||||||
|
]).then((resList) => {
|
||||||
|
console.log(resList)
|
||||||
|
const list = resList.flatMap(res => res.rows)
|
||||||
// 按照createTime 降序排序
|
// 按照createTime 降序排序
|
||||||
this.list = list.sort(
|
this.list = list.sort(
|
||||||
(a, b) => new Date(b.createTime) - new Date(a.createTime)
|
(a, b) => new Date(b.createTime) - new Date(a.createTime)
|
||||||
|
|||||||
Reference in New Issue
Block a user