{"remainingRequest":"/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/node_modules/babel-loader/lib/index.js","mtime":456789000000},{"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":499162500000}],"contextDependencies":[],"result":["\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\tname: 'o-image-upload',\n\tprops: [\"id\"],\n\tcomponents: {\n form_operation,\n },\n\tcomputed: {\n\t\tfield: function() {\n\t\t\tlet 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\t\t\tif(formData.value && typeof formData.value == 'string') {\n formData.value = JSON.parse(decodeURI(formData.value));\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\t\t\t}\n\n\t\t\tconsole.log(\"formData.value-->\",formData.value)\n\n\n\t\t\tif(formData.value && formData.value.length > 0) {\n\t\t\t\tformData.pathLists = []\n\t\t\t\tformData.value.forEach(el => {\n\t\t\t\t\tformData.pathLists.push(el.url)\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tformData.origiUrl = window.location.origin;\n\n\t formData.picUrl = formData.value&&formData.value[0].path.indexOf(\"http\")>-1?\"\":obpmConfig.obpmFilePath;//obs图片路径兼容\t \n\n\t\t\tlet accessToken = \"?accessToken=\" + localStorage.getItem(\"accessToken\");\n\t\t\tformData.accessToken = accessToken\n\t\t\treturn formData\n\t\t},\n\t\tuploadHidden: function() {\n\t\t\t// 超出上传数量,上传+不显示\n\t\t\tlet value = this.field.value\n\t\t\tif(value && value.length > 0) {\n\t\t\t\treturn !(value.length >= parseInt(this.field.limitNumber))\n\t\t\t}else {\n\t\t\t\treturn true\n\t\t\t}\n\t\t},\n\t},\n\tmounted() {\n\t\tthis.$nextTick(() => { //使用nextTick为了保证dom元素都已经渲染完毕 \n\t\t\tlet field = this.field;\n\t\t\tif(field.textType == \"hidden\" || field.displayType == Constant.PermissionType_HIDDEN){\n\t\t\t\tif(field.isHideType) {\n\t\t\t\t\tlet id = this.id,\n\t\t\t\t\t\tformShowType = field.formShowType;\n\t\t\t\t\tcontrolHidden({id, field, formShowType})\n\t\t\t\t}\n\t\t\t}\n\t\t\tif(field.imgh) {\n\t\t\t\tlet dom = document.getElementById(field.id).getElementsByClassName(\"el-upload\")\n\t\t\t\tif(dom[0]) {\n\t\t\t\t\tdom[0].style.width = parseInt(field.imgw) +\"px\";\n\t\t\t\t\tdom[0].style.height = parseInt(field.imgh)+\"px\";\n\t\t\t\t\tdom[0].style.lineHeight = parseInt(field.imgh) +\"px\";\n\t\t\t\t}\n\t\t\t\t// document.getElementById(field.id).getElementsByClassName(\"el-upload\")[0].style.width = parseInt(field.imgw) +\"px\";\n\t\t\t\t// document.getElementById(field.id).getElementsByClassName(\"el-upload\")[0].style.height = parseInt(field.imgh)+\"px\";\n\t\t\t\t// document.getElementById(field.id).getElementsByClassName(\"el-upload\")[0].style.lineHeight = parseInt(field.imgh) +\"px\";\n\t\t\t\t// document.getElementById(this.field.id).getElementsByClassName(\"el-upload-list__item\")[0].style.width = parseInt(this.field.imgw) +\"px\";\n\t\t\t\t// document.getElementById(this.field.id).getElementsByClassName(\"el-upload-list__item\")[0].style.height = parseInt(this.field.imgh) +\"px\";\n\t\t\t}\n\t\t});\n\t},\n\n\tdata: function() {\n\t\treturn {\n\t\t\tConstant,\n\t\t\tdialogImageUrl: '',\n\t\t\tdialogVisible: false,\n\t\t\timageType:'',\n\t\t\tfileArray:[],\n\t\t\tuploadArray:[],\n\t\t\tisActive:-1,\n\t\t\tisShow: false,\n\t\t\tshowLogsDialog: false,\n showLogsIcon:true,\n\t\t\toperationData:'',\n\t\t\tallfileArray:[],\n\t\t\timgDetails: {\n\t\t\t\tscaleNum:1,\n \tzoom:'',\n\t\t\t},\n\t\t\tinitialIndex: 1,\n\t\t\thiddenDialog: false,\n\t\t};\n\t},\n\t\n\tmethods: {\n\t\tgetBase64Image(origiUrl, url, picUrl, path, index) {\n\t\t\tlet field = this.field\n\t\t\tlet imgUrl\n\t\t\tif(url) {\n\t\t\t\timgUrl = origiUrl + url\n\t\t\t}else {\n\t\t\t\timgUrl = origiUrl + picUrl + path\n\t\t\t}\n\t\t\tlet image = new Image(); \n\t\t\timage.src = imgUrl; \n\t\t\tlet base64;\n\t\t\tlet that = this\n\t\t\timage.onload=function(){\n\t\t\t\tbase64 = that.transformBase64Image(image)\n\t\t\t\tfield.value[index].base64 = base64\n\t\t\t\tthat.$forceUpdate()\n\t\t\t}\n\t\t\treturn imgUrl\t\t\t\t\n\t\t},\n\n\t\ttransformBase64Image(img) {\n\t\t\tlet field = this.field\n\t\t\tlet canvas = document.createElement(\"canvas\"); \n\t\t\tcanvas.width = field.imgw; \n\t\t\tcanvas.height = field.imgh; \n\t\t\tlet ctx = canvas.getContext(\"2d\"); \n\t\t\tctx.drawImage(img, 0, 0, field.imgw, field.imgh); \n\t\t\tlet ext = img.src.substring(img.src.lastIndexOf(\".\")+1).toLowerCase(); \n\t\t\tlet dataURL = canvas.toDataURL(\"image/\"+ext); \n\t\t\treturn dataURL; \n\t\t},\n\n\t\t// 缩放图片\n rollImg() { \n /* 获取当前页面的缩放比 若未设置zoom缩放比,则为默认100%,即1,原图大小 */ \n let 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 let zoomNum = zoom/100;\n this.imgDetails.scaleNum = zoomNum;\n }\n return false; \n },\n\n\t\thiddenLogsDialog() {\n this.showLogsIcon = false;\n this.showLogsDialog = false;\n },\n\n enter(){\n if(this.field.isModified) {\n this.showLogsIcon = true;\n }\n },\n\n getOperationLogs() {\n let obj = {};\n obj.fieldName = this.field.name;\n this.operationData = obj;\n this.showLogsDialog = true;\n },\n\n\t\tchangeActive(index) {\n\t\t\tthis.isActive = index;\n\t\t\tthis.isShow = true;\n\t\t},\n\n\t\tremoveActive() {\n\t\t\tthis.isActive = -1;\n\t\t},\n\n\t\tuploadSuccess(response, file, fileList) {\n\t\t\tconsole.log(file);\n\t\t\tconsole.log(fileList);\n\t\t\tlet obj = {\n\t\t\t\t\tname: response.data[0].fileName,\n\t\t\t\t\tpath: response.data[0].filePath,\n\t\t\t\t\turl: obpmConfig.obpmFilePath + \"/\" + response.data[0].filePath,\n\t\t\t\t};\n\t\t\tthis.field.value.push(obj);\n\t\t},\n\n\t\tuploadImg(e){\n //obs文件上传start\n if(__network__){\n this.obsFile(e)//obs文件上传\n\t\t\t return\n\t\t }\n\n\t\t\tlet fileArray = e.file;\n\t\t\tlet file = fileArray;\n\t\t\tlet that = this;\n\t\t\tlet form = new FormData();\n\t\t\tform.append(\"files\", file);\n\n\t\t\tform.forEach(function (value, key) {\n\t\t\t\tif (value instanceof File) {\n\t\t\t\t\tform.set(key, value, value.name.replace(/ /g, ''))//去掉文件名称所有空格\n\t\t\t\t}\n\t\t\t})\n\n\t\t\t//form.append(\"***\");//根据上传入参添加参数\n\t\t\t//let result = await this.post(\"/file/upload-file\", form);\n\t\t\tlet files = form;\n\t\t\tlet actionType = this.imageType;\n\t\t\tlet appId = this.$root.appid;\n\t\t\tlet allowedTypes = this.field.fileType;\n\t\t\tlet fieldId = this.id;\n\t\t\tlet fileSaveMode = this.field.fileSaveMode;\n\t\t\tlet path = this.field.path;\n\t\t\tthis.$api.uploadFile(\n\t\t\t\tfiles, \n\t\t\t\tappId, \n\t\t\t\tallowedTypes, \n\t\t\t\tfieldId, \n\t\t\t\tfileSaveMode, \n\t\t\t\tpath, \n\t\t\t\tactionType,\n\t\t\t\t{\n\t\t\t\t\tonSucess: response => {\n\t\t\t\t\t\tfor(let i=0; i{\n\t\t\t\t\tfor(let i=0; i {\n\t\t\t\tthis.$message({\n\t\t\t\t\ttype: 'success',\n\t\t\t\t\tmessage:this.$t('msg.del_ss')\n\t\t\t\t});\n\t\t\t\tthis.handleRemove(item,index);\n\t\t\t}).catch(() => {\n\t\t\t\tthis.$message({\n\t\t\t\t\ttype: 'info',\n\t\t\t\t\tmessage: this.$t('msg.cancel_del')\n\t\t\t\t}); \n\t\t\t});\n\t\t},\n\t\t\n\t\thandleRemove(file, fileList) {\n\t\t\tconsole.log(\"file--->\",file);\n\t\t\tconsole.log(fileList);\n\t\t\tlet appId = this.$root.appid;\n let formId = this.field.formId;\n let docId = this.field.docId;\n let path = file.path;\n API.deleteUpload(appId, formId, docId, path, {\n onSucess: (res) => {\n\t\t\t\t\tif(res.data.errcode == 0) {\n\t\t\t\t\t\tlet arr = this.field.value;\n\t\t\t\t\t\tfor(let i=0; i\",this.field.value);\n\t\t\t\t\t}\n if (this.field.refreshOnChanged){\n // this.$parent.refresh(this.field.id);\n\t\t\t\t\t\tlet havePar = false;\n\t\t\t\t\t\tlet par = '';\n\t\t\t\t\t\twhile(!havePar) {\n\t\t\t\t\t\t\tpar = par + '.$parent';\n\t\t\t\t\t\t\tlet url = 'this' + par + '.refresh';\n\t\t\t\t\t\t\tif(eval(url)) {\n\t\t\t\t\t\t\t\tlet path = url + '(' + \"'\"+ this.id +\"'\" + ')';\n\t\t\t\t\t\t\t\teval(path);\n\t\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n }\n }\n });\n\t\t},\n\n\t\thandlePictureCardPreview(item,index,fieldvalue) {//图片预览\n\t\t\t// console.log(fieldvalue)\n\t\t\t// 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\t\t\tlet imagesArr=[]\n\t\t\tlet http=location.origin\n\t\t\tif(fieldvalue.length){\n\t\t\t\tfieldvalue.forEach(its=>{\n\t\t\t\t\tlet path=its.path&&its.path.indexOf('http')>-1?its.path:its.path.indexOf('/obpm')>-1?http+its.path:http+'/obpm'+its.path\n\t\t\t\t\timagesArr.push(path)\n\t\t\t\t})\n\t\t\t}\t\t\t \n\t\t\tthis.$nextTick(()=>{\n\t\t\t\t\tthis.$viewerApi({\n\t\t\t\t\t\toptions: {initialViewIndex: index},//增加这行可以选中当前对应的图片预览\n\t\t\t\t\t\timages: imagesArr,\t\t\t\t\n\t\t\t\t\t})\n\t\t\t})\n\t\t\t// this.initialIndex = index\n\t\t\t// this.hiddenDialog = true\n\n\n // let picUrl = obpmConfig.obpmFilePath;\n\t\t\t// this.dialogImageUrl = picUrl + file.path;\n\t\t\t// this.dialogVisible = true;\n\t\t},\n\n\t\thandlePictureCardPreviewT(index) {//图片预览\n\t\t\t// let path=item.path&&item.path.indexOf('http')>-1?item.path:'/obpm'+item.path\n // console.log(item.path)\n\t\t\t// this.$nextTick(()=>{\n\t\t\t// this.$viewerApi({\n\t\t\t// \timages: [path],\t\t\t\t\n\t\t\t// })\n\t\t\t// })\n\t\t\tthis.initialIndex = index\n\t\t\tthis.hiddenDialog = true\n\n\n // let picUrl = obpmConfig.obpmFilePath;\n\t\t\t// this.dialogImageUrl = picUrl + file.path;\n\t\t\t// this.dialogVisible = true;\n\t\t},\n\n\t\thandleExceed(files, fileList) {\n\t\t\tthis.$message.warning(this.$t('view.out'));\n\t\t},\n\n\t\tbeforeAvatarUpload(file) {\n\t\t\t \n\t\t\tthis.imageType = file.type\n\t\t\tconst isJPG = file.type === 'image/jpeg' || 'image/png' || 'image/gif' || 'image/jpg' || 'image/JPG'|| 'image/JPEG'|| 'image/GIF'|| 'image/PNG'\n\t\t\tlet temp = file.name.split(\".\")\n\t\t\tlet name = temp[temp.length -1]\n\t\t\tlet arr = ['','jpeg','png','gif','jpg', 'JPG', 'JPEG', 'PNG', 'GIF']\n\t\t\tlet isSuffix = arr.indexOf(name) > 0\n\t\t\tconst isLt2M = file.size / 1024 < this.field.maxsize\n\t\t\tif (!isJPG || !isSuffix) {\n\t\t\t\tthis.$message.error(this.$t('view.pic_err'))\n\t\t\t\treturn false\n\t\t\t}\n\t\t\tif (!isLt2M) {\n\t\t\t\tthis.$message.error(this.$t('view.data_out'))\n\t\t\t\treturn false\n\t\t\t}\n\n\n\t\t\tif(__network__){//obs文件上传不走下面代码\n\t\t\t return\n\t\t }\n\n\n\t\t\tif(isJPG){\n\t\t\t\tconst reader = new FileReader()\n\t\t\t\t// readAsDataURL:读取为base64格式\n\t\t\t\treader.readAsDataURL(file)\n\t\t\t\t// onload 在文件读取成功时触发\n\t\t\t\treader.onload = () => {\n\t\t\t\t\tconst ImgBase64 = reader.result\n\t\t\t\t\tlet ob = {}\n\t\t\t\t\tob.uid = file.uid\n\t\t\t\t\tob.name = file.name\n\t\t\t\t\tob.marks = 0\n\t\t\t\t\tob.marksValue = '0%'\n\t\t\t\t\tob.path = ImgBase64\n\t\t\t\t\tthis.allfileArray.push(ob)\n\t\t\t\t};\n\t\t\t}\n\t\t\treturn isJPG && isLt2M && isSuffix\n\t\t},\n\n\t\tobsFile(e){//obs文件上传\n\t console.log(e)\n\t\t //去掉文件名称空格start\n\t\t\tlet form = new FormData();\n\t\t\tform.append(\"files\", e.file);\t\t\t\n\t\t\tform.forEach(function (value, key) {\n\t\t\t\tif (value instanceof File) {\n\t\t\t\t\tform.set(key, value, value.name.replace(/ /g, ''))//去掉文件名称所有空格\n\t\t\t\t}\n\t\t\t})\n\t\t\tform.get('files')\n\t\t\tconsole.log(form.get('files'))\n\t\t\te.file=form.get('files')\n //去掉文件名称空格end\n\t\t\t\n\t\t var that=this;\n\t\t var domainId=localStorage.getItem(\"domainId\")||\"default\"//保存本地企业id\n\t\t\t// var objectKey=\"uploads/\"+domainId+\"/\"+new Date().getFullYear()+\"/\"+new Date().getTime()+e.file.name\n\t\t\t// https://bcxin-v5-prod.obs.cn-north-1.myhuaweicloud.com/uploads/2022/06-20/公司id/uuid/文件名.xls\t\t\n\t\t\tlet now=new Date()\n\t\t\tlet y=now.getFullYear()\n\t\t\tlet m=now.getMonth()+1<10?'0'+(now.getMonth()+1):now.getMonth()+1\n\t\t\tlet d=now.getDate()<10?'0'+now.getDate():now.getDate()\n\t\t\tlet md=m+'-'+d\t\t\t\n\t\t\tvar objectKey=`uploads/${y}/${md}/${domainId}/${now.getTime()}/${e.file.name}`\t\n\n\t\t\tvar obs = new ObsClient({\n\t\t\t\taccess_key_id: ak,\n\t\t\t\tsecret_access_key: sk,\n\t\t\t\tserver : urlserver,\n\t\t\t\ttimeout : 60 * 5,\n\t\t\t});\n\t\t\tobs.putObject({\n\t\t\t\tBucket: BucketName,\n\t\t\t\tKey : objectKey,\n\t\t\t\tSourceFile:e.file //获取file文件\n\t\t\t}).then(function(result) {\n\t\t\t\tconsole.log(result)\n\n\t\t\t\tif(result.CommonMsg.Status < 300){\n\n\t\t\t\t\tconsole.log('Create object:' + objectKey + ' successfully!\\n');\n\t\t\t\t\tvar httpurl=`https://${BucketName}.${urlserver}/${objectKey}`\n\t\t\t\t\thttpurl = convertCdnPath(httpurl);\n\t\t\t\t\t\n\t\t\t\t\t// let ob = {};\n\t\t\t\t\t// ob.uid = e.file.uid;\n\t\t\t\t\t// ob.name = e.file.name\n\t\t\t\t\t// ob.marks = 100;\n\t\t\t\t\t// ob.marksValue = '100%';\n\t\t\t\t\t// that.allfileArray.push(ob);\n\n\t\t\t\t\tlet uploadTime = '';\n\t\t\t\t\tlet date = new Date();\n\t\t\t\t\tlet Y = date.getFullYear() + '-';\n\t\t\t\t\tlet M = (date.getMonth()+1 < 10 ? '0'+(date.getMonth()+1) : date.getMonth()+1) + '-';\n\t\t\t\t\tlet D = (date.getDate() < 10 ? '0' + date.getDate() : date.getDate()) + ' ';\n\t\t\t\t\tlet h = (date.getHours() < 10 ? '0' + date.getHours() : date.getHours())+ ':';\n\t\t\t\t\tlet m = (date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes()) + ':';\n\t\t\t\t\tlet s = (date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds()); \n\t\t\t\t\tuploadTime = Y+M+D+h+m+s;\n\n\t\t\t\t\tthat.picUrl = obpmConfig.obpmFilePath + \"/\";\n\t\t\t\t\tlet obj = {\n\t\t\t\t\t\tname: e.file.name,\n\t\t\t\t\t\tpath: httpurl,\n\t\t\t\t\t\turl: httpurl,\n\t\t\t\t\t\tfileType: \"\",\n\t\t\t\t\t\tuploader: sessionStorage.getItem(\"myProfileName\")||'',\n\t\t\t\t\t\tuploadTime,\n\t\t\t\t\t\tuserName: sessionStorage.getItem(\"myProfileName\")||'',\n\t\t\t\t\t\ttime: uploadTime,\n\t\t\t\t\t\tsize: e.file.size\n\t\t\t\t\t};\n\t\t\t\t\tthat.fileArray.push(obj);\n\t\t\t\t\tif(that.field.value && that.field.value instanceof Array) {\n\t\t\t\t\t\tthat.field.value = that.fileArray.concat(that.field.value);\n\t\t\t\t\t}else {\n\t\t\t\t\t\tthat.field.value = that.fileArray;\n\t\t\t\t\t}\n\t\t\t\t\tthat.fileArray = [];\n\t\t\t\t\tif (that.field.refreshOnChanged){\n\t\t\t\t\t\tthat.$parent.refresh(that.id);\n\t\t\t\t\t}\n\t\t\t\t\tif(that.field.instantValidate) {\n\t\t\t\t\t\tthis.evenCheck();\n\t\t\t\t\t}\n\t\t\t\t\t// var pushstring=`${e.file.name},${httpurl},${e.file.size}`\n\t\t\t\t\t// if(values.indexOf(pushstring)===-1){\n\t\t\t\t\t// \tvalues.push(pushstring)\n\t\t\t\t\t// \tflag++\n\t\t\t\t\t// \tconsole.log(\"上传几个:\"+flag)\n\t\t\t\t\t// \t\tif(fileCount===flag){\n\t\t\t\t\t// \t\t\tconsole.log(\"已上传成功\")\n\t\t\t\t\t// \t\t\t$info.html(\"已上传成功\");\n\t\t\t\t\t// \t\t\t$('.state-ok').show();\n\t\t\t\t\t// \t\t}\n\t\t\t\t\t \n\t\t\t\t\t// }\n\t\t\t\t\t// console.log(values)\n\t\t\t\t\t\n\t\t\t\t}\n\t\t\t});\n\t },\n\t},\n}\n",null]}