wjx 2 日 前
コミット
681c382fc6

+ 13 - 8
src/pages/weComTask/page/bookLink/bookPromoLinkCreateDTO.tsx

@@ -29,17 +29,22 @@ const BookPromoLinkCreateDTO: React.FC<Props> = ({ restField, name, yueWenCreate
 
     return <>
         <Form.Item
-            {...restField}
-            name={[name, 'bookPromoLinkCreateDTO', 'bookId']}
             label={<strong>作品(书籍)ID</strong>}
-            rules={[{ required: true, message: '请输入作品(书籍)ID!' }]}
+            required
         >
             <Space.Compact style={{ width: '100%' }}>
-                <Input
-                    placeholder="请输入作品(书籍)ID"
-                    style={{ width: '100%' }}
-                    onChange={(e) => getFreeChapterList.mutate({ data: undefined })}
-                />
+                <Form.Item
+                    {...restField}
+                    name={[name, 'bookPromoLinkCreateDTO', 'bookId']}
+                    rules={[{ required: true, message: '请输入作品(书籍)ID!' }]}
+                    noStyle
+                >
+                    <Input
+                        placeholder="请输入作品(书籍)ID"
+                        style={{ width: '100%' }}
+                        onChange={(e) => getFreeChapterList.mutate({ data: undefined })}
+                    />
+                </Form.Item>
                 <Button type="primary" onClick={getChapterList} disabled={!yueWenCreateLinkDTO?.bookPromoLinkCreateDTO?.bookId} loading={getFreeChapterList.loading}>查询章节列表</Button>
             </Space.Compact>
         </Form.Item>

+ 11 - 0
src/pages/weComTask/page/bookLink/const.tsx

@@ -61,6 +61,17 @@ export const ACTICITYTHEME = {
     24: '七夕'
 }
 
+/** 模板消耗主题 */
+export const ACTICITYTHEMEXH = {
+    25: '七夕风格',
+    26: '默认风格',
+    29: '国庆风格',
+    30: '中秋风格',
+    33: '圣诞风格',
+    34: '春节风格',
+    35: '元旦风格'
+}
+
 // 活动展示位(可选,多个用逗号分隔):1=阅读页 banner2=客服消息3=首页 banner4=活动中心
 export const DISPLAYTYPE = {
     '1': '阅读页banner',

+ 2 - 2
src/pages/weComTask/page/bookLink/consumeActivityLinkDTO.tsx

@@ -1,6 +1,6 @@
 import { Checkbox, DatePicker, Form, Input, InputNumber, Radio, Select, Space } from "antd";
 import React from "react";
-import { ACTICITYTHEME, DISPLAYTYPE } from "./const";
+import { ACTICITYTHEME, ACTICITYTHEMEXH, DISPLAYTYPE } from "./const";
 
 
 /**
@@ -32,7 +32,7 @@ const ConsumeActivityLinkDTO: React.FC<BOOKLINK.BookLinkChildProps> = ({ restFie
                     ((option?.label ?? '') as string).toLowerCase().includes(input.toLowerCase())
                 }
                 allowClear
-                options={Object.keys(ACTICITYTHEME).map(key => ({ label: ACTICITYTHEME[key], value: key }))}
+                options={Object.keys(ACTICITYTHEMEXH).map(key => ({ label: ACTICITYTHEMEXH[key], value: key }))}
             />
         </Form.Item>
         <Form.Item

+ 2 - 2
src/pages/weComTask/page/bookLink/details.tsx

@@ -1,5 +1,5 @@
 import React from "react";
-import { ACTICITYTHEME, DISPLAYTYPE, LINKTYPE, LINKTYPEEle, PAGETYPE, RESOURCETTYPE } from "./const";
+import { ACTICITYTHEME, ACTICITYTHEMEXH, DISPLAYTYPE, LINKTYPE, LINKTYPEEle, PAGETYPE, RESOURCETTYPE } from "./const";
 
 interface Props {
     linkType: keyof typeof LINKTYPE,
@@ -51,7 +51,7 @@ const Details: React.FC<Props> = ({ linkType, linkContent }) => {
         return <div>
             <div>链接类型:{LINKTYPEEle[linkType]}</div>
             <div>活动名称:<span style={{ color: '#1890ff' }}>{linkContent?.activityName}</span></div>
-            <div>活动主题:<span style={{ color: '#1890ff' }}>{ACTICITYTHEME[linkContent?.activityTheme]}</span></div>
+            <div>活动主题:<span style={{ color: '#1890ff' }}>{ACTICITYTHEMEXH[linkContent?.activityTheme]}</span></div>
             <div>购买章节数量:<span style={{ color: '#1890ff' }}>{linkContent?.unlockChapter}</span></div>
             <div>生效书籍:<span style={{ color: '#1890ff' }}>{linkContent?.bookId || '全部'}</span></div>
             <div>赠送书卷数量:<span style={{ color: '#1890ff' }}>{linkContent?.giftAmount}</span></div>

+ 57 - 3
src/pages/weComTask/page/bookLink/index.tsx

@@ -30,6 +30,7 @@ const BookLink: React.FC<{ weComTaskStore: { data: { bookList: TASK_CREATE.BookL
     const [queryParamsNew, setQueryParamsNew] = useState<GetCorpAutoLinkListProps>({ pageNum: 1, pageSize: 20 })
     const [mpList, setMplist] = useState<{ label: string, value: number }[]>([])
     const [visible, setVisible] = useState<boolean>(false)
+    const [initialValues, setInitialValues] = useState<any>()
 
     const getCorpAutoLinkList = useAjax((params) => getCorpAutoLinkListApi(params))
     const getBindMpList = useAjax(() => getBindMpListApi())
@@ -45,6 +46,56 @@ const BookLink: React.FC<{ weComTaskStore: { data: { bookList: TASK_CREATE.BookL
         })
     }, [])
 
+    const handleCopy = (value: any) => {
+        const { linkType, linkContext, channelName, channelType, platform, mpAccountId } = value
+        const yueWenCreateLinkDTO: { [x: string]: any } = {
+            linkType: linkType + '',
+            channelName,
+            channelType: channelType + ''
+        }
+        switch (linkType) {
+            case 1:
+                yueWenCreateLinkDTO.pagePromoLinkCreateDTO = {
+                    ...linkContext,
+                    pageType: linkContext.pageType + ''
+                }
+                break
+            case 2:
+                yueWenCreateLinkDTO.bookPromoLinkCreateDTO = { ...linkContext, forceStyle: Number(linkContext.forceStyle) }
+                break
+            case 3:
+                yueWenCreateLinkDTO.rechargeActivityLinkDTO = {
+                    ...linkContext,
+                    activityTheme: linkContext.activityTheme + '',
+                    activityTime: [dayJs(linkContext.startTime), dayJs(linkContext.endTime)],
+                    display: linkContext?.display ? linkContext?.display?.split(',') : []
+                }
+                break
+            case 4:
+                yueWenCreateLinkDTO.giftActivityLinkDTO = {
+                    ...linkContext,
+                    // activityTheme: Number(linkContext.activityTheme), 
+                    activityTime: [dayJs(linkContext.startTime), dayJs(linkContext.endTime)],
+                    display: linkContext?.display ? linkContext?.display?.split(',') : [],
+                    resourceType: linkContext.resourceType + ''
+                }
+                break
+            case 5:
+                yueWenCreateLinkDTO.consumeActivityLinkDTO = {
+                    ...linkContext,
+                    activityTheme: linkContext.activityTheme + '', 
+                    activityTime: [dayJs(linkContext.startTime), dayJs(linkContext.endTime)],
+                    display: linkContext?.display ? linkContext?.display?.split(',') : [],
+                }
+                break
+        }
+        setInitialValues({
+            platform,
+            mpAccountIds: [mpAccountId],
+            yueWenCreateLinkDTOList: [yueWenCreateLinkDTO]
+        })
+        setVisible(true)
+    }
 
     return <Card
         styles={{ body: { padding: 0, display: 'flex', flexDirection: 'column', height: 'calc(100vh - 74px)', overflow: 'hidden' } }}
@@ -109,10 +160,10 @@ const BookLink: React.FC<{ weComTaskStore: { data: { bookList: TASK_CREATE.BookL
                         allowClear
                         options={[{ label: '外部', value: '1' }, { label: '内部', value: '2' }]}
                     />
-                    <DatePicker.RangePicker 
+                    <DatePicker.RangePicker
                         placeholder={['创建时间开始', '创建时间结束']}
                         allowClear
-                        value={queryParams?.createTimeStart ? [dayJs(queryParams?.createTimeStart), dayJs(queryParams?.createTimeEnd)] : undefined} 
+                        value={queryParams?.createTimeStart ? [dayJs(queryParams?.createTimeStart), dayJs(queryParams?.createTimeEnd)] : undefined}
                         onChange={(_, options) => setQueryParams({ ...queryParams, createTimeStart: options?.[0], createTimeEnd: options?.[1] })}
                     />
                 </>
@@ -121,7 +172,7 @@ const BookLink: React.FC<{ weComTaskStore: { data: { bookList: TASK_CREATE.BookL
         <div className={style.bookLinkTable} ref={ref}>
             <Table
                 dataSource={getCorpAutoLinkList?.data?.data?.records}
-                columns={bookLinkTableConfig()}
+                columns={bookLinkTableConfig(false, handleCopy)}
                 bordered
                 pagination={false}
                 rowKey={'id'}
@@ -154,11 +205,14 @@ const BookLink: React.FC<{ weComTaskStore: { data: { bookList: TASK_CREATE.BookL
             mpList={mpList}
             bookPlatForm={bookPlatForm}
             visible={visible}
+            initialValues={initialValues}
             onChange={() => {
+                setInitialValues(undefined)
                 setVisible(false)
                 getCorpAutoLinkList.refresh()
             }}
             onClose={() => {
+                setInitialValues(undefined)
                 setVisible(false)
             }}
         />}

+ 8 - 9
src/pages/weComTask/page/bookLink/modalBooklink.tsx

@@ -17,6 +17,7 @@ interface Props {
     visible?: boolean;
     onChange?: () => void
     onClose?: () => void
+    initialValues?: any
 }
 
 export const DispatchBookLink = React.createContext<BOOKLINK.DispatchBookLink | null>(null);
@@ -26,7 +27,7 @@ export const DispatchBookLink = React.createContext<BOOKLINK.DispatchBookLink |
  * @param param0 
  * @returns 
  */
-const ModalBookLink: React.FC<Props> = ({ mpList, bookPlatForm, visible, onChange, onClose }) => {
+const ModalBookLink: React.FC<Props> = ({ mpList, bookPlatForm, visible, onChange, onClose, initialValues = { yueWenCreateLinkDTOList: [{}] } }) => {
 
     /********************************************/
     const { message } = App.useApp()
@@ -51,8 +52,8 @@ const ModalBookLink: React.FC<Props> = ({ mpList, bookPlatForm, visible, onChang
                     } else if (linkType === '2') {
                         return { ...rest, bookPromoLinkCreateDTO, linkType }
                     } else if (linkType === '3') {
-                        const { activityTime, display, ...ralDto } = rechargeActivityLinkDTO
-                        return { ...rest, rechargeActivityLinkDTO: { ...ralDto, startTime: dayJs(activityTime[0]).format('YYYY-MM-DD'), endTime: dayJs(activityTime[1]).format('YYYY-MM-DD'), display: display?.join(',') }, linkType }
+                        const { activityTime, display, isDayRepeat, rechargeCount, ...ralDto } = rechargeActivityLinkDTO
+                        return { ...rest, rechargeActivityLinkDTO: { ...ralDto, rechargeCount, isDayRepeat: rechargeCount == 1 ? isDayRepeat : false, startTime: dayJs(activityTime[0]).format('YYYY-MM-DD'), endTime: dayJs(activityTime[1]).format('YYYY-MM-DD'), display: display?.join(',') }, linkType }
                     } else if (linkType === '4') {
                         const { activityTime, display, ...calDto } = giftActivityLinkDTO
                         return { ...rest, giftActivityLinkDTO: { ...calDto, startTime: dayJs(activityTime[0]).format('YYYY-MM-DD'), endTime: dayJs(activityTime[1]).format('YYYY-MM-DD'), display: display?.join(',') }, linkType }
@@ -95,9 +96,7 @@ const ModalBookLink: React.FC<Props> = ({ mpList, bookPlatForm, visible, onChang
                 message.error(errorFields?.[0]?.errors?.[0])
             }}
             onFinish={handleOk}
-            initialValues={{
-                yueWenCreateLinkDTOList: [{}]
-            }}
+            initialValues={initialValues}
         >
             <Card title={<strong>基础信息配置</strong>} style={{ background: '#fff', marginBottom: 10 }}>
                 <Form.Item label={<strong>书城</strong>} name="platform" rules={[{ required: true, message: '请选择书城!' }]}>
@@ -223,7 +222,7 @@ const ModalBookLink: React.FC<Props> = ({ mpList, bookPlatForm, visible, onChang
                                         {...restField}
                                         name={[name, 'channelName']}
                                         label={<strong>渠道名称</strong>}
-                                        rules={[{ required: ['1', '2'].includes(yueWenCreateLinkDTO?.linkType), message: '请输入渠道名称!' }]}
+                                        rules={[{ required: true, message: '请输入渠道名称!' }]}
                                     >
                                         <Input placeholder="请输入渠道名称" allowClear />
                                     </Form.Item>
@@ -231,7 +230,7 @@ const ModalBookLink: React.FC<Props> = ({ mpList, bookPlatForm, visible, onChang
                                         {...restField}
                                         name={[name, 'channelType']}
                                         label={<strong>推广类型</strong>}
-                                        rules={[{ required: ['1', '2'].includes(yueWenCreateLinkDTO?.linkType), message: '请选择推广类型!' }]}
+                                        rules={[{ required: true, message: '请选择推广类型!' }]}
                                     >
                                         <Select
                                             showSearch
@@ -245,7 +244,7 @@ const ModalBookLink: React.FC<Props> = ({ mpList, bookPlatForm, visible, onChang
                                     </Form.Item>
                                     {yueWenCreateLinkDTO?.linkType === '1' ? <PagePromoLinkCreateDTO restField={restField} name={name} /> :
                                         yueWenCreateLinkDTO?.linkType === '2' ? <BookPromoLinkCreateDTO restField={restField} name={name} platform={platform} mpAccountIds={mpAccountIds} yueWenCreateLinkDTO={yueWenCreateLinkDTO} /> :
-                                            yueWenCreateLinkDTO?.linkType === '3' ? <RechargeActivityLinkDTO restField={restField} name={name} /> :
+                                            yueWenCreateLinkDTO?.linkType === '3' ? <RechargeActivityLinkDTO restField={restField} name={name} itemData={yueWenCreateLinkDTO} /> :
                                                 yueWenCreateLinkDTO?.linkType === '4' ? <GiftActivityLinkDTO restField={restField} name={name} /> :
                                                     yueWenCreateLinkDTO?.linkType === '5' ? <ConsumeActivityLinkDTO restField={restField} name={name} /> :
                                                         undefined}

+ 4 - 5
src/pages/weComTask/page/bookLink/rechargeActivityLinkDTO.tsx

@@ -7,8 +7,7 @@ import { ACTICITYTHEME, DISPLAYTYPE } from "./const";
  * 模板充值活动
  * @returns 
  */
-const RechargeActivityLinkDTO: React.FC<BOOKLINK.BookLinkChildProps> = ({ restField, name }) => {
-
+const RechargeActivityLinkDTO: React.FC<BOOKLINK.BookLinkChildProps> = ({ restField, name, itemData }) => {
 
     return <>
         <Form.Item
@@ -74,7 +73,7 @@ const RechargeActivityLinkDTO: React.FC<BOOKLINK.BookLinkChildProps> = ({ restFi
                 options={[1, 2, 3].map(key => ({ label: key + '次', value: key }))}
             />
         </Form.Item>
-        <Form.Item
+        {itemData?.rechargeActivityLinkDTO?.rechargeCount === 1 && <Form.Item
             {...restField}
             name={[name, 'rechargeActivityLinkDTO', 'isDayRepeat']}
             label={<strong>是否每日充值活动</strong>}
@@ -88,7 +87,7 @@ const RechargeActivityLinkDTO: React.FC<BOOKLINK.BookLinkChildProps> = ({ restFi
                     { value: 0, label: '否' }
                 ]}
             />
-        </Form.Item>
+        </Form.Item>}
         <Form.Item
             {...restField}
             name={[name, 'rechargeActivityLinkDTO', 'activityTime']}
@@ -119,7 +118,7 @@ const RechargeActivityLinkDTO: React.FC<BOOKLINK.BookLinkChildProps> = ({ restFi
         >
             <Checkbox.Group options={Object.keys(DISPLAYTYPE).map(key => ({ label: DISPLAYTYPE[key], value: key }))} />
         </Form.Item>
-        
+
     </>
 }
 

+ 3 - 3
src/pages/weComTask/page/bookLink/selectBookLink.tsx

@@ -39,7 +39,7 @@ const SelectBookLink: React.FC<Props> = ({ bookPlatForm, linkData, mpAccountId,
     /*******************************************/
 
     useEffect(() => {
-        getCorpAutoLinkList.run({ ...queryParamsNew, isLink: true, mpAccountId })
+        getCorpAutoLinkList.run({ ...queryParamsNew, mpAccountId })
     }, [queryParamsNew, mpAccountId])
 
     useEffect(() => {
@@ -51,7 +51,7 @@ const SelectBookLink: React.FC<Props> = ({ bookPlatForm, linkData, mpAccountId,
     const handleOk = () => {
         if (data?.every(item => item?.bookLink?.length)) {
             const linkStr = data.map(item => item.bookLink?.[0].link).join(',')
-            const miniprogramAppid = data?.[0]?.bookLink?.[0]?.miniappId
+            const miniprogramAppid = data?.[0]?.bookLink?.[0]?.wxAppid
             const miniprogramPage = data?.[0]?.bookLink?.[0]?.miniappPagePath
             onChange?.(linkStr, miniprogramAppid, miniprogramPage)
         } else {
@@ -158,7 +158,7 @@ const SelectBookLink: React.FC<Props> = ({ bookPlatForm, linkData, mpAccountId,
                 <Table
                     tableLayout='fixed'
                     dataSource={getCorpAutoLinkList?.data?.data?.records}
-                    columns={bookLinkTableConfig()}
+                    columns={bookLinkTableConfig(true)}
                     loading={getCorpAutoLinkList.loading}
                     scroll={{ y: 400 }}
                     rowKey={'id'}

+ 15 - 12
src/pages/weComTask/page/bookLink/tableConfig.tsx

@@ -1,11 +1,11 @@
 import { copy } from "@/utils/utils"
 import { ColumnsType } from "antd/es/table"
 import { LINKTYPEEle } from "./const"
-import { Button, Popover } from "antd"
+import { Button, Flex, Popover } from "antd"
 import Details from "./details"
 
 
-export function bookLinkTableConfig(): ColumnsType<any> {
+export function bookLinkTableConfig(isSelect: boolean, handleCopy?: (value: any) => void): ColumnsType<any> {
 
     const arr: ColumnsType<any> = [
         {
@@ -72,9 +72,9 @@ export function bookLinkTableConfig(): ColumnsType<any> {
             }
         },
         {
-            title: '小程序原始ID',
-            dataIndex: 'miniappId',
-            key: 'miniappId',
+            title: '小程序Appid',
+            dataIndex: 'wxAppid',
+            key: 'wxAppid',
             width: 80,
             ellipsis: true,
             render: (value) => {
@@ -119,13 +119,16 @@ export function bookLinkTableConfig(): ColumnsType<any> {
             width: 60,
             fixed: 'right',
             render: (_, records) => {
-                return <Popover
-                    placement="left"
-                    content={<Details linkType={records.linkType} linkContent={records.linkContext} />}
-                    styles={{ body: { width: 300, overflow: 'hidden', overflowY: 'auto', maxHeight: 400 } }}
-                >
-                    <Button type="link" style={{ padding: 0, height: 'auto' }}>详情</Button>
-                </Popover>
+                return <Flex gap={4} justify='center'>
+                    <Popover
+                        placement="left"
+                        content={<Details linkType={records.linkType} linkContent={records.linkContext} />}
+                        styles={{ body: { width: 300, overflow: 'hidden', overflowY: 'auto', maxHeight: 400 } }}
+                    >
+                        <Button type="link" style={{ padding: 0, height: 'auto' }}>详情</Button>
+                    </Popover>
+                    {!isSelect && <Button type="link" style={{ padding: 0, height: 'auto' }} onClick={() => handleCopy(records)}>复制</Button>}
+                </Flex>
             }
         },
     ]

+ 2 - 1
src/pages/weComTask/page/bookLink/typings.d.ts

@@ -6,6 +6,7 @@ declare namespace BOOKLINK {
         restField: {
             fieldKey?: number;
         }
-        name: number
+        name: number,
+        itemData?: any
     }
 }

+ 1 - 1
src/pages/weComTask/page/businessPlan/create/index.tsx

@@ -821,7 +821,7 @@ const Create: React.FC<{ weComTaskStore: { data: { bookList: TASK_CREATE.BookLis
                                         return {
                                             ...item, corpUsers: item.corpUsers.map((item: any) => {
                                                 const { corpUserId, name, corpName, corpId, mpAccountId, mpAccountInfo } = item
-                                                return { corpUserId, name, corpName, corpId, mpAccountId, mpAccountName: mpAccountInfo.name }
+                                                return { corpUserId, name, corpName, corpId, mpAccountId, mpAccountName: mpAccountInfo?.name }
                                             })
                                         }
                                     })