sunjh 6 سال پیش
والد
کامیت
52797f7d2f
4فایلهای تغییر یافته به همراه19 افزوده شده و 7 حذف شده
  1. 1 1
      src/components/authen/Authentication.vue
  2. 3 1
      src/components/cheat/AgencyAdd.vue
  3. 14 4
      src/components/cheat/ProjectAdd.vue
  4. 1 1
      src/js/api.js

+ 1 - 1
src/components/authen/Authentication.vue

@@ -69,7 +69,7 @@
 <script>
 import Http from '@/js/http'
 import Apis from '@/js/api'
-
+import {notify} from '@/constants/index'
 export default {
   name: 'Authentication',
   data () {

+ 3 - 1
src/components/cheat/AgencyAdd.vue

@@ -123,7 +123,9 @@ export default {
         photo: this.agency.photoUrl,
       }
       Http.post(Apis.USER.ADD_AGENCY, newAgency).then((res) => {
-        console.log(res)
+        notify('success','测评机构添加成功')
+      }).catch(error=>{
+        notify('error',error.data.msg)
       })
     },
     cancelModify () {

+ 14 - 4
src/components/cheat/ProjectAdd.vue

@@ -181,6 +181,7 @@ import Apis from '@/js/api.js'
 import ServiceType from '@/constants/enum/service-type.js'
 import PlatformType from '@/constants/enum/platform-type.js'
 import {notify} from '@/constants/index'
+
 export default {
   name: 'ProjectAdd',
   data () {
@@ -207,7 +208,7 @@ export default {
         price: '',
         datetime: ''
       },
-      excelFile:{},
+      excelFile: {},
       rules: {
         // name: [
         //   {required: true, message: '请输入报告名称', trigger: 'blur'}
@@ -277,15 +278,24 @@ export default {
         datetime: this.project.datetime
       }
       Http.post(Apis.PROJECT.ADD_PROJECT, newProject).then((res) => {
+        notify('success', '项目添加成功')
         console.log(res)
+      }).catch(error => {
+        notify('error', error.data.msg)
       })
     },
     submitByFile () {
-      const data = {
-        file: this.project.file[0]
+      const formData = new FormData()
+      let config = {
+        //添加请求头
+        headers: {'Content-Type': 'multipart/form-data'},
       }
-      Http.post(Apis.PROJECT.ADD_PROJECT_BY_EXCEL, data).then((res) => {
+      formData.append('file', this.excelFile)
+      Http.upload(Apis.PROJECT.ADD_PROJECT_BY_EXCEL, formData,config).then((res) => {
         console.log(res)
+        notify('success', '项目添加成功')
+      }).catch(error => {
+        notify('error', error.data.msg)
       })
     },
     // cancelModify () {

+ 1 - 1
src/js/api.js

@@ -5,7 +5,7 @@ export default {
     UPDATE_PROJECT: '/api/project/{projectId}/',
     DELETE_PROJECT: '/api/project/{projectId}/',
     ADD_PROJECT: '',
-    ADD_PROJECT_BY_EXCEL: '/api/project/projectListImportByExcel/',
+    ADD_PROJECT_BY_EXCEL: '/api/project/projectImportByExcel/',
   },
   TASK: {
     GET_TASK: '/api/project/{projectId}/task/{taskId}/',