andrew 4 years ago
parent
commit
526c4615f8

+ 32
- 0
estateagents-admin-manager/src/components/CustomUpload/index.jsx View File

@@ -0,0 +1,32 @@
1
+import React, { PureComponent } from 'react'
2
+import { Upload, Spin } from 'antd';
3
+import { uploaderProps } from '@/utils/upload'
4
+
5
+export default class extends PureComponent {
6
+  state = {
7
+    loading: false,
8
+  }
9
+  
10
+  handleChange = ({ file, fileList }) => {
11
+    const { status, response } = file
12
+    this.setState({ fileList, loading: status === "uploading" })
13
+
14
+    if (typeof this.props.onChange === 'function' && status != "uploading") {
15
+      const image = status === 'done' ? response : undefined
16
+      this.props.onChange(image);
17
+    }
18
+  };
19
+
20
+  render() {
21
+    return (
22
+      <Upload
23
+        {...uploaderProps}
24
+        onChange={this.handleChange}
25
+      >
26
+        <Spin spinning={this.state.loading}>
27
+          {this.props.children}
28
+        </Spin>
29
+      </Upload>
30
+    )
31
+  }
32
+}

+ 46
- 0
estateagents-admin-manager/src/components/DragableUploadImageList/Item.jsx View File

@@ -0,0 +1,46 @@
1
+import React from 'react'
2
+import { Icon } from 'antd'
3
+
4
+export default (props) => {
5
+    const { dataset = {}, onPreview, onDelete, onClick, onSticky } = props
6
+    const { url } = dataset
7
+
8
+    const handlePreview = () => {
9
+        onPreview && onPreview(dataset)
10
+    }
11
+
12
+    const handleDelete = () => {
13
+        onDelete && onDelete(dataset)
14
+    }
15
+
16
+    const handleClick = () => {
17
+        return onClick ? onClick(dataset) : null
18
+    }
19
+
20
+    const handleSticky = () => {
21
+        onSticky && onSticky(dataset)
22
+    }
23
+
24
+    return (
25
+        <div className="ant-upload-list-picture-card-container">
26
+            <span>
27
+                <div className="ant-upload-list-item ant-upload-list-item-done ant-upload-list-item-list-type-picture-card">
28
+                    <div className="ant-upload-list-item-info">
29
+                        <span>
30
+                            <a className="ant-upload-list-item-thumbnail" href={url} target="_blank" rel="noopener noreferrer" onClick={handleClick}>
31
+                                <img className="ant-upload-list-item-image" src={url} alt="image" />
32
+                            </a>
33
+                        </span>
34
+                    </div>
35
+
36
+                    <span className="ant-upload-list-item-actions">
37
+                        <Icon type="vertical-align-top" className="anticon anticon-eye-o" onClick={handleSticky} />
38
+                        <Icon type="eye" className="anticon anticon-eye-o" onClick={handlePreview} />
39
+                        <Icon type="delete" onClick={handleDelete} />
40
+                    </span>
41
+                </div>
42
+            </span>
43
+        </div>
44
+    )
45
+}
46
+

+ 115
- 0
estateagents-admin-manager/src/components/DragableUploadImageList/index.jsx View File

@@ -0,0 +1,115 @@
1
+import React from 'react';
2
+import { Upload, Icon, Modal } from 'antd';
3
+import './style.less';
4
+import { uploaderProps } from '../../utils/upload';
5
+import Item from './Item'
6
+
7
+/**
8
+ * unlimited  属性表示上传图片无限制
9
+ * 例子: <ImageListUpload unlimited/>
10
+ */
11
+class ImageListUpload extends React.Component {
12
+  state = {
13
+    previewVisible: false,
14
+    previewImage: '',
15
+    loadding: false,
16
+  };
17
+
18
+  getFileList = () => {
19
+    return (this.props.value || []).map((img, inx) => ({ uid: inx, url: img, status: 'done' }))
20
+  }
21
+
22
+  handleCancel = () => this.setState({ previewVisible: false });
23
+
24
+  handlePreview = async file => {
25
+    this.setState({
26
+      previewImage: file.url ,
27
+      previewVisible: true,
28
+    });
29
+  };
30
+
31
+  handleSticky = ({ url }) => {
32
+    const fileList = this.props.value || [];
33
+    this.props.onChange([url].concat(fileList.filter(x => x != url)))
34
+  }
35
+
36
+  handleDelete = ({ url }) => {
37
+    const fileList = this.props.value || [];
38
+    this.props.onChange(fileList.filter(x => x != url))
39
+  }
40
+
41
+  handleChange = (e) => {
42
+    if (e.file.status === "uploading") {
43
+      this.setState({ loading: true });
44
+      return;
45
+    }
46
+
47
+    const fileList = (this.props.value || []).filter(x => x != e.file.url);
48
+    this.props.onChange(fileList);
49
+
50
+    // console.log('删除图片触发了', e.file)
51
+    // if (e.file.state === 'removed') {
52
+    //   const fileList = (this.props.value || []).filter(x => x != e.file.url);
53
+    //   this.props.onChange(fileList);
54
+    // }
55
+
56
+    // if (e.file.status === "done") {
57
+    //   this.setState({
58
+    //     loading: false,
59
+    //   })
60
+
61
+    //   if (e.file.response && e.file.response.url) {
62
+    //     if (typeof this.props.onChange === 'function') {
63
+    //       const fileList = this.getFileList()
64
+    //       this.props.onChange([...fileList || [], e.file.response.url]);
65
+    //     }
66
+    //   }
67
+    // }
68
+  };
69
+
70
+  handleUploadSucess = (url) => {
71
+    this.setState({ loading: false });
72
+    if (typeof this.props.onChange === 'function') {
73
+      const fileList = this.props.value || [];
74
+      this.props.onChange([...fileList, url]);
75
+    }
76
+  }
77
+
78
+  render() {
79
+    const { previewVisible, previewImage } = this.state;
80
+    const { multiple = false } = this.props;
81
+    const fileList = this.getFileList();
82
+
83
+    const uploadButton = (
84
+      <div>
85
+        <Icon style={{ fontSize: '2em', color: '#aaa' }} type={this.state.loading ? "loading" : "plus"}  />
86
+      </div>
87
+    );
88
+    return (
89
+      <div className="clearfix x-dargable-image-upload-list">
90
+        <div className="ant-upload-list ant-upload-list-picture-card">
91
+            {fileList.map(img => <Item key={img.url} dataset={img} onPreview={this.handlePreview} onSticky={this.handleSticky} onDelete={this.handleDelete}/>)}
92
+        </div>
93
+          
94
+        <Upload
95
+          listType="picture-card"
96
+          showUploadList={false}
97
+          multiple={multiple}
98
+          onPreview={this.handlePreview}
99
+          onChange={this.handleChange}
100
+          { ...uploaderProps }
101
+          onSuccess={this.handleUploadSucess}
102
+        >
103
+        
104
+          {/* unlimited 表示上传无限制数量 */}
105
+          {(this.props.unlimited && uploadButton) || ((fileList || images).length >= 8 ? null : uploadButton)}
106
+        </Upload>
107
+        <Modal visible={previewVisible} footer={null} onCancel={this.handleCancel}>
108
+          <img alt="example" style={{ width: '100%' }} src={previewImage} />
109
+        </Modal>
110
+      </div>
111
+    );
112
+  }
113
+}
114
+
115
+export default ImageListUpload;

+ 23
- 0
estateagents-admin-manager/src/components/DragableUploadImageList/style.less View File

@@ -0,0 +1,23 @@
1
+:global {
2
+  .x-dargable-image-upload-list {
3
+    display: flex;
4
+  }
5
+
6
+  
7
+  .x-dargable-image-upload-list  .ant-upload-picture-card-wrapper {
8
+    width: auto !important;
9
+  }
10
+
11
+}
12
+
13
+
14
+/* you can make up upload button and sample style by using stylesheets */
15
+.ant-upload-select-picture-card i {
16
+  font-size: 32px;
17
+  color: #999;
18
+}
19
+
20
+.ant-upload-select-picture-card .ant-upload-text {
21
+  margin-top: 8px;
22
+  color: #666;
23
+}

+ 64
- 0
estateagents-admin-manager/src/components/EchartsTest/EChart.jsx View File

@@ -0,0 +1,64 @@
1
+import React, { Component } from 'react';
2
+
3
+// 引入 ECharts 主模块
4
+import echarts from 'echarts/lib/echarts';
5
+// 引入柱状图
6
+import 'echarts/lib/chart/bar';
7
+import 'echarts/lib/chart/pie';
8
+import 'echarts/lib/chart/scatter';
9
+import 'echarts/lib/chart/effectScatter';
10
+import 'echarts/lib/chart/map';
11
+// 引入提示框和标题组件
12
+import 'echarts/lib/component/tooltip';
13
+import 'echarts/lib/component/legend';
14
+import 'echarts/lib/component/title';
15
+import 'echarts/lib/chart/line';
16
+import 'echarts/lib/component/dataZoom';
17
+import 'echarts/lib/component/geo';
18
+import 'echarts/lib/component/visualMap';
19
+
20
+import { ChinaData } from './china';
21
+
22
+echarts.registerMap('china', ChinaData);
23
+
24
+class EchartsTest extends Component {
25
+    chartRef = React.createRef();
26
+    chart = undefined
27
+    defaultChartOption = {}
28
+
29
+    componentDidMount () {
30
+        this.chart = echarts.init(this.chartRef.current)
31
+
32
+        // 绘制图表
33
+        this.chart.setOption({
34
+            ...this.defaultChartOption,
35
+            ...this.props.options || {},
36
+        });
37
+    }
38
+
39
+    componentDidUpdate (preProps) {
40
+        if (preProps.options != this.props.options) {
41
+            const options = {
42
+                ...this.defaultChartOption,
43
+                ...this.props.options || {},
44
+            }
45
+
46
+
47
+            this.chart.setOption(options);
48
+        }
49
+    }
50
+
51
+    render () {
52
+        const style = {
53
+            width: '600px',
54
+            height: '400px',
55
+            ...this.props.style || {}
56
+        }
57
+
58
+        return (
59
+            <div onClick={this.props.onClick} ref={this.chartRef} style={style}></div>
60
+        );
61
+    }
62
+}
63
+
64
+export default EchartsTest;

+ 37
- 0
estateagents-admin-manager/src/components/EchartsTest/Line.jsx View File

@@ -0,0 +1,37 @@
1
+import React, { useEffect } from 'react';
2
+import EChart from './EChart';
3
+
4
+
5
+const Line = (props) => {
6
+
7
+  const {person_realty_consultant, person_estate_agent, person_null} = xxx
8
+
9
+  const options = {
10
+    xAxis: {},
11
+    legend: {
12
+      left: '70%',
13
+      data: ['来源置业顾问', '来源全民经纪人', '自主进入'],
14
+    },
15
+    series: [
16
+      {
17
+        type: 'pie',
18
+        datasetIndex: 1,
19
+        center: ['75%', '50%'],
20
+        radius: [0, '50%'],
21
+      },
22
+    ],
23
+    dataset: {
24
+      id: 'pie',
25
+      source: [
26
+        { form: '来源置业顾问', value: person_realty_consultant },
27
+        { form: '来源全民经纪人', value: person_estate_agent },
28
+        { form: '自主进入', value: person_null },
29
+      ]
30
+    },
31
+  }
32
+
33
+  return (
34
+    <EChart options={options} />
35
+  )
36
+
37
+}

+ 1
- 0
estateagents-admin-manager/src/components/EchartsTest/china.js
File diff suppressed because it is too large
View File


+ 19
- 0
estateagents-admin-manager/src/components/EchartsTest/index.jsx View File

@@ -0,0 +1,19 @@
1
+import React, { Component } from 'react';
2
+
3
+// 引入 ECharts 主模块
4
+import echarts from 'echarts/lib/echarts';
5
+// 引入柱状图
6
+import 'echarts/lib/chart/bar';
7
+// 引入提示框和标题组件
8
+import 'echarts/lib/component/tooltip';
9
+import 'echarts/lib/component/title';
10
+import 'echarts/lib/chart/line'
11
+
12
+class Chart extends Component {
13
+
14
+  render() {
15
+    return (<div></div>);
16
+  }
17
+}
18
+
19
+export default Chart;