wjx 2 jaren geleden
bovenliggende
commit
0aa026ec98

+ 2 - 1
src/pages/launchSystemNew/components/textAideInput/index.tsx

@@ -1,5 +1,6 @@
 import { useAjax } from "@/Hook/useAjax"
 import { getText } from "@/services/launchAdq/global"
+import { txtLength } from "@/utils/utils";
 import { Input, List, Popover, Space } from "antd";
 import React, { useEffect } from "react"
 import { useState } from "react";
@@ -70,7 +71,7 @@ const TextAideInput: React.FC<Props> = (props) => {
                 />
             </Popover>
 
-            <span>{`${text?.length ?? 0}/${maxTextLength}`}</span>
+            <span>{`${txtLength(text)}/${maxTextLength}`}</span>
         </Space>
     </div>
 }

+ 50 - 3
src/pages/launchSystemNew/launchManage/createAd/creative/modal/index.tsx

@@ -15,6 +15,7 @@ import { creativeConfig, overrideCanvasHeadOptionEnum } from './config'
 import BrandImage from './brandImage'
 import HeadNickJump from './headNickJump'
 import moment from 'moment'
+import { txtLength } from '@/utils/utils'
 interface Props {
     queryForm: Partial<CreateAdProps>,
     title?: string,
@@ -865,7 +866,25 @@ function CreativePup(props: Props) {
                             adcreative_template?.adcreativeElements?.filter(item => item.name === 'title').map(item => {
                                 return <div key={item.fieldType}>
                                     <Form.Item label={<strong>{item.description}(选填)</strong>} className={'my_title'} >
-                                        <Form.Item name={item.name} rules={[{ pattern: RegExp(item.restriction.textRestriction.textPattern?.replace(/\+/ig, `{1,${item.restriction.textRestriction.maxLength}}`)), message: '请输入正确的' + item.description }]} noStyle>
+                                        <Form.Item
+                                            name={item.name}
+                                            rules={[{
+                                                // pattern: RegExp(item.restriction.textRestriction.textPattern?.replace(/\+/ig, `{1,${item.restriction.textRestriction.maxLength}}`)),
+                                                required: true,
+                                                message: '请输入正确的' + item.description,
+                                                validator: (rule, value) => {
+                                                    if (!value) {
+                                                        return Promise.reject()
+                                                    } else if (!value.match(RegExp(item.restriction.textRestriction.textPattern))) {
+                                                        return Promise.reject()
+                                                    } else if (txtLength(value) > item.restriction.textRestriction.maxLength) {
+                                                        return Promise.reject()
+                                                    }
+                                                    return Promise.resolve()
+                                                }
+                                            }]}
+                                            noStyle
+                                        >
                                             <Input
                                                 placeholder={'请输入' + item.description}
                                                 style={{ width: 500 }}
@@ -901,7 +920,21 @@ function CreativePup(props: Props) {
                             let maxNum = (adcreativeTemplateId === 1708 || adcreativeTemplateId === 1707) && actionBtn ? 10 : item.restriction.textRestriction.maxLength
                             return <div key={item.fieldType}>
                                 <Form.Item label={<strong>{item.description}</strong>} className={'my_description'}>
-                                    <Form.Item name={item.name} noStyle rules={[{ required: true, pattern: RegExp(item.restriction.textRestriction.textPattern?.replace(/\+/ig, `{1,${maxNum}}`)), message: '请输入正确的' + item.description }]}>
+                                    <Form.Item name={item.name} noStyle rules={[{
+                                        required: true,
+                                        // pattern: RegExp(item.restriction.textRestriction.textPattern?.replace(/\+/ig, `{1,${maxNum}}`)), 
+                                        message: '请输入正确的' + item.description,
+                                        validator: (rule, value) => {
+                                            if (!value) {
+                                                return Promise.reject()
+                                            } else if (!value.match(RegExp(item.restriction.textRestriction.textPattern))) {
+                                                return Promise.reject()
+                                            } else if (txtLength(value) > maxNum) {
+                                                return Promise.reject()
+                                            }
+                                            return Promise.resolve()
+                                        }
+                                    }]}>
                                         <Input
                                             placeholder={'请输入' + item.description}
                                             style={{ width: 500 }}
@@ -1044,7 +1077,21 @@ function CreativePup(props: Props) {
                             </Form.Item>
                             <div className={'my_endPageDesc'} >
                                 <Form.Item label={<strong>结束文案</strong>}>
-                                    <Form.Item name='endPageDesc' rules={[{ required: true, pattern: RegExp("^[^\\<\\>\\&'\\\"\\/\\x08\\x09\\x0A\\x0D\\\\]{1,12}$"), message: '请输入正确的结束页文案' }]} noStyle>
+                                    <Form.Item name='endPageDesc' rules={[{
+                                        required: true,
+                                        // pattern: RegExp("^[^\\<\\>\\&'\\\"\\/\\x08\\x09\\x0A\\x0D\\\\]{1,12}$"),
+                                        message: '请输入正确的结束页文案',
+                                        validator: (rule, value) => {
+                                            if (!value) {
+                                                return Promise.reject()
+                                            } else if (!value.match(RegExp("^[^\\<\\>\\&'\\\"\\/\\x08\\x09\\x0A\\x0D\\\\]+$"))) {
+                                                return Promise.reject()
+                                            } else if (txtLength(value) > 12) {
+                                                return Promise.reject()
+                                            }
+                                            return Promise.resolve()
+                                        }
+                                    }]} noStyle>
                                         <Input
                                             placeholder='请输入结束页文案'
                                             style={{ width: 300 }}

+ 37 - 2
src/pages/launchSystemNew/launchManage/createAd/creativeCL/modal/copywriting.tsx

@@ -1,4 +1,5 @@
 import TextAideInput from "@/pages/launchSystemNew/components/textAideInput"
+import { txtLength } from "@/utils/utils"
 import { MinusCircleOutlined, PlusOutlined } from "@ant-design/icons"
 import { Button, Collapse, Form, Modal, Popconfirm, Space } from "antd"
 import React, { useEffect, useState } from "react"
@@ -120,7 +121,24 @@ const Copywriting: React.FC<Props> = (props) => {
                                 {textData?.map((item, index) => {
                                     if (item.name === 'title') {
                                         return <div key={'title' + item.fieldType}>
-                                            <Form.Item {...field} label={<strong>{item.description}(选填)</strong>} name={[field.name, item.name]} rules={[{ pattern: RegExp(item.restriction.textRestriction.textPattern?.replace(/\+/ig, `{1,${item.restriction.textRestriction.maxLength}}`)), message: '请输入正确的' + item.description }]}>
+                                            <Form.Item
+                                                {...field}
+                                                label={<strong>{item.description}(选填)</strong>}
+                                                name={[field.name, item.name]}
+                                                rules={[{
+                                                    required: true,
+                                                    message: '请输入正确的' + item.description,
+                                                    validator: (rule, value) => {
+                                                        if (!value) {
+                                                            return Promise.reject()
+                                                        } else if (!value.match(RegExp(item.restriction.textRestriction.textPattern))) {
+                                                            return Promise.reject()
+                                                        } else if (txtLength(value) > item.restriction.textRestriction.maxLength) {
+                                                            return Promise.reject()
+                                                        }
+                                                        return Promise.resolve()
+                                                    }
+                                                }]}>
                                                 <TextAideInput placeholder={'请输入' + item.description} style={{ width: 450 }} maxTextLength={item.restriction.textRestriction.maxLength} />
                                             </Form.Item>
                                         </div>
@@ -128,7 +146,24 @@ const Copywriting: React.FC<Props> = (props) => {
                                     if (item.name === 'description') {
                                         let maxNum = (adcreativeTemplateId === 1708 || adcreativeTemplateId === 1707) && linkNameType ? 10 : item.restriction.textRestriction.maxLength
                                         return <div key={'description' + item.fieldType}>
-                                            <Form.Item {...field} label={<strong>{item.description}</strong>} name={[field.name, item.name]} rules={[{ required: true, pattern: RegExp(item.restriction.textRestriction.textPattern?.replace(/\+/ig, `{1,${maxNum}}`)), message: '请输入正确的' + item.description }]}>
+                                            <Form.Item
+                                                {...field}
+                                                label={<strong>{item.description}</strong>}
+                                                name={[field.name, item.name]}
+                                                rules={[{
+                                                    required: true, message: '请输入正确的' + item.description, validator: (rule, value) => {
+                                                        if (!value) {
+                                                            return Promise.reject()
+                                                        } else if (!value.match(RegExp(item.restriction.textRestriction.textPattern))) {
+                                                            return Promise.reject()
+                                                        } else if (txtLength(value) > item.restriction.textRestriction.maxLength) {
+                                                            return Promise.reject()
+                                                        }
+                                                        return Promise.resolve()
+                                                        // pattern: RegExp(item.restriction.textRestriction.textPattern?.replace(/\+/ig, `{1,${item.restriction.textRestriction.maxLength}}`))
+                                                    }
+                                                }]}
+                                            >
                                                 <TextAideInput placeholder={'请输入' + item.description} style={{ width: 450 }} maxTextLength={maxNum} />
                                             </Form.Item>
                                         </div>