Commit 47411217 authored by 武广's avatar 武广

Merge branch 'feature/package-upgrade' into 'master'

Feature/package upgrade

See merge request !74
parents d50542cd c9195344
import React, { useState, forwardRef, useEffect, useImperativeHandle } from 'react';
import { Form, Button, Row, Col, Input, Select, Modal, notification } from 'antd';
import { Form, Button, Row, Col, Input, Select, Modal, notification, Popover } from 'antd';
import { PlusOutlined } from '@ant-design/icons';
import styles from '../common.less';
import { isIntegerNotZero, isCheckPriceOneDecimal } from '@/utils/validator';
......@@ -15,19 +15,29 @@ const getCaiJson = gname => ({
gName: gname,
quantity: '',
dishName: '',
subtitle: '',
unit: '',
price: '',
skuId: '',
});
const FormCai = forwardRef((props, ref) => {
const { gitem, groupName, groupkey, packageIndex } = props;
const { gitem, groupName, groupkey, packageIndex, form, groupIndex } = props;
const lists = form.getFieldValue('lists');
const subTitles = lists[packageIndex].children[groupIndex].dishes.map(item => item.subtitle);
const [subTitle, setSubTitle] = useState(subTitles);
const onDel = (callback, name, key) => {
// callback(name);
props.onDelCai(packageIndex, groupkey, key);
};
const onChange = (e, i) => {
const { value } = e.target;
const arr = [...subTitle];
arr[i] = value;
setSubTitle(arr);
};
const onAdd = (callback, key) => {
if (props.onAddCai(packageIndex, groupkey)) {
callback(getCaiJson(groupName));
......@@ -40,7 +50,7 @@ const FormCai = forwardRef((props, ref) => {
<>
{items.map(({ key, name }, caiIndex) => (
<Row gutter={24} key={`cai_${key}`} className={styles.caiRow}>
<Col span={5}>
<Col span={3}>
<Form.Item name={[name, 'gName']}>
<Input readOnly hidden />
<span>{groupName}</span>
......@@ -80,7 +90,7 @@ const FormCai = forwardRef((props, ref) => {
</Select>
</Form.Item>
</Col>
<Col span={4}>
<Col span={3}>
<Form.Item
name={[name, 'price']}
rules={[
......@@ -91,7 +101,18 @@ const FormCai = forwardRef((props, ref) => {
<Input maxLength={10} />
</Form.Item>
</Col>
<Col span={3}>
<Col span={4}>
<Popover content={() => subTitle[caiIndex]} trigger="hover">
<Form.Item
name={[name, 'subtitle']}
onChange={e => onChange(e, caiIndex)}
// rules={[{ required: true, message: '请输入副标题' }]}
>
<Input maxLength={100} placeholder="最多100个字" />
</Form.Item>
</Popover>
</Col>
<Col span={2}>
<Button type="link" onClick={() => onDel(remove, name, key)}>
删除
</Button>
......@@ -118,15 +139,16 @@ const FormGroup = forwardRef((props, ref) => {
<Form.List name={item}>
{(items, { add, remove }) => (
<>
{items.map(({ key, name }) => (
{items.map(({ key, name }, index) => (
<div className={styles.groupMargin} key={`group_${key}`}>
<Row gutter={24} className={styles.groupHeader}>
<Col span={5}>组名</Col>
<Col span={3}>组名</Col>
<Col span={3}>数量</Col>
<Col span={4}>菜名</Col>
<Col span={4}>标题</Col>
<Col span={2}>单位</Col>
<Col span={4}>价格</Col>
<Col span={3}>操作</Col>
<Col span={3}>价格</Col>
<Col span={4}>副标题</Col>
<Col span={2}>操作</Col>
<Col span={3}>
<div>
<Form.Item name={[name, 'groupName']}>
......@@ -138,6 +160,8 @@ const FormGroup = forwardRef((props, ref) => {
<FormCai
gitem={[name, 'dishes']}
packageIndex={packageIndex}
groupIndex={index}
form={form}
groupkey={key}
onAddCai={onAddCai}
onDelCai={onDelCai}
......
......@@ -92,6 +92,7 @@ const ServiceGoods = options => {
setPageLoading(true);
setCategoryIds([]);
setVisibleCacheEdit(false);
resetForm();
const timer = setTimeout(() => {
setPageLoading(false);
resetForm();
......
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