add:需求单增加批量操作,强制回传功能

This commit is contained in:
zhangzq
2026-07-31 22:08:15 +08:00
parent 1d87add97d
commit aa2933a6b7
32 changed files with 435 additions and 141 deletions

View File

@@ -21,7 +21,9 @@
</el-form>
</div>
<crudOperation :permission="permission" >
<el-button slot="right" v-has-user="['admin']" class="filter-item" type="warning" icon="el-icon-s-promotion" size="mini" :disabled="audit_flag" @click="issueReturnBill">强制回传EAS</el-button>
<el-button slot="right" class="filter-item" type="success" icon="el-icon-s-promotion" size="mini" :disabled="isPushDisabled()" @click="handleBatchPush">下推出库</el-button>
<el-button slot="right" class="filter-item" type="warning" icon="el-icon-house" size="mini" :disabled="isBatchAllocateDisabled()" @click="openBatchAllocateDialog">批量分配</el-button>
</crudOperation>
<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;">
@@ -57,11 +59,6 @@
<el-table-column prop="houseName" label="仓库名称" min-width="140" show-overflow-tooltip />
<el-table-column prop="skuCode" label="物料编码" min-width="130" show-overflow-tooltip />
<el-table-column prop="qty" label="库存数量" width="110" />
<!-- <el-table-column label="分配数量" width="160">-->
<!-- <template slot-scope="scope">-->
<!-- <el-input-number v-model="scope.row.allocQty" :min="0" :max="scope.row.qty" :precision="4" size="mini" style="width:130px;" :disabled="!scope.row._selected" />-->
<!-- </template>-->
<!-- </el-table-column>-->
</el-table>
<div slot="footer" class="dialog-footer">
<el-button size="mini" @click="closeAllocateDialog">取消</el-button>
@@ -69,6 +66,24 @@
</div>
</el-dialog>
<!-- 批量分配仓库对话框 -->
<el-dialog :visible.sync="batchAllocateVisible" title="批量分配仓库" width="500px" :close-on-click-modal="false" @close="closeBatchAllocateDialog">
<div style="margin-bottom:10px;color:#606266;font-size:13px;">
已选择 <strong style="color:#E6A23C;">{{ multipleSelection.length }}</strong> 条需求单
</div>
<el-form label-width="80px" size="small">
<el-form-item label="仓库">
<el-checkbox-group v-model="batchAllocateHouses">
<el-checkbox v-for="item in warehouseOptions" :key="item.code" :label="item.code">{{ item.code }} {{ item.name }}</el-checkbox>
</el-checkbox-group>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button size="mini" @click="closeBatchAllocateDialog">取消</el-button>
<el-button size="mini" type="primary" :loading="batchAllocateSaving" @click="saveBatchAllocate">确认</el-button>
</div>
</el-dialog>
<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 />
@@ -88,6 +103,7 @@
<el-table-column prop="unit" label="单位" width="80" />
<el-table-column prop="targetArea" label="目标库存地点" min-width="140" show-overflow-tooltip />
<el-table-column prop="targetHouseCode" label="目标库" min-width="140" show-overflow-tooltip />
<el-table-column prop="inventoryDis" label="分配仓库" width="110" />
<el-table-column prop="carrierType" label="托盘类型" min-width="140" show-overflow-tooltip />
<el-table-column prop="productionLine" label="产线" min-width="100" show-overflow-tooltip />
<el-table-column prop="sn" label="车辆序列号" min-width="140" show-overflow-tooltip />
@@ -105,12 +121,13 @@
</template>
<script>
import crudDemand, { queryInventory, allocate, push } from './demand'
import crudDemand, { queryInventory, allocate, batchAllocate, push } from './demand'
import CRUD, { crud, form, header, presenter } from '@crud/crud'
import crudOperation from '@crud/CRUD.operation.vue'
import udOperation from '@crud/UD.operation.vue'
import rrOperation from '@crud/RR.operation.vue'
import pagination from '@crud/Pagination.vue'
import crudPurchase from "@/views/wms/pm_manage/allocationOut/purchase";
const createDefaultForm = () => ({ id: null, creator: '', createTime: '', priority: 0, status: 0, workOrder: '', skuCode: '', skuName: '', qty: undefined, unit: '', targetArea: '', productionLine: '', sn: '' })
@@ -134,6 +151,15 @@ export default {
{ value: '80', label: '完成' },
{ value: '90', label: '取消' }
],
batchAllocateVisible: false,
batchAllocateSaving: false,
batchAllocateHouses: [],
warehouseOptions: [
{ code: '6.011.01', name: '五期大件库' },
{ code: '6.011', name: '五期装配原材料平库' },
{ code: '6.002', name: '中鼎立库' }
],
audit_flag: true,
allocateVisible: false,
inventoryLoading: false,
allocateSaving: false,
@@ -167,8 +193,9 @@ export default {
},
isPushDisabled() {
// 没有选中、选中多行、或选中的行状态不是 '0' 时禁用
if (this.multipleSelection.length !== 1) return true
return this.multipleSelection[0].status !== '01'
if (this.multipleSelection.length === 0) return true
// 所有选中的行 status 都必须为 '01'
return this.multipleSelection.some(item => item.status !== '01')
},
statusLabel(status) {
const target = this.statusOptions.find(item => String(item.value) === String(status))
@@ -178,8 +205,34 @@ export default {
const map = { 0: '', '01': 'warning', '10': 'primary', '20': 'primary', '80': 'success', '90': 'danger' }
return map[String(status)] || ''
},
handleSelectionChange(selection) {
this.multipleSelection = selection
handleSelectionChange(val, row) {
this.multipleSelection = val
if (val.length === 0 && (val[0].status === '10' || val[0].status === '20')) {
this.audit_flag = true
} else {
this.audit_flag = false
}
},
issueReturnBill() {
const selections = this.multipleSelection
if (!selections || selections.length === 0) {
this.crud.notify('请至少选择一条单据', CRUD.NOTIFICATION_TYPE.INFO)
return
}
const ids = selections.map(s => s.id)
const billIds = selections.map(s => s.bill_id).join('、')
this.$confirm('确认下发以下单据的回传单?\n' + billIds, '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
crudDemand.issueReturnBill(ids).then(() => {
this.crud.notify('下发成功', CRUD.NOTIFICATION_TYPE.SUCCESS)
this.crud.toQuery()
}).catch(() => {
this.crud.notify('下发失败', CRUD.NOTIFICATION_TYPE.ERROR)
})
}).catch(() => {})
},
openAllocateDialog(row) {
this.currentDemand = { ...row }
@@ -255,16 +308,7 @@ export default {
this.$message.warning('请至少勾选一条库存记录')
return
}
const invalidRow = this.selectedInventory.find(item => !item.allocQty || item.allocQty <= 0)
if (invalidRow) {
this.$message.warning(`仓库 ${invalidRow.houseCode} 的分配数量必须大于0`)
return
}
const inventoryDisList = this.selectedInventory.map(item => ({
horseCode: item.houseCode,
qty: item.allocQty
}))
const inventoryDis = inventoryDisList.length === 1 ? JSON.stringify(inventoryDisList[0]) : JSON.stringify(inventoryDisList)
const inventoryDis = this.selectedInventory[0].houseCode
this.allocateSaving = true
allocate({ id: this.currentDemand.id, inventoryDis }).then(() => {
this.$message.success('库存分配成功')
@@ -291,13 +335,47 @@ export default {
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
push(this.multipleSelection).then(() => {
push(this.multipleSelection).then(res => {
if (res.code === 400) {
this.$message.error('下推失败'+res.message)
return
}
this.$message.success('下推成功')
this.crud.toQuery()
}).catch(() => {
this.$message.error('下推失败')
})
}).catch(() => {})
},
isBatchAllocateDisabled() {
if (!this.multipleSelection.length) return true
return this.multipleSelection.some(item => String(item.status) !== '0')
},
openBatchAllocateDialog() {
this.batchAllocateHouses = []
this.batchAllocateVisible = true
},
closeBatchAllocateDialog() {
this.batchAllocateVisible = false
this.batchAllocateHouses = []
},
saveBatchAllocate() {
if (!this.batchAllocateHouses.length) {
this.$message.warning('请至少选择一个仓库')
return
}
const ids = this.multipleSelection.map(item => item.id)
const inventoryDis = this.batchAllocateHouses.join(',')
this.batchAllocateSaving = true
batchAllocate({ ids, inventoryDis }).then(() => {
this.$message.success('批量分配成功')
this.closeBatchAllocateDialog()
this.crud.toQuery()
}).catch(() => {
this.$message.error('批量分配失败')
}).finally(() => {
this.batchAllocateSaving = false
})
}
}
}