Commit 0f8e5501 authored by 陈万宝's avatar 陈万宝

feat: 修改表单

parent 36782629
...@@ -12,6 +12,7 @@ import { ServiceContext } from '../context'; ...@@ -12,6 +12,7 @@ import { ServiceContext } from '../context';
import { debounce } from '@/utils/utils'; import { debounce } from '@/utils/utils';
import AddMenusModal from './AddMenusModal'; import AddMenusModal from './AddMenusModal';
import UploadImage from './UploadImage'; import UploadImage from './UploadImage';
import { apiShopIds, apiQueryShopList } from '../service';
const CreateSelectOption = optionList => const CreateSelectOption = optionList =>
optionList.map(brandItem => ( optionList.map(brandItem => (
...@@ -32,16 +33,16 @@ const FormInformationBasic = forwardRef((props, ref) => { ...@@ -32,16 +33,16 @@ const FormInformationBasic = forwardRef((props, ref) => {
categoryList, categoryList,
virtualCategoryList, virtualCategoryList,
brandList, brandList,
shopList,
afterAddressList, afterAddressList,
specListData, specListData,
queryShopList,
} = props; } = props;
const [form] = Form.useForm(); const [form] = Form.useForm();
const [noreBrandList, setNoreBrandList] = useState([]); const [noreBrandList, setNoreBrandList] = useState([]);
const customer = useContext(ServiceContext); const customer = useContext(ServiceContext);
const childAddMenusModalRef = useRef(null); const childAddMenusModalRef = useRef(null);
const [takeawayImageList, setTakeawayImageList] = useState([]); const [takeawayImageList, setTakeawayImageList] = useState([]);
const [shopIds, setShopIds] = useState([]);
const [shopList, setShopList] = useState([]);
const onCheck = async () => { const onCheck = async () => {
try { try {
...@@ -101,7 +102,25 @@ const FormInformationBasic = forwardRef((props, ref) => { ...@@ -101,7 +102,25 @@ const FormInformationBasic = forwardRef((props, ref) => {
const values = form.getFieldsValue(); const values = form.getFieldsValue();
props.onValuesChange({ infoMation: values }); props.onValuesChange({ infoMation: values });
}, 400); }, 400);
// 查询shopIds
const queryShopIds = async () => {
if (!shopIds.length) {
const result = await apiShopIds();
setShopIds(result.data || []);
}
};
// 查询分组列表
const queryShopList = async params => {
if (!shopList.length) {
const result = await apiQueryShopList(params);
setShopList(result.data || []);
}
};
const onChangeShopId = async e => {
if (e) {
queryShopList({ shopId: e }); // 分组列表
}
};
useImperativeHandle(ref, () => ({ useImperativeHandle(ref, () => ({
onCheck, onCheck,
reset: form.resetFields, reset: form.resetFields,
...@@ -121,6 +140,7 @@ const FormInformationBasic = forwardRef((props, ref) => { ...@@ -121,6 +140,7 @@ const FormInformationBasic = forwardRef((props, ref) => {
console.log('!customer.isTakeawayService', customer); console.log('!customer.isTakeawayService', customer);
console.log('newCategoryList[customer.productType]', newCategoryList[customer.productType]); console.log('newCategoryList[customer.productType]', newCategoryList[customer.productType]);
console.log('newCategoryList[customer.productType]', shopList); console.log('newCategoryList[customer.productType]', shopList);
queryShopIds()
}, [customer.productType]); }, [customer.productType]);
return ( return (
<Form <Form
...@@ -148,11 +168,25 @@ const FormInformationBasic = forwardRef((props, ref) => { ...@@ -148,11 +168,25 @@ const FormInformationBasic = forwardRef((props, ref) => {
<Input placeholder="请输入商品名称" disabled={customer.isDisabled} /> <Input placeholder="请输入商品名称" disabled={customer.isDisabled} />
</Form.Item> </Form.Item>
</Popover> </Popover>
{customer.isTakeawayService && (
<Form.Item
name="productRefShopId"
key="productRefShopId"
label="所属门店"
rules={[{ required: true, message: '请选择所属门店' }]}
>
<Select
fieldNames={{ label: 'name', value: 'id' }}
placeholder="请选择所属门店"
options={shopIds}
onChange={onChangeShopId}
></Select>
</Form.Item>
)}
{/* 菜单分组 */} {/* 菜单分组 */}
{customer.isTakeawayService && ( {customer.isTakeawayService && (
<Form.Item <Form.Item
name="categoryId" name="storageRackIds"
label="菜单分组" label="菜单分组"
rules={[{ type: 'array', required: true, message: '请输入菜单分组' }]} rules={[{ type: 'array', required: true, message: '请输入菜单分组' }]}
> >
...@@ -170,7 +204,8 @@ const FormInformationBasic = forwardRef((props, ref) => { ...@@ -170,7 +204,8 @@ const FormInformationBasic = forwardRef((props, ref) => {
{/* 新增菜单分组弹框 */} {/* 新增菜单分组弹框 */}
<AddMenusModal ref={childAddMenusModalRef} queryShopList={queryShopList} /> <AddMenusModal ref={childAddMenusModalRef} queryShopList={queryShopList} />
<Form.Item <Form.Item
name="storageRackIds" name="categoryId"
key="categoryId"
label="商品类目" label="商品类目"
rules={[{ type: 'array', required: true, message: '请输入商品类目' }]} rules={[{ type: 'array', required: true, message: '请输入商品类目' }]}
> >
......
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