|
@@ -14,29 +14,36 @@ import {
|
|
|
ProTable,
|
|
|
} from '@ant-design/pro-components';
|
|
|
import { useModel } from '@umijs/max';
|
|
|
-import { message } from 'antd';
|
|
|
+import { Button, message, Popconfirm, Space, Tag } from 'antd';
|
|
|
import { useEffect, useRef, useState } from 'react';
|
|
|
import formConfig from './formConfig';
|
|
|
import { columns } from './tableConfig';
|
|
|
+import { apiWxAppInfoList, removeBook } from '@/services/distribution/weChatInfo';
|
|
|
|
|
|
type DataItem = {
|
|
|
name: string;
|
|
|
state: string;
|
|
|
};
|
|
|
-const Page: React.FC = () => {
|
|
|
+type Porps = {
|
|
|
+ wechatAppId?: string
|
|
|
+}
|
|
|
+const Page: React.FC<Porps> = (props) => {
|
|
|
+ let { wechatAppId } = props
|
|
|
let { state, getLabelAndClassList } = useModel('global');
|
|
|
const formRef = useRef<ProFormInstance>();
|
|
|
const actionRef = useRef<ActionType>();
|
|
|
let [workDirection, setWorkDirection] = useState<any>(null);
|
|
|
let [open, setOpen] = useState<any>(null); //新增作者
|
|
|
let [editValues, setEditValues] = useState<any>({});
|
|
|
+ const [editSelectedRow, setEditSelectedRow] = useState<any[]>([]); //小说列表选择
|
|
|
// ======================API=======================
|
|
|
let DistributorInfoList = useAjax((params) => apiDistributorInfoList(params)); //分销商列表
|
|
|
let BookInfoList = useAjax((params) => apiShortBookInfoList(params), { type: 'table' }); //获取书籍列表
|
|
|
let BookInfoBookConfig = useAjax((params) => apiShortBookInfoBookConfig(params)); //小说信息配置
|
|
|
let BookInfoChapterAllList = useAjax((id) => apiShortBookInfoAllList(id)); //全部列表无分页
|
|
|
let BookInfoConfigDetail = useAjax((id) => apiShortBookInfoConfigDetail(id)); //小说配置详情
|
|
|
-
|
|
|
+ let RemoveBook = useAjax((params) => removeBook(params)); //移除小程序中的书籍
|
|
|
+ let WxAppInfoList = useAjax(() => apiWxAppInfoList()); //全部小程序
|
|
|
// 获取标签和分类
|
|
|
useEffect(() => {
|
|
|
getLabelAndClassList({ workDirection });
|
|
@@ -44,6 +51,7 @@ const Page: React.FC = () => {
|
|
|
// 编辑
|
|
|
const edit = (item: any) => {
|
|
|
DistributorInfoList.run();
|
|
|
+ WxAppInfoList.run();
|
|
|
BookInfoChapterAllList.run(item.bookId).then((res) => {
|
|
|
setOpen(true);
|
|
|
BookInfoConfigDetail.run(item.bookId).then((dres) => {
|
|
@@ -84,10 +92,25 @@ const Page: React.FC = () => {
|
|
|
} else {
|
|
|
}
|
|
|
};
|
|
|
+ // 组件模式小说移除
|
|
|
+ const delBook=()=>{
|
|
|
+ let bookIds = editSelectedRow?.map(item=>item.bookId)
|
|
|
+ RemoveBook.run({bookIds,appId:wechatAppId}).then(res=>{
|
|
|
+ if(res.code === 200){
|
|
|
+ actionRef.current?.reload()
|
|
|
+ message.success("移除成功")
|
|
|
+ setEditSelectedRow([])
|
|
|
+ }
|
|
|
+ console.log(res)
|
|
|
+ })
|
|
|
+ }
|
|
|
return (
|
|
|
- <PageContainer>
|
|
|
+ <PageContainer
|
|
|
+ header={wechatAppId ? { title: "", breadcrumb: {} } : {}}
|
|
|
+ childrenContentStyle={wechatAppId ? { paddingBlockStart: 0 } : {}}
|
|
|
+ >
|
|
|
<ProTable<any, any>
|
|
|
- headerTitle={'短篇小说配置信息列表'}
|
|
|
+ headerTitle={wechatAppId ? "短篇小说列表" : '短篇小说配置信息列表'}
|
|
|
actionRef={actionRef}
|
|
|
rowKey={(r) => r.bookId}
|
|
|
// 搜索的配置
|
|
@@ -96,7 +119,7 @@ const Page: React.FC = () => {
|
|
|
searchGutter: [10, 15],
|
|
|
}}
|
|
|
request={async (params) => {
|
|
|
- return await BookInfoList.run(params);
|
|
|
+ return await BookInfoList.run(wechatAppId ? { ...params, appId:wechatAppId } : params);
|
|
|
}}
|
|
|
scroll={{ x: 'auto' }}
|
|
|
columns={columns({
|
|
@@ -106,8 +129,80 @@ const Page: React.FC = () => {
|
|
|
enumList: state?.enumList,
|
|
|
setWorkDirection,
|
|
|
edit,
|
|
|
+ wechatAppId
|
|
|
})}
|
|
|
- // bordered
|
|
|
+ // bordered
|
|
|
+ // 组件模式多选
|
|
|
+ rowSelection={wechatAppId ? {
|
|
|
+ type: 'checkbox',
|
|
|
+ selectedRowKeys: editSelectedRow?.map((item: { bookId: any }) => item.bookId),
|
|
|
+ onSelect: (record, selected) => {
|
|
|
+ if (selected) {
|
|
|
+ setEditSelectedRow([...editSelectedRow, record]);
|
|
|
+ } else {
|
|
|
+ setEditSelectedRow(
|
|
|
+ editSelectedRow?.filter((item: { bookId: any }) => item.bookId !== record.bookId),
|
|
|
+ );
|
|
|
+ }
|
|
|
+ },
|
|
|
+ onSelectAll: (selected, rows, changeRows) => {
|
|
|
+ if (selected) {
|
|
|
+ setEditSelectedRow([...editSelectedRow, ...changeRows]);
|
|
|
+ } else {
|
|
|
+ let newArr = editSelectedRow?.filter((item: { bookId: any }) =>
|
|
|
+ changeRows.every((i) => i?.bookId !== item?.bookId),
|
|
|
+ );
|
|
|
+ setEditSelectedRow(newArr);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ } : {
|
|
|
+ alwaysShowAlert: true,//总是展示 alert,默认无选择不展示
|
|
|
+ hideSelectAll: true,// 隐藏全选框
|
|
|
+ renderCell: () => null, // 隐藏选择列中的勾选框
|
|
|
+ columnTitle: '', // 去掉选择列的表头
|
|
|
+ columnWidth: 0, // 设置选择列宽度为 0
|
|
|
+ }}
|
|
|
+ //多选展示栏
|
|
|
+ tableAlertRender={wechatAppId?({ selectedRowKeys, selectedRows }) => {
|
|
|
+ return (
|
|
|
+ <Space size={24}>
|
|
|
+ <span style={{ width: 90, display: 'inline-block' }}>
|
|
|
+ 已选 {selectedRowKeys.length} 项
|
|
|
+ </span>
|
|
|
+ <span style={{ color: 'red' }}>
|
|
|
+ {selectedRows
|
|
|
+ ?.map((item: { shortBookInfo?: any, longBookInfo?: any, bookId: any }) => <Tag
|
|
|
+ closable
|
|
|
+ key={item?.bookId}
|
|
|
+ onClose={() => {
|
|
|
+ let newArr = selectedRows?.filter((i) => i?.bookId != item?.bookId)
|
|
|
+ setEditSelectedRow(newArr)
|
|
|
+ }}>{item?.shortBookInfo?.bookName || item?.longBookInfo?.bookName}</Tag>)
|
|
|
+ }
|
|
|
+ </span>
|
|
|
+ </Space>
|
|
|
+ );
|
|
|
+ }:false}
|
|
|
+ // 添加取消选择按钮
|
|
|
+ tableAlertOptionRender={() => {
|
|
|
+ return (
|
|
|
+ <>
|
|
|
+ <Popconfirm
|
|
|
+ title="当前选中的书籍将从小程序中移除!"
|
|
|
+ onConfirm={delBook}
|
|
|
+ >
|
|
|
+ <Button type="link" danger >
|
|
|
+ 批量移除
|
|
|
+ </Button>
|
|
|
+ </Popconfirm>
|
|
|
+ <Button type="link" onClick={() => {
|
|
|
+ setEditSelectedRow([])
|
|
|
+ }}>
|
|
|
+ 取消选择
|
|
|
+ </Button>
|
|
|
+ </>
|
|
|
+ );
|
|
|
+ }}
|
|
|
/>
|
|
|
<BetaSchemaForm<DataItem>
|
|
|
title={"信息配置"}
|
|
@@ -127,6 +222,7 @@ const Page: React.FC = () => {
|
|
|
enumList: state?.enumList,
|
|
|
bookList: BookInfoChapterAllList?.data?.data,
|
|
|
distributorInfoList: DistributorInfoList?.data?.data,
|
|
|
+ wxAppInfoList:WxAppInfoList?.data?.data
|
|
|
})}
|
|
|
loading={BookInfoBookConfig?.loading}
|
|
|
/>
|