(("undefined"!==typeof self?self:this)["webpackJsonpkk_form_design"]=("undefined"!==typeof self?self:this)["webpackJsonpkk_form_design"]||[]).push([[37],{"0553":function(e,t,o){"use strict";o.r(t);var i=function(){var e=this,t=e._self._c;return t("div",{style:{width:e.record.options.width}},[e.record.options.drag?t("UploadDragger",{class:{"hide-upload-drag":!(e.fileList.length<e.record.options.limit)},attrs:{disabled:e.record.options.disabled||e.parentDisabled,name:e.config.uploadFileName||e.record.options.fileName,headers:e.config.uploadFileHeaders||e.record.options.headers,data:e.config.uploadFileData||e.optionsData,action:e.config.uploadFile||e.record.options.action,multiple:e.record.options.multiple,fileList:e.fileList,remove:e.remove,beforeUpload:e.beforeUpload},on:{preview:e.handlePreview,change:e.handleChange}},[t("p",{staticClass:"ant-upload-drag-icon"},[t("a-icon",{attrs:{type:"cloud-upload"}})],1),t("p",{staticClass:"ant-upload-text"},[e._v("单击或拖动文件到此区域")])]):t("Upload",{attrs:{disabled:e.record.options.disabled||e.parentDisabled,name:e.config.uploadFileName||e.record.options.fileName,headers:e.config.uploadFileHeaders||e.record.options.headers,data:e.config.uploadFileData||e.optionsData,action:e.config.uploadFile||e.record.options.action,multiple:e.record.options.multiple,fileList:e.fileList,remove:e.remove,beforeUpload:e.beforeUpload},on:{preview:e.handlePreview,change:e.handleChange}},[e.fileList.length<e.record.options.limit?t("Button",{attrs:{disabled:e.record.options.disabled||e.parentDisabled}},[t("a-icon",{attrs:{type:"upload"}}),e._v(" "+e._s(e.record.options.placeholder)+" ")],1):e._e()],1)],1)},n=[],a=(o("5f1c"),o("a450"),o("6927")),r=o("e74d"),s=r["c"].getComponent("upload"),l=r["c"].getComponent("uploadDragger"),d=r["c"].getComponent("aButton").component,c={name:"KUploadFile",props:["record","value","config","parentDisabled","dynamicData"],components:{Upload:s.component,UploadDragger:l.component,Button:d},data:function(){return{fileList:[]}},watch:{value:{handler:function(e){e&&this.setFileList()},immediate:!0,deep:!0}},computed:{optionsData:function(){try{return JSON.parse(this.record.options.data)}catch(e){return console.error(e),{}}}},methods:{setFileList:function(){"string"===typeof this.value?(this.fileList=JSON.parse(this.value),this.handleSelectChange()):this.fileList=this.value},handleSelectChange:function(){var e=this;setTimeout((function(){var t=e.fileList.map((function(e){if("undefined"!==typeof e.response){var t=e.response;return{type:"file",name:e.name,status:e.status,uid:t.data.fileId||Date.now(),url:t.data.url||""}}return{type:"file",name:e.name,status:e.status,uid:e.uid,url:e.url||""}}));e.$emit("change",t),e.$emit("input",t)}),10)},handlePreview:function(e){var t=this,o=this.record.options.downloadWay,i=this.record.options.dynamicFun;if("a"===o){var n=document.createElement("a");n.href=e.url||e.thumbUrl,n.download=e.name,n.click()}else"ajax"===o?this.getBlob(e.url||e.thumbUrl).then((function(o){t.saveAs(o,e.name)})):"dynamic"===o&&this.dynamicData[i](e)},getBlob:function(e){return new Promise((function(t){var o=new XMLHttpRequest;o.open("GET",e,!0),o.responseType="blob",o.onload=function(){200===o.status&&t(o.response)},o.send()}))},saveAs:function(e,t){if(window.navigator.msSaveOrOpenBlob)navigator.msSaveBlob(e,t);else{var o=document.createElement("a"),i=document.querySelector("body");o.href=window.URL.createObjectURL(e),o.download=t,o.style.display="none",i.appendChild(o),o.click(),i.removeChild(o),window.URL.revokeObjectURL(o.href)}},remove:function(){this.handleSelectChange()},beforeUpload:function(e,t){t.length+this.fileList.length>this.record.options.limit&&(a["a"].warning("最大上传数量为".concat(this.record.options.limit)),t.splice(this.record.options.limit-this.fileList.length))},handleChange:function(e){if(this.fileList=e.fileList,"done"===e.file.status){var t=e.file.response;0===t.code?this.handleSelectChange():(this.fileList.pop(),a["a"].error("文件上传失败"))}else"error"===e.file.status&&a["a"].error("文件上传失败")}}},p=c,u=o("e607"),f=Object(u["a"])(p,i,n,!1,null,null,null),h=f.exports;t["default"]=h}}]);