|  | @@ -4,6 +4,7 @@ import { Button, Card, Form, Modal, Popconfirm, Radio, Space, message } from "an
 | 
	
		
			
				|  |  |  import React, { useEffect, useState } from "react"
 | 
	
		
			
				|  |  |  import { TextTypeList } from "../../const"
 | 
	
		
			
				|  |  |  import { DeleteOutlined, PlusOutlined } from "@ant-design/icons"
 | 
	
		
			
				|  |  | +import AddTextS from "./addTextS"
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  interface Props {
 | 
	
	
		
			
				|  | @@ -29,6 +30,8 @@ const NewText: React.FC<Props> = ({ visible, onClose, onChange, value, textData,
 | 
	
		
			
				|  |  |      const textDto = Form.useWatch('textDto', form)
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      const [textList, setTextList] = useState<PULLIN.TextDtoProps[]>([])
 | 
	
		
			
				|  |  | +    const [desVisible, setDesVisible] = useState<boolean>(false)
 | 
	
		
			
				|  |  | +    const [addSTitle, setAddStitle] = useState<string>()
 | 
	
		
			
				|  |  |      /*************************************/
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      const handleOk = (values: any) => {
 | 
	
	
		
			
				|  | @@ -72,7 +75,13 @@ const NewText: React.FC<Props> = ({ visible, onClose, onChange, value, textData,
 | 
	
		
			
				|  |  |      }, [textData])
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      return <Modal
 | 
	
		
			
				|  |  | -        title={<strong style={{ fontSize: 20 }}>创意文案</strong>}
 | 
	
		
			
				|  |  | +        title={<Space>
 | 
	
		
			
				|  |  | +            <strong style={{ fontSize: 20 }}>创意文案</strong>
 | 
	
		
			
				|  |  | +            {type !== 0 && <>
 | 
	
		
			
				|  |  | +                {textList.some(item => item.value === "description") && <a style={{ fontSize: 12 }} onClick={() => { setDesVisible(true); setAddStitle(textList.find(item => item.value === "description")?.label) }}>批量添加{textList.find(item => item.value === "description")?.label}</a>}
 | 
	
		
			
				|  |  | +                {textList.some(item => item.value === "title") && <a style={{ fontSize: 12 }} onClick={() => { setDesVisible(true); setAddStitle(textList.find(item => item.value === "description")?.label) }}>批量添加{textList.find(item => item.value === "description")?.label}</a>}
 | 
	
		
			
				|  |  | +            </>}
 | 
	
		
			
				|  |  | +        </Space>}
 | 
	
		
			
				|  |  |          visible={visible}
 | 
	
		
			
				|  |  |          onCancel={onClose}
 | 
	
		
			
				|  |  |          footer={null}
 | 
	
	
		
			
				|  | @@ -186,6 +195,90 @@ const NewText: React.FC<Props> = ({ visible, onClose, onChange, value, textData,
 | 
	
		
			
				|  |  |                  </Space>
 | 
	
		
			
				|  |  |              </Form.Item>
 | 
	
		
			
				|  |  |          </Form>
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        {/* 批量添加 */}
 | 
	
		
			
				|  |  | +        {desVisible && <AddTextS
 | 
	
		
			
				|  |  | +            visible={desVisible}
 | 
	
		
			
				|  |  | +            title={addSTitle}
 | 
	
		
			
				|  |  | +            onClose={() => {
 | 
	
		
			
				|  |  | +                setDesVisible(false)
 | 
	
		
			
				|  |  | +                setAddStitle(undefined)
 | 
	
		
			
				|  |  | +            }}
 | 
	
		
			
				|  |  | +            onChange={(value) => {
 | 
	
		
			
				|  |  | +                if (value) {
 | 
	
		
			
				|  |  | +                    let valList = value
 | 
	
		
			
				|  |  | +                        .split(/\r?\n/)        // 按换行符分割字符串
 | 
	
		
			
				|  |  | +                        .map(line => line.trim()) // 去除每行的首尾空白
 | 
	
		
			
				|  |  | +                        .filter(line => line !== ''); // 过滤掉空行
 | 
	
		
			
				|  |  | +                    let fieldData = textList.find(item => item.label === addSTitle)
 | 
	
		
			
				|  |  | +                    console.log(valList, textDto, fieldData)
 | 
	
		
			
				|  |  | +                    let count = dynamicMaterialDTos.dynamicGroup.length
 | 
	
		
			
				|  |  | +                    if (type === 1) {
 | 
	
		
			
				|  |  | +                        let len = 0
 | 
	
		
			
				|  |  | +                        const newTextDto = textDto.map((item: { [x: string]: any }) => {
 | 
	
		
			
				|  |  | +                            if (fieldData?.value && !item?.[fieldData?.value] && valList.length >= len + 1) {
 | 
	
		
			
				|  |  | +                                return { ...item, [fieldData.value]: valList[len++] }
 | 
	
		
			
				|  |  | +                            }
 | 
	
		
			
				|  |  | +                            return item
 | 
	
		
			
				|  |  | +                        })
 | 
	
		
			
				|  |  | +                        form.setFieldsValue({
 | 
	
		
			
				|  |  | +                            textDto: newTextDto
 | 
	
		
			
				|  |  | +                        })
 | 
	
		
			
				|  |  | +                    } else if (type === 2) {
 | 
	
		
			
				|  |  | +                        let len = 0
 | 
	
		
			
				|  |  | +                        const newTextDto = textDto.map((item: { [x: string]: any }) => {
 | 
	
		
			
				|  |  | +                            if (fieldData?.value && !item?.[fieldData?.value] && valList.length >= len + 1) {
 | 
	
		
			
				|  |  | +                                return { ...item, [fieldData.value]: valList[len++] }
 | 
	
		
			
				|  |  | +                            }
 | 
	
		
			
				|  |  | +                            return item
 | 
	
		
			
				|  |  | +                        })
 | 
	
		
			
				|  |  | +                        let diffTextDto: any[] = []
 | 
	
		
			
				|  |  | +                        if (newTextDto.length < count && len < valList.length) {
 | 
	
		
			
				|  |  | +                            let diffCount = count - newTextDto.length
 | 
	
		
			
				|  |  | +                            let diffTextCount = valList.length - len
 | 
	
		
			
				|  |  | +                            let diff = 0
 | 
	
		
			
				|  |  | +                            if (diffCount >= diffTextCount) {
 | 
	
		
			
				|  |  | +                                diff = diffTextCount
 | 
	
		
			
				|  |  | +                            } else {
 | 
	
		
			
				|  |  | +                                diff = diffCount
 | 
	
		
			
				|  |  | +                            }
 | 
	
		
			
				|  |  | +                            diffTextDto = Array(diff).fill('').map((item: { [x: string]: any }) => {
 | 
	
		
			
				|  |  | +                                if (fieldData?.value) {
 | 
	
		
			
				|  |  | +                                    return { ...item, [fieldData.value]: valList[len++] }
 | 
	
		
			
				|  |  | +                                }
 | 
	
		
			
				|  |  | +                                return item
 | 
	
		
			
				|  |  | +                            })
 | 
	
		
			
				|  |  | +                        }
 | 
	
		
			
				|  |  | +                        form.setFieldsValue({
 | 
	
		
			
				|  |  | +                            textDto: [...newTextDto, ...diffTextDto]
 | 
	
		
			
				|  |  | +                        })
 | 
	
		
			
				|  |  | +                    } else if ([3, 4].includes(type)) {
 | 
	
		
			
				|  |  | +                        let len = 0
 | 
	
		
			
				|  |  | +                        const newTextDto = textDto.map((item: { [x: string]: any }) => {
 | 
	
		
			
				|  |  | +                            if (fieldData?.value && !item?.[fieldData?.value] && valList.length >= len + 1) {
 | 
	
		
			
				|  |  | +                                return { ...item, [fieldData.value]: valList[len++] }
 | 
	
		
			
				|  |  | +                            }
 | 
	
		
			
				|  |  | +                            return item
 | 
	
		
			
				|  |  | +                        })
 | 
	
		
			
				|  |  | +                        let diffTextDto: any[] = []
 | 
	
		
			
				|  |  | +                        if (len < valList.length) {
 | 
	
		
			
				|  |  | +                            let diff = valList.length - len
 | 
	
		
			
				|  |  | +                            diffTextDto = Array(diff).fill('').map((item: { [x: string]: any }) => {
 | 
	
		
			
				|  |  | +                                if (fieldData?.value) {
 | 
	
		
			
				|  |  | +                                    return { ...item, [fieldData.value]: valList[len++] }
 | 
	
		
			
				|  |  | +                                }
 | 
	
		
			
				|  |  | +                                return item
 | 
	
		
			
				|  |  | +                            })
 | 
	
		
			
				|  |  | +                        }
 | 
	
		
			
				|  |  | +                        form.setFieldsValue({
 | 
	
		
			
				|  |  | +                            textDto: [...newTextDto, ...diffTextDto]
 | 
	
		
			
				|  |  | +                        })
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +                setDesVisible(false)
 | 
	
		
			
				|  |  | +                setAddStitle(undefined)
 | 
	
		
			
				|  |  | +            }}
 | 
	
		
			
				|  |  | +        />}
 | 
	
		
			
				|  |  |      </Modal>
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  
 |