import React, { useState, useEffect } from "react"; import { Form, Input, InputNumber, Select, Divider, Radio, Row, Image, Modal, Button } from "antd"; import { formItemLayout } from "../entity"; import { FormInstance } from "antd/lib/form"; import * as api from "../api"; import WareLimitType from "./WareLimitType"; import ShopLimit from "./ShopLimit"; import useInitail from "@/hooks/useInitail"; import { PaymentTypeEnum } from '@/pages/coupon/CashChange/api'; import { RightOutlined } from '@ant-design/icons'; import RenderSelectGoos from '@/pages/capital/ReceiveRules/subPages/GoodsDimension/components/RenderSelectGoos'; const Option = Select.Option; interface Props { // brandId: number, info: MktConponSpace.ConListParams; form: FormInstance; readonly: boolean; getCouponType?: Function; confNo?: string; limitCoupon?: string[]; // 优惠券类型限制 carSelectApi?: Function expires?: boolean; changeEditKeys?: string[]; } export default function FullReduce({ info, readonly, form, getCouponType, confNo, limitCoupon, carSelectApi, expires, changeEditKeys, }: Props) { const [classifyInfo, setClassifyInfo] = useState({ code: "" }); const { data: ClassifyList } = useInitail(api.fetchClassifyList, [], {}); const { data: cashChangeTypes } = useInitail(api.fetchExchangeList, [], {}); const [visible, setVisible] = useState(false); useEffect(() => { setClassifyInfo({ code: info.classifyCode }); const currentItem = ClassifyList.filter( (i) => i.code === info.classifyCode ); if (currentItem.length) { getCouponType && getCouponType(currentItem[0].type); } }, [info.classifyCode]); function changeScene(v: any) { const currentItems = ClassifyList.filter((i) => i.code === v.value)[0]; form.setFieldsValue({ aliasName: currentItems.type == 1 ? currentItems.name : undefined, settlementType: 1, settlementCalType: v.value === "xjdhq" ? 1 : undefined, }); getCouponType && getCouponType(currentItems.type); setClassifyInfo({ code: v.value }); let limitItem = currentItems.schemes .split(",") .map((i: string) => { if (i === "1") { return ({ externalRely: true, limitScheme: true, schemeType: i }); } else { return ({ schemeType: i, limitScheme: false }); } }); if (currentItems.schemes.split(",").includes('7')) { const item = limitItem[1]; limitItem[1] = limitItem[2]; limitItem[2] = item; } // form.setFieldsValue({ schemeList: currentItems.schemes !== "0" ? limitItem : [] }); form.setFieldsValue({ schemeList: limitItem }); } // 优惠券类型限制 function screenCouponType() { const list = limitCoupon && limitCoupon.length ? ClassifyList.filter(v => limitCoupon.includes(v.code)) : ClassifyList; return list || []; } return (
{classifyInfo.code === "xjdhq" && ( )} 示例:至高6500元鲸喜基金;
setVisible(true)} > 预览
} >
{!!expires && ( 固定天数为0的时候,即有效期为当天23:59:59} rules={[{ required: true, message: "请输入优惠券固定天数有效期时间" }]} > )} {/* 实物兑换券选择兑换物品 */} {classifyInfo.code === "dhyhq" && ( *兑换物品仅限一个} rules={[{ required: true, message: '请选择' }]}> )} 商家结算给三方 {!["dhyhq"].includes(classifyInfo.code) && ( 厂家结算给商家 )} 系数 {!["xjdhq"].includes(classifyInfo.code) && ( 金额 )} prevValues.settlementCalType != currentValues.settlementCalType} > {({ getFieldValue }): any => { const calType = getFieldValue("settlementCalType"); const max = calType == 1 ? 1 : undefined; return ( ({ validator(_, value) { if (calType === 2 && value > getFieldValue("amount")) { return Promise.reject( new Error("结算金额不能大于优惠券券面金额") ); } return Promise.resolve(); }, }), ]} > ); }} 场景限制条件 setVisible(false)} footer={false} >
); }