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