Commit 9c278f8d authored by XieZhiXiong's avatar XieZhiXiong

feat: 添加 placeholder 属性

parent 2e3fd9b0
......@@ -38,10 +38,14 @@ interface AreaSelectItemProps {
* 自定义外部 className
*/
customClassName?: string,
/**
* placeholder
*/
placeholder?: string,
}
const AreaSelectItem: React.FC<AreaSelectItemProps> = (props) => {
const { pcode, value, onChange, customClassName } = props;
const { pcode, value, onChange, customClassName, placeholder } = props;
const [innerValue, setInnerValue] = useState<string | undefined>(undefined);
const [options, setOptions] = useState<OptionType[]>([]);
......@@ -97,6 +101,7 @@ const AreaSelectItem: React.FC<AreaSelectItemProps> = (props) => {
value={innerValue}
onChange={handleSelectChange}
loading={loading}
placeholder={placeholder}
allowClear
/>
);
......
......@@ -3,6 +3,7 @@
*/
import React, { useState, useEffect } from 'react';
import { Row, Col } from 'antd';
import { useIntl } from 'umi';
import themeConfig from '@/../config/lingxi.theme.config';
import AreaSelectItem, { AreaSelectValueType } from './AreaSelectItem';
import styles from './index.less';
......@@ -27,6 +28,8 @@ const AreaSelect: React.FC<AreaSelectProps> = (props) => {
} = props;
const [innerValues, setInnerValues] = useState<AreaSelectValueType[]>([]);
const intl = useIntl();
useEffect(() => {
if ('value' in props && value.length) {
setInnerValues(value);
......@@ -74,6 +77,7 @@ const AreaSelect: React.FC<AreaSelectProps> = (props) => {
customClassName={styles['area-select-item']}
value={innerValues[0]}
onChange={(value) => handleSelectChange(value, 0)}
placeholder={intl.formatMessage({id: 'components.shengfenzhixiashi'}, { default: '-省份/直辖市-' })}
/>
</Col>
<Col span={6}>
......@@ -82,6 +86,7 @@ const AreaSelect: React.FC<AreaSelectProps> = (props) => {
customClassName={styles['area-select-item']}
value={innerValues[1]}
onChange={(value) => handleSelectChange(value, 1)}
placeholder={intl.formatMessage({id: 'components.shi'}, { default: '-市-' })}
/>
</Col>
<Col span={6}>
......@@ -90,6 +95,7 @@ const AreaSelect: React.FC<AreaSelectProps> = (props) => {
customClassName={styles['area-select-item']}
value={innerValues[2]}
onChange={(value) => handleSelectChange(value, 2)}
placeholder={intl.formatMessage({id: 'components.qu'}, { default: '-区-' })}
/>
</Col>
<Col span={6}>
......@@ -98,6 +104,7 @@ const AreaSelect: React.FC<AreaSelectProps> = (props) => {
customClassName={styles['area-select-item']}
value={innerValues[3]}
onChange={(value) => handleSelectChange(value, 3)}
placeholder={intl.formatMessage({id: 'components.jiedao'}, { default: '-街道-' })}
/>
</Col>
</Row>
......
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