张延森 2 年之前
父節點
當前提交
d904f6b1c3
共有 4 個檔案被更改,包括 194 行新增69 行删除
  1. 6
    0
      config/routes.js
  2. 107
    0
      src/pages/borker/agentRule/index.jsx
  3. 71
    69
      src/pages/borker/announcement/Edit/index.jsx
  4. 10
    0
      src/services/apis.js

+ 6
- 0
config/routes.js 查看文件

@@ -579,6 +579,12 @@ export default [
579 579
                 component: './borker/list/index',
580 580
                 menuCode: '/borker/list',
581 581
               },
582
+              {
583
+                path: '/borker/agentRule',
584
+                name: '经纪人规则',
585
+                component: './borker/agentRule/index',
586
+                menuCode: '/borker/agentRule',
587
+              },
582 588
             ],
583 589
           },
584 590
           {

+ 107
- 0
src/pages/borker/agentRule/index.jsx 查看文件

@@ -0,0 +1,107 @@
1
+import React, { useEffect, useState } from 'react'
2
+import { Spin, Card, Form, Select, Input, Button, notification } from 'antd'
3
+import Wangedit from '@/components/Wangedit/Wangedit';
4
+import { fetch, apis } from '@/utils/request';
5
+
6
+const FormItem = Form.Item
7
+const formItemLayout = {
8
+  labelCol: {
9
+    xs: { span: 24 },
10
+    sm: { span: 3 },
11
+  },
12
+  wrapperCol: {
13
+    xs: { span: 24 },
14
+    sm: { span: 19 },
15
+  },
16
+}
17
+
18
+const editorMenus = [
19
+  'head', // 标题
20
+  'bold', // 粗体
21
+  'italic', // 斜体
22
+  'underline', // 下划线
23
+  'strikeThrough', // 删除线
24
+  'indent', // 缩进
25
+  'lineHeight', // 行高
26
+  'foreColor', // 文字颜色
27
+  'list', // 列表
28
+  'justify', // 对齐方式
29
+  'quote', // 引用
30
+  'undo', // 撤销
31
+];
32
+
33
+const getAgentRule = fetch(apis.borker.getAgentRule)
34
+const saveAgentRule = fetch(apis.borker.saveAgentRule)
35
+
36
+const AgentRule = React.forwardRef((props, ref) => {
37
+  const { getFieldDecorator, validateFieldsAndScroll, setFieldsValue } = props.form
38
+
39
+  const [loading, setLoading] = useState(false)
40
+  const [detail, setDetail] = useState({})
41
+
42
+  const handleSubmit = (e) => {
43
+    validateFieldsAndScroll((err, values) => {
44
+      if (err) return;
45
+
46
+      setLoading(true)
47
+      saveAgentRule({ data: { ...(detail || {}), ...values } }).then(res => {
48
+        setDetail(res)
49
+        setLoading(false)
50
+        notification.success({ message: "操作成功" })
51
+      }).catch(() => {
52
+        setLoading(false)
53
+      })
54
+    })
55
+
56
+    return false;
57
+  }
58
+
59
+  useEffect(() => {
60
+    setLoading(true)
61
+    getAgentRule().then(res => {
62
+      // ant3 的 form 赋值很诡异
63
+      const t = setTimeout(() => {
64
+        clearTimeout(t)
65
+        setLoading(false)
66
+        setDetail(res)
67
+        setFieldsValue({
68
+          content: (res || {}).content,
69
+          status: (res || {}).status,
70
+        })
71
+      }, 200)
72
+    }).catch(() => {
73
+      setLoading(false)
74
+    })
75
+  }, [])
76
+
77
+  return (
78
+    <Card>
79
+      <Spin spinning={loading}>
80
+        <Form {...formItemLayout} onSubmit={handleSubmit}>
81
+          <FormItem label="规则详情">
82
+            { 
83
+              getFieldDecorator('content')(<Wangedit menus={editorMenus} />)
84
+            }
85
+          </FormItem>
86
+          <FormItem label="发布状态">
87
+            { 
88
+              getFieldDecorator('status')(
89
+                <Select>
90
+                  <Select.Option value={1}>发布</Select.Option>
91
+                  <Select.Option value={0}>未发布</Select.Option>
92
+                </Select>
93
+              )
94
+            }
95
+          </FormItem>
96
+          <FormItem colon={false} label=" ">
97
+            <Button type="primary" htmlType="submit" loading={loading}>
98
+              提交
99
+            </Button>
100
+          </FormItem>
101
+        </Form>
102
+      </Spin>
103
+    </Card>
104
+  )
105
+})
106
+
107
+export default Form.create()(AgentRule)

+ 71
- 69
src/pages/borker/announcement/Edit/index.jsx 查看文件

@@ -1,5 +1,5 @@
1 1
 import React, { useEffect, useState } from 'react'
2
-import { Row, Col, Card, Form, Select, Input, Button, notification } from 'antd'
2
+import { Spin, Card, Form, Select, Input, Button, notification } from 'antd'
3 3
 import SelectCity from '@/components/SelectButton/CitySelect'
4 4
 import ImageUpload from '@/components/XForm/ImageUpload'
5 5
 import Wangedit from '@/components/Wangedit/Wangedit';
@@ -76,74 +76,76 @@ const AnnouncementEdit = React.forwardRef((props, ref) => {
76 76
   }, [id, setFieldsValue])
77 77
 
78 78
   return (
79
-    <Card loading={loading}>
80
-      <Form {...formItemLayout} onSubmit={handleSubmit}>
81
-        <FormItem label="公告类型">
82
-          {
83
-            getFieldDecorator('showType', {
84
-              rules: [{ required: true, message: '请填写标题' }],
85
-            })(
86
-              <Select style={fullWidth} allowClear>
87
-                {
88
-                  showTypeList.map(x => <Option key={x.value} value={x.value}>{x.label}</Option>)
89
-                }
90
-              </Select>
91
-            )
92
-          }
93
-        </FormItem>
94
-        <FormItem label="公告图片" help="建议图片尺寸:640*960px,比例2:3,格式:jpg">
95
-          {
96
-            getFieldDecorator('imageUrl', {
97
-              rules: [{ required: true, message: '公告图片' }],
98
-            })(<ImageUpload />)
99
-          }
100
-        </FormItem>
101
-        <FormItem label="公告标题">
102
-          {
103
-            getFieldDecorator('title', {
104
-              rules: [{ required: true, message: '请填写标题' }],
105
-            })(<Input />)
106
-          }
107
-        </FormItem>
108
-        <FormItem label="所属城市">
109
-          {
110
-            getFieldDecorator('cityId', {
111
-              rules: [{ required: true, message: '请选择城市' }],
112
-            })(
113
-              <SelectCity style={fullWidth} />,
114
-            )
115
-          }
116
-        </FormItem>
117
-        <FormItem label="跳转页面">
118
-          {
119
-            getFieldDecorator('linkPage')(
120
-              <Select style={fullWidth} allowClear>
121
-                {
122
-                  pages.map(x => <Option key={x.page} value={x.page}>{x.title}</Option>)
123
-                }
124
-              </Select>
125
-            )
126
-          }
127
-        </FormItem>
128
-        <FormItem label="页面参数">
129
-          {
130
-            getFieldDecorator('pageParam')(<Input placeholder="key1=value1&key2=value2" />)
131
-          }
132
-        </FormItem>
133
-        <FormItem label="公告详情">
134
-          { 
135
-            getFieldDecorator('content')(<Wangedit menus={editorMenus} />)
136
-          }
137
-        </FormItem>
138
-        <FormItem colon={false} label=" ">
139
-          <Button type="primary" htmlType="submit" loading={loading}>
140
-            提交
141
-          </Button>
142
-          <Button onClick={router.goBack} style={{ marginLeft: '2em' }}>
143
-            返回
144
-          </Button>
145
-        </FormItem>
146
-      </Form>
79
+    <Card>
80
+      <Spin spinning={loading}>
81
+        <Form {...formItemLayout} onSubmit={handleSubmit}>
82
+          <FormItem label="公告类型">
83
+            {
84
+              getFieldDecorator('showType', {
85
+                rules: [{ required: true, message: '请填写标题' }],
86
+              })(
87
+                <Select style={fullWidth} allowClear>
88
+                  {
89
+                    showTypeList.map(x => <Option key={x.value} value={x.value}>{x.label}</Option>)
90
+                  }
91
+                </Select>
92
+              )
93
+            }
94
+          </FormItem>
95
+          <FormItem label="公告图片" help="建议图片尺寸:640*960px,比例2:3,格式:jpg">
96
+            {
97
+              getFieldDecorator('imageUrl', {
98
+                rules: [{ required: true, message: '公告图片' }],
99
+              })(<ImageUpload />)
100
+            }
101
+          </FormItem>
102
+          <FormItem label="公告标题">
103
+            {
104
+              getFieldDecorator('title', {
105
+                rules: [{ required: true, message: '请填写标题' }],
106
+              })(<Input />)
107
+            }
108
+          </FormItem>
109
+          <FormItem label="所属城市">
110
+            {
111
+              getFieldDecorator('cityId', {
112
+                rules: [{ required: true, message: '请选择城市' }],
113
+              })(
114
+                <SelectCity style={fullWidth} />,
115
+              )
116
+            }
117
+          </FormItem>
118
+          <FormItem label="跳转页面">
119
+            {
120
+              getFieldDecorator('linkPage')(
121
+                <Select style={fullWidth} allowClear>
122
+                  {
123
+                    pages.map(x => <Option key={x.page} value={x.page}>{x.title}</Option>)
124
+                  }
125
+                </Select>
126
+              )
127
+            }
128
+          </FormItem>
129
+          <FormItem label="页面参数">
130
+            {
131
+              getFieldDecorator('pageParam')(<Input placeholder="key1=value1&key2=value2" />)
132
+            }
133
+          </FormItem>
134
+          <FormItem label="公告详情">
135
+            { 
136
+              getFieldDecorator('content')(<Wangedit menus={editorMenus} />)
137
+            }
138
+          </FormItem>
139
+          <FormItem colon={false} label=" ">
140
+            <Button type="primary" htmlType="submit" loading={loading}>
141
+              提交
142
+            </Button>
143
+            <Button onClick={router.goBack} style={{ marginLeft: '2em' }}>
144
+              返回
145
+            </Button>
146
+          </FormItem>
147
+        </Form>
148
+      </Spin>
147 149
     </Card>
148 150
   )
149 151
 })

+ 10
- 0
src/services/apis.js 查看文件

@@ -2449,5 +2449,15 @@ export default {
2449 2449
       method: 'GET',
2450 2450
       url: `${prefix}/borker`,
2451 2451
     },
2452
+    // 获取经纪人规则
2453
+    getAgentRule: {
2454
+      method: 'GET',
2455
+      url: `${prefix}/bkAgentRule`,
2456
+    },
2457
+    // 保存经纪人规则
2458
+    saveAgentRule: {
2459
+      method: 'POST',
2460
+      url: `${prefix}/bkAgentRule`,
2461
+    },
2452 2462
   }
2453 2463
 };