张延森 4 年 前
コミット
2baf1ce613

+ 11
- 0
config/routes.js ファイルの表示

@@ -120,6 +120,17 @@ export default [
120 120
                 component: './property/notice/Edit',
121 121
                 hideInMenu: true,
122 122
               },
123
+              {
124
+                path: 'news-type',
125
+                name: '服务分类',
126
+                component: './property/news/type/NewsType'
127
+              },
128
+              {
129
+                path: 'news-type/edit',
130
+                name: '服务内容详情',
131
+                component: './property/news/type/editNews',
132
+                hideInMenu: true,
133
+              },
123 134
               {
124 135
                 path: 'news',
125 136
                 name: '服务内容',

+ 4
- 4
src/pages/carouselFigure/editCarousel.jsx ファイルの表示

@@ -179,10 +179,10 @@ const { MonthPicker, RangePicker, WeekPicker } = DatePicker;
179 179
             label: '首页',
180 180
             value: 'index',
181 181
           },
182
-          {
183
-            label: '积分商城',
184
-            value: 'mall',
185
-          },
182
+          // {
183
+          //   label: '积分商城',
184
+          //   value: 'mall',
185
+          // },
186 186
           {
187 187
             label: '物业',
188 188
             value: 'property',

+ 1
- 1
src/pages/news/type/NewsType.jsx ファイルの表示

@@ -79,7 +79,7 @@ function NewsType(props) {
79 79
       dataIndex: 'newsTypeImg',
80 80
       key: 'newsTypeImg',
81 81
       align: 'center',
82
-      render: (text, record) => <img src={record.newsTypeImg} style={{ width: '165px', height: '104px' }} className={styles.touxiang} />,
82
+      render: (text, record) => <img src={record.newsTypeImg} className={styles.touxiang} />,
83 83
     },
84 84
     {
85 85
       title: '名称',

+ 2
- 2
src/pages/news/type/style.less ファイルの表示

@@ -38,8 +38,8 @@
38 38
     border-color: #3A91D5;
39 39
   }
40 40
   .touxiang {
41
-    width: 93px;
42
-    height: 93px;
41
+    width: 64px;
42
+    height: 64px;
43 43
   }
44 44
   .ant-table-column-title {
45 45
     font-weight: 600;

+ 147
- 0
src/pages/property/news/type/NewsType.jsx ファイルの表示

@@ -0,0 +1,147 @@
1
+import React, { useState, useEffect } from 'react';
2
+import { Form, Button, message, Table, Pagination, Modal } from 'antd';
3
+import router from 'umi/router';
4
+import AuthButton from '@/components/AuthButton';
5
+import withActions from '@/components/ActionList';
6
+import EditIcon from '@/components/EditIcon';
7
+import { ConfirmButton } from '@/components/ModalButton';
8
+import apis from '@/services/apis';
9
+import request from '@/utils/request'
10
+import BuildSelect from '@/components/SelectButton/BuildSelect';
11
+import Navigate from '@/components/Navigate';
12
+
13
+function NewsType(props) {
14
+  // 获取初始化数据
15
+  const [data, setData] = useState({})
16
+
17
+  useEffect(() => {
18
+    getList({ pageNum: 1, pageSize: 10 });
19
+  }, [])
20
+
21
+  // 查询列表
22
+  const getList = (params) => {
23
+    request({ ...apis.propNews.newsType.list, params: { ...params } }).then((data) => {
24
+      console.log(data)
25
+      setData(data)
26
+    })
27
+  }
28
+
29
+
30
+  // 提交事件
31
+  const handleSubmit = (e, props) => {
32
+    e.preventDefault();
33
+    props.form.validateFields((err, values) => {
34
+      if (!err) {
35
+        getList({ pageNum: 1, pageSize: 10, ...values })
36
+      }
37
+    });
38
+  }
39
+
40
+  const changePageNum = (pageNumber) => {
41
+    props.form.validateFields((err, values) => {
42
+      if (!err) {
43
+        getList({ pageNum: pageNumber, pageSize: 10, ...values })
44
+      }
45
+    });
46
+  }
47
+
48
+
49
+  // 跳转到编辑资讯
50
+  const toEditNews = (id) => () => {
51
+    router.push({
52
+      pathname: '/property/news-type/edit',
53
+      query: {
54
+        id
55
+      },
56
+    });
57
+  }
58
+
59
+
60
+  const changeNewsStatus = (row, newsId) => () => {
61
+    request({ ...propNews.newsType.put, urlData: { id: newsId }, data: { ...row, status: -1 } }).then((data) => {
62
+      message.info('操作成功!')
63
+      getList({ pageNum: 1, pageSize: 10 });
64
+    }).catch((err) => {
65
+      console.log(err)
66
+      message.info(err.msg || err.message)
67
+    })
68
+  }
69
+  /**
70
+   *
71
+   *
72
+   * @param {*} props
73
+   * @returns
74
+   */
75
+  const columns = [
76
+    {
77
+      title: '类型图',
78
+      dataIndex: 'newsTypeImg',
79
+      key: 'newsTypeImg',
80
+      align: 'center',
81
+      render: (text, record) => <img src={record.newsTypeImg} style={{width: '72px', height: '72px'}} />,
82
+    },
83
+    {
84
+      title: '名称',
85
+      dataIndex: 'newsTypeName',
86
+      key: 'newsTypeName',
87
+      align: 'center',
88
+      render: (text, record) => <Navigate to={`/news/type/editNews?id=${record.newsTypeId}`}>{text}</Navigate>
89
+    },
90
+    {
91
+      title: '操作',
92
+      dataIndex: 'handle',
93
+      key: 'handle',
94
+      align: 'center',
95
+      render: withActions((x, row) => [
96
+        <AuthButton name="admin.taNewsType.id.delete" noRight={null}>
97
+          <ConfirmButton type="link" title="确认删除?" onClick={changeNewsStatus(row, row.newsTypeId)}>
98
+            <EditIcon text="删除" type="delete" />
99
+          </ConfirmButton>
100
+        </AuthButton>,
101
+        <AuthButton name="admin.taNewsType.id.put" noRight={null}>
102
+          <EditIcon text="编辑" type="edit" onClick={toEditNews(row.newsTypeId)} />
103
+        </AuthButton>,
104
+      ]),
105
+    },
106
+  ];
107
+
108
+  function handleReset() {
109
+    props.form.resetFields();
110
+    getList({ pageNum: 1, pageSize: 10 })
111
+  }
112
+
113
+  const { getFieldDecorator } = props.form
114
+  return (
115
+
116
+    <>
117
+      {/* <Form layout="inline" onSubmit={e => handleSubmit(e, props)}>
118
+        <Form.Item>
119
+          {getFieldDecorator('buildingId')(
120
+            <BuildSelect />,
121
+          )}
122
+        </Form.Item>
123
+        <Form.Item>
124
+          <AuthButton name="admin.taNewsType.search" noRight={null}>
125
+            <Button type="primary" htmlType="submit" >
126
+              搜索
127
+              </Button>
128
+          </AuthButton>
129
+          <Button style={{ marginLeft: 8 }} onClick={handleReset}>
130
+            重置
131
+            </Button>
132
+        </Form.Item>
133
+      </Form> */}
134
+      <AuthButton name="admin.taNewsType.post" noRight={null}>
135
+        <Button type="primary" onClick={toEditNews()}>新增</Button>
136
+      </AuthButton>
137
+      <Table rowKey="newsType" dataSource={data.records} columns={columns} pagination={false} />
138
+      <div style={{ display: 'flex', justifyContent: 'flex-end', marginTop: '30px' }}>
139
+        <Pagination showQuickJumper defaultCurrent={1} total={data.total} onChange={changePageNum} current={data.current} />
140
+      </div>
141
+    </>
142
+  )
143
+}
144
+
145
+const WrappedHeader = Form.create({ name: 'header' })(NewsType);
146
+
147
+export default WrappedHeader

+ 80
- 0
src/pages/property/news/type/editNews.jsx ファイルの表示

@@ -0,0 +1,80 @@
1
+import React, { useState, useEffect } from 'react';
2
+import { Input, Menu, Dropdown, Button, Icon, message, Table, Divider, Tag, Select, Form, Alert } from 'antd';
3
+import router from 'umi/router';
4
+import apis from '@/services/apis';
5
+import request from '@/utils/request'
6
+import XForm, { FieldTypes } from '@/components/XForm';
7
+
8
+const { TextArea } = Input;
9
+const { Option } = Select;
10
+
11
+const header = props => {
12
+  const newsId = props.location.query.id
13
+  console.log("newsId" + newsId);
14
+  const [ newsData, setNewsData ] = useState({})
15
+  if(newsId){
16
+    useEffect(() => {
17
+      getNewsData(newsId);
18
+    },[])
19
+
20
+  // 查询列表
21
+  const getNewsData = (newsId) => {
22
+    request({
23
+        ...apis.propNews.newsType.get,
24
+        urlData: { id: newsId }
25
+    }).then((data) => {
26
+        setNewsData(data)
27
+    }).catch((err) => {
28
+      message.error(err.msg || err.message)
29
+    })
30
+  }
31
+  }
32
+
33
+  const fields = [
34
+    {
35
+      label: '类型图',
36
+      name: 'newsTypeImg',
37
+      type: FieldTypes.ImageUploader,
38
+      value: newsData.newsTypeImg,
39
+      help: '建议图片尺寸:660px*416px',
40
+    },
41
+    {
42
+      label: '名称',
43
+      name: 'newsTypeName',
44
+      type: FieldTypes.Text,
45
+      value: newsData.newsTypeName,
46
+      rules: [
47
+        {required: true, message: '请输入分类名称'},
48
+      ]
49
+    },
50
+  ]
51
+
52
+   
53
+  const handleSubmit = (values) => {
54
+    if(newsId){
55
+        values.newsTypeId = newsId
56
+        request({ ...apis.propNews.newsType.put, urlData: { id: newsId }, data: { ...values }}).then((data) => {
57
+          cancelPage();
58
+        }).catch((err) => {
59
+          message.error(err.msg || err.message)
60
+        })
61
+      }else{
62
+        request({ ...apis.propNews.newsType.post, data: { ...values } }).then((data) => {
63
+          cancelPage();
64
+        }).catch((err) => {
65
+          message.error(err.msg || err.message)
66
+        })
67
+      }
68
+  }
69
+
70
+  const cancelPage = () => {
71
+    router.go(-1);
72
+  }
73
+
74
+  return (
75
+    <XForm onSubmit={handleSubmit} onCancel={cancelPage} fields={fields}></XForm>
76
+  )
77
+}
78
+
79
+const WrappedNormalLoginForm = Form.create({ name: 'header' })(header);
80
+export default WrappedNormalLoginForm

+ 56
- 0
src/pages/property/news/type/style.less ファイルの表示

@@ -0,0 +1,56 @@
1
+.searchBox {
2
+    font-size: 30px;
3
+    color: red;
4
+    display: flex;
5
+    display: flex;
6
+    justify-items: center;
7
+    align-items: center;
8
+    justify-content: space-between;
9
+    .searchItem {
10
+      min-width: 200px;
11
+      margin-right: 20px;
12
+      text-align: left;
13
+      .anticon-down {
14
+        float: right !important;
15
+      }
16
+    }
17
+  }
18
+  .addBtn {
19
+    padding: 0 30px;
20
+    height: 36px;
21
+    background-color: #50be00;
22
+    color: #fff;
23
+    margin: 30px 0;
24
+    border-color: #50be00;
25
+  }
26
+  .addBtn:focus {
27
+    color: #fff;
28
+    background-color: #50be00;
29
+    border-color: #50be00;
30
+  }
31
+  .searchBtn{
32
+   background-color: #3A91D5;
33
+   border-color: #3A91D5;
34
+  }
35
+  .searchBtn:focus {
36
+    color: #fff;
37
+    background-color: #3A91D5;
38
+    border-color: #3A91D5;
39
+  }
40
+  .touxiang {
41
+    width: 64px;
42
+    height: 64px;
43
+  }
44
+  .ant-table-column-title {
45
+    font-weight: 600;
46
+  }
47
+  .shoppingCart{
48
+    color: #dcdcdc;
49
+    margin-left: 6px;
50
+    font-size: 16px;
51
+  }
52
+  .edit{
53
+    color: #dcdcdc;
54
+    margin-left: 6px;
55
+    font-size: 15px;
56
+  }

+ 29
- 1
src/services/prop_news_api.js ファイルの表示

@@ -36,6 +36,34 @@ export default prefix => {
36 36
       url: `${prefix}/${moduleName}/id`,
37 37
       method: 'delete',
38 38
       action: `admin.${moduleName}.delete`
39
-    }
39
+    },
40
+    
41
+    newsType: {
42
+      list: {
43
+        method: 'GET',
44
+        url: `${prefix}/tpNewsType`,
45
+        action: 'admin.tpNewsType.get',
46
+      },
47
+      delete: {
48
+        method: 'DELETE',
49
+        url: `${prefix}/tpNewsType/:id`,
50
+        action: 'admin.tpNewsType.id.delete',
51
+      },
52
+      put: {
53
+        method: 'PUT',
54
+        url: `${prefix}/tpNewsType/:id`,
55
+        action: 'admin.tpNewsType.id.delete',
56
+      },
57
+      post: {
58
+        method: 'POST',
59
+        url: `${prefix}/tpNewsType`,
60
+        action: 'admin.tpNewsType.post',
61
+      },
62
+      get: {
63
+        method: 'GET',
64
+        url: `${prefix}/tpNewsType/:id`,
65
+        action: 'admin.tpNewsType.get',
66
+      }
67
+    },
40 68
   }
41 69
 }