Commit e23bed6c authored by cellee's avatar cellee

组件通过参数显示不同内容

Signed-off-by: cellee's avatarcellee <893264950@qq.com>
parent cc8e125a
......@@ -4,7 +4,8 @@ import SearchOptions from './SearchOptions';
import SearchOptionsTow from './SearchOptionsTow';
const SearchOptionsCommnity = (props: any) => {
const { dispatch, CommunityList, opname, defaultName , SearchOptionsCommnity } = props;
const { dispatch, CommunityList, opname, defaultName, type } = props;
const tosCommunityget = (values: any) => {
dispatch({ type: 'Init/tosCommunityget', playload: values });
};
......@@ -34,6 +35,7 @@ const SearchOptionsCommnity = (props: any) => {
list={CommunityList}
extendName={extendName}
def={defaultName}
type={type}
></SearchOptionsTow>
) : null}
</>
......
......@@ -3,7 +3,8 @@ import { Select } from 'antd';
const { Option } = Select;
const SearchOptionsTow = (porps: any) => {
const { list, extendName, def } = porps;
const { list, extendName, def, type } = porps;
const options = list.map((d: any, index: number) => (
<Option value={d} key={index}>
{d}
......@@ -15,18 +16,33 @@ const SearchOptionsTow = (porps: any) => {
}
return (
<div>
<Select
showSearch
allowClear
mode="multiple"
style={{ width: 320 }}
placeholder="Community Name"
optionFilterProp="children"
onChange={onChange}
defaultValue={def}
>
{options}
</Select>
{type ? (
<Select
showSearch
allowClear
mode="multiple"
autoClearSearchValue
style={{ width: 320 }}
placeholder="Community Name"
optionFilterProp="children"
onChange={onChange}
defaultValue={def}
>
{options}
</Select>
) : (
<Select
showSearch
allowClear
style={{ width: 200 }}
placeholder="Community Name"
optionFilterProp="children"
onChange={onChange}
defaultValue={def}
>
{options}
</Select>
)}
</div>
);
};
......
......@@ -30,13 +30,12 @@ const module = 'CommunityAnnouncement';
const CommunityAnnouncement = (props: any) => {
const { dispatch, Data, curString, userListLoading, DataSaveDetail } = props;
// 先清空 其他信息
// 先清空 其他信息
useEffect(() => {
dispatch({ type: module + '/returnDataSave', playload: { DataSave: null } });
dispatch({ type: module + '/returnDataSaveDetail', playload: { DataSaveDetail: null } });
}, [1]);
// 表头
const columns = [
{
......@@ -70,13 +69,13 @@ const CommunityAnnouncement = (props: any) => {
render: function (text: any) {
switch (text) {
case 1:
return <Tag color="green">Publishing</Tag>; // 发布中
return <Tag color="green">Publishing</Tag>; // 发布中
break;
case 0:
return <Tag color="red">Expired</Tag>; // 已过期
return <Tag color="red">Expired</Tag>; // 已过期
break;
default:
return <Tag color="cyan">Waiting for release</Tag>; // 等待发布
return <Tag color="cyan">Waiting for release</Tag>; // 等待发布
break;
}
},
......@@ -85,10 +84,20 @@ const CommunityAnnouncement = (props: any) => {
title: 'Actions',
render: (text: any, record: any) => (
<Space size="middle">
<Button type="link" onClick={() => {goToAdd(1, record);}}>
<Button
type="link"
onClick={() => {
goToAdd(1, record);
}}
>
Edit
</Button>
<Button type="link" onClick={() => {goToAdd(2, record);}}>
<Button
type="link"
onClick={() => {
goToAdd(2, record);
}}
>
Detail
</Button>
</Space>
......@@ -100,11 +109,11 @@ const CommunityAnnouncement = (props: any) => {
const DetailPage = (page: any) => {
let data = {
Method: 'returnDataSaveDetail',
DefaultName: "DataSaveDetail",
Data: page
DefaultName: 'DataSaveDetail',
Data: page,
};
return data;
}
};
// 分页数据一改变就发起请求
useEffect(() => {
......@@ -122,16 +131,15 @@ const CommunityAnnouncement = (props: any) => {
function goToAdd(num: any, record: any) {
if (num == 0) {
history.push('./CommunityAnnouncement/Add');
}else if (num == 1) {
} else if (num == 1) {
// 传递列表信息
dispatch({ type: module + '/returnDataSave', playload: { DataSave: record } });
history.push('./CommunityAnnouncement/Edit');
}else if (num == 2) {
} else if (num == 2) {
// 传递列表信息
dispatch({ type: module + '/returnDataSave', playload: { DataSave: record } });
history.push('./CommunityAnnouncement/Detail');
}
}
const [form] = Form.useForm();
......@@ -145,21 +153,21 @@ const CommunityAnnouncement = (props: any) => {
pageNum: 1,
};
// 把内容存进去
SA(DetailPage(page), module, dispatch)
SA(DetailPage(page), module, dispatch);
};
// 表单提交
const onFinishContract = (value: any) => {
console.log(value)
console.log(value);
if (!value.communityNumList && !value.noticTitlel && !value.creator) {
message.error('Please enter one of them!');
} else {
// 要看是哪里分页
let mlist = { ...value }
mlist.communityNumList = value.communityNumList
// 要看是哪里分页
let mlist = { ...value };
mlist.communityNumList = value.communityNumList;
mlist.pageNum = 1;
// 把内容存进去
SA(DetailPage(mlist), module, dispatch)
SA(DetailPage(mlist), module, dispatch);
// requst(payload);
}
};
......@@ -173,11 +181,11 @@ const CommunityAnnouncement = (props: any) => {
// 页面切换
const paginationHandler = (page: number, pageSize?: number) => {
// 要看是哪里分页
let mlist = { ...DataSaveDetail }
// 要看是哪里分页
let mlist = { ...DataSaveDetail };
mlist.pageNum = page;
// 把内容存进去
SA(DetailPage(mlist), module, dispatch)
SA(DetailPage(mlist), module, dispatch);
};
return (
......@@ -194,6 +202,7 @@ const CommunityAnnouncement = (props: any) => {
<SearchOptionsCommnity
// ubmit={extendName}
opname={opname}
type={1}
/>
</Form.Item>
<Form.Item name="noticTitlel">
......@@ -225,7 +234,6 @@ const CommunityAnnouncement = (props: any) => {
</Form>
</div>
<div style={{ width: '100%', paddingLeft: 10, paddingRight: 10, backgroundColor: '#ffffff' }}>
<ProTable
loading={userListLoading}
rowKey="id"
......@@ -242,8 +250,8 @@ const CommunityAnnouncement = (props: any) => {
}}
>
<PlusOutlined />
Create New Announcement
</Button>,
Create New Announcement
</Button>,
]}
options={{
density: true,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment