;(function(){function asyncGeneratorStep(gen,resolve,reject,_next,_throw,key,arg){try{var info=gen[key](arg);var value=info.value;}catch(error){reject(error);return;}if(info.done){resolve(value);}else{Promise.resolve(value).then(_next,_throw);}}function _asyncToGenerator(fn){return function(){var self=this,args=arguments;return new Promise(function(resolve,reject){var gen=fn.apply(self,args);function _next(value){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"next",value);}function _throw(err){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"throw",err);}_next(undefined);});};}var __vite_style__=document.createElement('style');__vite_style__.innerHTML="._uploadSection_sa9wk_1{width:150px;height:85px;background:#f8faf9;border-radius:4px;border:1px solid rgba(45,199,170,.26);font-size:14px;color:#2dc7aa;line-height:20px}._uploadFile_sa9wk_11{width:100%;min-width:300px;height:40px;border:1px solid rgba(142,142,142,.26);border-radius:4px;display:flex;align-items:center;padding:0 15px;color:var(--el-text-color-regular)}._uploadFile_sa9wk_11 .el-icon{margin-right:5px}._fileUpload_sa9wk_25 .el-upload--text{width:100%}._fileUpload_sa9wk_25 .el-loading-spinner{display:flex;align-items:center;height:42px!important;justify-content:center;margin-top:-20px!important}._fileUpload_sa9wk_25 .el-loading-spinner svg{width:20px;height:20px;margin-right:5px}._uploadClass_sa9wk_40{height:85px;width:100%}._uploadClass_sa9wk_40 .el-loading-spinner{margin-top:-33px;height:85px}\n";document.head.appendChild(__vite_style__);System.register(['./vendor-legacy.457cbbd5.js','./icon_upload-legacy.e1b38fd3.js','./index-legacy.5050f563.js'],function(exports){'use strict';var defineComponent,ElMessage,ElLoading,createVNode,ElUpload,ElImage,ElIcon,document_default,createTextVNode,iconUpload,request;return{setters:[function(module){defineComponent=module.d;ElMessage=module.E;ElLoading=module.ab;createVNode=module.c;ElUpload=module.ac;ElImage=module.x;ElIcon=module.l;document_default=module.ad;createTextVNode=module.a;},function(module){iconUpload=module.i;},function(module){request=module.r;}],execute:function execute(){var uploadSection="_uploadSection_sa9wk_1";var uploadFile="_uploadFile_sa9wk_11";var fileUpload="_fileUpload_sa9wk_25";var uploadClass="_uploadClass_sa9wk_40";var styles={uploadSection:uploadSection,uploadFile:uploadFile,fileUpload:fileUpload,uploadClass:uploadClass};var ColUpload=exports('C',defineComponent({name:'col-upload',props:{modelValue:{type:String,default:''},uploadType:{type:String,default:'image'},disabled:{type:Boolean,default:false},bucket:{type:String,default:'daya'},size:{type:Number,default:5// 默认5M
},accept:{type:String,default:'images/*'},tips:{type:String,default:'请上传图片'},extraTips:{type:String,default:'图片最大不能超过5MB'},onChange:{type:Function,default:function _default(){}}},data:function data(){return{ossUploadUrl:'https://ks3-cn-beijing.ksyuncs.com/'+this.bucket,dataObj:{policy:'',signature:'',key:'',KSSAccessKeyId:'',acl:'public-read',name:''},fileList:[],loading:null};},methods:{handleSuccess:function handleSuccess(){var _this$loading;(_this$loading=this.loading)===null||_this$loading===void 0?void 0:_this$loading.close();var url=this.ossUploadUrl+'/'+this.dataObj.key;console.log(url);this.$emit('update:modelValue',url);this.onChange(url);},handleRemove:function handleRemove(){console.log('remove');},handleChange:function handleChange(){console.log('handleChange');},handleProgress:function handleProgress(){console.log('handleProgress');},handleError:function handleError(){var _this$loading2;(_this$loading2=this.loading)===null||_this$loading2===void 0?void 0:_this$loading2.close();},beforeUpload:function beforeUpload(file){var _this=this;return _asyncToGenerator(/*#__PURE__*/regeneratorRuntime.mark(function _callee(){var isLt2M,fileName,key,obj,_yield$request$post,data;return regeneratorRuntime.wrap(function _callee$(_context){while(1){switch(_context.prev=_context.next){case 0:// beforeUpload
console.log(file);// let fileType = true
// if (props.rules.type && props.rules.type.length > 0) {
//   const fileExtension = file.name.split('.').pop().toUpperCase()
//   console.log(
//     props.rules.type,
//     fileExtension,
//     props.rules.type.indexOf(fileExtension) != -1
//   )
//   if (props.rules.type.indexOf(fileExtension) != -1) {
//     fileType = true
//   } else {
//     fileType = false
//     ElMessage.error('请上传正确的文件!')
//     return false
//   }
// }
isLt2M=true;if(!_this.size){_context.next=7;break;}isLt2M=file.size/1024/1024<_this.size;if(isLt2M){_context.next=7;break;}ElMessage.error("\u6587\u4EF6\u5927\u5C0F\u4E0D\u80FD\u8D85\u8FC7".concat(_this.size,"M!"));return _context.abrupt("return",false);case 7:_this.loading=ElLoading.service({target:_this.$refs.uploadDom,lock:true,fullscreen:false,text:'上传中...',background:'rgba(0, 0, 0, 0.7)'});console.log(_this.loading);_context.prev=9;fileName=file.name.replaceAll(' ','_');key=new Date().getTime()+fileName;obj={filename:fileName,bucketName:_this.bucket,postData:{filename:fileName,acl:'public-read',key:key,unknowValueField:[]}};_context.next=15;return request.post('/api-website/getUploadSign',{data:obj});case 15:_yield$request$post=_context.sent;data=_yield$request$post.data;_this.dataObj={policy:data.policy,signature:data.signature,key:key,KSSAccessKeyId:data.kssAccessKeyId,acl:'public-read',name:fileName};_context.next=23;break;case 20:_context.prev=20;_context.t0=_context["catch"](9);_this.loading.close();case 23:case"end":return _context.stop();}}},_callee,null,[[9,20]]);}))();},fileName:function fileName(){var name=arguments.length>0&&arguments[0]!==undefined?arguments[0]:'';return name.split('/').pop();},handleExceed:function handleExceed(){}},render:function render(){var _this2=this;return createVNode("div",{"class":[styles.colUpload,'w-full']},[createVNode(ElUpload,{"disabled":this.disabled,"action":this.ossUploadUrl,"data":this.dataObj,"onSuccess":this.handleSuccess,"onRemove":this.handleRemove,"onChange":this.handleChange,"onProgress":this.handleProgress,"onError":this.handleError,"fileList":this.fileList,"showFileList":false,"accept":this.accept,"beforeUpload":this.beforeUpload,"onExceed":this.handleExceed,"ref":"uploadRef","class":this.uploadType==='file'?styles.fileUpload:''},{default:function _default(){return[createVNode("div",{"ref":"uploadDom","class":[styles.uploadClass,'w-full'],"style":{height:_this2.uploadType==='image'?'85px':'38px'}},[_this2.modelValue?_this2.uploadType==='image'?createVNode(ElImage,{"src":_this2.modelValue,"fit":"cover","class":styles.uploadSection},null):createVNode("div",{"class":styles.uploadFile},[createVNode(ElIcon,null,{default:function _default(){return[createVNode(document_default,null,null)];}}),createVNode("span",{"class":"whitespace-nowrap overflow-hidden text-ellipsis"},[_this2.fileName(_this2.modelValue)])]):_this2.uploadType==='image'?createVNode("div",{"class":[styles.uploadSection,'flex items-center flex-col justify-center']},[createVNode("img",{"src":iconUpload,"class":"w-8 h-7 mb-3"},null),createVNode("p",null,[_this2.tips])]):createVNode("div",{"class":styles.uploadFile},[createVNode(ElIcon,null,{default:function _default(){return[createVNode(document_default,null,null)];}}),createTextVNode("\u4E0A\u4F20\u6587\u4EF6")])])];}}),createVNode("p",{"class":"text-3 text-[#999999] leading-6 pt-1"},[this.extraTips])]);}}));}};});})();
