list页面上进行设置

This commit is contained in:
pqcqaq 2024-10-16 14:19:12 +08:00
parent f669f852a1
commit 64abfd5ecd
7 changed files with 99 additions and 73 deletions

View File

@ -10,7 +10,7 @@ import Crop from 'oak-general-business/es/components/extraFile/crop';
import Commit from 'oak-general-business/es/components/extraFile/commit';
import CategorySelector from '../../category/selector';
export default function VditorComponent(
export default function EditorComponent(
props: WebComponentProps<
EntityDict,
'essay',

View File

@ -1,26 +0,0 @@
export default OakComponent({
entity: 'essay',
isList: false,
// 这里可能存在bug在list下面的single组件中如果不添加projection会报错
projection: {
id: 1,
// 相关labels
// essayLabels$essay: {
// $entity: 'essayLabels',
// data: {
// id: 1,
// label: {
// id: 1,
// name: 1,
// color: 1,
// },
// sequence: 1,
// },
// }
},
formData({ data }) {
return {
item: data,
};
}
})

View File

@ -1,28 +0,0 @@
import React from 'react';
import { EntityDict } from '@project/oak-app-domain';
import { RowWithActions, WebComponentProps } from 'oak-frontend-base';
import Labels from '../../labels/list';
const EssayLabels = (
props: WebComponentProps<
EntityDict,
'essay',
false,
{
item: RowWithActions<EntityDict, 'essay'>;
}
>
) => {
return (
<>
{props.data.item && (
<Labels
essayId={props.data.item.id}
oakPath={`${props.data.oakFullpath}.essayLabels$essay`}
/>
)}
</>
);
};
export default EssayLabels;

View File

@ -0,0 +1,12 @@
import { essayProjection } from "@project/utils/projection";
export default OakComponent({
entity: 'essay',
isList: false,
projection: essayProjection,
formData({ data }) {
return {
item: data,
};
},
});

View File

@ -0,0 +1,79 @@
import { EntityDict } from '@project/oak-app-domain';
import { Form, Input } from 'antd';
import { RowWithActions, WebComponentProps } from 'oak-frontend-base';
import Crop from 'oak-general-business/es/components/extraFile/crop';
import React from 'react';
import CategorySelector from '../../category/selector';
import Labels from '../../labels/list';
const EssayUpsert = (
props: WebComponentProps<
EntityDict,
'essay',
false,
{
item: RowWithActions<EntityDict, 'essay'>;
}
>
) => {
const { item, oakFullpath, oakEntity } = props.data;
const { update, t } = props.methods;
return (
<>
{item && (
<Form>
<Form.Item label={t('essay:attr.title')}>
<Input
value={item?.title}
onChange={(e) =>
update({
title: e.target.value,
})
}
/>
</Form.Item>
<Form.Item label={t('essay:attr.images')}>
<Crop
entity={oakEntity}
entityId={item.id}
oakPath={`${oakFullpath}.extraFile$entity`}
maxNumber={1}
accept='image/*'
tag1='cover'
enableCrop
showRest
showGrid
rotationSlider
aspectSlider
aspect={16 / 9}
cropQuality={0.8}
enableCompross
maxWidth={1920}
maxHeight={1080}
minWidth={1280}
minHeight={720}
></Crop>
</Form.Item>
<Form.Item label={t('essay:attr.category')}>
<CategorySelector
oakPath='category-list'
selectedId={item?.categoryId}
onSelect={(id: string) => {
update({
categoryId: id,
});
}}
></CategorySelector>
</Form.Item>
<Labels
essayId={props.data.item.id}
oakPath={`${props.data.oakFullpath}.essayLabels$essay`}
/>
</Form>
)}
</>
);
};
export default EssayUpsert;

View File

@ -4,8 +4,7 @@
"summary": "文章摘要",
"author": "作者",
"action":{
"updateLabels": "修改标签",
"createLabels": "新建标签"
"setting": "设置"
},
"label": {
"selectLabels": "选择标签"

View File

@ -10,7 +10,7 @@ import PageHeader from 'oak-frontend-base/es/components/pageHeader2';
import Styles from './web.pc.module.less';
import { Button, Tag } from 'antd';
import Modal from 'antd/es/modal/Modal';
import Labels from '@project/components/console/essay/labels';
import EssayUpsert from '@project/components/console/essay/upsert';
const EssayList = (
props: WebComponentProps<
@ -165,18 +165,8 @@ const EssayList = (
}[] = (row) => {
return [
{
action: 'updateLabels',
label: (
row as RowWithActions<EntityDict, 'essay'> & {
labels: {
id: string;
name: string;
color: string;
}[];
}
).labels.length
? t('action.updateLabels')
: t('action.createLabels'),
action: 'setting',
label: t('action.setting'),
show: true,
},
];
@ -198,7 +188,7 @@ const EssayList = (
updateItem({}, row.id, 'publish');
execute();
break;
case 'updateLabels':
case 'setting':
setUpsertId(row.id);
setShowSelectLabels(true);
break;
@ -245,10 +235,10 @@ const EssayList = (
onOk={() => setShowSelectLabels(false)}
>
{upsertId && (
<Labels
<EssayUpsert
oakPath={`${oakFullpath}.${upsertId}`}
oakId={upsertId}
></Labels>
></EssayUpsert>
)}
</Modal>
</>