魏超 5 anos atrás
pai
commit
01175d4095
3 arquivos alterados com 52 adições e 28 exclusões
  1. 14
    17
      src/pages/news/list/NewsList.jsx
  2. 16
    11
      src/pages/news/type/NewsType.jsx
  3. 22
    0
      src/services/apis.js

+ 14
- 17
src/pages/news/list/NewsList.jsx Ver arquivo

97
         okText: '确认',
97
         okText: '确认',
98
         cancelText: '取消',
98
         cancelText: '取消',
99
         onOk() {
99
         onOk() {
100
-          request({
101
-            url: '/api/admin/taNews/' + newsId,
102
-            method: 'DELETE',
103
-            // data: { ...row },
104
-          }).then((data) => {
100
+          request({ ...apis.news.delete, urlData: { id: newsId },}).then((data) => {
105
             message.info('操作成功!')
101
             message.info('操作成功!')
106
             getList({ pageNum: 1, pageSize: 10 });
102
             getList({ pageNum: 1, pageSize: 10 });
103
+          }).catch((err) => {
104
+            console.log(err)
105
+            message.info(err.msg || err.message)
107
           })
106
           })
108
         }
107
         }
109
       });
108
       });
127
           okText: '确认',
126
           okText: '确认',
128
           cancelText: '取消',
127
           cancelText: '取消',
129
           onOk() {
128
           onOk() {
130
-            request({
131
-              url: '/api/admin/taNews/' + newsId,
132
-              method: 'PUT',
133
-              data: { "newsStatus": newsStatus, "buildingId": buildingId, "newsTypeId": newsTypeId },
134
-            }).then((data) => {
129
+            request({ ...apis.news.cancel, data:{"newsStatus": newsStatus, "buildingId": buildingId, "newsTypeId": newsTypeId}, urlData: { id: newsId },}).then((data) => {
135
               message.info('操作成功!')
130
               message.info('操作成功!')
136
               getList({ pageNum: 1, pageSize: 10 });
131
               getList({ pageNum: 1, pageSize: 10 });
132
+            }).catch((err) => {
133
+              console.log(err)
134
+              message.info(err.msg || err.message)
137
             })
135
             })
138
           },
136
           },
139
           onCancel() {
137
           onCancel() {
146
           okText: '确认',
144
           okText: '确认',
147
           cancelText: '取消',
145
           cancelText: '取消',
148
           onOk() {
146
           onOk() {
149
-            request({
150
-              url: '/api/admin/taNews/' + newsId,
151
-              method: 'PUT',
152
-              data: { "newsStatus": newsStatus, "buildingId": buildingId, "newsTypeId": newsTypeId },
153
-            }).then((data) => {
147
+            request({ ...apis.news.cancel, data:{"newsStatus": newsStatus, "buildingId": buildingId, "newsTypeId": newsTypeId}, urlData: { id: newsId },}).then((data) => {
154
               message.info('操作成功!')
148
               message.info('操作成功!')
155
               getList({ pageNum: 1, pageSize: 10 });
149
               getList({ pageNum: 1, pageSize: 10 });
150
+            }).catch((err) => {
151
+              console.log(err)
152
+              message.info(err.msg || err.message)
156
             })
153
             })
157
           },
154
           },
158
           onCancel() {
155
           onCancel() {
175
                   <Icon type="form" style={{ color: '#C0C4CC', marginLeft: '10px' }} />
172
                   <Icon type="form" style={{ color: '#C0C4CC', marginLeft: '10px' }} />
176
           </span>
173
           </span>
177
           {data.newsStatus === 0 ?
174
           {data.newsStatus === 0 ?
178
-            <span style={{ position: 'absolute', left: '280px', bottom: ' 0.11rem', fontSize: ' 0.11rem', color: '#FF7E48' }} onClick={cancelRelease.bind(this, data.newsId, 1, data.buildingId, data.newsType.newsTypeId)}>
175
+            <span style={{ position: 'absolute', left: '280px', bottom: ' 0.11rem', fontSize: ' 0.11rem', color: '#FF7E48',zIndex:1 }} onClick={cancelRelease.bind(this, data.newsId, 1, data.buildingId, data.newsType.newsTypeId)}>
179
               取消发布
176
               取消发布
180
                 <Icon type="close-circle" style={{ color: '#C0C4CC', marginLeft: '8px' }} />
177
                 <Icon type="close-circle" style={{ color: '#C0C4CC', marginLeft: '8px' }} />
181
             </span> :
178
             </span> :
182
-            <span style={{ position: 'absolute', left: '280px', bottom: ' 0.11rem', fontSize: ' 0.11rem', color: '#FF7E48' }} onClick={cancelRelease.bind(this, data.newsId, 0, data.buildingId, data.newsType.newsTypeId)}>
179
+            <span style={{ position: 'absolute', left: '280px', bottom: ' 0.11rem', fontSize: ' 0.11rem', color: '#FF7E48',zIndex:1 }} onClick={cancelRelease.bind(this, data.newsId, 0, data.buildingId, data.newsType.newsTypeId)}>
183
               发布
180
               发布
184
                 <Icon type="form" style={{ color: '#C0C4CC', marginLeft: '8px' }} />
181
                 <Icon type="form" style={{ color: '#C0C4CC', marginLeft: '8px' }} />
185
             </span>
182
             </span>

+ 16
- 11
src/pages/news/type/NewsType.jsx Ver arquivo

5
 import router from 'umi/router';
5
 import router from 'umi/router';
6
 import BuildSelect from '../../../components/SelectButton/BuildSelect';
6
 import BuildSelect from '../../../components/SelectButton/BuildSelect';
7
 import AuthButton from '@/components/AuthButton';
7
 import AuthButton from '@/components/AuthButton';
8
-
8
+import apis from '../../../services/apis';
9
 import request from '../../../utils/request'
9
 import request from '../../../utils/request'
10
 
10
 
11
 const { Option } = Select;
11
 const { Option } = Select;
21
 
21
 
22
   // 查询列表
22
   // 查询列表
23
   const getList = (params) => {
23
   const getList = (params) => {
24
-    request({
25
-        url: '/api/admin/taNewsType',
26
-        method: 'GET',
27
-        params: { ...params },
28
-    }).then((data) => {
24
+    request({ ...apis.newsType.list, params: { ...params } }).then((data) => {
29
         console.log(data)
25
         console.log(data)
30
         setData(data)
26
         setData(data)
31
     })
27
     })
32
   }
28
   }
29
+
33
   
30
   
34
   // 提交事件
31
   // 提交事件
35
   const handleSubmit = (e, props) => {
32
   const handleSubmit = (e, props) => {
63
       okText: '确认',
60
       okText: '确认',
64
       cancelText: '取消',
61
       cancelText: '取消',
65
       onOk() {
62
       onOk() {
66
-        request({
67
-          url: '/api/admin/taNewsType/' + newsId,
68
-          method: 'DELETE',
69
-          data: { ...row },
70
-        }).then((data) => {
63
+        request({ ...apis.newsType.delete, urlData: { id: newsId },}).then((data) => {
71
           message.info('操作成功!')
64
           message.info('操作成功!')
72
           getList({ pageNum: 1, pageSize: 10 });
65
           getList({ pageNum: 1, pageSize: 10 });
66
+        }).catch((err) => {
67
+          console.log(err)
68
+          message.info(err.msg || err.message)
73
         })
69
         })
70
+
71
+        // request({
72
+        //   url: '/api/admin/taNewsType/' + newsId,
73
+        //   method: 'DELETE',
74
+        //   data: { ...row },
75
+        // }).then((data) => {
76
+        //   message.info('操作成功!')
77
+        //   getList({ pageNum: 1, pageSize: 10 });
78
+        // })
74
       }
79
       }
75
     });
80
     });
76
   }
81
   }

+ 22
- 0
src/services/apis.js Ver arquivo

124
       url: `${prefix}/taNews`,
124
       url: `${prefix}/taNews`,
125
       action: 'admin.taNews.get',
125
       action: 'admin.taNews.get',
126
     },
126
     },
127
+    delete: {
128
+        method: 'DELETE',
129
+        url: `${prefix}/taNews/:id`,
130
+        action: 'admin.taNews.id.delete',
131
+    },
132
+    cancel: {
133
+        method: 'PUT',
134
+        url: `${prefix}/taNews/:id`,
135
+        action: 'admin.taNews.id.put',
136
+    },
137
+  },
138
+  newsType: {
139
+    list: {
140
+        method: 'GET',
141
+        url: `${prefix}/taNewsType`,
142
+        action: 'admin.taNewsType.get',
143
+      },
144
+    delete: {
145
+        method: 'DELETE',
146
+        url: `${prefix}/taNewsType/:id`,
147
+        action: 'admin.taNewsType.id.delete',
148
+    },
127
   },
149
   },
128
   customer: {
150
   customer: {
129
     drift: {
151
     drift: {