Commit 87e05d8b authored by 成旭东's avatar 成旭东

fix

parent 55129154
Pipeline #28109 passed with stage
in 2 minutes 23 seconds
......@@ -15,6 +15,7 @@ export async function fetchEstateBase(query: any) {
export async function fetchEstateTag(query: any) {
return request(`/estate/tag/${query.type}`, {
params: query.data,
method: 'GET',
});
}
......
/* eslint-disable no-plusplus */
import { PageHeaderWrapper } from '@ant-design/pro-layout';
import React, { useEffect, useState } from 'react';
import React from 'react';
import { connect } from 'umi';
// import moment from 'moment';
import { Card, Tabs, message } from 'antd';
......@@ -12,46 +12,32 @@ import OfficeType from './views/officeType';
const { TabPane } = Tabs;
const TypeTagList: React.FC<any> = (props) => {
const [allTag, setAllTag] = useState([]);
// 获取全部标签
const getAllTag = () => {
const { dispatch } = props;
dispatch({
type: `estateTagList/fetchEstateTagAll`,
callback: (ret: any) => {
if (ret.error) {
message.error(ret.error);
} else {
setAllTag(ret)
}
}
});
};
useEffect(() => {
getAllTag();
}, []);
const saveCurrentTag = (type: string, currentTag: any) => {
const saveCurrentTag = (type: string, dataSource: any, currentTag: any) => {
const typeMap = {
house: 'is_house',
business: 'is_business',
office: 'is_office',
house: 'in_house',
business: 'in_business',
office: 'in_office',
}
const orderMap = {
house: 'in_house_order',
business: 'in_business_order',
office: 'in_office_order',
}
const editeTag = [];
for (let i = 0; i < allTag.length; i++) {
const item: any = allTag[i];
for (let i = 0; i < dataSource.length; i++) {
const item: any = dataSource[i];
item[typeMap[type]] = 0;
item[orderMap[type]] = 0;
for (let j = 0; j < currentTag.length; j++) {
const key = currentTag[j];
if (item.id === key) {
item[orderMap[type]] = j;
item[typeMap[type]] = 1;
}
}
......@@ -65,7 +51,6 @@ const TypeTagList: React.FC<any> = (props) => {
type: `estateTagList/tagBatchUpdate`,
payload: {
data: editeTag,
type,
},
callback: (ret: any) => {
if (ret.error) {
......@@ -82,13 +67,13 @@ const TypeTagList: React.FC<any> = (props) => {
<Card bordered={false}>
<Tabs defaultActiveKey="1" type="card">
<TabPane tab="住宅业态列表" key="1">
<HouseType allTag={allTag} saveCurrentTag={saveCurrentTag} updateLoading={props.updateLoading} />
<HouseType saveCurrentTag={saveCurrentTag} updateLoading={props.updateLoading} />
</TabPane>
<TabPane tab="商业业态列表" key="2">
<BusinessType allTag={allTag} saveCurrentTag={saveCurrentTag} updateLoading={props.updateLoading} />
<BusinessType saveCurrentTag={saveCurrentTag} updateLoading={props.updateLoading} />
</TabPane>
<TabPane tab="办公业态列表" key="3">
<OfficeType allTag={allTag} saveCurrentTag={saveCurrentTag} updateLoading={props.updateLoading} />
<OfficeType saveCurrentTag={saveCurrentTag} updateLoading={props.updateLoading} />
</TabPane>
</Tabs>
</Card>
......
......@@ -3,9 +3,28 @@ import { connect } from 'umi';
import { message, Transfer, Button } from 'antd';
const BusinessTypeTag = (props: any) => {
const [currentDataSource, setcurrentDataSource] = useState([]);
const [currentTag, setCurrentTag] = useState([]);
// 获取住宅标签
// 获取商业标签
const getCurrentDataSource = (params = {}) => {
const { dispatch } = props;
dispatch({
type: `estateList/fetchEstateTag`,
payload: params,
callback: (ret: any) => {
if (ret.error) {
message.error(ret.error);
} else {
setcurrentDataSource(ret);
}
}
});
};
// 获取商业筛选标签
const getCurrentTag = (params = {}) => {
const { dispatch } = props;
......@@ -27,21 +46,30 @@ const BusinessTypeTag = (props: any) => {
type: 'business',
};
getCurrentTag(params);
getCurrentDataSource(params);
const tagParams = {
type: 'business',
data: {
in_business: 1,
},
}
getCurrentTag(tagParams);
}, []);
const handleChange = (nextTargetKeys: any) => {
setCurrentTag(nextTargetKeys)
};
const { allTag, dataLoading, saveCurrentTag, updateLoading } = props;
const { dataLoading, saveCurrentTag, updateLoading } = props;
return (
<>
{!dataLoading && (
<>
<Transfer
dataSource={allTag.map((item: any) => ({ ...item, key: item.id }))}
dataSource={currentDataSource.map((item: any) => ({ ...item, key: item.id }))}
titles={['其余标签', '当前标签']}
targetKeys={currentTag}
onChange={handleChange}
......@@ -49,7 +77,7 @@ const BusinessTypeTag = (props: any) => {
disabled={updateLoading}
style={{ marginTop: 16, marginBottom: 20 }}
/>
<Button style={{ width: '100%' }} type="primary" size="large" onClick={() => { saveCurrentTag('business', currentTag) }} loading={updateLoading}>保存</Button>
<Button style={{ width: '100%' }} type="primary" size="large" onClick={() => { saveCurrentTag('business', currentDataSource, currentTag) }} loading={updateLoading}>保存</Button>
</>
)}
</>
......
......@@ -4,9 +4,28 @@ import { connect } from 'umi';
import { message, Transfer, Button } from 'antd';
const HouseTypeTag = (props: any) => {
const [currentDataSource, setcurrentDataSource] = useState([]);
const [currentTag, setCurrentTag] = useState([]);
// 获取住宅标签
const getCurrentDataSource = (params = {}) => {
const { dispatch } = props;
dispatch({
type: `estateList/fetchEstateTag`,
payload: params,
callback: (ret: any) => {
if (ret.error) {
message.error(ret.error);
} else {
setcurrentDataSource(ret);
}
}
});
};
// 获取住宅筛选标签
const getCurrentTag = (params = {}) => {
const { dispatch } = props;
......@@ -28,21 +47,30 @@ const HouseTypeTag = (props: any) => {
type: 'house',
};
getCurrentTag(params);
getCurrentDataSource(params);
const tagParams = {
type: 'house',
data: {
in_house: 1,
},
}
getCurrentTag(tagParams);
}, []);
const handleChange = (nextTargetKeys: any) => {
setCurrentTag(nextTargetKeys)
};
const { allTag, dataLoading, saveCurrentTag, updateLoading } = props;
const { dataLoading, saveCurrentTag, updateLoading } = props;
return (
<>
{!dataLoading && (
<>
<Transfer
dataSource={allTag.map((item: any) => ({ ...item, key: item.id }))}
dataSource={currentDataSource.map((item: any) => ({ ...item, key: item.id }))}
titles={['其余标签', '当前标签']}
targetKeys={currentTag}
onChange={handleChange}
......@@ -50,7 +78,7 @@ const HouseTypeTag = (props: any) => {
disabled={updateLoading}
style={{ marginTop: 16, marginBottom: 20 }}
/>
<Button style={{ width: '100%' }} type="primary" size="large" onClick={() => { saveCurrentTag('house', currentTag) }} loading={updateLoading}>保存</Button>
<Button style={{ width: '100%' }} type="primary" size="large" onClick={() => { saveCurrentTag('house', currentDataSource, currentTag) }} loading={updateLoading}>保存</Button>
</>
)}
</>
......
......@@ -3,9 +3,28 @@ import { connect } from 'umi';
import { message, Transfer, Button } from 'antd';
const OfficeTypeTag = (props: any) => {
const [currentDataSource, setcurrentDataSource] = useState([]);
const [currentTag, setCurrentTag] = useState([]);
// 获取住宅标签
// 获取办公标签
const getCurrentDataSource = (params = {}) => {
const { dispatch } = props;
dispatch({
type: `estateList/fetchEstateTag`,
payload: params,
callback: (ret: any) => {
if (ret.error) {
message.error(ret.error);
} else {
setcurrentDataSource(ret);
}
}
});
};
// 获取办公筛选标签
const getCurrentTag = (params = {}) => {
const { dispatch } = props;
......@@ -27,21 +46,30 @@ const OfficeTypeTag = (props: any) => {
type: 'office',
};
getCurrentTag(params);
getCurrentDataSource(params);
const tagParams = {
type: 'office',
data: {
in_house: 1,
},
}
getCurrentTag(tagParams);
}, []);
const handleChange = (nextTargetKeys: any) => {
setCurrentTag(nextTargetKeys)
};
const { allTag, dataLoading, saveCurrentTag, updateLoading } = props;
const { dataLoading, saveCurrentTag, updateLoading } = props;
return (
<>
{!dataLoading && (
<>
<Transfer
dataSource={allTag.map((item: any) => ({ ...item, key: item.id }))}
dataSource={currentDataSource.map((item: any) => ({ ...item, key: item.id }))}
titles={['其余标签', '当前标签']}
targetKeys={currentTag}
onChange={handleChange}
......@@ -49,7 +77,7 @@ const OfficeTypeTag = (props: any) => {
disabled={updateLoading}
style={{ marginTop: 16, marginBottom: 20 }}
/>
<Button style={{ width: '100%' }} type="primary" size="large" onClick={() => { saveCurrentTag('office', currentTag) }} loading={updateLoading}>保存</Button>
<Button style={{ width: '100%' }} type="primary" size="large" onClick={() => { saveCurrentTag('office', currentDataSource, currentTag) }} loading={updateLoading}>保存</Button>
</>
)}
</>
......
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