baozhangchao преди 3 години
родител
ревизия
b7a38e48e4
променени са 3 файла, в които са добавени 147 реда и са изтрити 67 реда
  1. 2
    2
      src/pages/staff/Organization/form.jsx
  2. 116
    64
      src/pages/staff/Organization/index.jsx
  3. 29
    1
      src/services/apis.js

+ 2
- 2
src/pages/staff/Organization/form.jsx Целия файл

180
         <Button type="primary" htmlType="submit" style={{ marginLeft: '80px', marginTop: '30px' }}>
180
         <Button type="primary" htmlType="submit" style={{ marginLeft: '80px', marginTop: '30px' }}>
181
           修改
181
           修改
182
         </Button>
182
         </Button>
183
-        <Button type="danger">
183
+        {/* <Button type="danger">
184
           删除
184
           删除
185
-        </Button>
185
+        </Button> */}
186
       </FormItem>
186
       </FormItem>
187
     </Form>
187
     </Form>
188
   )
188
   )

+ 116
- 64
src/pages/staff/Organization/index.jsx Целия файл

1
 
1
 
2
 import { Row, Col, Card, Tree, Form, TreeSelect, Input, InputNumber, Modal, Button, message } from 'antd'
2
 import { Row, Col, Card, Tree, Form, TreeSelect, Input, InputNumber, Modal, Button, message } from 'antd'
3
+import React, { useState, useEffect } from 'react';
4
+import request from '@/utils/request';
5
+import apis from '@/services/apis';
3
 import moment from 'moment';
6
 import moment from 'moment';
4
-// import React, { useEffect, useState, useCallback,useRef } from 'react';
5
 import TreedataFrom from './form';
7
 import TreedataFrom from './form';
6
-
7
 const { TreeNode, DirectoryTree } = Tree;
8
 const { TreeNode, DirectoryTree } = Tree;
8
 const FormItem = Form.Item;
9
 const FormItem = Form.Item;
9
-
10
-//-----------------------------------
11
-const onAdd = (key) => {
12
-  if (expandedKeys.indexOf(key) === -1) {
13
-    expandedKeyArr.push(key);
14
-  }
15
-  expandedKeys(expandedKeyArr.slice());
16
-  addNode(key, treeData);//添加节点 树形
17
-  setData(treeData.slice());//添加子项
18
-};
19
-//-----------------------------------
20
-const confirm = data => {
21
-  // {...data,isPublish}
22
-  if (data.key !== 0) {
23
-    Modal.confirm({
24
-      title: '确认删除吗?',
25
-      okText: '确认',
26
-      cancelText: '取消',
27
-      onOk() {
28
-        message.error('失败');
29
-
30
-      },
31
-    });
32
-  } else {
33
-    message.error('error')
34
-  }
35
-}
36
-
37
-
38
-// function uuid() {
39
-//   var s = [];
40
-//   var hexDigits = "0123456789";
41
-//   for (var i = 0; i < 18; i++) {
42
-//       s[i] = hexDigits.substr(Math.floor(Math.random() * 1*10), 1);
43
-//   }
44
-
45
-//   var uuid = s.join("");
46
-//   return uuid;
47
-// }
48
-// import moment from 'moment';
49
-
10
+const { Search } = Input;
50
 
11
 
51
 const treeData =
12
 const treeData =
52
   [
13
   [
53
     {
14
     {
54
-      title: '分厂厂长管理',
55
-      key: '0',
15
+      title: 'institutionId',
16
+      name: 'institutionName',
17
+      key: '0-0-0',
56
       selectable: false,
18
       selectable: false,
57
       children: [
19
       children: [
58
-        { title: '郎岩', phone: '15920583224', remark: "", day: "1992-11-13", cardId: '511502199103223189', sex: 1, id: '0212', belon: 1, homeaddres: 1, key: '0-0-0-1' },//这个不行么 你写错了 你那是v4的写法在哪?刚刚那个啊。对
20
+        { name: 'institutionName', phone: '13184013427', remark: "", day: "1991-11-22", cardId: '210203197503102721', sex: 2, id: '4242', belon: 2, homeaddres: 2, key: '0-0-0-1', },
59
         { title: '柯琼彦', phone: '13184013427', remark: "", day: "1991-11-22", cardId: '210203197503102721', sex: 2, id: '4242', belon: 2, homeaddres: 2, key: '0-0-0-2', },
21
         { title: '柯琼彦', phone: '13184013427', remark: "", day: "1991-11-22", cardId: '210203197503102721', sex: 2, id: '4242', belon: 2, homeaddres: 2, key: '0-0-0-2', },
60
       ],
22
       ],
61
     },
23
     },
74
 
36
 
75
 
37
 
76
 
38
 
77
-// const item = this.info.node.key 不是!!!!
39
+// const item = this.info.node.key 
78
 
40
 
79
 class TreeDemo extends React.Component {
41
 class TreeDemo extends React.Component {
80
   formRef = React.createRef();
42
   formRef = React.createRef();
81
 
43
 
82
-
83
   constructor(props) {
44
   constructor(props) {
84
     super(props)
45
     super(props)
85
     this.state = {
46
     this.state = {
86
       expandedKeys: ['0-0-0', '0-0-1'],
47
       expandedKeys: ['0-0-0', '0-0-1'],
87
       autoExpandParent: false,
48
       autoExpandParent: false,
88
       checkedKeys: ['0-0-0'],
49
       checkedKeys: ['0-0-0'],
50
+      searchValue: '',
89
       selectedKeys: [],
51
       selectedKeys: [],
90
       // treeTitle: [info.node.props],
52
       // treeTitle: [info.node.props],
91
       checked: true,
53
       checked: true,
92
-      treeData: treeData
54
+      treeData: [],
55
+      testarr: []
93
     };
56
     };
94
   }
57
   }
95
 
58
 
112
     console.log(valeu);
75
     console.log(valeu);
113
   };
76
   };
114
 
77
 
115
-
78
+  //修改
116
   onChangethis = (value) => {
79
   onChangethis = (value) => {
117
 
80
 
118
     const treeData = this.state.treeData
81
     const treeData = this.state.treeData
119
-
120
     let Data1 = this.state.treeData
82
     let Data1 = this.state.treeData
121
     for (var i = 0; i < treeData.length; i++) {
83
     for (var i = 0; i < treeData.length; i++) {
122
-
123
       for (var j = 0; j < treeData[i].children.length; j++) {
84
       for (var j = 0; j < treeData[i].children.length; j++) {
124
         // console.log(Data1[i].children[j].key);
85
         // console.log(Data1[i].children[j].key);
125
         // console.log("---------")
86
         // console.log("---------")
133
           break
94
           break
134
         }
95
         }
135
       }
96
       }
136
-
137
     }
97
     }
98
+    this.setState({
99
+      treeData1: Data1
100
+    }, () => {
101
+      message.success('修改成功!')
102
+    })
103
+
138
   }
104
   }
139
   //删除
105
   //删除
140
   onDelect = (value) => {
106
   onDelect = (value) => {
173
         key: info.node.props.eventKey,//event
139
         key: info.node.props.eventKey,//event
174
         day: moment(info.node.props.day)
140
         day: moment(info.node.props.day)
175
       })
141
       })
176
-
177
-      console.log(values, info)
142
+      console.log(this.getTreeData)
178
 
143
 
179
       // moment(info.node.props.day).format('YYYY-MM-DD')
144
       // moment(info.node.props.day).format('YYYY-MM-DD')
180
     })
145
     })
182
 
147
 
183
 
148
 
184
 
149
 
150
+  // getTreeData = (e) => {
151
+  //   request({
152
+  //     url: "http://localhost:8000/api/admin/institution/list",
153
+  //     method: 'GET',
154
+
155
+  //     // params: {leveltype: 3, cityId},
156
+  //     action: "admin.institution.get",
157
+  //   }).then((treeData) => {
158
+  //     setData(treeData)
159
+  //     console.log(this.getTreeData)
160
+  //   })
161
+  // }
162
+
163
+
164
+
165
+
166
+
167
+
168
+  async institutionTree(params) {
169
+    let arr = []
170
+
171
+    return request('/api/admin/institution/list', {
172
+      method: 'GET',
173
+      data: params,
174
+    }).then((testarr2) => {
175
+      this.setState({ testarr: testarr2 }, () => {
176
+        console.log("testarr2")
177
+        console.log(this.state.testarr)
178
+        // title: 'institutionId',
179
+        // name: 'institutionName',
180
+        // key: '0-0-0',
181
+        const arr2 = this.state.testarr
182
+        for (var i = 0; i < this.state.testarr.length; i++) {
183
+          let list = {
184
+            title: 'institutionId',
185
+            name: 'institutionName',
186
+            key: '0-0-0'
187
+          }
188
+          list.title = arr2[i].institutionName
189
+          list.key = '0' + i.toString
190
+          arr.push(list)
191
+
192
+        }
193
+
194
+        this.setState({
195
+          treeData: arr
196
+        })
197
+
198
+      })
199
+      // console.log(this.getTreeData)
200
+    })
201
+  }
202
+
203
+  componentDidMount() {
204
+    // fetch(`http://localhost:8000/api/admin/institution/list`, {
205
+    //   headers: {
206
+    //     Authorization: "Bearer eyJhbGciOiJIUzI1NiJ9.eyJ1c2VySWQiOiIxIiwib3JnSWQiOiIxIiwiZXhwIjoxNjI3MDQ1MjQxfQ.7FhVDoI0dEECZinRUzMzcLl-kcobkamZSqoUzTxBTRo"
207
+    //   }
208
+    // }).then((res) => {
209
+    //   console.log(res)
210
+    // }),
211
+    // this.institutionTree()
212
+    this.institutionTree([])
213
+
214
+  }
215
+
216
+
217
+
218
+
219
+
220
+
185
 
221
 
186
   renderTreeNodes = data =>
222
   renderTreeNodes = data =>
187
     data.map(item => {
223
     data.map(item => {
194
       }
230
       }
195
       return <TreeNode key={item.key} {...item} />;
231
       return <TreeNode key={item.key} {...item} />;
196
     });
232
     });
233
+  //搜索框 
234
+  // onChange = e => {
235
+  //   const { value } = e.target;
236
+  //   const expandedKeys = treeData
237
+  //     .map(item => {
238
+  //       if (item.title.indexOf(value) > -1) {
239
+  //         return getParentKey(item.key, gData);
240
+  //       }
241
+  //       return null;
242
+  //     })
243
+  //     .filter((item, i, self) => item && self.indexOf(item) === i);
244
+  //   this.setState({
245
+  //     expandedKeys,
246
+  //     searchValue: value,
247
+  //     autoExpandParent: true,
248
+  //   });
249
+  // };
197
 
250
 
198
 
251
 
199
 
252
 
200
-  render() {
201
 
253
 
254
+  render() {
255
+    const { searchValue } = this.state;
202
     return (
256
     return (
203
       <Card>
257
       <Card>
204
         <Row >
258
         <Row >
207
               <FormItem
261
               <FormItem
208
                 label="管辖部门"
262
                 label="管辖部门"
209
               >
263
               >
210
-                <Button type="primary" onClick={onAdd} >
211
-                  增加
212
-                </Button>
213
-
264
+                {/* <Search style={{ marginBottom: 8 }} placeholder="Search" onChange={this.onChange} /> */}
214
                 <Tree
265
                 <Tree
215
-
266
+                  // api={apis.Institution.instIist}
216
                   showLine
267
                   showLine
217
-                  // switcherIcon={<DownOutlined />}
218
-                  defaultExpandedKeys={['0-0-0']}
268
+                  defaultExpandedKeys={['0-0']}
219
                   onSelect={this.onSelect}
269
                   onSelect={this.onSelect}
220
                   treeData={this.state.treeData}
270
                   treeData={this.state.treeData}
271
+                // api={apis.Institution.instIist} 
221
                 >
272
                 >
222
                   {this.renderTreeNodes(this.state.treeData)}
273
                   {this.renderTreeNodes(this.state.treeData)}
223
                   {/* 动态渲染 */}
274
                   {/* 动态渲染 */}
224
                 </Tree >
275
                 </Tree >
225
-                {/* 不加入生命周期不会有更改a */}
226
               </FormItem>
276
               </FormItem>
227
             </Card>
277
             </Card>
228
           </Col>
278
           </Col>
233
                 triggerRef={this.bindRef}
283
                 triggerRef={this.bindRef}
234
                 onChangethis={this.onChangethis}
284
                 onChangethis={this.onChangethis}
235
                 onSubmit={this.onChangethis}
285
                 onSubmit={this.onChangethis}
286
+
287
+
236
               />
288
               />
237
             </Card>
289
             </Card>
238
           </Col>
290
           </Col>

+ 29
- 1
src/services/apis.js Целия файл

196
       method: 'GET',
196
       method: 'GET',
197
       action: 'admin.building.marketing,get',
197
       action: 'admin.building.marketing,get',
198
     },
198
     },
199
- 
199
+
200
     // GET /api/admin/trend/{id}
200
     // GET /api/admin/trend/{id}
201
   },
201
   },
202
   buildingType: {
202
   buildingType: {
1076
       action: 'admin.channel.introductionList.personNumListExport.get',
1076
       action: 'admin.channel.introductionList.personNumListExport.get',
1077
     },
1077
     },
1078
   },
1078
   },
1079
+  //组织架构
1080
+  Institution: {
1081
+    instIist: {
1082
+      url: `${prefix}/institution/list`,
1083
+      method: 'GET',
1084
+      action: 'admin.institution.get'
1085
+    },
1086
+    instSave: {
1087
+      url: `${prefix}/institution/save`,
1088
+      method: 'POST',
1089
+      action: 'admin.institution.post'
1090
+    },
1091
+    instiDelete: {
1092
+      url: `${prefix}/institution/:id`,
1093
+      method: 'DELETE',
1094
+      action: 'admin.institution.id.delete',
1095
+    },
1096
+    instiSearch: {
1097
+      url: `${prefix}/institution/:id`,
1098
+      method: 'GET',
1099
+      action: 'admin.institution.id.get',
1100
+    },
1101
+    instiAlert: {
1102
+      url: `${prefix}/institution/:id`,
1103
+      method: 'PUT',
1104
+      action: 'admin.institution.id.put',
1105
+    }
1106
+  },
1079
   role: {
1107
   role: {
1080
     getRoleList: {
1108
     getRoleList: {
1081
       url: `${prefix}/taRole`,
1109
       url: `${prefix}/taRole`,