actionRef={ref}
columns={[
{
title: intl.formatMessage({
id: "dict.fields.sn.label",
}),
dataIndex: "id",
key: "id",
width: 50,
search: false,
},
{
title: intl.formatMessage({
id: "forms.fields.title.label",
}),
dataIndex: "title",
width: 250,
key: "title",
tooltip: "过长会自动收缩",
ellipsis: true,
render: (_text, row, index, _action) => {
return (
<>
{activeKey !== "my" ? (
) : undefined}
>
);
},
},
{
title: intl.formatMessage({
id: "forms.fields.created-at.label",
}),
key: "progress",
hideInTable: typeof chapter === "undefined",
render(_dom, entity, _index, _action, _schema) {
return (
);
},
},
{
title: intl.formatMessage({
id: "forms.fields.summary.label",
}),
dataIndex: "summary",
key: "summary",
tooltip: "过长会自动收缩",
ellipsis: true,
},
{
title: intl.formatMessage({
id: "forms.fields.role.label",
}),
dataIndex: "role",
key: "role",
width: 80,
search: false,
filters: true,
onFilter: true,
valueEnum: {
all: {
text: intl.formatMessage({
id: "channel.type.all.title",
}),
status: "Default",
},
owner: {
text: intl.formatMessage({
id: "auth.role.owner",
}),
},
manager: {
text: intl.formatMessage({
id: "auth.role.manager",
}),
},
editor: {
text: intl.formatMessage({
id: "auth.role.editor",
}),
},
member: {
text: intl.formatMessage({
id: "auth.role.member",
}),
},
},
},
{
title: intl.formatMessage({
id: "forms.fields.type.label",
}),
dataIndex: "type",
key: "type",
width: 80,
search: false,
filters: true,
onFilter: true,
valueEnum: channelTypeFilter,
},
{
title: intl.formatMessage({
id: "forms.fields.publicity.label",
}),
dataIndex: "publicity",
key: "publicity",
width: 80,
search: false,
filters: true,
onFilter: true,
valueEnum: PublicityValueEnum(),
},
{
title: intl.formatMessage({
id: "forms.fields.created-at.label",
}),
key: "created_at",
width: 100,
search: false,
dataIndex: "created_at",
valueType: "date",
sorter: true,
},
{
title: intl.formatMessage({ id: "buttons.option" }),
key: "option",
width: 100,
valueType: "option",
hideInTable: activeKey !== "my",
render: (_text, row, index, _action) => {
return [
),
icon: ,
},
{
key: "transfer",
label: intl.formatMessage({
id: "columns.studio.transfer.title",
}),
icon: ,
},
{
key: "remove",
label: intl.formatMessage({
id: "buttons.delete",
}),
icon: ,
danger: true,
},
],
onClick: (e) => {
switch (e.key) {
case "remove":
showDeleteConfirm(row.uid, row.title);
break;
case "transfer":
setTransfer([row.uid]);
setTransferName(row.title);
setTransferOpen(true);
break;
default:
break;
}
},
}}
>
{intl.formatMessage({
id: "buttons.setting",
})}
,
];
},
},
]}
request={async (params = {}, sorter, filter) => {
console.log(params, sorter, filter);
let url = `/v2/channel?`;
if (activeKey === "community") {
url += `view=public`;
} else {
url += `view=studio&view2=${activeKey}&name=${studioName}`;
}
if (chapter) {
url += `&book=${chapter.book}¶graph=${chapter.paragraph}`;
}
const offset =
((params.current ? params.current : 1) - 1) *
(params.pageSize ? params.pageSize : 20);
url += `&limit=${params.pageSize}&offset=${offset}`;
url += collaborator ? "&collaborator=" + collaborator : "";
url += params.keyword ? "&search=" + params.keyword : "";
url += channelType ? "&type=" + channelType : "";
if (chapter && activeKey === "community") {
url += "&order=progress";
} else {
url += getSorterUrl(sorter);
}
console.log("url", url);
const res: IApiResponseChannelList = await get(url);
const items: IChannelItem[] = res.data.rows.map((item, id) => {
return {
id: id + 1,
uid: item.uid,
title: item.name,
summary: item.summary,
type: item.type,
role: item.role,
progress: item.progress,
studio: item.studio,
publicity: item.status,
created_at: item.created_at,
};
});
return {
total: res.data.count,
succcess: true,
data: items,
};
}}
rowKey="id"
bordered
pagination={{
showQuickJumper: true,
showSizeChanger: true,
}}
search={false}
options={{
search: true,
}}
toolBarRender={() => [
activeKey !== "my" ? (
{
setCollaborator(value);
ref.current?.reload();
}}
/>
) : undefined,
{
setOpenCreate(false);
ref.current?.reload();
}}
/>
}
placement="bottomRight"
trigger="click"
open={openCreate}
onOpenChange={(open: boolean) => {
setOpenCreate(open);
}}
>
} type="primary">
{intl.formatMessage({ id: "buttons.create" })}
,
]}
toolbar={{
menu: {
activeKey,
items: [
{
key: "my",
label: (
{intl.formatMessage({ id: "labels.this-studio" })}
{renderBadge(myNumber, activeKey === "my")}
),
},
{
key: "collaboration",
label: (
{intl.formatMessage({ id: "labels.collaboration" })}
{renderBadge(
collaborationNumber,
activeKey === "collaboration"
)}
),
},
{
key: "community",
label: (
{intl.formatMessage({ id: "labels.community" })}
{renderBadge(
collaborationNumber,
activeKey === "community"
)}
),
},
],
onChange(key) {
console.log("show course", key);
setActiveKey(key);
setCollaborator(undefined);
ref.current?.reload();
},
},
}}
/>
setTransferOpen(visible)}
/>
>
);
};
export default ChannelTableWidget;