Commit a0927faa authored by cellee's avatar cellee

预约设施同一组件不同条件搜索

Signed-off-by: cellee's avatarcellee <893264950@qq.com>
parent 2e28f266
...@@ -93,10 +93,11 @@ class SelectOptions extends React.PureComponent { ...@@ -93,10 +93,11 @@ class SelectOptions extends React.PureComponent {
componentWillReceiveProps(nextProps) { componentWillReceiveProps(nextProps) {
// 如果存在更新 就拿取最新的选中小区值 // 如果存在更新 就拿取最新的选中小区值
// 判断是不是props 的最新值 否则每次点击都要更新 // 判断是不是props 的最新值 否则每次点击都要更新
// console.log(nextProps.checklist);
if (nextProps.checklist !== this.props.checklist) { if (nextProps.checklist.sort().toString() !== this.props.checklist.sort().toString()) {
this.setState({ this.setState({
checkedList: nextProps.checklist, checkedList: nextProps.checklist,
resultList: nextProps.checklist,
}); });
} }
} }
......
import React, { useState, useEffect, useRef } from 'react';
import { Link, useIntl, connect, Dispatch, history } from 'umi';
import styles from './index.less';
import BackButton from '../BackButton/BackButton';
import TitleGet from '../TitleGet/TitleGet';
import { SearchOutlined } from '@ant-design/icons';
import { Input, Row, Col, Form, Select, Button, DatePicker } from 'antd';
const { Option } = Select;
import SelectOptions from '../SelectOptions/Tow';
import { gray } from 'chalk';
import SearchOptionsCommnity from '../SearchOptions/SearchOptionsCommnity';
const TitleSearch = (props: any) => {
// console.log("===================================", props)
const { dispatch, CommunityList } = props;
const key = props.listkey;
const name = props.list;
// const single = props.single
// const checklist = props.checklist;
// const status = props.status;
// const communitySelect = props.communitySelect
// const defaultValue = props.defaultValue;
const { single, checklist, status, communitySelect, defaultValue } = props;
const time = props.time;
const community = props.community;
const [selectOptions, setSelectOptions] = useState(true);
const [communitys, setCommunitys] = useState(CommunityList);
const [communitySingle, setCommunitySingle] = useState(null);
const [datePicker, setDate] = useState(null);
const [form] = Form.useForm();
const tosCommunityget = (values: any) => {
dispatch({ type: 'Init/tosCommunityget', playload: values });
};
useEffect(() => {
// console.log("标题搜寻组件初始化") OK
if (CommunityList == null) {
// console.log("小区数量初始化") OK
console.log('这里开始获取小区');
tosCommunityget(null);
}
if (defaultValue != null) {
form.setFieldsValue(defaultValue);
}
}, []);
useEffect(() => {
if (defaultValue != null) {
form.setFieldsValue(defaultValue);
}
}, [defaultValue]);
useEffect(() => {
// console.log(CommunityList)
if (CommunityList != null) {
// console.log("小区数量初始化完毕") OK
var tmp = {};
tmp[community] = CommunityList;
// props.onSubmit(tmp) 禁用 改用组件初始化
setCommunitys(CommunityList);
}
}, [CommunityList]);
const onFinish = (values: any) => {
if (datePicker) {
values[time[0]] = datePicker;
}
if (community) {
values[community] = communitys;
}
console.log('Success:', values);
props.onSubmit(values);
};
const onFinishFailed = (errorInfo: any) => {
console.log('Failed:', errorInfo);
};
const onChange = (date: any, dateString: string) => {
setDate(dateString);
};
const printContent = (comment: any) => {
setCommunitys(comment);
};
// 选择小区名字并赋值
const opname = (value: any) => {
form.setFieldsValue({
communityName: value,
});
};
return (
<>
<Form form={form} name="basic" onFinish={onFinish} onFinishFailed={onFinishFailed}>
<Row gutter={32}>
{communitySelect != null ? (
<Col key={'communitySelect_'}>
<Form.Item name={'communityName'}>
<SearchOptionsCommnity titleSearch={true} opname={opname} />
</Form.Item>
</Col>
) : null}
{key != null
? key.map((item, index) => {
return (
<Col key={'KeyCol_' + index}>
<Form.Item name={item}>
<Input placeholder={name[index]} allowClear />
</Form.Item>
</Col>
);
})
: null}
{status != null
? status.map((item, index) => {
return (
<Col key={'StatusCol_' + index}>
<Form.Item name={item.name[0]}>
<Select style={{ width: 160 }} placeholder={item.name[1]} allowClear={true}>
{item.data.map((word) => {
return (
<Option key={word} value={word[0]}>
{word[1]}
</Option>
);
})}
</Select>
</Form.Item>
</Col>
);
})
: null}
{time != null ? (
<Col key={'datePicker_'}>
{' '}
<DatePicker placeholder={time[1]} onChange={onChange} />
</Col>
) : null}
{community == null ? (
<Col>
<Form.Item>
<Button type="primary" htmlType="submit">
Search
</Button>
</Form.Item>
</Col>
) : null}
</Row>
{community != null ? (
<>
{CommunityList != null ? (
<SelectOptions
checklist={checklist}
single={single}
list={CommunityList.sort()}
show={selectOptions}
onSubmit={printContent}
/>
) : null}
<Form.Item>
<Button
type="primary"
htmlType="submit"
style={{ backgroundColor: '#e7f4ff', color: 'rgba(24,144,255,1)' }}
>
<SearchOutlined /> Search
</Button>
</Form.Item>
</>
) : null}
</Form>
</>
);
};
function mapStateToProps(state: any) {
// console.log("state参数",state)
const { CommunityList } = state.Init;
return {
CommunityList,
};
}
export default connect(mapStateToProps)(TitleSearch);
// time={["key","预订时间筛选"]}
// status = [{name:"status",data:["处理", "未处理"]}]
// listkey={['A', 'C']} list={['订单状态', '预订时间筛选']}
// <TitleSearch
// status={[{
// name: ["status", "订单状态"],
// data: [[0, "全部"], [1, "已申请"], [2, "已预订"], [3, "已使用"], [4, "已取消"]]
// }]}
// time={["key", "预订时间筛选"]}
// community={"communityName"}
// // single={true}
// onSubmit={CallBackTitleSearch} />
...@@ -34,7 +34,7 @@ const TitleSearch = (props: any) => { ...@@ -34,7 +34,7 @@ const TitleSearch = (props: any) => {
const community = props.community; const community = props.community;
// const [selectOptions, setSelectOptions] = useState(true); // const [selectOptions, setSelectOptions] = useState(true);
const [communitys, setCommunitys] = useState(CommunityList); const [communitys, setCommunitys] = useState([] as any);
const [datePicker, setDate] = useState(null as any); const [datePicker, setDate] = useState(null as any);
const [defalueName, setDefalueName] = useState(undefined); const [defalueName, setDefalueName] = useState(undefined);
...@@ -48,10 +48,19 @@ const TitleSearch = (props: any) => { ...@@ -48,10 +48,19 @@ const TitleSearch = (props: any) => {
// console.log("标题搜寻组件初始化") OK // console.log("标题搜寻组件初始化") OK
if (CommunityList == null) { if (CommunityList == null) {
// console.log("小区数量初始化") OK // console.log("小区数量初始化") OK
tosCommunityget(null); tosCommunityget([]);
} }
}, []); }, []);
// 监听选择小区
useEffect(() => {
// console.log(checklist);
if (checklist && checklist.sort().toString() !== communitys.sort().toString()) {
// form.setFieldsValue(checklist);
setCommunitys(checklist);
}
}, [checklist]);
useEffect(() => { useEffect(() => {
if (defaultValue != null) { if (defaultValue != null) {
form.setFieldsValue(defaultValue); form.setFieldsValue(defaultValue);
...@@ -110,6 +119,8 @@ const TitleSearch = (props: any) => { ...@@ -110,6 +119,8 @@ const TitleSearch = (props: any) => {
}; };
const printContent = (comment: any) => { const printContent = (comment: any) => {
// console.log(comment);
setCommunitys(comment); setCommunitys(comment);
}; };
......
...@@ -233,8 +233,18 @@ export default { ...@@ -233,8 +233,18 @@ export default {
} }
break; break;
} }
} else if (resp.error_code == '0002') {
// 多端操作提示清空并返回
message.error(resp.error_msg ? `${resp.error_msg}` : 'This record has been processed!');
let Data,
Data2,
Data3 = null;
yield put({ type: 'returnPage', Data });
yield put({ type: 'returnPage2', Data2 });
yield put({ type: 'returnPage3', Data3 });
history.push('/CommunityManagement/FacilityBookings');
} else { } else {
console.log('错误?'); // console.log('错误?');
message.error(`${resp.error_code}:${resp.error_msg}`); message.error(`${resp.error_code}:${resp.error_msg}`);
} }
}, },
......
...@@ -218,7 +218,7 @@ const FacilityBookings = (props: any) => { ...@@ -218,7 +218,7 @@ const FacilityBookings = (props: any) => {
}; };
// console.log(obj); // console.log(obj);
requse(obj, tab); requse(obj, tab);
} else { } else if (tab == 2 && CommunityList !== null) {
let obj = { let obj = {
communityNameList: search2.communityNameList ? search2.communityNameList : CommunityList, communityNameList: search2.communityNameList ? search2.communityNameList : CommunityList,
facilityName: search2.facilityName ? search2.facilityName : null, facilityName: search2.facilityName ? search2.facilityName : null,
...@@ -260,6 +260,7 @@ const FacilityBookings = (props: any) => { ...@@ -260,6 +260,7 @@ const FacilityBookings = (props: any) => {
// 切换tab // 切换tab
function TabCallback(tab: any) { function TabCallback(tab: any) {
// console.log(search2);
TB(tab); TB(tab);
if (tab == 1) { if (tab == 1) {
// 搜索t // 搜索t
...@@ -275,7 +276,7 @@ const FacilityBookings = (props: any) => { ...@@ -275,7 +276,7 @@ const FacilityBookings = (props: any) => {
} else { } else {
// 储存的值 // 储存的值
let obj = { let obj = {
communityNameList: search2.communityNameList ? search2.communityNameList : CommunityList, communityNameList: search2.communityNameList,
pageNum: search2.pageNum, pageNum: search2.pageNum,
userToken: token, userToken: token,
}; };
...@@ -297,7 +298,7 @@ const FacilityBookings = (props: any) => { ...@@ -297,7 +298,7 @@ const FacilityBookings = (props: any) => {
requse(obj, tab); requse(obj, tab);
} else { } else {
let obj = { let obj = {
communityNameList: search2.communityNameList ? search2.communityNameList : CommunityList, communityNameList: search2.communityNameList,
pageNum: current, pageNum: current,
userToken: token, userToken: token,
}; };
...@@ -307,9 +308,11 @@ const FacilityBookings = (props: any) => { ...@@ -307,9 +308,11 @@ const FacilityBookings = (props: any) => {
// 储存并发起请求 // 储存并发起请求
const requse = (v: any, tab: any) => { const requse = (v: any, tab: any) => {
// console.log(v.communityNameList);
// console.log('发起');
if (tab == 1) { if (tab == 1) {
let obj = { let obj = {
communityNameList: v.communityNameList ? v.communityNameList : null, communityNameList: v.communityNameList ? v.communityNameList : CommunityList,
userToken: token, userToken: token,
pageNum: v.pageNum ? v.pageNum : '1', pageNum: v.pageNum ? v.pageNum : '1',
subscribeDate: v.subscribeDate !== null ? v.subscribeDate : null, subscribeDate: v.subscribeDate !== null ? v.subscribeDate : null,
...@@ -323,7 +326,7 @@ const FacilityBookings = (props: any) => { ...@@ -323,7 +326,7 @@ const FacilityBookings = (props: any) => {
// 储存的 // 储存的
// 搜索的 // 搜索的
let obj = { let obj = {
communityNameList: v.communityNameList ? v.communityNameList : null, communityNameList: v.communityNameList ? v.communityNameList : CommunityList,
facilityName: v.facilityName ? v.facilityName : null, facilityName: v.facilityName ? v.facilityName : null,
pageNum: v.curPage ? v.curPage : '1', pageNum: v.curPage ? v.curPage : '1',
}; };
......
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