Files
WMS/HHWMS.Web/Areas/WCS/Views/WCSTask/Index.cshtml
T
zhougf 2b01cc7584 添加wcs任务下发测试
修改入库功能
重新生成material页面
2025-05-26 19:06:50 +08:00

225 lines
8.8 KiB
Plaintext

@{
ViewData["Title"] = "WCS任务下发";
}
<div id="wcsapp">
<a-row :gutter="20">
<a-col :span="24">
<a-card class="general-card">
<a-form :model="form" :rules="rules" ref="formRef" auto-label-width>
<a-form-item label="任务类型" field="taskType">
<a-radio-group v-model="form.taskType" @@change="handleTaskTypeChange">
<a-radio value="in">入库</a-radio>
<a-radio value="out">出库</a-radio>
</a-radio-group>
</a-form-item>
<a-form-item label="任务号" field="taskNo">
<a-input v-model="form.taskNo" ref="taskNoRef" placeholder="请输入任务号(选填)" @@keydown.enter.prevent="focusNext('palletNoRef')" />
</a-form-item>
<a-form-item label="托盘号" field="palletNo">
<a-input v-model="form.palletNo" @@change="scanPallet" ref="palletNoRef" placeholder="请扫描托盘号" @@keydown.enter.prevent="focusNext('fromLocationRef')" />
</a-form-item>
<a-form-item label="起始位置" field="fromLocation">
<a-input v-model="form.fromLocation" ref="fromLocationRef" placeholder="请输入起始位置"
:disabled="form.taskType === 'in'"
@@keydown.enter.prevent="focusNext('toLocationRef')" />
</a-form-item>
<a-form-item label="目标位置" field="toLocation">
<template v-if="form.taskType === 'in'">
<a-input v-model="form.toLocation" ref="toLocationRef" placeholder="请输入目标位置" />
</template>
<template v-else>
<a-select v-model="form.toLocation" placeholder="请选择目标位置" ref="toLocationRef">
<a-option v-for="item in locationOptions"
:key="item.value"
:value="item.value">
{{ item.label }}
</a-option>
</a-select>
</template>
</a-form-item>
<a-form-item>
<a-space>
<a-button type="primary" @@click="submitForm" :loading="loading">下发任务</a-button>
<a-button @@click="resetForm">重置</a-button>
</a-space>
</a-form-item>
</a-form>
</a-card>
</a-col>
</a-row>
</div>
<script>
const { createApp, reactive, ref, onMounted, nextTick, watch } = Vue;
const { Message } = ArcoVue;
const app = createApp({
setup() {
const formRef = ref(null);
const taskNoRef = ref(null);
const palletNoRef = ref(null);
const fromLocationRef = ref(null);
const toLocationRef = ref(null);
const loading = ref(false);
const form = reactive({
taskType: 'in', // 默认入库
taskNo: '',
palletNo: '',
fromLocation: '',
toLocation: ''
});
const locationOptions = ref([
{ value: 'EnterExit_P2001', label: '拣货口1' },
{ value: 'EnterExit_P2003', label: '拣货口2' },
{ value: 'EnterExit_P2005', label: '拣货口3' },
{ value: 'EnterExit_P2007', label: '拣货口4' },
{ value: 'EnterExit_P2009', label: '拣货口5' },
{ value: 'EnterExit_P2011', label: '拣货口6' },
{ value: 'EnterExit_P2013', label: '拣货口7' }
]);
const rules = reactive({
palletNo: [
{ required: true, message: '请输入托盘号', trigger: ['change', 'blur'] }
],
fromLocation: [
{
required: form.taskType === 'out',
message: '请输入起始位置',
trigger: ['change', 'blur']
}
],
toLocation: [
{ required: true, message: '请输入/选择目标位置', trigger: ['change', 'blur'] }
]
});
// 任务类型变更处理
const handleTaskTypeChange = () => {
if (form.taskType === 'in') {
form.fromLocation = ''; // 入库时清空起始位置
}
form.toLocation = ''; // 清空目标位置
// 更新验证规则
rules.fromLocation[0].required = form.taskType === 'out';
};
// 扫描托盘号
const scanPallet = () => {
if (!form.palletNo) return;
// TODO: 实现托盘号验证逻辑
};
// 提交表单
const submitForm = () => {
formRef.value.validate((errors) => {
if (!errors) {
loading.value = true;
$.ajax({
type: "post",
dataType: "json",
contentType: "application/json",
data: JSON.stringify(form),
url: "/wcs/WCSTask/SubmitTask",
success: (json) => {
if (json.Success) {
Message.success(json.Msg || '任务下发成功!');
resetForm();
} else {
Message.error(json.Msg || '任务下发失败!');
}
},
error: (xhr, status, error) => {
Message.error('提交失败:' + error);
},
complete: () => {
loading.value = false;
}
});
} else {
Message.error('请填写所有必填项!');
}
});
};
// 重置表单
const resetForm = () => {
formRef.value.resetFields();
setTimeout(() => {
if (taskNoRef.value) {
taskNoRef.value.focus();
}
}, 100);
};
// 焦点跳转到下一个输入框
const focusNext = (nextRef) => {
const refMap = {
palletNoRef: palletNoRef,
fromLocationRef: fromLocationRef,
toLocationRef: toLocationRef
};
const nextElement = refMap[nextRef];
if (nextElement?.value) {
// 先让当前元素失去焦点
if (document.activeElement) {
document.activeElement.blur();
}
// 使用 nextTick 确保 DOM 更新完成
nextTick(() => {
if (nextElement.value.$el) {
// 处理 Input 组件
const input = nextElement.value.$el.querySelector('input');
if (input) {
input.focus();
}
} else {
// 处理基础组件
nextElement.value.focus();
}
});
}
};
// 生命周期钩子
onMounted(() => {
// 页面加载时自动聚焦第一个输入框
setTimeout(() => {
if (taskNoRef.value) {
taskNoRef.value.focus();
}
}, 100);
});
return {
formRef,
taskNoRef,
palletNoRef,
fromLocationRef,
toLocationRef,
form,
loading,
locationOptions,
rules,
handleTaskTypeChange,
scanPallet,
submitForm,
resetForm,
focusNext
};
}
});
app.use(ArcoVue);
app.mount('#wcsapp');
</script>