feat: 接入ERP成品发货出库流程
This commit is contained in:
1 parent
66a1f60428
commit
7c2722c88d
25 files changed
+2547
-22
No files matched your search
@@ -0,0 +1,257 @@
|
||||
@model HHWMS.Web.ShipmentHeaderVM
|
||||
|
||||
<div id="shipment-allocate-@Model.Entity.ID">
|
||||
<a-space direction="vertical" fill size="large">
|
||||
<a-alert type="info">
|
||||
ERP单号:{{ header.SourceCode || '-' }};WMS单号:{{ header.Code || '-' }}。
|
||||
分配只保存人员填写的数量,同一托盘下发一个WCS任务。
|
||||
</a-alert>
|
||||
|
||||
<a-card title="出库明细">
|
||||
<template #extra>
|
||||
<a-button type="text" @@click="loadData">刷新</a-button>
|
||||
</template>
|
||||
<a-table :data="details" :pagination="false" row-key="ID">
|
||||
<template #columns>
|
||||
<a-table-column title="物料编码" data-index="MaterialCode"></a-table-column>
|
||||
<a-table-column title="物料名称" data-index="MaterialName"></a-table-column>
|
||||
<a-table-column title="需求数量" data-index="Qty"></a-table-column>
|
||||
<a-table-column title="已分配" data-index="DividedQty"></a-table-column>
|
||||
<a-table-column title="已出库" data-index="CompletedQty"></a-table-column>
|
||||
<a-table-column title="可分配" data-index="RemainingQty"></a-table-column>
|
||||
<a-table-column title="状态" data-index="Status"></a-table-column>
|
||||
<a-table-column title="操作" :width="110">
|
||||
<template #cell="{ record }">
|
||||
<a-button type="primary" size="small" :disabled="record.RemainingQty <= 0"
|
||||
@@click="openInventory(record)">选择库存</a-button>
|
||||
</template>
|
||||
</a-table-column>
|
||||
</template>
|
||||
</a-table>
|
||||
</a-card>
|
||||
|
||||
<a-card title="托盘任务">
|
||||
<a-empty v-if="tasks.length === 0" description="尚未分配库存"></a-empty>
|
||||
<a-card v-for="task in tasks" :key="task.ID" :title="task.TaskNo" size="small"
|
||||
style="margin-bottom: 12px">
|
||||
<template #extra>
|
||||
<a-space>
|
||||
<span>托盘:{{ task.ContainerCode }};状态:{{ task.Status }}</span>
|
||||
<a-select v-if="task.CanDispatch" v-model="task.SelectedOutPort"
|
||||
placeholder="选择出库口" style="width: 150px">
|
||||
<a-option v-for="port in outPorts" :key="port.Value" :value="port.Value">
|
||||
{{ port.Label }}
|
||||
</a-option>
|
||||
</a-select>
|
||||
<a-button v-if="task.CanDispatch" type="primary" :loading="task.Loading"
|
||||
@@click="dispatchTask(task)">下发任务</a-button>
|
||||
<a-button v-if="task.CanCancel" status="danger" :disabled="task.Loading"
|
||||
@@click="cancelTask(task)">取消整托分配</a-button>
|
||||
</a-space>
|
||||
</template>
|
||||
<a-table :data="task.Details" :pagination="false" row-key="ID" size="small">
|
||||
<template #columns>
|
||||
<a-table-column title="ERP单号" data-index="ShipmentCode"></a-table-column>
|
||||
<a-table-column title="库存ID" data-index="InventoryId"></a-table-column>
|
||||
<a-table-column title="物料编码" data-index="MaterialCode"></a-table-column>
|
||||
<a-table-column title="分配数量" data-index="Qty"></a-table-column>
|
||||
<a-table-column title="状态" data-index="Status"></a-table-column>
|
||||
<a-table-column title="操作" :width="100">
|
||||
<template #cell="{ record }">
|
||||
<a-button v-if="record.CanCancel" type="text" status="danger"
|
||||
@@click="cancelAllocation(record)">取消分配</a-button>
|
||||
</template>
|
||||
</a-table-column>
|
||||
</template>
|
||||
</a-table>
|
||||
</a-card>
|
||||
</a-card>
|
||||
|
||||
<a-modal v-model:visible="inventoryVisible" title="选择库存并填写分配数量"
|
||||
width="1000px" :ok-loading="saving" @@before-ok="saveAllocation">
|
||||
<a-alert type="warning" style="margin-bottom: 12px">
|
||||
本明细剩余可分配 {{ currentDetail.RemainingQty || 0 }}。同一库存可以分给多个明细,但累计不能超过库存数量。
|
||||
</a-alert>
|
||||
<a-table :data="inventories" :pagination="{ pageSize: 10 }" row-key="ID">
|
||||
<template #columns>
|
||||
<a-table-column title="选择" :width="65">
|
||||
<template #cell="{ record }">
|
||||
<a-checkbox v-model="record.Selected"></a-checkbox>
|
||||
</template>
|
||||
</a-table-column>
|
||||
<a-table-column title="库存ID" data-index="ID" :width="90"></a-table-column>
|
||||
<a-table-column title="托盘" data-index="ContainerCode"></a-table-column>
|
||||
<a-table-column title="库位" data-index="LocationCode"></a-table-column>
|
||||
<a-table-column title="批次" data-index="Batch"></a-table-column>
|
||||
<a-table-column title="库存数量" data-index="Qty"></a-table-column>
|
||||
<a-table-column title="已被分配" data-index="AllocatedQty"></a-table-column>
|
||||
<a-table-column title="可用数量" data-index="AvailableQty"></a-table-column>
|
||||
<a-table-column title="本次分配" :width="150">
|
||||
<template #cell="{ record }">
|
||||
<a-input-number v-model="record.AllocationQty" :min="0"
|
||||
:max="record.AvailableQty" :precision="4"
|
||||
:disabled="!record.Selected" style="width: 125px"></a-input-number>
|
||||
</template>
|
||||
</a-table-column>
|
||||
</template>
|
||||
</a-table>
|
||||
</a-modal>
|
||||
</a-space>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
(() => {
|
||||
const allocationApp = Vue.createApp({
|
||||
data() {
|
||||
return {
|
||||
headerId: @Model.Entity.ID,
|
||||
header: {},
|
||||
details: [],
|
||||
tasks: [],
|
||||
outPorts: [],
|
||||
inventoryVisible: false,
|
||||
inventories: [],
|
||||
currentDetail: {},
|
||||
saving: false
|
||||
};
|
||||
},
|
||||
mounted() {
|
||||
this.loadData();
|
||||
},
|
||||
methods: {
|
||||
notifyError(message) {
|
||||
this.$notification.error({ content: message || '操作失败', duration: 5000, closable: true });
|
||||
},
|
||||
loadData() {
|
||||
axios.get('/shipment/ShipmentHeader/GetAllocationData', { params: { headerId: this.headerId } })
|
||||
.then(response => {
|
||||
const json = response.data;
|
||||
if (Number(json.Code) !== 200) {
|
||||
this.notifyError(json.Msg);
|
||||
return;
|
||||
}
|
||||
this.header = json.Data.Header || {};
|
||||
this.details = json.Data.Details || [];
|
||||
this.tasks = (json.Data.Tasks || []).map(task => ({
|
||||
...task,
|
||||
SelectedOutPort: task.ToLocation || '',
|
||||
Loading: false
|
||||
}));
|
||||
this.outPorts = json.Data.OutPorts || [];
|
||||
})
|
||||
.catch(error => this.notifyError(error.message));
|
||||
},
|
||||
openInventory(detail) {
|
||||
this.currentDetail = detail;
|
||||
axios.get('/shipment/ShipmentHeader/GetAvailableInventories', { params: { detailId: detail.ID } })
|
||||
.then(response => {
|
||||
const json = response.data;
|
||||
if (Number(json.Code) !== 200) {
|
||||
this.notifyError(json.Msg);
|
||||
return;
|
||||
}
|
||||
this.inventories = (json.Data || []).map(item => ({
|
||||
...item,
|
||||
Selected: false,
|
||||
AllocationQty: 0
|
||||
}));
|
||||
this.inventoryVisible = true;
|
||||
})
|
||||
.catch(error => this.notifyError(error.message));
|
||||
},
|
||||
saveAllocation(done) {
|
||||
const rows = this.inventories
|
||||
.filter(item => item.Selected && Number(item.AllocationQty) > 0)
|
||||
.map(item => ({ InventoryId: item.ID, Qty: item.AllocationQty }));
|
||||
if (rows.length === 0) {
|
||||
this.notifyError('请选择库存并填写大于0的分配数量');
|
||||
if (done) done(false);
|
||||
return;
|
||||
}
|
||||
const total = rows.reduce((sum, item) => sum + Number(item.Qty), 0);
|
||||
if (total > Number(this.currentDetail.RemainingQty)) {
|
||||
this.notifyError('本次分配总数不能超过明细剩余可分配数量');
|
||||
if (done) done(false);
|
||||
return;
|
||||
}
|
||||
this.saving = true;
|
||||
axios.post('/shipment/ShipmentHeader/AllocateInventories', {
|
||||
DetailId: this.currentDetail.ID,
|
||||
Rows: rows
|
||||
}).then(response => {
|
||||
const json = response.data;
|
||||
if (Number(json.Code) === 200) {
|
||||
this.$message.success('分配成功');
|
||||
this.inventoryVisible = false;
|
||||
this.loadData();
|
||||
if (done) done(true);
|
||||
} else {
|
||||
this.notifyError(json.Msg);
|
||||
if (done) done(false);
|
||||
}
|
||||
}).catch(error => {
|
||||
this.notifyError(error.message);
|
||||
if (done) done(false);
|
||||
}).finally(() => {
|
||||
this.saving = false;
|
||||
});
|
||||
},
|
||||
postForm(url, values) {
|
||||
const data = new URLSearchParams();
|
||||
Object.keys(values).forEach(key => data.append(key, values[key]));
|
||||
return axios.post(url, data);
|
||||
},
|
||||
cancelAllocation(record) {
|
||||
if (!window.confirm(`确认取消库存 ${record.InventoryId} 的分配吗?`)) return;
|
||||
this.postForm('/shipment/ShipmentHeader/CancelAllocation', { id: record.ID })
|
||||
.then(response => {
|
||||
const json = response.data;
|
||||
if (Number(json.Code) === 200) {
|
||||
this.$message.success('取消分配成功');
|
||||
this.loadData();
|
||||
} else {
|
||||
this.notifyError(json.Msg);
|
||||
}
|
||||
}).catch(error => this.notifyError(error.message));
|
||||
},
|
||||
cancelTask(task) {
|
||||
if (!window.confirm(`确认取消托盘 ${task.ContainerCode} 的全部待下发分配吗?`)) return;
|
||||
task.Loading = true;
|
||||
this.postForm('/shipment/ShipmentHeader/CancelPendingTask', { id: task.ID })
|
||||
.then(response => {
|
||||
const json = response.data;
|
||||
if (Number(json.Code) === 200) {
|
||||
this.$message.success('整托分配已取消');
|
||||
this.loadData();
|
||||
} else {
|
||||
this.notifyError(json.Msg);
|
||||
}
|
||||
}).catch(error => this.notifyError(error.message))
|
||||
.finally(() => { task.Loading = false; });
|
||||
},
|
||||
dispatchTask(task) {
|
||||
if (!task.SelectedOutPort) {
|
||||
this.notifyError('请先选择出库口');
|
||||
return;
|
||||
}
|
||||
task.Loading = true;
|
||||
this.postForm('/shipment/ShipmentHeader/DispatchPendingTask', {
|
||||
id: task.ID,
|
||||
outPort: task.SelectedOutPort
|
||||
}).then(response => {
|
||||
const json = response.data;
|
||||
if (Number(json.Code) === 200) {
|
||||
this.$message.success('WCS任务下发成功');
|
||||
this.loadData();
|
||||
} else {
|
||||
this.notifyError(json.Msg);
|
||||
}
|
||||
}).catch(error => this.notifyError(error.message))
|
||||
.finally(() => { task.Loading = false; });
|
||||
}
|
||||
}
|
||||
});
|
||||
allocationApp.use(ArcoVue);
|
||||
allocationApp.mount('#shipment-allocate-@Model.Entity.ID');
|
||||
})();
|
||||
</script>
|
||||
Reference in new issue
Block a user