weiximei 5 anni fa
parent
commit
b6c4429d6c
1 ha cambiato i file con 84 aggiunte e 8 eliminazioni
  1. 84
    8
      src/pages/building/list/add/components/buildingImage.jsx

+ 84
- 8
src/pages/building/list/add/components/buildingImage.jsx Vedi File

@@ -1,36 +1,112 @@
1
-import React, { useState } from 'react';
1
+import React, { useState, useEffect } from 'react';
2 2
 import { Form, Icon, Input, Button, DatePicker, Select, Card, Row, Col, Pagination, Alert, Radio, Tag, Tooltip, Tabs, Table, notification, Modal, Layout } from 'antd';
3 3
 import ImageListUpload from '../../../../../components/XForm/ImageListUpload';
4 4
 
5 5
 const { Header, Footer, Sider, Content } = Layout;
6 6
 
7
-function BuildingImageModel() {
7
+/**
8
+ * 弹框
9
+ */
10
+function ModalEdi(props) {
11
+
12
+  const [visibleData, setVisibleData] = useState({ visible: false })
13
+
14
+  if (!props.visibleData) {
15
+    console.error('缺少visibleData参数!')
16
+  }
17
+
18
+  useEffect(() => {
19
+    setVisibleData(props.visibleData)
20
+  }, [props.visibleData.visible])
21
+
22
+  function handleOk(e) {
23
+    // console.log(e);
24
+    props.onCancel();
25
+  }
26
+
27
+  function handleCancel(e) {
28
+    // console.log(e);
29
+    props.onCancel();
30
+  }
31
+
32
+  return (
33
+    <>
34
+      <Modal
35
+          title="Basic Modal"
36
+          visible={visibleData.visible}
37
+          onOk={handleOk}
38
+          onCancel={handleCancel}
39
+        >
40
+          <p>Some contents...</p>
41
+          <p>Some contents...</p>
42
+          <p>Some contents...</p>
43
+        </Modal>
44
+    </>
45
+  )
46
+}
47
+
48
+/**
49
+ * 模块
50
+ */
51
+function BuildingImageModel(props) {
8 52
   const [imageList, setImageList] = useState([])
53
+  const [visibleData, setVisibleData] = useState({ visible: false })
9 54
 
10 55
   function onImageChange(e) {
11 56
     setImageList(e)
12 57
   }
13 58
 
59
+  function edi() {
60
+    setVisibleData({ visible: true })
61
+  }
62
+
63
+  function onCancel(e) {
64
+    setVisibleData({ visible: false })
65
+  }
66
+
67
+  function deletePhoto() {
68
+
69
+  }
70
+
14 71
   return (
15 72
     <>
16
-      <span>效果图(10)</span>
17
-      <Button type="link" style={{ color: 'blue' }}>重命名</Button>
18
-      <Button type="link" style={{ color: 'blue' }}>删除相册</Button>
73
+<span style={{ marginTop: '10px', marginBottom: '10px' }}>效果图({imageList.length})</span>
74
+      <Button type="link" style={{ color: 'blue' }} onClick={() => edi()}>重命名</Button>
75
+      <Button type="link" style={{ color: 'blue' }} onClick={() => deletePhoto()}>删除相册</Button>
19 76
       <ImageListUpload value={imageList} onChange={onImageChange} unlimited/>
77
+
78
+       {/* 编辑页 */}
79
+       <ModalEdi visibleData={visibleData} onCancel={e => onCancel(e)}/>
80
+       <hr />
20 81
     </>
21 82
   )
22 83
 }
23 84
 
24
-
85
+/**
86
+ * 主体
87
+ */
25 88
 function buildingImage() {
89
+  const [visibleData, setVisibleData] = useState({ visible: false })
90
+
91
+  function edi() {
92
+    setVisibleData({ visible: true })
93
+  }
94
+
95
+  function onCancel(e) {
96
+    setVisibleData({ visible: false })
97
+  }
98
+
26 99
   return (
27 100
     <>
28
-      <Button type="primary">新增</Button>
29
-      <Layout>
101
+      <Button type="primary" onClick={() => edi()}>新增</Button>
102
+      <Layout style={{ background: '#fff' }}>
30 103
         <Content><BuildingImageModel /></Content>
31 104
         <Content><BuildingImageModel /></Content>
32 105
         <Content><BuildingImageModel /></Content>
33 106
       </Layout>
107
+
108
+      {/* 编辑页 */}
109
+      <ModalEdi visibleData={visibleData} onCancel={e => onCancel(e)}/>
34 110
     </>
35 111
   )
36 112
 }