UNPKG

jsmom-file-upload

Version:

文件上传

2 lines 33.7 kB
!function(n,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("axios"),require("js-md5")):"function"==typeof define&&define.amd?define("main",["axios","js-md5"],t):"object"==typeof exports?exports.main=t(require("axios"),require("js-md5")):n.main=t(n.axios,n.jsMd5)}(this,(function(n,t){return function(n){var t={};function e(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return n[r].call(o.exports,o,o.exports,e),o.l=!0,o.exports}return e.m=n,e.c=t,e.d=function(n,t,r){e.o(n,t)||Object.defineProperty(n,t,{enumerable:!0,get:r})},e.r=function(n){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(n,"__esModule",{value:!0})},e.t=function(n,t){if(1&t&&(n=e(n)),8&t)return n;if(4&t&&"object"==typeof n&&n&&n.__esModule)return n;var r=Object.create(null);if(e.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:n}),2&t&&"string"!=typeof n)for(var o in n)e.d(r,o,function(t){return n[t]}.bind(null,o));return r},e.n=function(n){var t=n&&n.__esModule?function(){return n.default}:function(){return n};return e.d(t,"a",t),t},e.o=function(n,t){return Object.prototype.hasOwnProperty.call(n,t)},e.p="/dist/",e(e.s=10)}([function(n,t,e){n.exports=e(15)},function(t,e){t.exports=n},function(n,t,e){var r=e(11),o=e(12),i=e(13),a=e(14);n.exports=function(n){return r(n)||o(n)||i(n)||a()},n.exports.default=n.exports,n.exports.__esModule=!0},function(n,t){function e(n,t,e,r,o,i,a){try{var s=n[i](a),u=s.value}catch(n){return void e(n)}s.done?t(u):Promise.resolve(u).then(r,o)}n.exports=function(n){return function(){var t=this,r=arguments;return new Promise((function(o,i){var a=n.apply(t,r);function s(n){e(a,o,i,s,u,"next",n)}function u(n){e(a,o,i,s,u,"throw",n)}s(void 0)}))}},n.exports.default=n.exports,n.exports.__esModule=!0},function(n,t){n.exports=function(n,t){(null==t||t>n.length)&&(t=n.length);for(var e=0,r=new Array(t);e<t;e++)r[e]=n[e];return r},n.exports.default=n.exports,n.exports.__esModule=!0},function(n,t,e){var r=e(17);r.__esModule&&(r=r.default),"string"==typeof r&&(r=[[n.i,r,""]]),r.locals&&(n.exports=r.locals);(0,e(19).default)("7dee4044",r,!0,{})},function(n,t){function e(t){return"function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?(n.exports=e=function(n){return typeof n},n.exports.default=n.exports,n.exports.__esModule=!0):(n.exports=e=function(n){return n&&"function"==typeof Symbol&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},n.exports.default=n.exports,n.exports.__esModule=!0),e(t)}n.exports=e,n.exports.default=n.exports,n.exports.__esModule=!0},function(n,t){n.exports=function(n,t,e){return t in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n},n.exports.default=n.exports,n.exports.__esModule=!0},function(n,e){n.exports=t},function(n,t,e){"use strict";n.exports=function(n){var t=[];return t.toString=function(){return this.map((function(t){var e=function(n,t){var e=n[1]||"",r=n[3];if(!r)return e;if(t&&"function"==typeof btoa){var o=(a=r,s=btoa(unescape(encodeURIComponent(JSON.stringify(a)))),u="sourceMappingURL=data:application/json;charset=utf-8;base64,".concat(s),"/*# ".concat(u," */")),i=r.sources.map((function(n){return"/*# sourceURL=".concat(r.sourceRoot||"").concat(n," */")}));return[e].concat(i).concat([o]).join("\n")}var a,s,u;return[e].join("\n")}(t,n);return t[2]?"@media ".concat(t[2]," {").concat(e,"}"):e})).join("")},t.i=function(n,e,r){"string"==typeof n&&(n=[[null,n,""]]);var o={};if(r)for(var i=0;i<this.length;i++){var a=this[i][0];null!=a&&(o[a]=!0)}for(var s=0;s<n.length;s++){var u=[].concat(n[s]);r&&o[u[0]]||(e&&(u[2]?u[2]="".concat(e," and ").concat(u[2]):u[2]=e),t.push(u))}},t}},function(n,t,e){n.exports=e(18)},function(n,t,e){var r=e(4);n.exports=function(n){if(Array.isArray(n))return r(n)},n.exports.default=n.exports,n.exports.__esModule=!0},function(n,t){n.exports=function(n){if("undefined"!=typeof Symbol&&null!=n[Symbol.iterator]||null!=n["@@iterator"])return Array.from(n)},n.exports.default=n.exports,n.exports.__esModule=!0},function(n,t,e){var r=e(4);n.exports=function(n,t){if(n){if("string"==typeof n)return r(n,t);var e=Object.prototype.toString.call(n).slice(8,-1);return"Object"===e&&n.constructor&&(e=n.constructor.name),"Map"===e||"Set"===e?Array.from(n):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?r(n,t):void 0}},n.exports.default=n.exports,n.exports.__esModule=!0},function(n,t){n.exports=function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")},n.exports.default=n.exports,n.exports.__esModule=!0},function(n,t,e){var r=function(n){"use strict";var t=Object.prototype,e=t.hasOwnProperty,r="function"==typeof Symbol?Symbol:{},o=r.iterator||"@@iterator",i=r.asyncIterator||"@@asyncIterator",a=r.toStringTag||"@@toStringTag";function s(n,t,e){return Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}),n[t]}try{s({},"")}catch(n){s=function(n,t,e){return n[t]=e}}function u(n,t,e,r){var o=t&&t.prototype instanceof d?t:d,i=Object.create(o.prototype),a=new S(r||[]);return i._invoke=function(n,t,e){var r="suspendedStart";return function(o,i){if("executing"===r)throw new Error("Generator is already running");if("completed"===r){if("throw"===o)throw i;return A()}for(e.method=o,e.arg=i;;){var a=e.delegate;if(a){var s=x(a,e);if(s){if(s===c)continue;return s}}if("next"===e.method)e.sent=e._sent=e.arg;else if("throw"===e.method){if("suspendedStart"===r)throw r="completed",e.arg;e.dispatchException(e.arg)}else"return"===e.method&&e.abrupt("return",e.arg);r="executing";var u=l(n,t,e);if("normal"===u.type){if(r=e.done?"completed":"suspendedYield",u.arg===c)continue;return{value:u.arg,done:e.done}}"throw"===u.type&&(r="completed",e.method="throw",e.arg=u.arg)}}}(n,e,a),i}function l(n,t,e){try{return{type:"normal",arg:n.call(t,e)}}catch(n){return{type:"throw",arg:n}}}n.wrap=u;var c={};function d(){}function f(){}function p(){}var h={};s(h,o,(function(){return this}));var v=Object.getPrototypeOf,m=v&&v(v(L([])));m&&m!==t&&e.call(m,o)&&(h=m);var y=p.prototype=d.prototype=Object.create(h);function g(n){["next","throw","return"].forEach((function(t){s(n,t,(function(n){return this._invoke(t,n)}))}))}function b(n,t){var r;this._invoke=function(o,i){function a(){return new t((function(r,a){!function r(o,i,a,s){var u=l(n[o],n,i);if("throw"!==u.type){var c=u.arg,d=c.value;return d&&"object"==typeof d&&e.call(d,"__await")?t.resolve(d.__await).then((function(n){r("next",n,a,s)}),(function(n){r("throw",n,a,s)})):t.resolve(d).then((function(n){c.value=n,a(c)}),(function(n){return r("throw",n,a,s)}))}s(u.arg)}(o,i,r,a)}))}return r=r?r.then(a,a):a()}}function x(n,t){var e=n.iterator[t.method];if(void 0===e){if(t.delegate=null,"throw"===t.method){if(n.iterator.return&&(t.method="return",t.arg=void 0,x(n,t),"throw"===t.method))return c;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return c}var r=l(e,n.iterator,t.arg);if("throw"===r.type)return t.method="throw",t.arg=r.arg,t.delegate=null,c;var o=r.arg;return o?o.done?(t[n.resultName]=o.value,t.next=n.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,c):o:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,c)}function w(n){var t={tryLoc:n[0]};1 in n&&(t.catchLoc=n[1]),2 in n&&(t.finallyLoc=n[2],t.afterLoc=n[3]),this.tryEntries.push(t)}function k(n){var t=n.completion||{};t.type="normal",delete t.arg,n.completion=t}function S(n){this.tryEntries=[{tryLoc:"root"}],n.forEach(w,this),this.reset(!0)}function L(n){if(n){var t=n[o];if(t)return t.call(n);if("function"==typeof n.next)return n;if(!isNaN(n.length)){var r=-1,i=function t(){for(;++r<n.length;)if(e.call(n,r))return t.value=n[r],t.done=!1,t;return t.value=void 0,t.done=!0,t};return i.next=i}}return{next:A}}function A(){return{value:void 0,done:!0}}return f.prototype=p,s(y,"constructor",p),s(p,"constructor",f),f.displayName=s(p,a,"GeneratorFunction"),n.isGeneratorFunction=function(n){var t="function"==typeof n&&n.constructor;return!!t&&(t===f||"GeneratorFunction"===(t.displayName||t.name))},n.mark=function(n){return Object.setPrototypeOf?Object.setPrototypeOf(n,p):(n.__proto__=p,s(n,a,"GeneratorFunction")),n.prototype=Object.create(y),n},n.awrap=function(n){return{__await:n}},g(b.prototype),s(b.prototype,i,(function(){return this})),n.AsyncIterator=b,n.async=function(t,e,r,o,i){void 0===i&&(i=Promise);var a=new b(u(t,e,r,o),i);return n.isGeneratorFunction(e)?a:a.next().then((function(n){return n.done?n.value:a.next()}))},g(y),s(y,a,"Generator"),s(y,o,(function(){return this})),s(y,"toString",(function(){return"[object Generator]"})),n.keys=function(n){var t=[];for(var e in n)t.push(e);return t.reverse(),function e(){for(;t.length;){var r=t.pop();if(r in n)return e.value=r,e.done=!1,e}return e.done=!0,e}},n.values=L,S.prototype={constructor:S,reset:function(n){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(k),!n)for(var t in this)"t"===t.charAt(0)&&e.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var n=this.tryEntries[0].completion;if("throw"===n.type)throw n.arg;return this.rval},dispatchException:function(n){if(this.done)throw n;var t=this;function r(e,r){return a.type="throw",a.arg=n,t.next=e,r&&(t.method="next",t.arg=void 0),!!r}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return r("end");if(i.tryLoc<=this.prev){var s=e.call(i,"catchLoc"),u=e.call(i,"finallyLoc");if(s&&u){if(this.prev<i.catchLoc)return r(i.catchLoc,!0);if(this.prev<i.finallyLoc)return r(i.finallyLoc)}else if(s){if(this.prev<i.catchLoc)return r(i.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return r(i.finallyLoc)}}}},abrupt:function(n,t){for(var r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r];if(o.tryLoc<=this.prev&&e.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===n||"continue"===n)&&i.tryLoc<=t&&t<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=n,a.arg=t,i?(this.method="next",this.next=i.finallyLoc,c):this.complete(a)},complete:function(n,t){if("throw"===n.type)throw n.arg;return"break"===n.type||"continue"===n.type?this.next=n.arg:"return"===n.type?(this.rval=this.arg=n.arg,this.method="return",this.next="end"):"normal"===n.type&&t&&(this.next=t),c},finish:function(n){for(var t=this.tryEntries.length-1;t>=0;--t){var e=this.tryEntries[t];if(e.finallyLoc===n)return this.complete(e.completion,e.afterLoc),k(e),c}},catch:function(n){for(var t=this.tryEntries.length-1;t>=0;--t){var e=this.tryEntries[t];if(e.tryLoc===n){var r=e.completion;if("throw"===r.type){var o=r.arg;k(e)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(n,t,e){return this.delegate={iterator:L(n),resultName:t,nextLoc:e},"next"===this.method&&(this.arg=void 0),c}},n}(n.exports);try{regeneratorRuntime=r}catch(n){"object"==typeof globalThis?globalThis.regeneratorRuntime=r:Function("r","regeneratorRuntime = r")(r)}},function(n,t,e){"use strict";e(5)},function(n,t,e){"use strict";e.r(t);var r=e(9),o=e.n(r)()(!0);o.push([n.i,".uploadFloatWindow[data-v-a77bf798]{position:fixed;right:15px;bottom:15px;padding:5px 0;background-color:#fff;width:520px;box-shadow:0 0 10px -6px #000;border-radius:8px;z-index:100}.file-upload[data-v-a77bf798] .el-upload{display:block}","",{version:3,sources:["webpack://src/packages/my-component.vue"],names:[],mappings:"AAy1BA,oCACE,cAAA,CACA,UAAA,CACA,WAAA,CACA,aAAA,CACA,qBAAA,CACA,WAAA,CACA,6BAAA,CACA,iBAAA,CACA,WAAA,CAKE,0CACE,aAAA",sourcesContent:["\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n.uploadFloatWindow {\n position: fixed;\n right: 15px;\n bottom: 15px;\n padding: 5px 0;\n background-color: #fff;\n width: 520px;\n box-shadow: 0 0 10px -6px black;\n border-radius: 8px;\n z-index: 100;\n}\n\n.file-upload {\n ::v-deep {\n .el-upload {\n display: block;\n }\n }\n}\n"],sourceRoot:""}]),t.default=o},function(n,t,e){"use strict";e.r(t);var r=e(6),o=e.n(r),i=e(2),a=e.n(i),s=e(3),u=e.n(s),l=e(7),c=e.n(l),d=e(0),f=e.n(d),p=e(8),h=e.n(p);function v(n,t){if(t)window.localStorage.setItem(n,JSON.stringify(t));else if(null===t)window.localStorage.removeItem(n);else try{return JSON.parse(window.localStorage.getItem(n))}catch(t){return window.localStorage.getItem(n)}}var m=e(1),y=e.n(m);function g(n,t){var e="undefined"!=typeof Symbol&&n[Symbol.iterator]||n["@@iterator"];if(!e){if(Array.isArray(n)||(e=function(n,t){if(!n)return;if("string"==typeof n)return b(n,t);var e=Object.prototype.toString.call(n).slice(8,-1);"Object"===e&&n.constructor&&(e=n.constructor.name);if("Map"===e||"Set"===e)return Array.from(n);if("Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e))return b(n,t)}(n))||t&&n&&"number"==typeof n.length){e&&(n=e);var r=0,o=function(){};return{s:o,n:function(){return r>=n.length?{done:!0}:{done:!1,value:n[r++]}},e:function(n){throw n},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,s=!1;return{s:function(){e=e.call(n)},n:function(){var n=e.next();return a=n.done,n},e:function(n){s=!0,i=n},f:function(){try{a||null==e.return||e.return()}finally{if(s)throw i}}}}function b(n,t){(null==t||t>n.length)&&(t=n.length);for(var e=0,r=new Array(t);e<t;e++)r[e]=n[e];return r}function x(n,t){var e=Object.keys(n);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(n);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(n,t).enumerable}))),e.push.apply(e,r)}return e}function w(n){for(var t=1;t<arguments.length;t++){var e=null!=arguments[t]?arguments[t]:{};t%2?x(Object(e),!0).forEach((function(t){c()(n,t,e[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(e)):x(Object(e)).forEach((function(t){Object.defineProperty(n,t,Object.getOwnPropertyDescriptor(e,t))}))}return n}var k=y.a.CancelToken,S={name:"file-upload",props:{limit:Number,accept:{type:String,default:""},beforeUpload:Function,uploadedFileList:Array,configData:{type:Object,default:function(){return{}}},showFileList:{type:Boolean,default:!1}},data:function(){var n;return{t:this.$t?this.$t:function(n){return n},fileList:[],uploadPromise:[],uploadListStatus:"hide",tenantId:null!==(n=v("tenant_id"))&&void 0!==n?n:""}},computed:{computeConfigData:function(){var n,t,e,r,o,i,a,s,u,l,c,d,f,p,h,v,m,y,g,b,x,k,S,L,A;return w(w({},this.configData),{},{chunkSize:null!==(n=null===(t=this.configData)||void 0===t?void 0:t.chunkSize)&&void 0!==n?n:2048e3,fileCheckUrl:null!==(e=this.configData.fileCheckUrl)&&void 0!==e?e:"".concat(null!==(r=this.configData.baseApi)&&void 0!==r?r:"","/mdm/AttachMentUploadAPI/Upload"),fileUploadUrl:null!==(o=this.configData.fileUploadUrl)&&void 0!==o?o:"".concat(null!==(i=this.configData.baseApi)&&void 0!==i?i:"","/mdm/AttachMentUploadAPI/Upload"),fileMergeUrl:null!==(a=this.configData.fileMergeUrl)&&void 0!==a?a:"".concat(null!==(s=this.configData.baseApi)&&void 0!==s?s:"","/mdm/AttachMentUploadAPI/merge"),fileDownloadUrl:null!==(u=this.configData.fileDownloadUrl)&&void 0!==u?u:"".concat(null!==(l=this.configData.baseApi)&&void 0!==l?l:"","/mdm/AttachMentUploadAPI/downloadFile"),fromTable:null!==(c=this.configData.fromTable)&&void 0!==c?c:"",fromKey:null!==(d=this.configData.fromKey)&&void 0!==d?d:"",headers:w(w({},null!==(f=null===(p=this.configData)||void 0===p?void 0:p.headers)&&void 0!==f?f:{}),{},{jsmomtoken:null!==(h=null===(v=this.configData)||void 0===v||null===(m=v.headers)||void 0===m?void 0:m.jsmomtoken)&&void 0!==h?h:(null===(y=document)||void 0===y||null===(g=y.cookie)||void 0===g||null===(b=g.split(";"))||void 0===b||null===(x=b.find((function(n){return-1!==n.indexOf("jsmomtoken=")})))||void 0===x||null===(k=x.split("="))||void 0===k?void 0:k[1])||"",tenantId:null!==(S=null===(L=this.configData)||void 0===L||null===(A=L.headers)||void 0===A?void 0:A.tenantId)&&void 0!==S?S:this.tenantId})})}},methods:{handleFileRemove:function(n){var t=this.uploadedFileList.findIndex((function(t){return t.id===n.id}));-1!==t&&this.uploadedFileList.splice(t,1)},handleFilePreview:function(n){n.id&&window.open("".concat(this.computeConfigData.fileDownloadUrl+"?tenantId=".concat(this.computeConfigData.headers.tenantId,"&jsmomtoken=").concat(this.computeConfigData.headers.jsmomtoken,"&AttachMentCode=$id")).replace("$id",n.id),"_blank")},handleClickUploadBtn:function(){void 0===this.limit||0===this.limit||this.uploadedFileList.length<this.limit?this.$refs.inputFile.dispatchEvent(new MouseEvent("click")):this.$message({message:this.t("超过当前文件上传数量限制")+this.limit,type:"warning"})},handleClickPauseOrRestoreBtn:function(n){"paused"===n.status?0===n.chunkList.length||n.chunkList.some((function(n){return"done"!==n.status}))?(n.cancelTokenSource.cancel(this.t("重新上传")),this.fnFileUpload(n.file,n).then((function(n){console.log(n)})).catch((function(n){console.error(n)}))):(this.fnSetFileListById(n.id,{status:"done"}),console.error("上传完了")):(n.cancelTokenSource.cancel(this.t("暂停")),this.fnSetFileListById(n.id,{status:"paused"}))},handleClickDelBtn:function(n){n.cancelTokenSource.cancel(this.t("删除")),this.fileList=this.fileList.filter((function(t){return t.id!==n.id}))},handleFileChange:function(){var n=this,t=this.$refs.inputFile.files,e=t.length+this.uploadedFileList.length+this.fileList.filter((function(n){return"done"!==n.status&&"success"!==n.status&&"error"!==n.status})).length;void 0===this.limit||0===this.limit||e<=this.limit?new Promise((function(e){if(n.beforeUpload&&"function"==typeof n.beforeUpload){var r=n.beforeUpload(Array.from(t));r instanceof Promise?null==r||r.then((function(){e()})):r&&e()}else e()})).then((function(){n.uploadListStatus="show";var e,r=[],o=g(t);try{for(o.s();!(e=o.n()).done;){var i=e.value;r.push(n.fnFileUpload(i))}}catch(n){o.e(n)}finally{o.f()}n.$refs.inputFile.value="",Promise.all(r).then((function(){})).catch((function(){}))})):this.$message({message:"".concat(this.t("当前限制上传文件数:")).concat(this.limit,",").concat(this.t("本次选择文件数:")).concat(t.length,",").concat(this.t("共选择文件数:")).concat(e),type:"warning"})},fnFileUpload:function(n,t){var e=this,r=null,i=k.source();return t?(r=t.id,this.fnSetFileListById(r,{cancelTokenSource:i})):(r=function(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:16,t=new Date,e=t.getTime(),r=Math.round(1e3*Math.random());return parseInt("".concat(e.toString().slice(-(n-2),-1)).concat(r))}(),this.fileList.push({status:"waiting",file:n,id:r,md5:"",md5Progress:0,uploadProgress:0,cancelTokenSource:i,chunkList:[]})),new Promise((function(s,l){t||e.fnSetFileListById(r,{status:"md5"});var c=new FileReader;c.readAsArrayBuffer(n),c.addEventListener("load",function(){var c=u()(f.a.mark((function u(c){var d,p,v,m,y,g;return f.a.wrap((function(u){for(;;)switch(u.prev=u.next){case 0:if(d=c.target.result,p=null,v=[],m=Math.ceil(n.size/e.computeConfigData.chunkSize),p=t?t.md5:h()(d),e.fnSetFileListById(r,{md5:p,md5Progress:1}),u.prev=6,y=null,t){u.next=13;break}return e.fnSetFileListById(r,{status:"check"}),u.next=12,e.fnGetCheckFile({data:{identifier:p,FromTable:e.computeConfigData.fromTable,FromKey:e.computeConfigData.fromKey,totalChunks:m,totalSize:n.size,filename:n.name,relativePath:n.name},url:e.computeConfigData.fileCheckUrl});case 12:y=u.sent;case 13:if(!(t||y&&200===y.code)){u.next=17;break}if(g=function(){if(y&&y.data&&y.data.skipUpload)return e.fnSetFileListById(r,{status:"done",uploadProgress:1}),e.uploadedFileList.push({id:y.data.AttachMentCode,name:n.name}),s(y),{v:!0};for(var o=[],u=function(s){var u=s*e.computeConfigData.chunkSize,l=n.size>u+e.computeConfigData.chunkSize?u+e.computeConfigData.chunkSize:n.size,c=d.slice(u,l);if(t){if(t.chunkList&&t.chunkList[s]&&"done"===t.chunkList[s].status)return o[s]=l-u,"continue"}else{var f,h;if((y.data&&y.data.uploadeds||[]).some((function(n){return parseInt(n)===s+1})))return e.fnSetFileListById(r,{chunkList:[].concat(a()((null===(f=e.fnGetFileListById(r))||void 0===f?void 0:f.chunkList)||[]),[{start:u,end:l,status:"done"}])}),o[s]=l-u,"continue";e.fnSetFileListById(r,{chunkList:[].concat(a()((null===(h=e.fnGetFileListById(r))||void 0===h?void 0:h.chunkList)||[]),[{start:u,end:l,status:"waiting"}])})}v.push(new Promise((function(t,a){e.fnSetFileListById(r,{status:"uploading"}),e.fnPostFileUpload({url:e.computeConfigData.fileUploadUrl,data:[{key:"upfile",value:new Blob([c])},{key:"identifier",value:p},{key:"FromTable",value:e.computeConfigData.fromTable},{key:"FromKey",value:e.computeConfigData.fromKey},{key:"chunkNumber",value:s+1},{key:"totalChunks",value:m},{key:"totalSize",value:n.size},{key:"filename",value:n.name},{key:"relativePath",value:n.name}],cancelToken:i.token,onUploadProgress:function(t){o[s]=t.loaded,t.total>0&&e.fnSetFileListById(r,{uploadProgress:o.reduce((function(n,t){return n+t}))/n.size})},onSuccess:function(n){if(200===n.code){var o,i=(null===(o=e.fnGetFileListById(r))||void 0===o?void 0:o.chunkList)||[];i[s].status="done",e.fnSetFileListById(r,{chunkList:i}),t(n)}else a(n)},onError:function(n){a(n)}})})).then((function(n){return console.log(n),n})))},c=0;c<m;c++)u(c);Promise.all(v).then((function(t){e.fnSetFileListById(r,{status:"merging",uploadProgress:1}),m>1?e.fnPostFileMerge({url:e.computeConfigData.fileMergeUrl,data:[{key:"identifier",value:p},{key:"FromTable",value:e.computeConfigData.fromTable},{key:"FromKey",value:e.computeConfigData.fromKey},{key:"totalChunks",value:m},{key:"totalSize",value:n.size},{key:"filename",value:n.name},{key:"relativePath",value:n.name}],onSuccess:function(t){t&&t.data&&200===t.code?(e.fnSetFileListById(r,{status:"done"}),e.uploadedFileList.push({id:t.data.AttachMentCode,name:n.name}),s(t)):l(t)},onError:function(n){e.fnSetFileListById(r,{status:"error"}),l(n)}}):(e.fnSetFileListById(r,{status:"done"}),e.uploadedFileList.push({id:t[0].data.AttachMentCode,name:n.name}),s(t))})).catch((function(n){console.log(n),n&&"暂停"==n.message||(e.fnSetFileListById(r,{status:"error"}),l())}))}(),"object"!==o()(g)){u.next=17;break}return u.abrupt("return",g.v);case 17:u.next=23;break;case 19:u.prev=19,u.t0=u.catch(6),e.fnSetFileListById(r,{status:"error"}),l();case 23:case"end":return u.stop()}}),u,null,[[6,19]])})));return function(n){return c.apply(this,arguments)}}(),!1),c.addEventListener("error",(function(){l()}),!1),c.addEventListener("progress",(function(n){n.total>0&&e.fnSetFileListById(r,{md5Progress:n.loaded/n.total})}),!1)}))},fnPostFileUpload:function(n){var t=n.data,e=void 0===t?[]:t,r=n.onUploadProgress,o=n.url,i=n.cancelToken,a=n.onSuccess,s=n.onError,u=new FormData;e.forEach((function(n){u.append(n.key,n.value)})),y.a.create({headers:w({"Content-Type":"multipart/form-data"},this.computeConfigData.headers||{}),onUploadProgress:r,cancelToken:i}).post(o,u).then((function(n){n&&n.data&&200===n.data.code?a(n.data):s(n.data)})).catch((function(n){s(n)}))},fnGetCheckFile:function(n){var t=this;return u()(f.a.mark((function e(){var r,o,i,a;return f.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=n.data,o=void 0===r?[]:r,i=n.url,e.next=3,y.a.create({headers:w({},t.computeConfigData.headers||{})}).get(i,{params:o});case 3:if(!(a=e.sent)||!a.data||200!==a.data.code){e.next=8;break}return e.abrupt("return",a.data);case 8:return e.abrupt("return",a.data);case 9:case"end":return e.stop()}}),e)})))()},fnPostFileMerge:function(n){var t=n.data,e=void 0===t?[]:t,r=n.url,o=n.onSuccess,i=n.onError,a=new FormData;e.forEach((function(n){a.append(n.key,n.value)})),y.a.create({headers:w({"Content-Type":"multipart/form-data"},this.computeConfigData.headers||{})}).post(r,a).then((function(n){n&&n.data&&200===n.data.code?o(n.data):i(n.data)})).catch((function(n){i(n)}))},fnSetFileListById:function(n,t){var e=this;this.fileList.some((function(r,o){if(r.id===n){for(var i in t)e.fileList[o][i]=t[i];return!0}return!1}))},fnGetFileListById:function(n){var t,e=g(this.fileList);try{for(e.s();!(t=e.n()).done;){var r=t.value;if(r.id===n)return Object.freeze(w({},r))}}catch(n){e.e(n)}finally{e.f()}return null},fnFormatterFileStatus:function(n){var t="";switch(n){case"waiting":t=this.t("等待中");break;case"md5":t=this.t("正在计算MD5");break;case"uploading":t=this.t("正在上传");break;case"merging":t=this.t("合并文件中");break;case"done":t=this.t("完成");break;case"paused":t=this.t("已暂停");break;case"error":t=this.t("上传失败");break;case"check":t=this.t("检查远程数据")}return t},fnFormatterFileSize:function(n){return n<=1024?n.toFixed(2)/1+"Byte":n<=1048576?(n/1024).toFixed(2)/1+"KB":n<=1073741824?(n/1024/1024).toFixed(2)/1+"MB":n<=1099511627776?(n/1024/1024/1024).toFixed(2)/1+"GB":(n/1024/1024/1024/1024).toFixed(2)/1+"TB"}}};e(16);var L=function(n,t,e,r,o,i,a,s){var u,l="function"==typeof n?n.options:n;if(t&&(l.render=t,l.staticRenderFns=e,l._compiled=!0),r&&(l.functional=!0),i&&(l._scopeId="data-v-"+i),a?(u=function(n){(n=n||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext)||"undefined"==typeof __VUE_SSR_CONTEXT__||(n=__VUE_SSR_CONTEXT__),o&&o.call(this,n),n&&n._registeredComponents&&n._registeredComponents.add(a)},l._ssrRegister=u):o&&(u=s?function(){o.call(this,(l.functional?this.parent:this).$root.$options.shadowRoot)}:o),u)if(l.functional){l._injectStyles=u;var c=l.render;l.render=function(n,t){return u.call(t),c(n,t)}}else{var d=l.beforeCreate;l.beforeCreate=d?[].concat(d,u):[u]}return{exports:n,options:l}}(S,(function(){var n=this,t=n.$createElement,e=n._self._c||t;return e("div",[e("div",{on:{click:n.handleClickUploadBtn}},[n._t("default")],2),n._v(" "),n.showFileList?e("el-upload",{staticClass:"file-upload",attrs:{action:"","on-remove":function(t,e){n.handleFileRemove(t,e)},"on-preview":n.handleFilePreview,"file-list":n.uploadedFileList}}):n._e(),n._v(" "),e("input",{directives:[{name:"show",rawName:"v-show",value:!1,expression:"false"}],ref:"inputFile",attrs:{type:"file",multiple:"",accept:n.accept||""},on:{change:n.handleFileChange}}),n._v(" "),e("div",{directives:[{name:"show",rawName:"v-show",value:"hide"!==n.uploadListStatus,expression:"uploadListStatus !== 'hide'"}],staticClass:"uploadFloatWindow"},[e("el-row",{staticStyle:{"border-bottom":"1px solid #999",padding:"0 5px"},attrs:{type:"flex",align:"middle",justify:"space-between"}},[e("el-col",{attrs:{span:6}},[n._v(" "+n._s(n.t("上传列表"))+" ")]),n._v(" "),e("el-col",{attrs:{span:2}},[e("el-button",{attrs:{type:"text",icon:"mini"===n.uploadListStatus?"el-icon-full-screen":"el-icon-minus",title:n.t("最小化")},on:{click:function(t){n.uploadListStatus="mini"===n.uploadListStatus?"show":"mini"}}}),n._v(" "),e("el-button",{attrs:{type:"text",icon:"el-icon-close",title:n.t("关闭")},on:{click:function(t){n.uploadListStatus="hide"}}})],1)],1),n._v(" "),e("div",{directives:[{name:"show",rawName:"v-show",value:"mini"!==n.uploadListStatus,expression:"uploadListStatus !== 'mini'"}],staticStyle:{height:"240px","overflow-y":"auto","overflow-x":"hidden"}},n._l(n.fileList,(function(t,r){return e("el-row",{key:r,staticStyle:{padding:"10px 5px","border-bottom":"1px solid #ccc"},attrs:{type:"flex",align:"middle",gutter:5}},[e("el-col",{staticStyle:{"white-space":"nowrap",overflow:"hidden","text-overflow":"ellipsis"},attrs:{span:8,title:t.file.name}},[n._v(n._s(t.file.name))]),n._v(" "),e("el-col",{attrs:{span:4}},[n._v(n._s(n.fnFormatterFileSize(t.file.size)))]),n._v(" "),e("el-col",{attrs:{span:6}},[e("el-progress",{attrs:{"text-inside":!0,"stroke-width":18,percentage:Math.min("md5"===t.status?(100*t.md5Progress).toFixed(2)/1:(100*t.uploadProgress).toFixed(2)/1,100),status:"done"===t.status?"success":"error"===t.status?"exception":void 0,"text-color":"done"===t.status?"#ffffff":"error"===t.status?"#ff8d00":"#00ff00"}})],1),n._v(" "),e("el-col",{attrs:{span:3}},[e("el-tag",{attrs:{type:"done"===t.status?"success":"error"===t.status?"danger":"info",size:"mini"}},[n._v(n._s(n.fnFormatterFileStatus(t.status)))])],1),n._v(" "),e("el-col",{attrs:{span:3}},[e("el-button",{directives:[{name:"show",rawName:"v-show",value:!["done","check","md5","error"].includes(t.status),expression:"!['done', 'check', 'md5', 'error'].includes(item.status)"}],attrs:{type:"text",icon:"paused"===t.status?"el-icon-video-play":"el-icon-video-pause",title:n.t("paused"===t.status?"恢复":"暂停")},on:{click:function(e){return n.handleClickPauseOrRestoreBtn(t)}}}),n._v(" "),e("el-button",{directives:[{name:"show",rawName:"v-show",value:!["done","check","md5"].includes(t.status),expression:"!['done', 'check', 'md5'].includes(item.status)"}],attrs:{type:"text",icon:"el-icon-delete",title:n.t("删除")},on:{click:function(e){return n.handleClickDelBtn(t)}}})],1)],1)})),1)],1)],1)}),[],!1,null,"a77bf798",null).exports;L.install=function(n){return n.component(L.name,L)};var A=L,F=[A];"undefined"!=typeof window&&window.Vue&&function(n){F.map((function(t){n.component(t.name,t)}))}(window.Vue);t.default=A},function(n,t,e){"use strict";function r(n,t){for(var e=[],r={},o=0;o<t.length;o++){var i=t[o],a=i[0],s={id:n+":"+o,css:i[1],media:i[2],sourceMap:i[3]};r[a]?r[a].parts.push(s):e.push(r[a]={id:a,parts:[s]})}return e}e.r(t),e.d(t,"default",(function(){return p}));var o="undefined"!=typeof document;if("undefined"!=typeof DEBUG&&DEBUG&&!o)throw new Error("vue-style-loader cannot be used in a non-browser environment. Use { target: 'node' } in your Webpack config to indicate a server-rendering environment.");var i={},a=o&&(document.head||document.getElementsByTagName("head")[0]),s=null,u=0,l=!1,c=function(){},d=null,f="undefined"!=typeof navigator&&/msie [6-9]\b/.test(navigator.userAgent.toLowerCase());function p(n,t,e,o){l=e,d=o||{};var a=r(n,t);return h(a),function(t){for(var e=[],o=0;o<a.length;o++){var s=a[o];(u=i[s.id]).refs--,e.push(u)}t?h(a=r(n,t)):a=[];for(o=0;o<e.length;o++){var u;if(0===(u=e[o]).refs){for(var l=0;l<u.parts.length;l++)u.parts[l]();delete i[u.id]}}}}function h(n){for(var t=0;t<n.length;t++){var e=n[t],r=i[e.id];if(r){r.refs++;for(var o=0;o<r.parts.length;o++)r.parts[o](e.parts[o]);for(;o<e.parts.length;o++)r.parts.push(m(e.parts[o]));r.parts.length>e.parts.length&&(r.parts.length=e.parts.length)}else{var a=[];for(o=0;o<e.parts.length;o++)a.push(m(e.parts[o]));i[e.id]={id:e.id,refs:1,parts:a}}}}function v(){var n=document.createElement("style");return n.type="text/css",a.appendChild(n),n}function m(n){var t,e,r=document.querySelector('style[data-vue-ssr-id~="'+n.id+'"]');if(r){if(l)return c;r.parentNode.removeChild(r)}if(f){var o=u++;r=s||(s=v()),t=b.bind(null,r,o,!1),e=b.bind(null,r,o,!0)}else r=v(),t=x.bind(null,r),e=function(){r.parentNode.removeChild(r)};return t(n),function(r){if(r){if(r.css===n.css&&r.media===n.media&&r.sourceMap===n.sourceMap)return;t(n=r)}else e()}}var y,g=(y=[],function(n,t){return y[n]=t,y.filter(Boolean).join("\n")});function b(n,t,e,r){var o=e?"":r.css;if(n.styleSheet)n.styleSheet.cssText=g(t,o);else{var i=document.createTextNode(o),a=n.childNodes;a[t]&&n.removeChild(a[t]),a.length?n.insertBefore(i,a[t]):n.appendChild(i)}}function x(n,t){var e=t.css,r=t.media,o=t.sourceMap;if(r&&n.setAttribute("media",r),d.ssrId&&n.setAttribute("data-vue-ssr-id",t.id),o&&(e+="\n/*# sourceURL="+o.sources[0]+" */",e+="\n/*# sourceMappingURL=data:application/json;base64,"+btoa(unescape(encodeURIComponent(JSON.stringify(o))))+" */"),n.styleSheet)n.styleSheet.cssText=e;else{for(;n.firstChild;)n.removeChild(n.firstChild);n.appendChild(document.createTextNode(e))}}}])})); //# sourceMappingURL=main.js.map