webpackJsonp([19],{TGdV:function(e,t){},tFWN:function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var o=r("SQ4B"),a=r("b9vf"),n=r("qI5z"),i=r("vGYV"),s={name:"TaskReportCreate",components:{},data:function(){return{user:{},loading:!1,reportType:[],scope:0,projectId:"",taskId:"",dependencyCode:"",report:{name:"",target:"",content:"",file:[],fileUrl:"",type:"",conclusion:""},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.scope=this.$route.params.scope,this.dependencyCode=this.$route.params.dependencyCode,this.projectId=this.$route.params.projectId,this.taskId=this.$route.params.taskId,this.setUserInfo(),this.setReportType()},submitForm:function(e){var t=this;this.$refs.report.validate(function(e){if(!e)return Object(n.a)("error","表单填写有误"),!1;t.showLoading();var r={name:t.report.name,scope:t.scope,type:t.report.type,dependencyCode:t.dependencyCode,target:t.report.target,content:t.report.content,file:t.report.fileUrl,conclusion:t.report.conclusion};console.log(r),o.a.post(a.a.REPORT.CREATE_TASK_REPORT.replace("{projectId}",t.projectId).replace("{taskId}",t.taskId),r).then(function(e){t.hideLoading(),t.createReportSuccess(e.crowdReportVO.code)}).catch(function(e){t.hideLoading(),Object(n.a)("error","报告创建失败:"+e.data)})})},resetForm:function(e){this.$refs[e].resetFields(),this.report.name="",this.report.abstract.target="",this.report.abstract.content="",this.report.file=[],this.report.type="",this.report.conclusion=""},cancelCreate:function(){if(window.history.length<=1)return this.$router.push({path:"/"}),!1;this.$router.go(-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){},loadData:function(){},uploadReportFile:function(e){var t=this,r=new FormData;r.append("file",e.file),o.a.upload(a.a.FILE.UPLOAD_REPORT_FILE.replace("{userId}",this.user.userVO.id),r,{headers:{"Content-Type":"multipart/form-data"}}).then(function(e){Object(n.a)("success","上传成功"),t.report.fileUrl=e.data,console.log(e)})},setReportType:function(){var e=this;this.reportType=Object(i.q)().then(function(t){e.reportType=t}).catch(function(e){Object(n.a)("error","获取报告类型列表失败")})},setUserInfo:function(){this.user=Object(i.J)("user")},createReportSuccess:function(e){var t=this;this.$alert("报告创建成功","创建成功",{confirmButtonText:"确定",callback:function(r){t.$router.push({name:"TaskReport",params:{reportId:e,projectId:t.projectId,taskId:t.taskId}})}})},showLoading:function(){this.loading=!0},hideLoading:function(){this.loading=!1}},watch:{reportType:function(e){this.reportType=e}}},l={render:function(){var e=this,t=e.$createElement,r=e._self._c||t;return r("div",{directives:[{name:"loading",rawName:"v-loading",value:e.loading,expression:"loading"}],staticClass:"create-container"},[r("div",{staticClass:"title h1"},[e._v("创建报告")]),e._v(" "),r("div",{staticClass:"create-body"},[r("el-form",{ref:"report",staticClass:"demo-report",attrs:{model:e.report,rules:e.rules,"label-width":"12%"}},[r("el-form-item",{attrs:{label:"报告名称",prop:"name"}},[r("el-input",{attrs:{size:"small"},model:{value:e.report.name,callback:function(t){e.$set(e.report,"name",t)},expression:"report.name"}})],1),e._v(" "),r("el-form-item",{attrs:{label:"报告类型",prop:"type"}},[r("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,o){return r("span",{key:o},[r("el-radio",{attrs:{label:t,name:"type"}},[e._v(e._s(t))])],1)}),0)],1),e._v(" "),r("el-form-item",{attrs:{label:"测试对象",prop:"target"}},[r("el-input",{staticStyle:{width:"400px"},attrs:{autosize:"",type:"textarea"},model:{value:e.report.target,callback:function(t){e.$set(e.report,"target",t)},expression:"report.target"}})],1),e._v(" "),r("el-form-item",{attrs:{label:"测试内容",prop:"content"}},[r("el-input",{staticStyle:{width:"400px"},attrs:{autosize:"",type:"textarea"},model:{value:e.report.content,callback:function(t){e.$set(e.report,"content",t)},expression:"report.content"}})],1),e._v(" "),r("el-form-item",{attrs:{prop:"file",label:"报告文件"}},[r("el-upload",{staticClass:"upload-demo",staticStyle:{width:"400px"},attrs:{drag:"",action:"https://jsonplaceholder.typicode.com/posts/","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}},[r("i",{staticClass:"el-icon-upload"}),e._v(" "),r("div",{staticClass:"el-upload__text"},[e._v("\n 将文件拖到此处,或\n "),r("em",[e._v("点击上传")])]),e._v(" "),r("div",{staticClass:"el-upload__tip",attrs:{slot:"tip"},slot:"tip"},[e._v("请上传报告文件")])])],1),e._v(" "),r("el-form-item",{attrs:{label:"结论",prop:"conclusion"}},[r("el-input",{staticStyle:{width:"400px"},attrs:{autosize:"",type:"textarea"},model:{value:e.report.conclusion,callback:function(t){e.$set(e.report,"conclusion",t)},expression:"report.conclusion"}})],1),e._v(" "),r("el-form-item",[r("div",{staticClass:"btn btn-medium btn-info",on:{click:function(t){return e.submitForm("report")}}},[e._v("提交")]),e._v(" "),r("div",{staticClass:"btn btn-medium",on:{click:function(t){return e.cancelCreate("report")}}},[e._v("取消")])])],1)],1)])},staticRenderFns:[]};var c=r("VU/8")(s,l,!1,function(e){r("TGdV")},"data-v-b3e69d9a",null);t.default=c.exports}});