18.025ca09dd63c76ee33eb.js 9.1 KB

1
  1. webpackJsonp([18],{F14N:function(e,t,a){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=a("SQ4B"),n=a("b9vf"),o=a("qI5z"),s=a("vGYV"),r={name:"AgencyAuthenticationCreate",data:function(){var e=this;return{userId:0,user:{},loading:!1,isModifyMode:!0,resourceTypes:[],serviceTypes:[],authentication:{mobile:"",evaluationAgencyName:"",bankAccount:"",address:"",evaluationAgencyAbilityList:[],evaluationAgencyResourceList:[],photo:[],agencyPhoto:""},rules:{evaluationAgencyName:[{required:!0,message:"请输入机构名称",trigger:"blur"},{min:3,max:50,message:"机构名称长度在 3 到 50 个字符",trigger:"blur"}],bankAccount:[{required:!0,message:"请输入银行卡账户",trigger:"blur"},{min:16,max:19,message:"银行卡账户输入有误",trigger:"blur"},{validator:function(t,a,i){e.checkNumber(a)?i():i(new Error("银行卡账户输入有误"))},trigger:"blur"}],address:[{required:!0,message:"请输入地址",trigger:"blur"}],evaluationAgencyAbilityList:[{type:"array",required:!0,message:"请至少选择一种测试类型",trigger:"change"}],evaluationAgencyResourceList:[{validator:function(e,t,a){var i=!1;if(null==t||0==t.length)a(new Error("机构资源不可为空"));else for(var n=0;n<t.length;n++)if(""==t[n].name){i=!0;break}i?a(new Error("资源名称不可为空")):a()},trigger:"blur"}],agencyPhoto:[{validator:function(e,t,a){null==t||""==t?a(new Error("机构logo不可为空")):a()},trigger:"blur"}]}}},mounted:function(){var e=this;this.$nextTick(function(){e.init()})},methods:{init:function(){this.setServiceTypes(),this.setResourceTypes(),this.setUserInfo()},loadData:function(){},modifyInfo:function(){this.isModifyMode=!0},submitInfo:function(){var e=this;this.$refs.authentication.validate(function(t){if(!t)return Object(o.a)("error","表单填写错误!"),!1;e.showLoading();var a={userId:e.user.userVO.id,evaluationAgencyName:e.authentication.evaluationAgencyName,bankAccount:e.authentication.bankAccount,address:e.authentication.address,evaluationAgencyAbilityList:e.authentication.evaluationAgencyAbilityList,evaluationAgencyResourceList:e.authentication.evaluationAgencyResourceList,agencyPhoto:e.authentication.agencyPhoto};console.log(a),Object(s.T)(e.user.userVO.id,a,e.submitInfoSuccess,e.submitInfoFail)})},submitInfoSuccess:function(e){var t=this;console.log(e),Object(s.v)().then(function(e){Object(s.M)("user",e),t.user=e,t.sendBusMessage(),Object(s.M)("rolesPermissions",Object(s.B)(e.roleList)),t.hideLoading(),t.$alert("认证信息提交成功,将于3个工作日内审核完成","提交成功",{confirmButtonText:"确定",callback:function(e){t.$router.push({name:"AgencyAuthentication",params:{userId:t.user.userVO.id}})}})}).catch(function(e){t.hideLoading(),Object(o.a)("error","重新获取用户信息失败:"+e.data)})},submitInfoFail:function(e){this.hideLoading(),Object(o.a)("error",e.data)},cancelModify: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){if(e.size>1e7)return Object(o.a)("error","单个文件大小不能超过10M"),!1;var t=e.name,a=t.lastIndexOf(".");if(a<=0)return Object(o.a)("error","只能上传png/jpg格式的文件"),!1;var i=t.substr(a);return".jpg"!==i&&".png"!==i?(Object(o.a)("error","只能上传png/jpg格式的文件"),!1):void 0},uploadFile:function(e){var t=this;this.showLoading();var a=new FormData;a.append("file",e.file),i.a.upload(n.a.FILE.UPLOAD_IMAGE.replace("{userId}",this.user.userVO.id),a,{headers:{"Content-Type":"multipart/form-data"}}).then(function(e){t.hideLoading(),t.authentication.agencyPhoto=e.data,console.log(e.data),Object(o.a)("success","上传成功"),t.$refs.authentication.validateField("agencyPhoto")}).catch(function(e){t.hideLoading();try{413===e.response.status?Object(o.a)("error","文件过大,请选择小于20M的图片"):500===e.response.status&&Object(o.a)("error","上传文件发生错误,请稍后重试")}catch(t){Object(o.a)("error",e.data)}})},setServiceTypes:function(){var e=this;Object(s.r)().then(function(t){e.serviceTypes=t}).catch(function(e){Object(o.a)("error","机构能力加载失败")})},setResourceTypes:function(){this.resourceTypes=Object(s.k)()},addAgencyResource:function(){var e={id:this.authentication.evaluationAgencyResourceList.length,type:this.resourceTypes[0],name:"",totalNum:0,availableNum:0};this.authentication.evaluationAgencyResourceList.push(e)},removeAgencyResource:function(e){this.authentication.evaluationAgencyResourceList.splice(e,1);for(var t=0;t<this.authentication.evaluationAgencyResourceList.length;t++)this.authentication.evaluationAgencyResourceList[t].id=t},checkAgencyResourceVaild:function(){if(0===this.authentication.evaluationAgencyResourceList.length)return!0;for(var e=0;e<this.authentication.evaluationAgencyResourceList.length;e++){var t=this.authentication.evaluationAgencyResourceList[e];if(""===t.type)return Object(o.a)("error","资源类型不能为空"),!1;if(""===t.name)return Object(o.a)("error","资源名称不能为空"),!1;if(t.totalNum<t.availableNum)return Object(o.a)("error","资源总数量不能低于可用数量"),!1}return!0},setUserInfo:function(){this.user=Object(s.K)("user")},showLoading:function(){this.loading=!0},hideLoading:function(){this.loading=!1},submitSuccess:function(){},sendBusMessage:function(){this.$root.$emit("user",this.user)},checkNumber:function(e){return/^\d+$/.test(e)}},created:function(){}},c={render:function(){var e=this,t=e.$createElement,a=e._self._c||t;return a("div",{staticClass:"create-container"},[a("div",{directives:[{name:"loading",rawName:"v-loading",value:e.loading,expression:"loading"}],staticClass:"create-body"},[a("div",{staticClass:"title"},[e._v("测评机构认证")]),e._v(" "),a("el-form",{ref:"authentication",staticClass:"demo-report",attrs:{model:e.authentication,rules:e.rules,"label-width":"12%"}},[a("el-form-item",{attrs:{prop:"agencyPhoto",label:"机构logo"}},[a("el-upload",{staticClass:"avatar-uploader",attrs:{action:"","show-file-list":!1,"http-request":e.uploadFile,"before-upload":e.beforeFileUpload}},[e.authentication.agencyPhoto?a("img",{staticClass:"avatar",attrs:{src:e.authentication.agencyPhoto}}):a("i",{staticClass:"el-icon-plus avatar-uploader-icon"})])],1),e._v(" "),a("el-form-item",{attrs:{label:"机构名称",prop:"evaluationAgencyName"}},[e.isModifyMode?a("el-input",{attrs:{size:"small"},model:{value:e.authentication.evaluationAgencyName,callback:function(t){e.$set(e.authentication,"evaluationAgencyName",t)},expression:"authentication.evaluationAgencyName"}}):e._e()],1),e._v(" "),a("el-form-item",{attrs:{label:"地址",prop:"address"}},[e.isModifyMode?a("el-input",{attrs:{size:"small"},model:{value:e.authentication.address,callback:function(t){e.$set(e.authentication,"address",t)},expression:"authentication.address"}}):e._e()],1),e._v(" "),a("el-form-item",{attrs:{label:"测评机构能力",prop:"evaluationAgencyAbilityList"}},[e.isModifyMode?a("el-checkbox-group",{model:{value:e.authentication.evaluationAgencyAbilityList,callback:function(t){e.$set(e.authentication,"evaluationAgencyAbilityList",t)},expression:"authentication.evaluationAgencyAbilityList"}},e._l(e.serviceTypes,function(t,i){return a("span",{key:i},[a("el-checkbox",{attrs:{label:t,name:"type"}},[e._v(e._s(t)+"    ")])],1)}),0):e._e()],1),e._v(" "),a("el-form-item",{attrs:{label:"测评机构资源",prop:"evaluationAgencyResourceList"}},[e._l(e.authentication.evaluationAgencyResourceList,function(t){return a("span",{key:t.id},[e._v("\n 资源类型: "),a("el-select",{staticStyle:{width:"150px","margin-bottom":"10px"},attrs:{size:"small",placeholder:"请选择",value:t.type},model:{value:t.type,callback:function(a){e.$set(t,"type",a)},expression:"item.type"}},e._l(e.resourceTypes,function(e){return a("el-option",{key:e,attrs:{label:e,value:e}})}),1),e._v("\n 资源名称: "),a("el-input",{staticStyle:{width:"150px"},attrs:{size:"small"},model:{value:t.name,callback:function(a){e.$set(t,"name",a)},expression:"item.name"}}),e._v("\n 总量: "),a("el-input-number",{attrs:{size:"small",min:0},model:{value:t.totalNum,callback:function(a){e.$set(t,"totalNum",a)},expression:"item.totalNum"}}),e._v("\n 可用数量: "),a("el-input-number",{attrs:{size:"small",min:0,max:t.totalNum},model:{value:t.availableNum,callback:function(a){e.$set(t,"availableNum",a)},expression:"item.availableNum"}}),e._v(" "),a("el-button",{attrs:{size:"small",type:"danger",icon:"el-icon-delete"},on:{click:function(a){return e.removeAgencyResource(t.id)}}}),e._v(" "),a("br")],1)}),e._v(" "),a("el-button",{attrs:{type:"primary",icon:"el-icon-circle-plus",plain:"",size:"small"},on:{click:e.addAgencyResource}},[e._v("添加资源\n ")])],2),e._v(" "),e.isModifyMode?a("el-form-item",[a("el-button",{attrs:{type:"primary",size:"small"},on:{click:function(t){return e.submitInfo()}}},[e._v("提交")])],1):e._e()],1)],1)])},staticRenderFns:[]};var u=a("VU/8")(r,c,!1,function(e){a("SVhI")},"data-v-ea727efa",null);t.default=u.exports},SVhI:function(e,t){}});