Commit dfc37e17 by 张恒

Merge remote-tracking branch 'origin/weiqiao-vue3' into weiqiao-vue3

parents d4c05731 6f360236
......@@ -3,7 +3,7 @@
v-bind="$attrs"
@register="registerModal"
title="生成领料单"
width="700px"
width="1000px"
:confirmLoading="loading"
@ok="handleOk"
@cancel="handleCancel"
......@@ -34,7 +34,7 @@
/* 表格数据 */
const tableData = ref<any[]>([]);
/* 加载状态 */
const loading = ref(false);
......@@ -42,19 +42,21 @@
const columns: BasicColumn[] = [
{ title: '物料编码', dataIndex: 'wlbh', width: 120 },
{ title: '物料名称', dataIndex: 'wlmc', width: 200 },
{ title: '备料数量', dataIndex: 'blsl', width: 200 },
{ title: '库存数量', dataIndex: 'kcl', width: 200 },
{
title: '领料数量',
dataIndex: 'blsl',
dataIndex: 'sl',
width: 130,
// 常驻输入框
customRender: ({ record }) =>
h(InputNumber, {
value: record.blsl,
value: 0,
min: 0,
max: 999999,
size: 'small',
style: { width: '100%' },
onChange: (val) => (record.blsl = val),
// onChange: (val) => (record.sl = val),
}),
},
];
......@@ -69,7 +71,7 @@
async function handleOk() {
// 防止重复提交
if (loading.value) return;
// 简单校验:数量不能全 0
const allZero = tableData.value.every((r) => r.blsl === 0);
if (allZero) {
......@@ -77,11 +79,20 @@
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, // 物料编码
wlmc: item.wlmc, // 物料名称
sl: item.blsl || 0 // 领料数量
blsl: item.blsl || 0, // 备料数量
kcl: item.kcl || 0, // 库存数量
sl: item.sl || 0, // 领料数量
}));
loading.value = true;
......@@ -94,9 +105,9 @@
},
{
errorMessageMode: 'message',
}
},
);
// 接口调用成功
createMessage.success('领料单生成成功');
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