Forráskód Böngészése

update serviceCode

wangJJ 5 éve
szülő
commit
0151eb0f4c
2 módosított fájl, 318 hozzáadás és 314 törlés
  1. 22 21
      src/components/task/Task.vue
  2. 296 293
      src/components/task/TaskCreate.vue

+ 22 - 21
src/components/task/Task.vue

@@ -29,30 +29,21 @@
         <!--<span v-if="!isModifyMode">{{task.fixedPrice}}</span>-->
         <!--</el-form-item>-->
         <el-form-item label="测试类型" prop="serviceType">
-          <el-radio-group v-if="isModifyMode" v-model="task.serviceType">
+          <el-radio-group v-if="isModifyMode" v-model="task.serviceType" @change="handleTestTypeChange">
             <span v-for="(item,index) in serviceType" :key="index">
-              <el-radio :label="item.name" name="serviceType">{{item.name}}</el-radio>
+              <el-radio :label="item.code" name="serviceType">{{item.name}}</el-radio>
             </span>
           </el-radio-group>
-          <span class="badge" v-if="!isModifyMode">{{task.serviceType}}</span>
+          <span class="badge" v-if="!isModifyMode">{{serviceName}}</span>
         </el-form-item>
 
-        <el-form-item label="examId" prop="endPointVO.examId" style="width: 700px;"
+        <el-form-item label="serverCode" prop="endPointVO.serverCode" style="width: 700px;"
                       v-if="showBD&&task.endPointVO&&currType.type===1"
-                      :rules="[{ required: true, message: '请输入examId', trigger: 'blur' }]">
-          <el-input v-if="isModifyMode" v-model="task.endPointVO.examId" label="examId"></el-input>
-          <span v-if="!isModifyMode&&showBD">{{task.endPointVO.examId}}</span>
+                      :rules="[{ required: true, message: 'serverCode', trigger: 'blur' }]">
+          <el-input v-if="isModifyMode" v-model="task.endPointVO.serverCode" label="examId"></el-input>
+          <span v-if="!isModifyMode&&showBD">{{task.endPointVO.serverCode}}</span>
         </el-form-item>
 
-
-        <el-form-item label="caseId" prop="endPointVO.caseId" style="width: 700px;"
-                      v-if="showBD&&task.endPointVO&&currType.type===1"
-                      :rules="[{ required: true, message: '请输入caseId', trigger: 'blur' }]">
-          <el-input v-if="isModifyMode" v-model.number="task.endPointVO.caseId" label="caseId"></el-input>
-          <span v-if="!isModifyMode&&showBD">{{task.endPointVO.caseId}}</span>
-        </el-form-item>
-
-
         <el-form-item label="任务可见性" prop="resource" style="width: 700px;">
           <div v-if="!isModifyMode">
             <!--<div v-if="task.resource=='1'">{{updateLocation(task.location)}}</div>-->
@@ -274,6 +265,7 @@
       return {
         currType: {},
         user: {},
+        serviceName:'',
         showBD: true,
         rolesPermissions: {},
         loading: false,
@@ -310,8 +302,7 @@
           title: '',
           description: '',
           endPointVO: {
-            caseId: '',
-            examId: ''
+            serverCode: '',
           }
         },
         reportList: [],
@@ -367,6 +358,7 @@
             {required: true},
             {
               validator: (rule, value, callback) => {
+                console.log(value)
                 if (value == 0 && this.task.institution.id == null) {
                   callback(new Error('定向发布至少要选择一个测评机构'))
                 } else {
@@ -413,6 +405,14 @@
       })
     },
     methods: {
+      getServiceByCode(code){
+        let serviceName = this.serviceType.filter((item) => {
+          return item.code === code;
+        });
+        console.log(serviceName)
+        return serviceName&&serviceName[0]&&serviceName[0]['name']
+      },
+
       handleTestTypeChange(val) {
         let type = this.serviceType.filter((item) => {
           return item.code === val;
@@ -530,13 +530,14 @@
         this.task.status = res.crowdTaskVO.status
         this.task.statusVO = res.crowdTaskVO.statusVO
         this.task.endPointVO = res.crowdTaskVO.endPointVO ? res.crowdTaskVO.endPointVO : {
-          caseId: '',
-          examId: ''
+          serverCode: '',
         }
         this.taskOperationControl = res.taskOperationControl
         this.acceptedUserList = res.acceptedUserList;
         this.crowdReportUrl = res.crowdTaskVO.writeReportUrl;
         this.handleFormatReport(this.acceptedUserList);
+        this.handleTestTypeChange(res.crowdTaskVO.serviceType);
+        this.serviceName = this.getServiceByCode(res.crowdTaskVO.serviceType);
       },
       //获取任务详情失败时回调函数
       getTaskDetailFail(error) {
@@ -593,7 +594,7 @@
               fixedPrice: this.task.fixedPrice,
               requirementFile: this.task.requireDocUrl,
               participantCount: this.task.participantCount,
-              endpoint: this.task.endPointVO
+              endPoint: this.task.endPointVO
             }
             //console.log(newTask)
             updateTask(this.projectId, this.taskId, newTask, this.updateTaskSuccess, this.updateTaskFail)

+ 296 - 293
src/components/task/TaskCreate.vue

@@ -59,8 +59,10 @@
           </el-tabs>
         </el-form-item>
 
-        <el-form-item label="任务可见性" prop="resource" style="width:700px;" v-if="currType.type ==1">
-          <el-tabs :tab-position="tabPosition" v-model="task.resource" style="width: 800px">
+        <el-form-item label="任务可见性" prop="resource" style="width:700px;"
+                      v-if="currType.type ==1"
+                      required>
+          <el-tabs :tab-position="tabPosition" v-model="task.resource" value='2' style="width: 800px">
             <el-tab-pane :label="resourceType[2]" name="2"></el-tab-pane>
           </el-tabs>
         </el-form-item>
@@ -123,315 +125,316 @@
   import {getAllAgencies, getAllServiceTypes, getProvinceNameByProvinceCode, storageGet} from '@/js/index'
 
   export default {
-  name: 'Task',
-  components: {
-    provincecity
-  },
-  data () {
-    return {
-      currType:{},
-      user: {},
-      projectId: 0,
-      institutionArray: [],
-      tabPosition: 'top',
-      resourceType: ResourceType,
-      loading: false,
-      serviceType: [],
-      task: {
-        name: '',
-        desc: '',
-        type: '',
-        resource: '0', //如果是广场不用管Location和institution ,定向看institution,区域看location
-        // location: {provinceCode: '3200', cityCode: '3201'},
-        institution: '',
-        datetime: '',
-        quotePrice: '',
-        fixedPrice: '',
-        doc: [],
-        requireDocUrl: '',
-        participantCount: 1,
-        endPoint:{
-          serverCode:'',
-        }
-      },
-      pickerOptions: {
-        shortcuts: [
-          {
-            text: '今天',
-            onClick (picker) {
-              picker.$emit('pick', new Date())
-            }
-          },
-          {
-            text: '昨天',
-            onClick (picker) {
-              const date = new Date()
-              date.setTime(date.getTime() - 3600 * 1000 * 24)
-              picker.$emit('pick', date)
-            }
-          },
-          {
-            text: '一周前',
-            onClick (picker) {
-              const date = new Date()
-              date.setTime(date.getTime() - 3600 * 1000 * 24 * 7)
-              picker.$emit('pick', date)
-            }
+    name: 'Task',
+    components: {
+      provincecity
+    },
+    data() {
+      return {
+        currType: {},
+        user: {},
+        projectId: 0,
+        institutionArray: [],
+        tabPosition: 'top',
+        resourceType: ResourceType,
+        loading: false,
+        serviceType: [],
+        task: {
+          name: '',
+          desc: '',
+          type: '',
+          resource: '', //如果是广场不用管Location和institution ,定向看institution,区域看location
+          // location: {provinceCode: '3200', cityCode: '3201'},
+          institution: '',
+          datetime: '',
+          quotePrice: '',
+          fixedPrice: '',
+          doc: [],
+          requireDocUrl: '',
+          participantCount: 1,
+          endPoint: {
+            serverCode: '',
           }
-        ]
-      },
-      rules: {
-        name: [
-          {required: true, message: '请输入任务名称', trigger: 'blur'},
-          {min: 5, max: 50, message: '任务名称长度在 5 到 50 个字符', trigger: 'blur'}
-        ],
-        type: [
-          {required: true, message: '测试类型不可为空'},
-        ],
-        desc: [{required: false, message: '请填写描述', trigger: 'blur'}],
-        //price: [{required: true, message: '请填写价格', trigger: 'blur'}],
-        quotePrice: [
-          {required: true, message: '预算不可为空', trigger: 'blur'},
-          {
-            validator: (rule, value, callback) => {
-              if (parseInt(value) < 0) {
-                callback(new Error('请输入不小于0的数'))
-              } else {
-                callback()
+        },
+        pickerOptions: {
+          shortcuts: [
+            {
+              text: '今天',
+              onClick(picker) {
+                picker.$emit('pick', new Date())
               }
-            }, trigger: 'blur'
-          },
-        ],
-        resource: [
-          {required: true},
-          {
-            validator: (rule, value, callback) => {
-              console.log(value)
-              if (value == 0 && this.task.institution.id == null) {
-                callback(new Error('定向发布至少要选择一个测评机构'))
-              } else {
-                callback()
+            },
+            {
+              text: '昨天',
+              onClick(picker) {
+                const date = new Date()
+                date.setTime(date.getTime() - 3600 * 1000 * 24)
+                picker.$emit('pick', date)
               }
-            }, trigger: 'change'
-          },
-        ],
-        endPoint:[
-          {
-            validator: (rule, value, callback) => {
-              if (this.currType.type=== 1 && this.task.endPoint.serverCode === '') {
-                callback(new Error('请填写对应得serverCode'))
-              } else {
-                callback()
+            },
+            {
+              text: '一周前',
+              onClick(picker) {
+                const date = new Date()
+                date.setTime(date.getTime() - 3600 * 1000 * 24 * 7)
+                picker.$emit('pick', date)
               }
-            }, trigger: 'change'
-          },
-        ],
-        datetime: [{required: true, message: '截止时间不可为空', trigger: 'blur'}],
+            }
+          ]
+        },
+        rules: {
+          name: [
+            {required: true, message: '请输入任务名称', trigger: 'blur'},
+            {min: 5, max: 50, message: '任务名称长度在 5 到 50 个字符', trigger: 'blur'}
+          ],
+          type: [
+            {required: true, message: '测试类型不可为空'},
+          ],
+          desc: [{required: false, message: '请填写描述', trigger: 'blur'}],
+          //price: [{required: true, message: '请填写价格', trigger: 'blur'}],
+          quotePrice: [
+            {required: true, message: '预算不可为空', trigger: 'blur'},
+            {
+              validator: (rule, value, callback) => {
+                if (parseInt(value) < 0) {
+                  callback(new Error('请输入不小于0的数'))
+                } else {
+                  callback()
+                }
+              }, trigger: 'blur'
+            },
+          ],
+          resource: [
+            {required: true},
+            {
+              validator: (rule, value, callback) => {
+                if (value == 0 && this.task.institution.id == null) {
+                  callback(new Error('定向发布至少要选择一个测评机构'))
+                } else {
+                  callback()
+                }
+              }, trigger: 'change'
+            },
+          ],
+          endPoint: [
+            {
+              validator: (rule, value, callback) => {
+                if (this.currType.type === 1 && this.task.endPoint.serverCode === '') {
+                  callback(new Error('请填写对应得serverCode'))
+                } else {
+                  callback()
+                }
+              }, trigger: 'change'
+            },
+          ],
+          datetime: [{required: true, message: '截止时间不可为空', trigger: 'blur'}],
+        }
       }
-    }
-  },
-  watch: {
-    serviceType (val) {
-      this.serviceType = val
-    },
-    institution (val) {
-      this.institution = val
     },
-    // 'task.institution' () {
-    //   if (this.task.institution) {
-    //     this.$refs.addFormProvince.resetProviceCity()
-    //     this.task.location = {provinceCode: '', cityCode: ''}
-    //   }
-    // },
-    // 'task.location' () {
-    //   if (this.task.location.provinceCode || this.task.location.cityCode) {
-    //     this.task.institution = ''
-    //   }
-    // },
-    // 'task.resource' () {
-    //   if (this.task.resource == '广场') {
-    //     this.$refs.addFormProvince.resetProviceCity()
-    //     this.task.institution = ''
-    //     this.task.location = {provinceCode: '', cityCode: ''}
-    //   }
-    // },
-    deep: true
-  },
-  mounted () {
-    this.$nextTick(() => {
-      this.init()
-    })
-  },
-  methods: {
-    handleTestTypeChange(val){
-      let type = this.serviceType.filter((item)=>{
-        return item.code === val ;
-      });
-      this.currType = type[0] ? type[0] : {};
-      if(this.currType.type === 0){
-        this.task.participantCount = 1
-      }
+    watch: {
+      serviceType(val) {
+        this.serviceType = val
+      },
+      institution(val) {
+        this.institution = val
+      },
+      // 'task.institution' () {
+      //   if (this.task.institution) {
+      //     this.$refs.addFormProvince.resetProviceCity()
+      //     this.task.location = {provinceCode: '', cityCode: ''}
+      //   }
+      // },
+      // 'task.location' () {
+      //   if (this.task.location.provinceCode || this.task.location.cityCode) {
+      //     this.task.institution = ''
+      //   }
+      // },
+      // 'task.resource' () {
+      //   if (this.task.resource == '广场') {
+      //     this.$refs.addFormProvince.resetProviceCity()
+      //     this.task.institution = ''
+      //     this.task.location = {provinceCode: '', cityCode: ''}
+      //   }
+      // },
+      deep: true
     },
-    init () {
-      this.projectId = this.$route.params.projectId
-      this.setServiceType()
-      this.setInstitutions()
-      this.setUserInfo()
+    mounted() {
+      this.$nextTick(() => {
+        this.init()
+      })
     },
-    updateLocation (location) {
-      var provinceName = ''
-      var cityName = ''
-      for (var item of provinceCityJSON.provinces) {
-        if (item.code === location.provinceCode) {
-          provinceName = item.name
-          for (var city of item.cities) {
-            if (city.code === location.cityCode) {
-              cityName = city.name
-              break
+    methods: {
+      handleTestTypeChange(val) {
+        let type = this.serviceType.filter((item) => {
+          return item.code === val;
+        });
+        this.currType = type[0] ? type[0] : {};
+        if (this.currType.type === 0) {
+          this.task.participantCount = 1
+        }else{
+          this.task.resource = '2'
+        }
+      },
+      init() {
+        this.projectId = this.$route.params.projectId
+        this.setServiceType()
+        this.setInstitutions()
+        this.setUserInfo()
+      },
+      updateLocation(location) {
+        var provinceName = ''
+        var cityName = ''
+        for (var item of provinceCityJSON.provinces) {
+          if (item.code === location.provinceCode) {
+            provinceName = item.name
+            for (var city of item.cities) {
+              if (city.code === location.cityCode) {
+                cityName = city.name
+                break
+              }
             }
           }
         }
-      }
-      return provinceName + ' / ' + cityName
-    },
-    submitForm (formName) {
-      this.$refs['task'].validate(valid => {
-        if (valid) {
-          this.showLoading()
-          const newTask = {
-            name: this.task.name,
-            desc: this.task.desc,
-            type: this.task.type,
-            resource: this.task.resource,
-            // location: this.task.resource == '0' ? getProvinceNameByProvinceCode(this.task.location.provinceCode, this.task.location.cityCode):null,
-            institution: this.task.resource == '0' ? this.task.institution.id : null,
-            datetime: this.task.datetime,
-            quotePrice: this.task.quotePrice,
-            fixedPrice: this.task.fixedPrice,
-            requirementFile: this.task.requireDocUrl,
-            participantCount: this.task.participantCount,
-            endPoint:this.task.endPoint
+        return provinceName + ' / ' + cityName
+      },
+      submitForm(formName) {
+        this.$refs['task'].validate(valid => {
+          if (valid) {
+            this.showLoading()
+            const newTask = {
+              name: this.task.name,
+              desc: this.task.desc,
+              type: this.task.type,
+              resource: this.task.resource,
+              // location: this.task.resource == '0' ? getProvinceNameByProvinceCode(this.task.location.provinceCode, this.task.location.cityCode):null,
+              institution: this.task.resource == '0' ? this.task.institution.id : null,
+              datetime: this.task.datetime,
+              quotePrice: this.task.quotePrice,
+              fixedPrice: this.task.fixedPrice,
+              requirementFile: this.task.requireDocUrl,
+              participantCount: this.task.participantCount,
+              endPoint: this.task.endPoint
+            }
+            Http.post(Apis.TASK.CREATE_TASK.replace('{projectId}', this.projectId), newTask).then((res) => {
+              console.log(res)
+              this.hideLoading()
+              this.createTaskSuccess(res.crowdTaskVO.id)
+            }).catch((error) => {
+              console.log(error)
+              this.hideLoading()
+              notify('error', error.data)
+            })
+          } else {
+            notify('error', '表单填写有误!')
+            return false
           }
-          Http.post(Apis.TASK.CREATE_TASK.replace('{projectId}', this.projectId), newTask).then((res) => {
-            console.log(res)
-            this.hideLoading()
-            this.createTaskSuccess(res.crowdTaskVO.id)
-          }).catch((error) => {
-            console.log(error)
-            this.hideLoading()
-            notify('error', error.data)
-          })
-        } else {
-          notify('error', '表单填写有误!')
+        })
+      },
+      resetForm(formName) {
+        this.$refs.addFormProvince.resetProviceCity()
+        this.$refs[formName].resetFields()
+        this.task.name = ''
+        this.task.desc = ''
+        this.task.type = ''
+        this.task.resource = '广场'; //如果是广场不用管Location和institution ,定向看institution,区域看location
+        (this.task.location = {provinceCode: '', cityCode: ''}),
+          (this.task.institution = '')
+        this.task.datetime = '',
+          this.task.participantCount = 1
+      },
+      locationChange(provinceId, cityId) {
+        if (provinceId || cityId) {
+          this.task.location = {provinceCode: provinceId, cityCode: cityId}
+        }
+      },
+      cancelCreate() {
+        if (window.history.length <= 1) {
+          this.$router.push({path: '/'})
           return false
+        } else {
+          this.$router.go(-1)
         }
-      })
-    },
-    resetForm (formName) {
-      this.$refs.addFormProvince.resetProviceCity()
-      this.$refs[formName].resetFields()
-      this.task.name = ''
-      this.task.desc = ''
-      this.task.type = ''
-      this.task.resource = '广场'; //如果是广场不用管Location和institution ,定向看institution,区域看location
-      (this.task.location = {provinceCode: '', cityCode: ''}),
-        (this.task.institution = '')
-      this.task.datetime = '',
-        this.task.participantCount = 1
-    },
-    locationChange (provinceId, cityId) {
-      if (provinceId || cityId) {
-        this.task.location = {provinceCode: provinceId, cityCode: cityId}
-      }
-    },
-    cancelCreate () {
-      if (window.history.length <= 1) {
-        this.$router.push({path: '/'})
-        return false
-      } else {
-        this.$router.go(-1)
-      }
-    },
-    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 (file) {
-      console.log(file)
-      const isPDF = file.type === 'application/pdf'
-      const isDOC = file.type === 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'
-      const isEXCEL = file.type === 'application/vnd.ms-excel'
-      const isXLS = file.type === 'application/x-xls'
-      const isTXT = file.type === 'text/plain'
-      const isXLSX = file.type === 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
-      //console.log(file)
-      if (!(isDOC || isEXCEL || isPDF || isTXT || isXLS || isXLSX)) {
-        this.$message.error('上传文件只能是 PDF 、 DOC 、DOCX 、XLS、TXT、XLSX 格式!')
-      }
-      return isDOC || isEXCEL || isPDF || isTXT || isXLS || isXLSX
-    },
-    uploadRequireDoc (param) {
-      this.showLoading()
-      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}', this.user.userVO.id), formData, config).then((res) => {
-        this.hideLoading()
-        notify('success', '上传成功')
-        this.task.requireDocUrl = res.data
-        console.log(res.data)
-      }).catch((error) => {
-        this.hideLoading()
-        notify('error', '上传失败:' + error.data)
-      })
-    },
-    setServiceType () {
+      },
+      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(file) {
+        console.log(file)
+        const isPDF = file.type === 'application/pdf'
+        const isDOC = file.type === 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'
+        const isEXCEL = file.type === 'application/vnd.ms-excel'
+        const isXLS = file.type === 'application/x-xls'
+        const isTXT = file.type === 'text/plain'
+        const isXLSX = file.type === 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
+        //console.log(file)
+        if (!(isDOC || isEXCEL || isPDF || isTXT || isXLS || isXLSX)) {
+          this.$message.error('上传文件只能是 PDF 、 DOC 、DOCX 、XLS、TXT、XLSX 格式!')
+        }
+        return isDOC || isEXCEL || isPDF || isTXT || isXLS || isXLSX
+      },
+      uploadRequireDoc(param) {
+        this.showLoading()
+        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}', this.user.userVO.id), formData, config).then((res) => {
+          this.hideLoading()
+          notify('success', '上传成功')
+          this.task.requireDocUrl = res.data
+          console.log(res.data)
+        }).catch((error) => {
+          this.hideLoading()
+          notify('error', '上传失败:' + error.data)
+        })
+      },
+      setServiceType() {
         getAllServiceTypes().then((res) => {
-            this.serviceType = res
+          this.serviceType = res
         })
-    },
-    setInstitutions () {
-      getAllAgencies().then((res) => {
-        this.institutionArray = res
-        console.log(this.institutionArray)
-      }).catch((error) => {
-        notify('error', '测评机构加载失败')
-      })
-    },
-    setUserInfo () {
-      this.user = storageGet('user')
-    },
-    createTaskSuccess (taskId) {
-      this.$alert('任务创建成功', '创建成功', {
-        confirmButtonText: '确定',
-        callback: action => {
-          this.$router.push({
-            name: 'Task',
-            params: {projectId: this.projectId, taskId: taskId}
-          })
-        }
-      })
-    },
-    showLoading () {
-      this.loading = true
-    },
-    hideLoading () {
-      this.loading = false
+      },
+      setInstitutions() {
+        getAllAgencies().then((res) => {
+          this.institutionArray = res
+          console.log(this.institutionArray)
+        }).catch((error) => {
+          notify('error', '测评机构加载失败')
+        })
+      },
+      setUserInfo() {
+        this.user = storageGet('user')
+      },
+      createTaskSuccess(taskId) {
+        this.$alert('任务创建成功', '创建成功', {
+          confirmButtonText: '确定',
+          callback: action => {
+            this.$router.push({
+              name: 'Task',
+              params: {projectId: this.projectId, taskId: taskId}
+            })
+          }
+        })
+      },
+      showLoading() {
+        this.loading = true
+      },
+      hideLoading() {
+        this.loading = false
+      }
     }
   }
-}
 </script>
 
 <style lang="less" scoped>