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

feat: 修改表单

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