feat: 城市选择器

perf/export-docx
Lei OT 1 year ago
parent 2d9e577859
commit 93572e6594

@ -0,0 +1,29 @@
import { createContext, useEffect, useState } from 'react';
import {} from 'antd';
import SearchInput from './SearchInput';
import { fetchJSON } from '@/utils/request';
import { HT_HOST } from '@/config';
import { useTranslation } from 'react-i18next';
//
export const fetchCityList = async (q) => {
const { errcode, result } = await fetchJSON(`${HT_HOST}/Service_BaseInfoWeb/search_cities`, { q });
return errcode !== 0 ? [] : result;
};
const CitySelector = ({ ...props }) => {
const { t } = useTranslation();
return (
<>
<SearchInput
placeholder={t('products:City')}
mode={null}
maxTagCount={0}
{...props}
fetchOptions={fetchCityList}
map={{ city_name: 'label', city_id: 'value' }}
/>
</>
);
};
export default CitySelector;

@ -10,6 +10,7 @@ import SearchInput from './SearchInput';
import AuditStateSelector from './AuditStateSelector';
import DeptSelector from './DeptSelector';
import ProductsTypesSelector, { fetchVendorList } from './ProductsTypesSelector';
import CitySelector from '@/components/CitySelector';
const { RangePicker } = DatePicker;
@ -65,6 +66,12 @@ const SearchForm = ({ initialValue, onSubmit, onReset, confirmText, formName, fo
return Array.isArray(value) ? value.map((ele) => ele.key).join(',') : value ? value.value : '';
},
},
'city': {
key: 'city',
transform: (value) => {
return Array.isArray(value) ? value.map((ele) => ele.key).join(',') : value ? value.value : '';
},
},
'unconfirmed': { key: 'unconfirmed', transform: (value) => value ? 1 : 0 },
};
let dest = {};
@ -276,6 +283,14 @@ function getFields(props) {
</Form.Item>,
fieldProps?.dept?.col || 6
),
item(
'city',
99,
<Form.Item name={`city`} label={t('products:City')} {...fieldProps.city} initialValue={at(props, 'initialValue.city')[0] || undefined}>
<CitySelector {...fieldComProps.city} />
</Form.Item>,
fieldProps?.city?.col || 4
),
item(
'unconfirmed',
99,

@ -71,7 +71,7 @@ const NewAddonModal = ({ onPick, ...props }) => {
<Modal width={'95%'} style={{ top: 20 }} open={open} title={'添加附加'} footer={false} onCancel={() => setOpen(false)} destroyOnClose>
<SearchForm
fieldsConfig={{
shows: [ 'year', 'keyword', 'products_types'], // 'dates',
shows: [ 'year', 'keyword', 'products_types', 'city'], // 'dates',
fieldProps: {
dates: { label: t('products:CreateDate') },
keyword: { label: t('products:Title'), col: 4 },
@ -91,6 +91,7 @@ const NewAddonModal = ({ onPick, ...props }) => {
<Table
size={'small'}
key={'searchProductsTable'}
rowKey={'id'}
loading={searchLoading}
dataSource={searchResult}
columns={searchResultColumns}

Loading…
Cancel
Save