|
@@ -1,11 +1,12 @@
|
|
|
-import { PageContainer, ProTable } from "@ant-design/pro-components"
|
|
|
+import { BetaSchemaForm, PageContainer, ProFormInstance, ProTable } from "@ant-design/pro-components"
|
|
|
import { columns } from "./tableConfig"
|
|
|
import { useAjax } from "@/Hook/useAjax"
|
|
|
import { useModel } from "@umijs/max"
|
|
|
-import { shortBookInfoList, shortBookInfoParagraphList } from "@/services/miniApp/bookManage"
|
|
|
-import { useState } from "react"
|
|
|
+import { shortBookInfoList, shortBookInfoParagraphList, shortBookInfoBookConfig, shortBookInfoConfig, shortBookInfoParagraphAllList } from "@/services/miniApp/bookManage"
|
|
|
+import { useMemo, useRef, useState } from "react"
|
|
|
import { Drawer } from "antd"
|
|
|
import ReadText from "../components/readText"
|
|
|
+import formConfig from "./formConfig"
|
|
|
const wordCountRanges: any = {
|
|
|
"": { start: null, end: null }, // 全部
|
|
|
"0-2": { start: 0, end: 2 * 10000 },
|
|
@@ -19,13 +20,31 @@ const wordCountRanges: any = {
|
|
|
"200-300": { start: 200 * 10000, end: 300 * 10000 },
|
|
|
"300-0": { start: 300 * 10000, end: null }, // 300万以上
|
|
|
};
|
|
|
+type DataItem = {
|
|
|
+ name: string;
|
|
|
+ state: string;
|
|
|
+};
|
|
|
const Page: React.FC = () => {
|
|
|
let { initialState } = useModel("@@initialState")
|
|
|
let { state } = useModel('global')
|
|
|
+ let [open, setOpen] = useState<any>(null)//付费配置
|
|
|
+ let [editValues, setEditValues] = useState<any>({})
|
|
|
+ let paymentType=useState([])
|
|
|
const [openBook, setOpneBook] = useState<any>(null)//阅读小说
|
|
|
- let getList = useAjax((params) => shortBookInfoList(params), { type: 'table' })
|
|
|
- let getParagraphList = useAjax((params) => shortBookInfoParagraphList(params))
|
|
|
+ let getList = useAjax((params) => shortBookInfoList(params), { type: 'table' })//获取书列表
|
|
|
+ let getParagraphList = useAjax((params) => shortBookInfoParagraphList(params))//获取段落内容信息
|
|
|
+ let getParagraphAllList = useAjax((params) => shortBookInfoParagraphAllList(params))//获取全部段落
|
|
|
+ let add = useAjax((params) => shortBookInfoBookConfig(params))//新增配置
|
|
|
+ let configInfo = useAjax((params) => shortBookInfoConfig(params))//获取配置信息
|
|
|
+ const formRef = useRef<ProFormInstance>();
|
|
|
|
|
|
+ let publicData = useMemo(() => {
|
|
|
+ return {
|
|
|
+ miniappId: initialState?.selectApp?.id || "",
|
|
|
+ distributorId: initialState?.currentUser?.distributorId,
|
|
|
+ appType: initialState?.selectApp?.appType || ""
|
|
|
+ }
|
|
|
+ }, [initialState?.selectApp, initialState?.currentUser?.distributorId])
|
|
|
|
|
|
// 看小说
|
|
|
const lookBook = (params: any) => {
|
|
@@ -35,15 +54,53 @@ const Page: React.FC = () => {
|
|
|
return res.data
|
|
|
})
|
|
|
}
|
|
|
+ // 提交表单
|
|
|
+ const submit = async (values: any) => {
|
|
|
+ if (!values.activateTemplate) {
|
|
|
+ values.activateTemplate = false
|
|
|
+ }
|
|
|
+ if (editValues?.id) {
|
|
|
+ values.id = editValues?.id
|
|
|
+ }
|
|
|
+ console.log(values)
|
|
|
+ // add.run({ ...values, ...publicData }).then(res => {
|
|
|
+ // if (res.code === 200) {
|
|
|
+ // getList.refresh()
|
|
|
+ // message.success(values.id ? "编辑模板成功" : "新建模板成功!")
|
|
|
+ // closeForm(false)
|
|
|
+ // }
|
|
|
+ // })
|
|
|
+ }
|
|
|
+ // 关闭表单弹窗和重置表单内容
|
|
|
+ const closeForm = (b: boolean, values?: any) => {
|
|
|
+ if (!b) {
|
|
|
+ setEditValues({})
|
|
|
+ formRef?.current?.resetFields?.()
|
|
|
+ setOpen(b)
|
|
|
+ } else {
|
|
|
+ // 获取书全部段落
|
|
|
+ // getParagraphAllList.run(values.bookId).then(res => {
|
|
|
+ // if (res.code === 200) {
|
|
|
+ setOpen(b)//弹窗开启
|
|
|
+ if (values) {
|
|
|
+ // 获取书付费配置
|
|
|
+ configInfo.run({ bookId: values.bookId, ...publicData }).then(res => {
|
|
|
+ if (res.code === 200) {
|
|
|
+ let data = { ...res.data }
|
|
|
+ setEditValues(data)
|
|
|
+ formRef?.current?.setFieldsValue(data)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ // }
|
|
|
+ // })
|
|
|
+ }
|
|
|
+ }
|
|
|
return <PageContainer title={false}
|
|
|
tabProps={{ type: 'card' }}
|
|
|
>
|
|
|
<ProTable<any, any>
|
|
|
- params={{
|
|
|
- miniappId: initialState?.selectApp?.id || "",
|
|
|
- distributorId: initialState?.currentUser?.distributorId,
|
|
|
- appType: initialState?.selectApp?.appType || ""
|
|
|
- }}
|
|
|
+ params={publicData}
|
|
|
headerTitle={"短篇小说列表"}
|
|
|
rowKey={(r) => r.bookId}
|
|
|
search={{
|
|
@@ -70,8 +127,22 @@ const Page: React.FC = () => {
|
|
|
request={async (params) => {
|
|
|
return await getList.run(params)
|
|
|
}}
|
|
|
- columns={columns({ authList: state?.authList, enumList: state?.enumList,lookBook })}
|
|
|
- // bordered
|
|
|
+ columns={columns({ authList: state?.authList, enumList: state?.enumList, lookBook, closeForm })}
|
|
|
+ />
|
|
|
+ {/* 付费配置 */}
|
|
|
+ <BetaSchemaForm<DataItem>
|
|
|
+ title={editValues?.id ? "编辑模板" : '新建模板'}
|
|
|
+ formRef={formRef}
|
|
|
+ open={open}
|
|
|
+ onOpenChange={(b) => { !b && closeForm(b) }}
|
|
|
+ layoutType={"ModalForm"}
|
|
|
+ labelCol={{span:6}}
|
|
|
+ wrapperCol={{span:14}}
|
|
|
+ // grid={true}
|
|
|
+ layout='horizontal'
|
|
|
+ onFinish={submit}
|
|
|
+ columns={formConfig({ enumList: state?.enumList,paymentType })}
|
|
|
+ loading={add?.loading}
|
|
|
/>
|
|
|
{/* 阅读小说 */}
|
|
|
<Drawer
|
|
@@ -84,7 +155,7 @@ const Page: React.FC = () => {
|
|
|
// getContainer={false}
|
|
|
bodyStyle={{ padding: 0 }}
|
|
|
closeIcon={false}
|
|
|
- title={<div style={{ fontSize: 20}}>{openBook?.bookName ? openBook?.bookName : ""}</div>}
|
|
|
+ title={<div style={{ fontSize: 20 }}>{openBook?.bookName ? openBook?.bookName : ""}</div>}
|
|
|
>
|
|
|
<ReadText data={openBook} next={lookBook} />
|
|
|
</Drawer>
|