Browse Source

物料设置数量

tags/小炒逻辑变更前
yangwenhua 2 years ago
parent
commit
b37cb04b41
3 changed files with 117 additions and 5 deletions
  1. +84
    -2
      src/pages/quickStart/components/MaterialConfig/index.jsx
  2. +11
    -2
      src/pages/quickStart/components/StepsButton/index.jsx
  3. +22
    -1
      src/pages/quickStart/index.jsx

+ 84
- 2
src/pages/quickStart/components/MaterialConfig/index.jsx View File

@@ -202,6 +202,11 @@ const MaterialConfig = (props) => {
],
},
},
{
title: '物料数量',
dataIndex: 'BomQty',
width: 50
},
{
title: '操作',
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>
],
},
@@ -256,7 +268,11 @@ const MaterialConfig = (props) => {
}
const findBom = bomDropDown.find(item => item.id === currentSelectedBom);
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([]);
setSetSelectedRows([]);
}
@@ -271,6 +287,12 @@ const MaterialConfig = (props) => {
}
}

/**
* 更新物料信息
*/
const [isModalEditMaterial, setIsModalEditMaterial] = useState(false);
const [editMaterialForm] = Form.useForm();

useEffect(() => {
onFetchMaterialTypeList();
onFetchMaterialUnit();
@@ -630,7 +652,7 @@ const MaterialConfig = (props) => {
</Form>
</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 className={indexStyles.current_selected_obj}>
当前配方:
@@ -721,7 +743,67 @@ const MaterialConfig = (props) => {
</div>
<Button className={indexStyles.sure_add_btn} type='primary' onClick={onMaterialRelationBom}>确定关联</Button>
</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>
</>
}


+ 11
- 2
src/pages/quickStart/components/StepsButton/index.jsx View File

@@ -86,8 +86,17 @@ const StepsButton = (props) => {
});
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();
@@ -122,7 +131,7 @@ const StepsButton = (props) => {
bomItem?.materialConfig.forEach((materialItem, materialIndex) => {
jsonData.foodMenuList[foodMenuIndex].goodsList[foodIndex].BOMList[bomIndex].BatchingList[materialIndex] = {
id: materialItem.id,
BomQty: 10
BomQty: materialItem.BomQty
}
});
});


+ 22
- 1
src/pages/quickStart/index.jsx View File

@@ -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 = () => {
setCurrent(current + 1);
@@ -111,7 +132,7 @@ const QuickStart = () => {
<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>,
<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>
];



Loading…
Cancel
Save