|
@@ -29,14 +29,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)//收费货币
|
|
|
+ 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)//阅读小说
|
|
@@ -56,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 => {
|
|
@@ -143,7 +153,7 @@ const Page: React.FC = (props: Props) => {
|
|
|
tabProps={{ type: 'card' }}
|
|
|
>
|
|
|
<ProTable<any, any>
|
|
|
- params={publicData}
|
|
|
+ // params={publicData}
|
|
|
actionRef={actionRef}
|
|
|
headerTitle={"小说列表"}
|
|
|
rowKey={(r) => r.bookId}
|
|
@@ -169,6 +179,23 @@ const Page: React.FC = (props: Props) => {
|
|
|
labelWidth: 90,
|
|
|
searchGutter: [10, 15],
|
|
|
}}
|
|
|
+ //多选
|
|
|
+ rowSelection={!!props?.onChange ? {
|
|
|
+ hideSelectAll: true,
|
|
|
+ type: 'radio',
|
|
|
+ selectedRowKeys: [props?.value?.bookId || props?.value],
|
|
|
+ onSelect: (record, selected) => {
|
|
|
+ props?.onChange?.({ ...record?.longBookInfo, ...record })
|
|
|
+ props?.closeDrawer?.(false)
|
|
|
+ },
|
|
|
+ } : false}
|
|
|
+ // 点击行
|
|
|
+ onRow={(record) => ({
|
|
|
+ onClick: () => {
|
|
|
+ props?.onChange?.({ ...record?.longBookInfo, ...record })
|
|
|
+ props?.closeDrawer?.(false)
|
|
|
+ }
|
|
|
+ })}
|
|
|
loading={getChapterAllList?.loading || configInfo?.loading || getList.loading}
|
|
|
// ghost={true}//去除表格的背景一些配置改变ui
|
|
|
beforeSearchSubmit={(params) => {//处理搜索数据
|
|
@@ -188,10 +215,14 @@ const Page: React.FC = (props: Props) => {
|
|
|
return newParams
|
|
|
}}
|
|
|
request={async (params) => {
|
|
|
- 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: lookBookList, closeForm, setWorkDirection, isModal: !!props?.onChange })}
|
|
|
/>
|
|
|
+
|
|
|
{/* 付费配置 */}
|
|
|
<BetaSchemaForm<DataItem>
|
|
|
title={(isGlobalConfig ? "全局" : "《" + editValues?.bookName + "》") + "付费配置"}
|