Browse Source

修改 url

魏熙美 5 years ago
parent
commit
75a319007f

+ 1
- 3
src/pages/building/list/add/components/base.jsx View File

52
 
52
 
53
    // 获取详情信息
53
    // 获取详情信息
54
    function getById(currentId) {
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
       res.openingDate = moment(res.openingDate)
57
       res.openingDate = moment(res.openingDate)
60
       res.receivedDate = moment(res.receivedDate)
58
       res.receivedDate = moment(res.receivedDate)
61
       res.avatarImage = res.buildingImg.map(item => item.url)
59
       res.avatarImage = res.buildingImg.map(item => item.url)

+ 2
- 8
src/pages/building/list/add/components/imageSet.jsx View File

51
 
51
 
52
   function getList(params) {
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
       setData(res)
55
       setData(res)
59
     }).catch(err => {
56
     }).catch(err => {
60
       openNotificationWithIcon('error', err.message)
57
       openNotificationWithIcon('error', err.message)
86
    */
83
    */
87
   function deleteApartment(record) {
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
       getList()
87
       getList()
94
       openNotificationWithIcon('error', '操作成功')
88
       openNotificationWithIcon('error', '操作成功')
95
     }).catch(err => {
89
     }).catch(err => {

+ 1
- 4
src/pages/building/list/add/components/modalImage.jsx View File

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
       // res.img = res.buildingImgList.map((item, _) => item.url)
91
       // res.img = res.buildingImgList.map((item, _) => item.url)
95
       res.img = res.buildingImgList.map(item => item.url)
92
       res.img = res.buildingImgList.map(item => item.url)
96
       this.props.form.setFieldsValue(res)
93
       this.props.form.setFieldsValue(res)

+ 2
- 4
src/pages/building/list/add/components/poster.jsx View File

51
 
51
 
52
   // 获取详情信息
52
   // 获取详情信息
53
   function getById(currentId) {
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
       setBuilding(res)
56
       setBuilding(res)
59
     })
57
     })
60
   }
58
   }

+ 1
- 4
src/pages/building/list/index.jsx View File

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

+ 1
- 4
src/pages/building/type/edi.jsx View File

31
 
31
 
32
   // 获取详情信息
32
   // 获取详情信息
33
   function getById(currentId) {
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
       data = res
35
       data = res
39
       props.form.setFieldsValue(res)
36
       props.form.setFieldsValue(res)
40
     })
37
     })

+ 1
- 1
src/pages/customer/recommendCustomer/index.jsx View File

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

+ 8
- 8
src/services/apis.js View File

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

+ 6
- 2
src/utils/request.js View File

76
       });
76
       });
77
       throw new Error(response.statusText);
77
       throw new Error(response.statusText);
78
     } else {
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
       const { code, data, message } = await response.clone().json();
85
       const { code, data, message } = await response.clone().json();
82
       if (code != 1000) {
86
       if (code != 1000) {
83
         notification.error({
87
         notification.error({