1 |
- webpackJsonp([19],{"3H+J":function(e,t,o){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=o("SQ4B"),i=o("b9vf"),n=o("qI5z"),a=o("vGYV"),s={name:"TaskReport",components:{},data:function(){return{user:{},loading:!1,reportId:0,projectId:"",taskId:"",isModifyMode:!1,operational:"",reportType:[],report:{name:"",type:"",description:"",target:"",content:"",file:[],fileUrl:"",conclusion:"",participantCount:1},rules:{name:[{required:!0,message:"任务名称不可为空",trigger:"blur"},{min:5,max:50,message:"报告名称长度在 5 到 50 个字符",trigger:"blur"}],type:[{required:!0,message:"报告类型不可为空"}],target:[{required:!0,message:"测试对象不可为空",trigger:"blur"}],content:[{required:!0,message:"测试内容不可为空",trigger:"blur"}],conclusion:[{required:!0,message:"结论不可为空",trigger:"blur"}]}}},mounted:function(){var e=this;this.$nextTick(function(){e.init()})},methods:{init:function(){this.reportId=this.$route.params.reportId,this.projectId=this.$route.params.projectId,this.taskId=this.$route.params.taskId,this.setReportType(),this.setUserInfo(),this.loadData()},modifyForm:function(){this.isModifyMode=!0},submitForm:function(e){var t=this;this.$refs.report.validate(function(e){if(!e)return Object(n.a)("error","表单填写有误"),!1;t.isModifyMode=!1,t.showLoading();var o={name:t.report.name,scope:null==t.taskId?0:1,type:t.report.type,dependencyCode:null==t.taskId?t.projectId:t.taskId,target:t.report.target,content:t.report.content,file:t.report.fileUrl,conclusion:t.report.conclusion,participantCount:t.report.participantCount};console.log(o),r.a.put(i.a.REPORT.UPDATE_TASK_REPORT.replace("{projectId}",t.projectId).replace("{taskId}",t.taskId).replace("{reportId}",t.reportId),o).then(function(e){console.log(e),t.hideLoading(),t.isModifyMode=!1}).catch(function(e){t.hideLoading(),Object(n.a)("error",e.data)})})},resetForm:function(e){this.$refs[e].resetFields(),this.report.name="",this.report.target="",this.report.content="",this.report.file="",this.report.type="",this.report.conclusion="",this.report.participantCount=1},cancelCreate:function(){this.isModifyMode=!1},handleRemove:function(e,t){console.log(e,t)},handleExceed:function(e,t){this.$message.warning("当前限制选择 1 个文件,本次选择了 "+e.length+" 个文件,共选择了 "+(e.length+t.length)+" 个文件")},beforeRemove:function(e,t){},beforeFileUpload:function(e){return!0},back:function(){this.$router.push({name:"Task",params:{projectId:this.projectId,taskId:this.taskId}})},loadData:function(){var e=this;this.showLoading(),r.a.get(i.a.REPORT.GET_TASK_REPORT.replace("{projectId}",this.projectId).replace("{taskId}",this.taskId).replace("{reportId}",this.reportId)).then(function(t){console.log(t),e.report.name=t.crowdReportVO.name,e.report.crowdTestTaskId=t.crowdReportVO.crowdTestTaskId,e.report.scope=t.crowdReportVO.scope,e.report.type=t.crowdReportVO.type,e.report.description=t.crowdReportVO.description,e.report.content=t.crowdReportVO.content,e.report.fileUrl=t.crowdReportVO.file,e.report.conclusion=t.crowdReportVO.conclusion,e.report.target=t.crowdReportVO.target,e.report.participantCount=t.crowdReportVO.participantCount,e.operational=t.operational,e.hideLoading()}).catch(function(t){e.hideLoading(),Object(n.a)("error","打开报告失败:"+t.data)})},uploadReportFile:function(e){var t=this;this.showLoading();var o=new FormData;o.append("file",e.file),r.a.upload(i.a.FILE.UPLOAD_REPORT_FILE.replace("{userId}",this.user.userVO.id),o,{headers:{"Content-Type":"multipart/form-data"}}).then(function(e){console.log("上传成功"),t.report.fileUrl=e.data,console.log(e),t.hideLoading()}).catch(function(e){t.hideLoading(),Object(n.a)("error","文件上传失败:"+e.data)})},setReportType:function(){var e=this;Object(a.q)().then(function(t){e.reportType=t}).catch(function(e){Object(n.a)("error","加载报告类型失败")})},setUserInfo:function(){this.user=Object(a.K)("user")},updateReportSuccess:function(){},showLoading:function(){this.loading=!0},hideLoading:function(){this.loading=!1}},watch:{reportType:function(e){this.reportType=e}}},p={render:function(){var e=this,t=e.$createElement,o=e._self._c||t;return o("div",{staticClass:"create-container"},[o("div",{directives:[{name:"loading",rawName:"v-loading",value:e.loading,expression:"loading"}],staticClass:"create-body"},[o("el-form",{ref:"report",staticClass:"demo-report",attrs:{model:e.report,rules:e.rules,"label-width":"12%"}},[o("el-form-item",{attrs:{label:"报告名称",prop:"name"}},[e.isModifyMode?o("el-input",{attrs:{size:"small"},model:{value:e.report.name,callback:function(t){e.$set(e.report,"name",t)},expression:"report.name"}}):e._e(),e._v(" "),e.isModifyMode?e._e():o("span",[e._v(e._s(e.report.name))])],1),e._v(" "),o("el-form-item",{attrs:{label:"报告类型",prop:"type"}},[e.isModifyMode?o("el-radio-group",{model:{value:e.report.type,callback:function(t){e.$set(e.report,"type",t)},expression:"report.type"}},e._l(e.reportType,function(t,r){return o("span",{key:r},[o("el-radio",{attrs:{label:t,name:"type"}},[e._v(e._s(t))])],1)}),0):e._e(),e._v(" "),e.isModifyMode?e._e():o("span",{staticClass:"badge"},[e._v(e._s(e.report.type))])],1),e._v(" "),o("el-form-item",{attrs:{label:"测试对象",prop:"target"}},[e.isModifyMode?o("el-input",{attrs:{autosize:"",type:"textarea"},model:{value:e.report.target,callback:function(t){e.$set(e.report,"target",t)},expression:"report.target"}}):e._e(),e._v(" "),e.isModifyMode?e._e():o("span",[e._v(e._s(e.report.target))])],1),e._v(" "),o("el-form-item",{attrs:{label:"测试内容",prop:"content"}},[e.isModifyMode?o("el-input",{attrs:{autosize:"",type:"textarea"},model:{value:e.report.content,callback:function(t){e.$set(e.report,"content",t)},expression:"report.content"}}):e._e(),e._v(" "),e.isModifyMode?e._e():o("span",[e._v(e._s(e.report.content))])],1),e._v(" "),o("el-form-item",{attrs:{prop:"file",label:"报告文件"}},[e.isModifyMode?o("el-upload",{staticClass:"upload-demo",staticStyle:{width:"400px"},attrs:{drag:"",action:"","on-remove":e.handleRemove,"before-remove":e.beforeRemove,multiple:"",limit:1,"on-exceed":e.handleExceed,"before-upload":e.beforeFileUpload,"file-list":e.report.file,"http-request":e.uploadReportFile}},[o("i",{staticClass:"el-icon-upload"}),e._v(" "),o("div",{staticClass:"el-upload__text"},[e._v("\n 将文件拖到此处,或\n "),o("em",[e._v("点击上传")])]),e._v(" "),o("div",{staticClass:"el-upload__tip",attrs:{slot:"tip"},slot:"tip"},[e._v("请上传报告文件")])]):e._e(),e._v(" "),e.isModifyMode?e._e():o("div",[null==e.report.fileUrl?o("span",[e._v("暂无文件")]):e._e(),e._v(" "),null!=e.report.fileUrl?o("a",{attrs:{href:e.report.fileUrl}},[o("el-link",{attrs:{underline:!1,type:"primary"}},[o("i",{staticClass:"el-icon-document"}),e._v("下载文档")])],1):e._e()])],1),e._v(" "),o("el-form-item",{attrs:{label:"结论",prop:"conclusion"}},[e.isModifyMode?o("el-input",{attrs:{autosize:"",type:"textarea"},model:{value:e.report.conclusion,callback:function(t){e.$set(e.report,"conclusion",t)},expression:"report.conclusion"}}):e._e(),e._v(" "),e.isModifyMode?e._e():o("span",[e._v(e._s(e.report.conclusion))])],1),e._v(" "),e.isModifyMode?e._e():o("el-form-item",[e.operational?o("div",{staticClass:"btn btn-medium btn-info",on:{click:function(t){return e.modifyForm()}}},[e._v("修改")]):e._e(),e._v(" "),o("div",{staticClass:"btn btn-medium",on:{click:function(t){return e.back()}}},[e._v("返回")])]),e._v(" "),e.isModifyMode?o("el-form-item",[o("div",{staticClass:"btn btn-medium btn-info",on:{click:function(t){return e.submitForm("report")}}},[e._v("确认修改")]),e._v(" "),o("div",{staticClass:"btn btn-medium",on:{click:function(t){return e.cancelCreate("report")}}},[e._v("取消")])]):e._e()],1)],1)])},staticRenderFns:[]};var l=o("VU/8")(s,p,!1,function(e){o("p1wF")},"data-v-e1186c80",null);t.default=l.exports},p1wF:function(e,t){}});
|