分类创建完成
This commit is contained in:
parent
c3b0d564f6
commit
f8c338c2c8
|
|
@ -0,0 +1,40 @@
|
|||
import { extraFileProjection } from "@project/utils/projection";
|
||||
|
||||
export default OakComponent({
|
||||
entity: 'category',
|
||||
isList: false,
|
||||
projection: {
|
||||
id: 1,
|
||||
name: 1,
|
||||
description: 1,
|
||||
extraFile$entity: {
|
||||
$entity: 'extraFile',
|
||||
data: extraFileProjection,
|
||||
filter: {
|
||||
tag1: 'cover',
|
||||
},
|
||||
sorter: [
|
||||
{
|
||||
$attr: {
|
||||
sort: 1,
|
||||
},
|
||||
$direction: 'asc',
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
formData({ data }) {
|
||||
return {
|
||||
item: data,
|
||||
};
|
||||
},
|
||||
lifetimes: {
|
||||
ready() {
|
||||
if (this.isCreation()) {
|
||||
this.update({
|
||||
creatorId: features.token.getUserId(),
|
||||
});
|
||||
}
|
||||
},
|
||||
},
|
||||
});
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
.editor {
|
||||
height: 100%;
|
||||
}
|
||||
|
|
@ -0,0 +1,52 @@
|
|||
import React from 'react';
|
||||
import { EntityDict } from '@project/oak-app-domain';
|
||||
import { RowWithActions, WebComponentProps } from 'oak-frontend-base';
|
||||
import Styles from './style.module.less';
|
||||
import { Button, Form, Input } from 'antd';
|
||||
|
||||
const CategoryUpsert = (
|
||||
props: WebComponentProps<
|
||||
EntityDict,
|
||||
'category',
|
||||
false,
|
||||
{
|
||||
item: RowWithActions<EntityDict, 'category'>
|
||||
}
|
||||
>
|
||||
) => {
|
||||
const { item } = props.data;
|
||||
const { update, t } = props.methods;
|
||||
|
||||
return (
|
||||
<div className={Styles.editor}>
|
||||
{item ? (
|
||||
<Form labelCol={{ span: 5 }}>
|
||||
<Form.Item label={t('category:attr.name')}>
|
||||
<Input
|
||||
value={item.name || ''}
|
||||
onChange={(e) => {
|
||||
update({ name: e.target.value });
|
||||
}}
|
||||
type='text'
|
||||
placeholder={t('category:attr.name')}
|
||||
/>
|
||||
</Form.Item>
|
||||
<Form.Item label={t('category:attr.description')}>
|
||||
<Input
|
||||
value={item.description || ''}
|
||||
onChange={(e) => {
|
||||
update({ description: e.target.value });
|
||||
}}
|
||||
type='text'
|
||||
placeholder={t('category:attr.description')}
|
||||
/>
|
||||
</Form.Item>
|
||||
</Form>
|
||||
) : (
|
||||
<div>No item</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default CategoryUpsert;
|
||||
|
|
@ -54,7 +54,7 @@ const menus: IMenu[] = [
|
|||
url: '/relation/entityList',
|
||||
parent: 'System',
|
||||
},
|
||||
// category
|
||||
// category
|
||||
{
|
||||
name: 'categoryManage',
|
||||
icon: 'stealth',
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ export default OakComponent({
|
|||
],
|
||||
formData({ data }) {
|
||||
return {
|
||||
list: data,
|
||||
list: data.filter(item => (item.$$createAt$$ as number) > 1),
|
||||
};
|
||||
},
|
||||
actions: ['create', 'update', 'remove'],
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
{
|
||||
"pageHeader": "分类列表",
|
||||
"author": "作者"
|
||||
}
|
||||
"author": "作者",
|
||||
"createCategory": "创建分类"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,7 +7,8 @@ import {
|
|||
} from 'oak-frontend-base';
|
||||
import PageHeader from 'oak-frontend-base/es/components/pageHeader2';
|
||||
import { ListPro } from '@project/components/AbstractComponents';
|
||||
import { Button, message } from 'antd';
|
||||
import { Button, message, Modal } from 'antd';
|
||||
import CategoryUpsert from '@project/components/console/category/upsert';
|
||||
|
||||
/**
|
||||
* 分类列表
|
||||
|
|
@ -25,7 +26,10 @@ const CategoryList = (
|
|||
>
|
||||
) => {
|
||||
const { list, oakFullpath } = props.data;
|
||||
const { t } = props.methods;
|
||||
const { t, navigateTo, updateItem, execute, addItem, clean, removeItem } =
|
||||
props.methods;
|
||||
|
||||
const [upsertId, setUpsertId] = React.useState<string | null>(null);
|
||||
|
||||
const attrs: OakAbsAttrDef[] = [
|
||||
'name',
|
||||
|
|
@ -39,27 +43,65 @@ const CategoryList = (
|
|||
},
|
||||
];
|
||||
|
||||
const onAction = (row: any, action: string) => {
|
||||
switch (action) {
|
||||
case 'update':
|
||||
setUpsertId(row.id);
|
||||
break;
|
||||
case 'remove':
|
||||
removeItem(row.id);
|
||||
execute();
|
||||
break;
|
||||
default:
|
||||
message.error('Unknown action');
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<PageHeader
|
||||
title={t('pageHeader')}
|
||||
extra={
|
||||
<Button
|
||||
type='primary'
|
||||
onClick={() => {
|
||||
message.info('create');
|
||||
}}
|
||||
>
|
||||
{t('common::action.create')}
|
||||
</Button>
|
||||
}
|
||||
>
|
||||
<ListPro
|
||||
entity='category'
|
||||
attributes={attrs}
|
||||
data={list}
|
||||
oakPath={oakFullpath}
|
||||
></ListPro>
|
||||
</PageHeader>
|
||||
<>
|
||||
<PageHeader
|
||||
title={t('pageHeader')}
|
||||
extra={
|
||||
<Button
|
||||
type='primary'
|
||||
onClick={() => {
|
||||
setUpsertId(addItem({}));
|
||||
}}
|
||||
>
|
||||
{t('common::action.create')}
|
||||
</Button>
|
||||
}
|
||||
>
|
||||
<ListPro
|
||||
entity='category'
|
||||
attributes={attrs}
|
||||
data={list}
|
||||
oakPath={oakFullpath}
|
||||
onAction={onAction}
|
||||
></ListPro>
|
||||
</PageHeader>
|
||||
<Modal
|
||||
title={t('createCategory')}
|
||||
open={!!upsertId}
|
||||
onCancel={() => {
|
||||
clean();
|
||||
setUpsertId(null);
|
||||
}}
|
||||
onOk={() => {
|
||||
execute();
|
||||
setUpsertId(null);
|
||||
}}
|
||||
destroyOnClose
|
||||
zIndex={10}
|
||||
>
|
||||
{oakFullpath && upsertId && (
|
||||
<CategoryUpsert
|
||||
oakId={upsertId}
|
||||
oakPath={`${oakFullpath}.${upsertId}`}
|
||||
></CategoryUpsert>
|
||||
)}
|
||||
</Modal>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue