sunjh 6 éve
szülő
commit
8bd21348aa

+ 6 - 0
src/components/commons/ProvinceCity.vue

@@ -93,6 +93,12 @@ export default {
         this.city = "";
       }
     }
+  },
+  watch:{
+    data(){
+      this.province = this.provinceCode
+      this.city = this.cityCode
+    }
   }
 };
 </script>

+ 38 - 26
src/components/report/ReportList.vue

@@ -12,13 +12,14 @@
     <el-table :showHeader="false" :data="reportList" style="width: 100%">
       <el-table-column prop="type" label="报告类型" title="报告类型">
         <template slot-scope="scope">
-          <span class="badge">{{scope.row.type}}</span>
+          <span class="badge">{{serviceType[scope.row.type]}}</span>
         </template>
       </el-table-column>
       <el-table-column prop="file" sortable label="报告文件">
         <template slot-scope="scope">
           <span v-if="scope.row.file.length==0">暂无文件</span>
-          <a :href="scope.row.file[0].url" v-if="scope.row.file.length>0" target="_blank"><i class="fa fa-file-text-o"></i> {{scope.row.file[0].name}}</a>
+          <a :href="scope.row.file[0].url" v-if="scope.row.file.length>0" target="_blank"><i
+            class="fa fa-file-text-o"></i> {{scope.row.file[0].name}}</a>
         </template>
       </el-table-column>
       <el-table-column align="right" label="操作">
@@ -31,50 +32,61 @@
   </div>
 </template>
 <script>
+
+import ServiceType from '../../constants/enum/service-type'
+
 export default {
-  name: "report-list",
+  name: 'report-list',
   props: {reports: {}},
-  data() {
+  data () {
     return {
       editIndex: -1,
+      serviceType: ServiceType,
       reportList: this.reports
-    };
+    }
   },
   methods: {
-    handleEdit(index, row) {
-      this.$router.push({ name: "Report" ,params:{reportId:row.id}});
+    handleEdit (index, row) {
+      this.$router.push({name: 'Report', params: {reportId: row.id}})
       // this.editIndex = index;
     },
-    handleDelete(index, row) {
-      this.reportList.splice(index, 1);
+    handleDelete (index, row) {
+      this.reportList.splice(index, 1)
     },
-    cancelEdit(index, row) {
-      this.editIndex = -1;
+    cancelEdit (index, row) {
+      this.editIndex = -1
     },
-    handleRemove(file, fileList) {
-      console.log(file, fileList);
+    handleRemove (file, fileList) {
+      console.log(file, fileList)
     },
-    handleExceed(files, fileList) {
+    handleExceed (files, fileList) {
       this.$message.warning(
         `当前限制选择 1 个文件,本次选择了 ${
           files.length
-        } 个文件,共选择了 ${files.length + fileList.length} 个文件`
-      );
+          } 个文件,共选择了 ${files.length + fileList.length} 个文件`
+      )
     },
-    beforeRemove(file, fileList) {
-      return this.$confirm(`确定移除 ${file.name}?`);
+    beforeRemove (file, fileList) {
+      return this.$confirm(`确定移除 ${file.name}?`)
     },
-    beforeFileUpload() {}
+    beforeFileUpload () {
+    }
+  },
+  watch: {
+    reports () {
+      this.reportList = this.reports
+    }
   }
-};
+}
 </script>
 
 
 <style lang="less" scoped>
-.report-container {
-  margin: 0 30px;
-}
-.el-row {
-  margin-bottom: 20px;
-}
+  .report-container {
+    margin: 0 30px;
+  }
+
+  .el-row {
+    margin-bottom: 20px;
+  }
 </style>

+ 31 - 72
src/components/task/Task.vue

@@ -4,25 +4,25 @@
     <div class="create-body">
       <div class="title h2" v-if="!isModifyMode">基本信息</div>
       <el-form :model="task" :rules="rules" ref="task" label-width="12%" class="demo-task">
-        <el-form-item label="任务名称" prop="name">
-          <el-input v-if="isModifyMode" v-model="task.name"></el-input>
-          <span v-if="!isModifyMode">{{task.name}}</span>
+        <el-form-item label="任务名称" prop="title">
+          <el-input v-if="isModifyMode" v-model="task.title"></el-input>
+          <span v-if="!isModifyMode">{{task.title}}</span>
         </el-form-item>
-        <el-form-item label="任务描述" prop="desc">
-          <el-input v-if="isModifyMode" type="textarea" v-model="task.desc"></el-input>
-          <span v-if="!isModifyMode">{{task.desc}}</span>
+        <el-form-item label="任务描述" prop="description">
+          <el-input v-if="isModifyMode" type="textarea" v-model="task.description"></el-input>
+          <span v-if="!isModifyMode">{{task.description}}</span>
         </el-form-item>
-        <el-form-item label="业务类型" prop="type">
-          <el-radio-group v-if="isModifyMode" v-model="task.type">
-            <el-radio label="接口测试" name="type"></el-radio>
-            <el-radio label="安全漏洞扫描" name="type"></el-radio>
-            <el-radio label="风险评估服务" name="type"></el-radio>
-            <el-radio label="源代码安全审计服务" name="type"></el-radio>
-            <el-radio label="功能测试服务" name="type"></el-radio>
-            <el-radio label="性能测试" name="type"></el-radio>
-            <el-radio label="功能和易用性测试" name="type"></el-radio>
+        <el-form-item label="业务类型" prop="serviceType">
+          <el-radio-group v-if="isModifyMode" v-model="task.serviceType">
+            <el-radio :label="serviceType[0]" name="type"></el-radio>
+            <el-radio :label="serviceType[1]" name="type"></el-radio>
+            <el-radio :label="serviceType[2]" name="type"></el-radio>
+            <el-radio :label="serviceType[3]" name="type"></el-radio>
+            <el-radio :label="serviceType[4]" name="type"></el-radio>
+            <el-radio :label="serviceType[5]" name="type"></el-radio>
+            <el-radio :label="serviceType[6]" name="type"></el-radio>
           </el-radio-group>
-          <span class="badge" v-if="!isModifyMode">{{task.type}}</span>
+          <span class="badge" v-if="!isModifyMode">{{serviceType[task.serviceType]}}</span>
         </el-form-item>
         <el-form-item label="任务可见性" prop="resource">
           <div v-if="!isModifyMode">
@@ -93,6 +93,7 @@
 <script>
 import Enum from '@/constants/enum/index'
 import ResourceType from '@/constants/enum/resource-type.js'
+import ServiceType from '@/constants/enum/service-type'
 import provincecity from '@/components/commons/ProvinceCity'
 import provinceCityJSON from '@/constants/provinceCity.json'
 import ReportList from '@/components/report/ReportList'
@@ -111,46 +112,11 @@ export default {
       institutionArray: Enum.institution,
       tabPosition: 'top',
       resourceType: ResourceType,
+      serviceType:ServiceType,
       taskId: 0,
       projectId: 0,
-      task: {
-        id: 0,
-        projectId: 0,
-        name: '任务名称xxxxs',
-        desc: '任务描述文字',
-        type: '安全漏洞扫描',
-        resource: 1, //如果是广场不用管Location和institution ,定向看institution,区域看location
-        location: {provinceCode: '3200', cityCode: '3201'},
-        institution: '',
-        datetime: new Date('2018-11-11 23:11:11')
-      },
-      reportList: [
-        {
-          id: 1,
-          type: '项目可行性报告',
-          file: []
-        },
-        {
-          id: 2,
-          type: '项目测试方案(汇总)',
-          file: [{name: 'report2', url: 'report2.excel'}]
-        },
-        {
-          id: 3,
-          type: '项目测试报告(汇总)',
-          file: [{name: 'report3', url: 'report3.excel'}]
-        },
-        {
-          id: 4,
-          type: '项目缺陷报告(汇总)',
-          file: [{name: 'report4', url: 'report4.excel'}]
-        },
-        {
-          id: 5,
-          type: '项目用例报告(汇总)',
-          file: [{name: 'report5', url: 'report5.excel'}]
-        }
-      ],
+      task: {},
+      reportList: [],
       pickerOptions: {
         shortcuts: [
           {
@@ -227,6 +193,7 @@ export default {
     init () {
       this.taskId = +this.$route.params.taskId
       this.projectId = +this.$route.params.projectId
+      this.loadData()
     },
     updateLocation (location) {
       var provinceName = ''
@@ -257,20 +224,9 @@ export default {
     },
     cancelMode (formName) {
       this.isModifyMode = false
-      //获得task 信息
-      // this.task = {
-      //   name: "任务名称xxxxs",
-      //   desc: "任务描述文字",
-      //   type: "安全漏洞扫描",
-      //   resource: "区域", //如果是广场不用管Location和institution ,定向看institution,区域看location
-      //   location: { provinceCode: "3200", cityCode: "3201" },
-      //   institution: "",
-      //   datetime: new Date("2018-11-11 23:11:11")
-      // };
     },
     modifyForm () {
       this.isModifyMode = true
-      //获得task 信息
 
     },
     resetForm (formName) {
@@ -279,7 +235,7 @@ export default {
       this.task.name = ''
       this.task.desc = ''
       this.task.type = ''
-      this.task.resource = '广场'; //如果是广场不用管Location和institution ,定向看institution,区域看location
+      this.task.resource = '2'; //如果是广场不用管Location和institution ,定向看institution,区域看location
       (this.task.location = {provinceCode: '', cityCode: ''}),
         (this.task.institution = '')
       this.task.datetime = ''
@@ -302,15 +258,18 @@ export default {
       this.$router.push({name: 'ReportCreate'})
     },
     loadData () {
-      Http.get(Apis.PAGE.TASK_DETAIL_PAGE.replace('{taskId}', this.taskId)).then((res) => {
-        if (0 === res.code) {
-          this.task = res.task
-          this.reportList = res.reportList
-        }
+      //replace('{taskId}', this.taskId)
+      Http.get(Apis.PAGE.TASK_DETAIL_PAGE.replace('{taskId}', 0), {}).then((res) => {
+        this.task = res.task
+        this.reportList = res.reportList
+        console.log(this.task)
       })
     },
 
-  }
+  },
+  // created () {
+  //   this.loadData()
+  // }
 }
 </script>
 

+ 1 - 1
src/mock.js

@@ -25,7 +25,7 @@ Mock.mock(Apis.PAGE.HOME_PAGE, 'get', getHomePageMock.data)
 Mock.mock(Apis.PAGE.SQUARE_PAGE, 'get', getSquarePageMock.data)
 Mock.mock(Apis.PAGE.PROJECT_DETAIL_PAGE, 'get', getProjectDetailMock.data)
 Mock.mock(Apis.PAGE.REPORT_DETAIL_PAGE, 'get', getReportDetailMock.data)
-Mock.mock(Apis.PAGE.TASK_DETAIL_PAGE, 'get', getTaskDetailMock.data)
+Mock.mock(Apis.PAGE.TASK_DETAIL_PAGE.replace('{taskId}', 0), 'get', getTaskDetailMock.data)
 Mock.mock(Apis.PAGE.MY_CROWD_TEST_PAGE, 'get', getMyCrowdTestMock.data)
 Mock.mock(Apis.PROJECT.UPDATE_PROJECT_SUBMIT, 'put', updateProjectMock.data)
 Mock.mock(Apis.REPORT.UPDATE_REPORT_SUBMIT, 'put', updateReportMock.data)

+ 48 - 0
src/mock/getSquarePageMock.js

@@ -43,6 +43,54 @@ var data = Mock.mock({
       'serviceType': 0,
       'participantNum': 0,
       'status': 1
+    },
+    {
+      'id': 1,
+      'coverImgUrl': '',
+      'projectId': 1234,
+      'title': '多人聊天发送文件测试',
+      'platform': [0],
+      'description': '任务描述文字xxxx',
+      'price': '10',
+      'serviceType': 0,
+      'participantNum': 0,
+      'status': 1
+    },
+    {
+      'id': 1,
+      'coverImgUrl': '',
+      'projectId': 1234,
+      'title': '多人聊天发送文件测试',
+      'platform': [0],
+      'description': '任务描述文字xxxx',
+      'price': '10',
+      'serviceType': 0,
+      'participantNum': 0,
+      'status': 1
+    },
+    {
+      'id': 1,
+      'coverImgUrl': '',
+      'projectId': 1234,
+      'title': '多人聊天发送文件测试',
+      'platform': [0],
+      'description': '任务描述文字xxxx',
+      'price': '10',
+      'serviceType': 0,
+      'participantNum': 0,
+      'status': 1
+    },
+    {
+      'id': 1,
+      'coverImgUrl': '',
+      'projectId': 1234,
+      'title': '多人聊天发送文件测试',
+      'platform': [0],
+      'description': '任务描述文字xxxx',
+      'price': '10',
+      'serviceType': 0,
+      'participantNum': 0,
+      'status': 1
     }
   ]
 })

+ 4 - 4
src/mock/getTaskDetailMock.js

@@ -53,12 +53,12 @@ var data = Mock.mock({
       // 5: "性能测试",
       // 6: "功能和易用性测试",
       'type': 1,
-      'file': {
+      'file': [{
         //报告文件名
         'name': 'report2',
         //报告文件url
         'url': 'report2.excel'
-      }
+      }]
     },
     {
       'id': 3,
@@ -70,10 +70,10 @@ var data = Mock.mock({
       // 5: "性能测试",
       // 6: "功能和易用性测试",
       'type': 2,
-      'file': {
+      'file': [{
         'name': 'report3',
         'url': 'report3.excel'
-      }
+      }]
     }
   ]
 })