Commit 6f360236 by 金民

feat(ckgl): 扩展领料单生成功能并增加库存校验

- 将弹窗宽度从700px调整为1000px以适应更多列显示
- 在表格中新增备料数量和库存数量列
- 修改领料数量字段绑定从blsl改为sl,并初始化为0
- 添加库存数量不足的校验逻辑
- 更新请求参数结构,包含备料数量、库存数量和领料数量
- 移除原领料数量变更事件绑定逻辑
parent 925bd006
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
v-bind="$attrs" v-bind="$attrs"
@register="registerModal" @register="registerModal"
title="生成领料单" title="生成领料单"
width="700px" width="1000px"
:confirmLoading="loading" :confirmLoading="loading"
@ok="handleOk" @ok="handleOk"
@cancel="handleCancel" @cancel="handleCancel"
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
/* 表格数据 */ /* 表格数据 */
const tableData = ref<any[]>([]); const tableData = ref<any[]>([]);
/* 加载状态 */ /* 加载状态 */
const loading = ref(false); const loading = ref(false);
...@@ -42,19 +42,21 @@ ...@@ -42,19 +42,21 @@
const columns: BasicColumn[] = [ const columns: BasicColumn[] = [
{ title: '物料编码', dataIndex: 'wlbh', width: 120 }, { title: '物料编码', dataIndex: 'wlbh', width: 120 },
{ title: '物料名称', dataIndex: 'wlmc', width: 200 }, { title: '物料名称', dataIndex: 'wlmc', width: 200 },
{ title: '备料数量', dataIndex: 'blsl', width: 200 },
{ title: '库存数量', dataIndex: 'kcl', width: 200 },
{ {
title: '领料数量', title: '领料数量',
dataIndex: 'blsl', dataIndex: 'sl',
width: 130, width: 130,
// 常驻输入框 // 常驻输入框
customRender: ({ record }) => customRender: ({ record }) =>
h(InputNumber, { h(InputNumber, {
value: record.blsl, value: 0,
min: 0, min: 0,
max: 999999, max: 999999,
size: 'small', size: 'small',
style: { width: '100%' }, style: { width: '100%' },
onChange: (val) => (record.blsl = val), // onChange: (val) => (record.sl = val),
}), }),
}, },
]; ];
...@@ -69,7 +71,7 @@ ...@@ -69,7 +71,7 @@
async function handleOk() { async function handleOk() {
// 防止重复提交 // 防止重复提交
if (loading.value) return; if (loading.value) return;
// 简单校验:数量不能全 0 // 简单校验:数量不能全 0
const allZero = tableData.value.every((r) => r.blsl === 0); const allZero = tableData.value.every((r) => r.blsl === 0);
if (allZero) { if (allZero) {
...@@ -77,11 +79,20 @@ ...@@ -77,11 +79,20 @@
return; return;
} }
// 校验库存数量是否足够
const insufficientItem = tableData.value.find((r) => (r.kcl || 0) < (r.blsl || 0));
if (insufficientItem) {
createMessage.warning(`${insufficientItem.wlmc}库存数量不足`);
return;
}
// 构建请求参数 // 构建请求参数
const requestData = tableData.value.map(item => ({ const requestData = tableData.value.map((item) => ({
wlbm: item.wlbh, // 物料编码 wlbm: item.wlbh, // 物料编码
wlmc: item.wlmc, // 物料名称 wlmc: item.wlmc, // 物料名称
sl: item.blsl || 0 // 领料数量 blsl: item.blsl || 0, // 备料数量
kcl: item.kcl || 0, // 库存数量
sl: item.sl || 0, // 领料数量
})); }));
loading.value = true; loading.value = true;
...@@ -94,9 +105,9 @@ ...@@ -94,9 +105,9 @@
}, },
{ {
errorMessageMode: 'message', errorMessageMode: 'message',
} },
); );
// 接口调用成功 // 接口调用成功
createMessage.success('领料单生成成功'); createMessage.success('领料单生成成功');
emit('success', tableData.value); // 回传完整数组 emit('success', tableData.value); // 回传完整数组
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment