{"remainingRequest":"D:\\jenkins\\workspace\\xypm-web-prod\\node_modules\\thread-loader\\dist\\cjs.js!D:\\jenkins\\workspace\\xypm-web-prod\\node_modules\\babel-loader\\lib\\index.js!D:\\jenkins\\workspace\\xypm-web-prod\\node_modules\\cache-loader\\dist\\cjs.js??ref--0-0!D:\\jenkins\\workspace\\xypm-web-prod\\node_modules\\vue-loader\\lib\\index.js??vue-loader-options!D:\\jenkins\\workspace\\xypm-web-prod\\src\\components\\upload\\fileUpload.vue?vue&type=script&lang=js&","dependencies":[{"path":"D:\\jenkins\\workspace\\xypm-web-prod\\src\\components\\upload\\fileUpload.vue","mtime":1667333350884},{"path":"D:\\jenkins\\workspace\\xypm-web-prod\\babel.config.js","mtime":1667333346259},{"path":"D:\\jenkins\\workspace\\xypm-web-prod\\node_modules\\cache-loader\\dist\\cjs.js","mtime":499162500000},{"path":"D:\\jenkins\\workspace\\xypm-web-prod\\node_modules\\thread-loader\\dist\\cjs.js","mtime":499162500000},{"path":"D:\\jenkins\\workspace\\xypm-web-prod\\node_modules\\babel-loader\\lib\\index.js","mtime":456789000000},{"path":"D:\\jenkins\\workspace\\xypm-web-prod\\node_modules\\cache-loader\\dist\\cjs.js","mtime":499162500000},{"path":"D:\\jenkins\\workspace\\xypm-web-prod\\node_modules\\vue-loader\\lib\\index.js","mtime":499162500000}],"contextDependencies":[],"result":["import \"core-js/modules/es7.object.get-own-property-descriptors\";\nimport \"core-js/modules/web.dom.iterable\";\nimport \"core-js/modules/es6.object.keys\";\nimport \"core-js/modules/es6.function.name\";\nimport \"core-js/modules/es6.regexp.to-string\";\nimport _defineProperty from \"D:/jenkins/workspace/xypm-web-prod/node_modules/@babel/runtime/helpers/esm/defineProperty.js\";\nfunction ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }\nfunction _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n\n/**\r\n * 全局上传插件\r\n * 调用方法:this.$bus.$emit('openUploader', {}) 打开文件选择框,参数为需要传递的额外参数\r\n * 监听函数:this.$bus.$on('fileAdded', fn); 文件选择后的回调\r\n * this.$bus.$on('fileSuccess', fn); 文件上传成功的回调\r\n */\nimport { ACCEPT_CONFIG } from \"./js/config\";\nimport Bus from \"./js/bus.js\";\nimport SparkMD5 from 'spark-md5';\n// // 这两个是我自己项目中用的,请忽略\n// import {Ticket} from '@/assets/js/utils';\n// import api from '@/api';\nexport default {\n data: function data() {\n return {\n options: {\n target: window.context.cqxy + '/biz/universal/accessory/v1/ShardUpload',\n // /biz/universal/accessory/v1/minioUpload\n // /biz/universal/accessory/v1/ShardUpload\n chunkSize: '2048000',\n fileParameterName: 'file',\n maxChunkRetries: 3,\n testChunks: true,\n //是否开启服务器分片校验\n // 服务器分片校验函数,秒传及断点续传基础\n checkChunkUploadedByResponse: function checkChunkUploadedByResponse(chunk, message) {\n if (message) {\n var objMessage = JSON.parse(message);\n if (objMessage.skipUpload) {\n return true;\n }\n return (objMessage.uploaded || []).indexOf(chunk.offset + 1) >= 0;\n }\n },\n headers: {\n Authorization: ''\n },\n 'Content-Type': 'multipart/form-data; boundary=----WebKitFormBoundaryKIEIaJFJwN7T1GQQ',\n query: function query(file, chunk) {\n return _objectSpread({}, file.params);\n }\n },\n attrs: {\n accept: ACCEPT_CONFIG.getAll()\n },\n panelShow: false,\n //选择文件后,展示上传panel\n collapse_: false,\n params: {},\n isDrag: false\n };\n },\n mounted: function mounted() {\n var _this = this;\n this.getToken();\n this.$bus.$on('openUploader', function (query) {\n _this.key_ = query;\n Object.prototype.toString.call(query) == '[object String]' ? '' : query;\n _this.params = query || {};\n if (_this.$refs.uploadBtn) {\n $('#global-uploader-btn').click();\n }\n });\n this.$bus.$on('openUploader2', function (query) {\n _this.isDrag = true;\n _this.key_ = query;\n Object.prototype.toString.call(query) == '[object String]' ? '' : query;\n _this.params = query || {};\n });\n },\n computed: {\n //Uploader实例\n uploader: function uploader() {\n return this.$refs.uploader.uploader;\n }\n },\n created: function created() {},\n methods: {\n handleCloseDrag: function handleCloseDrag() {\n this.isDrag = false;\n },\n handleUpload: function handleUpload() {\n this.$bus.$emit('openUploader');\n },\n getToken: function getToken() {\n if (window.sessionStorage.getItem('currentUser')) {\n var token = JSON.parse(window.sessionStorage.getItem('currentUser')).token;\n this.options.headers.Authorization = 'Bearer ' + token;\n } else {\n this.options.headers.Authorization = '';\n }\n },\n onFileAdded: function onFileAdded(file) {\n this.panelShow = true;\n this.computeMD5(file);\n // 2022/1/10 将额外的参数赋值到每个文件上,解决了不同文件使用不同params的需求\n file.params = this.params;\n this.$bus.$emit('fileAdded');\n },\n onFileProgress: function onFileProgress(rootFile, file, chunk) {\n console.log(rootFile, file, chunk);\n console.log(\"\\u4E0A\\u4F20\\u4E2D \".concat(file.name, \"\\uFF0Cchunk\\uFF1A\").concat(chunk.startByte / 1024 / 1024, \" ~ \").concat(chunk.endByte / 1024 / 1024));\n },\n onFileSuccess: function onFileSuccess(rootFile, file, response, chunk) {\n var _this2 = this;\n console.log(file, response, 'file');\n var res = JSON.parse(response);\n console.log(res, '上传返回数据');\n // 服务器自定义的错误(即虽返回200,但是是错误的情况),这种错误是Uploader无法拦截的\n if (!res.state) {\n this.$message({\n message: res.message,\n type: 'error'\n });\n // 文件状态设为“失败”\n this.statusSet(file.id, 'failed');\n return;\n }\n console.log('上传成功');\n //上传成功之后发起请求合并\n var bizPath = '';\n var fileName = encodeURIComponent(file.name); //解码decodeURIComponent()\n console.log(file, '文件分片');\n this.$http.post('${cqxy}/biz/universal/accessory/v1/mergeFileToMinIO?bizPath=' + bizPath + '&fileName=' + fileName).then(function (res) {\n res.data.value.key_ = _this2.key_;\n //传递文件实际大小\n res.data.value.fileSizeB = file.size;\n _this2.$bus.$emit('fileSuccess', res.data.value);\n console.log(res.data.value, '合并返回数据');\n });\n // // 如果服务端返回需要合并\n // if (res.needMerge) {\n // // 文件状态设为“合并中”\n // this.statusSet(file.id, 'merging')\n // // api.mergeSimpleUpload({\n // // tempName: res.tempName,\n // // fileName: file.name,\n // // ...file.params,\n // // }).then(res => {\n // // // 文件合并成功\n // // this.$bus.$emit('fileSuccess');\n // // this.statusRemove(file.id);\n // // }).catch(e => {});\n // // 不需要合并\n // } else {\n // this.$bus.$emit('fileSuccess')\n // console.log('上传成功')\n // }\n },\n onFileError: function onFileError(rootFile, file, response, chunk) {\n this.$message({\n message: response,\n type: 'error'\n });\n },\n /**\r\n * 计算md5,实现断点续传及秒传\r\n * @param file\r\n */\n computeMD5: function computeMD5(file) {\n var _this3 = this;\n var fileReader = new FileReader();\n var time = new Date().getTime();\n var blobSlice = File.prototype.slice || File.prototype.mozSlice || File.prototype.webkitSlice;\n var currentChunk = 0;\n var chunkSize = 10 * 1024 * 1000 * 4;\n var chunks = Math.ceil(file.size / chunkSize);\n var spark = new SparkMD5.ArrayBuffer();\n // 文件状态设为\"计算MD5\"\n this.statusSet(file.id, 'md5');\n file.pause();\n loadNext();\n fileReader.onload = function (e) {\n spark.append(e.target.result);\n if (currentChunk < chunks) {\n currentChunk++;\n loadNext();\n // 实时展示MD5的计算进度\n _this3.$nextTick(function () {\n $(\".myStatus_\".concat(file.id)).text('校验MD5 ' + (currentChunk / chunks * 100).toFixed(0) + '%');\n });\n } else {\n var md5 = spark.end();\n _this3.computeMD5Success(md5, file);\n console.log(\"MD5\\u8BA1\\u7B97\\u5B8C\\u6BD5\\uFF1A\".concat(file.name, \" \\nMD5\\uFF1A\").concat(md5, \" \\n\\u5206\\u7247\\uFF1A\").concat(chunks, \" \\u5927\\u5C0F:\").concat(file.size, \" \\u7528\\u65F6\\uFF1A\").concat(new Date().getTime() - time, \" ms\"));\n }\n };\n fileReader.onerror = function () {\n this.error(\"\\u6587\\u4EF6\".concat(file.name, \"\\u8BFB\\u53D6\\u51FA\\u9519\\uFF0C\\u8BF7\\u68C0\\u67E5\\u8BE5\\u6587\\u4EF6\"));\n file.cancel();\n };\n function loadNext() {\n var start = currentChunk * chunkSize;\n var end = start + chunkSize >= file.size ? file.size : start + chunkSize;\n fileReader.readAsArrayBuffer(blobSlice.call(file.file, start, end));\n }\n },\n computeMD5Success: function computeMD5Success(md5, file) {\n file.uniqueIdentifier = md5;\n file.resume();\n this.statusRemove(file.id);\n },\n fileListShow: function fileListShow() {\n var $list = $('#global-uploader .file-list');\n if ($list.is(':visible')) {\n $list.slideUp();\n this.collapse_ = true;\n } else {\n $list.slideDown();\n this.collapse_ = false;\n }\n },\n close: function close() {\n this.uploader.cancel();\n this.panelShow = false;\n },\n /**\r\n * 新增的自定义的状态: 'md5'、'transcoding'、'failed'\r\n * @param id\r\n * @param status\r\n */\n statusSet: function statusSet(id, status) {\n var statusMap = {\n md5: {\n text: '校验MD5',\n bgc: '#fff'\n },\n merging: {\n text: '合并中',\n bgc: '#e2eeff'\n },\n transcoding: {\n text: '转码中',\n bgc: '#e2eeff'\n },\n failed: {\n text: '上传失败',\n bgc: '#e2eeff'\n }\n };\n this.$nextTick(function () {\n $(\"

\")).appendTo(\".file_\".concat(id, \" .uploader-file-status\")).css({\n position: 'absolute',\n top: '0',\n left: '0',\n right: '0',\n bottom: '0',\n zIndex: '1',\n backgroundColor: statusMap[status].bgc\n }).text(statusMap[status].text);\n });\n },\n statusRemove: function statusRemove(id) {\n this.$nextTick(function () {\n $(\".myStatus_\".concat(id)).remove();\n });\n },\n error: function error(msg) {\n this.$notify({\n title: '错误',\n message: msg,\n type: 'error',\n duration: 2000\n });\n }\n },\n watch: {},\n destroyed: function destroyed() {\n this.$bus.$off('openUploader');\n },\n components: {}\n};",null]}