mirror of
https://github.com/hpd840321/starRiverProperty.git
synced 2026-06-10 00:40:30 +08:00
4f79e10bd6
Former-commit-id: 376f94edd602d3dfed1cbada6e08361ee7b08e73
1 line
18 KiB
JavaScript
1 line
18 KiB
JavaScript
webpackJsonp([38],{"6MJD":function(e,t,a){var i=a("eFVF");"string"==typeof i&&(i=[[e.i,i,""]]),i.locals&&(e.exports=i.locals);a("rjj0")("cb90724a",i,!0)},JJ6Z:function(e,t,a){var i=a("qF5q");"string"==typeof i&&(i=[[e.i,i,""]]),i.locals&&(e.exports=i.locals);a("rjj0")("e6cab574",i,!0)},eFVF:function(e,t,a){(e.exports=a("FZ+f")(!1)).push([e.i,"\n.upload-wrp[data-v-59fd1c8f] {\n position: relative;\n}\n.upload-wrp #uploadButton[data-v-59fd1c8f] {\n position: absolute;\n top: 0;\n left: 0;\n width: 100px;\n bottom: 0;\n right: 0;\n opacity: 0;\n z-index: 33;\n}\n.file-list-wrp[data-v-59fd1c8f] {\n max-height: 200px;\n overflow-y: auto;\n margin: 10px 0;\n}\n.file-name[data-v-59fd1c8f] {\n width: 560px;\n color: #606266;\n -webkit-transition: color 0.3s;\n transition: color 0.3s;\n overflow: hidden;\n font-size: 14px;\n line-height: 1.8;\n}\n.file-name[data-v-59fd1c8f]:hover {\n background: #f5f7fa;\n cursor: pointer;\n}\n.file-name:hover span[data-v-59fd1c8f] {\n color: #3399ff;\n}\n.file-name:hover .el-icon-close[data-v-59fd1c8f] {\n opacity: 1 !important;\n}\n.file-name:hover .el-icon-upload-success[data-v-59fd1c8f] {\n display: none !important;\n}\n#uploadButton[data-v-59fd1c8f] {\n cursor: pointer;\n}\n",""])},fYPO:function(e,t,a){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=a("Gu7T"),n=a.n(i),l=a("hpEt"),s=a("Xxa5"),o=a.n(s),r=a("exGp"),c=a.n(r),p=a("//Fk"),d=a.n(p),u=a("woOf"),f=a.n(u),h=a("Zrlr"),m=a.n(h),g=a("wxAW"),v=a.n(g),k=a("JSQk"),F=a.n(k),y=a("9Zzp"),x=a("TIfe"),b=1,w=2,_=101,S=102,z={DELETE:-1,PAUSE:0,WORKING:1,COMPLETE:2},T=50*Math.pow(1024,2),C=10*Math.pow(1024,2),M=function(){function e(t,a){m()(this,e),this.file=t,this.file.percent=0,this.state=z.WORKING,this.opt=f()({chunkSize:T,merge:!0,unique:!0,url:"/upload",progress:function(){},complete:function(){},final:function(){},cancel:function(){},getSpeed:function(){},uploadId:"",filePath:"",clearable:!0},a||{}),this.file.size<=C&&(this.opt.chunkSize=this.file.size),this.chunks=0==this.opt.chunkSize?1:Math.ceil(this.file.size/this.opt.chunkSize),this.file.chunks=this.chunks,this.blobSlice=File.prototype.slice||File.prototype.mozSlice||File.prototype.webkitSlice,this.file.md5=this.opt.uploadId||"",this.request_result=[]}return v()(e,[{key:"run",value:function(){var e=c()(o.a.mark(function e(){return o.a.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.md5File();case 2:this.exec();case 3:case"end":return e.stop()}},e,this)}));return function(){return e.apply(this,arguments)}}()},{key:"exec",value:function(){var e=c()(o.a.mark(function e(){var t;return o.a.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:t=0;case 1:if(!(t<this.chunks)){e.next=7;break}return e.next=4,this.upload(t);case 4:t++,e.next=1;break;case 7:case"end":return e.stop()}},e,this)}));return function(){return e.apply(this,arguments)}}()},{key:"pause",value:function(){this.state=z.PAUSE}},{key:"continue",value:function(){this.state=z.WORKING,this.exec()}},{key:"restart",value:function(){this.state=z.WORKING,this.exec()}},{key:"cancel",value:function(){this.state=z.DELETE,this.opt.cancel()}},{key:"md5File",value:function(){var e=this;return new d.a(function(t,a){if(e.opt.unique){var i=0,n=new F.a.ArrayBuffer,l=new FileReader;l.onload=function(a){if(e.opt.progress(b,Math.floor(i/e.chunks*100)),n.append(a.target.result),++i<2)e.loadNext(i,l);else{var s=n.end();e.file.md5||(e.file.md5=s),e.opt.progress(b,100),t(s)}},l.onerror=function(){this.opt.progress(w)},e.loadNext(i,l)}else{var s=F.a.hash(e.file.name+"-"+e.file.size+"-"+e.opt.parentId+"}");e.file.md5||(e.file.md5=s),t(s)}})}},{key:"upload",value:function(){var e=c()(o.a.mark(function e(t){var a,i,n,l;return o.a.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(this.state==z.WORKING){e.next=2;break}return e.abrupt("return");case 2:return e.prev=2,e.next=5,this.uploadChunck(t);case 5:if(!(a=e.sent).success){e.next=25;break}if((i=a.index)!=this.chunks-1){e.next=21;break}if(this.opt.merge){e.next=14;break}return this.opt.progress(_,100),this.opt.complete(this.file),this.opt.final(this.file.md5),e.abrupt("return");case 14:return e.next=16,y.a.fileFinish({filePath:this.opt.filePath,uploadId:this.opt.uploadId,fileSize:this.file.size});case 16:return n=e.sent,this.opt.progress(_,100),this.opt.complete(this.file),this.opt.final(n),e.abrupt("return");case 21:l=Math.floor((i+1)/this.chunks*100),this.opt.progress(_,l),e.next=26;break;case 25:throw new Error(a.message);case 26:e.next=33;break;case 28:return e.prev=28,e.t0=e.catch(2),this.opt.progress(S,0,e.t0.message||"上传错误"),e.abrupt("return");case 33:case"end":return e.stop()}},e,this,[[2,28]])}));return function(t){return e.apply(this,arguments)}}()},{key:"uploadChunck",value:function(){var e=c()(o.a.mark(function e(t){return o.a.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.sendToServer(t);case 2:return e.abrupt("return",{success:!0,index:t});case 3:case"end":return e.stop()}},e,this)}));return function(t){return e.apply(this,arguments)}}()},{key:"sendToServer",value:function(e){var t=this;return new d.a(function(a,i){var n=e*t.opt.chunkSize,l=(e+1)*t.opt.chunkSize,s=l>=t.file.size?t.file.size:l,o=new FormData;o.append("filePath",t.opt.filePath),o.append("uploadId",t.opt.uploadId),o.append("name",t.file.name),o.append("type",t.file.type),o.append("partNumber",e+1),o.append("lastModifiedDate",t.file.lastModifiedDate),o.append("size",t.file.size),o.append("md5",t.file.md5),o.append("file",t.file.slice(n,s));var r,c,p=new XMLHttpRequest;p.open("POST",t.opt.url,!0),p.setRequestHeader("Authorization","Basic "+Object(x.b)()),p.onload=function(t){var n=t.target,l=JSON.parse(n.response);200==n.status&&l.success?a({success:!0,index:e}):i(new Error(l.message))},p.onerror=function(e){i(e)},p.upload.onprogress=function(a){var i=(Date.now()-r)/1e3,n=(a.loaded-c)/i,l="b/s";n/1024>1&&(n/=1024,l="k/s"),n/1024>1&&(n/=1024,l="M/s");var s=(100*(e*t.opt.chunkSize+a.loaded)/t.file.size).toFixed(2);Number(s)<97&&(t.file.percent=Number(s),t.opt.getSpeed(n+l,s)),r=(new Date).getTime(),c=a.loaded},p.upload.onloadstart=function(e){r=(new Date).getTime(),c=0},p.send(o)})}},{key:"loadNext",value:function(e,t){if(this.state==z.WORKING){var a=e*this.opt.chunkSize,i=a+this.opt.chunkSize>=this.file.size?this.file.size:a+this.opt.chunkSize;t.readAsArrayBuffer(this.blobSlice.call(this.file,a,i))}}},{key:"getBeautifyDate",value:function(){var e=new Date;return e.getFullYear()+"-"+(e.getMonth()+1)+"-"+e.getDate()+" "+e.getHours()+":"+e.getMinutes()+":"+e.getSeconds()}}]),e}(),A={data:function(){return{showTask:!1,fileList:[],acceptFileList:"application/x-gzip,application/vnd.android.package-archive,application/zip",fileName:"",percent:0,loading:!1,uploaders:[]}},props:{dataSetId:{type:String,default:""}},destroyed:function(){this.uploaders.length>0&&(this.uploaders.forEach(function(e){e.cancel()}),this.uploaders=[])},computed:{currentFile:function(){return this.fileList.length>0?this.fileList[this.fileList.length-1].name:""}},methods:{handleFileChange:function(e){var t=this;return c()(o.a.mark(function a(){var i,n,l,s,r,c;return o.a.wrap(function(a){for(;;)switch(a.prev=a.next){case 0:if(t.uploaders.length>0&&(t.uploaders.forEach(function(e){e.cancel()}),t.uploaders=[]),t.fileName="",t.percent=0,"application/x-zip-compressed"==e.target.files[0].type||"application/x-gzip"==e.target.files[0].type||"application/vnd.android.package-archive"==e.target.files[0].type||"application/zip"==e.target.files[0].type||e.target.files[0].name.endsWith(".update")){a.next=6;break}return t.$message.error("请上传.tar.gz或者.apk或者.update格式的文件"),a.abrupt("return",!1);case 6:(i=e.target.files).length>0&&(t.showTask=!0),t.loading=!0,n=0;case 10:if(!(n<i.length)){a.next=23;break}return l=i[n],t.fileList.push(l),a.next=15,t.fileInit(l);case 15:s=a.sent,r=s.filePath,c=s.uploadId,t.initChunkUpload(l,t.fileList.length-1,c,r),t.packageSuccess2(l);case 20:n++,a.next=10;break;case 23:t.$refs.uploader.value="";case 24:case"end":return a.stop()}},a,t)}))()},fetchAllComplete:function(e){e===this.fileList.length-1&&this.$emit("complete",this.fileList[0])},fileInit:function(e){return y.a.fileInit({fileName:e.name})},initChunkUpload:function(e,t,a,i){var n=this,l=new M(e,{dataSetId:this.dataSetId,uploadId:a,filePath:i,url:"/cwos-portal/portal/file/part/append",chunkSize:8*Math.pow(1024,2),progress:function(a,i,s){e.code=a,e.status=l.state,e.progress=i,n.percent=i,100!=n.percent&&0!=n.percent&&1!=n.percent&&(n.loading=!1),s&&(e.message=s),l.state>0&&(n.$set(n.fileList,t,e),n.fetchAllComplete(t))},complete:function(t){n.$emit("complete",t),e.success=!0,n.fileName=e.name,n.loading=!1,n.uploaders=[],n.percent=0},final:function(e){n.$emit("final",e),n.loading=!1,n.uploaders=[],n.percent=0}});this.uploaders.push(l),l.run(),e._uploader=l},packageSuccess2:function(e){var t=this,a=File.prototype.slice||File.prototype.mozSlice||File.prototype.webkitSlice,i=2097152,n=Math.ceil(e.size/i),l=0,s=new F.a.ArrayBuffer,o=function(e){s.append(e.target.result),++l<n?c():t.$emit("fullMd5",s.end())},r=function(){};function c(){var t=new FileReader;t.onload=o,t.onerror=r;var n=l*i,s=n+i>=e.size?e.size:n+i;t.readAsArrayBuffer(a.call(e,n,s))}c(),this.percent=0},removeFile:function(){this.fileName="",this.$emit("removeFullFile")}},watch:{uploaders:{immediate:!0,handler:function(e){e.length||(this.percent=0)}}},components:{}},I={render:function(){var e=this,t=e.$createElement,a=e._self._c||t;return a("div",{staticClass:"flex-box",staticStyle:{width:"230px"}},[a("div",{staticClass:"upload-wrp flex-item"},[a("el-button",{directives:[{name:"loading",rawName:"v-loading",value:e.loading,expression:"loading"}],attrs:{size:"small"}},[e._v("上传文件")]),e._v(" "),a("input",{ref:"uploader",attrs:{type:"file",id:"uploadButton","on-success":e.packageSuccess2},on:{change:e.handleFileChange}}),e._v(" "),a("div",{staticClass:"el-upload__tip",attrs:{slot:"tip"},slot:"tip"},[e._v("支持扩展名:.tar.gz、apk、zip、.update")]),e._v(" "),e.fileName?a("div",{staticClass:"file-name"},[a("el-icon",{staticClass:"el-icon-document"}),e._v(" "),a("span",[e._v(e._s(e.fileName))]),e._v(" "),a("el-icon",{staticClass:"el-icon-upload-success el-icon-circle-check",staticStyle:{float:"right","margin-right":"4px","margin-top":"5px",color:"#67c23a"}}),e._v(" "),a("el-icon",{staticClass:"el-icon-close",staticStyle:{float:"right",opacity:"0",display:"inline-block","margin-right":"4px","margin-top":"5px"},nativeOn:{click:function(t){return e.removeFile(t)}}})],1):e._e(),e._v(" "),0!=e.percent&&100!=e.percent&&1!=e.percent&&e.uploaders.length?a("el-progress",{staticStyle:{width:"746px"},attrs:{percentage:e.percent}}):e._e()],1)])},staticRenderFns:[]};var P=a("VU/8")(A,I,!1,function(e){a("6MJD")},"data-v-59fd1c8f",null).exports,$={name:"addFile",props:{dialogVisible:{type:Boolean,default:!1}},components:{fileUpload:P},data:function(){return{actionUrl:"/cwos-portal/portal/device/upgrade/descFileUpload",headers:{Authorization:"Basic "+Object(x.b)()},engineTypes:[],BASE_API:"/cwos-portal",serviceTypes:[],modelForm:{remark:"",deviceTypeId:"",serviceCode:"",configFilePath:"",packageAppendPath:"",packageFullPath:"",packageAppendMd5:"",packageFullMd5:""},rules:{packageType:[{required:!0,message:"请选择升级文件包类型"}],fileDescribe:[{required:!0,message:"请上传升级描述文件",trigger:"change"}],deviceTypeId:[{required:!0,message:"请上传升级描述文件",trigger:"change"}],serviceCode:[{required:!0,message:"请上传升级描述文件",trigger:"change"}],filePackage:[{required:!0,message:"请上传升级文件包",trigger:"change"}]},fileList:[]}},created:function(){this.fetchTypeList(),this.fetchApplicationList()},methods:{handleFinal:function(e){this.modelForm.packageFullPath=e},handleFinal1:function(e){this.modelForm.packageAppendPath=e},complete:function(e){this.modelForm.packageFullSize=e.size},complete1:function(e){this.modelForm.packageAppendSize=e.size},downloadTemplate:function(){l.a.downloadJsonAndXmlTemplate(this.BASE_API+"/portal/device/upgrade/downloadJsonAndXmlTemplate",{},"模板.zip")},fetchApplicationList:function(){var e=this;l.a.applicationList().then(function(t){e.serviceTypes=[{label:"全部",value:""}].concat(n()(t))}).catch(function(t){e.$message.error(t.message)})},fetchTypeList:function(){var e=this;l.a.typeList().then(function(t){e.engineTypes=t,e.engineTypes.unshift({label:"全部",value:""})}).catch(function(t){e.$message.error(t.message)})},handleConfirm:function(e){var t=this;if(this.modelForm.deviceTypeId)if(this.modelForm.serviceCode)if(this.modelForm.configFilePath)if(0!=this.modelForm.packageType||this.modelForm.packageAppendPath)if(1!=this.modelForm.packageType||this.modelForm.packageFullPath&&this.modelForm.packageFullMd5){var a=this.$loading({lock:!0,text:"",background:"rgba(255, 255, 255, 0.7)"});l.a.fileAdd(this.modelForm).then(function(e){t.$message.success(e.message),t.$router.push("/mulDeviceManage/fileManage/index"),a.close()}).catch(function(e){t.$message.error(e.message),a.close()})}else this.$message.warning("请先上传全量升级文件包");else this.$message.warning("请先上传增量升级文件包");else this.$message.warning("请先上传升级描述文件");else this.$message.warning("请选择升级应用类型");else this.$message.warning("请选择升级设备类型")},fileError:function(e,t,a){this.$message.error(e)},fileSuccess:function(e,t,a){"00000000"===e.code?this.modelForm.configFilePath=e.data:(this.$message.error(e.message),this.$refs.upload.clearFiles())},fullMd5:function(e){this.modelForm.packageFullMd5=e},fullMd51:function(e){this.modelForm.packageAppendMd5=e},removeFullFile:function(){this.modelForm.packageFullPath="",this.modelForm.packageFullMd5="",this.modelForm.packageFullSize=0},removeFile:function(){this.modelForm.packageAppendPath="",this.modelForm.packageAppendMd5="",this.modelForm.packageAppendSize=0},cancle:function(){this.$router.go(-1)},handleChange:function(e,t){2===t.length&&(this.fileList=t.slice(1))},beforeFileUpload:function(e){if("application/json"!==e.type&&"text/xml"!==e.type)return this.$message.error("请上传.xml或.json格式的文件"),!1}}},L={render:function(){var e=this,t=e.$createElement,a=e._self._c||t;return a("div",{staticClass:"app-container",staticStyle:{width:"100%"}},[a("el-form",{ref:"detailData",staticClass:"demo-detailData",attrs:{model:e.modelForm,rules:e.rules,"label-width":"140px"}},[a("el-card",{staticClass:"upadd-card",attrs:{shadow:"hover"}},[a("div",{staticClass:"clearfix",attrs:{slot:"header"},slot:"header"},[a("span",[e._v("基本信息")])]),e._v(" "),a("div",{staticClass:"add-form",staticStyle:{width:"100%"}},[a("el-form-item",{attrs:{label:"需升级设备类型",prop:"deviceTypeId"}},[a("el-select",{model:{value:e.modelForm.deviceTypeId,callback:function(t){e.$set(e.modelForm,"deviceTypeId",t)},expression:"modelForm.deviceTypeId"}},e._l(e.engineTypes,function(e,t){return a("el-option",{key:t,attrs:{label:e.label,value:e.value}})}),1)],1),e._v(" "),a("el-form-item",{attrs:{label:"需升级应用类型",prop:"serviceCode"}},[a("el-select",{model:{value:e.modelForm.serviceCode,callback:function(t){e.$set(e.modelForm,"serviceCode",t)},expression:"modelForm.serviceCode"}},e._l(e.serviceTypes,function(e,t){return a("el-option",{key:t,attrs:{label:e.label,value:e.value}})}),1)],1),e._v(" "),a("el-form-item",{staticStyle:{width:"40%"},attrs:{label:"备注",prop:"remark"}},[a("div",{staticClass:"word-limit-ctnr",staticStyle:{width:"555px"}},[a("el-input",{staticStyle:{width:"555px"},attrs:{type:"textarea",placeholder:"请输入备注",maxlength:"255",resize:"none"},model:{value:e.modelForm.remark,callback:function(t){e.$set(e.modelForm,"remark",t)},expression:"modelForm.remark"}}),e._v(" "),a("span",{staticClass:"word-limit"},[e._v(e._s(e.modelForm.remark&&e.modelForm.remark.length||0)+"/255")])],1)])],1)]),e._v(" "),a("el-card",{staticClass:"upadd-card",attrs:{shadow:"hover"}},[a("div",{staticClass:"clearfix",attrs:{slot:"header"},slot:"header"},[a("span",[e._v("文件上传")])]),e._v(" "),a("div",{staticClass:"add-form",staticStyle:{width:"100%"}},[a("el-form-item",{attrs:{label:"升级描述文件",prop:"fileDescribe"}},[a("el-upload",{ref:"upload",staticClass:"upload-demo",attrs:{action:e.actionUrl,headers:e.headers,"before-remove":e.beforeRemove,"before-upload":e.beforeFileUpload,"on-change":e.handleChange,"on-success":e.fileSuccess,"file-list":e.fileList,"on-error":e.fileError,limit:2,name:"descFile",accept:".xml, .json"}},[a("el-button",{attrs:{size:"small"}},[e._v("上传文件")])],1),e._v(" "),a("a",{staticStyle:{"text-decoration":"underline",color:"rgb(88,180,222)"},on:{click:e.downloadTemplate}},[e._v("模板下载")])],1),e._v(" "),a("div",{staticClass:"el-upload__tip",staticStyle:{"margin-left":"140px","margin-top":"-20px","margin-bottom":"10px"},attrs:{slot:"tip"},slot:"tip"},[e._v("\n 支持扩展名:.xml或.json\n ")]),e._v(" "),a("el-form-item",{attrs:{label:"升级文件包类型",prop:"packageType"}},[a("el-radio-group",{model:{value:e.modelForm.packageType,callback:function(t){e.$set(e.modelForm,"packageType",t)},expression:"modelForm.packageType"}},[a("el-radio",{attrs:{label:1}},[e._v("全量升级包")]),e._v(" "),a("el-radio",{attrs:{label:0}},[e._v("增量升级包")])],1)],1),e._v(" "),a("el-form-item",{directives:[{name:"show",rawName:"v-show",value:0==e.modelForm.packageType,expression:"modelForm.packageType == 0"}],attrs:{label:"升级文件包",prop:"filePackage1"}},[a("file-upload",{key:"filePackage1",staticClass:"flex-item",on:{complete:e.complete1,final:e.handleFinal1,fullMd5:e.fullMd51,removeFullFile:e.removeFile}})],1),e._v(" "),a("el-form-item",{directives:[{name:"show",rawName:"v-show",value:1==e.modelForm.packageType,expression:"modelForm.packageType == 1"}],attrs:{label:"升级文件包",prop:"filePackage2"}},[a("file-upload",{key:"filePackage2",staticClass:"flex-item",on:{complete:e.complete,final:e.handleFinal,fullMd5:e.fullMd5,removeFullFile:e.removeFullFile}})],1),e._v(" "),a("el-form-item",[a("el-button",{attrs:{type:"primary"},on:{click:function(t){return e.handleConfirm("modelForm")}}},[e._v("确定")]),e._v(" "),a("el-button",{on:{click:e.cancle}},[e._v("取消")])],1)],1)])],1)],1)},staticRenderFns:[]};var N=a("VU/8")($,L,!1,function(e){a("JJ6Z")},"data-v-06006a46",null);t.default=N.exports},qF5q:function(e,t,a){(e.exports=a("FZ+f")(!1)).push([e.i,"\n[data-v-06006a46] .el-upload {\n text-align: left;\n width: 100px;\n}\n[data-v-06006a46] .el-upload-list__item {\n width: 560px;\n}\n.upadd-card[data-v-06006a46] {\n /* margin-bottom: 100px;\n padding-bottom: 18px; */\n}\n[data-v-06006a46] .el-button--default:hover {\n opacity: 1;\n}\n",""])}}); |