add:增加仓储服务,增加需求单至出库单流程

This commit is contained in:
zhangzq
2026-06-08 08:45:53 +08:00
parent ec9fce406c
commit 854a1714fe
45 changed files with 817 additions and 288 deletions

View File

@@ -20,7 +20,10 @@
<rrOperation :crud="crud" />
</el-form>
</div>
<crudOperation :permission="permission" />
<div style="margin-bottom: 10px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap;">
<crudOperation :permission="permission" />
<el-button size="mini" type="success" :disabled="!multipleSelection.length" @click="handleBatchPush">下推</el-button>
</div>
<el-dialog :close-on-click-modal="false" :before-close="crud.cancelCU" :visible.sync="crud.status.cu > 0" :title="crud.status.title" width="900px">
<el-form ref="form" :model="form" :rules="rules" size="mini" label-width="110px" label-suffix=":" style="border: 1px solid #cfe0df;margin-top: 10px;padding: 10px;">
<el-row>
@@ -66,7 +69,7 @@
</div>
</el-dialog>
<el-table ref="table" v-loading="crud.loading" :data="crud.data" size="small">
<el-table ref="table" v-loading="crud.loading" :data="crud.data" size="small" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" />
<el-table-column prop="id" label="ID" width="220" show-overflow-tooltip />
<el-table-column prop="creator" label="操作人" min-width="100" show-overflow-tooltip />
@@ -86,11 +89,10 @@
<el-table-column prop="productionLine" label="产线" min-width="100" show-overflow-tooltip />
<el-table-column prop="sn" label="车辆序列号" min-width="140" show-overflow-tooltip />
<el-table-column prop="createAt" label="创建时间" min-width="160" show-overflow-tooltip />
<el-table-column label="操作" width="240px" align="center" fixed="right">
<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>
<el-button size="mini" type="success" plain style="margin-left:4px;" :disabled="scope.row.status !== '01'" @click="handlePush(scope.row)">下发</el-button>
</template>
</el-table-column>
</el-table>
@@ -120,7 +122,7 @@ export default {
return {
permission: {},
statusOptions: [
{ value: 0, label: '生成' },
{ value: '0', label: '生成' },
{ value: '01', label: '分配' },
{ value: '10', label: '下发' },
{ value: '20', label: '执行' },
@@ -133,6 +135,7 @@ export default {
currentDemand: {},
inventoryList: [],
selectedInventory: [],
multipleSelection: [],
rules: {
creator: [{ required: true, message: '请输入操作人', trigger: 'blur' }],
createTime: [{ required: true, message: '请选择需求日期', trigger: 'change' }],
@@ -165,6 +168,9 @@ export default {
const map = { 0: '', '01': 'warning', '10': 'primary', '20': 'primary', '80': 'success', '90': 'danger' }
return map[String(status)] || ''
},
handleSelectionChange(selection) {
this.multipleSelection = selection
},
openAllocateDialog(row) {
this.currentDemand = { ...row }
this.inventoryList = []
@@ -181,11 +187,12 @@ export default {
if (row.inventoryDis) {
try {
const saved = JSON.parse(row.inventoryDis)
const savedList = Array.isArray(saved) ? saved : [saved]
this.inventoryList.forEach(item => {
const match = saved.find(s => s.houseCode === item.houseCode)
const match = savedList.find(s => (s.horseCode || s.houseCode) === item.houseCode)
if (match) {
item._selected = true
item.allocQty = match.allocQty
item.allocQty = Number(match.qty || match.allocQty || 0)
this.$nextTick(() => {
this.$refs.allocateTable && this.$refs.allocateTable.toggleRowSelection(item, true)
})
@@ -219,16 +226,11 @@ export default {
this.$message.warning(`仓库 ${invalidRow.houseCode} 的分配数量必须大于0`)
return
}
const inventoryDis = JSON.stringify(
this.selectedInventory.map(item => ({
houseCode: item.houseCode,
houseName: item.houseName,
skuCode: item.skuCode,
skuName: item.skuName,
qty: item.qty,
allocQty: item.allocQty
}))
)
const inventoryDisList = this.selectedInventory.map(item => ({
horseCode: item.houseCode,
qty: item.allocQty
}))
const inventoryDis = inventoryDisList.length === 1 ? JSON.stringify(inventoryDisList[0]) : JSON.stringify(inventoryDisList)
this.allocateSaving = true
allocate({ id: this.currentDemand.id, inventoryDis }).then(() => {
this.$message.success('库存分配成功')
@@ -240,17 +242,26 @@ export default {
this.allocateSaving = false
})
},
handlePush(row) {
this.$confirm(`确认下发需求单 "${row.workOrder}" `, '提示', {
handleBatchPush() {
if (!this.multipleSelection.length) {
this.$message.warning('请先勾选要下推的需求单')
return
}
const invalidRows = this.multipleSelection.filter(item => String(item.status) !== '01')
if (invalidRows.length) {
this.$message.warning('仅支持批量下推状态为“分配”的需求单')
return
}
this.$confirm(`确认批量下推已勾选的 ${this.multipleSelection.length} 条需求单吗?`, '提示', {
confirmButtonText: '确认',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
push({ id: row.id, workOrder: row.workOrder }).then(() => {
this.$message.success('下成功')
push(this.multipleSelection).then(() => {
this.$message.success('下成功')
this.crud.toQuery()
}).catch(() => {
this.$message.error('下失败')
this.$message.error('下失败')
})
}).catch(() => {})
}

View File

@@ -128,18 +128,19 @@
:data="form.tableData"
style="width: 100%;"
border
fit
:header-cell-style="{background:'#f5f7fa',color:'#606266'}"
>
<el-table-column type="index" label="序号" width="55" align="center" />
<el-table-column show-overflow-tooltip width="150" prop="storagevehicle_code" label="批次号" />
<el-table-column show-overflow-tooltip width="150" prop="pcsn" label="批次号" />
<el-table-column show-overflow-tooltip width="150" prop="material_code" label="物料编码" />
<el-table-column show-overflow-tooltip width="150" prop="material_name" label="物料名称" />
<el-table-column show-overflow-tooltip width="170" prop="qty" label="数量" />
<el-table-column show-overflow-tooltip width="170" prop="qty_unit_name" label="计量单位名称" />
<el-table-column show-overflow-tooltip width="150" prop="ext_code" label="源单号" />
<el-table-column show-overflow-tooltip width="150" prop="ext_type" label="源单类型" />
<el-table-column v-if="crud.status.cu > 0" align="center" label="操作" width="120" fixed="right">
<el-table-column show-overflow-tooltip min-width="140" prop="storagevehicle_code" label="载具编码" />
<el-table-column show-overflow-tooltip min-width="140" prop="pcsn" label="批次号" />
<el-table-column show-overflow-tooltip min-width="140" prop="material_code" label="物料编码" />
<el-table-column show-overflow-tooltip min-width="180" prop="material_name" label="物料名称" />
<el-table-column show-overflow-tooltip min-width="110" prop="qty" label="数量" />
<el-table-column show-overflow-tooltip min-width="130" prop="qty_unit_name" label="计量单位名称" />
<el-table-column show-overflow-tooltip min-width="140" prop="ext_code" label="源单号" />
<el-table-column show-overflow-tooltip min-width="120" prop="ext_type" label="源单类型" />
<el-table-column v-if="crud.status.cu > 0" align="center" label="操作" width="100" fixed="right">
<template scope="scope">
<el-button
type="danger"
@@ -309,21 +310,20 @@ export default {
}
},
tableChanged(rows) {
// 对新增的行进行校验不能存在相同物料批次
rows.forEach((item) => {
let same_mater = true
this.form.tableData.forEach((row) => {
if (row.pcsn === item.pcsn && row.material_id === item.material_id && row.storagevehicle_code === item.storagevehicle_code) {
same_mater = false
}
})
if (same_mater) {
const exists = this.form.tableData.some(row => this.isSameMaterialRow(row, item))
if (!exists) {
this.form.total_qty = parseFloat(this.form.total_qty) + parseFloat(item.qty)
this.form.tableData.splice(-1, 0, item)
this.form.tableData.push(item)
}
})
this.form.detail_count = this.form.tableData.length
},
isSameMaterialRow(row, item) {
const rowKey = [row.pcsn || '', row.material_id || row.material_code || '', row.storagevehicle_code || ''].join('_')
const itemKey = [item.pcsn || '', item.material_id || item.material_code || '', item.storagevehicle_code || ''].join('_')
return rowKey === itemKey
},
async insertEvent(row) {
if (this.form.bill_type === '') {
this.crud.notify('请选择业务类型!', CRUD.NOTIFICATION_TYPE.INFO)

View File

@@ -144,13 +144,14 @@ export default {
this.$emit('update:dialogShow', false)
},
submit() {
const selection = this.$refs.multipleTable.selection || []
if (!selection.length) {
this.$message.warning('请至少选择一条数据')
return
}
this.$emit('update:dialogShow', false)
this.rows = this.$refs.multipleTable.selection
console.log('获取的rows:')
console.log(this.rows)
this.$emit('tableChanged', this.rows)
group.getAllGroupInfo(this.rows).then(res => {
this.rows = res.content
group.getAllGroupInfo(selection).then(res => {
this.rows = res.content || []
this.$emit('tableChanged', this.rows)
})
// this.form = this.$options.data().form