|
@@ -9,6 +9,7 @@ import {
|
|
|
message,
|
|
message,
|
|
|
Space,
|
|
Space,
|
|
|
Table,
|
|
Table,
|
|
|
|
|
+ Badge,
|
|
|
} from "antd";
|
|
} from "antd";
|
|
|
import { ActionType, ProTable } from "@ant-design/pro-components";
|
|
import { ActionType, ProTable } from "@ant-design/pro-components";
|
|
|
import {
|
|
import {
|
|
@@ -16,20 +17,23 @@ import {
|
|
|
DeleteOutlined,
|
|
DeleteOutlined,
|
|
|
TeamOutlined,
|
|
TeamOutlined,
|
|
|
ExclamationCircleOutlined,
|
|
ExclamationCircleOutlined,
|
|
|
|
|
+ FolderAddOutlined,
|
|
|
|
|
+ ReconciliationOutlined,
|
|
|
} from "@ant-design/icons";
|
|
} from "@ant-design/icons";
|
|
|
|
|
|
|
|
import ArticleCreate from "../../../components/article/ArticleCreate";
|
|
import ArticleCreate from "../../../components/article/ArticleCreate";
|
|
|
-import { delete_, get, post } from "../../../request";
|
|
|
|
|
|
|
+import { delete_, get } from "../../../request";
|
|
|
import {
|
|
import {
|
|
|
IArticleListResponse,
|
|
IArticleListResponse,
|
|
|
- IArticleMapAddRequest,
|
|
|
|
|
- IArticleMapAddResponse,
|
|
|
|
|
IDeleteResponse,
|
|
IDeleteResponse,
|
|
|
} from "../../../components/api/Article";
|
|
} from "../../../components/api/Article";
|
|
|
import { PublicityValueEnum } from "../../../components/studio/table";
|
|
import { PublicityValueEnum } from "../../../components/studio/table";
|
|
|
import { useRef, useState } from "react";
|
|
import { useRef, useState } from "react";
|
|
|
-import AnthologyModal from "../../../components/anthology/AnthologyModal";
|
|
|
|
|
import ArticleTplMaker from "../../../components/article/ArticleTplMaker";
|
|
import ArticleTplMaker from "../../../components/article/ArticleTplMaker";
|
|
|
|
|
+import ShareModal from "../../../components/share/ShareModal";
|
|
|
|
|
+import { EResType } from "../../../components/share/Share";
|
|
|
|
|
+import AddToAnthology from "../../../components/article/AddToAnthology";
|
|
|
|
|
+import AnthologySelect from "../../../components/anthology/AnthologySelect";
|
|
|
|
|
|
|
|
const { Text } = Typography;
|
|
const { Text } = Typography;
|
|
|
|
|
|
|
@@ -39,6 +43,8 @@ interface DataItem {
|
|
|
title: string;
|
|
title: string;
|
|
|
subtitle: string;
|
|
subtitle: string;
|
|
|
summary: string;
|
|
summary: string;
|
|
|
|
|
+ anthologyCount?: number;
|
|
|
|
|
+ anthologyTitle?: string;
|
|
|
publicity: number;
|
|
publicity: number;
|
|
|
createdAt: number;
|
|
createdAt: number;
|
|
|
}
|
|
}
|
|
@@ -46,6 +52,7 @@ const Widget = () => {
|
|
|
const intl = useIntl(); //i18n
|
|
const intl = useIntl(); //i18n
|
|
|
const { studioname } = useParams(); //url 参数
|
|
const { studioname } = useParams(); //url 参数
|
|
|
const [openCreate, setOpenCreate] = useState(false);
|
|
const [openCreate, setOpenCreate] = useState(false);
|
|
|
|
|
+ const [anthologyId, setAnthologyId] = useState<string>();
|
|
|
|
|
|
|
|
const showDeleteConfirm = (id: string, title: string) => {
|
|
const showDeleteConfirm = (id: string, title: string) => {
|
|
|
Modal.confirm({
|
|
Modal.confirm({
|
|
@@ -81,7 +88,6 @@ const Widget = () => {
|
|
|
},
|
|
},
|
|
|
});
|
|
});
|
|
|
};
|
|
};
|
|
|
-
|
|
|
|
|
const ref = useRef<ActionType>();
|
|
const ref = useRef<ActionType>();
|
|
|
return (
|
|
return (
|
|
|
<>
|
|
<>
|
|
@@ -107,20 +113,33 @@ const Widget = () => {
|
|
|
ellipsis: true,
|
|
ellipsis: true,
|
|
|
render: (text, row, index, action) => {
|
|
render: (text, row, index, action) => {
|
|
|
return (
|
|
return (
|
|
|
- <Link to={`/studio/${studioname}/article/${row.id}/edit`}>
|
|
|
|
|
- {row.title}
|
|
|
|
|
- </Link>
|
|
|
|
|
|
|
+ <>
|
|
|
|
|
+ <div>
|
|
|
|
|
+ <Link to={`/studio/${studioname}/article/${row.id}/edit`}>
|
|
|
|
|
+ {row.title}
|
|
|
|
|
+ </Link>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ <Text type="secondary">{row.subtitle}</Text>
|
|
|
|
|
+ </>
|
|
|
);
|
|
);
|
|
|
},
|
|
},
|
|
|
},
|
|
},
|
|
|
{
|
|
{
|
|
|
title: intl.formatMessage({
|
|
title: intl.formatMessage({
|
|
|
- id: "forms.fields.subtitle.label",
|
|
|
|
|
|
|
+ id: "columns.library.anthology.title",
|
|
|
}),
|
|
}),
|
|
|
dataIndex: "subtitle",
|
|
dataIndex: "subtitle",
|
|
|
key: "subtitle",
|
|
key: "subtitle",
|
|
|
- tip: "过长会自动收缩",
|
|
|
|
|
- ellipsis: true,
|
|
|
|
|
|
|
+ render: (text, row, index, action) => {
|
|
|
|
|
+ return (
|
|
|
|
|
+ <Space>
|
|
|
|
|
+ {row.anthologyTitle}
|
|
|
|
|
+ {row.anthologyCount ? (
|
|
|
|
|
+ <Badge color="geekblue" count={row.anthologyCount} />
|
|
|
|
|
+ ) : undefined}
|
|
|
|
|
+ </Space>
|
|
|
|
|
+ );
|
|
|
|
|
+ },
|
|
|
},
|
|
},
|
|
|
{
|
|
{
|
|
|
title: intl.formatMessage({
|
|
title: intl.formatMessage({
|
|
@@ -131,7 +150,6 @@ const Widget = () => {
|
|
|
tip: "过长会自动收缩",
|
|
tip: "过长会自动收缩",
|
|
|
ellipsis: true,
|
|
ellipsis: true,
|
|
|
},
|
|
},
|
|
|
-
|
|
|
|
|
{
|
|
{
|
|
|
title: intl.formatMessage({
|
|
title: intl.formatMessage({
|
|
|
id: "forms.fields.publicity.label",
|
|
id: "forms.fields.publicity.label",
|
|
@@ -163,6 +181,7 @@ const Widget = () => {
|
|
|
render: (text, row, index, action) => {
|
|
render: (text, row, index, action) => {
|
|
|
return [
|
|
return [
|
|
|
<Dropdown.Button
|
|
<Dropdown.Button
|
|
|
|
|
+ trigger={["click", "contextMenu"]}
|
|
|
key={index}
|
|
key={index}
|
|
|
type="link"
|
|
type="link"
|
|
|
menu={{
|
|
menu={{
|
|
@@ -177,15 +196,31 @@ const Widget = () => {
|
|
|
trigger={<>模版</>}
|
|
trigger={<>模版</>}
|
|
|
/>
|
|
/>
|
|
|
),
|
|
),
|
|
|
- icon: <TeamOutlined />,
|
|
|
|
|
|
|
+ icon: <ReconciliationOutlined />,
|
|
|
},
|
|
},
|
|
|
{
|
|
{
|
|
|
key: "share",
|
|
key: "share",
|
|
|
- label: intl.formatMessage({
|
|
|
|
|
- id: "buttons.share",
|
|
|
|
|
- }),
|
|
|
|
|
|
|
+ label: (
|
|
|
|
|
+ <ShareModal
|
|
|
|
|
+ trigger={intl.formatMessage({
|
|
|
|
|
+ id: "buttons.share",
|
|
|
|
|
+ })}
|
|
|
|
|
+ resId={row.id}
|
|
|
|
|
+ resType={EResType.article}
|
|
|
|
|
+ />
|
|
|
|
|
+ ),
|
|
|
icon: <TeamOutlined />,
|
|
icon: <TeamOutlined />,
|
|
|
- disabled: true,
|
|
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ key: "addToAnthology",
|
|
|
|
|
+ label: (
|
|
|
|
|
+ <AddToAnthology
|
|
|
|
|
+ trigger="加入文集"
|
|
|
|
|
+ studioName={studioname}
|
|
|
|
|
+ articleIds={[row.id]}
|
|
|
|
|
+ />
|
|
|
|
|
+ ),
|
|
|
|
|
+ icon: <FolderAddOutlined />,
|
|
|
},
|
|
},
|
|
|
{
|
|
{
|
|
|
key: "remove",
|
|
key: "remove",
|
|
@@ -257,40 +292,18 @@ const Widget = () => {
|
|
|
onCleanSelected,
|
|
onCleanSelected,
|
|
|
}) => {
|
|
}) => {
|
|
|
return (
|
|
return (
|
|
|
- <Space size={16}>
|
|
|
|
|
- <AnthologyModal
|
|
|
|
|
- studioName={studioname}
|
|
|
|
|
- trigger={<Button type="link">加入文集</Button>}
|
|
|
|
|
- onSelect={(id: string) => {
|
|
|
|
|
- console.log(selectedRowKeys);
|
|
|
|
|
- post<IArticleMapAddRequest, IArticleMapAddResponse>(
|
|
|
|
|
- "/v2/article-map",
|
|
|
|
|
- {
|
|
|
|
|
- anthology_id: id,
|
|
|
|
|
- article_id: selectedRowKeys.map((item) =>
|
|
|
|
|
- item.toString()
|
|
|
|
|
- ),
|
|
|
|
|
- operation: "add",
|
|
|
|
|
- }
|
|
|
|
|
- )
|
|
|
|
|
- .finally(() => {
|
|
|
|
|
- onCleanSelected();
|
|
|
|
|
- })
|
|
|
|
|
- .then((json) => {
|
|
|
|
|
- if (json.ok) {
|
|
|
|
|
- message.success(json.data);
|
|
|
|
|
- } else {
|
|
|
|
|
- message.error(json.message);
|
|
|
|
|
- }
|
|
|
|
|
- })
|
|
|
|
|
- .catch((e) => console.error(e));
|
|
|
|
|
- }}
|
|
|
|
|
- />
|
|
|
|
|
- </Space>
|
|
|
|
|
|
|
+ <AddToAnthology
|
|
|
|
|
+ studioName={studioname}
|
|
|
|
|
+ articleIds={selectedRowKeys.map((item) => item.toString())}
|
|
|
|
|
+ onFinally={() => {
|
|
|
|
|
+ onCleanSelected();
|
|
|
|
|
+ }}
|
|
|
|
|
+ />
|
|
|
);
|
|
);
|
|
|
}}
|
|
}}
|
|
|
request={async (params = {}, sorter, filter) => {
|
|
request={async (params = {}, sorter, filter) => {
|
|
|
console.log(params, sorter, filter);
|
|
console.log(params, sorter, filter);
|
|
|
|
|
+ console.log("anthology", anthologyId);
|
|
|
let url = `/v2/article?view=studio&name=${studioname}`;
|
|
let url = `/v2/article?view=studio&name=${studioname}`;
|
|
|
const offset =
|
|
const offset =
|
|
|
((params.current ? params.current : 1) - 1) *
|
|
((params.current ? params.current : 1) - 1) *
|
|
@@ -299,8 +312,11 @@ const Widget = () => {
|
|
|
if (typeof params.keyword !== "undefined") {
|
|
if (typeof params.keyword !== "undefined") {
|
|
|
url += "&search=" + (params.keyword ? params.keyword : "");
|
|
url += "&search=" + (params.keyword ? params.keyword : "");
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+ if (typeof anthologyId !== "undefined") {
|
|
|
|
|
+ url += "&anthology=" + anthologyId;
|
|
|
|
|
+ }
|
|
|
const res = await get<IArticleListResponse>(url);
|
|
const res = await get<IArticleListResponse>(url);
|
|
|
|
|
+ console.log("article list", res);
|
|
|
const items: DataItem[] = res.data.rows.map((item, id) => {
|
|
const items: DataItem[] = res.data.rows.map((item, id) => {
|
|
|
const date = new Date(item.created_at);
|
|
const date = new Date(item.created_at);
|
|
|
return {
|
|
return {
|
|
@@ -309,6 +325,8 @@ const Widget = () => {
|
|
|
title: item.title,
|
|
title: item.title,
|
|
|
subtitle: item.subtitle,
|
|
subtitle: item.subtitle,
|
|
|
summary: item.summary,
|
|
summary: item.summary,
|
|
|
|
|
+ anthologyCount: item.anthology_count,
|
|
|
|
|
+ anthologyTitle: item.anthology_first?.title,
|
|
|
publicity: item.status,
|
|
publicity: item.status,
|
|
|
createdAt: date.getTime(),
|
|
createdAt: date.getTime(),
|
|
|
};
|
|
};
|
|
@@ -324,12 +342,20 @@ const Widget = () => {
|
|
|
pagination={{
|
|
pagination={{
|
|
|
showQuickJumper: true,
|
|
showQuickJumper: true,
|
|
|
showSizeChanger: true,
|
|
showSizeChanger: true,
|
|
|
|
|
+ pageSize: 10,
|
|
|
}}
|
|
}}
|
|
|
search={false}
|
|
search={false}
|
|
|
options={{
|
|
options={{
|
|
|
search: true,
|
|
search: true,
|
|
|
}}
|
|
}}
|
|
|
toolBarRender={() => [
|
|
toolBarRender={() => [
|
|
|
|
|
+ <AnthologySelect
|
|
|
|
|
+ studioName={studioname}
|
|
|
|
|
+ onSelect={(value: string) => {
|
|
|
|
|
+ setAnthologyId(value);
|
|
|
|
|
+ ref.current?.reload();
|
|
|
|
|
+ }}
|
|
|
|
|
+ />,
|
|
|
<Popover
|
|
<Popover
|
|
|
content={
|
|
content={
|
|
|
<ArticleCreate
|
|
<ArticleCreate
|