{"remainingRequest":"/data/jenkins/workspace/badp-bcxin-web-5.x-vue/node_modules/thread-loader/dist/cjs.js!/data/jenkins/workspace/badp-bcxin-web-5.x-vue/node_modules/babel-loader/lib/index.js!/data/jenkins/workspace/badp-bcxin-web-5.x-vue/node_modules/cache-loader/dist/cjs.js??ref--0-0!/data/jenkins/workspace/badp-bcxin-web-5.x-vue/node_modules/vue-loader/lib/index.js??vue-loader-options!/data/jenkins/workspace/badp-bcxin-web-5.x-vue/src/components/o_image_upload.vue?vue&type=script&lang=js&","dependencies":[{"path":"/data/jenkins/workspace/badp-bcxin-web-5.x-vue/src/components/o_image_upload.vue","mtime":1732857533163},{"path":"/data/jenkins/workspace/badp-bcxin-web-5.x-vue/babel.config.js","mtime":1725957645200},{"path":"/data/jenkins/workspace/badp-bcxin-web-5.x-vue/node_modules/cache-loader/dist/cjs.js","mtime":499162500000},{"path":"/data/jenkins/workspace/badp-bcxin-web-5.x-vue/node_modules/thread-loader/dist/cjs.js","mtime":499162500000},{"path":"/data/jenkins/workspace/badp-bcxin-web-5.x-vue/node_modules/babel-loader/lib/index.js","mtime":315532800000},{"path":"/data/jenkins/workspace/badp-bcxin-web-5.x-vue/node_modules/cache-loader/dist/cjs.js","mtime":499162500000},{"path":"/data/jenkins/workspace/badp-bcxin-web-5.x-vue/node_modules/vue-loader/lib/index.js","mtime":1655715099000}],"contextDependencies":[],"result":["import \"core-js/modules/es6.regexp.split\";\nimport \"core-js/modules/es6.function.name\";\nimport \"core-js/modules/web.dom.iterable\";\nimport \"core-js/modules/es6.regexp.replace\";\nimport Constant from \"@/Constant.js\";\nimport API from \"@/api.js\";\nimport form_operation from \"@/components/form_operation_log\";\nimport controlHidden from \"@/assets/js/controlHidden.js\";\nexport default {\n name: 'o-image-upload',\n props: [\"id\"],\n components: {\n form_operation: form_operation\n },\n computed: {\n field: function field() {\n var formData = this.$parent.findField(this.id);\n if (formData.displayType == 5 || formData.displayType == 3) {\n formData.printHiddenValue = formData.printHiddenValue ? formData.printHiddenValue.replace(/ /g, \"\") : '';\n }\n if (formData.value && typeof formData.value == 'string') {\n formData.value = JSON.parse(decodeURI(formData.value));\n }\n if (formData.value && formData.value instanceof Array) {\n if (formData.value.length == 0) {\n formData.value = \"\";\n } else {\n formData.value = formData.value;\n }\n formData.value = formData.value;\n } else {\n formData.value = '';\n }\n if (formData.value && formData.value.length > 0) {\n formData.pathLists = [];\n formData.value.forEach(function (el) {\n formData.pathLists.push(el.url);\n });\n }\n formData.origiUrl = window.location.origin;\n formData.picUrl = formData.value && formData.value[0].path.indexOf(\"http\") > -1 ? \"\" : obpmConfig.obpmFilePath; //obs图片路径兼容\t \n\n var accessToken = \"?accessToken=\" + localStorage.getItem(\"accessToken\");\n formData.accessToken = accessToken;\n return formData;\n },\n uploadHidden: function uploadHidden() {\n // 超出上传数量,上传+不显示\n var value = this.field.value;\n if (value && value.length > 0) {\n return !(value.length >= parseInt(this.field.limitNumber));\n } else {\n return true;\n }\n }\n },\n mounted: function mounted() {\n var _this = this;\n this.$nextTick(function () {\n //使用nextTick为了保证dom元素都已经渲染完毕 \n var field = _this.field;\n if (field.textType == \"hidden\" || field.displayType == Constant.PermissionType_HIDDEN) {\n if (field.isHideType) {\n var id = _this.id,\n formShowType = field.formShowType;\n controlHidden({\n id: id,\n field: field,\n formShowType: formShowType\n });\n }\n }\n if (field.imgh) {\n var dom = document.getElementById(field.id).getElementsByClassName(\"el-upload\");\n if (dom[0]) {\n dom[0].style.width = parseInt(field.imgw) + \"px\";\n dom[0].style.height = parseInt(field.imgh) + \"px\";\n dom[0].style.lineHeight = parseInt(field.imgh) + \"px\";\n }\n // document.getElementById(field.id).getElementsByClassName(\"el-upload\")[0].style.width = parseInt(field.imgw) +\"px\";\n // document.getElementById(field.id).getElementsByClassName(\"el-upload\")[0].style.height = parseInt(field.imgh)+\"px\";\n // document.getElementById(field.id).getElementsByClassName(\"el-upload\")[0].style.lineHeight = parseInt(field.imgh) +\"px\";\n // document.getElementById(this.field.id).getElementsByClassName(\"el-upload-list__item\")[0].style.width = parseInt(this.field.imgw) +\"px\";\n // document.getElementById(this.field.id).getElementsByClassName(\"el-upload-list__item\")[0].style.height = parseInt(this.field.imgh) +\"px\";\n }\n });\n },\n data: function data() {\n return {\n Constant: Constant,\n dialogImageUrl: '',\n dialogVisible: false,\n imageType: '',\n fileArray: [],\n uploadArray: [],\n isActive: -1,\n isShow: false,\n showLogsDialog: false,\n showLogsIcon: true,\n operationData: '',\n allfileArray: [],\n imgDetails: {\n scaleNum: 1,\n zoom: ''\n },\n initialIndex: 1,\n hiddenDialog: false\n };\n },\n methods: {\n getBase64Image: function getBase64Image(origiUrl, url, picUrl, path, index) {\n var field = this.field;\n var imgUrl;\n if (url) {\n imgUrl = origiUrl + url;\n } else {\n imgUrl = origiUrl + picUrl + path;\n }\n var image = new Image();\n image.src = imgUrl;\n var base64;\n var that = this;\n image.onload = function () {\n base64 = that.transformBase64Image(image);\n field.value[index].base64 = base64;\n that.$forceUpdate();\n };\n return imgUrl;\n },\n transformBase64Image: function transformBase64Image(img) {\n var field = this.field;\n var canvas = document.createElement(\"canvas\");\n canvas.width = field.imgw;\n canvas.height = field.imgh;\n var ctx = canvas.getContext(\"2d\");\n ctx.drawImage(img, 0, 0, field.imgw, field.imgh);\n var ext = img.src.substring(img.src.lastIndexOf(\".\") + 1).toLowerCase();\n var dataURL = canvas.toDataURL(\"image/\" + ext);\n return dataURL;\n },\n // 缩放图片\n rollImg: function rollImg() {\n /* 获取当前页面的缩放比 若未设置zoom缩放比,则为默认100%,即1,原图大小 */\n var zoom = parseInt(this.zoom) || 100;\n /* event.wheelDelta 获取滚轮滚动值并将滚动值叠加给缩放比zoom wheelDelta统一为±120,其中正数表示为向上滚动,负数表示向下滚动 */\n zoom += event.wheelDelta / 12;\n /* 最小范围 和 最大范围 的图片缩放尺度 */\n if (zoom >= 5 && zoom < 500) {\n this.imgDetails.zoom = zoom + \"%\";\n var zoomNum = zoom / 100;\n this.imgDetails.scaleNum = zoomNum;\n }\n return false;\n },\n hiddenLogsDialog: function hiddenLogsDialog() {\n this.showLogsIcon = false;\n this.showLogsDialog = false;\n },\n enter: function enter() {\n if (this.field.isModified) {\n this.showLogsIcon = true;\n }\n },\n getOperationLogs: function getOperationLogs() {\n var obj = {};\n obj.fieldName = this.field.name;\n this.operationData = obj;\n this.showLogsDialog = true;\n },\n changeActive: function changeActive(index) {\n this.isActive = index;\n this.isShow = true;\n },\n removeActive: function removeActive() {\n this.isActive = -1;\n },\n uploadSuccess: function uploadSuccess(response, file, fileList) {\n var obj = {\n name: response.data[0].fileName,\n path: response.data[0].filePath,\n url: obpmConfig.obpmFilePath + \"/\" + response.data[0].filePath\n };\n this.field.value.push(obj);\n },\n uploadImg: function uploadImg(e) {\n var _this2 = this;\n //obs文件上传start\n if (__network__) {\n this.obsFile(e); //obs文件上传\n return;\n }\n var fileArray = e.file;\n var file = fileArray;\n var that = this;\n var form = new FormData();\n form.append(\"files\", file);\n form.forEach(function (value, key) {\n if (value instanceof File) {\n form.set(key, value, value.name.replace(/ /g, '')); //去掉文件名称所有空格\n }\n });\n\n //form.append(\"***\");//根据上传入参添加参数\n //let result = await this.post(\"/file/upload-file\", form);\n var files = form;\n var actionType = this.imageType;\n var appId = this.$root.appid;\n var allowedTypes = this.field.fileType;\n var fieldId = this.id;\n var fileSaveMode = this.field.fileSaveMode;\n var path = this.field.path;\n this.$api.uploadFile(files, appId, allowedTypes, fieldId, fileSaveMode, path, actionType, {\n onSucess: function onSucess(response) {\n for (var i = 0; i < _this2.allfileArray.length; i++) {\n if (e.file.uid === _this2.allfileArray[i].uid) {\n _this2.allfileArray.splice(i, 1);\n i--;\n }\n }\n that.picUrl = obpmConfig.obpmFilePath + \"/\";\n var obj = {\n name: response.data.data[0].fileName,\n path: response.data.data[0].filePath,\n url: obpmConfig.obpmFilePath + \"/\" + response.data.data[0].filePath\n };\n that.fileArray.push(obj);\n // that.field.value = that.fileArray;\n if (that.field.value && that.field.value instanceof Array) {\n that.field.value = that.fileArray.concat(that.field.value);\n } else {\n that.field.value = that.fileArray;\n }\n that.fileArray = [];\n if (that.field.refreshOnChanged) {\n that.$parent.refresh(that.id);\n }\n }\n }, function (res) {\n for (var i = 0; i < _this2.allfileArray.length; i++) {\n if (res.uid === _this2.allfileArray[i].uid) {\n _this2.allfileArray[i].marks = res.num;\n _this2.allfileArray[i].marksValue = res.complete;\n _this2.$forceUpdate();\n }\n }\n }, e.file.uid);\n },\n opendialog: function opendialog(item, index) {\n var _this3 = this;\n this.$confirm(this.$t('msg.forever_del'), this.$t('msg.tip'), {\n confirmButtonText: this.$t('btns.sure'),\n cancelButtonText: this.$t('btns.cancel'),\n type: 'warning'\n }).then(function () {\n _this3.$message({\n type: 'success',\n message: _this3.$t('msg.del_ss')\n });\n _this3.handleRemove(item, index);\n }).catch(function () {\n _this3.$message({\n type: 'info',\n message: _this3.$t('msg.cancel_del')\n });\n });\n },\n handleRemove: function handleRemove(file, fileList) {\n var _this4 = this;\n var appId = this.$root.appid;\n var formId = this.field.formId;\n var docId = this.field.docId;\n var path = file.path;\n API.deleteUpload(appId, formId, docId, path, {\n onSucess: function onSucess(res) {\n if (res.data.errcode == 0) {\n var arr = _this4.field.value;\n for (var i = 0; i < arr.length; i++) {\n if (file.path == arr[i].path) {\n arr.splice(i, 1);\n }\n }\n }\n if (_this4.field.refreshOnChanged) {\n // this.$parent.refresh(this.field.id);\n var havePar = false;\n var par = '';\n while (!havePar) {\n par = par + '.$parent';\n var url = 'this' + par + '.refresh';\n if (eval(url)) {\n var _path = url + '(' + \"'\" + _this4.id + \"'\" + ')';\n eval(_path);\n break;\n }\n }\n }\n }\n });\n },\n handlePictureCardPreview: function handlePictureCardPreview(item, index, fieldvalue) {\n var _this5 = this;\n //图片预览\n // console.log(fieldvalue)\n // let path=item.path&&item.path.indexOf('http')>-1?item.path:item.path.indexOf('/obpm')>-1?item.path:'/obpm'+item.path\n // console.log(item.path)\n var imagesArr = [];\n var http = location.origin;\n if (fieldvalue.length) {\n fieldvalue.forEach(function (its) {\n var path = its.path && its.path.indexOf('http') > -1 ? its.path : its.path.indexOf('/obpm') > -1 ? http + its.path : http + '/obpm' + its.path;\n imagesArr.push(path);\n });\n }\n this.$nextTick(function () {\n _this5.$viewerApi({\n options: {\n initialViewIndex: index\n },\n //增加这行可以选中当前对应的图片预览\n images: imagesArr\n });\n });\n // this.initialIndex = index\n // this.hiddenDialog = true\n\n // let picUrl = obpmConfig.obpmFilePath;\n // this.dialogImageUrl = picUrl + file.path;\n // this.dialogVisible = true;\n },\n handlePictureCardPreviewT: function handlePictureCardPreviewT(index) {\n //图片预览\n // let path=item.path&&item.path.indexOf('http')>-1?item.path:'/obpm'+item.path\n // console.log(item.path)\n // this.$nextTick(()=>{\n // this.$viewerApi({\n // \timages: [path],\t\t\t\t\n // })\n // })\n this.initialIndex = index;\n this.hiddenDialog = true;\n\n // let picUrl = obpmConfig.obpmFilePath;\n // this.dialogImageUrl = picUrl + file.path;\n // this.dialogVisible = true;\n },\n handleExceed: function handleExceed(files, fileList) {\n this.$message.warning(this.$t('view.out'));\n },\n beforeAvatarUpload: function beforeAvatarUpload(file) {\n var _this6 = this;\n this.imageType = file.type;\n var isJPG = file.type === 'image/jpeg' || 'image/png' || 'image/gif' || 'image/jpg' || 'image/JPG' || 'image/JPEG' || 'image/GIF' || 'image/PNG';\n var temp = file.name.split(\".\");\n var name = temp[temp.length - 1];\n var arr = ['', 'jpeg', 'png', 'gif', 'jpg', 'JPG', 'JPEG', 'PNG', 'GIF'];\n var isSuffix = arr.indexOf(name) > 0;\n var isLt2M = file.size / 1024 < this.field.maxsize;\n if (!isJPG || !isSuffix) {\n this.$message.error(this.$t('view.pic_err'));\n return false;\n }\n if (!isLt2M) {\n this.$message.error(this.$t('view.data_out'));\n return false;\n }\n if (__network__) {\n //obs文件上传不走下面代码\n return;\n }\n if (isJPG) {\n var reader = new FileReader();\n // readAsDataURL:读取为base64格式\n reader.readAsDataURL(file);\n // onload 在文件读取成功时触发\n reader.onload = function () {\n var ImgBase64 = reader.result;\n var ob = {};\n ob.uid = file.uid;\n ob.name = file.name;\n ob.marks = 0;\n ob.marksValue = '0%';\n ob.path = ImgBase64;\n _this6.allfileArray.push(ob);\n };\n }\n return isJPG && isLt2M && isSuffix;\n },\n obsFile: function obsFile(e) {\n //obs文件上传\n\n //去掉文件名称空格start\n var form = new FormData();\n form.append(\"files\", e.file);\n form.forEach(function (value, key) {\n if (value instanceof File) {\n form.set(key, value, value.name.replace(/ /g, '')); //去掉文件名称所有空格\n }\n });\n form.get('files');\n e.file = form.get('files');\n //去掉文件名称空格end\n\n var that = this;\n var domainId = localStorage.getItem(\"domainId\") || \"default\"; //保存本地企业id\n // var objectKey=\"uploads/\"+domainId+\"/\"+new Date().getFullYear()+\"/\"+new Date().getTime()+e.file.name\n // https://bcxin-v5-prod.obs.cn-north-1.myhuaweicloud.com/uploads/2022/06-20/公司id/uuid/文件名.xls\t\t\n var now = new Date();\n var y = now.getFullYear();\n var m = now.getMonth() + 1 < 10 ? '0' + (now.getMonth() + 1) : now.getMonth() + 1;\n var d = now.getDate() < 10 ? '0' + now.getDate() : now.getDate();\n var md = m + '-' + d;\n var objectKey = \"uploads/\".concat(y, \"/\").concat(md, \"/\").concat(domainId, \"/\").concat(now.getTime(), \"/\").concat(e.file.name);\n var obs = new ObsClient({\n access_key_id: ak,\n secret_access_key: sk,\n server: urlserver,\n timeout: 60 * 5\n });\n obs.putObject({\n Bucket: BucketName,\n Key: objectKey,\n SourceFile: e.file //获取file文件\n }).then(function (result) {\n if (result.CommonMsg.Status < 300) {\n var httpurl = \"https://\".concat(BucketName, \".\").concat(urlserver, \"/\").concat(objectKey);\n httpurl = convertCdnPath(httpurl);\n\n // let ob = {};\n // ob.uid = e.file.uid;\n // ob.name = e.file.name\n // ob.marks = 100;\n // ob.marksValue = '100%';\n // that.allfileArray.push(ob);\n\n var uploadTime = '';\n var date = new Date();\n var Y = date.getFullYear() + '-';\n var M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';\n var D = (date.getDate() < 10 ? '0' + date.getDate() : date.getDate()) + ' ';\n var h = (date.getHours() < 10 ? '0' + date.getHours() : date.getHours()) + ':';\n var _m = (date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes()) + ':';\n var s = date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds();\n uploadTime = Y + M + D + h + _m + s;\n that.picUrl = obpmConfig.obpmFilePath + \"/\";\n var obj = {\n name: e.file.name,\n path: httpurl,\n url: httpurl,\n fileType: \"\",\n uploader: sessionStorage.getItem(\"myProfileName\") || '',\n uploadTime: uploadTime,\n userName: sessionStorage.getItem(\"myProfileName\") || '',\n time: uploadTime,\n size: e.file.size\n };\n that.fileArray.push(obj);\n if (that.field.value && that.field.value instanceof Array) {\n that.field.value = that.fileArray.concat(that.field.value);\n } else {\n that.field.value = that.fileArray;\n }\n that.fileArray = [];\n if (that.field.refreshOnChanged) {\n that.$parent.refresh(that.id);\n }\n if (that.field.instantValidate) {\n this.evenCheck();\n }\n // var pushstring=`${e.file.name},${httpurl},${e.file.size}`\n // if(values.indexOf(pushstring)===-1){\n // \tvalues.push(pushstring)\n // \tflag++\n // \tconsole.log(\"上传几个:\"+flag)\n // \t\tif(fileCount===flag){\n // \t\t\tconsole.log(\"已上传成功\")\n // \t\t\t$info.html(\"已上传成功\");\n // \t\t\t$('.state-ok').show();\n // \t\t}\n\n // }\n // console.log(values)\n }\n });\n }\n }\n};",null]}