|
@@ -1,10 +1,10 @@
|
|
-import { BetaSchemaForm, PageContainer, ProFormInstance, ProTable } from "@ant-design/pro-components"
|
|
|
|
|
|
+import { ActionType, BetaSchemaForm, PageContainer, ProFormInstance, ProTable } from "@ant-design/pro-components"
|
|
import { columns } from "./tableConfig"
|
|
import { columns } from "./tableConfig"
|
|
import { useAjax } from "@/Hook/useAjax"
|
|
import { useAjax } from "@/Hook/useAjax"
|
|
import { useModel } from "@umijs/max"
|
|
import { useModel } from "@umijs/max"
|
|
import { shortBookInfoList, shortBookInfoParagraphList, shortBookInfoBookConfig, shortBookInfoConfig, shortBookInfoParagraphAllList } from "@/services/miniApp/bookManage"
|
|
import { shortBookInfoList, shortBookInfoParagraphList, shortBookInfoBookConfig, shortBookInfoConfig, shortBookInfoParagraphAllList } from "@/services/miniApp/bookManage"
|
|
-import { useMemo, useRef, useState } from "react"
|
|
|
|
-import { Drawer } from "antd"
|
|
|
|
|
|
+import { useEffect, useMemo, useRef, useState } from "react"
|
|
|
|
+import { Drawer, message } from "antd"
|
|
import ReadText from "../components/readText"
|
|
import ReadText from "../components/readText"
|
|
import formConfig from "./formConfig"
|
|
import formConfig from "./formConfig"
|
|
const wordCountRanges: any = {
|
|
const wordCountRanges: any = {
|
|
@@ -26,10 +26,11 @@ type DataItem = {
|
|
};
|
|
};
|
|
const Page: React.FC = () => {
|
|
const Page: React.FC = () => {
|
|
let { initialState } = useModel("@@initialState")
|
|
let { initialState } = useModel("@@initialState")
|
|
- let { state } = useModel('global')
|
|
|
|
|
|
+ let { state, getLabelAndClassList } = useModel('global')
|
|
let [open, setOpen] = useState<any>(null)//付费配置
|
|
let [open, setOpen] = useState<any>(null)//付费配置
|
|
let [editValues, setEditValues] = useState<any>({})
|
|
let [editValues, setEditValues] = useState<any>({})
|
|
let paymentType = useState([])
|
|
let paymentType = useState([])
|
|
|
|
+ let [workDirection, setWorkDirection] = useState<any>(null)
|
|
const [openBook, setOpneBook] = useState<any>(null)//阅读小说
|
|
const [openBook, setOpneBook] = useState<any>(null)//阅读小说
|
|
let getList = useAjax((params) => shortBookInfoList(params), { type: 'table' })//获取书列表
|
|
let getList = useAjax((params) => shortBookInfoList(params), { type: 'table' })//获取书列表
|
|
let getParagraphList = useAjax((params) => shortBookInfoParagraphList(params))//获取段落内容信息
|
|
let getParagraphList = useAjax((params) => shortBookInfoParagraphList(params))//获取段落内容信息
|
|
@@ -37,7 +38,12 @@ const Page: React.FC = () => {
|
|
let add = useAjax((params) => shortBookInfoBookConfig(params))//新增配置
|
|
let add = useAjax((params) => shortBookInfoBookConfig(params))//新增配置
|
|
let configInfo = useAjax((params) => shortBookInfoConfig(params))//获取配置信息
|
|
let configInfo = useAjax((params) => shortBookInfoConfig(params))//获取配置信息
|
|
const formRef = useRef<ProFormInstance>();
|
|
const formRef = useRef<ProFormInstance>();
|
|
-
|
|
|
|
|
|
+ const actionRef = useRef<ActionType>();
|
|
|
|
+ // 获取标签和分类
|
|
|
|
+ useEffect(() => {
|
|
|
|
+ getLabelAndClassList({ workDirection })
|
|
|
|
+ }, [workDirection])
|
|
|
|
+ // 接口公共参数
|
|
let publicData = useMemo(() => {
|
|
let publicData = useMemo(() => {
|
|
return {
|
|
return {
|
|
miniappId: initialState?.selectApp?.id || "",
|
|
miniappId: initialState?.selectApp?.id || "",
|
|
@@ -49,27 +55,26 @@ const Page: React.FC = () => {
|
|
// 看小说
|
|
// 看小说
|
|
const lookBook = (params: any) => {
|
|
const lookBook = (params: any) => {
|
|
let { id, pageNum, pageSize } = params
|
|
let { id, pageNum, pageSize } = params
|
|
- return getParagraphList.run({ id, pageNum, pageSize, backContent: 1 }).then(res => {
|
|
|
|
|
|
+ return getParagraphList.run({ bookId: id, pageNum, pageSize, backContent: true }).then(res => {
|
|
setOpneBook({ ...res.data, ...params })
|
|
setOpneBook({ ...res.data, ...params })
|
|
return res.data
|
|
return res.data
|
|
})
|
|
})
|
|
}
|
|
}
|
|
// 提交表单
|
|
// 提交表单
|
|
const submit = async (values: any) => {
|
|
const submit = async (values: any) => {
|
|
- if (!values.activateTemplate) {
|
|
|
|
- values.activateTemplate = false
|
|
|
|
- }
|
|
|
|
if (editValues?.id) {
|
|
if (editValues?.id) {
|
|
values.id = 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)
|
|
|
|
- // }
|
|
|
|
- // })
|
|
|
|
|
|
+ if (editValues?.bookId) {
|
|
|
|
+ values.bookId = editValues?.bookId
|
|
|
|
+ }
|
|
|
|
+ add.run({ ...values, ...publicData }).then(res => {
|
|
|
|
+ if (res.code === 200) {
|
|
|
|
+ actionRef?.current?.reload()
|
|
|
|
+ message.success("付费配置成功!")
|
|
|
|
+ closeForm(false)
|
|
|
|
+ }
|
|
|
|
+ })
|
|
}
|
|
}
|
|
// 关闭表单弹窗和重置表单内容
|
|
// 关闭表单弹窗和重置表单内容
|
|
const closeForm = (b: boolean, values?: any) => {
|
|
const closeForm = (b: boolean, values?: any) => {
|
|
@@ -80,21 +85,23 @@ const Page: React.FC = () => {
|
|
setOpen(b)
|
|
setOpen(b)
|
|
} else {
|
|
} 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)
|
|
|
|
|
|
+ getParagraphAllList.run({ bookId: values.bookId, backContent: true }).then(res => {
|
|
|
|
+ if (res.code === 200) {
|
|
|
|
+ setOpen(b)//弹窗开启
|
|
|
|
+ if (values) {
|
|
|
|
+ // 获取书付费配置
|
|
|
|
+ configInfo.run({ bookId: values.bookId, ...publicData }).then(res => {
|
|
|
|
+ if (res.code === 200) {
|
|
|
|
+ let paymentTypeArr = res.data?.paymentType?.map((i: string) => i + '')
|
|
|
|
+ let data = { ...res.data, paymentType: paymentTypeArr }
|
|
|
|
+ setEditValues(data)
|
|
|
|
+ paymentType[1](paymentTypeArr)
|
|
|
|
+ formRef?.current?.setFieldsValue(data)
|
|
|
|
+ }
|
|
|
|
+ })
|
|
}
|
|
}
|
|
- })
|
|
|
|
- }
|
|
|
|
- // }
|
|
|
|
- // })
|
|
|
|
|
|
+ }
|
|
|
|
+ })
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return <PageContainer title={false}
|
|
return <PageContainer title={false}
|
|
@@ -102,6 +109,7 @@ const Page: React.FC = () => {
|
|
>
|
|
>
|
|
<ProTable<any, any>
|
|
<ProTable<any, any>
|
|
params={publicData}
|
|
params={publicData}
|
|
|
|
+ actionRef={actionRef}
|
|
headerTitle={"短篇小说列表"}
|
|
headerTitle={"短篇小说列表"}
|
|
rowKey={(r) => r.bookId}
|
|
rowKey={(r) => r.bookId}
|
|
search={{
|
|
search={{
|
|
@@ -128,7 +136,7 @@ const Page: React.FC = () => {
|
|
request={async (params) => {
|
|
request={async (params) => {
|
|
return await getList.run(params)
|
|
return await getList.run(params)
|
|
}}
|
|
}}
|
|
- columns={columns({ authList: state?.authList, enumList: state?.enumList, lookBook, closeForm })}
|
|
|
|
|
|
+ columns={columns({ authList: state?.authList, labelList: state.labelList, categoryList: state.categoryList, enumList: state?.enumList, lookBook, closeForm, setWorkDirection })}
|
|
/>
|
|
/>
|
|
{/* 付费配置 */}
|
|
{/* 付费配置 */}
|
|
<BetaSchemaForm<DataItem>
|
|
<BetaSchemaForm<DataItem>
|
|
@@ -142,7 +150,7 @@ const Page: React.FC = () => {
|
|
// grid={true}
|
|
// grid={true}
|
|
layout='horizontal'
|
|
layout='horizontal'
|
|
onFinish={submit}
|
|
onFinish={submit}
|
|
- columns={formConfig({ enumList: state?.enumList, paymentType })}
|
|
|
|
|
|
+ columns={formConfig({ enumList: state?.enumList, paymentType, paragraphList: getParagraphAllList?.data?.data?.map((item: { paragraphInfo: any }) => item.paragraphInfo) })}
|
|
loading={add?.loading}
|
|
loading={add?.loading}
|
|
/>
|
|
/>
|
|
{/* 阅读小说 */}
|
|
{/* 阅读小说 */}
|
|
@@ -154,7 +162,7 @@ const Page: React.FC = () => {
|
|
width={'65%'}
|
|
width={'65%'}
|
|
destroyOnClose={true}
|
|
destroyOnClose={true}
|
|
// getContainer={false}
|
|
// getContainer={false}
|
|
- bodyStyle={{ padding: 0 }}
|
|
|
|
|
|
+ styles={{ body: { padding: 0 } }}
|
|
closeIcon={false}
|
|
closeIcon={false}
|
|
title={<div style={{ fontSize: 20 }}>{openBook?.bookName ? openBook?.bookName : ""}</div>}
|
|
title={<div style={{ fontSize: 20 }}>{openBook?.bookName ? openBook?.bookName : ""}</div>}
|
|
>
|
|
>
|