shenwu 7 kuukautta sitten
vanhempi
commit
73b24d4a73

+ 77 - 0
src/components/bookSelect/drawer.less

@@ -4,4 +4,81 @@
     display: flex;
     align-items: center;
     justify-content: center;
+}
+.book{
+    margin-top: calc(100vw / 170);
+    // display: flex;
+
+    img {
+        width: calc(100vw / 30);
+        height: calc(100vw / 22.4);
+        background: #D8D8D8;
+        border-radius: calc(100vw / 500);
+        margin-right: calc(100vw / 170);
+        float: left;
+    }
+
+    >div {
+        float: left;
+        display: flex;
+        flex-flow: column;
+        width: calc(100vw / 10);
+        strong {
+            height: calc(100vw / 100);
+            font-family: PingFangSC, PingFang SC;
+            font-weight: 500;
+            font-size: calc(100vw / 140);
+            color: #333333;
+            line-height: calc(100vw / 100);
+            text-align: left;
+            font-style: normal;
+            white-space: nowrap;
+            /* 强制文本在一行内显示 */
+            overflow: hidden;
+            /* 隐藏溢出内容 */
+            text-overflow: ellipsis;
+            /* 显示省略号 */
+        }
+
+        >span {
+            height: calc(100vw / 65);
+            font-family: PingFangSC, PingFang SC;
+            font-weight: 400;
+            font-size: calc(100vw / 180);
+            color: #666666;
+            line-height: calc(100vw / 130);
+            text-align: left;
+            font-style: normal;
+            margin-top: calc(100vw / 320);
+            display: -webkit-box;
+            /* 创建弹性盒子模型 */
+            -webkit-box-orient: vertical;
+            /* 设置盒子方向为垂直 */
+            -webkit-line-clamp: 2;
+            /* 限制显示两行 */
+            overflow: hidden;
+            /* 超出部分隐藏 */
+            text-overflow: ellipsis;
+            /* 溢出显示省略号 */
+            white-space: normal;
+            /* 允许文本换行 */
+        }
+
+        >div {
+            display: flex;
+            justify-content: space-between;
+            margin-top: calc(100vw / 320);
+
+            span {
+                height: calc(100vw / 140);
+                font-family: PingFangSC, PingFang SC;
+                font-weight: 400;
+                font-size: calc(100vw / 210);
+                color: #949BAB;
+                line-height: calc(100vw / 140);
+                text-align: left;
+                font-style: normal;
+            }
+        }
+    }
 }

+ 40 - 6
src/components/bookSelect/drawer.tsx

@@ -1,15 +1,48 @@
 import { PlusOutlined } from "@ant-design/icons"
-import { Button, Drawer } from "antd"
+import { Button, Drawer, Tag } from "antd"
 import Book from '@/pages/MiniApp/BookManage/index'
-import { useState } from "react"
+import { useEffect, useState } from "react"
 import styles from './drawer.less'
+import { useAjax } from "@/Hook/useAjax"
+import useApi from "@/Hook/useApi"
+import { useModel } from "@umijs/max"
 function BookSelectDrawer(props: { value?: any, onChange?: (v: any) => void }) {
     let [open, setOpen] = useState(false)
+    let { initialState } = useModel("@@initialState")
+    let apiobj = useApi(initialState?.selectApp?.appCategory || 1)
+    let getList = useAjax((params) => apiobj.getBookPageList(params))
+    useEffect(() => {
+        if (!props?.value?.bookId && props?.value) {
+            getList.run({
+                pageSize: 20,
+                pageNum: 1,
+                appId: initialState?.selectApp?.id || "",
+                appType: initialState?.selectApp?.appType || "",
+                bookId: props?.value
+            }).then(res => {
+                if (res?.data?.total > 0) {
+                    props.onChange?.(res.data.records[0]?.shortBookInfoVO ? { ...res.data.records[0], ...res.data.records[0]?.shortBookInfoVO } : { ...res.data.records[0], ...res.data.records[0]?.longBookInfo })
+                }
+            })
+        }
+    }, [props?.value])
     return <div>
         <div>
-            <Button type="dashed" onClick={() => { setOpen(true) }} className={styles.addBtn}>
-                <PlusOutlined style={{fontSize:20}}/>
-            </Button>
+            {!props?.value ? <Button type="dashed" onClick={() => { setOpen(true) }} className={styles.addBtn}>
+                <PlusOutlined style={{ fontSize: 20 }} />
+            </Button> :
+                <div onClick={() => { setOpen(true) }} className={styles.book}>
+                    <img className={styles.addBtn} src={props?.value?.picUrl} />
+                    <div>
+                        <strong>{props?.value?.bookName || "书名"}</strong>
+                        <span>{props?.value?.bookDesc || "描述"}</span>
+                        <div>
+                            <span>{props?.value?.authorInfo?.authorName}·{props?.value?.wordCount}万字·{props?.value?.bookStatus == 0 ? "连载中" : "完结"}</span>
+                            <Tag >{props?.value?.labelInfoList?.[0]?.name}</Tag>
+                        </div>
+                    </div>
+                </div>
+            }
         </div>
         <Drawer
             title={"小说选择"}
@@ -17,8 +50,9 @@ function BookSelectDrawer(props: { value?: any, onChange?: (v: any) => void }) {
             footer={false}
             width={"80%"}
             onClose={() => { setOpen(false) }}
+            destroyOnClose
         >
-            <Book {...props} />
+            <Book {...props} closeDrawer={setOpen} />
         </Drawer>
     </div>
 }

+ 33 - 15
src/pages/MiniApp/BookManage/Short/index.tsx

@@ -28,15 +28,20 @@ type DataItem = {
 type Props = {
     value?: any,
     onChange?: (v: any) => void
+    closeDrawer?: (v: any) => void
 }
+/**
+ * 关于props的值和bookId的操作都是为了在被当做组件选择书籍使用时的逻辑处理
+ * */
 const Page: React.FC = (props: Props) => {
     let { initialState } = useModel("@@initialState")
     let { state, getLabelAndClassList } = useModel('global')
+    let { tabs } = useModel("appPageConifg", modal => ({ tabs: modal.state.tabs }))
     let [open, setOpen] = useState<any>(null)//付费配置
     let [editValues, setEditValues] = useState<any>({})
     let paymentType = useState(0)//付费方式
     let paymentCategory = useState(0)//收费货币
-    const [editSelectedRow, setEditSelectedRow] = useState<any>(null); //小说列表选择
+    let [bookId, setBookId] = useState<any>(props?.value?.bookId || props?.value)//付费配置
     let [isGlobalConfig, setIsGlobalConfig] = useState(false)//
     let [workDirection, setWorkDirection] = useState<any>(null)
     const [openBook, setOpneBook] = useState<any>(null)//阅读小说
@@ -57,12 +62,16 @@ const Page: React.FC = (props: Props) => {
     }, [workDirection])
     // 接口公共参数
     let publicData = useMemo(() => {
-        return {
+        let pramas = {
             appId: initialState?.selectApp?.id || "",
-            distributorId: initialState?.currentUser?.distributorId,
             appType: initialState?.selectApp?.appType || ""
         }
-    }, [initialState?.selectApp, initialState?.currentUser?.distributorId])
+        return bookId ? {
+            appId: initialState?.selectApp?.id || "",
+            appType: initialState?.selectApp?.appType || "",
+            bookId
+        } : pramas
+    }, [initialState?.selectApp, bookId])
     //获取全局收费配置
     const getGlobalInfo = useCallback(() => {
         globaleConfig.run(publicData).then(res => {
@@ -154,22 +163,27 @@ const Page: React.FC = (props: Props) => {
         loading={globaleConfig?.loading}
     >
         <ProTable<any, any>
-            params={publicData}
+            // params={publicData}//改变立即触发刷新请求
             actionRef={actionRef}
             headerTitle={"小说列表"}
             rowKey={(r) => r.bookId}
-            // {alwaysShowAlert: true, hideSelectAll: true, columnWidth: 0, columnTitle: '', renderCell: () => null}
             //多选
             rowSelection={!!props?.onChange ? {
                 hideSelectAll: true,
                 type: 'radio',
-                selectedRowKeys: [props?.value?.bookId],
+                selectedRowKeys: [props?.value?.bookId || props?.value],
                 onSelect: (record, selected) => {
-                    // setEditSelectedRow(record)
-                    console.log(record)
-                    props?.onChange?.(record)
+                    props?.onChange?.({ ...record, ...record?.shortBookInfoVO })
+                    props?.closeDrawer?.(false)
                 },
             } : false}
+            // 点击行
+            onRow={(record) => ({
+                onClick: () => {
+                    props?.onChange?.({ ...record, ...record?.shortBookInfoVO })
+                    props?.closeDrawer?.(false)
+                }
+            })}
             tableAlertRender={() => {
                 let { paymentType, paymentOption, paymentCategory, paymentAmount, paymentCoin, beginPayNo } = globaleConfig?.data?.data || {}
                 let enumList: any = state?.enumList
@@ -195,7 +209,8 @@ const Page: React.FC = (props: Props) => {
             scroll={{ x: true }}
             loading={getParagraphList?.loading || getList?.loading}
             // ghost={true}//去除表格的背景一些配置改变ui
-            beforeSearchSubmit={(params) => {//处理搜索数据
+            //处理搜索数据
+            beforeSearchSubmit={(params) => {
                 let newParams = Object.entries(params).reduce((acc: any, [key, value]) => {
                     // 过滤掉空值,包括空字符串和 null
                     if (value !== '' && value != null) {
@@ -209,13 +224,16 @@ const Page: React.FC = (props: Props) => {
                     }
                     return acc;
                 }, {});
+                if (props?.onChange) {
+                    newParams.workDirection = tabs
+                }
                 return newParams
             }}
             request={async (params) => {
-                // if (props?.value) {
-                //     params = { ...params, bookId: props.value?.bookId }
-                // }
-                return await getList.run(params)
+                return await getList.run({ ...params, ...publicData }).then(res => {
+                    setBookId(null)
+                    return res
+                })
             }}
             columns={columns({ authList: state?.authList, labelList: state.labelList, categoryList: state.categoryList, enumList: state?.enumList, lookBook, closeForm, setWorkDirection, isModal: !!props?.onChange })}
         />

+ 2 - 1
src/pages/MiniApp/BookManage/Short/tableConfig.tsx

@@ -60,7 +60,8 @@ export const columns = (props: { authList?: any[], labelList?: any[], enumList?:
                 return <Row >
                     <Col span={24}>
                         <Space size={[5, 0]} wrap>
-                            <a style={{ fontSize: 14, color: "#337ab7" }} onClick={() => {
+                            <a style={{ fontSize: 14, color: "#337ab7" }} onClick={(e) => {
+                                e.stopPropagation()
                                 lookBook?.({ ...b.shortBookInfoVO, vipFree: b.vipFree, beginPayParagraphNo: b.beginPayParagraphNo, pageNum: 1, pageSize: 2 })
                             }}>[{categoryInfo?.name}]{bookName}</a>
                             <span style={{ fontSize: 11 }} className={styles.bookLabel}>[{arr[bookStatus]?.description}]</span>

+ 7 - 6
src/pages/MiniApp/CompConfig/DrawerBox/compFormConfig.tsx

@@ -45,6 +45,7 @@ export function bannersConfig(pageList: any[]): ProFormColumnsType<any>[] {
                             },
                             formItemProps: {
                                 style: { marginBottom: 10 },
+                                initialValue:"0",
                                 rules: [
                                     {
                                         required: true,
@@ -61,7 +62,7 @@ export function bannersConfig(pageList: any[]): ProFormColumnsType<any>[] {
                                     {
                                         dataIndex: "bookId",
                                         title: '小说',
-                                        hideInForm: bannerType != 0,
+                                        hideInForm: bannerType == 1,
                                         formItemProps: {
                                             style: { marginBottom: 10 },
                                             rules: [
@@ -75,7 +76,7 @@ export function bannersConfig(pageList: any[]): ProFormColumnsType<any>[] {
                                             span: 24
                                         },
                                         renderFormItem(schema, config, form, action) {
-                                            return <BookSelect />
+                                            return <BookSelectDrawer />
                                         },
                                     },
                                     {
@@ -86,7 +87,7 @@ export function bannersConfig(pageList: any[]): ProFormColumnsType<any>[] {
                                             span: 24
                                         },
                                         fieldProps: {
-                                            style: { width: 'auto' },
+                                            style: { width: '100%' },
                                             showSearch: true,
                                             placeholder: '请选择活动页面'
                                         },
@@ -208,7 +209,7 @@ export function hotBooksConfig(): ProFormColumnsType<any>[] {
                             dataIndex: "bookId",
                             title: '小说',
                             colProps: {
-                                span: 12
+                                span: 24
                             },
                             formItemProps: {
                                 style: { marginBottom: 10 },
@@ -220,8 +221,8 @@ export function hotBooksConfig(): ProFormColumnsType<any>[] {
                                 ],
                             },
                             renderFormItem(schema, config, form, action) {
-                                return <BookSelect />
-                                // return <BookSelectDrawer />
+                                // return <BookSelect />
+                                return <BookSelectDrawer />
                             },
                         },
                         {

+ 2 - 2
src/pages/MiniApp/CompConfig/DrawerBox/index.tsx

@@ -108,11 +108,11 @@ const ModalForm = forwardRef((props: Props, ref) => {
                     <PageList ref={PageListRef} data={AppComponentConfigGetAppPageList?.data?.data} />
                 </Col>
                 {/* 中间展示 content*/}
-                <Col xl={14} xs={24} style={{ background: token.colorBgContainerDisabled, display: 'flex', alignItems: 'center', justifyContent: 'center' }}>
+                <Col xl={13} xs={24} style={{ background: token.colorBgContainerDisabled, display: 'flex', alignItems: 'center', justifyContent: 'center' }}>
                     <Content ref={ContentRef} />
                 </Col>
                 {/* 右侧参数设置 set*/}
-                <Col xl={5} xs={24}>
+                <Col xl={6} xs={24}>
                     <SetData ref={SetDataRef} pageList={AppComponentConfigGetAppPageList?.data?.data} />
                 </Col>
             </Row>