/*! * @form-create/component-ivu-upload v2.5.27 * (c) 2018-2022 xaboy * Github https://github.com/xaboy/form-create with @form-create/component-ivu-upload * Released under the MIT License. */ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self).FcUpload=t()}(this,function(){"use strict";function e(){return(e=Object.assign||function(e){for(var t,n=1;ne.length)&&(t=e.length);for(var n=0,i=new Array(t);n-1?[]:[e]}function c(e){return{url:e,name:p(e)}}function p(e){return(""+e).split("/").pop()}!function(e,t){void 0===t&&(t={});var n=t.insertAt;if(e&&"undefined"!=typeof document){var i=document.head||document.getElementsByTagName("head")[0],o=document.createElement("style");o.type="text/css","top"===n&&i.firstChild?i.insertBefore(o,i.firstChild):i.appendChild(o),o.styleSheet?o.styleSheet.cssText=e:o.appendChild(document.createTextNode(e))}}("._fc-upload .fc-upload-btn {\n border: 1px dashed #c0ccda;\n cursor: pointer;\n}\n\n._fc-upload .fc-upload-cover {\n opacity: 0;\n position: absolute;\n top: 0;\n bottom: 0;\n left: 0;\n right: 0;\n background: rgba(0, 0, 0, .6);\n transition: opacity .3s;\n}\n\n._fc-upload .fc-upload-cover i {\n color: #fff;\n font-size: 20px;\n cursor: pointer;\n margin: 0 2px;\n}\n\n._fc-upload .fc-files:hover .fc-upload-cover {\n opacity: 1;\n}\n\n._fc-upload .ivu-upload-list {\n margin-top: 0;\n}\n\n._fc-upload .fc-files img {\n width: 100%;\n height: 100%;\n display: inline-block;\n vertical-align: top;\n}\n\n._fc-upload .fc-upload-btn, ._fc-upload .fc-files {\n display: inline-block;\n width: 58px;\n height: 58px;\n text-align: center;\n line-height: 58px;\n border: 1px solid #c0ccda;\n border-radius: 4px;\n overflow: hidden;\n background: #fff;\n position: relative;\n box-shadow: 2px 2px 5px rgba(0, 0, 0, .1);\n margin-right: 4px;\n box-sizing: border-box;\n}\n");var u="fcUpload";function f(e){return{name:u,props:{formCreateInject:{type:Object,required:!0},onHandle:{type:Function,default:function(e){this.previewImage=e.url,this.previewVisible=!0}},uploadType:{type:String,default:"file"},maxLength:{type:Number,default:0},allowRemove:{type:Boolean,default:!0},modalTitle:String,handleIcon:{type:[String,Boolean],default:function(){}},value:[Array,String]},data:function(){return{uploadList:[],previewVisible:!1,previewImage:"",cacheFiles:[]}},created:function(){void 0===this.formCreateInject.prop.props.showUploadList&&(this.formCreateInject.prop.props.showUploadList=!1),this.formCreateInject.prop.props.defaultFileList=l(this.value).map(c)},watch:{value:function(e){this.$refs.upload.fileList.every(function(e){return!e.status||"finished"===e.status})&&(this.$refs.upload.fileList=l(e).map(c),this.uploadList=this.$refs.upload.fileList)},maxLength:function(e,t){1!==t&&1!==e||this.update()}},methods:{key:function(e){return e},isDisabled:function(){return!0===this.formCreateInject.prop.props.disabled},onRemove:function(e){this.isDisabled()||this.$refs.upload.handleRemove(e)},handleClick:function(e){this.onHandle(e)},makeItem:function(t,n){var i=this.$createElement;return"image"===this.uploadType?i("img",{attrs:{src:t.url},key:this.key("img"+n)}):i("icon",r([{},{props:{type:e.fileIcon,size:40}},{key:this.key("i"+n)}]))},makeRemoveIcon:function(e,t){var n=this;return(0,this.$createElement)("icon",{attrs:{type:"ios-trash-outline"},on:{click:function(){return n.onRemove(e)}},key:this.key("ri"+t)})},makeHandleIcon:function(e,t){var n=this;return(0,this.$createElement)("icon",{attrs:{type:!0===this.handleIcon||void 0===this.handleIcon?"ios-eye-outline":this.handleIcon},on:{click:function(){return n.handleClick(e)}},key:this.key("hi"+t)})},makeProgress:function(e,t){return(0,this.$createElement)("Progress",r([{},{props:{percent:e.percentage,hideInfo:!0}},{style:"width:90%",key:this.key("pg"+t)}]))},makeIcons:function(e,t){var n=this.$createElement,i=[];if(this.allowRemove||!1!==this.handleIcon)return("file"!==this.uploadType&&!1!==this.handleIcon||"file"===this.uploadType&&this.handleIcon)&&i.push(this.makeHandleIcon(e,t)),this.allowRemove&&i.push(this.makeRemoveIcon(e,t)),n("div",{class:"fc-upload-cover"},[i])},makeFiles:function(){var e=this,t=this.$createElement;return this.uploadList.map(function(n,i){return e.$scopedSlots.fileList?e.$scopedSlots.fileList({file:n,index:i,vm:e}):t("div",{key:e.key(i),class:"fc-files"},[n.showProgress?e.makeProgress(n,i):[e.makeItem(n,i),e.makeIcons(n,i)]])})},makeUpload:function(){var t,n,i=this.$createElement,o=!this.maxLength||this.maxLength>this.uploadList.length;return i("Upload",r([{},this.formCreateInject.prop,{ref:"upload",style:{display:"inline-block"},key:this.key("upload")}]),[o?i("template",{slot:"default"},[this.$slots.default||i("div",{class:"fc-upload-btn"},[i("icon",r([{},{props:{type:"file"===this.uploadType?"ios-cloud-upload-outline":e.imgUpIcon,size:20}}]))])]):null,(t=this.$slots,n=["default"],Object.keys(t).reduce(function(e,i){return n&&-1!==n.indexOf(i)||e.push(t[i]),e},[]))])},update:function(){var e=this.$refs.upload.fileList.map(function(e){return e.url}).filter(function(e){return void 0!==e});this.cacheFiles.length!==e.length&&(this.cacheFiles=a(e),this.$emit("input",1===this.maxLength?e[0]||"":e))},handleCancel:function(){this.previewVisible=!1}},render:function(){var e=this,t=arguments[0];return this.$refs.upload&&(void 0===this.formCreateInject.prop.props.showUploadList&&(this.formCreateInject.prop.props.showUploadList=this.$refs.upload.showUploadList),this.formCreateInject.prop.props.defaultFileList=this.$refs.upload.defaultFileList),t("div",{class:"_fc-upload"},[[this.formCreateInject.prop.props.showUploadList?[]:this.makeFiles(),this.makeUpload()],t("Modal",r([{},{props:{title:this.modalTitle,footerHide:!0}},{model:{value:e.previewVisible,callback:function(t){e.previewVisible=t}}}]),[t("img",{attrs:{alt:"example",src:this.previewImage},style:"width: 100%"})])])},mounted:function(){var e=this;this.uploadList=this.$refs.upload.fileList,this.$watch(function(){return e.$refs.upload.fileList},function(){e.update()},{deep:!0})}}}var d=f({fileIcon:"md-document",imgUpIcon:"md-images"});return d.v2=f({fileIcon:"document-text",imgUpIcon:"image"}),d}); //# sourceMappingURL=index.js.map