张延森 3 년 전
부모
커밋
8613ca701f
5개의 변경된 파일96개의 추가작업 그리고 23개의 파일을 삭제
  1. 2
    1
      config/proxy.js
  2. 0
    1
      config/routes.js
  3. 73
    18
      src/pages/building/Edit/Channel.jsx
  4. 18
    0
      src/services/apis.js
  5. 3
    3
      src/utils/request.js

+ 2
- 1
config/proxy.js 파일 보기

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

+ 0
- 1
config/routes.js 파일 보기

@@ -86,7 +86,6 @@ export default [
86 86
                 hideInMenu: true,
87 87
                 component: './customer/Customer/PrivateCustomer/CustomerDetail',
88 88
               },
89
-
90 89
               // {
91 90
               //   path: '/customer/customerlist/list',
92 91
               //   name: '客户列表old',

+ 73
- 18
src/pages/building/Edit/Channel.jsx 파일 보기

@@ -1,35 +1,90 @@
1
-import React from 'react'
2
-import { Button, Form, Input, Select } from 'antd'
1
+import React, { useEffect, useState } from 'react'
2
+import { connect } from 'dva';
3
+import { Button, Form, Input, message, Select } from 'antd'
4
+import { fetch, apis } from '@/utils/request'
3 5
 import InputNumber from './components/InputNumber'
4 6
 import { formItemLayout, validMinNum } from './utils'
5 7
 
6
-const ChannelForm = (props) => {
7
-  const { form } = props
8
-  const { getFieldDecorator } = form
8
+const getChannel = fetch(apis.building.channel.get)
9
+// const saveChannel = fetch(apis.building.channel.save)
10
+const updateChannel = fetch(apis.building.channel.update)
11
+const getChannelDict = fetch(apis.channelList.getList)
12
+
13
+const ChannelForm = React.forwardRef((props, ref) => {
14
+  const { form, history, user } = props
15
+  const { getFieldDecorator, setFieldsValue, validateFields } = form
16
+  const { query } = history.location;
17
+  const { id } = query;
18
+
19
+  const [loading, setLoading] = useState(false)
20
+  const [dict, setDict] = useState([])
21
+
22
+  const handleSubmit = (e) => {
23
+    e.preventDefault();
24
+    validateFields((err, values) => {
25
+      if (!err) {
26
+        const data = {
27
+          ...values,
28
+          buildingId: id,
29
+        }
30
+
31
+        setLoading(true)
32
+        updateChannel({ data }).then(() => {
33
+          setLoading(false)
34
+          message.success('数据保存成功')
35
+        }).catch(() => {
36
+          setLoading(false)
37
+        })
38
+      }
39
+    });
40
+  }
41
+
42
+  useEffect(() => {
43
+    getChannelDict({ params: { pageSize: 500, institutionId: user.institutionId }}).then((res) => {
44
+      const { records } = res || {}
45
+      if (records?.length) {
46
+        setDict(records)
47
+      }
48
+    })
49
+  }, [])
50
+
51
+  useEffect(() => {
52
+    if (id) {
53
+      getChannel({ urlData: { id } }).then((res) => {
54
+        if (res) {
55
+          setFieldsValue(res)
56
+        }
57
+      })
58
+    }
59
+  }, [id])
9 60
 
10 61
   return (
11
-    <Form {...formItemLayout}>
62
+    <Form {...formItemLayout} onSubmit={handleSubmit}>
12 63
       <Form.Item label="渠道">
13
-      {getFieldDecorator('shareContentTitle', {
14
-        rules: [{required: true, message: '请填写分享标题'}]
15
-      })(<Select />)}
64
+      {getFieldDecorator('channelIdList', {
65
+        rules: [{required: true, message: '请选择渠道'}]
66
+      })(
67
+        <Select mode="multiple" style={{ width: '100%' }}>
68
+          {
69
+            dict.map((item) => (<Select.Option key={item.channelId} value={`${item.channelId}`}>{item.channelName}</Select.Option>))
70
+          }          
71
+        </Select>
72
+      )}
16 73
       </Form.Item>
17 74
       <Form.Item label="报备有效期">
18
-      {getFieldDecorator('posterImg', {
75
+      {getFieldDecorator('expirationDate', {
19 76
           rules: [{ validator: validMinNum }],
20 77
       })(<InputNumber min={0} step={1} addonAfter="天" />)}
21 78
       </Form.Item>
22
-      <Form.Item label="报备有效期">
23
-      {getFieldDecorator('posterImg', {
24
-          rules: [{ validator: validMinNum }],
25
-      })(<Input.TextArea row={4} />)}
79
+      <Form.Item label="报备规则">
80
+      {getFieldDecorator('remark', {})(<Input.TextArea row={4} />)}
26 81
       </Form.Item>
27 82
       <Form.Item label=" " colon={false} style={{marginTop: '2em'}}>
28
-        <Button style={{marginLeft: '4em'}} type="primary" htmlType="submit">保存</Button>
29
-        <Button style={{marginLeft: '2em'}} onClick={props.onCancel}>取消</Button>
83
+        <Button style={{marginLeft: '4em'}} loading={loading} type="primary" htmlType="submit">保存</Button>
84
+        {/* <Button style={{marginLeft: '2em'}} onClick={props.onCancel}>取消</Button> */}
30 85
       </Form.Item>
31 86
     </Form>
32 87
   )
33
-}
88
+})
34 89
 
35
-export default Form.create({})(ChannelForm)
90
+export default connect((s) => ({ user: s.user.currentUser }))(Form.create({})(ChannelForm))

+ 18
- 0
src/services/apis.js 파일 보기

@@ -201,6 +201,24 @@ export default {
201 201
       method: 'DELETE',
202 202
       action: 'admin.marketing.id.delete',
203 203
     },
204
+    // 渠道
205
+    channel: {
206
+      get: {
207
+        url: `${prefix}/buildingChannel/:id`,
208
+        method: 'GET',
209
+        action: 'admin.building.channel.get',
210
+      },
211
+      save: {
212
+        url: `${prefix}/buildingChannel`,
213
+        method: 'POST',
214
+        action: 'admin.building.channel.post',
215
+      },
216
+      update: {
217
+        url: `${prefix}/buildingChannel`,
218
+        method: 'PUT',
219
+        action: 'admin.building.channel.post',
220
+      }
221
+    }
204 222
   },
205 223
   buildingType: {
206 224
     getList: {

+ 3
- 3
src/utils/request.js 파일 보기

@@ -82,7 +82,7 @@ request.interceptors.response.use(async (response, options) => {
82 82
     } else {
83 83
       // console.log('response.headers: ', response.headers)
84 84
       // console.log('response.headers.Content-Type: ', response.headers.get('Content-Type'))
85
-      console.log(response,'response')
85
+      // console.log(response,'response')
86 86
       if (response.headers.get('Content-Type') === 'application/octet-stream;charset=utf-8') {
87 87
         return await response.clone().blob();
88 88
       }
@@ -91,9 +91,9 @@ request.interceptors.response.use(async (response, options) => {
91 91
       if (response.url.indexOf('gaode_amap') !== -1) {
92 92
         return await response.clone().json();
93 93
       }
94
-      console.log(response,'response')
94
+      // console.log(response,'response')
95 95
       const { code, data, message } = await response.clone().json();
96
-     
96
+
97 97
       if (code != 1000) {
98 98
         if (code === 1001) {
99 99
           // notification.error({