Commit 1308c934 by 姜雷

修改派车为多选

parent aca4100d
...@@ -128,7 +128,7 @@ class PublicCarItem extends Component { ...@@ -128,7 +128,7 @@ class PublicCarItem extends Component {
}`} }`}
> >
<div className={styles.listLabel}>派车车牌:</div> <div className={styles.listLabel}>派车车牌:</div>
<div className={styles.listValue}> <div className={styles.listValueMutLine}>
{data.dealResult === 1 {data.dealResult === 1
? '待处理后显示' ? '待处理后显示'
: data.carPlate : data.carPlate
......
...@@ -13,13 +13,12 @@ class Select extends Component { ...@@ -13,13 +13,12 @@ class Select extends Component {
componentWillMount() { componentWillMount() {
console.log(this.props.children); console.log(this.props.children);
if (this.props.children.length) { if (this.props.children.length) {
this.props.onChange(this.props.children[0].props.value); this.props.onChange([this.props.children[0].props.value]);
} }
} }
toggleOptions = () => { toggleOptions = () => {
console.log('in click'); console.log('in click');
this.setState(({ showOptions }) => ({ this.setState(({ showOptions }) => ({
showOptions: !showOptions, showOptions: !showOptions,
})); }));
...@@ -28,10 +27,15 @@ class Select extends Component { ...@@ -28,10 +27,15 @@ class Select extends Component {
e.preventDefault(); e.preventDefault();
e.stopPropagation(); e.stopPropagation();
console.log(val); console.log(val);
this.setState({ // this.setState({
showOptions: false, // showOptions: false,
}); // });
this.props.onChange(val); const { value } = this.props;
if (value.indexOf(val) !== -1) {
this.props.onChange(value.filter(i => i !== val));
} else {
this.props.onChange([...value, val]);
}
}; };
render() { render() {
const { showOptions } = this.state; const { showOptions } = this.state;
...@@ -39,10 +43,23 @@ class Select extends Component { ...@@ -39,10 +43,23 @@ class Select extends Component {
return ( return (
<div className={styles.selectWrap} onClick={this.toggleOptions}> <div className={styles.selectWrap} onClick={this.toggleOptions}>
<div className={styles.selectValue}> <div className={styles.selectValue}>
<div className={styles.selectOption}>{value}</div> <div className={styles.selectValueOption}>{value.join(',')}</div>
{showOptions && ( {showOptions && (
<div className={styles.selectOptionsBox}> <div className={styles.selectOptionsBox}>
{this.props.children.map((i, idx) => ( {this.props.children.map(
(i, idx) =>
value.indexOf(i.props.value) !== -1 ? (
<div
className={styles.selectOptionChecked}
key={idx}
onClick={e => this.selectHandle(e, i.props.value)}
>
{i}
<div className={styles.selected}>
<div className={styles.selectedInner} />
</div>
</div>
) : (
<div <div
className={styles.selectOption} className={styles.selectOption}
key={idx} key={idx}
...@@ -50,7 +67,8 @@ class Select extends Component { ...@@ -50,7 +67,8 @@ class Select extends Component {
> >
{i} {i}
</div> </div>
))} )
)}
</div> </div>
)} )}
</div> </div>
......
...@@ -39,7 +39,7 @@ class PublicCarDeal extends Component { ...@@ -39,7 +39,7 @@ class PublicCarDeal extends Component {
selected: { selected: {
id: '', id: '',
value: '', value: '',
carPlate: '', carPlate: [],
dealOpinion: '', dealOpinion: '',
}, },
carPlateList: [], carPlateList: [],
...@@ -129,7 +129,7 @@ class PublicCarDeal extends Component { ...@@ -129,7 +129,7 @@ class PublicCarDeal extends Component {
selected: { selected: {
id: '', id: '',
value: '', value: '',
carPlate: '', carPlate: [],
dealOpinion: '', dealOpinion: '',
}, },
})); }));
...@@ -151,7 +151,7 @@ class PublicCarDeal extends Component { ...@@ -151,7 +151,7 @@ class PublicCarDeal extends Component {
return false; return false;
} }
if (value === 2) { if (value === 2) {
if (carPlate === '-1') { if (carPlate.length === 0) {
Toast.fail('请选择派车!'); Toast.fail('请选择派车!');
return false; return false;
} }
...@@ -172,7 +172,7 @@ class PublicCarDeal extends Component { ...@@ -172,7 +172,7 @@ class PublicCarDeal extends Component {
id: id, id: id,
dealName: userinfo.name, dealName: userinfo.name,
dealResult: value, dealResult: value,
carPlate: carPlate, carPlate: carPlate.join(','),
} }
: { : {
id: id, id: id,
...@@ -193,6 +193,8 @@ class PublicCarDeal extends Component { ...@@ -193,6 +193,8 @@ class PublicCarDeal extends Component {
}); });
}; };
onSelectHandle = val => { onSelectHandle = val => {
console.log(val);
this.setState(({ selected }) => ({ this.setState(({ selected }) => ({
selected: { selected: {
...selected, ...selected,
......
...@@ -58,14 +58,16 @@ ...@@ -58,14 +58,16 @@
height: 100%; height: 100%;
line-height: 60px; line-height: 60px;
border-radius: 8px; border-radius: 8px;
display: flex;
} }
.selectValue { .selectValue {
padding-left: 26px; padding-left: 26px;
flex: 1;
background-color: #f2f2f2; background-color: #f2f2f2;
margin-right: 46px;
} }
.selectIcon { .selectIcon {
position: absolute;
right: 0;
top: 0;
width: 46px; width: 46px;
height: 60px; height: 60px;
} }
...@@ -79,6 +81,27 @@ ...@@ -79,6 +81,27 @@
height: 60px; height: 60px;
border-bottom: 1px solid #fff; border-bottom: 1px solid #fff;
} }
.selectValueOption {
composes: selectOption;
white-space: nowrap;
width: 100%;
text-overflow: ellipsis;
overflow: hidden;
}
.selectOptionChecked {
composes: selectOption;
position: relative;
}
.selected {
position: absolute;
right: 10px;
top: 20px;
width: 20px;
height: 10px;
border-left: 1px solid #666;
border-bottom: 1px solid #666;
transform: rotate(-45deg);
}
.select { .select {
border: none; border: none;
appearance: none; appearance: none;
......
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