sunjh пре 6 година
родитељ
комит
5dc693e7fe
1 измењених фајлова са 107 додато и 11 уклоњено
  1. 107 11
      src/components/task/Task.vue

+ 107 - 11
src/components/task/Task.vue

@@ -65,7 +65,36 @@
             <el-tab-pane :label="resourceType[2]" name="2"></el-tab-pane>
           </el-tabs>
         </el-form-item>
-
+        <el-form-item label="需求文档" prop="doc">
+          <el-upload
+            v-if="isModifyMode"
+            drag
+            class="upload-demo"
+            action=""
+            :on-remove="handleRemove"
+            :before-remove="beforeRemove"
+            :limit="1"
+            :on-exceed="handleExceed"
+            :before-upload="beforeFileUpload"
+            :http-request="uploadRequireDoc"
+            :file-list="task.doc"
+          >
+            <i class="el-icon-upload"></i>
+            <div class="el-upload__text">
+              将文件拖到此处,或
+              <em>点击上传</em>
+            </div>
+            <div class="el-upload__tip" slot="tip">请上传需求文档</div>
+          </el-upload>
+          <span v-if="!isModifyMode">
+              <span v-if="task.requireDocUrl == null">
+                暂无文件
+              </span>
+              <span v-if="task.requireDocUrl != null">
+                <a :href="task.requireDocUrl">{{task.requireDocUrl}}</a>
+              </span>
+            </span>
+        </el-form-item>
         <el-form-item label="任务截止时间" prop="datetime">
           <div class="block" v-if="isModifyMode">
             <el-date-picker
@@ -124,7 +153,19 @@ export default {
       serviceType: ServiceType,
       taskId: '',
       projectId: '',
-      task: {},
+      task: {
+        name: '',
+        desc: '',
+        type: '',
+        resource: '',
+        location: '',
+        institution: '',
+        datetime: '',
+        quotePrice: '',
+        fixedPrice: '',
+        doc: [],
+        requireDocUrl: '123.doc'
+      },
       reportList: [],
       pickerOptions: {
         shortcuts: [
@@ -236,10 +277,11 @@ export default {
             institution: this.task.institution,
             datetime: this.task.datetime,
             quotePrice: this.task.quotePrice,
-            fixedPrice: this.task.fixedPrice
+            fixedPrice: this.task.fixedPrice,
+            requireDoc: this.task.requireDocUrl
           }
           //修改TASK
-          Http.put(Apis.TASK.UPDATE_TASK.replace('{projectId}', 'pro1564487183259').replace('{taskId}', 'pro1564487183259_task1564487274060'), newTask).then((res) => {
+          Http.put(Apis.TASK.UPDATE_TASK.replace('{projectId}', this.projectId).replace('{taskId}', this.taskId), newTask).then((res) => {
             console.log(res)
           })
           //提交 task
@@ -282,20 +324,20 @@ export default {
     applyTask () {
       const data = {
         userId: 3,
-        projectId:this.projectId,
-        taskId:this.taskId
+        projectId: this.projectId,
+        taskId: this.taskId
       }
-      Http.post(Apis.USER.ACCEPT_TASK,data).then((res) => {
+      Http.post(Apis.USER.ACCEPT_TASK, data).then((res) => {
         console.log(res)
       })
     },
     submitTaskRequest () {
       const data = {
         userId: 3,
-        projectId:this.projectId,
-        taskId:this.taskId
+        projectId: this.projectId,
+        taskId: this.taskId
       }
-      Http.post(Apis.USER.SUBMIT_TASK_REQUEST,data).then((res) => {
+      Http.post(Apis.USER.SUBMIT_TASK_REQUEST, data).then((res) => {
         console.log(res)
       })
     },
@@ -313,11 +355,65 @@ export default {
     loadData (projectId, taskId) {
       //replace('{taskId}', this.taskId)
       Http.get(Apis.TASK.GET_TASK.replace('{projectId}', projectId).replace('{taskId}', taskId)).then((res) => {
-        this.task = res.crowdTaskVO
+        this.taskId = res.crowdTaskVO.id
+        this.projectId = res.crowdTaskVO.projectId
+        this.task.title = res.crowdTaskVO.title
+        this.task.description = res.crowdTaskVO.description
+        this.task.serviceType = res.crowdTaskVO.serviceType
+        this.task.resource = res.crowdTaskVO.resource
+        this.task.location = res.crowdTaskVO.location
+        this.task.institution = res.crowdTaskVO.institution
+        this.task.datetime = new Date(res.crowdTaskVO.datetime)
+        this.task.quotePrice = res.crowdTaskVO.quotePrice
+        this.task.fixedPrice = res.crowdTaskVO.fixedPrice
+        this.task.doc = []
+        this.task.requireDocUrl = res.crowdTaskVO.requireDocUrl
+
         this.reportList = res.crowdReportVOList
       })
     },
+    handleRemove (file, fileList) {
+      console.log(file, fileList)
+    },
+    handleExceed (files, fileList) {
+      this.$message.warning(
+        `当前限制选择 1 个文件,本次选择了 ${
+          files.length
+          } 个文件,共选择了 ${files.length + fileList.length} 个文件`
+      )
+    },
+    beforeRemove (file, fileList) {
+      return this.$confirm(`确定移除 ${file.name}?`)
+    },
+    beforeFileUpload () {
 
+    },
+    uploadProjectCreateExcelFile (param) {
+      const formData = new FormData()
+      let config = {
+        //添加请求头
+        headers: {'Content-Type': 'multipart/form-data'},
+      }
+      formData.append('file', param.file)
+      Http.upload(Apis.PROJECT.ADD_PROJECT_BY_EXCEL, formData, config).then((res) => {
+        console.log('上传成功')
+        this.project.excelFileUrl = res.data
+        console.log(res.data)
+      })
+    },
+    uploadRequireDoc (param) {
+      const formData = new FormData()
+      let config = {
+        //添加请求头
+        headers: {'Content-Type': 'multipart/form-data'},
+      }
+      formData.append('file', param.file)
+      Http.upload(Apis.FILE.REQUIREMENT_FILE.replace('{userId}', 3), formData, config).then((res) => {
+        console.log('上传成功')
+        this.task.requireDocUrl = res.data
+        console.log(res.data)
+      })
+    },
   },
   // created () {
   //   this.loadData()