Browse Source

加些筛选条件

master
nili 3 years ago
parent
commit
8655dfc12d
  1. 23
      src/pages/PoemPage/index.tsx

23
src/pages/PoemPage/index.tsx

@ -12,13 +12,11 @@ const columns: ProColumns<API.PoemBo>[] = [
{ {
dataIndex: 'id', dataIndex: 'id',
title: 'id', title: 'id',
hideInSearch: true,
}, },
{ {
title: '标题', title: '标题',
dataIndex: 'title', dataIndex: 'title',
ellipsis: true, ellipsis: true,
hideInSearch: true,
tip: '标题过长会自动收缩', tip: '标题过长会自动收缩',
formItemProps: { formItemProps: {
rules: [ rules: [
@ -51,7 +49,7 @@ const columns: ProColumns<API.PoemBo>[] = [
}, },
{ {
title: '作者', title: '作者',
dataIndex: 'author', dataIndex: 'authorId',
hideInTable: true, hideInTable: true,
formItemProps: { formItemProps: {
rules: [ rules: [
@ -79,7 +77,7 @@ const columns: ProColumns<API.PoemBo>[] = [
/>, />,
<Popconfirm <Popconfirm
title="确定删除吗?" title="确定删除吗?"
key={record.id} key={'delete' + record.id}
onConfirm={async () => { onConfirm={async () => {
await savePoemUsingPOST({ id: record.id, status: -1 }); await savePoemUsingPOST({ id: record.id, status: -1 });
action?.reload(); action?.reload();
@ -91,7 +89,7 @@ const columns: ProColumns<API.PoemBo>[] = [
</Popconfirm>, </Popconfirm>,
<Popconfirm <Popconfirm
title="确定标记吗?" title="确定标记吗?"
key={record.id} key={'mark_' + record.id}
onConfirm={async () => { onConfirm={async () => {
await savePoemUsingPOST({ id: record.id, status: record.status == 0 ? 1 : 0 }); await savePoemUsingPOST({ id: record.id, status: record.status == 0 ? 1 : 0 });
action?.reload(); action?.reload();
@ -115,16 +113,13 @@ export default () => {
cardBordered cardBordered
request={async (params = {}) => { request={async (params = {}) => {
const query: API.QueryParam[] = []; const query: API.QueryParam[] = [];
if (params.author) { const allowedKey = ['authorId', 'title', 'status', 'id'];
let author = params.author; Object.keys(params).forEach((x) => {
if (typeof params.author == 'string') { if (allowedKey.includes(x) && params[x]) {
author = JSON.parse(params.author); query.push({ key: x, val: params[x] });
}
query.push({ key: 'authorId', val: author });
}
if (params.status) {
query.push({ key: 'status', val: params.status });
} }
});
const response = await poemListUsingPOST({ const response = await poemListUsingPOST({
current: params.current, current: params.current,
pageSize: params.pageSize, pageSize: params.pageSize,

Loading…
Cancel
Save