add::退料单增加targethource,增加分配及下推功能

This commit is contained in:
zhangzq
2026-07-31 13:16:12 +08:00
parent ebd07db3ca
commit eaea2e0540
13 changed files with 298 additions and 8 deletions

View File

@@ -9,6 +9,11 @@
<el-form-item label="退料单号">
<el-input v-model="query.orderCode" size="mini" clearable placeholder="退料单号" @keyup.enter.native="crud.toQuery" />
</el-form-item>
<el-form-item label="状态">
<el-select v-model="query.status" clearable size="mini" placeholder="全部" class="filter-item" @change="crud.toQuery">
<el-option v-for="item in statusOptions" :key="item.value" :label="item.label" :value="item.value" />
</el-select>
</el-form-item>
<el-form-item label="物料编码">
<el-input v-model="query.skuCode" size="mini" clearable placeholder="物料编码" @keyup.enter.native="crud.toQuery" />
</el-form-item>
@@ -43,20 +48,17 @@
</div>
<crudOperation :permission="permission">
<el-button slot="right" class="filter-item" type="primary" icon="el-icon-printer" size="mini" :disabled="actionDisabled" @click="printBill">打印</el-button>
<el-button slot="right" class="filter-item" type="success" icon="el-icon-s-promotion" size="mini" :disabled="isPushDisabled()" @click="handleBatchPush">下推单据</el-button>
</crudOperation>
<el-table ref="table" v-loading="crud.loading" :data="crud.data" size="mini" highlight-current-row style="width: 100%;" @selection-change="handleSelectionChange" @current-change="handleCurrentChange">
<el-table-column type="selection" width="55" />
<el-table-column v-permission="['admin','pmReturn:del','pmReturn:edit']" label="操作" width="115" align="center" fixed="right">
<template slot-scope="scope">
<udOperation :data="scope.row" :permission="permission" :disabled-edit="canUd(scope.row)" :disabled-dle="canUd(scope.row)" />
</template>
</el-table-column>
<el-table-column show-overflow-tooltip prop="orderCode" width="160" label="退料单号">
<template slot-scope="scope">
<el-link type="warning" @click="toView(scope.row)">{{ scope.row.orderCode }}</el-link>
</template>
</el-table-column>
<el-table-column show-overflow-tooltip prop="serialNo" width="90" label="序号" />
<el-table-column prop="status" width="100" label="状态" :formatter="statusFormat" />
<el-table-column show-overflow-tooltip prop="skuCode" width="140" label="物料编码" />
<el-table-column show-overflow-tooltip prop="skuName" min-width="180" label="物料名称" />
<el-table-column prop="qty" width="100" label="数量" align="right" />
@@ -68,9 +70,15 @@
<el-table-column show-overflow-tooltip prop="creator" width="100" label="操作人工号" />
<el-table-column show-overflow-tooltip prop="createTime" width="160" label="操作时间" />
<el-table-column show-overflow-tooltip prop="sourceHouseCode" width="120" label="来源仓别" />
<el-table-column prop="status" width="100" label="状态" :formatter="statusFormat" />
<el-table-column show-overflow-tooltip prop="targetHouseCode" width="120" label="目标仓库" />
<el-table-column show-overflow-tooltip prop="updateName" width="100" label="更新人" />
<el-table-column show-overflow-tooltip prop="updateTime" width="160" label="更新时间" />
<el-table-column label="操作" width="180px" align="center" fixed="right">
<template slot-scope="scope">
<udOperation style="display: inline" :data="scope.row" :permission="permission" />
<el-button size="mini" type="warning" plain style="margin-left:4px;" @click="openAllocateDialog(scope.row)">分配</el-button>
</template>
</el-table-column>
</el-table>
<pagination />
</div>
@@ -121,6 +129,22 @@
</el-form>
<div slot="footer" class="dialog-footer"><el-button type="primary" @click="viewShow = false">关闭</el-button></div>
</el-dialog>
<el-dialog :visible.sync="inventoryLoading" title="仓库分配" width="820px" :close-on-click-modal="false" @close="closeAllocateDialog">
<div style="margin-bottom:10px;color:#606266;font-size:13px;">
物料编码:<strong>{{ currentReturn.sku_code }}</strong> &nbsp;|&nbsp;
需求数量:<strong style="color:#E6A23C;">{{ currentReturn.qty }} {{ currentReturn.unit }}</strong>
</div>
<el-table ref="allocateTable" :data="inventoryList" size="small" border @selection-change="handleInventorySelection">
<el-table-column type="selection" width="45" />
<el-table-column prop="label" label="仓库编号" min-width="130" show-overflow-tooltip />
<el-table-column prop="value" label="物料编码" min-width="130" show-overflow-tooltip />
</el-table>
<div slot="footer" class="dialog-footer">
<el-button size="mini" @click="closeAllocateDialog">取消</el-button>
<el-button size="mini" type="primary" :loading="!allocateSaving" @click="saveAllocate">保存分配</el-button>
</div>
</el-dialog>
</div>
</template>
@@ -131,6 +155,7 @@ import rrOperation from '@crud/RR.operation.vue'
import crudOperation from '@crud/CRUD.operation.vue'
import udOperation from '@crud/UD.operation.vue'
import pagination from '@crud/Pagination.vue'
import {allocate, upload} from '@/views/wms/pm_manage/pmReturn/pmReturn'
const createDefaultForm = () => ({
id: '',
@@ -147,6 +172,7 @@ const createDefaultForm = () => ({
creator: '',
createTime: '',
sourceHouseCode: '',
targetHouseCode: '',
status: 0,
updateTime: '',
updateName: ''
@@ -169,7 +195,12 @@ export default {
data() {
return {
viewShow: false,
inventoryLoading: false,
currentRow: {},
currentReturn: {},
multipleSelection: [],
selectedInventory: '',
allocateSaving: false,
actionDisabled: true,
permission: {
add: ['admin', 'pmReturn:add'],
@@ -179,9 +210,15 @@ export default {
statusOptions: [
{ value: 0, label: '生成' },
{ value: 1, label: '失效' },
{ value: 10, label: '分配' },
{ value: 20, label: '执行' },
{ value: 80, label: '完成' }
],
inventoryList: [
{ value: '6.002', label: '中鼎立库' },
{ value: '6.011', label: '五期装配车间平库' },
{ value: '6.011.01', label: '五期装配车间大件库' }
],
deliveryMethodOptions: [
{ value: 1, label: '人工' },
{ value: 2, label: 'AGV' }
@@ -221,6 +258,11 @@ export default {
const target = this.statusOptions.find(item => Number(item.value) === Number(status))
return target ? target.label : status
},
isPushDisabled() {
// 没有选中、选中多行、或选中的行状态不是 '0' 时禁用
if (this.multipleSelection.length !== 1) return true
return this.multipleSelection[0].status !== '10'
},
statusFormat(row) {
return this.statusLabel(row.status)
},
@@ -234,6 +276,7 @@ export default {
handleSelectionChange(selection) {
this.crud.selectionChangeHandler(selection)
this.actionDisabled = !selection || selection.length === 0
this.multipleSelection = selection
},
handleCurrentChange(currentRow) {
this.currentRow = currentRow || {}
@@ -243,6 +286,74 @@ export default {
this.currentRow = { ...row }
this.viewShow = true
},
openAllocateDialog(row) {
this.inventoryLoading = true
this.currentReturn = row
this.allocateSaving = false
},
closeAllocateDialog() {
this.inventoryLoading = false
this.currentReturn = {}
this.selectedInventory = ''
this.allocateSaving = false
},
handleInventorySelection(selection) {
// 如果选中了多个,只保留最后一个
if (selection.length > 1) {
this.selectedInventory = ''
this.allocateSaving = false
} else if (selection.length === 1) {
this.selectedInventory = selection[0].value
this.allocateSaving = true
} else {
this.selectedInventory = ''
this.allocateSaving = false
}
},
saveAllocate() {
if (!this.selectedInventory) {
this.$message.warning('请至少勾选一条库存记录')
return
}
this.currentReturn.targetHouseCode = this.selectedInventory
allocate(this.currentReturn).then(res => {
if (res.code == 400){
this.$message.warning('分配失败'+res.message)
return
}
this.$message.success('分配成功')
this.crud.toQuery()
}).finally(() => {
this.closeAllocateDialog()
})
},
handleBatchPush() {
if (!this.multipleSelection.length) {
this.$message.warning('请先勾选要下推的需求单')
return
}
const invalidRows = this.multipleSelection.filter(item => String(item.status) !== '10')
if (invalidRows.length) {
this.$message.warning('仅支持批量下推状态为“分配”的需求单')
return
}
this.$confirm(`确认批量下推已勾选的 ${this.multipleSelection.length} 条需求单吗?`, '提示', {
confirmButtonText: '确认',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
upload(this.multipleSelection).then(res => {
if (res.code == 400){
this.$message.warning('分配失败'+res.message)
return
}
this.$message.success('下推成功')
this.crud.toQuery()
}).catch(() => {
this.$message.error('下推失败')
})
}).catch(() => {})
},
printBill() {
const selections = this.crud.selections
if (!selections || selections.length === 0) {

View File

@@ -31,4 +31,20 @@ export function get(id) {
})
}
export default { add, edit, del, get }
export function allocate(data) {
return request({
url: 'api/pmReturn/allocate',
method: 'post',
data
})
}
export function upload(data) {
return request({
url: 'api/pmReturn/upload',
method: 'post',
data
})
}
export default { add, edit, del, get, allocate }