Commit 8e2d9467 authored by 武广's avatar 武广

fix: 修改新增分组清空套餐数据的问题

parent 4d334927
......@@ -21,7 +21,7 @@ const FormCai = forwardRef((props, ref) => {
const { gitem, groupName, groupkey, packageIndex } = props;
const onDel = (callback, name, key) => {
callback(name);
// callback(name);
props.onDelCai(packageIndex, groupkey, key);
};
......@@ -155,7 +155,7 @@ const FormPackage = forwardRef((props, ref) => {
const [list, setList] = useState([]);
const [form] = Form.useForm();
const { validateFields } = form;
const { validateFields, getFieldsValue } = form;
const onCheck = async () => {
console.log('form :>> ', form);
......@@ -181,15 +181,16 @@ const FormPackage = forwardRef((props, ref) => {
const str = groupName && groupName.trim();
if (str) {
const arr = [...list];
arr[groupIndex].children.push({
const fieldsValue = getFieldsValue();
const obj = {
groupName: str,
uuid: UUID.createUUID(),
dishes: [getCaiJson(str)],
});
};
arr[groupIndex].children.push(obj);
fieldsValue.lists[groupIndex].children.push(obj);
setList(arr);
form.setFieldsValue({
lists: arr,
});
form.setFieldsValue(fieldsValue);
setVisibleGroup(!1);
}
};
......@@ -217,14 +218,18 @@ const FormPackage = forwardRef((props, ref) => {
// 删除菜品
const onDelCai = (i, j, k) => {
const arr = [...list];
const arrList = props.form.getFieldsValue();
const arrList = getFieldsValue();
const len = arr[i].children[j].dishes.length;
if (len === 1) {
arr[i].children.splice(j, 1);
arr[i].children = [];
arrList.lists[i].children = [];
} else {
arr[i].children[j].dishes.splice(k, 1);
console.log('arrList :>> ', [...arrList.lists]);
arrList.lists[i].children[j].dishes.splice(k, 1);
}
setList(arr);
form.setFieldsValue(arrList);
};
useEffect(() => {
......@@ -254,7 +259,7 @@ const FormPackage = forwardRef((props, ref) => {
} else {
setList([]);
form.setFieldsValue({
list: [],
lists: [],
});
}
}, [props.initData]);
......
......@@ -139,13 +139,13 @@ const FormSettlementOthers = forwardRef((props, ref) => {
<InputNumber min={0} style={{ width: 200 }} placeholder="请输入每日最低接待量" />
</Form.Item>
<Title title="结算信息" />
<Form.Item
{/* <Form.Item
name="packageContent"
label="套餐内容"
rules={[{ required: true, message: '请输入套餐内容, 1000字以内!!' }]}
>
<Input.TextArea showCount maxLength={1000} placeholder="请输入套餐内容, 1000字以内!!" />
</Form.Item>
</Form.Item> */}
<Form.Item
name="settlementMethod"
label="结算方式"
......
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