瀏覽代碼

Merge branch 'master' of http://git.ycjcjy.com/marketing/pc-admin into master

zlisen 3 年之前
父節點
當前提交
079b4e09ed
共有 31 個文件被更改,包括 1324 次插入1006 次删除
  1. 1
    1
      config/proxy.js
  2. 1
    0
      package.json
  3. 10
    6
      src/models/user.js
  4. 1
    1
      src/pages/building/Developers/tableColumns.js
  5. 0
    0
      src/pages/building/Edit/Basic.jsx
  6. 31
    0
      src/pages/building/Edit/Basic/form.js
  7. 0
    53
      src/pages/building/Edit/Basic/getData.js
  8. 315
    297
      src/pages/building/Edit/Basic/index.jsx
  9. 0
    116
      src/pages/building/Edit/Basic/tag.js
  10. 48
    0
      src/pages/building/Edit/Basic/useArrounds.js
  11. 40
    0
      src/pages/building/Edit/Basic/usePois.js
  12. 40
    0
      src/pages/building/Edit/Basic/useQuery.js
  13. 11
    5
      src/pages/building/Edit/components/Amap/index.jsx
  14. 6
    2
      src/pages/building/Edit/components/BuildingTypeDetail.jsx
  15. 3
    4
      src/pages/building/Edit/components/BuildingTypeSelect.jsx
  16. 0
    26
      src/pages/building/Edit/components/EditableArround/MapPois.jsx
  17. 0
    41
      src/pages/building/Edit/components/EditableArround/hooks/usePoi.js
  18. 0
    43
      src/pages/building/Edit/components/EditableArround/hooks/useTag.js
  19. 0
    17
      src/pages/building/Edit/components/EditableArround/hooks/useValue.js
  20. 8
    9
      src/pages/building/Edit/components/EditableArround/index.jsx
  21. 0
    35
      src/pages/building/Edit/components/EditableArround/utils.js
  22. 9
    9
      src/pages/building/Edit/index.jsx
  23. 8
    8
      src/pages/home/Recommend/auditCopy.jsx
  24. 95
    101
      src/pages/home/Recommend/index.jsx
  25. 79
    0
      src/pages/staff/Organization/TreeTitle.jsx
  26. 4
    0
      src/pages/staff/Organization/form.jsx
  27. 494
    132
      src/pages/staff/Organization/index.jsx
  28. 18
    0
      src/pages/staff/Organization/tree.jsx
  29. 2
    2
      src/pages/system/Sellhouse/index.jsx
  30. 99
    97
      src/pages/system/housingPolicy/Edit/index.jsx
  31. 1
    1
      src/utils/image.js

+ 1
- 1
config/proxy.js 查看文件

@@ -8,7 +8,7 @@
8 8
 export default {
9 9
   dev: {
10 10
     '/api/': {
11
-      target: 'http://81.69.196.8:8567/',
11
+      target: 'https://xlk.njyz.tech/',
12 12
       changeOrigin: true,
13 13
       pathRewrite: {
14 14
         '^': '',

+ 1
- 0
package.json 查看文件

@@ -56,6 +56,7 @@
56 56
     "md5": "^2.3.0",
57 57
     "moment": "^2.24.0",
58 58
     "omit.js": "^1.0.2",
59
+    "package.json": "^2.0.1",
59 60
     "path-to-regexp": "2.4.0",
60 61
     "qs": "^6.9.0",
61 62
     "react": "^16.8.6",

+ 10
- 6
src/models/user.js 查看文件

@@ -13,12 +13,16 @@ const UserModel = {
13 13
   },
14 14
   effects: {
15 15
     *fetchCurrent(_, { call, put }) {
16
-      const response = yield call(getCurrentUser);
17
-
18
-      yield put({
19
-        type: 'saveCurrentUser',
20
-        payload: response,
21
-      });
16
+      try {
17
+        const response = yield call(getCurrentUser);
18
+  
19
+        yield put({
20
+          type: 'saveCurrentUser',
21
+          payload: response,
22
+        });
23
+      } catch (err) {
24
+        console.error(err)
25
+      }
22 26
     },
23 27
   },
24 28
   reducers: {

+ 1
- 1
src/pages/building/Developers/tableColumns.js 查看文件

@@ -27,7 +27,7 @@ export default ({page,getBrandData, onEdit, onDelete}) => [
27 27
     dataIndex: 'brandImg',
28 28
     key: 'brandImg',
29 29
     align: 'center',
30
-    render:(_,record)=> <img src={getImgURL(record.brandImg)} style={{width:'165px',height:'104px'}}/>,
30
+    render:(_,record)=> <img src={getImgURL(record.brandImg)} style={{width:'165px',height:'104px',borderRadius:'5px'}}/>,
31 31
   },
32 32
   {
33 33
     title: '简介',

+ 0
- 0
src/pages/building/Edit/Basic.jsx 查看文件


+ 31
- 0
src/pages/building/Edit/Basic/form.js 查看文件

@@ -0,0 +1,31 @@
1
+export function initForm(form, data) {
2
+  if (!data) return;
3
+
4
+  const formData = { ...data }
5
+  // 交房时间
6
+  if (data.receivedDate) {
7
+    formData.receivedDate = moment(data.receivedDate)
8
+  }
9
+
10
+  // 主图 - 多个
11
+  if (data.buildingImg) {
12
+    formData.avatarImage = data.buildingImg.map((x) => x.url)
13
+  }
14
+
15
+  // 封面 - 一个
16
+  if (data.buildingListImg) {
17
+    formData.listImage = data.buildingListImg.map(item => item.url)[0]
18
+  }
19
+
20
+  // 视频
21
+  if (data.videoUrl) {
22
+    formData.videoUrl = [].concat(data.videoUrl)
23
+  }
24
+
25
+  // 视频封面
26
+  if (data.videoImage) {
27
+    formData.videoImage = data.videoImage[0].url
28
+  }
29
+
30
+  form.setFieldsValue(formData);
31
+}

+ 0
- 53
src/pages/building/Edit/Basic/getData.js 查看文件

@@ -1,53 +0,0 @@
1
-import moment from 'moment'
2
-import { fetch, apis } from '@/utils/request'
3
-
4
-export default (id) => {
5
-  if (!id) {
6
-    return Promise.reject('没有找到有效的项目ID');
7
-  }
8
-
9
-  return new Promise((resolve, reject) => {
10
-    fetch(apis.building.buildingGetById)({ urlData: { id } }).then((res) => {
11
-      const data = { ...res }
12
-
13
-      // 交房时间
14
-      if (res.receivedDate) {
15
-        data.receivedDate = moment(res.receivedDate)
16
-      }
17
-
18
-      // 标签
19
-      if (res.buildingTag) {
20
-        data.tag = res.buildingTag.map((x) => x.tagName)
21
-      }
22
-
23
-      // 主图 - 多个
24
-      if (res.buildingImg) {
25
-        data.avatarImage = res.buildingImg.map((x) => x.url)
26
-      }
27
-
28
-      // 封面 - 一个
29
-      if (res.buildingListImg) {
30
-        data.listImage = res.buildingListImg.map(item => item.url)[0]
31
-      }
32
-
33
-      // 视频
34
-      if (res.videoUrl) {
35
-        data.videoUrl = [].concat(res.videoUrl)
36
-      }
37
-
38
-      // 视频封面
39
-      if (res.videoImage) {
40
-        data.videoImage = res.videoImage[0].url
41
-      }
42
-
43
-      // POI 相关
44
-      if (res.mapJson) {
45
-        data.mapJson = JSON.parse(res.mapJson) || []
46
-      }
47
-
48
-      resolve(data)
49
-    }).catch((err) => {
50
-      reject(err.message || err)
51
-    })
52
-  })
53
-}

+ 315
- 297
src/pages/building/Edit/Basic/index.jsx 查看文件

@@ -12,27 +12,40 @@ import OpenTimePicker from '../components/OpenTimePicker'
12 12
 import EditableArround from '../components/EditableArround'
13 13
 import FormGroupItem, { gourpItemLayout } from '../components/FormGroupItem'
14 14
 import { formItemLayout, validMinNum } from '../utils'
15
-import useTags from './tag'
15
+import useArrounds from './useArrounds'
16
+import usePois from './usePois'
17
+import useQuery from './useQuery'
18
+import { initForm } from './form'
16 19
 
17 20
 const fullWidth= { width: '100%' }
18 21
 const Item = Form.Item
19 22
 
20 23
 const BuildingBasic = React.forwardRef((props, ref) => {
21
-  const { form } = props;
24
+  const { form, history } = props;
22 25
   const { getFieldDecorator, getFieldValue, setFieldsValue } = form;
26
+  const { query } = history.location;
27
+  const { id } = query;
23 28
 
24
-  const [ loading, setLoading ] = useState({ arround: false })
29
+  const [ loading, setLoading ] = useState({ form: false, arround: false })
25 30
   const [
26
-    tags,
27
-    initTags,
28
-    updateTags,
29
-    deletePoi,
31
+    arrounds,
32
+    initArrounds,
33
+    updateArrounds,
34
+    deleteArround,
35
+  ] = useArrounds()
36
+  const [
37
+    pois,
30 38
     initPois,
31
-    pois2Tags,
32
-    // updatePois,
33
-    deleteTag,
34
-    updatePoisAndTags,
35
-  ] = useTags()
39
+    deletePoi,
40
+  ] = usePois()
41
+
42
+  const updateLoading = (key) => (state) => setLoading({ ...loading, [key]: state })
43
+
44
+  useQuery(id, updateLoading('form'), (res) => {
45
+    initPois(res.mapJson)
46
+    initArrounds(res)
47
+    initForm(form, res)
48
+  })
36 49
   
37 50
   // 视频文件上传前 回调
38 51
   const fileUploadBeforeUpload = (file, fileList) => {
@@ -67,322 +80,327 @@ const BuildingBasic = React.forwardRef((props, ref) => {
67 80
         }
68 81
       }, {})
69 82
 
70
-      updatePoisAndTags(pois)
83
+      initPois(pois, true)
71 84
       setLoading({ ...loading, arround: false })
72 85
     }).catch((err) => {
73 86
       setLoading({ ...loading, arround: false })
74 87
       console.error(err)
75 88
       notification.error({ message: '周边数据获取异常' })
76 89
     })
77
-
78
-    // POI_TYPES.forEach(({ key }) => {
79
-    //   getPoiData({ type: key, location: lngLat, radius: e }).then(res => {
80
-    //     updatePois(key, res.pois || [])
81
-    //   }).catch(err => {
82
-    //     console.error(err)
83
-    //     notification.error({ message: '周边数据获取失败' })
84
-    //   })
85
-    // })
86 90
   }
87 91
 
88 92
   return (
89
-    <Form {...formItemLayout}>
90
-      <Item label="项目Id" style={{ display: 'none' }}>
91
-        {getFieldDecorator('buildingId')(<Input disabled />)}
92
-      </Item>
93
-      <Item label="楼盘编号" >
94
-        {getFieldDecorator('code', {
95
-          rules: [{ required: true, message: '请输入楼盘编号' }],
96
-        })(<Input />)}
97
-      </Item>
98
-      <Item label="楼盘名称" >
99
-        {getFieldDecorator('buildingName', {
100
-          rules: [{ required: true, message: '请输入楼盘名' }],
101
-        })(<Input />)}
102
-      </Item>
103
-      <Form.Item label="项目类型">
104
-        {getFieldDecorator('buildingProjectType', {
105
-          rules: [{ required: true, message: '请选择项目类型' }],
106
-        })(<BuildingType />)}
107
-      </Form.Item>
108
-      <Form.Item label="列表均价" help="项目列表展示价格,示例:约10000元/㎡、约1000万元/套起">
109
-        {getFieldDecorator('price')(<Input />)}
110
-      </Form.Item>
111
-      <FormGroupItem>
112
-        <Form.Item label="开盘时间" {...gourpItemLayout.ab.a} >
113
-          {getFieldDecorator('openingDate')(
114
-            <OpenTimePicker placeholder="请选择开盘时间" style={fullWidth} />
115
-          )}
93
+    <Spin spinning={loading.form}>
94
+      <Form {...formItemLayout}>
95
+        <Item label="项目Id" style={{ display: 'none' }}>
96
+          {getFieldDecorator('buildingId')(<Input disabled />)}
97
+        </Item>
98
+        <Item label="楼盘编号" >
99
+          {getFieldDecorator('code', {
100
+            rules: [{ required: true, message: '请输入楼盘编号' }],
101
+          })(<Input />)}
102
+        </Item>
103
+        <Item label="楼盘名称" >
104
+          {getFieldDecorator('buildingName', {
105
+            rules: [{ required: true, message: '请输入楼盘名' }],
106
+          })(<Input />)}
107
+        </Item>
108
+        <Form.Item label="项目类型">
109
+          {getFieldDecorator('buildingProjectType', {
110
+            rules: [{ required: true, message: '请选择项目类型' }],
111
+          })(<BuildingType />)}
116 112
         </Form.Item>
117
-        <Form.Item label="电话" {...gourpItemLayout.ab.b } >
118
-          {getFieldDecorator('tel', {
119
-            rules: [
120
-              {
121
-                pattern: new RegExp('^[0-9]*$'),
122
-                message: '请输入正确的电话号码',
123
-              },
124
-            ],
125
-          })(<Input placeholder="手机或者座机号码" />)}
113
+        <Form.Item label="列表均价" help="项目列表展示价格,示例:约10000元/㎡、约1000万元/套起">
114
+          {getFieldDecorator('price')(<Input />)}
126 115
         </Form.Item>
127
-      </FormGroupItem>
128
-      <Form.Item label="项目说明" >
129
-        {getFieldDecorator('dynamic')(<Input placeholder="项目动态等,不超过30个字" maxLength={30}/>)}
130
-      </Form.Item>
131
-      {/* <Form.Item label="物业类型" >
132
-        {getFieldDecorator('propertyType')(<Input />)}
133
-      </Form.Item> */}
134
-      <Form.Item label="销售状态" >
135
-        {getFieldDecorator('marketStatus', {
136
-          rules: [{ required: true, message: '请选择销售状态' }],
137
-        })(
138
-          <Select placeholder="销售状态" style={fullWidth}>
139
-            <Select.Option value="待售">待售</Select.Option>
140
-            <Select.Option value="在售">在售</Select.Option>
141
-            <Select.Option value="售罄">售罄</Select.Option>
142
-            <Select.Option value="在租">在租</Select.Option>
143
-          </Select>,
144
-        )}
145
-      </Form.Item>
146
-      <Form.Item label="项目标签" >
147
-        {getFieldDecorator('tag')(
148
-          <Select mode="tags" placeholder="输入后选中" style={fullWidth} />
149
-        )}
150
-      </Form.Item>
151
-
152
-      <FormGroupItem>
153
-        <Form.Item label="项目视频" help="视频仅支持mp4格式,建议尺寸:750*600,比例5:4,用于楼盘详情" {...gourpItemLayout.ab.a} >
154
-          {getFieldDecorator('videoUrl')(
155
-            <FileUpload accept=".mp4" beforeUpload={fileUploadBeforeUpload} label="上传视频" size={1} />,
156
-          )}
116
+        <FormGroupItem>
117
+          <Form.Item label="开盘时间" {...gourpItemLayout.ab.a} >
118
+            {getFieldDecorator('openingDate')(
119
+              <OpenTimePicker placeholder="请选择开盘时间" style={fullWidth} />
120
+            )}
121
+          </Form.Item>
122
+          <Form.Item label="电话" {...gourpItemLayout.ab.b } >
123
+            {getFieldDecorator('tel', {
124
+              rules: [
125
+                {
126
+                  pattern: new RegExp('^[0-9]*$'),
127
+                  message: '请输入正确的电话号码',
128
+                },
129
+              ],
130
+            })(<Input placeholder="手机或者座机号码" />)}
131
+          </Form.Item>
132
+        </FormGroupItem>
133
+        <Form.Item label="项目说明" >
134
+          {getFieldDecorator('dynamic')(<Input placeholder="项目动态等,不超过30个字" maxLength={30}/>)}
157 135
         </Form.Item>
158
-        <Form.Item label="视频封面图" help="建议图片尺寸:750*600px,比例5:4,格式:jpg,用于视频封面" labelCol={{span: 8}} wrapperCol={{span:16}}>
159
-          {getFieldDecorator('videoImage')(
160
-            <ImageUpload />,
136
+        {/* <Form.Item label="物业类型" >
137
+          {getFieldDecorator('propertyType')(<Input />)}
138
+        </Form.Item> */}
139
+        <Form.Item label="销售状态" >
140
+          {getFieldDecorator('marketStatus', {
141
+            rules: [{ required: true, message: '请选择销售状态' }],
142
+          })(
143
+            <Select placeholder="销售状态" style={fullWidth}>
144
+              <Select.Option value="待售">待售</Select.Option>
145
+              <Select.Option value="在售">在售</Select.Option>
146
+              <Select.Option value="售罄">售罄</Select.Option>
147
+              <Select.Option value="在租">在租</Select.Option>
148
+            </Select>,
161 149
           )}
162 150
         </Form.Item>
163
-      </FormGroupItem>
164
-      <Form.Item label="楼盘主图" help="建议图片尺寸:750*600px,比例5:4,格式:jpg,用于楼盘详情">
165
-        {getFieldDecorator('avatarImage', {
166
-          rules: [{ required: true, message: '请选择项目主图' }],
167
-        })(
168
-          <ImageListUpload unlimited />,
169
-        )}
170
-      </Form.Item>
171
-      <Form.Item label="楼盘封面图" help="建议图片尺寸:750*420px,比例16:9,格式:jpg,用于楼盘列表">
172
-        {getFieldDecorator('listImage', {
173
-          rules: [{ required: true, message: '请选择列表图' }],
174
-        })(
175
-          <ImageUpload />,
176
-        )}
177
-      </Form.Item>
178
-      <FormGroupItem>
179
-        <Form.Item label="首页推荐" {...gourpItemLayout.ab.a} >
180
-          {getFieldDecorator('isMain', { initialValue: 1 })(
181
-            <Radio.Group>
182
-              <Radio value={1}>是</Radio>
183
-              <Radio value={2}>否</Radio>
184
-            </Radio.Group>,
151
+        <Form.Item label="项目标签" >
152
+          {getFieldDecorator('tag')(
153
+            <Select mode="tags" placeholder="输入后选中" style={fullWidth} />
185 154
           )}
186 155
         </Form.Item>
187
-        <Form.Item label="排序" help="数值越大,楼盘在小程序列表页中展示越靠前" {...gourpItemLayout.ab.b}>
188
-          {getFieldDecorator('orderNo')(<InputNumber min={0} style={fullWidth} />)}
189
-        </Form.Item>
190
-      </FormGroupItem>
191
-      <FormGroupItem>
192
-        <Form.Item label="所在城市" {...gourpItemLayout.ab.a } >
193
-          {getFieldDecorator('cityId', {
194
-            rules: [{ required: true, message: '请选择城市' }],
156
+
157
+        <FormGroupItem>
158
+          <Form.Item label="项目视频" help="视频仅支持mp4格式,建议尺寸:750*600,比例5:4,用于楼盘详情" {...gourpItemLayout.ab.a} >
159
+            {getFieldDecorator('videoUrl')(
160
+              <FileUpload accept=".mp4" beforeUpload={fileUploadBeforeUpload} label="上传视频" size={1} />,
161
+            )}
162
+          </Form.Item>
163
+          <Form.Item label="视频封面图" help="建议图片尺寸:750*600px,比例5:4,格式:jpg,用于视频封面" labelCol={{span: 8}} wrapperCol={{span:16}}>
164
+            {getFieldDecorator('videoImage')(
165
+              <ImageUpload />,
166
+            )}
167
+          </Form.Item>
168
+        </FormGroupItem>
169
+        <Form.Item label="楼盘主图" help="建议图片尺寸:750*600px,比例5:4,格式:jpg,用于楼盘详情">
170
+          {getFieldDecorator('avatarImage', {
171
+            rules: [{ required: true, message: '请选择项目主图' }],
195 172
           })(
196
-            <SelectCity style={fullWidth} />,
173
+            <ImageListUpload unlimited />,
197 174
           )}
198 175
         </Form.Item>
199
-        <Form.Item label="楼盘区域" {...gourpItemLayout.ab.b } >
200
-          {getFieldDecorator('buildingArea', {
201
-            rules: [{ required: true, message: '请输入楼盘区域' }],
202
-          })(<AreaSelect style={fullWidth} />)}
203
-        </Form.Item>
204
-      </FormGroupItem>
205
-      <Form.Item label="项目地址" >
206
-        {getFieldDecorator('address', {
207
-          rules: [{ required: true, message: '请输入项目地址' }],
208
-        })(<Input />)}
209
-      </Form.Item>
210
-      <Form.Item label="项目坐标" >
211
-        {getFieldDecorator('coordinate', {
212
-          rules: [{ required: true, message: '请输入项目坐标' }],
213
-        })(<Amap onChange={e => setFieldsValue({ coordinate: e })} />)}
214
-      </Form.Item>
215
-      <Form.Item label="周边范围" >
216
-        {getFieldDecorator('mapScope', {
217
-          rules: [{ required: true, message: '请选择周边设施搜索范围' }],
218
-        })(
219
-          <Select placeholder="周边设施搜索范围" style={fullWidth} onChange={handleMapScopeChange}>
220
-            <Select.Option value={1000}>1公里</Select.Option>
221
-            <Select.Option value={3000}>3公里</Select.Option>
222
-            <Select.Option value={5000}>5公里</Select.Option>
223
-            <Select.Option value={10000}>10公里</Select.Option>
224
-          </Select>,
225
-        )}
226
-      </Form.Item>
227
-      <Spin spinning={loading.arround}>
228
-        <Form.Item label="周边交通" >
229
-          <EditableArround
230
-            tags={tags.buildingTransport}
231
-            onChange={(e) => updateTags('buildingTransport', e)}
232
-            onDelete={(tag) => deleteTag('buildingTransport', tag)}
233
-            onPoiDelete={(poi) => deletePoi('Transport', poi)}
234
-          />
235
-        </Form.Item>
236
-        <Form.Item label="周边商业" >
237
-          <EditableArround
238
-            tags={tags.buildingMall}
239
-            onChange={(e) => updateTags('buildingMall', e)}
240
-            onDelete={(tag) => deleteTag('buildingMall', tag)}
241
-            onPoiDelete={(poi) => deletePoi('Mall', poi)}
242
-          />
243
-        </Form.Item>
244
-        <Form.Item label="周边学校" >
245
-          <EditableArround
246
-            tags={tags.buildingEdu}
247
-            onChange={(e) => updateTags('buildingEdu', e)}
248
-            onDelete={(tag) => deleteTag('buildingEdu', tag)}
249
-            onPoiDelete={(poi) => deletePoi('Edu', poi)}
250
-          />
251
-        </Form.Item>
252
-        <Form.Item label="周边医院" >
253
-          <EditableArround
254
-            tags={tags.buildingHospital}
255
-            onChange={(e) => updateTags('buildingHospital', e)}
256
-            onDelete={(tag) => deleteTag('buildingHospital', tag)}
257
-            onPoiDelete={(poi) => deletePoi('Hospital', poi)}
258
-          />
259
-        </Form.Item>
260
-        <Form.Item label="周边银行" >
261
-          <EditableArround
262
-            tags={tags.buildingBank}
263
-            onChange={(e) => updateTags('buildingBank', e)}
264
-            onDelete={(tag) => deleteTag('buildingBank', tag)}
265
-            onPoiDelete={(poi) => deletePoi('Bank', poi)}
266
-          />
267
-        </Form.Item>
268
-        <Form.Item label="周边餐饮" >
269
-          <EditableArround
270
-            tags={tags.buildingRestaurant}
271
-            onChange={(e) => updateTags('buildingRestaurant', e)}
272
-            onDelete={(tag) => deleteTag('buildingRestaurant', tag)}
273
-            onPoiDelete={(poi) => deletePoi('Restaurant', poi)}
274
-          />
275
-        </Form.Item>
276
-      </Spin>
277
-      <FormGroupItem>
278
-        <Form.Item label="绿化率" {...gourpItemLayout.ab.a } >
279
-          {getFieldDecorator('greeningRate')(<Input />)}
280
-        </Form.Item>
281
-        <Form.Item label="容积率" {...gourpItemLayout.ab.b }>
282
-          {getFieldDecorator('volumeRate')(<Input />)}
176
+        <Form.Item label="楼盘封面图" help="建议图片尺寸:750*420px,比例16:9,格式:jpg,用于楼盘列表">
177
+          {getFieldDecorator('listImage', {
178
+            rules: [{ required: true, message: '请选择列表图' }],
179
+          })(
180
+            <ImageUpload />,
181
+          )}
283 182
         </Form.Item>
284
-      </FormGroupItem>
285
-      <FormGroupItem>
286
-        <Form.Item label="车位数量" {...gourpItemLayout.ab.a }>
287
-          {getFieldDecorator('parkingRate', {
288
-            rules: [{ validator: validMinNum }]
289
-          })(<InputNumber min={0} style={fullWidth}/>)}
183
+        <FormGroupItem>
184
+          <Form.Item label="首页推荐" {...gourpItemLayout.ab.a} >
185
+            {getFieldDecorator('isMain', { initialValue: 1 })(
186
+              <Radio.Group>
187
+                <Radio value={1}>是</Radio>
188
+                <Radio value={2}>否</Radio>
189
+              </Radio.Group>,
190
+            )}
191
+          </Form.Item>
192
+          <Form.Item label="排序" help="数值越大,楼盘在小程序列表页中展示越靠前" {...gourpItemLayout.ab.b}>
193
+            {getFieldDecorator('orderNo')(<InputNumber min={0} style={fullWidth} />)}
194
+          </Form.Item>
195
+        </FormGroupItem>
196
+        <FormGroupItem>
197
+          <Form.Item label="所在城市" {...gourpItemLayout.ab.a } >
198
+            {getFieldDecorator('cityId', {
199
+              rules: [{ required: true, message: '请选择城市' }],
200
+            })(
201
+              <SelectCity style={fullWidth} />,
202
+            )}
203
+          </Form.Item>
204
+          <Form.Item label="楼盘区域" {...gourpItemLayout.ab.b } >
205
+            {getFieldDecorator('buildingArea', {
206
+              rules: [{ required: true, message: '请输入楼盘区域' }],
207
+            })(<AreaSelect style={fullWidth} />)}
208
+          </Form.Item>
209
+        </FormGroupItem>
210
+        <Form.Item label="项目地址" >
211
+          {getFieldDecorator('address', {
212
+            rules: [{ required: true, message: '请输入项目地址' }],
213
+          })(<Input />)}
290 214
         </Form.Item>
291
-        <Form.Item label="规划户数" {...gourpItemLayout.ab.b }>
292
-          {getFieldDecorator('familyNum', {
293
-            rules: [{ validator: validMinNum }]
294
-          })(<InputNumber min={0} style={fullWidth}/>)}
215
+        <Form.Item label="项目坐标" >
216
+          {getFieldDecorator('coordinate', {
217
+            rules: [{ required: true, message: '请输入项目坐标' }],
218
+          })(<Amap onChange={e => setFieldsValue({ coordinate: e })} />)}
295 219
         </Form.Item>
296
-      </FormGroupItem>
297
-      <FormGroupItem>
298
-        <Form.Item label="供水" {...gourpItemLayout.abc.a }>
299
-          {getFieldDecorator('waterSupply')(
300
-            <Select style={fullWidth}>
301
-              <Select.Option value="民水">民水</Select.Option>
302
-              <Select.Option value="商用">商用</Select.Option>
303
-            </Select>
220
+        <Form.Item label="周边范围" >
221
+          {getFieldDecorator('mapScope', {
222
+            rules: [{ required: true, message: '请选择周边设施搜索范围' }],
223
+          })(
224
+            <Select placeholder="周边设施搜索范围" style={fullWidth} onChange={handleMapScopeChange}>
225
+              <Select.Option value={1000}>1公里</Select.Option>
226
+              <Select.Option value={3000}>3公里</Select.Option>
227
+              <Select.Option value={5000}>5公里</Select.Option>
228
+              <Select.Option value={10000}>10公里</Select.Option>
229
+            </Select>,
304 230
           )}
305 231
         </Form.Item>
306
-        <Form.Item label="供电" {...gourpItemLayout.abc.b }>
307
-          {getFieldDecorator('powerSupply')(
308
-            <Select style={fullWidth}>
309
-              <Select.Option value="民电">民电</Select.Option>
310
-              <Select.Option value="商用">商用</Select.Option>
311
-            </Select>
312
-          )}
232
+        <Spin spinning={loading.arround}>
233
+          <Form.Item label="周边交通" >
234
+            <EditableArround
235
+              type="Transport"
236
+              pois={pois.Transport}
237
+              tags={arrounds.buildingTransport}
238
+              onChange={(e) => updateArrounds('buildingTransport', e)}
239
+              onDelete={deleteArround}
240
+              onPoiDelete={(poi) => deletePoi('Transport', poi)}
241
+            />
242
+          </Form.Item>
243
+          <Form.Item label="周边商业" >
244
+            <EditableArround
245
+              type="Mall"
246
+              pois={pois.Mall}
247
+              tags={arrounds.buildingMall}
248
+              onChange={(e) => updateArrounds('buildingMall', e)}
249
+              onDelete={deleteArround}
250
+              onPoiDelete={(poi) => deletePoi('Mall', poi)}
251
+            />
252
+          </Form.Item>
253
+          <Form.Item label="周边学校" >
254
+            <EditableArround
255
+              type="Edu"
256
+              pois={pois.Edu}
257
+              tags={arrounds.buildingEdu}
258
+              onChange={(e) => updateArrounds('buildingEdu', e)}
259
+              onDelete={deleteArround}
260
+              onPoiDelete={(poi) => deletePoi('Edu', poi)}
261
+            />
262
+          </Form.Item>
263
+          <Form.Item label="周边医院" >
264
+            <EditableArround
265
+              type="Hospital"
266
+              pois={pois.Hospital}
267
+              tags={arrounds.buildingHospital}
268
+              onChange={(e) => updateArrounds('buildingHospital', e)}
269
+              onDelete={deleteArround}
270
+              onPoiDelete={(poi) => deletePoi('Hospital', poi)}
271
+            />
272
+          </Form.Item>
273
+          <Form.Item label="周边银行" >
274
+            <EditableArround
275
+              type="Bank"
276
+              pois={pois.Bank}
277
+              tags={arrounds.buildingBank}
278
+              onChange={(e) => updateArrounds('buildingBank', e)}
279
+              onDelete={deleteArround}
280
+              onPoiDelete={(poi) => deletePoi('Bank', poi)}
281
+            />
282
+          </Form.Item>
283
+          <Form.Item label="周边餐饮" >
284
+            <EditableArround
285
+              type="Restaurant"
286
+              pois={pois.Restaurant}
287
+              tags={arrounds.buildingRestaurant}
288
+              onChange={(e) => updateArrounds('buildingRestaurant', e)}
289
+              onDelete={deleteArround}
290
+              onPoiDelete={(poi) => deletePoi('Restaurant', poi)}
291
+            />
292
+          </Form.Item>
293
+        </Spin>
294
+        <FormGroupItem>
295
+          <Form.Item label="绿化率" {...gourpItemLayout.ab.a } >
296
+            {getFieldDecorator('greeningRate')(<Input />)}
297
+          </Form.Item>
298
+          <Form.Item label="容积率" {...gourpItemLayout.ab.b }>
299
+            {getFieldDecorator('volumeRate')(<Input />)}
300
+          </Form.Item>
301
+        </FormGroupItem>
302
+        <FormGroupItem>
303
+          <Form.Item label="车位数量" {...gourpItemLayout.ab.a }>
304
+            {getFieldDecorator('parkingRate', {
305
+              rules: [{ validator: validMinNum }]
306
+            })(<InputNumber min={0} style={fullWidth}/>)}
307
+          </Form.Item>
308
+          <Form.Item label="规划户数" {...gourpItemLayout.ab.b }>
309
+            {getFieldDecorator('familyNum', {
310
+              rules: [{ validator: validMinNum }]
311
+            })(<InputNumber min={0} style={fullWidth}/>)}
312
+          </Form.Item>
313
+        </FormGroupItem>
314
+        <FormGroupItem>
315
+          <Form.Item label="供水" {...gourpItemLayout.abc.a }>
316
+            {getFieldDecorator('waterSupply')(
317
+              <Select style={fullWidth}>
318
+                <Select.Option value="民水">民水</Select.Option>
319
+                <Select.Option value="商用">商用</Select.Option>
320
+              </Select>
321
+            )}
322
+          </Form.Item>
323
+          <Form.Item label="供电" {...gourpItemLayout.abc.b }>
324
+            {getFieldDecorator('powerSupply')(
325
+              <Select style={fullWidth}>
326
+                <Select.Option value="民电">民电</Select.Option>
327
+                <Select.Option value="商用">商用</Select.Option>
328
+              </Select>
329
+            )}
330
+          </Form.Item>
331
+          <Form.Item label="供暖" {...gourpItemLayout.abc.c }>
332
+            {getFieldDecorator('heatingSupply')(
333
+              <Select style={fullWidth}>
334
+                <Select.Option value="集中供暖">集中供暖</Select.Option>
335
+                <Select.Option value="自采暖">自采暖</Select.Option>
336
+              </Select>
337
+            )}
338
+          </Form.Item>
339
+        </FormGroupItem>
340
+        <Form.Item label="物业公司" >
341
+          {getFieldDecorator('serviceCompany', {
342
+            rules: [{ max: 30, message: '不超过30个字' }]
343
+          })(<Input placeholder="不超过30个字"/>)}
313 344
         </Form.Item>
314
-        <Form.Item label="供暖" {...gourpItemLayout.abc.c }>
315
-          {getFieldDecorator('heatingSupply')(
316
-            <Select style={fullWidth}>
317
-              <Select.Option value="集中供暖">集中供暖</Select.Option>
318
-              <Select.Option value="自采暖">自采暖</Select.Option>
319
-            </Select>
320
-          )}
345
+        <Form.Item label="物业费" >
346
+          {getFieldDecorator('serviceFee', {
347
+            rules: [{ max: 30, message: '不超过30个字' }]
348
+          })(<Input placeholder="不超过30个字"/>)}
321 349
         </Form.Item>
322
-      </FormGroupItem>
323
-      <Form.Item label="物业公司" >
324
-        {getFieldDecorator('serviceCompany', {
325
-          rules: [{ max: 30, message: '不超过30个字' }]
326
-        })(<Input placeholder="不超过30个字"/>)}
327
-      </Form.Item>
328
-      <Form.Item label="物业费" >
329
-        {getFieldDecorator('serviceFee', {
330
-          rules: [{ max: 30, message: '不超过30个字' }]
331
-        })(<Input placeholder="不超过30个字"/>)}
332
-      </Form.Item>
333
-      <FormGroupItem>
334
-        <Form.Item label="装修标准" {...gourpItemLayout.ab.a }>
335
-          {getFieldDecorator('decoration')(
336
-            <Select style={fullWidth}>
337
-              <Select.Option value="精装">精装</Select.Option>
338
-              <Select.Option value="毛坯">毛坯</Select.Option>
339
-            </Select>
340
-          )}
350
+        <FormGroupItem>
351
+          <Form.Item label="装修标准" {...gourpItemLayout.ab.a }>
352
+            {getFieldDecorator('decoration')(
353
+              <Select style={fullWidth}>
354
+                <Select.Option value="精装">精装</Select.Option>
355
+                <Select.Option value="毛坯">毛坯</Select.Option>
356
+              </Select>
357
+            )}
358
+          </Form.Item>
359
+          <Form.Item label="楼栋总数" {...gourpItemLayout.ab.b }>
360
+            {getFieldDecorator('buildingNum', {
361
+              rules: [{ validator: validMinNum }]
362
+            })(<InputNumber style={fullWidth}/>)}
363
+          </Form.Item>
364
+        </FormGroupItem>
365
+        <FormGroupItem>
366
+          <Form.Item label="交房时间" {...gourpItemLayout.ab.a }>
367
+            {getFieldDecorator('receivedDate')(<DatePicker style={fullWidth}/>)}
368
+          </Form.Item>
369
+          <Form.Item label="产权年限" {...gourpItemLayout.ab.b }>
370
+            {getFieldDecorator('rightsYear', {
371
+              rules: [{ validator: validMinNum }]
372
+            })(<InputNumber style={fullWidth}/>)}
373
+          </Form.Item>
374
+        </FormGroupItem>
375
+        <Form.Item label="品牌开发商" help="【品牌开发商】与【开发商】二选一">
376
+          {getFieldDecorator('brandId')(<Select style={fullWidth}></Select>)}
341 377
         </Form.Item>
342
-        <Form.Item label="楼栋总数" {...gourpItemLayout.ab.b }>
343
-          {getFieldDecorator('buildingNum', {
344
-            rules: [{ validator: validMinNum }]
345
-          })(<InputNumber style={fullWidth}/>)}
378
+        <Form.Item label="开发商" >
379
+          {getFieldDecorator('propertyDeveloper', {
380
+            rules: [{ max: 30, message: '不超过30个字' }]
381
+          })(<Input placeholder="不超过30个字"/>)}
346 382
         </Form.Item>
347
-      </FormGroupItem>
348
-      <FormGroupItem>
349
-        <Form.Item label="交房时间" {...gourpItemLayout.ab.a }>
350
-          {getFieldDecorator('receivedDate')(<DatePicker style={fullWidth}/>)}
383
+        <Form.Item label="备案名" >
384
+          {getFieldDecorator('recordName', {
385
+            rules: [{ max: 30, message: '不超过30个字' }]
386
+          })(<Input placeholder="不超过30个字" />)}
351 387
         </Form.Item>
352
-        <Form.Item label="产权年限" {...gourpItemLayout.ab.b }>
353
-          {getFieldDecorator('rightsYear', {
354
-            rules: [{ validator: validMinNum }]
355
-          })(<InputNumber style={fullWidth}/>)}
388
+        <Form.Item label="预售许可证" >
389
+          {getFieldDecorator('preSalePermit')(
390
+            <ImageUpload />,
391
+          )}
356 392
         </Form.Item>
357
-      </FormGroupItem>
358
-      <Form.Item label="品牌开发商" help="【品牌开发商】与【开发商】二选一">
359
-        {getFieldDecorator('brandId')(<Select style={fullWidth}></Select>)}
360
-      </Form.Item>
361
-      <Form.Item label="开发商" >
362
-        {getFieldDecorator('propertyDeveloper', {
363
-          rules: [{ max: 30, message: '不超过30个字' }]
364
-        })(<Input placeholder="不超过30个字"/>)}
365
-      </Form.Item>
366
-      <Form.Item label="备案名" >
367
-        {getFieldDecorator('recordName', {
368
-          rules: [{ max: 30, message: '不超过30个字' }]
369
-        })(<Input placeholder="不超过30个字" />)}
370
-      </Form.Item>
371
-      <Form.Item label="预售许可证" >
372
-        {getFieldDecorator('preSalePermit')(
373
-          <ImageUpload />,
374
-        )}
375
-      </Form.Item>
376 393
 
377
-      <Form.Item label=" " colon={false}>
378
-        <Button style={{marginLeft: '6em'}} type="primary" htmlType="submit">
379
-            确定
380
-        </Button>
381
-        <Button style={{marginLeft: '2em'}} onClick={() => router.go(-1)}>
382
-            取消
383
-        </Button>
384
-      </Form.Item>
385
-    </Form>
394
+        <Form.Item label=" " colon={false}>
395
+          <Button style={{marginLeft: '6em'}} type="primary" htmlType="submit">
396
+              确定
397
+          </Button>
398
+          <Button style={{marginLeft: '2em'}} onClick={() => router.go(-1)}>
399
+              取消
400
+          </Button>
401
+        </Form.Item>
402
+      </Form>
403
+    </Spin>
386 404
   )
387 405
 })
388 406
 

+ 0
- 116
src/pages/building/Edit/Basic/tag.js 查看文件

@@ -1,116 +0,0 @@
1
-import { useCallback, useState, useRef } from "react";
2
-
3
-export default function useTags(form) {
4
-  const [tags, setTags] = useState({})
5
-  const poisRef = useRef({})
6
-
7
-  // const updatePoi2Form = pois => form.setFieldsValue('mapJson', Object.keys(pois).map((key) => ({ key, data: pois[key] })))
8
-
9
-  // initPois 必须先于 initTags 执行
10
-  // initPois, initTags 是在请求远程数据结束后执行
11
-  const initPois = useCallback((raw) => {
12
-    const newPois = !raw ? {} : raw.reduce((acc, poi) => {
13
-      const { key, data } = poi
14
-      return {
15
-        ...acc,
16
-        [key]: data || []
17
-      }
18
-    }, {})
19
-
20
-    poisRef.current = newPois
21
-  }, [])
22
-
23
-  // 主要用于地图搜索周边结果
24
-  const updatePois = useCallback((key, val) => {
25
-    poisRef.current[key] = val
26
-
27
-    // 先把 tags 中的 poi 去掉, 再更新
28
-    const tagKey = `building${key}`
29
-    const newTags = (tags[tagKey] || []).filter((tag) => !tag.id).concat(val)
30
-    setTags({
31
-      ...tags,
32
-      [tagKey]: newTags,
33
-    })
34
-
35
-    // 更新form
36
-    // updatePoi2Form(poisRef.current)
37
-    // form.setFieldsValue({ [key]: newTags.map((tag) => tag.name).join(',') })
38
-  }, [tags])
39
-
40
-  // 主要用于单个 poi 删除
41
-  const deletePoi = useCallback((key, val) => {
42
-    if (!poisRef.current[key] || !poisRef.current[key].length) return;
43
-
44
-    const newPois = poisRef.current[key].filter((poi) => poi.name !== val.name)
45
-    poisRef.current[key] = newPois
46
-
47
-    // 更新form
48
-    // updatePoi2Form(poisRef.current)
49
-  }, [])
50
-
51
-  const updatePoisAndTags = useCallback((pois) => {
52
-    poisRef.current = pois
53
-    const keys = Object.keys(pois)
54
-    
55
-    const newTags = keys.reduce((acc, key) => {
56
-      const tagKey = `building${key}`
57
-      const arr = (tags[tagKey] || []).filter((tag) => !tag.id).concat(pois[key])
58
-      return { ...acc, [tagKey]: arr }
59
-    }, tags)
60
-
61
-    setTags(newTags)
62
-  }, [tags])
63
-
64
-  const initTags = useCallback((key, raw) => {
65
-    const tagArr = !raw ? [] : raw.split(',').filter(Boolean)
66
-
67
-    if (!tagArr.length) return;
68
-
69
-    const pois = poisRef.current[key] || []
70
-
71
-    const newTags = tagArr.map((tag) => {
72
-      const found = pois.filter((poi) => poi.name === tag)[0]
73
-
74
-      return found || { name: tag }
75
-    })
76
-
77
-    setTags({
78
-      ...tags,
79
-      [key]: newTags,
80
-    })
81
-  }, [tags])
82
-
83
-  const updateTags = useCallback((key, newTags = []) => {
84
-    setTags({
85
-      ...tags,
86
-      [key]: newTags,
87
-    })
88
-
89
-    // form.setFieldsValue({ [key]: newTags.map((tag) => tag.name).join(',') })
90
-  }, [tags])
91
-
92
-  // 主要用户单个 tag 删除
93
-  const deleteTag = useCallback((key, tag) => {
94
-    if (!tags[key] || !tags[key].length) return;
95
-
96
-    const leftTags = tags[key].filter((x) => x.name !== tag.name)
97
-
98
-    setTags({
99
-      ...tags,
100
-      [key]: leftTags,
101
-    })
102
-
103
-    // form.setFieldsValue({ [key]: leftTags.map((tag) => tag.name).join(',') })
104
-  })
105
-
106
-  return [
107
-    tags,
108
-    initTags,
109
-    updateTags,
110
-    deletePoi,
111
-    initPois,
112
-    updatePois,
113
-    deleteTag,
114
-    updatePoisAndTags,
115
-  ]
116
-}

+ 48
- 0
src/pages/building/Edit/Basic/useArrounds.js 查看文件

@@ -0,0 +1,48 @@
1
+import { useCallback, useState, useRef } from "react";
2
+
3
+const formateArroundTag = str => (str || '').split(',').filter(Boolean).map(x => ({name: x}));
4
+
5
+export default function useArrounds() {
6
+  const [arrounds, setArrounds] = useState({})
7
+
8
+  // 用来初始化数据库数据
9
+  const initArrounds = useCallback((data) => {
10
+    const tags = {
11
+      buildingTransport: formateArroundTag(data.buildingTransport),
12
+      buildingMall: formateArroundTag(data.buildingMall),
13
+      buildingEdu: formateArroundTag(data.buildingEdu),
14
+      buildingHospital: formateArroundTag(data.buildingHospital),
15
+      buildingBank: formateArroundTag(data.buildingBank),
16
+      buildingRestaurant: formateArroundTag(data.buildingRestaurant),
17
+    }
18
+
19
+    setArrounds(tags)
20
+  }, [])
21
+
22
+  // 用于周边 onChange 事件
23
+  const updateArrounds = useCallback((key, vals) => {
24
+    setArrounds({
25
+      ...arrounds,
26
+      [key]: vals || [],
27
+    })
28
+  }, [arrounds])
29
+
30
+  // 主要用户单个 tag 删除
31
+  const deleteArround = useCallback((key, tag) => {
32
+    if (!arrounds[key] || !arrounds[key].length) return;
33
+
34
+    const leftArrounds = arrounds[key].filter((x) => x.name !== tag.name)
35
+
36
+    setArrounds({
37
+      ...arrounds,
38
+      [key]: leftArrounds,
39
+    })
40
+  }, [arrounds])
41
+
42
+  return [
43
+    arrounds,
44
+    initArrounds,
45
+    updateArrounds,
46
+    deleteArround,
47
+  ]
48
+}

+ 40
- 0
src/pages/building/Edit/Basic/usePois.js 查看文件

@@ -0,0 +1,40 @@
1
+import { useCallback, useState } from "react";
2
+
3
+export default function usePois() {
4
+  const [pois, setPois] = useState({})
5
+
6
+  const initPois = useCallback((data, formated) => {
7
+    if (!data) return;
8
+
9
+    if (formated) {
10
+      setPois(data)
11
+      return;
12
+    }
13
+
14
+    const nwPois = data.reduce((acc, poi) => {
15
+      return {
16
+        ...acc,
17
+        [poi.key]: poi.data ? JSON.parse(poi.data) : [],
18
+      }
19
+    }, {})
20
+
21
+    setPois(nwPois)
22
+  }, [])
23
+  
24
+  const deletePoi = useCallback((key, val) => {
25
+    if (!pois[key] || !pois[key].length) return;
26
+
27
+    const newPois = pois[key].filter((poi) => poi.name !== val.name)
28
+
29
+    setPois({
30
+      ...pois,
31
+      [key]: newPois
32
+    })
33
+  }, [pois])
34
+
35
+  return [
36
+    pois,
37
+    initPois,
38
+    deletePoi,
39
+  ]
40
+}

+ 40
- 0
src/pages/building/Edit/Basic/useQuery.js 查看文件

@@ -0,0 +1,40 @@
1
+import { useEffect, useState } from 'react'
2
+import { fetch, apis } from '@/utils/request'
3
+import { notification } from 'antd'
4
+
5
+export default function useData(id, setLoading, callback) {
6
+  const [data, setData] = useState()
7
+
8
+  useEffect(() => {
9
+    if (!id) {
10
+      setData();
11
+      return;
12
+    }
13
+
14
+    setLoading(true);
15
+    fetch(apis.building.buildingGetById)({ urlData: { id } }).then((res) => {
16
+
17
+      // 标签
18
+      if (res.buildingTag) {
19
+        res.tag = res.buildingTag.map((x) => x.tagName)
20
+      }
21
+
22
+      // POI 相关
23
+      if (res.mapJson) {
24
+        res.mapJson = JSON.parse(res.mapJson) || []
25
+      }
26
+
27
+      setData(res)
28
+      setLoading(false);
29
+
30
+      if (callback) {
31
+        callback(res)
32
+      }
33
+    }).catch((err) => {
34
+      setLoading(false);
35
+      notification.error({message: err.message || err})
36
+    })
37
+  }, [id])
38
+
39
+  return [data, setData]
40
+}

+ 11
- 5
src/pages/building/Edit/components/Amap/index.jsx 查看文件

@@ -22,13 +22,11 @@ export default (props) => {
22 22
 
23 23
   useEffect(() => {
24 24
     // 只加载一次 amap 相关 js
25
-    sdk.loadMapModule({
26
-      plugins,
27
-    }).then((AMap) => {
25
+    sdk.loadMapModule({ plugins }).then((AMap) => {
28 26
       const instance = new AMap.Map(container.current, { zoom: 12 })
29 27
       instance.addControl(new AMap.Scale())
30 28
       instance.addControl(new AMap.ToolBar())
31
-      
29
+
32 30
       // 尝试自动定位到当前位置
33 31
       if (!props.value) {
34 32
         instance.addControl(autoPos(AMap))
@@ -60,7 +58,15 @@ export default (props) => {
60 58
 
61 59
   useEffect(() => {
62 60
     if (currentPos.length) {
63
-      posMarker.current.setPosition(currentPos)
61
+      if (posMarker.current) {
62
+        posMarker.current.setPosition(currentPos)
63
+      }
64
+      if (map.current) {
65
+        map.current.setCenter(currentPos);
66
+      }
67
+      if (currentPos.length && map.current) {
68
+        posMarker.current.setMap(map.current)
69
+      }
64 70
     }
65 71
   }, [currentPos])
66 72
 

+ 6
- 2
src/pages/building/Edit/components/BuildingTypeDetail.jsx 查看文件

@@ -1,4 +1,4 @@
1
-import React, { useState } from 'react'
1
+import React, { useEffect, useState } from 'react'
2 2
 import { Button, Drawer, Form, Radio, Input, Select } from 'antd'
3 3
 import { formItemLayout } from '../utils'
4 4
 import styles from '../style.less'
@@ -31,14 +31,18 @@ const BuildingTypeDetail = (props) => {
31 31
       };
32 32
 
33 33
       const data = {
34
-        ...values,
35 34
         ...dataset || {},
35
+        ...values,
36 36
       }
37 37
 
38 38
       onSubmit(data)
39 39
     })
40 40
   }
41 41
 
42
+  useEffect(() => {
43
+    form.setFieldsValue(dataset)
44
+  }, [dataset])
45
+
42 46
   return (
43 47
     <Drawer
44 48
       width={600}

+ 3
- 4
src/pages/building/Edit/components/BuildingTypeSelect.jsx 查看文件

@@ -33,7 +33,7 @@ export default React.forwardRef((props, ref) => {
33 33
 
34 34
   const handleClick = (buildingType) => () => {
35 35
     const current = (value || []).filter((it) => it.buildingTypeId === buildingType.buildingTypeId)[0] || {buildingTypeId: buildingType.buildingTypeId}
36
-    
36
+    console.log('-------------->', current)
37 37
     setCurRow(current)
38 38
     setBuildingType(buildingType)
39 39
     setShowDrawer(true)
@@ -84,9 +84,8 @@ export default React.forwardRef((props, ref) => {
84 84
               <Checkbox
85 85
                 checked={checked}
86 86
                 onChange={handleChange(it)}
87
-              >
88
-                {it.buildingTypeName}
89
-              </Checkbox>
87
+              />
88
+              <span style={{display: 'inline-block', margin: '0 .5em'}}>{it.buildingTypeName}</span>
90 89
               {checked && <a href="#" onClick={handleClick(it)}><Icon type="edit" /></a>}              
91 90
             </Card.Grid>
92 91
           )

+ 0
- 26
src/pages/building/Edit/components/EditableArround/MapPois.jsx 查看文件

@@ -1,26 +0,0 @@
1
-import React, { useRef, useEffect, forwardRef } from 'react'
2
-
3
-export default forwardRef((props, ref) => {
4
-  const tags = useRef((props.pois || '').split(','))
5
-
6
-  // 用来记录上一次传值
7
-  const previous = useRef()
8
-
9
-  // 监控 props.pois 的变化, 触发 onChange
10
-  // 实际场景中 props.pois 只会由地图引起变化
11
-  useEffect(() => {
12
-    const changed = previous.current !== props.pois
13
-    if (changed) {
14
-      tags.current = (props.pois || '').split(',')
15
-      previous.current = props.pois
16
-
17
-      if (props.onChange) {
18
-        props.onChange(tags.current)
19
-      }
20
-    }
21
-  }, [props.pois, props.onChange])
22
-
23
-  return (
24
-    <></>
25
-  )
26
-})

+ 0
- 41
src/pages/building/Edit/components/EditableArround/hooks/usePoi.js 查看文件

@@ -1,41 +0,0 @@
1
-import { useCallback, useEffect, useRef } from "react";
2
-
3
-export default function usePoi(pois, tags, setTags) {
4
-  const poiRef = useRef([])
5
-
6
-  useEffect(() => {
7
-    const len1 = !pois ? 0 : pois.length
8
-    const len2 = poiRef.current.length
9
-
10
-    // 空数据
11
-    if (len1 === len2 && len1 === 0) {
12
-      return
13
-    }
14
-
15
-    // 如果是 poiRef 更新导致了 pois 更新
16
-    if (len1 > 0 && poiRef.current === pois) {
17
-      return
18
-    }
19
-
20
-    // 如果是初始化
21
-    poiRef.current = pois || []
22
-  }, [pois])
23
-
24
-  const updatePois = useCallback((pois) => {
25
-    const newTags = tags.filter((tag) => !tag.id)
26
-    setTags(newTags.concat(pois))
27
-  }, [tags])
28
-
29
-  const deletePoi = useCallback((poi) => {
30
-    const newTags = tags.filter((tag) => tag.id !== poi.id)
31
-
32
-    const newPois = !poiRef.current.length ? [] : poiRef.current.filter((p) => p.id !== poi.id)
33
-    poiRef.current = newPois
34
-
35
-    setTags(newTags)
36
-
37
-    return newPois
38
-  }, [tags])
39
-
40
-  return [updatePois, deletePoi]
41
-}

+ 0
- 43
src/pages/building/Edit/components/EditableArround/hooks/useTag.js 查看文件

@@ -1,43 +0,0 @@
1
-import { useCallback, useRef } from "react";
2
-
3
-export default function useTag(inited, tags, setTags) {
4
-  const getNewTag = useRef()
5
-  getNewTag.current = (tag) => {
6
-    const matched = tags.filter((item) => (tag.name === item.name))[0]
7
-
8
-    if (matched && matched.id) {
9
-      return matched
10
-    }
11
-
12
-    return tag
13
-  }
14
-
15
-  const updateTags = useCallback((nwTags) => {
16
-    if (!nwTags || !nwTags.length) {
17
-      return tags
18
-    }
19
-
20
-    const nwVals = nwTags.map((tag) => getNewTag.current(tag))
21
-    setTags(nwVals)
22
-    inited.current = true
23
-  }, [tags])
24
-
25
-  const appendTags = useCallback((tag) => {
26
-    const found = tags.filter((item) => (tag.name === item.name))[0]
27
-    if (found) {
28
-      return
29
-    }
30
-
31
-    setTags(tags.concat(tag))
32
-    inited.current = true
33
-  }, [tags])
34
-
35
-
36
-  const deleteTags = useCallback((tag) => {
37
-    const nwVal = tags.filter((it) => it.name !== tag.name)
38
-    
39
-    setTags(nwVal)
40
-  }, [tags])
41
-
42
-  return [updateTags, appendTags, deleteTags]
43
-}

+ 0
- 17
src/pages/building/Edit/components/EditableArround/hooks/useValue.js 查看文件

@@ -1,17 +0,0 @@
1
-import { useEffect, useRef } from "react"
2
-
3
-export default function useValue(value, poiRef, updateTags) {
4
-  const valueInited = useRef(false)
5
-
6
-  useEffect(() => {
7
-    if (!valueInited.current && value) {
8
-      const vals = value.split(',').filter(Boolean).map((tag) => ({ name: tag }))
9
-      const newTags = !poiRef.length ? vals : vals.map((val) => {
10
-        const found = poiRef.current.filter((poi) => poi.name === val.name)[0]
11
-        return found || val
12
-      })
13
-      updateTags(newTags)
14
-      valueInited.current = true
15
-    }
16
-  }, [value])
17
-}

+ 8
- 9
src/pages/building/Edit/components/EditableArround/index.jsx 查看文件

@@ -1,10 +1,8 @@
1
-import React, { useEffect, useRef, useState } from 'react'
1
+import React, { useRef, useState } from 'react'
2 2
 import { Typography, Tag, Input, Icon } from 'antd'
3
-import MapPois from './MapPois'
4
-import { arrRemove, arrAdd } from './utils'
5 3
 
6 4
 export default React.forwardRef((props, ref) => {
7
-  const { tags = [], onPoiDelete, onDelete, onChange } = props
5
+  const { tags = [], pois = [], type, onPoiDelete, onDelete, onChange } = props
8 6
 
9 7
   const inputRef = useRef()
10 8
   const [inputValue, setInputValue] = useState()
@@ -12,18 +10,19 @@ export default React.forwardRef((props, ref) => {
12 10
 
13 11
   const handleClose = (tag) => {
14 12
     if (tag.id && onPoiDelete) {
15
-      onPoiDelete(tag)
13
+      onPoiDelete(type, tag)
14
+      return
16 15
     }
17 16
 
18 17
     if (onDelete) {
19
-      onDelete(tag)
18
+      onDelete(`building${type}`, tag)
20 19
     }
21 20
   }
22 21
 
23 22
   const handleInputConfirm = () => {
24
-    const exists = tags.filter((tag) => tag.name === inputValue)[0]
23
+    const exists = tags.concat(pois).filter((tag) => tag.name === inputValue)[0]
25 24
     if (!exists) {
26
-      onChange(tags.concat({ name: inputValue }))
25
+      onChange(`building${type}`, tags.concat({ name: inputValue }))
27 26
     }
28 27
     setInputVisible(false)
29 28
     setInputValue()
@@ -32,7 +31,7 @@ export default React.forwardRef((props, ref) => {
32 31
   return (
33 32
     <div>
34 33
       {
35
-        tags.map((tag) => (
34
+        tags.concat(pois).map((tag) => (
36 35
           <Tag key={tag.name} closable onClose={() => handleClose(tag)}>
37 36
             <Typography.Text>{tag.name}</Typography.Text>
38 37
           </Tag>

+ 0
- 35
src/pages/building/Edit/components/EditableArround/utils.js 查看文件

@@ -1,35 +0,0 @@
1
-
2
-export function arrRemove(src, target) {
3
-  if (!target || target.length < 1) {
4
-    return src;
5
-  }
6
-
7
-  if (!src || src.length < 1) {
8
-    return src;
9
-  }
10
-
11
-  const arr = src.filter((it) => target.indexOf(it) === -1)
12
-  if (arr.length === src.length) return src;
13
-
14
-  return arr;
15
-}
16
-
17
-export function arrAdd(src, add) {
18
-  if (!add || add.length < 1) {
19
-    return src;
20
-  }
21
-
22
-  if (!src && add.length > 0) {
23
-    return [...add]
24
-  }
25
-
26
-  
27
-  const nwTags = src.slice()
28
-  add.forEach((it) => {
29
-    if (nwTags.indexOf(it) === -1) {
30
-      nwTags.push(it)
31
-    }
32
-  })
33
-
34
-  return nwTags;
35
-}

+ 9
- 9
src/pages/building/Edit/index.jsx 查看文件

@@ -21,45 +21,45 @@ export default (props) => {
21 21
       <Tabs defaultActiveKey="1">
22 22
         <TabPane tab="基础信息" key="1">
23 23
           <div className={styles['tab-wrapper']} style={{maxWidth: 1000}}>
24
-            <Basic />
24
+            <Basic {...props} />
25 25
           </div>
26 26
         </TabPane>
27 27
         <TabPane tab="户型设置" key="2">
28 28
           <div className={styles['tab-wrapper']}>
29
-            <Apartment />
29
+            <Apartment {...props} />
30 30
           </div>
31 31
         </TabPane>
32 32
         <TabPane tab="项目相册" key="3">
33 33
           <div className={styles['tab-wrapper']}>
34
-            <AlbumList />
34
+            <AlbumList {...props} />
35 35
           </div>
36 36
         </TabPane>
37 37
         <TabPane tab="全景照片" key="4">
38 38
           <div className={styles['tab-wrapper']}>
39
-            <Panorama />
39
+            <Panorama {...props} />
40 40
           </div>
41 41
         </TabPane>
42 42
         <TabPane tab="项目动态" key="8">
43 43
           <div className={styles['tab-wrapper']}>
44
-            <News />
44
+            <News {...props} />
45 45
           </div>
46 46
         </TabPane>
47 47
         <TabPane tab="特价房源" key="9">
48 48
           <div className={styles['tab-wrapper']}>
49
-            <SpecialRoom />
49
+            <SpecialRoom {...props} />
50 50
           </div>
51 51
         </TabPane>
52 52
         <TabPane tab="渠道设置" key="7">
53 53
           <div className={styles['tab-wrapper']} style={{maxWidth: '800px'}}>
54
-            <Channel />
54
+            <Channel {...props} />
55 55
           </div>
56 56
         </TabPane>
57 57
         <TabPane tab="海报图片" key="5">
58
-          <Poster target={target} />
58
+          <Poster target={target} {...props} />
59 59
         </TabPane>
60 60
         <TabPane tab="分享设置" key="6">
61 61
           <div className={styles['tab-wrapper']} style={{maxWidth: '800px'}}>
62
-            <Share target={target} />
62
+            <Share target={target} {...props} />
63 63
           </div>
64 64
         </TabPane>
65 65
       </Tabs>

+ 8
- 8
src/pages/home/Recommend/auditCopy.jsx 查看文件

@@ -33,14 +33,14 @@ function body(props) {
33 33
   function getById(currentId) {
34 34
     request({ ...apis.customer.recommendGetById, urlData: { id: currentId } }).then(res => {
35 35
       // res.reportDate = moment(res.reportDate)
36
-      if(res){
37
-        props.form.setFieldsValue({...res,reportDate:moment(res.reportDate)})
36
+      if (res) {
37
+        props.form.setFieldsValue({ ...res, reportDate: moment(res.reportDate) })
38 38
       }
39
-    
39
+
40 40
     })
41 41
   }
42 42
   //返回上一页
43
-  function backCom(){
43
+  function backCom() {
44 44
     window.history.back(-1)
45 45
   }
46 46
   return (
@@ -81,15 +81,15 @@ function body(props) {
81 81
         </Form.Item>
82 82
         <Form.Item label="客户备注"  >
83 83
           {getFieldDecorator('say')(
84
-            <TextArea  placeholder="客户描述" rows={7}
84
+            <TextArea placeholder="客户描述" rows={7}
85 85
             />,
86 86
           )}
87 87
         </Form.Item>
88 88
         <Form.Item label="回访备注" >
89
-          {getFieldDecorator('describe' ,{
90
-            rules:[{required:true}]//v3x必填
89
+          {getFieldDecorator('describe', {
90
+            rules: [{ required: true }]//v3x必填
91 91
           })(
92
-            <TextArea placeholder="回访备注" rows={7}  value={props}/>,
92
+            <TextArea placeholder="回访备注" rows={7} value={props} />,
93 93
           )}
94 94
         </Form.Item>
95 95
         <Form.Item style={{ display: 'flex', justifyContent: 'center' }}>

+ 95
- 101
src/pages/home/Recommend/index.jsx 查看文件

@@ -1,5 +1,5 @@
1
-import React, {PureComponent, useMemo, useState } from 'react';
2
-import {  Avatar, Button } from 'antd';
1
+import React, { PureComponent, useMemo, useState } from 'react';
2
+import { Avatar, Button } from 'antd';
3 3
 import moment from 'moment';
4 4
 import request from '../../../utils/request';
5 5
 import apis from '../../../services/apis';
@@ -26,7 +26,7 @@ import { backgroundColor } from 'echarts/lib/theme/dark';
26 26
 
27 27
 
28 28
 function Recommend() {
29
-  const [exportLoding,setExportLoding] = useState(false)
29
+  const [exportLoding, setExportLoding] = useState(false)
30 30
   //详情页面弹窗配置
31 31
   function toAudit(cuurentId) {
32 32
     router.push({
@@ -35,7 +35,7 @@ function Recommend() {
35 35
         id: cuurentId,
36 36
       },
37 37
     })
38
-    
38
+
39 39
   }
40 40
   function toSee(cuurentId) {
41 41
     router.push({
@@ -44,7 +44,7 @@ function Recommend() {
44 44
         id: cuurentId,
45 45
       },
46 46
     })
47
-    
47
+
48 48
   }
49 49
 
50 50
 
@@ -64,19 +64,16 @@ function Recommend() {
64 64
 
65 65
     })
66 66
   }
67
-  function back(){
68
-    window.history.back(-1)
69
-  }
70 67
 
71 68
   function download(data) {
72 69
     if (!data) {
73
-      return 
70
+      return
74 71
     }
75 72
     const url = window.URL.createObjectURL(new Blob([data]))
76 73
     const link = document.createElement('a')
77 74
     link.style.display = 'none'
78 75
     link.href = url
79
-    link.setAttribute('download', '推荐客户.xlsx')
76
+    link.setAttribute('download', '找房需求.xlsx')
80 77
     document.body.append(link)
81 78
     link.click()
82 79
     setExportLoding(false)
@@ -84,146 +81,143 @@ function Recommend() {
84 81
   const columns = [
85 82
     {
86 83
       title: '头像',
87
-      dataIndex: 'picture',
88
-      key: 'picture',
89
-      align:'center',
90
-      render: (_, record) => <Avatar shape="square" src={record.picture} size={64} icon="user" />,
84
+      dataIndex: 'avatarurl',
85
+      key: 'avatarurl',
86
+      align: 'center',
87
+      render: (_, record) => <Avatar shape="square" src={record.avatarurl} size={64} />,
91 88
     },
92 89
     {
93 90
       title: '姓名',
94
-      dataIndex: 'name',
95
-      key: 'name',
96
-      align:'center',
91
+      dataIndex: 'nickname',
92
+      key: 'nickname',
93
+      align: 'center',
97 94
       // render: (_, record) => <><span>{record.name = '曹建芳'}</span></>,
98 95
     },
99 96
     {
100 97
       title: '电话',
101 98
       dataIndex: 'phone',
102 99
       key: 'phone',
103
-      align:'center',
100
+      align: 'center',
104 101
     },
105 102
     {
106 103
       title: '性别',
107
-      dataIndex: 'sex',
108
-      key: 'sex',
109
-      align:'center',
104
+      dataIndex: 'gender',
105
+      key: 'gender',
106
+      align: 'center',
110 107
       // eslint-disable-next-line no-nested-ternary
111
-      render: (_, record) => <><span>{record.sex === 1 ? '男' : record.sex === 2 ? '女' : '未知'}</span></>,
108
+      render: (_, record) => <><span>{record.gender === '1' ? '男' : record.gender === '2' ? '女' : '未知'}</span></>,
112 109
     },
113 110
     {
114 111
       title: '意向区域',
115
-      dataIndex: 'area',//意向区域
116
-      key: 'area',
117
-      align:'center',
118
-      render: (_, record) => <><span>{record.area = '江苏省南京市秦淮区'}</span></>,
112
+      dataIndex: 'intentArea',//意向区域
113
+      key: 'intentArea',
114
+      align: 'center',
115
+      // render: (_, record) => <><span>{record.area = '江苏省南京市秦淮区'}</span></>,
119 116
 
120 117
     },
121 118
     {
122 119
       title: '意向项目',
123 120
       dataIndex: 'intention',
124 121
       key: 'intention',
125
-      // intention
126
-      //project
127
-      align:'center',
128
-      // render: (_, record) => <><span>{record.area = '香颂.蔚澜半岛'}</span></>,
129
-      render:(_,record)=><span>{record='香颂.蔚澜半岛'}</span>
122
+      align: 'center',
123
+      // render:(_,record)=><span>{record='香颂.蔚澜半岛'}</span>
130 124
 
131 125
     },
132 126
     {
133 127
       title: '提交时间',
134
-      dataIndex: 'createDate',
135
-      key: 'createDate',
136
-      align:'center',
137
-      render: (_, record) => <><span>{record.createDate && moment(record.createDate).format('YYYY-MM-DD HH:mm:ss')}</span></>,
128
+      dataIndex: 'createdTime',
129
+      key: 'createdTime',
130
+      align: 'center',
131
+      render: (_, record) => <><span>{record.createdTime && moment(record.createdTime).format('YYYY-MM-DD HH:mm:ss')}</span></>,
138 132
     },
139 133
     {
140 134
       title: '状态',
141
-      dataIndex: 'verifyStatus',
142
-      key: 'verifyStatus',
143
-      align:'center',
144
-      render: (_, record) => <><span>{record.verifyStatus === 0 ? '待回访' : record.verifyStatus === 1 ? '已回访'   : record.verifyStatus === 2 ? '无效' : ''}</span></>,
135
+      dataIndex: 'status',
136
+      key: 'status',
137
+      align: 'center',
138
+      render: (_, record) => <><span>{record.verifyStatus === 0 ? '待回访' : record.verifyStatus === 1 ? '已回访' : record.verifyStatus === 2 ? '无效' : ''}</span></>,
145 139
     },
146 140
     {
147 141
       title: '操作',
148 142
       dataIndex: 'customerId',
149 143
       key: 'customerId',
150
-      align:'center',
144
+      align: 'center',
151 145
 
152 146
       render: (_, record) => (
153 147
         <><span style={{ color: 'rgba(239,39,58,1)', cursor: 'pointer' }} >
154
-          {record.verifyStatus ===0?<span onClick={() => toAudit(record.customerId)}>审核</span>
155
-          : record.verifyStatus ===1?<span onClick={() => toSee(record.customerId)}>查看详情</span>
156
-          : record.verifyStatus ===2?<span onClick={() => toSee(record.customerId)}>查看详情</span>
157
-          :''}</span>
148
+          {record.verifyStatus === 0 ? <span onClick={() => toAudit(record.customerId)}>审核</span>
149
+            : record.verifyStatus === 1 ? <span onClick={() => toSee(record.customerId)}>查看详情</span>
150
+              : record.verifyStatus === 2 ? <span onClick={() => toSee(record.customerId)}>查看详情</span>
151
+                : ''}</span>
158 152
         </>
159 153
       ),
160 154
     },
161 155
   ]
162 156
 
163 157
 
164
- const searchFields=[
165
-
166
-  {
167
-    name: 'project',
168
-    label: '意向项目',
169
-    placeholder: '请输入意向项目',
170
-  },
171
-
172
-  {
173
-    name: 'name',
174
-    label: '姓名',
175
-    placeholder: '请输入姓名',
176
-  },
177
-  {
178
-    name: 'tel',
179
-    label: '电话',
180
-    placeholder: '请输入电话',
181
-  },
158
+  const searchFields = [
159
+
160
+    {
161
+      name: 'project',
162
+      label: '意向项目',
163
+      placeholder: '请输入意向项目',
164
+    },
165
+
166
+    {
167
+      name: 'name',
168
+      label: '姓名',
169
+      placeholder: '请输入姓名',
170
+    },
182 171
     {
183
-    name: 'types',
184
-    label: '类型',
185
-    placeholder: '类型',
186
-    type: 'select',
187
-    options: [
188
-      {label: '全部',value:''},
189
-      {label: '买房',value: '1'},
190
-      {label: '租房', value: '2'},
191
-      {label: '海外', value: '3'}
192
-    ]
193
-  },
194
-  {
195
-    name: 'verifyStatus',
196
-    label: '状态',
197
-    placeholder: '请选择状态',
198
-    type: 'select',
199
-    placeholder:'全部',//错误
200
-    options: [
201
-      {label: '全部',value:''},
202
-      {label: '待回访', value: '0'},
203
-      {label: '已回访', value: '1'},
204
-      {label: '无效', value: '2'}
205
-    ]
206
-  },
172
+      name: 'tel',
173
+      label: '电话',
174
+      placeholder: '请输入电话',
175
+    },
176
+    {
177
+      name: 'types',
178
+      label: '类型',
179
+      placeholder: '类型',
180
+      type: 'select',
181
+      options: [
182
+        { label: '全部', value: '' },
183
+        { label: '买房', value: '1' },
184
+        { label: '租房', value: '2' },
185
+        { label: '海外', value: '3' }
186
+      ]
187
+    },
188
+    {
189
+      name: 'verifyStatus',
190
+      label: '状态',
191
+      placeholder: '请选择状态',
192
+      type: 'select',
193
+      placeholder: '全部',//错误
194
+      options: [
195
+        { label: '全部', value: '' },
196
+        { label: '待回访', value: '0' },
197
+        { label: '已回访', value: '1' },
198
+        { label: '无效', value: '2' }
199
+      ]
200
+    },
207 201
   ]
208
- const actionRender = () => {
209
-  return (
210
-    <Button type="danger" loading={exportLoding} onClick={() => exportRecommendCustomer()}>
211
-      导出
212
-    </Button>
213
-  );
214
-};
202
+  const actionRender = () => {
203
+    return (
204
+      <Button type="danger" loading={exportLoding} onClick={() => exportRecommendCustomer()}>
205
+        导出
206
+      </Button>
207
+    );
208
+  };
215 209
 
216 210
   return (
217 211
     <>
218 212
       <QueryTable
219
-          rowKey="recommendCustomer"
220
-          // recommendCustomer
221
-          api={apis.searchHouse.list}
222
-          searchFields={searchFields}
223
-          columns={columns}
224
-          actionRender={actionRender}
225
-        />
226
-    
213
+        rowKey="recommendCustomer"
214
+        // recommendCustomer
215
+        api={apis.searchHouse.list}
216
+        searchFields={searchFields}
217
+        columns={columns}
218
+        actionRender={actionRender}
219
+      />
220
+
227 221
     </>
228 222
   );
229 223
 }

+ 79
- 0
src/pages/staff/Organization/TreeTitle.jsx 查看文件

@@ -0,0 +1,79 @@
1
+import { Icon } from 'antd';
2
+import { useState } from 'react';
3
+
4
+export default (props) => {
5
+    const [isEdit, setIsEdit] = useState(false)
6
+    const [inputVal, setInputVal] = useState()
7
+    const { onAdd, onDelete, isDelete, onChange, value } = props
8
+
9
+    const handleClose = () => {
10
+        setIsEdit(false)
11
+        setInputVal(value)
12
+    }
13
+
14
+    const handleSave = () => {
15
+        onChange(inputVal)
16
+        setIsEdit(false)
17
+        setInputVal()
18
+    }
19
+
20
+    if (isEdit) {
21
+        return (
22
+
23
+            <div>
24
+                {/* 逻辑运算 OR  */}
25
+                {/* item项目value根据状态切换 */}
26
+                {/*onChange这个API是一个函数,并且需要返回值,API的返回值是onChange方法的返回值
27
+                e就是api的形参,这个参数的生成需要onChange的API触发,同时将e传给方法并获取其返回值
28
+                实参把值给形参,由形参保存。
29
+                这个e会获取到最新的变化值并且传到onchange方法
30
+                */}
31
+                <input value={inputVal} onChange={(e) => setInputVal(e.target.value)} />
32
+
33
+                <Icon
34
+                    //取消保存
35
+                    type="close-circle"
36
+                    theme="filled"
37
+
38
+                    style={{ marginLeft: 10 }}
39
+                    onClick={handleClose}//恢复默认值 
40
+                />
41
+                <Icon
42
+                    //保存节点
43
+                    type="check-circle"
44
+                    theme="filled"
45
+                    style={{ marginLeft: 10 }}
46
+                    onClick={handleSave}
47
+                />
48
+            </div>
49
+        )
50
+    }
51
+
52
+    return (
53
+        <div >
54
+            <span>{value}</span>
55
+            <span>
56
+                {/* 编辑edit onclick 拿到项目的key */}
57
+                <Icon
58
+                    type="edit"
59
+                    style={{ marginLeft: 10 }}
60
+                    onClick={() => setIsEdit(true)}
61
+                />
62
+                {/* 编辑plus onclick 拿到项目的key */}
63
+                <Icon
64
+                    type="plus"
65
+                    style={{ marginLeft: 10 }}
66
+                    onClick={onAdd}
67
+                />
68
+                {/* 先确认父key是不是绝对等于"0" */}
69
+                {isDelete && (
70
+                    <Icon
71
+                        type="delete"
72
+                        style={{ marginLeft: 10 }}
73
+                        onClick={onDelete}
74
+                    />
75
+                )}
76
+            </span>
77
+        </div>
78
+    )
79
+}

+ 4
- 0
src/pages/staff/Organization/form.jsx 查看文件

@@ -0,0 +1,4 @@
1
+
2
+export default (props) => {
3
+
4
+}

+ 494
- 132
src/pages/staff/Organization/index.jsx 查看文件

@@ -1,140 +1,502 @@
1
+// import React, { useState } from "react";
2
+// import { Tree, Icon, Card } from "antd";
3
+// import { nanoid } from "nanoid";//生成唯一id
4
+// import { duration } from "moment";
5
+// import TreeTitle from './TreeTitle'
6
+
7
+// const { TreeNode } = Tree;
8
+// //树形数据
9
+// const treeData = [
10
+//   {
11
+//     value: "0",
12
+//     defaultValue: "0",
13
+//     key: "0",
14
+//     parentKey: '0',
15
+//     isEditable: false,
16
+//     children: [
17
+//       {
18
+//         value: "0",
19
+//         key: "0-1",
20
+//         defaultValue: "0-1",
21
+//         isEditable: false,
22
+//       },
23
+//     ],
24
+//   },
25
+
26
+// ];
27
+
28
+// const expandedKeyArr = ["0"];
29
+// export default function TreeDemo() {
30
+//   const [data, setData] = useState(treeData);//获取值,及时更新被修改的值。变量
31
+//   const [expandedKeys, setExpandedKeys] = useState(expandedKeyArr);//状态
32
+//   // const onExpand = (expandedKeys) => {
33
+//   //   //记录折叠的key值
34
+//   //   setExpandedKeys(expandedKeys);
35
+//   // };
36
+//   //开始渲染树形节点 data拿到数据
37
+//   const renderTreeNodes = (data) => {
38
+//     //遍历项目
39
+//     let nodeArr = data.map((item) => {
40
+
41
+//       const Title = (
42
+//         <TreeTitle
43
+//           value={item.value}
44
+//           isDelete={item.parentKey !== "0"}
45
+//           onAdd={() => onAdd(item.key)}
46
+//           onDelete={() => onDelete(item.key)}
47
+//           onChange={(val) => onChange(val, item.key)}
48
+//         />
49
+//       );
50
+//       if (item.children) {
51
+//         return (
52
+//           <TreeNode title={Title} key={item.key} dataRef={item}>
53
+//             {/* 渲染 */}
54
+//             {renderTreeNodes(item.children)}
55
+//           </TreeNode>
56
+//         );
57
+//       }
58
+//       //返回他的标题,和key值
59
+//       return <TreeNode title={Title} key={item.key} />;
60
+//     });
61
+//     //返回节点
62
+//     return nodeArr;
63
+//   }
64
+//   //新增
65
+//   const onAdd = (key) => {
66
+//     if (expandedKeys.indexOf(key) === -1) {
67
+//       expandedKeyArr.push(key);
68
+//     }
69
+//     setExpandedKeys(expandedKeyArr.slice());
70
+//     addNode(key, treeData);//添加节点 树形
71
+//     //useState里数据务必为immutable (不可赋值的对象),所以必须加上slice()返回一个新的数组对象
72
+//     setData(treeData.slice());//添加子项
73
+//   };
74
+//   //编辑
75
+//   //拿到key treeData数据--setData设置数据---slice删除数据中已返回的元素  [aa,bb,cc,dd,ee]--slice(2)输出[cc,dd,ee]
76
+//   const onEdit = (key) => {
77
+//     editNode(key, treeData);
78
+//     setData(treeData.slice());
79
+//   };
80
+//   const editNode = (key, data) =>
81
+//     data.forEach((item) => {
82
+//       if (item.key === key) {
83
+//         //编辑状态 true
84
+
85
+//         item.isEditable = true;
86
+//       } else {
87
+
88
+//         //编辑状态 false
89
+//         item.isEditable = false;
90
+//       }
91
+//       item.value = item.defaultValue; // 当某节点处于编辑状态,并改变数据,点击编辑其他节点时,此节点变成不可编辑状态,value 需要回退到 defaultvalue
92
+//       //当某子项处于编辑状态,改变数据,点击其他时候,此项变成不可编辑
93
+//       if (item.children) {
94
+//         editNode(key, item.children);
95
+//         //编辑子节点
96
+//       }
97
+//     });
98
+
99
+//   const addNode = (key, data) =>
100
+//     data.forEach((item) => {
101
+//       if (item.key === key) {//如果拿到的key相同则判断子项
102
+//         if (item.children) {
103
+//           item.children.push({
104
+//             value: "default",//创建新的子项默认值
105
+//             key: nanoid(), // 这个 key 应该是唯一的
106
+//           });
107
+//         } else {
108
+//           item.children = [];
109
+//           item.children.push({
110
+//             value: "default",
111
+//             key: nanoid(),
112
+//           });
113
+//         }
114
+//         return;
115
+//       }
116
+//       if (item.children) {
117
+//         addNode(key, item.children);
118
+//       }
119
+//     });
120
+
121
+//   const onChange = (val, key) => {
122
+//     changeNode(key, val, treeData);
123
+//     setData(treeData.slice());
124
+//   };
125
+
126
+//   const changeNode = (key, value, data) =>
127
+//     data.forEach((item) => {
128
+//       if (item.key === key) {//新增子项内容赋值
129
+//         item.value = value;
130
+//       }
131
+//       if (item.children) {
132
+//         changeNode(key, value, item.children);//子项
133
+//       }
134
+//     });
135
+
136
+//   //确认保存节点
137
+//   const saveNode = (key, data) =>
138
+//     data.forEach((item) => {
139
+//       if (item.key === key) {
140
+//         item.defaultValue = item.value;//item.value内容赋值给defaultValue
141
+//       }
142
+//       //子项保存不能编辑
143
+//       if (item.children) {
144
+//         saveNode(key, item.children);
145
+//       }
146
+//       //项目是否能编辑
147
+//       item.isEditable = false;
148
+//     });
149
+
150
+//   //取消确认
151
+//   const closeNode = (key, defaultValue, data) =>
152
+//     data.forEach((item) => {
153
+//       item.isEditable = false;
154
+//       if (item.key === key) {
155
+//         item.value = defaultValue;
156
+//       }
157
+//       if (item.children) {
158
+//         closeNode(key, defaultValue, item.children);
159
+//       }
160
+//     });
161
+//   // slice() 方法可提取字符串的某个部分,并以新的字符串返回被提取的部分。
162
+//   const onDelete = (key) => {
163
+//     deleteNode(key, treeData);
164
+//     setData(treeData.slice());
165
+//   };
166
+//   //删除节点
167
+//   const deleteNode = (key, data) =>
168
+//     //拿到每个key数据, 如果要删除的key相同,则删除,并返回。如果不同判断子项
169
+//     data.forEach((item, index) => {
170
+//       if (item.key === key) {
171
+//         data.splice(index, 1);//从某个位置开始删除元素
172
+//         return;
173
+//       } else {
174
+//         if (item.children) {
175
+//           deleteNode(key, item.children);
176
+//         }
177
+//       }
178
+//     });
179
+
180
+//   return (
181
+//     <div>
182
+//       <Card style={{ width: '90%' }}>
183
+//         <Tree
184
+//           switcherIcon={<Icon type="down-square" theme="filled" />}
185
+//           expandedKeys={expandedKeys}
186
+//         // onExpand={onExpand}
187
+//         >
188
+//           {renderTreeNodes(data)}
189
+//         </Tree>
190
+//       </Card>
191
+
192
+//     </div>
193
+//   );
194
+// }
195
+
196
+
197
+
198
+
199
+
200
+
201
+
202
+
203
+
204
+
205
+
206
+
207
+
208
+import { Row, Col, Card, Tree, DatePicker, Form, Input, InputNumber, Radio, Button } from 'antd'
209
+import React, { useEffect, useState, useCallback } from 'react';
210
+import ImageUpload from '@/components/XForm/ImageUpload';
211
+
212
+// import userTrees from './tree'
213
+
214
+const { TreeNode, DirectoryTree } = Tree
215
+const FormItem = Form.Item;
216
+
217
+
218
+
219
+
220
+const userTree = React.forwardRef((props, ref) => {
221
+  const [loading, setLoading] = useState(false);//防止多次点击 定义loadind
222
+  const [formData, setFormData] = useState();//提交表单的数据
223
+  const [contentType, setContentType] = useState(1);//单选。初始默认显示1 富文本框。点击视频, 渲染2
224
+  const { form, history } = props;
225
+  const { getFieldDecorator, setFieldsValue, validateFields } = form;
226
+  const { curriculumId } = history.location.query || {}
227
+
228
+
229
+  const formItemLayout = {
230
+    //布局
231
+    labelCol: { span: 6 },
232
+    wrapperCol: { span: 14 },
1 233
 
2
-import React, { Component,useState } from 'react';
3
-import { Card, Tree,Icon } from 'antd';
4
-import { render } from 'preact';
5
-import { turn } from 'cli-table';
6
-const { DirectoryTree,TreeNode } = Tree;
7
-const treeData = [
8
-  {
9
-    value:'江苏省公安厅',
10
-    defaultValue:'0',
11
-    parentKey:'0',
12
-    isEditable:false,
13
-    key:'0',
14
-    children:[
15
-      {
16
-        value:'南京分局',
17
-        key:'0-1',
18
-        defaultValue: "0-1",
19
-        isEditable: false,
20
-      },
21
-      {
22
-        value:'苏州分局',
23
-        key:'0-2',
24
-        defaultValue: "0-2",
25
-        isEditable: false,
26
-      },
27
-    ],
28
-  },
29
-];
30
-
31
-
32
-const expandedKeyArr=['0'];
33
-
34
-
35
-export default function TreeDemo() {
36
-  const[data,setData]=useState(treeData)//获取值,及时更新被修改的值。变量
37
-  const renderTreeNodes=(data)=>{
38
-    let nodeArr=data.map((item)=>{//遍历数据
39
-      item.title=(//修改
40
-        <div style={{display:'flex', minWidth: '100px'}}>
41
-          <span style={{ flex: 'auto' }}>{item.value}</span>
42
-          <span style={{ width: '6em', flex: 'none',marginLeft:'20px' }}>
43
-            {/* 编辑 */}
44
-            <Icon type="edit" onClick={()=>onDelete(item.key)} /> 
45
-            {/* 添加 */}
46
-            <Icon type="diff" onClick={()=>onAdd(item.key)} />
47
-            {/* 删除 */}
48
-            <Icon type="delete"  onClick={()=>onEdit(item.key)}/>
49
-          </span>
50
-        </div>
51
-      )
52
-      if(item.children){//如果有子项就返回下面组件
53
-        return(
54
-          <TreeNode title={item.title} key={item.key} dataRef={item}>
55
-            {renderTreeNodes(item.children)}
56
-            {/* 重新渲染节点 */}
57
-          </TreeNode>//title 接收的 ReactNode类型数据 自定义
58
-        )
59
-      }
60
-      //返回
61
-      return <TreeNode title={item.title} key={item.key} />
62
-    })
63
-      return nodeArr
64
-  };
65
-//添加
66
-  const onAdd=(key)=>{
67
-    // useState 里面数据是不能变的对象。需要slice返回一个新的数组
68
-    addNode(key.treeData);//添加节点 树形
69
-    setData(treeData.slice()) //设置 子项
70
-  }
71
-  //编辑
72
-  const onEdit=(key)=>{
73
-    editNode(key,treeData);
74
-    setData(treeData.slice());
75 234
   };
76
-  const editNode=(key,data)=>
77
-    data.forEach((item)=>{
78
-      if (item.key===key) {
79
-        item.isEditable=true;//可编辑状态更改
80
-      }else{
81
-        item.isEditable=false;
82
-      }
83
-      item.value=item.defaultValue;//当某子项处于编辑状态,改变数据,点击其他时候,此项变成不可编辑
84
-      if (item.children) {
85
-        editNode(key,item.children);
86
-      }
87
-    })  
88
-
89
-    //删除
90
-    const onDelete = (key) => {
91
-      deleteNode(key, treeData);
92
-      setData(treeData.slice());
93
-    };
94
-    const deleteNode = (key, data) =>
95
-      data.forEach((item, index) => {
96
-        if (item.key === key) {
97
-          data.splice(index, 1);//从某个位置开始删除元素
98
-          return;
99
-        } else {
100
-          if (item.children) {
101
-            deleteNode(key, item.children);
102
-          }
103
-        }
104
-      });
105
-
106
-  const addNode=(key,data)=>
107
-    data.forEach((item)=>{
108
-      if(item.key===key){//如果拿到的key相同则判断子项
109
-        if (item.children) {
110
-          item.children.push({
111
-            value:"请输入内容",
112
-            key:key+Math.random(100),//随机唯一的key
113
-          });
114
-        }
115
-        return;
116
-      }
117
-      if (item.children) {
118
-        addNode(key,item.children)//子项
119
-      }
120
-    })
235
+
121 236
   return (
122
-    <div>
123
-      <Card style={{width:'90%'}}>
124
-        <Tree 
125
-        switcherIcon={<Icon type="down-square" theme="filled" />}
126
-        // icon={<Icon type="carry-out" />}
127
-        style={{paddingLeft:'60px'}} 
128
-        treeData={treeData}  >
129
-        {renderTreeNodes(data)}
130
-        </Tree>
131
-        {/* 渲染被更新 */}
132
-      </Card>
133
-    </div>
134
-  );
135
-}
237
+    <Card>
238
+      <Row justify='center'>
239
+        <Col xs={{ span: 5, offset: 1 }} lg={{ span: 6, offset: 0 }}>
240
+          <Card>
241
+            <Button type='danger' style={{ marginLeft: '2em' }} >
242
+              删除
243
+            </Button>
244
+            <DirectoryTree multiple>
245
+              <TreeNode title="parent 0" key="0-0">
246
+                <TreeNode title="leaf 0-0" key="0-0-0" isLeaf />
247
+                <TreeNode title="leaf 0-1" key="0-0-1" isLeaf />
248
+              </TreeNode>
249
+              <TreeNode title="parent 1" key="0-1">
250
+                <TreeNode title="leaf 1-0" key="0-1-0" isLeaf />
251
+                <TreeNode title="leaf 1-1" key="0-1-1" isLeaf />
252
+                <TreeNode title="leaf 1-1" key="0-1-2" isLeaf />
253
+                <TreeNode title="leaf 1-1" key="0-1-3" isLeaf />
254
+                <TreeNode title="leaf 1-1" key="0-1-4" isLeaf />
255
+                <TreeNode title="leaf 1-1" key="0-1-5" isLeaf />
256
+              </TreeNode>
257
+            </DirectoryTree>
258
+          </Card>
259
+        </Col>
260
+        {/* FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF>Form表单 */}
261
+        <Col xs={{ span: 10, offset: 10 }} lg={{ span: 10, offset: 4 }}>
262
+          <Card>
263
+            <Form {...formItemLayout} >
264
+              <FormItem label="照片" help="建议尺寸:750px*600px,比例5:4,格式:jpg,用于:列表和详情">
265
+                {
266
+                  getFieldDecorator('curriculumImg', {
267
+                    rules: [
268
+                      { required: true, message: '请上传照片' }
269
+                    ]
270
+                  })(
271
+                    <ImageUpload />
272
+                  )
273
+                }
274
+              </FormItem>
275
+              <FormItem label="姓名">
276
+                {
277
+                  getFieldDecorator('name', {
278
+                    rules: [
279
+                      { required: true, message: '请输入姓名' }
280
+                    ]
281
+                  })(
282
+                    <Input style={{ width: '88px' }} />
283
+                  )
284
+                }
285
+              </FormItem>
286
+              <FormItem label="年龄" >
287
+                {
288
+                  getFieldDecorator('weight', {
289
+                    rules: [{ required: true, message: '请输入年龄' }]
290
+                  })(
291
+                    <InputNumber min='18' />
292
+                  )
293
+                }
294
+              </FormItem>
295
+
296
+              <FormItem label="性别">
297
+                {
298
+                  getFieldDecorator('type', {
299
+                    rules: [
300
+                      { required: true, message: '请选择性别' }
301
+                    ]
302
+                  })(
303
+                    <Radio.Group value={contentType} style={{ width: '500px' }} defaultValue={1}>
304
+                      {/* onChange={e => setContentType(e.target.value)} */}
305
+                      <Radio value={1}>男</Radio>
306
+                      <Radio value={2}>女</Radio>
307
+                    </Radio.Group>
308
+                  )
309
+                }
310
+              </FormItem>
311
+              <Form.Item label="工作总时间" style={{ marginBottom: 0 }} help="如未离职,第二个日期则不用输入">
312
+                <Form.Item style={{ display: 'inline-block' }} >
313
+                  <DatePicker />
314
+                </Form.Item>
315
+                <span style={{ display: 'inline-block', width: '20px', textAlign: 'center' }}>至</span>
316
+                <Form.Item style={{ display: 'inline-block' }}>
317
+                  <DatePicker />
318
+                </Form.Item>
319
+              </Form.Item>
320
+
321
+              <FormItem wrapperCol={{ span: 12, offset: 6 }}>
322
+                <Button loading={loading} type="primary" htmlType="">
323
+                  确认修改
324
+                </Button>
325
+              </FormItem>
326
+            </Form>
327
+          </Card>
328
+        </Col>
329
+      </Row>
330
+    </Card>
331
+
332
+  )
333
+})
334
+
335
+
336
+
337
+// import React, { useEffect, useState, useCallback } from 'react';
338
+// import { Button, Form, Select, Input, InputNumber, Radio, message, DatePicker, Card } from 'antd';
339
+// import ImageUpload from '@/components/XForm/ImageUpload';
340
+// import FileUpload from '@/components/XForm/FileUpload';
341
+// import Wangedit from '@/components/Wangedit/Wangedit';
342
+// import router from 'umi/router';
343
+// import { fetch, apis } from '@/utils/request';
344
+
345
+// const FormItem = Form.Item;
346
+// const Option = Select.Option;
347
+// // const getCurriculumData = fetch(apis.course.searchCourse);
348
+// // const saveCurriculumData = fetch(apis.course.addCourse);
349
+// // const updateCurriculumData = fetch(apis.course.alterCourse);
350
+// const goBack = () => router.goBack(-1);
351
+
352
+// const userTree = React.forwardRef((props, ref) => {
353
+//   const [loading, setLoading] = useState(false);//防止多次点击 定义loadind
354
+//   const [formData, setFormData] = useState();//提交表单的数据
355
+//   const [contentType, setContentType] = useState(1);//单选。初始默认显示1 富文本框。点击视频, 渲染2
356
+//   const { form, history } = props;
357
+//   const { getFieldDecorator, setFieldsValue, validateFields } = form;
358
+//   const { curriculumId } = history.location.query || {}
359
+
360
+//   const formItemLayout = {
361
+//     //布局
362
+//     labelCol: { span: 6 },
363
+//     wrapperCol: { span: 14 },
364
+
365
+//   };
366
+
367
+//   const handleSubmit = (e) => {
368
+//     e.preventDefault();
369
+//     validateFields((err, values) => {
370
+//       if (err) {
371
+//         return;
372
+//         //字符验证未填写---返回
373
+//       }
374
+
375
+//       setLoading(true);//loading开始
376
+
377
+//       if (curriculumId) {
378
+//         //如果有这个id拿。没有就,拿返回的curriculumId
379
+//         updateCurriculumData({
380
+//           data: {
381
+//             ...values,
382
+//             curriculumId
383
+//           },
384
+//           urlData: { id: curriculumId }
385
+//         }).then(() => {
386
+//           setLoading(false);
387
+//           message.success('数据更新成功');
388
+//           goBack()
389
+//         }).catch((err) => {
390
+//           setLoading(false);//loading消失
391
+//           message.error(err.message || err);
392
+//         })
393
+//       } else {
394
+//         saveCurriculumData({ data: values }).then(() => {
395
+//           setLoading(false);
396
+//           message.success('数据保存成功');
397
+//           goBack()
398
+//         }).catch((err) => {
399
+//           setLoading(false);//loading消失
400
+//           message.error(err.message || err);
401
+//         })
402
+//       }
403
+//     });
404
+//   }
405
+
406
+//   const getCourseData = useCallback(({ curriculumId }) => {//函数结果存 初始化运行一次,等待调用。
407
+//     getCurriculumData({ urlData: { id: curriculumId } }).then((res) => {
408
+//       setFormData(res)
409
+//     })
410
+//   }, [])
411
+
412
+//   useEffect(() => {
413
+//     if (curriculumId) {
414
+//       getCourseData({ curriculumId })//第一次渲染前//获取id
415
+//     }
416
+//   }, [curriculumId])//第二次id一样不执行
417
+
418
+//   useEffect(() => {
419
+//     if (formData) {//1.form表单数据{2} 执行。无变更不执行
420
+//       setFieldsValue(formData)
421
+//     }
422
+//   }, [formData])//2.有变更跟的话
423
+
136 424
 
425
+//   return (
426
+//     <Card>
427
+//       <Form {...formItemLayout} onSubmit={handleSubmit}>
428
+//         <FormItem label="照片" help="建议尺寸:750px*600px,比例5:4,格式:jpg,用于:列表和详情">
429
+//           {
430
+//             getFieldDecorator('curriculumImg', {
431
+//               rules: [
432
+//                 { required: true, message: '请上传照片' }
433
+//               ]
434
+//             })(
435
+//               <ImageUpload />
436
+//             )
437
+//           }
438
+//         </FormItem>
439
+//         <FormItem label="姓名">
440
+//           {
441
+//             getFieldDecorator('name', {
442
+//               rules: [
443
+//                 { required: true, message: '请输入姓名' }
444
+//               ]
445
+//             })(
446
+//               <Input style={{ width: '88px' }} />
447
+//             )
448
+//           }
449
+//         </FormItem>
450
+//         <FormItem label="年龄" >
451
+//           {
452
+//             getFieldDecorator('weight', {
453
+//               rules: [{ required: true, message: '请输入年龄' }]
454
+//             })(
455
+//               <InputNumber min='18' />
456
+//             )
457
+//           }
458
+//         </FormItem>
137 459
 
460
+//         <FormItem label="性别">
461
+//           {
462
+//             getFieldDecorator('type', {
463
+//               rules: [
464
+//                 { required: true, message: '请选择性别' }
465
+//               ]
466
+//             })(
467
+//               <Radio.Group value={contentType} style={{ width: '500px' }} defaultValue={1}>
468
+//                 {/* onChange={e => setContentType(e.target.value)} */}
469
+//                 <Radio value={1}>男</Radio>
470
+//                 <Radio value={2}>女</Radio>
471
+//               </Radio.Group>
472
+//             )
473
+//           }
474
+//         </FormItem>
475
+//         <Form.Item label="工作总时间" style={{ marginBottom: 0 }} help="如未离职,第二个日期则不用输入">
476
+//           <Form.Item style={{ display: 'inline-block' }} >
477
+//             <DatePicker />
478
+//           </Form.Item>
479
+//           <span style={{ display: 'inline-block', width: '20px', textAlign: 'center' }}>至</span>
480
+//           <Form.Item style={{ display: 'inline-block' }}>
481
+//             <DatePicker />
482
+//           </Form.Item>
483
+//         </Form.Item>
138 484
 
485
+//         <FormItem wrapperCol={{ span: 12, offset: 6 }}>
486
+//           <Button loading={loading} type="primary" htmlType="">
487
+//             保存
488
+//           </Button>
489
+//           <Button style={{ marginLeft: '2em' }} onClick={goBack}>
490
+//             返回
491
+//           </Button>
492
+//           <Button type='danger' style={{ marginLeft: '2em' }} >
493
+//             删除
494
+//           </Button>
495
+//         </FormItem>
496
+//       </Form>
497
+//     </Card>
139 498
 
499
+//   )
500
+// })
140 501
 
502
+export default Form.create({})(userTree);

+ 18
- 0
src/pages/staff/Organization/tree.jsx 查看文件

@@ -0,0 +1,18 @@
1
+import { Tree } from 'antd'
2
+
3
+export default (props) => {
4
+    const { TreeNode, DirectoryTree } = Tree
5
+
6
+    return (
7
+        <DirectoryTree multiple>
8
+            <TreeNode title="parent 0" key="0-0">
9
+                <TreeNode title="leaf 0-0" key="0-0-0" isLeaf />
10
+                <TreeNode title="leaf 0-1" key="0-0-1" isLeaf />
11
+            </TreeNode>
12
+            <TreeNode title="parent 1" key="0-1">
13
+                <TreeNode title="leaf 1-0" key="0-1-0" isLeaf />
14
+                <TreeNode title="leaf 1-1" key="0-1-1" isLeaf />
15
+            </TreeNode>
16
+        </DirectoryTree>
17
+    )
18
+}

+ 2
- 2
src/pages/system/Sellhouse/index.jsx 查看文件

@@ -163,7 +163,7 @@ export default props => {
163 163
       align: 'center',
164 164
       with: 300,
165 165
       // ellipsis: true,
166
-      render:(_,record)=><span>{record.houseName='高奢生活,在遇到它之前你想象不到'}</span>
166
+      // render:(_,record)=><span>{record.houseName='高奢生活,在遇到它之前你想象不到'}</span>
167 167
     },
168 168
     {
169 169
       title: '城市',
@@ -171,7 +171,7 @@ export default props => {
171 171
       dataIndex: 'houseType',
172 172
       align: 'center',
173 173
       // render: t => t.newsTypeName,
174
-      render:(_,record)=><span>{record.houseType='南京'}</span>
174
+      // render:(_,record)=><span>{record.houseType='南京'}</span>
175 175
 
176 176
     },
177 177
     {

+ 99
- 97
src/pages/system/housingPolicy/Edit/index.jsx 查看文件

@@ -1,5 +1,5 @@
1 1
 import React, { useState, useEffect } from 'react';
2
-import { Form, Input, Button, Icon, Select, Tabs, Radio, DatePicker,message } from 'antd';
2
+import { Form, Input, Button, Icon, Select, Tabs, Radio, DatePicker, message, Card } from 'antd';
3 3
 
4 4
 import moment from 'moment';
5 5
 import router from 'umi/router';
@@ -16,118 +16,120 @@ const { MonthPicker, RangePicker, WeekPicker } = DatePicker;
16 16
  * @param {*} props
17 17
  * @returns
18 18
  */
19
- const Edit = (props) => {
19
+const Edit = (props) => {
20 20
   const policyId = props.location.query.policyId
21
-  const [ policyData, setPolicyData ] = useState({})
22
-  if(policyId){
21
+  const [policyData, setPolicyData] = useState({})
22
+  if (policyId) {
23 23
     useEffect(() => {
24 24
       getPolicyData(policyId);
25
-    },[])
25
+    }, [])
26 26
 
27
-  // 查询列表
28
-  const getPolicyData = (policyId) => {
29
-    request({ ...apis.system.taPolicy, urlData: {id: policyId} }).then((data) => {
27
+    // 查询列表
28
+    const getPolicyData = (policyId) => {
29
+      request({ ...apis.system.taPolicy, urlData: { id: policyId } }).then((data) => {
30 30
         console.log(data)
31 31
         setPolicyData(data)
32
-    })
33
-  }
32
+      })
33
+    }
34 34
   }
35 35
 
36
-  const cancelPage = () =>{
36
+  const cancelPage = () => {
37 37
     router.push({
38 38
       pathname: '/system/housingPolicy',
39 39
     });
40 40
   }
41
-    const fields = [
42
-      {
43
-        label: '城市',
44
-        name: 'cityId',
45
-        render: <SelectCity />,
46
-        value: policyData.cityId,
47
-        rules: [
48
-          {
49
-            required: true,
50
-            message: '请选择城市',
51
-          },
52
-        ],
53
-      },
54
-      {
55
-        label: '购房须知封面图',
56
-        name: 'policyImg',
57
-        type: FieldTypes.ImageUploader,
58
-        value: policyData.policyImg,
59
-        help: '建议图片尺寸:220*176px,比例5:4,格式:jpg,用于购房须知列表',
60
-        rules: [
61
-          {
62
-            required: true,
63
-            message: '请选择购房须知封面图',
64
-          },
65
-        ],
66
-      },
67
-      {
68
-        label: '购房须知标题',
69
-        name: 'title',
70
-        type: FieldTypes.Text,
71
-        value: policyData.title,
72
-        rules: [
73
-          {
74
-            required: true,
75
-            message: '请输入购房须知标题',
76
-          },
77
-        ],
78
-      },
79
-      {
80
-        label: '购房须知详情',
81
-        name: 'body',
82
-        render: <Wangedit />,
83
-        value: policyData.body,
84
-        rules: [
85
-          {
86
-            required: true,
87
-            message: '请输入购房须知详情',
88
-          },
89
-        ],
90
-      },
91
-      {
92
-        label: '状态',
93
-        name: 'publishStatus',
94
-        type: FieldTypes.Select,
95
-        dict: [{label:"未发布",value:0},{label:"已发布",value:1}],
96
-        value: policyData.publishStatus != null ? policyData.publishStatus : 1,
97
-      },
98
-    ]
99
-  
100
-    const handleSubmit = val => { 
101
-      console.log('submit data --->', val)
102
-      console.log(val.body, 'val.body')
103
-      if (val.body == '<p><br></p>'){
104
-        message.info("购房须知详情必填")
105
-        return
106
-      }
107
-      
108
-      if(policyId){
109
-        val.policyId = policyId
110
-        request({ ...apis.system.updateTaPolicy, urlData: {id: policyId},data: val, }).then((data) => {
111
-          message.info("保存成功")
112
-          cancelPage()
113
-        }).catch((err) => {
114
-          message.info(err.msg || err.message)
115
-        })
116
-      }else{
117
-        request({ ...apis.system.addTaPolicy,data: val, }).then((data) => {
118
-          message.info("保存成功")
119
-          cancelPage()
120
-        }).catch((err) => {
121
-          message.info(err.msg || err.message)
122
-        })
123
-      }
41
+  const fields = [
42
+    {
43
+      label: '城市',
44
+      name: 'cityId',
45
+      render: <SelectCity />,
46
+      value: policyData.cityId,
47
+      rules: [
48
+        {
49
+          required: true,
50
+          message: '请选择城市',
51
+        },
52
+      ],
53
+    },
54
+    {
55
+      label: '购房须知封面图',
56
+      name: 'policyImg',
57
+      type: FieldTypes.ImageUploader,
58
+      value: policyData.policyImg,
59
+      help: '建议图片尺寸:220*176px,比例5:4,格式:jpg,用于购房须知列表',
60
+      rules: [
61
+        {
62
+          required: true,
63
+          message: '请选择购房须知封面图',
64
+        },
65
+      ],
66
+    },
67
+    {
68
+      label: '购房须知标题',
69
+      name: 'title',
70
+      type: FieldTypes.Text,
71
+      value: policyData.title,
72
+      rules: [
73
+        {
74
+          required: true,
75
+          message: '请输入购房须知标题',
76
+        },
77
+      ],
78
+    },
79
+    {
80
+      label: '购房须知详情',
81
+      name: 'body',
82
+      render: <Wangedit />,
83
+      value: policyData.body,
84
+      rules: [
85
+        {
86
+          required: true,
87
+          message: '请输入购房须知详情',
88
+        },
89
+      ],
90
+    },
91
+    {
92
+      label: '状态',
93
+      name: 'publishStatus',
94
+      type: FieldTypes.Select,
95
+      dict: [{ label: "未发布", value: 0 }, { label: "已发布", value: 1 }],
96
+      value: policyData.publishStatus != null ? policyData.publishStatus : 1,
97
+    },
98
+  ]
99
+
100
+  const handleSubmit = val => {
101
+    console.log('submit data --->', val)
102
+    console.log(val.body, 'val.body')
103
+    if (val.body == '<p><br></p>') {
104
+      message.info("购房须知详情必填")
105
+      return
124 106
     }
125
-     
107
+
108
+    if (policyId) {
109
+      val.policyId = policyId
110
+      request({ ...apis.system.updateTaPolicy, urlData: { id: policyId }, data: val, }).then((data) => {
111
+        message.info("保存成功")
112
+        cancelPage()
113
+      }).catch((err) => {
114
+        message.info(err.msg || err.message)
115
+      })
116
+    } else {
117
+      request({ ...apis.system.addTaPolicy, data: val, }).then((data) => {
118
+        message.info("保存成功")
119
+        cancelPage()
120
+      }).catch((err) => {
121
+        message.info(err.msg || err.message)
122
+      })
123
+    }
124
+  }
125
+
126 126
 
127 127
   return (
128
-    <XForm onSubmit={handleSubmit} onCancel={cancelPage} fields={fields}></XForm>
128
+    <Card>
129
+      <XForm onSubmit={handleSubmit} onCancel={cancelPage} fields={fields}></XForm>
130
+    </Card>
129 131
   );
130
- }
132
+}
131 133
 
132 134
 
133 135
 

+ 1
- 1
src/utils/image.js 查看文件

@@ -3,5 +3,5 @@ export function getImgURL(img) {
3 3
     if (!img) return undefined;
4 4
 
5 5
     const isProd = process.env.NODE_ENV === 'production'
6
-    return isProd ? img : `http://81.69.196.8:8567${img}`;
6
+    return isProd ? img : `https://xlk.njyz.tech${img}`;
7 7
 }