|
|
|
@ -84,6 +84,7 @@ |
|
|
|
<el-form-item label=" "> |
|
|
|
<el-button type="primary" @click="getDataList()">查询</el-button> |
|
|
|
<el-button type="primary" :disabled="this.dataListSelections.length === 0" @click="printList()">打印</el-button> |
|
|
|
<el-button v-if="canToPurchaseSubmit" type="primary" :disabled="this.dataListSelections.length === 0 || queryForm.safetyStock === '安全'" @click="openPurchaseDialog()">转采购申请</el-button> |
|
|
|
<download-excel |
|
|
|
:fields="fields()" |
|
|
|
:data="exportData" |
|
|
|
@ -174,6 +175,34 @@ |
|
|
|
layout="total, sizes, prev, pager, next, jumper"> |
|
|
|
</el-pagination> |
|
|
|
|
|
|
|
<!-- 转采购申请弹窗 --> |
|
|
|
<el-dialog title="转采购申请" :close-on-click-modal="false" v-drag :visible.sync="purchaseDialogVisible" width="900px"> |
|
|
|
<el-form label-position="top" :model="{purchaseReason: purchaseReason}"> |
|
|
|
<el-form-item label="请购原因"> |
|
|
|
<el-input v-model="purchaseReason" placeholder="请填写请购原因" style="width: 100%"></el-input> |
|
|
|
</el-form-item> |
|
|
|
</el-form> |
|
|
|
<div class="purchase-tip">请为每个备品备件单独填写采购数量:</div> |
|
|
|
<el-table :data="purchaseList" border height="360px" class="purchase-table" style="width: 100%;"> |
|
|
|
<el-table-column prop="buDesc" label="BU" min-width="90" align="center" header-align="center" show-overflow-tooltip></el-table-column> |
|
|
|
<el-table-column prop="partNo" label="备品备件编码" min-width="120" show-overflow-tooltip></el-table-column> |
|
|
|
<el-table-column prop="partDescription" label="备品备件名称" min-width="150" show-overflow-tooltip></el-table-column> |
|
|
|
<el-table-column prop="spec" label="规格型号" min-width="120" show-overflow-tooltip></el-table-column> |
|
|
|
<el-table-column prop="qtyOnHand" label="在库数量" min-width="80" align="right" header-align="center"></el-table-column> |
|
|
|
<el-table-column prop="minStock" label="最低库存" min-width="80" align="right" header-align="center"></el-table-column> |
|
|
|
<el-table-column label="采购数量" min-width="140" align="center" header-align="center"> |
|
|
|
<template slot-scope="scope"> |
|
|
|
<el-input :value="scope.row.qty" style="width: 130px" placeholder="请输入" |
|
|
|
@input="val => onQtyInput(scope.row, val)"></el-input> |
|
|
|
</template> |
|
|
|
</el-table-column> |
|
|
|
</el-table> |
|
|
|
<span slot="footer"> |
|
|
|
<el-button v-if="canToPurchaseSubmit" type="primary" :loading="purchaseSaving" @click="submitPurchase">确定</el-button> |
|
|
|
<el-button @click="purchaseDialogVisible = false">取消</el-button> |
|
|
|
</span> |
|
|
|
</el-dialog> |
|
|
|
|
|
|
|
</div> |
|
|
|
</template> |
|
|
|
|
|
|
|
@ -181,6 +210,7 @@ |
|
|
|
import { |
|
|
|
getInventoryStockList,partSpareTemp |
|
|
|
} from '@/api/partspare/inventorystock.js' |
|
|
|
import {saveFromStockApply} from '@/api/partspare/partsparePurchase.js' |
|
|
|
import { |
|
|
|
getWareHouseList, |
|
|
|
} from '@/api/partspare/wareHouseEntity.js' |
|
|
|
@ -229,6 +259,11 @@ export default { |
|
|
|
dataListLoading: false, |
|
|
|
dataListSelections: [], |
|
|
|
addOrUpdateVisible: false, |
|
|
|
// 转采购申请弹窗 |
|
|
|
purchaseDialogVisible: false, |
|
|
|
purchaseSaving: false, |
|
|
|
purchaseReason: '', |
|
|
|
purchaseList: [], |
|
|
|
// 展示列集 |
|
|
|
columnList: [], |
|
|
|
// 料号汇总 |
|
|
|
@ -741,6 +776,12 @@ export default { |
|
|
|
immediate: true |
|
|
|
} |
|
|
|
}, |
|
|
|
computed: { |
|
|
|
// 转采购申请:仅拥有 partSpare:stock:purchase 操作权限才显示按钮及提交 |
|
|
|
canToPurchaseSubmit () { |
|
|
|
return this.isAuth('partSpare:stock:purchase') |
|
|
|
} |
|
|
|
}, |
|
|
|
activated() { |
|
|
|
// this.getDataList() |
|
|
|
// this.getWareHouseList() |
|
|
|
@ -824,6 +865,91 @@ export default { |
|
|
|
partSpareTemp(this.dataListSelections) |
|
|
|
}, |
|
|
|
|
|
|
|
// 判断是否不安全库存(与“安全库存汇总=不安全”筛选一致:在库数量 <= 最低库存) |
|
|
|
isUnsafe (row) { |
|
|
|
const onHand = Number(row.qtyOnHand) || 0 |
|
|
|
const min = Number(row.minStock) |
|
|
|
if (isNaN(min)) { |
|
|
|
return false |
|
|
|
} |
|
|
|
return onHand <= min |
|
|
|
}, |
|
|
|
|
|
|
|
// 打开转采购申请弹窗 |
|
|
|
openPurchaseDialog () { |
|
|
|
const selections = this.dataListSelections |
|
|
|
if (selections.length === 0) { |
|
|
|
this.$message.warning('请先勾选需要转采购的库存数据') |
|
|
|
return |
|
|
|
} |
|
|
|
const unsafe = selections.filter(row => this.isUnsafe(row)) |
|
|
|
if (unsafe.length === 0) { |
|
|
|
this.$message.warning('请勾选不安全库存(在库数量低于最低库存)的数据') |
|
|
|
return |
|
|
|
} |
|
|
|
if (unsafe.length !== selections.length) { |
|
|
|
this.$message.warning('只能勾选不安全库存的数据,请取消安全库存的勾选') |
|
|
|
return |
|
|
|
} |
|
|
|
this.purchaseList = unsafe.map(row => ({ |
|
|
|
site: row.site, |
|
|
|
buNo: row.citemCode, |
|
|
|
buDesc: row.buDesc, |
|
|
|
partNo: row.partNo, |
|
|
|
partDescription: row.partDescription, |
|
|
|
spec: row.spec, |
|
|
|
umid: row.umid, |
|
|
|
qtyOnHand: row.qtyOnHand, |
|
|
|
minStock: row.minStock, |
|
|
|
qty: '' |
|
|
|
})) |
|
|
|
this.purchaseReason = '安全库存不足,申请补货' |
|
|
|
this.purchaseDialogVisible = true |
|
|
|
}, |
|
|
|
|
|
|
|
// 采购数量输入:只允许正整数 |
|
|
|
onQtyInput (row, val) { |
|
|
|
const num = String(val).replace(/[^\d]/g, '').replace(/^0+/, '') |
|
|
|
row.qty = num === '' ? '' : Number(num) |
|
|
|
}, |
|
|
|
|
|
|
|
// 提交:逐个产品写入待采购申请 |
|
|
|
submitPurchase () { |
|
|
|
if (!this.purchaseReason || !this.purchaseReason.trim()) { |
|
|
|
this.$message.warning('请填写请购原因') |
|
|
|
return |
|
|
|
} |
|
|
|
const invalid = this.purchaseList.some(item => !item.qty || Number(item.qty) <= 0) |
|
|
|
if (invalid) { |
|
|
|
this.$message.warning('请为每个备品备件填写大于0的采购数量') |
|
|
|
return |
|
|
|
} |
|
|
|
this.purchaseSaving = true |
|
|
|
const list = this.purchaseList.map(item => ({ |
|
|
|
site: item.site, |
|
|
|
buNo: item.buNo, |
|
|
|
partNo: item.partNo, |
|
|
|
partDescription: item.partDescription, |
|
|
|
spec: item.spec, |
|
|
|
umid: item.umid, |
|
|
|
qty: Number(item.qty), |
|
|
|
purchaseReason: this.purchaseReason |
|
|
|
})) |
|
|
|
saveFromStockApply(list).then(({ data }) => { |
|
|
|
this.purchaseSaving = false |
|
|
|
if (data && data.code === 0) { |
|
|
|
this.$message.success('已保存到待采购申请') |
|
|
|
this.purchaseDialogVisible = false |
|
|
|
this.getDataList() |
|
|
|
} else { |
|
|
|
this.$message.error(data && data.msg ? data.msg : '保存失败') |
|
|
|
} |
|
|
|
}).catch(() => { |
|
|
|
this.purchaseSaving = false |
|
|
|
this.$message.error('保存失败') |
|
|
|
}) |
|
|
|
}, |
|
|
|
|
|
|
|
// 控制单行的背景颜色 |
|
|
|
controlRowStyle ({row, rowIndex}) { |
|
|
|
// 当前行在库数量 |
|
|
|
@ -961,3 +1087,19 @@ export default { |
|
|
|
} |
|
|
|
} |
|
|
|
</script> |
|
|
|
|
|
|
|
<style scoped> |
|
|
|
.purchase-tip { |
|
|
|
font-size: 12px; |
|
|
|
color: #909399; |
|
|
|
margin-bottom: 8px; |
|
|
|
} |
|
|
|
.purchase-table /deep/ .cell { |
|
|
|
height: auto; |
|
|
|
line-height: 1.5; |
|
|
|
overflow: visible; |
|
|
|
} |
|
|
|
.purchase-table /deep/ td { |
|
|
|
padding: 4px 0; |
|
|
|
} |
|
|
|
</style> |