parent
30e730e61b
commit
e182b977e3
2 changed files with 503 additions and 410 deletions
@ -1,430 +1,523 @@ |
|||||||
<template> |
<template> |
||||||
<el-dialog :title="rowItem.isBatch ? '批量出库' : '出库'" append-to-body :modelValue="openShow" width="90%" @close="closeDialog" fullscreen> |
<el-dialog |
||||||
<div style="height: 50px;"> |
:title="rowItem.isBatch ? '批量出库' : '出库'" |
||||||
<el-input v-model="formInline.orderId" placeholder="扫描出库单号条形码" @keyup.enter.native="changeCode" style="width: 200px;float: left;"></el-input> |
append-to-body |
||||||
<el-button type="danger" @click="delFn" style="float: right;">删除</el-button> |
:modelValue="openShow" |
||||||
</div> |
width="90%" |
||||||
|
@close="closeDialog" |
||||||
<avue-crud :option="option" :table-loading="loading" :data="data" v-model="form" v-model:page="page" ref="crud" |
fullscreen |
||||||
@search-change="searchChange" @search-reset="searchReset" :before-open="beforeOpen" |
> |
||||||
@selection-change="selectionChange" @current-change="currentChange" @size-change="sizeChange" |
<div style="height: 50px"> |
||||||
@refresh-change="refreshChange" @on-load="onLoad" @row-save="rowSave" |
<el-input |
||||||
@cell-click="cellClick"> |
v-model="formInline.orderId" |
||||||
<template #goodsCode="scope"> |
placeholder="扫描出库单号条形码" |
||||||
<el-select v-model="scope.row.goodsCode" @change="val => changeGoods(val,scope.index)"> |
@keyup.enter.native="changeCode" |
||||||
<el-option v-for="item in goodsList" :key="item.id" :label="item.goodsCode" :value="item.goodsCode"></el-option> |
style="width: 200px; float: left" |
||||||
</el-select> |
></el-input> |
||||||
</template> |
<el-button type="danger" @click="delFn" style="float: right">删除</el-button> |
||||||
<template #shId="scope"> |
</div> |
||||||
<el-select v-model="scope.row.shId" @change="val => changeWare(val,scope.index)"> |
|
||||||
<el-option v-for="item in scope.row.shList" :key="item.id" :label="item.shName" :value="item.id"></el-option> |
<avue-crud |
||||||
</el-select> |
:option="option" |
||||||
</template> |
:table-loading="loading" |
||||||
<template #slId="scope"> |
:data="data" |
||||||
<el-select v-model="scope.row.slId" @change="val => changeLocation(val,scope.index)"> |
v-model="form" |
||||||
<el-option v-for="item in scope.row.slList" :key="item.id" :label="item.location" :value="item.slId"></el-option> |
v-model:page="page" |
||||||
</el-select> |
ref="crud" |
||||||
</template> |
@search-change="searchChange" |
||||||
<template #piNo="scope"> |
@search-reset="searchReset" |
||||||
<el-select v-model="scope.row.piNo" @change="val => changePiNo(val,scope.index)"> |
:before-open="beforeOpen" |
||||||
<el-option v-for="item in scope.row.piNoList" :key="item.id" :label="item.piNo" :value="item.piNo"></el-option> |
@selection-change="selectionChange" |
||||||
</el-select> |
@current-change="currentChange" |
||||||
</template> |
@size-change="sizeChange" |
||||||
<template #outQty="scope"> |
@refresh-change="refreshChange" |
||||||
<el-input-number v-model="scope.row.outQty" :min="1" :max="scope.row.stockQty" style="width:90%;" controls-position="right"></el-input-number> |
@on-load="onLoad" |
||||||
</template> |
@row-save="rowSave" |
||||||
</avue-crud> |
@cell-click="cellClick" |
||||||
|
> |
||||||
<template #footer> |
<template #goodsCode="scope"> |
||||||
<span class="dialog-footer"> |
<el-select v-model="scope.row.goodsCode" @change="val => changeGoods(val, scope.index)"> |
||||||
<el-button @click="closeDialog">取 消</el-button> |
<el-option |
||||||
<el-button type="primary" @click="submit">确 定</el-button> |
v-for="item in goodsList" |
||||||
</span> |
:key="item.id" |
||||||
</template> |
:label="item.goodsCode" |
||||||
</el-dialog> |
:value="item.goodsCode" |
||||||
|
></el-option> |
||||||
|
</el-select> |
||||||
|
</template> |
||||||
|
<template #shId="scope"> |
||||||
|
<el-select v-model="scope.row.shId" @change="val => changeWare(val, scope.index)"> |
||||||
|
<el-option |
||||||
|
v-for="item in scope.row.shList" |
||||||
|
:key="item.id" |
||||||
|
:label="item.shName" |
||||||
|
:value="item.id" |
||||||
|
></el-option> |
||||||
|
</el-select> |
||||||
|
</template> |
||||||
|
<template #slId="scope"> |
||||||
|
<el-select v-model="scope.row.slId" @change="val => changeLocation(val, scope.index)"> |
||||||
|
<el-option |
||||||
|
v-for="item in scope.row.slList" |
||||||
|
:key="item.id" |
||||||
|
:label="item.location" |
||||||
|
:value="item.slId" |
||||||
|
></el-option> |
||||||
|
</el-select> |
||||||
|
</template> |
||||||
|
<template #piNo="scope"> |
||||||
|
<el-select v-model="scope.row.piNo" @change="val => changePiNo(val, scope.index)"> |
||||||
|
<el-option |
||||||
|
v-for="item in scope.row.piNoList" |
||||||
|
:key="item.id" |
||||||
|
:label="item.piNo" |
||||||
|
:value="item.piNo" |
||||||
|
></el-option> |
||||||
|
</el-select> |
||||||
|
</template> |
||||||
|
<template #outQty="scope"> |
||||||
|
<el-input-number |
||||||
|
v-model="scope.row.outQty" |
||||||
|
:min="1" |
||||||
|
:max="scope.row.stockQty" |
||||||
|
style="width: 90%" |
||||||
|
controls-position="right" |
||||||
|
></el-input-number> |
||||||
|
</template> |
||||||
|
</avue-crud> |
||||||
|
|
||||||
|
<template #footer> |
||||||
|
<span class="dialog-footer"> |
||||||
|
<el-button @click="closeDialog">取 消</el-button> |
||||||
|
<el-button type="primary" @click="submit">确 定</el-button> |
||||||
|
</span> |
||||||
|
</template> |
||||||
|
</el-dialog> |
||||||
</template> |
</template> |
||||||
<script> |
<script> |
||||||
import {getGoodsList,getWarehouseList,getLocationData,scanIssue,batchIssue,} from "@/api/storeManagement/glassCakeOutbound" |
import { |
||||||
|
getGoodsList, |
||||||
|
getWarehouseList, |
||||||
|
getLocationData, |
||||||
|
scanIssue, |
||||||
|
batchIssue, |
||||||
|
} from '@/api/storeManagement/glassCakeOutbound'; |
||||||
export default { |
export default { |
||||||
props: { |
props: { |
||||||
showDialog: { |
showDialog: { |
||||||
type: Boolean, |
type: Boolean, |
||||||
default: false |
default: false, |
||||||
}, |
|
||||||
rowItem: { |
|
||||||
type: Object, |
|
||||||
default: () => ({}) |
|
||||||
} |
|
||||||
}, |
}, |
||||||
data() { |
rowItem: { |
||||||
return { |
type: Object, |
||||||
openShow: false, |
default: () => ({}), |
||||||
formInline: { |
}, |
||||||
orderId: '', |
}, |
||||||
number2: '' |
data() { |
||||||
}, |
return { |
||||||
goodsList:[], |
openShow: false, |
||||||
option: { |
formInline: { |
||||||
columnSort: true, |
orderId: '', |
||||||
tip: false, |
number2: '', |
||||||
align: 'center', |
}, |
||||||
calcHeight: 32, |
goodsList: [], |
||||||
simplePage: false, |
option: { |
||||||
page: false, |
columnSort: true, |
||||||
searchShow: true, |
tip: false, |
||||||
searchMenuSpan: 6, |
align: 'center', |
||||||
searchIcon: true, |
calcHeight: 32, |
||||||
searchIndex: 3, |
simplePage: false, |
||||||
tree: false, |
page: false, |
||||||
border: true, |
searchShow: true, |
||||||
index: false, |
searchMenuSpan: 6, |
||||||
selection: true, |
searchIcon: true, |
||||||
viewBtn: false, |
searchIndex: 3, |
||||||
delBtn: false, |
tree: false, |
||||||
editBtn: true, |
border: true, |
||||||
cellEdit: true, |
index: false, |
||||||
menu: true, |
selection: true, |
||||||
|
viewBtn: false, |
||||||
editBtnText: '修改', |
delBtn: false, |
||||||
editBtnIcon: ' ', |
editBtn: true, |
||||||
delBtnIcon: ' ', |
cellEdit: true, |
||||||
addBtn: false, |
menu: true, |
||||||
labelWidth: 140, |
|
||||||
searchLabelWidth: 120, |
|
||||||
menu: false, |
|
||||||
menuWidth: 200, |
|
||||||
dialogWidth: 1200, |
|
||||||
dialogClickModal: false, |
|
||||||
searchEnter: true, |
|
||||||
excelBtn: true, |
|
||||||
gridBtn: false, |
|
||||||
searchShowBtn: false, |
|
||||||
showOverflowTooltip: true, |
|
||||||
header: false, |
|
||||||
searchLabelPosition:'left', |
|
||||||
searchLabelPosition:'left', |
|
||||||
searchGutter:24, |
|
||||||
searchSpan:6, |
|
||||||
menuAlign: 'left', |
|
||||||
gridBtn:false, |
|
||||||
searchMenuPosition:'right', |
|
||||||
addBtnIcon: ' ', |
|
||||||
viewBtnIcon: ' ', |
|
||||||
delBtnIcon: ' ', |
|
||||||
editBtnIcon: ' ', |
|
||||||
|
|
||||||
column: [ |
editBtnText: '修改', |
||||||
{ |
editBtnIcon: ' ', |
||||||
label: '车间订单号', |
delBtnIcon: ' ', |
||||||
prop: 'woCode', |
addBtn: false, |
||||||
width: 150, |
labelWidth: 140, |
||||||
search: false, |
searchLabelWidth: 120, |
||||||
}, |
menu: false, |
||||||
{ |
menuWidth: 200, |
||||||
label: '零件号', |
dialogWidth: 1200, |
||||||
prop: 'partCode', |
dialogClickModal: false, |
||||||
width: 150, |
searchEnter: true, |
||||||
search: false, |
excelBtn: true, |
||||||
}, |
gridBtn: false, |
||||||
{ |
searchShowBtn: false, |
||||||
label: '零件名称', |
showOverflowTooltip: true, |
||||||
prop: 'partName', |
header: false, |
||||||
width: 150, |
searchLabelPosition: 'left', |
||||||
search: false, |
searchLabelPosition: 'left', |
||||||
}, |
searchGutter: 24, |
||||||
{ |
searchSpan: 6, |
||||||
label: "流程卡号", |
menuAlign: 'left', |
||||||
prop: "cardNo", |
gridBtn: false, |
||||||
width: 150, |
searchMenuPosition: 'right', |
||||||
search: false, |
addBtnIcon: ' ', |
||||||
}, |
viewBtnIcon: ' ', |
||||||
{ |
delBtnIcon: ' ', |
||||||
label: "生产数量", |
editBtnIcon: ' ', |
||||||
prop: "quantity", |
|
||||||
search: false, |
|
||||||
width: 120, |
|
||||||
}, |
|
||||||
{ |
|
||||||
label: '物料号', |
|
||||||
prop: 'goodsCode', |
|
||||||
search: false, |
|
||||||
width:200, |
|
||||||
}, |
|
||||||
{ |
|
||||||
label: '物料名称', |
|
||||||
width:150, |
|
||||||
prop: 'goodsName', |
|
||||||
search: false, |
|
||||||
}, |
|
||||||
{ |
|
||||||
label: '库房', |
|
||||||
prop: 'shId', |
|
||||||
width:150, |
|
||||||
search: false, |
|
||||||
}, |
|
||||||
{ |
|
||||||
label: '库位', |
|
||||||
prop: 'slId', |
|
||||||
width:150, |
|
||||||
search: false, |
|
||||||
}, |
|
||||||
{ |
|
||||||
label: '批次号', |
|
||||||
prop: 'piNo', |
|
||||||
width:150, |
|
||||||
search: false, |
|
||||||
}, |
|
||||||
{ |
|
||||||
label: '是否印字', |
|
||||||
prop: 'printMark', |
|
||||||
width: 120, |
|
||||||
search: false, |
|
||||||
type: 'select', |
|
||||||
dicData:[ |
|
||||||
{label:'是',value:true}, |
|
||||||
{label:'否',value:false}, |
|
||||||
] |
|
||||||
}, |
|
||||||
{ |
|
||||||
label: '粉重', |
|
||||||
prop: 'powderWeight', |
|
||||||
width: 120, |
|
||||||
search: false, |
|
||||||
}, |
|
||||||
{ |
|
||||||
label: "材料号", |
|
||||||
prop: "materialNo", |
|
||||||
search: false, |
|
||||||
width: 120, |
|
||||||
}, |
|
||||||
{ |
|
||||||
label: '成型厚度', |
|
||||||
prop: 'thickness', |
|
||||||
width: 120, |
|
||||||
search: false, |
|
||||||
}, |
|
||||||
{ |
|
||||||
label: "炉批号", |
|
||||||
prop: "stovePiNo", |
|
||||||
search: false, |
|
||||||
width: 120, |
|
||||||
}, |
|
||||||
// { |
|
||||||
// label:"已出库数量", |
|
||||||
// prop: "outQuantity", |
|
||||||
// width:150, |
|
||||||
// }, |
|
||||||
{ |
|
||||||
label:"库存数量", |
|
||||||
prop: "stockQty", |
|
||||||
width:120, |
|
||||||
}, |
|
||||||
{ |
|
||||||
label:"出库数量", |
|
||||||
prop: "outQty", |
|
||||||
width:150, |
|
||||||
} |
|
||||||
] |
|
||||||
}, |
|
||||||
data: [], |
|
||||||
selectionList:[] |
|
||||||
|
|
||||||
|
column: [ |
||||||
|
{ |
||||||
|
label: '车间订单号', |
||||||
|
prop: 'woCode', |
||||||
|
width: 150, |
||||||
|
search: false, |
||||||
|
}, |
||||||
|
{ |
||||||
|
label: '零件号', |
||||||
|
prop: 'partCode', |
||||||
|
width: 150, |
||||||
|
search: false, |
||||||
|
}, |
||||||
|
{ |
||||||
|
label: '零件名称', |
||||||
|
prop: 'partName', |
||||||
|
width: 150, |
||||||
|
search: false, |
||||||
|
}, |
||||||
|
{ |
||||||
|
label: '流程卡号', |
||||||
|
prop: 'cardNo', |
||||||
|
width: 150, |
||||||
|
search: false, |
||||||
|
}, |
||||||
|
{ |
||||||
|
label: '生产数量', |
||||||
|
prop: 'quantity', |
||||||
|
search: false, |
||||||
|
width: 120, |
||||||
|
}, |
||||||
|
{ |
||||||
|
label: '物料号', |
||||||
|
prop: 'goodsCode', |
||||||
|
search: false, |
||||||
|
width: 200, |
||||||
|
}, |
||||||
|
{ |
||||||
|
label: '物料名称', |
||||||
|
width: 150, |
||||||
|
prop: 'goodsName', |
||||||
|
search: false, |
||||||
|
}, |
||||||
|
{ |
||||||
|
label: '库房', |
||||||
|
prop: 'shId', |
||||||
|
width: 150, |
||||||
|
search: false, |
||||||
|
}, |
||||||
|
{ |
||||||
|
label: '库位', |
||||||
|
prop: 'slId', |
||||||
|
width: 150, |
||||||
|
search: false, |
||||||
|
}, |
||||||
|
{ |
||||||
|
label: '批次号', |
||||||
|
prop: 'piNo', |
||||||
|
width: 150, |
||||||
|
search: false, |
||||||
|
}, |
||||||
|
{ |
||||||
|
label: '是否印字', |
||||||
|
prop: 'printMark', |
||||||
|
width: 120, |
||||||
|
search: false, |
||||||
|
type: 'select', |
||||||
|
dicData: [ |
||||||
|
{ label: '是', value: true }, |
||||||
|
{ label: '否', value: false }, |
||||||
|
], |
||||||
|
}, |
||||||
|
{ |
||||||
|
label: '粉重', |
||||||
|
prop: 'powderWeight', |
||||||
|
width: 120, |
||||||
|
search: false, |
||||||
|
}, |
||||||
|
{ |
||||||
|
label: '材料号', |
||||||
|
prop: 'materialNo', |
||||||
|
search: false, |
||||||
|
width: 120, |
||||||
|
}, |
||||||
|
{ |
||||||
|
label: '成型厚度', |
||||||
|
prop: 'thickness', |
||||||
|
width: 120, |
||||||
|
search: false, |
||||||
|
}, |
||||||
|
{ |
||||||
|
label: '炉批号', |
||||||
|
prop: 'stovePiNo', |
||||||
|
search: false, |
||||||
|
width: 120, |
||||||
|
}, |
||||||
|
// { |
||||||
|
// label:"已出库数量", |
||||||
|
// prop: "outQuantity", |
||||||
|
// width:150, |
||||||
|
// }, |
||||||
|
{ |
||||||
|
label: '库存数量', |
||||||
|
prop: 'stockQty', |
||||||
|
width: 120, |
||||||
|
}, |
||||||
|
{ |
||||||
|
label: '出库数量', |
||||||
|
prop: 'outQty', |
||||||
|
width: 150, |
||||||
|
}, |
||||||
|
], |
||||||
|
}, |
||||||
|
data: [], |
||||||
|
selectionList: [], |
||||||
|
}; |
||||||
|
}, |
||||||
|
mounted() { |
||||||
|
this.openShow = this.showDialog; |
||||||
|
this.getGoods(); |
||||||
|
this.onLoad(); |
||||||
|
}, |
||||||
|
watch: { |
||||||
|
showDialog(newVal) { |
||||||
|
this.openShow = newVal; |
||||||
|
if (newVal) { |
||||||
|
this.onLoad(); |
||||||
|
} |
||||||
|
}, |
||||||
|
rowItem: { |
||||||
|
handler() { |
||||||
|
if (this.openShow) { |
||||||
|
this.onLoad(); |
||||||
} |
} |
||||||
|
}, |
||||||
|
deep: true, |
||||||
}, |
}, |
||||||
mounted() { |
}, |
||||||
this.openShow = this.showDialog; |
methods: { |
||||||
this.getGoods() |
getGoods() { |
||||||
this.onLoad(); |
getGoodsList().then(res => { |
||||||
|
this.goodsList = res.data.data.records; |
||||||
|
}); |
||||||
}, |
}, |
||||||
watch: { |
selectionChange(list) { |
||||||
showDialog(newVal) { |
this.selectionList = list; |
||||||
this.openShow = newVal; |
}, |
||||||
if (newVal) { |
uniqueByKeys(arr, keys) { |
||||||
this.onLoad(); |
const seen = new Set(); |
||||||
} |
return arr.filter(item => { |
||||||
}, |
// 生成唯一键,例如 "1-A123" 或 "1||A123"(避免字段值包含分隔符冲突) |
||||||
rowItem: { |
const keyValue = keys.map(k => item[k]).join('||'); |
||||||
handler() { |
if (seen.has(keyValue)) { |
||||||
if (this.openShow) { |
return false; |
||||||
this.onLoad(); |
|
||||||
} |
|
||||||
}, |
|
||||||
deep: true |
|
||||||
} |
} |
||||||
|
seen.add(keyValue); |
||||||
|
return true; |
||||||
|
}); |
||||||
}, |
}, |
||||||
methods: { |
changeCode() { |
||||||
getGoods(){ |
scanIssue({ |
||||||
getGoodsList().then(res =>{ |
cardNo: this.formInline.orderId, |
||||||
this.goodsList = res.data.data.records |
}).then(res => { |
||||||
}) |
console.log('res------------', res); |
||||||
}, |
let data_ = res.data.data; |
||||||
selectionChange(list){ |
// data_[0].outQty =data_.requireQty |
||||||
this.selectionList = list; |
data_.forEach(item => { |
||||||
}, |
item.outQty = item.requireQty; |
||||||
uniqueByKeys(arr, keys) { |
}); |
||||||
const seen = new Set(); |
|
||||||
return arr.filter(item => { |
|
||||||
// 生成唯一键,例如 "1-A123" 或 "1||A123"(避免字段值包含分隔符冲突) |
|
||||||
const keyValue = keys.map(k => item[k]).join('||'); |
|
||||||
if (seen.has(keyValue)) { |
|
||||||
return false; |
|
||||||
} |
|
||||||
seen.add(keyValue); |
|
||||||
return true; |
|
||||||
}); |
|
||||||
}, |
|
||||||
changeCode() { |
|
||||||
scanIssue({ |
|
||||||
cardNo:this.formInline.orderId |
|
||||||
}).then(res =>{ |
|
||||||
console.log('res------------',res) |
|
||||||
let data = [...res.data.data,...this.data] |
|
||||||
this.data = this.uniqueByKeys(data,['id', 'cardNo']) |
|
||||||
if(this.data.length > 0){ |
|
||||||
this.data.map(item =>{ |
|
||||||
getWarehouseList({ |
|
||||||
goodsCode:item.goodsCode |
|
||||||
}).then(res =>{ |
|
||||||
item.shList = res.data.data |
|
||||||
}) |
|
||||||
getLocationData({ |
|
||||||
goodsId:item.goodsId, |
|
||||||
shId:item.shId |
|
||||||
}).then(res =>{ |
|
||||||
let data = this.uniqueById(res.data.data.records) |
|
||||||
item.slList = data |
|
||||||
}) |
|
||||||
getLocationData({ |
|
||||||
goodsId:item.goodsId, |
|
||||||
shId:item.shId, |
|
||||||
slId:item.slId |
|
||||||
}).then(res =>{ |
|
||||||
item.piNoList = res.data.data.records |
|
||||||
}) |
|
||||||
}) |
|
||||||
} |
|
||||||
}) |
|
||||||
}, |
|
||||||
changeGoods(val,index){ |
|
||||||
let tmp = this.goodsList.find(item => item.goodsCode == val) |
|
||||||
console.log('tmp------------',tmp) |
|
||||||
console.log('index------------',index) |
|
||||||
this.data[index].goodsName = tmp.goodsName |
|
||||||
this.data[index].goodsId = tmp.id |
|
||||||
this.data[index].shId = '' |
|
||||||
this.data[index].slId = '' |
|
||||||
this.data[index].stockQty = '' |
|
||||||
this.data[index].outQty = '' |
|
||||||
|
|
||||||
|
let data = [...res.data.data, ...this.data]; |
||||||
|
this.data = this.uniqueByKeys(data, ['id', 'cardNo']); |
||||||
|
if (this.data.length > 0) { |
||||||
|
this.data.map(item => { |
||||||
getWarehouseList({ |
getWarehouseList({ |
||||||
goodsCode:val |
goodsCode: item.goodsCode, |
||||||
}).then(res =>{ |
}).then(res => { |
||||||
this.data[index].shList = res.data.data |
item.shList = res.data.data; |
||||||
}) |
}); |
||||||
}, |
|
||||||
uniqueById(arr) { |
|
||||||
const seen = new Map(); |
|
||||||
for (const item of arr) { |
|
||||||
if (!seen.has(item.slId)) { |
|
||||||
seen.set(item.slId, item); |
|
||||||
} |
|
||||||
} |
|
||||||
return Array.from(seen.values()); |
|
||||||
}, |
|
||||||
changeWare(val,index){ |
|
||||||
this.data[index].stockQty = '' |
|
||||||
this.data[index].slId = '' |
|
||||||
getLocationData({ |
getLocationData({ |
||||||
goodsId:this.data[index].goodsId, |
goodsId: item.goodsId, |
||||||
shId:val |
shId: item.shId, |
||||||
}).then(res =>{ |
}).then(res => { |
||||||
let data = this.uniqueById(res.data.data.records) |
let data = this.uniqueById(res.data.data.records); |
||||||
this.data[index].slList = data |
item.slList = data; |
||||||
}) |
}); |
||||||
}, |
|
||||||
changeLocation(val,index){ |
|
||||||
console.log('val',val) |
|
||||||
this.data[index].piNo = '' |
|
||||||
this.data[index].stockQty = '' |
|
||||||
getLocationData({ |
getLocationData({ |
||||||
goodsId:this.data[index].goodsId, |
goodsId: item.goodsId, |
||||||
shId:this.data[index].shId, |
shId: item.shId, |
||||||
slId:val |
slId: item.slId, |
||||||
}).then(res =>{ |
}).then(res => { |
||||||
this.data[index].piNoList = res.data.data.records |
item.piNoList = res.data.data.records; |
||||||
}) |
|
||||||
}, |
|
||||||
changePiNo(val,index){ |
|
||||||
console.log('val',val) |
|
||||||
console.log('index',index) |
|
||||||
let tmp = this.data[index].piNoList.find(item => item.piNo == val) |
|
||||||
console.log('tmp=======',tmp) |
|
||||||
this.data[index].stockQty = tmp.usableQuantity |
|
||||||
this.data[index].rlsId = tmp.id |
|
||||||
}, |
|
||||||
closeDialog(val) { |
|
||||||
this.openShow = false |
|
||||||
this.$emit('closeDialog',val); |
|
||||||
}, |
|
||||||
submit() { |
|
||||||
// 校验通过:准备提交数据(过滤无用字段) |
|
||||||
const submitData = this.data.map(row => { |
|
||||||
const { _select,shList,slList,piNoList, ...validData } = row; // 剔除选择状态字段 |
|
||||||
return validData; |
|
||||||
}); |
}); |
||||||
console.log('submitData',submitData) |
}); |
||||||
batchIssue(submitData).then(res =>{ |
} |
||||||
if(res.data.code === 200){ |
}); |
||||||
this.$message.success("出库成功") |
}, |
||||||
this.closeDialog(true) |
|
||||||
} |
changeGoods(val, index) { |
||||||
}) |
let tmp = this.goodsList.find(item => item.goodsCode == val); |
||||||
// this.$message.success('提交成功') |
console.log('tmp------------', tmp); |
||||||
// this.openShow = false |
console.log('index------------', index); |
||||||
}, |
this.data[index].goodsName = tmp.goodsName; |
||||||
delFn() { |
this.data[index].goodsId = tmp.id; |
||||||
if(this.selectionList.length == 0){ |
this.data[index].shId = ''; |
||||||
this.$message.error('请至少选择一条数据') |
this.data[index].slId = ''; |
||||||
return |
this.data[index].stockQty = ''; |
||||||
} |
this.data[index].outQty = ''; |
||||||
|
|
||||||
|
getWarehouseList({ |
||||||
|
goodsCode: val, |
||||||
|
}).then(res => { |
||||||
|
this.data[index].shList = res.data.data; |
||||||
|
}); |
||||||
|
}, |
||||||
|
uniqueById(arr) { |
||||||
|
const seen = new Map(); |
||||||
|
for (const item of arr) { |
||||||
|
if (!seen.has(item.slId)) { |
||||||
|
seen.set(item.slId, item); |
||||||
|
} |
||||||
|
} |
||||||
|
return Array.from(seen.values()); |
||||||
|
}, |
||||||
|
changeWare(val, index) { |
||||||
|
this.data[index].stockQty = ''; |
||||||
|
this.data[index].slId = ''; |
||||||
|
getLocationData({ |
||||||
|
goodsId: this.data[index].goodsId, |
||||||
|
shId: val, |
||||||
|
}).then(res => { |
||||||
|
let data = this.uniqueById(res.data.data.records); |
||||||
|
this.data[index].slList = data; |
||||||
|
}); |
||||||
|
}, |
||||||
|
changeLocation(val, index) { |
||||||
|
console.log('val', val); |
||||||
|
this.data[index].piNo = ''; |
||||||
|
this.data[index].stockQty = ''; |
||||||
|
getLocationData({ |
||||||
|
goodsId: this.data[index].goodsId, |
||||||
|
shId: this.data[index].shId, |
||||||
|
slId: val, |
||||||
|
}).then(res => { |
||||||
|
this.data[index].piNoList = res.data.data.records; |
||||||
|
}); |
||||||
|
}, |
||||||
|
changePiNo(val, index) { |
||||||
|
console.log('val', val); |
||||||
|
console.log('index', index); |
||||||
|
let tmp = this.data[index].piNoList.find(item => item.piNo == val); |
||||||
|
console.log('tmp=======', tmp); |
||||||
|
this.data[index].stockQty = tmp.usableQuantity; |
||||||
|
this.data[index].rlsId = tmp.id; |
||||||
|
}, |
||||||
|
closeDialog(val) { |
||||||
|
this.openShow = false; |
||||||
|
this.$emit('closeDialog', val); |
||||||
|
}, |
||||||
|
submit() { |
||||||
|
// 1. 校验逻辑:遍历数据,检查出库数量是否超标 |
||||||
|
const invalidRow = this.data.filter(row => { |
||||||
|
// 获取需求数量,默认为0防止undefined |
||||||
|
const requireQty = row.requireQty || 0; |
||||||
|
// 获取当前出库数量,默认为0 |
||||||
|
const outQty = row.outQty || 0; |
||||||
|
|
||||||
this.$confirm('确定将选择数据删除?', { |
// 计算允许的最大出库数量 (需求 + 需求的20%) |
||||||
confirmButtonText: '确定', |
const maxAllowedQty = requireQty + requireQty * 0.2; |
||||||
cancelButtonText: '取消', |
|
||||||
type: 'warning', |
|
||||||
}).then(() => { |
|
||||||
// 1. 提取 arr2 中所有 id,放入 Set(提高查找效率) |
|
||||||
const arr2Ids = new Set(this.selectionList.map(item => item.id)); |
|
||||||
|
|
||||||
// 2. 过滤 arr1:只保留 id 不在 arr2Ids 中的项 |
// 如果出库数量大于允许的最大值,则视为无效行 |
||||||
const result = this.data.filter(item => !arr2Ids.has(item.id)); |
return outQty > maxAllowedQty; |
||||||
this.data = result |
}); |
||||||
// return removeApiScope(this.scopeIds); |
console.log(898989898,invalidRow) |
||||||
}) |
|
||||||
}, |
// 2. 如果存在超标数据,提示用户并终止提交 |
||||||
cellClick(row, column, cell, event) { |
if (invalidRow) { |
||||||
if (column.property === 'actualPartCode' || column.property === 'goodsKuwei') { |
// 重新计算该行的最大允许数量用于提示 |
||||||
this.$refs.crud.rowCellEdit(row, column); |
const requireQty = invalidRow[0].requireQty; |
||||||
} |
const maxAllowedQty = requireQty + (requireQty * 0.2); |
||||||
}, |
|
||||||
onLoad() { |
// 提取标识符用于提示 |
||||||
if (JSON.stringify(this.rowItem) !== '{}') { |
const identifier = invalidRow[0].cardNo; |
||||||
this.data = [{...this.rowItem}] |
|
||||||
getWarehouseList({ |
this.$message.error( |
||||||
goodsCode:this.rowItem.goodsCode |
`流程卡/零件 [${identifier}] 的出库数量超过允许最大值 (${maxAllowedQty.toFixed(0)}),请调整后重试!` |
||||||
}).then(res =>{ |
); |
||||||
this.data[0].shList = res.data.data |
return; |
||||||
}) |
} |
||||||
getLocationData({ |
// 校验通过:准备提交数据(过滤无用字段) |
||||||
goodsId:this.data[0].goodsId, |
const submitData = this.data.map(row => { |
||||||
shId:this.data[0].shId |
const { _select, shList, slList, piNoList, ...validData } = row; // 剔除选择状态字段 |
||||||
}).then(res =>{ |
return validData; |
||||||
let data = this.uniqueById(res.data.data.records) |
}); |
||||||
this.data[0].slList = data |
console.log('submitData', submitData); |
||||||
}) |
|
||||||
} |
batchIssue(submitData).then(res => { |
||||||
|
if (res.data.code === 200) { |
||||||
|
this.$message.success('出库成功'); |
||||||
|
this.closeDialog(true); |
||||||
} |
} |
||||||
} |
}); |
||||||
} |
// this.$message.success('提交成功') |
||||||
|
// this.openShow = false |
||||||
|
}, |
||||||
|
delFn() { |
||||||
|
if (this.selectionList.length == 0) { |
||||||
|
this.$message.error('请至少选择一条数据'); |
||||||
|
return; |
||||||
|
} |
||||||
|
|
||||||
|
this.$confirm('确定将选择数据删除?', { |
||||||
|
confirmButtonText: '确定', |
||||||
|
cancelButtonText: '取消', |
||||||
|
type: 'warning', |
||||||
|
}).then(() => { |
||||||
|
// 1. 提取 arr2 中所有 id,放入 Set(提高查找效率) |
||||||
|
const arr2Ids = new Set(this.selectionList.map(item => item.id)); |
||||||
|
|
||||||
|
// 2. 过滤 arr1:只保留 id 不在 arr2Ids 中的项 |
||||||
|
const result = this.data.filter(item => !arr2Ids.has(item.id)); |
||||||
|
this.data = result; |
||||||
|
// return removeApiScope(this.scopeIds); |
||||||
|
}); |
||||||
|
}, |
||||||
|
cellClick(row, column, cell, event) { |
||||||
|
if (column.property === 'actualPartCode' || column.property === 'goodsKuwei') { |
||||||
|
this.$refs.crud.rowCellEdit(row, column); |
||||||
|
} |
||||||
|
}, |
||||||
|
onLoad() { |
||||||
|
if (JSON.stringify(this.rowItem) !== '{}') { |
||||||
|
this.data = [{ ...this.rowItem }]; |
||||||
|
getWarehouseList({ |
||||||
|
goodsCode: this.rowItem.goodsCode, |
||||||
|
}).then(res => { |
||||||
|
this.data[0].shList = res.data.data; |
||||||
|
}); |
||||||
|
getLocationData({ |
||||||
|
goodsId: this.data[0].goodsId, |
||||||
|
shId: this.data[0].shId, |
||||||
|
}).then(res => { |
||||||
|
let data = this.uniqueById(res.data.data.records); |
||||||
|
this.data[0].slList = data; |
||||||
|
}); |
||||||
|
} |
||||||
|
}, |
||||||
|
}, |
||||||
|
}; |
||||||
</script> |
</script> |
||||||
<style lang="scss" scoped></style> |
<style lang="scss" scoped></style> |
||||||
Loading…
Reference in new issue