<template>
|
<el-dialog
|
width="60%"
|
title="退料详情"
|
top="5vh"
|
:visible.sync="innerVisible"
|
append-to-body
|
@close="$emit('update:currshowlist', false)"
|
:show="currshowlist"
|
class="returnstock-form-dialog"
|
>
|
<div>
|
<div style="display:flex;">
|
<div class="stock-label">
|
<span>退料单号:{{ returnStockObj.applySerialNo }}</span>
|
</div>
|
<div class="stock-label">
|
<span>申请人:{{ returnStockObj.createUser }}</span>
|
</div>
|
<div class="stock-label">
|
<span>状态:{{ stateFormat(returnStockObj.state) }}</span>
|
</div>
|
<div></div>
|
</div>
|
<el-divider></el-divider>
|
<div>
|
<div class="dialog-sub-title"><span>退料需求</span></div>
|
<div class="dialog-sub-button">
|
<el-button
|
type="primary"
|
round
|
@click="openPartDialog"
|
:disabled="returnStockObj.state == 'processed'"
|
>新增</el-button
|
><el-button type="primary" round v-thinclick="`openLocationDialog`"
|
>IFS至库位</el-button
|
><el-button type="primary" round v-thinclick="`runJob`"
|
>执行</el-button
|
>
|
</div>
|
<!--退料明细-->
|
<div>
|
<el-table
|
:data="dataList"
|
style="width: 100%;"
|
height="620px"
|
border
|
@selection-change="selectionChange"
|
stripe
|
v-loading="dataListLoading"
|
ref="palletTransportsMaterialTable"
|
>
|
<el-table-column type="selection" width="55"> </el-table-column>
|
<el-table-column
|
prop="partNo"
|
label="零件号"
|
align="center"
|
show-overflow-tooltip
|
>
|
</el-table-column>
|
<el-table-column
|
prop="partName"
|
label="零件描述"
|
align="center"
|
show-overflow-tooltip
|
>
|
</el-table-column>
|
<el-table-column
|
prop="ifsBatchNo"
|
label="IFS批次号"
|
align="center"
|
show-overflow-tooltip
|
>
|
</el-table-column>
|
<el-table-column
|
prop="sn"
|
label="SN号"
|
align="center"
|
show-overflow-tooltip
|
>
|
</el-table-column>
|
<el-table-column
|
prop="reverseQuantity"
|
label="退料数量"
|
align="center"
|
>
|
<template slot-scope="scope">
|
<el-input
|
v-show="scope.row.canEdit"
|
v-model="scope.row.reverseQuantity"
|
></el-input>
|
<span v-show="!scope.row.canEdit">{{
|
scope.row.reverseQuantity
|
}}</span>
|
</template>
|
</el-table-column>
|
<el-table-column prop="unit" label="单位" align="center">
|
</el-table-column>
|
<el-table-column
|
prop="ifsFromLocationNo"
|
label="IFS从库位"
|
align="center"
|
>
|
</el-table-column>
|
<el-table-column
|
prop="ifsToLocationNo"
|
label="IFS至库位"
|
align="center"
|
>
|
</el-table-column>
|
<el-table-column prop="state" label="状态" align="center">
|
<template slot-scope="scope">
|
<span>{{ scope.row.state == 'new' ? '新建' : '已执行' }}</span>
|
</template>
|
</el-table-column>
|
<el-table-column prop="executor" label="执行人" align="center">
|
</el-table-column>
|
<el-table-column prop="executeTime" label="执行时间" align="center">
|
</el-table-column>
|
<el-table-column label="操作" align="center" width="100">
|
<template slot-scope="scope">
|
<el-button
|
v-show="!scope.row.canEdit"
|
type="text"
|
:disabled="scope.row.state != 'new'"
|
@click="scope.row.canEdit = true"
|
>编辑</el-button
|
>
|
<el-button
|
v-show="scope.row.canEdit"
|
type="text"
|
:disabled="scope.row.state != 'new'"
|
@click="updateDetail(scope.row)"
|
>保存</el-button
|
>
|
<el-button
|
type="text"
|
:disabled="scope.row.state != 'new'"
|
:loading="deleteLoading"
|
@click="delMaterial(scope.row)"
|
>删除</el-button
|
>
|
</template>
|
</el-table-column>
|
</el-table>
|
</div>
|
<div class="avue-crud__pagination">
|
<el-pagination
|
@size-change="sizeChangeHandle"
|
@current-change="currentChangeHandle"
|
:current-page="pageIndex"
|
:page-sizes="[10, 20, 50, 100]"
|
:page-size="pageSize"
|
:total="totalPage"
|
background
|
layout="total, sizes, prev, pager, next, jumper"
|
>
|
</el-pagination>
|
</div>
|
|
<!-- 弹窗, 库存列表 -->
|
<stockPart
|
:currshowlist.sync="showPart"
|
:multi-select="true"
|
@listenToPartEvent="selectPartCallback"
|
/>
|
|
<!-- 弹窗, IFS库位列表 -->
|
<ifsLocationDialog
|
:currshowlist.sync="showLocation"
|
:transportsList="selectionArray"
|
@refreshDataList="selectLocationCallback"
|
/>
|
</div>
|
</div>
|
</el-dialog>
|
</template>
|
<script>
|
import ifsLocationDialog from '@/views/warehouse/returnstock/ifslocation-form'
|
import stockPart from '@/views/warehouse/returnstock/stock-part'
|
import {
|
detailPage,
|
detailUpdate,
|
addDetail,
|
delDetail,
|
executeReverseMoveLocation
|
} from '@/api/warehouse/returnstock'
|
export default {
|
components: { ifsLocationDialog, stockPart },
|
props: {
|
currshowlist: {
|
type: Boolean,
|
default: false
|
},
|
returnStockId: {
|
type: Number,
|
default: 0
|
},
|
returnStockObj: {
|
type: Object,
|
default: () => {
|
return {}
|
}
|
}
|
},
|
data() {
|
return {
|
innerVisible: false,
|
dataForm: {
|
id: 0,
|
applyStaffId: null,
|
staffName: null
|
},
|
selectionArray: [],
|
dataList: [],
|
pageIndex: 1,
|
pageSize: 20,
|
totalPage: 0,
|
dataListLoading: false,
|
showLocation: false,
|
showPart: false,
|
deleteLoading: false
|
}
|
},
|
watch: {
|
currshowlist() {
|
this.innerVisible = this.currshowlist
|
if (this.currshowlist) {
|
this.initData()
|
this.$nextTick(() => {
|
if (this.returnStockId) {
|
// 查询对应退料数据
|
this.getDataList()
|
}
|
})
|
}
|
}
|
},
|
methods: {
|
initData() {
|
this.dataForm.id = 0
|
this.dataForm.applyStaffId = null
|
this.dataForm.staffName = null
|
},
|
// 查询数据
|
getDataList() {
|
if (this.returnStockId) {
|
this.dataListLoading = true
|
// 查询对应退料数据
|
const queryParam = Object.assign(
|
{
|
current: this.pageIndex,
|
size: this.pageSize
|
}
|
// {
|
// stockApplyId: this.returnStockId
|
// }
|
)
|
this.dataList = []
|
detailPage(queryParam, this.returnStockId).then((response) => {
|
console.log(response)
|
const resData = response.data
|
if (resData.code === 0) {
|
this.dataList = resData.data.records
|
for (let i = 0; i < this.dataList.length; i++) {
|
this.$set(this.dataList[i], 'canEdit', false)
|
this.$set(this.dataList[i], 'reverseApplyId', this.returnStockId)
|
}
|
this.totalPage = response.data.data.total
|
}
|
})
|
this.dataListLoading = false
|
}
|
},
|
stateFormat(state) {
|
let formatVal = ''
|
if (state === 'draft') {
|
formatVal = '草稿'
|
} else if (state === 'processing') {
|
formatVal = '进行中'
|
} else {
|
formatVal = '已执行'
|
}
|
return formatVal
|
},
|
selectionChange(val) {
|
this.selectionArray = val
|
// if (this.selectionArray.length > 0) {
|
// const currPalletTransportsMaterial = this.selectionArray[
|
// this.selectionArray.length - 1
|
// ]
|
// } else {
|
// }
|
},
|
// 打开库存列表
|
openPartDialog() {
|
this.showPart = true
|
},
|
// 库存物料选中后的回调
|
selectPartCallback(rows) {
|
console.log(rows)
|
if (rows && rows.length > 0) {
|
const detailList = []
|
for (let i = 0; i < rows.length; i++) {
|
const row = rows[i]
|
|
detailList.push(
|
Object.assign({
|
stockId: row.id,
|
ifsBatchNo: row.ifsBatchNo,
|
ifsFromLocationName: row.locationName,
|
ifsFromLocationNo: row.locationNo,
|
partNo: row.partNo,
|
partName: row.partName,
|
reverseQuantity: row.availableStockQuantity,
|
sn: row.partBatchNo,
|
reverseApplyId: this.returnStockId,
|
unit: row.unit
|
})
|
)
|
}
|
// console.log(detailList)
|
addDetail(detailList).then((response) => {
|
const resData = response.data
|
if (resData.code === 0) {
|
this.getDataList()
|
this.$message.success('退料需求新增成功')
|
} else {
|
this.$message.error('退料需求新增失败')
|
}
|
})
|
} else {
|
this.$message.error('未选择数据')
|
}
|
},
|
|
// 打开ifs库位选择框
|
openLocationDialog() {
|
if (this.selectionArray.length > 0) {
|
for (let i = 0; i < this.selectionArray.length; i++) {
|
if (this.selectionArray[i].state != 'new') {
|
this.$message.error('存在已执行的退料需求,无法IFS至库位')
|
return
|
}
|
}
|
this.showLocation = true
|
} else {
|
this.$message.error('请先选择退料需求,再进行IFS库位添加')
|
}
|
},
|
// 至库存选中回调
|
selectLocationCallback() {
|
this.getDataList()
|
},
|
// 修改保存物料需求
|
updateDetail(row) {
|
const updateParam = {
|
id: row.id,
|
stockId: row.stockId,
|
ifsBatchNo: row.ifsBatchNo,
|
ifsFromLocationName: row.ifsFromLocationName,
|
ifsFromLocationNo: row.ifsFromLocationNo,
|
partNo: row.partNo,
|
partName: row.partName,
|
reverseQuantity: row.reverseQuantity,
|
sn: row.sn,
|
reverseApplyId: this.returnStockId,
|
unit: row.unit,
|
state: row.state
|
}
|
detailUpdate(updateParam).then((response) => {
|
const resData = response.data
|
if (resData.code === 0) {
|
row.canEdit = false
|
this.$message.success('保存成功')
|
} else {
|
this.$message.error('保存失败')
|
}
|
})
|
},
|
// 删除退料明细
|
delMaterial(row) {
|
if (row.state == 'new') {
|
this.deleteLoading = true
|
delDetail({ id: row.id })
|
.then((response) => {
|
this.deleteLoading = false
|
if (response.data.code === 0) {
|
this.getDataList()
|
this.$message.success('删除成功')
|
this.returnStockObj.state = response.data.data
|
} else {
|
this.$message.error('删除失败')
|
}
|
})
|
.catch((error) => {
|
this.deleteLoading = false
|
})
|
}
|
},
|
// 执行
|
runJob() {
|
if (this.selectionArray.length > 0) {
|
const ids = []
|
for (let i = 0; i < this.selectionArray.length; i++) {
|
if (!this.selectionArray[i].ifsFromLocationNo) {
|
this.$message.error('请先选择IFS至库位')
|
return
|
}
|
ids.push(this.selectionArray[i].id)
|
}
|
executeReverseMoveLocation(ids).then((response) => {
|
if (response.data.code === 0) {
|
this.getDataList()
|
this.$message.success('执行成功')
|
this.returnStockObj.state = response.data.data
|
// 刷新主表
|
this.$emit('refreshDataList')
|
} else {
|
this.$message.error('执行失败')
|
}
|
})
|
} else {
|
this.$message.error('请先选择需要执行的数据')
|
}
|
},
|
// 每页数
|
sizeChangeHandle(val) {
|
this.pageSize = val
|
this.pageIndex = 1
|
this.getDataList()
|
},
|
// 当前页
|
currentChangeHandle(val) {
|
this.pageIndex = val
|
this.getDataList()
|
}
|
}
|
}
|
</script>
|
<style>
|
.returnstock-form-dialog .el-dialog__header {
|
padding: 10px 20px 10px;
|
}
|
.returnstock-form-dialog .el-dialog__header .el-dialog__headerbtn {
|
top: 10px;
|
}
|
.returnstock-form-dialog .el-dialog__body {
|
padding: 5px 20px;
|
}
|
|
.returnstock-form-dialog .el-dialog__footer {
|
padding: 5px 20px 10px;
|
}
|
|
.returnstock-form-dialog .el-dialog__body .avue-crud__pagination {
|
margin-top: 0px;
|
margin-bottom: 5px;
|
}
|
.stock-label {
|
width: 200px;
|
}
|
.dialog-sub-title {
|
font-size: 16px;
|
margin-bottom: 5px;
|
}
|
|
.dialog-sub-button {
|
margin-bottom: 5px;
|
}
|
</style>
|