1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import React from 'react';
import PandaImageSelect from '../index';
import request from 'umi-request';
class Demo extends React.Component {
constructor(props) {
super(props);
this.state = {
dataSource: [],
};
}
onSelect = (value) => {
console.log(value, 'PandaImageSelect-value');
};
fetchData = (params = {}) => {
const _this = this;
request(baseUrl + '/Publish/OMS/FileCenter/GetImageOrderByPath', {
method: 'get',
params: {
path: 'assets/images/appMenu',
maxLength: 279.1525423728813,
fileName: params.fileName ? params.fileName : '',
},
}).then(function (response) {
_this.setState({
dataSource: response.data,
});
});
};
// 获取token
componentDidMount() {
this.fetchData();
}
render() {
return (
<PandaImageSelect
onSearch={(params) => this.fetchData(params)}
dataSource={this.state.dataSource}
onSelect={(value) => this.onSelect(value)}
url={imgUrl}
/>
);
}
}
export default Demo;
const imgUrl = 'http://192.168.10.150:8777';
const baseUrl = 'https://www.fastmock.site/mock/162c15dca15c4dba9ba51e0a0b76929b/api';