sunjh 6 年之前
父節點
當前提交
89610a4b7b
共有 4 個文件被更改,包括 47 次插入56 次删除
  1. 11 9
      src/components/project/Project.vue
  2. 18 24
      src/components/project/ProjectCreate.vue
  3. 3 13
      src/js/api.js
  4. 15 10
      src/js/http.js

+ 11 - 9
src/components/project/Project.vue

@@ -82,7 +82,8 @@
 
         <el-form-item label="预算" prop="budget">
           <el-input v-if="isModifyMode" type="number" v-model="project.budget">
-            ¥<template slot="append"></template>
+            ¥
+            <template slot="append"></template>
           </el-input>
           <span v-if="!isModifyMode">{{project.budget}}¥</span>
         </el-form-item>
@@ -285,6 +286,7 @@ import ResourceType from '@/constants/enum/resource-type'
 import provincecity from '@/components/commons/ProvinceCity'
 import provinceCityJSON from '@/constants/provinceCity.json'
 import ServiceType from '@/constants/enum/service-type'
+
 export default {
   name: 'Project',
   components: {
@@ -309,9 +311,9 @@ export default {
       isModifyMode: false,
       platformType: PlatformType,
       resourceType: ResourceType,
-      serviceType:ServiceType,
+      serviceType: ServiceType,
       project: {},
-      task:[],
+      task: [],
       analyseDemandList: [],
       pickerOptions: {
         shortcuts: [
@@ -427,10 +429,10 @@ export default {
         if (valid) {
           this.isModifyMode = false
           console.log(this.project)
-          // Http.put(Apis.PROJECT.UPDATE_PROJECT_SUBMIT, this.project).then((res) => {
-          //   console.log(res)
-          //   console.log(this.project)
-          // })
+          Http.put(Apis.PROJECT, this.project).then((res) => {
+            console.log(res)
+            console.log(this.project)
+          })
           //提交 project
         } else {
           console.log('error submit!!')
@@ -500,8 +502,8 @@ export default {
     handleReject (index, id) {
       console.log('拒绝')
     },
-    loadData () {//.replace('{projectId}','PROJECT_1')
-      Http.get(Apis.PAGE.PROJECT_DETAIL_PAGE.replace('{projectId}','PROJECT_1')).then((res) => {
+    loadData () {
+      Http.get(Apis.PROJECT + 'PROJECT_1').then((res) => {
         console.log(res)
         this.project = res.projectDetails
         this.task = res.taskList

+ 18 - 24
src/components/project/ProjectCreate.vue

@@ -130,7 +130,7 @@
           </div>
         </el-form-item>
         <el-form-item>
-          <div class="btn btn-medium btn-info" v-on:click="submitForm()">立即申请</div>
+          <div class="btn btn-medium btn-info" v-on:click="submitForm('project')">立即申请</div>
           <div class="btn btn-medium" @click="resetForm('project')">重置</div>
         </el-form-item>
       </el-form>
@@ -147,6 +147,7 @@ import provincecity from '@/components/commons/ProvinceCity'
 import provinceCityJSON from '@/constants/provinceCity.json'
 import ServiceType from '@/constants/enum/service-type'
 import ResourceType from '@/constants/enum/resource-type'
+
 export default {
   name: 'ProjectCreate',
   components: {
@@ -167,8 +168,8 @@ export default {
       tabPosition: 'top',
       institutionArray: Enum.institution,
       platformType: [],
-      serviceType:ServiceType,
-      resourceType:ResourceType,
+      serviceType: ServiceType,
+      resourceType: ResourceType,
       project: {
         name: '',
         contactName: '',
@@ -298,23 +299,18 @@ export default {
         this.platformType.push(PlatformType[item])
       })
     },
-    submitForm () {
-      console.log(this.project)
-      Http.posts(Apis.PROJECT.CREATE_PROJECT_SUBMIT, this.project).then((res) => {
-        console.log(res.status)
+    submitForm (formName) {
+      this.$refs[formName].validate(valid => {
+        if (valid) {
+          Http.post(Apis.PROJECT, this.project).then((res) => {
+            console.log(res.status)
+          })
+          //提交 project
+        } else {
+          console.log('error submit!!')
+          return false
+        }
       })
-      // this.$refs[formName].validate(valid => {
-      //   if (valid) {
-      //     console.log(this.project)
-      //     Http.post(Apis.PROJECT.CREATE_PROJECT_SUBMIT, this.project).then((res) => {
-      //       console.log(res)
-      //     })
-      //     //提交 project
-      //   } else {
-      //     console.log('error submit!!')
-      //     return false
-      //   }
-      // })
     },
     resetForm (formName) {
       this.$refs[formName].resetFields()
@@ -324,10 +320,8 @@ export default {
       this.project.desc = ''
       this.project.file = ''
       this.project.doc = ''
-      this.project.contact = {
-        name: '',
-        phone: ''
-      }
+      this.project.contactName = ''
+      this.project.contactPhone = ''
 
       this.project.resource = '非定向'
       this.project.institution = ''
@@ -346,7 +340,7 @@ export default {
       return isAPK && isDMG
     },
     loadData () {
-      Http.get(Apis.PAGE.CREATE_PROJECT_PAGE).then((res) => {
+      Http.get(Apis.PAGE.PROJECT_DETAIL_PAGE).then((res) => {
         this.project = res.project
       })
     }

+ 3 - 13
src/js/api.js

@@ -1,17 +1,7 @@
 export default {
-  PROJECT: {
-    CREATE_PROJECT_SUBMIT: '/api/project',
-    UPDATE_PROJECT_SUBMIT: '/api/project/',
-    CREATE_ANALYSE_DEMAND_SUBMIT: '/api/project/analyseDemand/',
-  },
-  TASK: {
-    CREATE_TASK_SUBMIT: '/api/task/',
-    UPDATE_TASK_SUBMIT: '/api/task/'
-  },
-  REPORT: {
-    CREATE_REPORT_SUBMIT: '/api/report/',
-    UPDATE_REPORT_SUBMIT: '/api/report/',
-  },
+  PROJECT: '/api/project/',
+  TASK: '/api/task/',
+  REPORT: '/api/report/',
   USER: {},
   PAGE: {
     HOME_PAGE: '/api/page/home/',

+ 15 - 10
src/js/http.js

@@ -62,7 +62,7 @@ function handleParams (data) {
 }
 
 export default {
-  posts (url, data) {
+  post (url, data) {
     return new Promise((resolve, reject) => {
       axios.post(url, qs.stringify(data)).then(
         (result) => {
@@ -77,7 +77,7 @@ export default {
   },
   get (url) {
     return new Promise((resolve, reject) => {
-      axios.get(handleUrl(url) )
+      axios.get(handleUrl(url))
         .then(response => {
           resolve(response.data)
         }).catch(error => {
@@ -89,15 +89,20 @@ export default {
   },
   put (url, data) {
     return new Promise((resolve, reject) => {
-      axios({
-        method: 'put',
-        url: handleUrl(url),
-        data: handleParams(data),
-        timeout: TIME_OUT_MS,
-        headers: {
-          'Content-Type': 'application/json; charset=UTF-8'
+      axios.put(url, qs.stringify(data)).then(
+        (result) => {
+          resolve(result)
+        }
+      ).catch(
+        (error) => {
+          reject(error)
         }
-      }).then(
+      )
+    })
+  },
+  delete (url, data) {
+    return new Promise((resolve, reject) => {
+      axios.delete(url, {data: qs.stringify(data)}).then(
         (result) => {
           resolve(result)
         }