魏熙美 5 лет назад
Родитель
Сommit
75a319007f

+ 1
- 3
src/pages/building/list/add/components/base.jsx Просмотреть файл

@@ -52,10 +52,8 @@ function AddBuilding(props) {
52 52
 
53 53
    // 获取详情信息
54 54
    function getById(currentId) {
55
-    const { url, method } = apis.building.buildingGetById
56
-    const tempUrl = url.substring(0, url.lastIndexOf('id')).concat(currentId)
57 55
 
58
-    request({ url: tempUrl, method }).then(res => {
56
+    request({ ...apis.building.buildingGetById, urlData: { id: currentId } }).then(res => {
59 57
       res.openingDate = moment(res.openingDate)
60 58
       res.receivedDate = moment(res.receivedDate)
61 59
       res.avatarImage = res.buildingImg.map(item => item.url)

+ 2
- 8
src/pages/building/list/add/components/imageSet.jsx Просмотреть файл

@@ -51,10 +51,7 @@ function imageSet(props) {
51 51
 
52 52
   function getList(params) {
53 53
     // 网路请求
54
-    const { url, method } = apis.building.buildingApartment
55
-    const tempUrl = url.substring(0, url.lastIndexOf('id')).concat(props.building.buildingId)
56
-
57
-    request({ url: tempUrl, method, params: { ...params } }).then(res => {
54
+    request({ ...apis.building.buildingApartment, urlData: { id: props.building.buildingId }, params: { ...params } }).then(res => {
58 55
       setData(res)
59 56
     }).catch(err => {
60 57
       openNotificationWithIcon('error', err.message)
@@ -86,10 +83,7 @@ function imageSet(props) {
86 83
    */
87 84
   function deleteApartment(record) {
88 85
     // 网路请求
89
-    const { url, method } = apis.building.buildingApartmentDelete
90
-    const tempUrl = url.substring(0, url.lastIndexOf('id')).concat(record.apartmentId)
91
-
92
-    request({ url: tempUrl, method }).then(res => {
86
+    request({ ...apis.building.buildingApartmentDelete, urlData: { id: record.apartmentId } }).then(res => {
93 87
       getList()
94 88
       openNotificationWithIcon('error', '操作成功')
95 89
     }).catch(err => {

+ 1
- 4
src/pages/building/list/add/components/modalImage.jsx Просмотреть файл

@@ -87,10 +87,7 @@ class ModalImage extends React.Component {
87 87
     }
88 88
 
89 89
     // 网路请求
90
-    const { url, method } = apis.building.buildingApartmentGetById
91
-    const tempUrl = url.substring(0, url.lastIndexOf('id')).concat(apartmentId)
92
-
93
-    request({ url: tempUrl, method, params: { ...params } }).then(res => {
90
+    request({ ...apis.building.buildingApartmentGetById, urlData: { id: apartmentId }, params: { ...params } }).then(res => {
94 91
       // res.img = res.buildingImgList.map((item, _) => item.url)
95 92
       res.img = res.buildingImgList.map(item => item.url)
96 93
       this.props.form.setFieldsValue(res)

+ 2
- 4
src/pages/building/list/add/components/poster.jsx Просмотреть файл

@@ -51,10 +51,8 @@ const Poster = props => {
51 51
 
52 52
   // 获取详情信息
53 53
   function getById(currentId) {
54
-    const { url, method } = apis.building.buildingGetById
55
-    const tempUrl = url.substring(0, url.lastIndexOf('id')).concat(currentId)
56
-
57
-    request({ url: tempUrl, method }).then(res => {
54
+ 
55
+    request({ ...apis.building.buildingGetById, urlData: { id: currentId } }).then(res => {
58 56
       setBuilding(res)
59 57
     })
60 58
   }

+ 1
- 4
src/pages/building/list/index.jsx Просмотреть файл

@@ -77,16 +77,13 @@ function CartBody(props) {
77 77
    * @param {*} record
78 78
    */
79 79
   function deleteBuilding(record) {
80
-    const { url, method } = apis.building.deleteBuilding
81
-    const tempUrl = url.substring(0, url.lastIndexOf('id')).concat(record.buildingId)
82
-
83 80
     const modal = Modal.confirm();
84 81
     modal.update({
85 82
       content: '确定删除此楼盘?',
86 83
       okText: '确认',
87 84
       cancelText: '关闭',
88 85
       onOk: () => {
89
-        request({ url: tempUrl, method }).then(() => {
86
+        request({ ...apis.building.deleteBuilding, urlData: { id: record.buildingId } }).then(() => {
90 87
           openNotificationWithIcon('success', '操作成功')
91 88
           props.onSuccess()
92 89
         }).catch(err => {

+ 1
- 4
src/pages/building/type/edi.jsx Просмотреть файл

@@ -31,10 +31,7 @@ function body(props) {
31 31
 
32 32
   // 获取详情信息
33 33
   function getById(currentId) {
34
-    const { url, method } = apis.buildingType.getById
35
-    const tempUrl = url.substring(0, url.lastIndexOf('id')).concat(currentId)
36
-
37
-    request({ url: tempUrl, method }).then(res => {
34
+    request({ ...apis.buildingType.getById, urlData: { id: currentId } }).then(res => {
38 35
       data = res
39 36
       props.form.setFieldsValue(res)
40 37
     })

+ 1
- 1
src/pages/customer/recommendCustomer/index.jsx Просмотреть файл

@@ -86,7 +86,7 @@ function body(props) {
86 86
       ...apis.customer.customerRecommendRecommenderExport, 
87 87
       responseType: 'blob',
88 88
     }).then(response => {
89
-      console.log('exportRecommendCustomer: ', response.body())
89
+      console.log('exportRecommendCustomer: ', response)
90 90
       download(response)
91 91
     }).catch(error => {
92 92
 

+ 8
- 8
src/services/apis.js Просмотреть файл

@@ -55,22 +55,22 @@ export default {
55 55
     },
56 56
     buildingGetById: {
57 57
       method: 'GET',
58
-      url: `${prefix}/buildingSelectId/id`,
58
+      url: `${prefix}/buildingSelectId/:id`,
59 59
       action: 'admin.buildingSelectId.id.get',
60 60
     },
61 61
     deleteBuilding: {
62 62
       method: 'DELETE',
63
-      url: `${prefix}/building/delete/id`,
63
+      url: `${prefix}/building/delete/:id`,
64 64
       action: 'admin.building.delete.id.delete',
65 65
     },
66 66
     buildingApartment: {
67 67
       method: 'GET',
68
-      url: `${prefix}/buildingApartment/buildingId/id`,
68
+      url: `${prefix}/buildingApartment/buildingId/:id`,
69 69
       action: 'admin.buildingApartment.buildingId.id.get',
70 70
     },
71 71
     buildingApartmentGetById: {
72 72
       method: 'GET',
73
-      url: `${prefix}/buildingApartment/id`,
73
+      url: `${prefix}/buildingApartment/:id`,
74 74
       action: 'admin.buildingApartment.id.get',
75 75
     },
76 76
     buildingApartmentUpdate: {
@@ -85,7 +85,7 @@ export default {
85 85
     },
86 86
     buildingApartmentDelete: {
87 87
       method: 'DELETE',
88
-      url: `${prefix}/apartment/deleted/id`,
88
+      url: `${prefix}/apartment/deleted/:id`,
89 89
       action: 'admin.apartment.deleted.id.delete',
90 90
     },
91 91
     buildingSelect: {
@@ -102,12 +102,12 @@ export default {
102 102
     },
103 103
     delete: {
104 104
       method: 'DELETE',
105
-      url: `${prefix}/tdBuildingType/id`,
105
+      url: `${prefix}/tdBuildingType/:id`,
106 106
       action: 'admin.tdBuildingType.id.delete',
107 107
     },
108 108
     update: {
109 109
       method: 'PUT',
110
-      url: `${prefix}/tdBuildingType/id`,
110
+      url: `${prefix}/tdBuildingType/:id`,
111 111
       action: 'admin.tdBuildingType.id.put',
112 112
     },
113 113
     add: {
@@ -117,7 +117,7 @@ export default {
117 117
     },
118 118
     getById: {
119 119
       method: 'GET',
120
-      url: `${prefix}/tdBuildingType/id`,
120
+      url: `${prefix}/tdBuildingType/:id`,
121 121
       action: 'admin.tdBuildingType.id.get',
122 122
     },
123 123
   },

+ 6
- 2
src/utils/request.js Просмотреть файл

@@ -76,8 +76,12 @@ request.interceptors.response.use(async (response, options) => {
76 76
       });
77 77
       throw new Error(response.statusText);
78 78
     } else {
79
-      // console.log('response: ', response)
80
-      // console.log('response.headers: ', response.headers)
79
+      console.log('response.headers: ', response.headers)
80
+      console.log('response.headers.Content-Type: ', response.headers.get('Content-Type'))
81
+      if (response.headers.get('Content-Type') === 'application/octet-stream;charset=utf-8') {
82
+        return response
83
+      }
84
+
81 85
       const { code, data, message } = await response.clone().json();
82 86
       if (code != 1000) {
83 87
         notification.error({