@@ -202,6 +202,11 @@ const MaterialConfig = (props) => { | |||||
], | ], | ||||
}, | }, | ||||
}, | }, | ||||
{ | |||||
title: '物料数量', | |||||
dataIndex: 'BomQty', | |||||
width: 50 | |||||
}, | |||||
{ | { | ||||
title: '操作', | title: '操作', | ||||
dataIndex: 'option', | dataIndex: 'option', | ||||
@@ -218,6 +223,13 @@ const MaterialConfig = (props) => { | |||||
}} | }} | ||||
> | > | ||||
移除物料 | 移除物料 | ||||
</a>, | |||||
<a key="primary3" | |||||
type="primary" style={{ marginLeft: '10px' }} onClick={() => { | |||||
editMaterialForm.setFieldsValue(record); | |||||
setIsModalEditMaterial(true); | |||||
}}> | |||||
设置数量 | |||||
</a> | </a> | ||||
], | ], | ||||
}, | }, | ||||
@@ -256,7 +268,11 @@ const MaterialConfig = (props) => { | |||||
} | } | ||||
const findBom = bomDropDown.find(item => item.id === currentSelectedBom); | const findBom = bomDropDown.find(item => item.id === currentSelectedBom); | ||||
if (findBom) { | if (findBom) { | ||||
props.onMaterialRelationBom(findBom.id, selectedRows); | |||||
const temp = JSON.parse(JSON.stringify(selectedRows)); | |||||
temp.forEach(item => { | |||||
item.BomQty = 0; | |||||
}); | |||||
props.onMaterialRelationBom(findBom.id, temp); | |||||
setSelectRowKeys([]); | setSelectRowKeys([]); | ||||
setSetSelectedRows([]); | setSetSelectedRows([]); | ||||
} | } | ||||
@@ -271,6 +287,12 @@ const MaterialConfig = (props) => { | |||||
} | } | ||||
} | } | ||||
/** | |||||
* 更新物料信息 | |||||
*/ | |||||
const [isModalEditMaterial, setIsModalEditMaterial] = useState(false); | |||||
const [editMaterialForm] = Form.useForm(); | |||||
useEffect(() => { | useEffect(() => { | ||||
onFetchMaterialTypeList(); | onFetchMaterialTypeList(); | ||||
onFetchMaterialUnit(); | onFetchMaterialUnit(); | ||||
@@ -630,7 +652,7 @@ const MaterialConfig = (props) => { | |||||
</Form> | </Form> | ||||
</Modal> | </Modal> | ||||
<Drawer width={800} title="物料关联配方" placement="right" onClose={() => setShowMenuDrawer(false)} visible={showMenuDrawer}> | |||||
<Drawer width={900} title="物料关联配方" placement="right" onClose={() => setShowMenuDrawer(false)} visible={showMenuDrawer}> | |||||
<div style={{ display: 'flex', alignItems: 'center', marginBottom: '10px' }}> | <div style={{ display: 'flex', alignItems: 'center', marginBottom: '10px' }}> | ||||
<div className={indexStyles.current_selected_obj}> | <div className={indexStyles.current_selected_obj}> | ||||
当前配方: | 当前配方: | ||||
@@ -721,7 +743,67 @@ const MaterialConfig = (props) => { | |||||
</div> | </div> | ||||
<Button className={indexStyles.sure_add_btn} type='primary' onClick={onMaterialRelationBom}>确定关联</Button> | <Button className={indexStyles.sure_add_btn} type='primary' onClick={onMaterialRelationBom}>确定关联</Button> | ||||
</Drawer> | </Drawer> | ||||
<Modal title="设置物料数量" visible={isModalEditMaterial} footer={null} onCancel={() => setIsModalEditMaterial(false)}> | |||||
<Form | |||||
form={editMaterialForm} | |||||
name="basic" | |||||
labelCol={{ | |||||
span: 8, | |||||
}} | |||||
wrapperCol={{ | |||||
span: 16, | |||||
}} | |||||
initialValues={{ | |||||
remember: true, | |||||
}} | |||||
onFinish={(values) => { | |||||
setIsModalEditMaterial(false); | |||||
props.onUpdateMaterial(currentSelectedBom, values); | |||||
}} | |||||
autoComplete="off" | |||||
> | |||||
<Form.Item name="id" hidden={true}> | |||||
<Input /> | |||||
</Form.Item> | |||||
<Form.Item | |||||
label="物料名称" | |||||
name="name" | |||||
rules={[ | |||||
{ | |||||
required: true, | |||||
message: '请输入物料名称', | |||||
}, | |||||
]} | |||||
> | |||||
<Input disabled /> | |||||
</Form.Item> | |||||
<Form.Item | |||||
label="物料数量" | |||||
name="BomQty" | |||||
rules={[ | |||||
{ | |||||
required: true, | |||||
message: '请输入物料数量', | |||||
}, | |||||
]} | |||||
> | |||||
<Input /> | |||||
</Form.Item> | |||||
<Form.Item | |||||
wrapperCol={{ | |||||
offset: 8, | |||||
span: 16, | |||||
}} | |||||
> | |||||
<Button type="primary" htmlType="submit"> | |||||
确定 | |||||
</Button> | |||||
</Form.Item> | |||||
</Form> | |||||
</Modal> | |||||
</> | </> | ||||
} | } | ||||
@@ -86,8 +86,17 @@ const StepsButton = (props) => { | |||||
}); | }); | ||||
return; | return; | ||||
} | } | ||||
for(let n = 0; n < materialList.length; n++) { | |||||
if (!materialList[n].BomQty) { | |||||
notification.error({ | |||||
message: '物料配置出错', | |||||
description: `请为物料【${materialList[n].name}】设置数量!`, | |||||
placement: 'topRight' | |||||
}); | |||||
return; | |||||
} | |||||
} | |||||
} | } | ||||
} | } | ||||
} | } | ||||
props.next(); | props.next(); | ||||
@@ -122,7 +131,7 @@ const StepsButton = (props) => { | |||||
bomItem?.materialConfig.forEach((materialItem, materialIndex) => { | bomItem?.materialConfig.forEach((materialItem, materialIndex) => { | ||||
jsonData.foodMenuList[foodMenuIndex].goodsList[foodIndex].BOMList[bomIndex].BatchingList[materialIndex] = { | jsonData.foodMenuList[foodMenuIndex].goodsList[foodIndex].BOMList[bomIndex].BatchingList[materialIndex] = { | ||||
id: materialItem.id, | id: materialItem.id, | ||||
BomQty: 10 | |||||
BomQty: materialItem.BomQty | |||||
} | } | ||||
}); | }); | ||||
}); | }); | ||||
@@ -93,6 +93,27 @@ const QuickStart = () => { | |||||
}); | }); | ||||
} | } | ||||
/** | |||||
* 更新物料信息 | |||||
* @param {*} bomId | |||||
* @param {*} material | |||||
*/ | |||||
const onUpdateMaterial = (bomId, material) => { | |||||
const tempQuick = JSON.parse(JSON.stringify(quickStartObj)); | |||||
tempQuick.foodMenuConfig.forEach(findFoodMenu => { | |||||
findFoodMenu.goodsConfig.forEach(findGoods => { | |||||
const findBom = findGoods.bomConfig.find(item => item.id === bomId); | |||||
if (findBom) { | |||||
const findMaterial = findBom.materialConfig.find(materialItem => materialItem.id === material.id); | |||||
if (findMaterial) { | |||||
findMaterial.BomQty = Number.parseFloat(material.BomQty) || 0; | |||||
setQuickStartObj(tempQuick); | |||||
} | |||||
} | |||||
}); | |||||
}); | |||||
} | |||||
//下一步 | //下一步 | ||||
const next = () => { | const next = () => { | ||||
setCurrent(current + 1); | setCurrent(current + 1); | ||||
@@ -111,7 +132,7 @@ const QuickStart = () => { | |||||
<FoodMenuConfig foodMenuConfig={quickStartObj.foodMenuConfig} current={current} steps={stepsText} prev={prev} next={next} onSelectedChange={onSelectedChange}></FoodMenuConfig>, | <FoodMenuConfig foodMenuConfig={quickStartObj.foodMenuConfig} current={current} steps={stepsText} prev={prev} next={next} onSelectedChange={onSelectedChange}></FoodMenuConfig>, | ||||
<GoodsConfig deviceConfig={quickStartObj.deviceConfig} foodMenuConfig={quickStartObj.foodMenuConfig} current={current} steps={stepsText} onAddGoodsToFoodMenu={onAddGoodsToFoodMenu} prev={prev} next={next} ></GoodsConfig>, | <GoodsConfig deviceConfig={quickStartObj.deviceConfig} foodMenuConfig={quickStartObj.foodMenuConfig} current={current} steps={stepsText} onAddGoodsToFoodMenu={onAddGoodsToFoodMenu} prev={prev} next={next} ></GoodsConfig>, | ||||
<BomConfig foodMenuConfig={quickStartObj.foodMenuConfig} current={current} steps={stepsText} prev={prev} next={next} onBomRelationGoods={onBomRelationGoods}></BomConfig>, | <BomConfig foodMenuConfig={quickStartObj.foodMenuConfig} current={current} steps={stepsText} prev={prev} next={next} onBomRelationGoods={onBomRelationGoods}></BomConfig>, | ||||
<MaterialConfig foodMenuConfig={quickStartObj.foodMenuConfig} current={current} steps={stepsText} onMaterialRelationBom={onMaterialRelationBom} prev={prev} next={next}></MaterialConfig>, | |||||
<MaterialConfig foodMenuConfig={quickStartObj.foodMenuConfig} current={current} steps={stepsText} onMaterialRelationBom={onMaterialRelationBom} onUpdateMaterial={onUpdateMaterial} prev={prev} next={next}></MaterialConfig>, | |||||
<ConfirmConfig {...quickStartObj} current={current} steps={stepsText} prev={prev} ></ConfirmConfig> | <ConfirmConfig {...quickStartObj} current={current} steps={stepsText} prev={prev} ></ConfirmConfig> | ||||
]; | ]; | ||||