fix:永丰售后修复BUG,
1,物料库存获取不到ERP:重新调整触发查询逻辑 2,工序变更导致物料无法出库:配置旧工序 3,测试出库订单ERP推送,任务下发
This commit is contained in:
1 parent
b2a9a38f38
commit
c76e7bb681
69 files changed
+5510
-157
No files matched your search
@@ -0,0 +1,225 @@
|
||||
@model HHWMS.Web.AgvTaskListVM
|
||||
@inject IStringLocalizer<Program> Localizer;
|
||||
|
||||
@* 手动下发 AGV 任务表单(由列表页 grid 工具栏「下发任务」按钮以 Dialog 打开) *@
|
||||
<style>
|
||||
/* 任务场景下拉:原生 select + Vue 渲染选项,规避 ArcoVue 组件渲染链路问题 */
|
||||
.agv-scene-select {
|
||||
width: 100%;
|
||||
height: 32px;
|
||||
padding: 0 12px;
|
||||
border: 1px solid #e5e6eb;
|
||||
border-radius: 4px;
|
||||
background: #fff;
|
||||
color: #4e5969;
|
||||
font-size: 14px;
|
||||
outline: none;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
.agv-scene-select:focus {
|
||||
border-color: rgb(22, 93, 255);
|
||||
}
|
||||
</style>
|
||||
<div id="plapp">
|
||||
<div style="padding: 16px 20px;">
|
||||
<a-form :model="form" auto-label-width>
|
||||
<a-form-item label="任务场景" field="taskType" required>
|
||||
<select v-model="form.taskType" class="agv-scene-select">
|
||||
<option value="" disabled>请选择任务场景(必填)</option>
|
||||
<option v-for="item in sceneOptions" :key="item.value" :value="item.value">{{ item.label }}</option>
|
||||
</select>
|
||||
</a-form-item>
|
||||
<a-form-item label="起点库位" field="fromLocation" required>
|
||||
<a-input v-model="form.fromLocation" placeholder="手动输入起点库位编码(必填)" allow-clear />
|
||||
</a-form-item>
|
||||
<a-form-item label="终点库位" field="toLocation" required>
|
||||
<a-input v-model="form.toLocation" placeholder="手动输入终点库位编码(必填)" allow-clear />
|
||||
</a-form-item>
|
||||
<a-form-item label="容器号" field="containerCode">
|
||||
<a-input v-model="form.containerCode" placeholder="可不填,自动生成 LS 临时容器" allow-clear />
|
||||
</a-form-item>
|
||||
<a-form-item label="优先级" field="priority">
|
||||
<a-input-number v-model="form.priority" :min="0" placeholder="默认 0" style="width:100%" />
|
||||
</a-form-item>
|
||||
<a-form-item label="物料明细" field="details">
|
||||
<div v-if="form.details.length === 0" style="color:#86909c; margin-bottom:8px;">
|
||||
未添加物料,按空容器业务处理
|
||||
</div>
|
||||
<div v-else style="width:100%; margin-bottom:8px;">
|
||||
<!-- 表头 -->
|
||||
<div style="display:flex; background:#f7f8fa; border:1px solid #e5e6eb; border-radius:4px 4px 0 0; padding:6px 8px; font-weight:500; font-size:13px; color:#4e5969;">
|
||||
<span style="flex:2.2;">物料编码</span>
|
||||
<span style="flex:1; text-align:center;">数量</span>
|
||||
<span style="flex:1.4; text-align:center;">批次</span>
|
||||
<span style="width:56px; text-align:center;">操作</span>
|
||||
</div>
|
||||
<!-- 物料行:多个物料竖向排列 -->
|
||||
<div v-for="d in form.details" :key="d._key"
|
||||
style="display:flex; align-items:center; border:1px solid #e5e6eb; border-top:none; padding:4px 8px; background:#fff;">
|
||||
<div style="flex:2.2; padding-right:8px;">
|
||||
<a-auto-complete v-model="d.materialCode" :data="d.options" placeholder="编码/名称搜索"
|
||||
@@search="(kw) => handleMaterialSearch(kw, d)" style="width:100%" />
|
||||
</div>
|
||||
<div style="flex:1; padding-right:8px;">
|
||||
<a-input-number v-model="d.qty" :min="0" placeholder="数量" style="width:100%" />
|
||||
</div>
|
||||
<div style="flex:1.4; padding-right:8px;">
|
||||
<a-input v-model="d.batch" placeholder="批次" allow-clear />
|
||||
</div>
|
||||
<div style="width:56px; text-align:center;">
|
||||
<a-button type="text" status="danger" size="mini" @@click="removeDetail(d._key)">删除</a-button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<a-button type="outline" size="small" @@click="addMaterial">+ 添加物料</a-button>
|
||||
</a-form-item>
|
||||
<a-form-item>
|
||||
<a-space>
|
||||
<a-button type="primary" @@click="createTask" :loading="loading">创建任务</a-button>
|
||||
<a-button type="outline" @@click="resetForm">重置</a-button>
|
||||
</a-space>
|
||||
</a-form-item>
|
||||
</a-form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
// IIFE 包裹:弹窗 HTML 每次打开都会重新注入执行脚本,
|
||||
// 避免顶层 const 在当前文档重复声明报错导致第二次打开表单失效
|
||||
(function () {
|
||||
const { createApp, reactive, ref, onMounted } = Vue;
|
||||
const { Message } = ArcoVue;
|
||||
|
||||
const app = createApp({
|
||||
setup() {
|
||||
const loading = ref(false);
|
||||
// 场景选项由服务端 Create 时直接查库注入,前端无需异步加载,保证下拉必有选项
|
||||
const sceneOptions = ref(@Html.Raw(ViewBag.ScenesJson ?? "[]"));
|
||||
|
||||
const form = reactive({
|
||||
taskType: undefined,
|
||||
fromLocation: "",
|
||||
toLocation: "",
|
||||
containerCode: "",
|
||||
priority: 0,
|
||||
details: []
|
||||
});
|
||||
|
||||
// 关闭当前弹窗并刷新列表:同文档弹窗(layer type:1)用父页记录的层号关闭;兼容旧 iframe 模式兜底
|
||||
const closeAndRefresh = () => {
|
||||
try {
|
||||
if (window.agvCreateLayerIndex) {
|
||||
layer.close(window.agvCreateLayerIndex);
|
||||
window.agvCreateLayerIndex = 0;
|
||||
} else {
|
||||
var idx = parent.layer.getFrameIndex(window.name);
|
||||
if (idx) parent.layer.close(idx);
|
||||
}
|
||||
} catch (e) { /* 非 Dialog 环境忽略 */ }
|
||||
try {
|
||||
if (window.reloadAgvTask) { window.reloadAgvTask(); }
|
||||
else if (parent.reloadAgvTask) { parent.reloadAgvTask(); }
|
||||
} catch (e) { /* 父页不可达时忽略 */ }
|
||||
};
|
||||
|
||||
const loadScenes = async () => {
|
||||
// 场景已由服务端注入 sceneOptions,此处保留用于手动刷新兜底
|
||||
const { data } = await axios.post("/agv/AgvTask/GetScenes");
|
||||
if (data && data.Data && data.Data.length > 0)
|
||||
{
|
||||
sceneOptions.value = data.Data;
|
||||
}
|
||||
};
|
||||
|
||||
// 物料搜索(按行缓存选项,支持多行独立搜索)
|
||||
const handleMaterialSearch = async (keyword, row) => {
|
||||
if (!row) return;
|
||||
const { data } = await axios.post(`/agv/AgvTask/GetMaterials?keyword=${encodeURIComponent(keyword || "")}`);
|
||||
row.options = (data.Data || []).map(m => `${m.materialCode}(${m.materialName || ""})`);
|
||||
};
|
||||
|
||||
// 添加物料行(多个物料竖向表格,直接内嵌,无弹窗)
|
||||
const addMaterial = () => {
|
||||
form.details.push({
|
||||
_key: Date.now() + Math.random(),
|
||||
materialCode: "",
|
||||
qty: null,
|
||||
batch: "",
|
||||
options: [],
|
||||
erpDetailId: ""
|
||||
});
|
||||
};
|
||||
|
||||
const removeDetail = (key) => {
|
||||
const idx = form.details.findIndex(d => d._key === key);
|
||||
if (idx >= 0) form.details.splice(idx, 1);
|
||||
};
|
||||
|
||||
const createTask = async () => {
|
||||
if (!form.taskType) {
|
||||
Message.warning("任务场景为必填项");
|
||||
return;
|
||||
}
|
||||
if (!form.fromLocation || !form.fromLocation.trim()) {
|
||||
Message.warning("起点库位为必填项");
|
||||
return;
|
||||
}
|
||||
if (!form.toLocation || !form.toLocation.trim()) {
|
||||
Message.warning("终点库位为必填项");
|
||||
return;
|
||||
}
|
||||
if (form.fromLocation.trim() === form.toLocation.trim()) {
|
||||
Message.warning("起点与终点不能相同");
|
||||
return;
|
||||
}
|
||||
loading.value = true;
|
||||
try {
|
||||
// 过滤未填物料编码的空行,全空则按空容器业务处理
|
||||
const validDetails = form.details
|
||||
.filter(d => d.materialCode && d.materialCode.trim())
|
||||
.map(d => ({ MaterialCode: d.materialCode.trim(), Qty: d.qty || 0, Batch: d.batch || "", ErpDetailId: d.erpDetailId || "" }));
|
||||
const { data } = await axios.post("/agv/AgvTask/Create", {
|
||||
TaskType: form.taskType,
|
||||
FromLocation: form.fromLocation.trim(),
|
||||
ToLocation: form.toLocation.trim(),
|
||||
ContainerCode: form.containerCode || undefined,
|
||||
Priority: form.priority || 0,
|
||||
Details: validDetails.length > 0 ? validDetails : undefined
|
||||
});
|
||||
if (data.Code == 200) {
|
||||
// 提示显示在弹窗上层(父窗口 layer),iframe 内 ArcoVue Message 会被弹窗遮挡
|
||||
parent.layer.msg(data.Msg || "任务创建成功", { icon: 1, time: 1500 });
|
||||
closeAndRefresh();
|
||||
} else {
|
||||
parent.layer.msg(data.Msg || "操作失败", { icon: 2, time: 3000 });
|
||||
}
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
const resetForm = () => {
|
||||
form.taskType = undefined;
|
||||
form.fromLocation = "";
|
||||
form.toLocation = "";
|
||||
form.containerCode = "";
|
||||
form.priority = 0;
|
||||
form.details = [];
|
||||
};
|
||||
|
||||
onMounted(async () => {
|
||||
try { await loadScenes(); }
|
||||
catch (e) { console.warn("loadScenes 失败", e); }
|
||||
});
|
||||
|
||||
return {
|
||||
form, loading, sceneOptions,
|
||||
createTask, resetForm,
|
||||
addMaterial, removeDetail, handleMaterialSearch
|
||||
};
|
||||
}
|
||||
});
|
||||
app.use(ArcoVue);
|
||||
app.mount("#plapp");
|
||||
})(); /* IIFE 结束 */
|
||||
</script>
|
||||
@@ -0,0 +1,225 @@
|
||||
@model HHWMS.Web.AgvTaskListVM
|
||||
@inject IStringLocalizer<Program> Localizer;
|
||||
|
||||
@* AGV 平库任务列表:原生 HTML 表格渲染,完全避开 WTM grid / layui table 渲染链路的异常问题
|
||||
查询、分页、行内 下发/取消/重试完成 均由本页 JS 直调后端接口实现 *@
|
||||
<div style="padding:10px;">
|
||||
<!-- 查询区 -->
|
||||
<div style="background:#fff; border-radius:4px; padding:12px 12px 2px; margin-bottom:10px; box-shadow:0 1px 2px rgba(0,0,0,.06);">
|
||||
<div style="display:flex; flex-wrap:wrap; gap:8px 18px; align-items:center;">
|
||||
<div><label style="margin-right:4px;">任务号</label><input id="q_taskNo" placeholder="模糊查询" class="agv-q-input" /></div>
|
||||
<div><label style="margin-right:4px;">起点</label><input id="q_from" placeholder="模糊查询" class="agv-q-input" /></div>
|
||||
<div><label style="margin-right:4px;">终点</label><input id="q_to" placeholder="模糊查询" class="agv-q-input" /></div>
|
||||
<div><label style="margin-right:4px;">容器号</label><input id="q_container" placeholder="模糊查询" class="agv-q-input" /></div>
|
||||
<div><label style="margin-right:4px;">来源系统</label><select id="q_source" class="agv-q-input"><option value="">全部</option></select></div>
|
||||
<div><label style="margin-right:4px;">状态</label><select id="q_status" class="agv-q-input"><option value="">全部</option></select></div>
|
||||
<div style="margin-bottom:10px;">
|
||||
<button type="button" class="layui-btn layui-btn-sm" onclick="agvSearch(1)"><i class="layui-icon"></i> 查询</button>
|
||||
<button type="button" class="layui-btn layui-btn-sm layui-btn-primary" onclick="agvReset()">重置</button>
|
||||
<button type="button" class="layui-btn layui-btn-sm layui-btn-normal" style="margin-left:10px;" onclick="agvOpenCreate()"><i class="layui-icon"></i> 下发任务</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 数据表格(原生 table,行内操作由 JS 直接生成,显示稳定可控) -->
|
||||
<table class="layui-table" style="margin:0;">
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="width:170px;">任务号</th>
|
||||
<th style="width:110px;">任务场景</th>
|
||||
<th style="width:90px;">状态</th>
|
||||
<th style="width:110px;">起点</th>
|
||||
<th style="width:110px;">终点</th>
|
||||
<th style="width:150px;">容器号</th>
|
||||
<th style="width:90px;">来源系统</th>
|
||||
<th style="width:180px;">错误信息</th>
|
||||
<th style="width:150px;">创建时间</th>
|
||||
<th style="width:120px;">操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="agvTbody"><tr><td colspan="10" style="text-align:center; color:#999;">加载中...</td></tr></tbody>
|
||||
</table>
|
||||
|
||||
<!-- 分页 -->
|
||||
<div style="display:flex; justify-content:flex-end; align-items:center; gap:10px; padding:10px 2px; color:#666;">
|
||||
<span id="agvTotal">共 0 条</span>
|
||||
<span>每页</span>
|
||||
<select id="q_size" style="height:26px; padding:0 4px; border:1px solid #e5e6eb; border-radius:4px; outline:none;" onchange="agvSizeChange()">
|
||||
<option value="10" selected>10 条</option>
|
||||
<option value="20">20 条</option>
|
||||
<option value="50">50 条</option>
|
||||
<option value="100">100 条</option>
|
||||
</select>
|
||||
<button type="button" class="layui-btn layui-btn-xs layui-btn-primary" onclick="agvPageTurn(-1)">上一页</button>
|
||||
<span id="agvPageNo">第 1 页</span>
|
||||
<button type="button" class="layui-btn layui-btn-xs layui-btn-primary" onclick="agvPageTurn(1)">下一页</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.agv-q-input {
|
||||
height: 30px;
|
||||
padding: 0 8px;
|
||||
border: 1px solid #e5e6eb;
|
||||
border-radius: 4px;
|
||||
outline: none;
|
||||
font-size: 13px;
|
||||
width: 130px;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
.agv-q-input:focus { border-color: #16b777; }
|
||||
/* 操作列文字链接:纯文字可点击,间隔 5px */
|
||||
#agvTbody a { color: #01AAED; margin-right: 5px; }
|
||||
#agvTbody td { font-size: 13px; }
|
||||
</style>
|
||||
|
||||
<script>
|
||||
// 状态映射(与 AgvTaskStatusEnum 一致:成员名即中文)
|
||||
var agvStatusMap = { 0: "新建", 5: "已下发", 10: "执行中", 90: "异常", 95: "取消", 99: "完成联动失败", 100: "完成" };
|
||||
var agvPage = 1, agvSize = 10, agvTotal = 0;
|
||||
|
||||
// HTML 转义,防止数据中的特殊字符破坏表格结构
|
||||
function agvEsc(v) {
|
||||
return v == null ? "" : String(v).replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
||||
}
|
||||
|
||||
// 加载任务列表(多条件 + 分页)
|
||||
function loadTasks() {
|
||||
var body = {
|
||||
TaskNo: $("#q_taskNo").val(), FromLocation: $("#q_from").val(), ToLocation: $("#q_to").val(),
|
||||
ContainerCode: $("#q_container").val(), SourceSystem: $("#q_source").val(),
|
||||
AgvStatus: $("#q_status").val() === "" ? null : parseInt($("#q_status").val()),
|
||||
Page: agvPage, Size: agvSize
|
||||
};
|
||||
$.ajax({
|
||||
type: "post", url: "/agv/AgvTask/GetTasks", dataType: "json",
|
||||
contentType: "application/json", data: JSON.stringify(body),
|
||||
success: function (json) {
|
||||
var data = json.Data || {};
|
||||
agvTotal = data.Total || 0;
|
||||
var list = data.List || [];
|
||||
if (list.length === 0) {
|
||||
$("#agvTbody").html('<tr><td colspan="10" style="text-align:center; color:#999;">暂无数据</td></tr>');
|
||||
} else {
|
||||
var rows = "";
|
||||
for (var i = 0; i < list.length; i++) {
|
||||
var t = list[i];
|
||||
rows += "<tr>"
|
||||
+ "<td>" + agvEsc(t.TaskNo) + "</td>"
|
||||
+ "<td>" + agvEsc(t.SceneName) + "</td>"
|
||||
+ "<td>" + agvEsc(t.AgvStatusName || agvStatusMap[t.AgvStatus] || "-") + "</td>"
|
||||
+ "<td>" + agvEsc(t.FromLocation) + "</td>"
|
||||
+ "<td>" + agvEsc(t.ToLocation) + "</td>"
|
||||
+ "<td>" + agvEsc(t.ContainerCode) + "</td>"
|
||||
+ "<td>" + agvEsc(t.SourceSystem) + "</td>"
|
||||
+ "<td>" + agvEsc(t.ErrorMsg) + "</td>"
|
||||
+ "<td>" + agvEsc((t.CreateTime || "").replace("T", " ").substring(0, 19)) + "</td>"
|
||||
+ "<td>" + agvOps(t.AgvStatus, t.TaskNo) + "</td>"
|
||||
+ "</tr>";
|
||||
}
|
||||
$("#agvTbody").html(rows);
|
||||
}
|
||||
$("#agvTotal").text("共 " + agvTotal + " 条");
|
||||
var maxPage = Math.max(1, Math.ceil(agvTotal / agvSize));
|
||||
$("#agvPageNo").text("第 " + agvPage + " / " + maxPage + " 页");
|
||||
},
|
||||
error: function () {
|
||||
$("#agvTbody").html('<tr><td colspan="10" style="text-align:center; color:#999;">请求失败,请检查服务是否正常</td></tr>');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 行内操作链接:新建/异常→下发;新建/已下发/执行中→取消;完成联动失败→重试完成
|
||||
function agvOps(st, taskNo) {
|
||||
var html = "";
|
||||
if (st == 0 || st == 90) {
|
||||
html += "<a href='javascript:void(0)' onclick=\"agvDispatch('" + agvEsc(taskNo) + "')\">下发</a>";
|
||||
}
|
||||
if (st == 0 || st == 5 || st == 10) {
|
||||
html += "<a href='javascript:void(0)' onclick=\"agvCancel('" + agvEsc(taskNo) + "')\">取消</a>";
|
||||
}
|
||||
if (st == 99) {
|
||||
html += "<a href='javascript:void(0)' onclick=\"agvRetryFinish('" + agvEsc(taskNo) + "')\">重试完成</a>";
|
||||
}
|
||||
return html == "" ? "-" : html;
|
||||
}
|
||||
|
||||
// 通用行操作:确认后 POST 指定接口,成功后刷新列表
|
||||
function agvPost(url, taskNo, confirmText, successMsg) {
|
||||
layer.confirm(confirmText + " [" + taskNo + "]?", { icon: 3, title: "提示" }, function (index) {
|
||||
layer.close(index);
|
||||
$.ajax({
|
||||
type: "post", dataType: "json", contentType: "application/json",
|
||||
data: JSON.stringify({ TaskNo: taskNo }), url: url,
|
||||
success: function (json) {
|
||||
if (json.Code == 200) {
|
||||
layer.msg(json.Msg || successMsg);
|
||||
loadTasks();
|
||||
} else {
|
||||
layer.alert(json.Msg || "操作失败");
|
||||
}
|
||||
},
|
||||
error: function () { layer.alert("请求失败,请检查服务是否正常"); }
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// 下发(仅新建/异常行显示,后端仍做状态校验兜底)
|
||||
function agvDispatch(taskNo) { agvPost("/agv/AgvTask/Dispatch", taskNo, "确定下发任务", "下发成功"); }
|
||||
// 取消(仅新建/已下发/执行中行显示)
|
||||
function agvCancel(taskNo) { agvPost("/agv/AgvTask/Cancel", taskNo, "确定取消任务", "取消成功"); }
|
||||
// 重试完成联动(仅完成联动失败行显示)
|
||||
function agvRetryFinish(taskNo) { agvPost("/agv/AgvTask/RetryFinish", taskNo, "确定重试完成联动", "重试成功"); }
|
||||
|
||||
// 查询(重置回第 1 页)
|
||||
function agvSearch(page) { agvPage = page || 1; loadTasks(); }
|
||||
// 切换每页条数:回到第 1 页重新加载
|
||||
function agvSizeChange() {
|
||||
agvSize = parseInt($("#q_size").val()) || 10;
|
||||
agvSearch(1);
|
||||
}
|
||||
// 翻页
|
||||
function agvPageTurn(step) {
|
||||
var maxPage = Math.max(1, Math.ceil(agvTotal / agvSize));
|
||||
var target = agvPage + step;
|
||||
if (target < 1 || target > maxPage) return;
|
||||
agvPage = target; loadTasks();
|
||||
}
|
||||
// 重置查询条件
|
||||
function agvReset() {
|
||||
$("#q_taskNo,#q_from,#q_to,#q_container").val("");
|
||||
$("#q_source,#q_status").val("");
|
||||
agvSearch(1);
|
||||
}
|
||||
|
||||
// 打开「下发任务」弹窗:与 WTM 弹窗机制一致(ajax 取 HTML 注入当前文档 type:1),
|
||||
// 当前文档已加载 Vue/ArcoVue/CSS,避免 iframe 内无脚本导致表单模板原样显示
|
||||
var agvCreateLayerIndex = 0;
|
||||
function agvOpenCreate() {
|
||||
$.ajax({
|
||||
type: "get", url: "/agv/AgvTask/Create", dataType: "html",
|
||||
success: function (html) {
|
||||
agvCreateLayerIndex = layer.open({
|
||||
type: 1, title: "下发任务", area: ["800px", "90%"], content: html
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 供 Create 弹窗关闭后刷新列表
|
||||
function reloadAgvTask() { loadTasks(); }
|
||||
|
||||
// 初始化:填充状态下拉 + 来源系统下拉 + 首次加载
|
||||
$(function () {
|
||||
var statusSel = $("#q_status");
|
||||
for (var k in agvStatusMap) { statusSel.append('<option value="' + k + '">' + agvStatusMap[k] + "</option>"); }
|
||||
$.ajax({
|
||||
type: "post", url: "/agv/AgvTask/GetSourceSystems", dataType: "json", contentType: "application/json", data: "{}",
|
||||
success: function (json) {
|
||||
var list = json.Data || [];
|
||||
for (var i = 0; i < list.length; i++) { $("#q_source").append('<option value="' + agvEsc(list[i]) + '">' + agvEsc(list[i]) + "</option>"); }
|
||||
}
|
||||
});
|
||||
loadTasks();
|
||||
});
|
||||
</script>
|
||||
Reference in new issue
Block a user