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

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

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