{"remainingRequest":"/data/jenkins/workspace/badp-bcxin-web-5.x-mobile/node_modules/vue-loader/lib/index.js??vue-loader-options!/data/jenkins/workspace/badp-bcxin-web-5.x-mobile/src/components/o_file_upload.vue?vue&type=script&lang=js&","dependencies":[{"path":"/data/jenkins/workspace/badp-bcxin-web-5.x-mobile/src/components/o_file_upload.vue","mtime":1740130327257},{"path":"/data/jenkins/workspace/badp-bcxin-web-5.x-mobile/node_modules/cache-loader/dist/cjs.js","mtime":499162500000},{"path":"/data/jenkins/workspace/badp-bcxin-web-5.x-mobile/node_modules/thread-loader/dist/cjs.js","mtime":499162500000},{"path":"/data/jenkins/workspace/badp-bcxin-web-5.x-mobile/node_modules/babel-loader/lib/index.js","mtime":499162500000},{"path":"/data/jenkins/workspace/badp-bcxin-web-5.x-mobile/node_modules/cache-loader/dist/cjs.js","mtime":499162500000},{"path":"/data/jenkins/workspace/badp-bcxin-web-5.x-mobile/node_modules/vue-loader/lib/index.js","mtime":499162500000}],"contextDependencies":[],"result":["//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n\nimport { Toast } from 'mint-ui'\n// import { Progress } from 'mint-ui';\nimport pdf from 'vue-pdf'\nimport Constant from \"@/Constant.js\"\nimport API from \"@/api.js\"\nimport controlHidden from \"@/assets/js/controlHidden.js\"\n\nexport default {\n name: \"o-file-upload\",\n props: [\"id\"],\n components: {\n pdf,\n },\n computed: {\n field: function() {\n let formData = this.$parent.findField(this.id);\n if(formData.discript) {//识别控件描述最后一个字符为*时,*变红\n if(formData.discript.charAt(formData.discript.length - 1) == \"*\") {\n formData.discript = formData.discript.replace(/(\\s|\\*)+$/g, '');\n formData.essential = true;\n }\n }\n formData.downloadUrl = obpmConfig.obpmFilePath +\"/\";\n if(formData.value && typeof formData.value == 'string') {\n formData.value = JSON.parse(formData.value);\n }if(formData.value && formData.value instanceof Array) {\n if(formData.value.length == 0) {\n formData.value = \"\";\n }\n }else {\n formData.value = '';\n }\n return this.$parent.findField(this.id);\n },\n },\n mounted(){\n this.$nextTick(()=>{\n let field = this.field;\n if(field.isHideType) {\n let id = this.id,\n formShowType = field.formShowType;\n controlHidden({id, field, formShowType})\n }\n })\n },\n destroyed(){\n window.removeEventListener('popstate', this.backChange, false);//false阻止默认事件\n },\n data: function() {\n return {\n actions:[\n {\n name: '原版',\n method: this.callback,\n },\n {\n name: '压缩版',\n method: this.callback,\n }\n \n ],\n sheetVisible:false,\n Constant,\n fileList: [],\n fileType: \"\",\n imageType: \"\",\n maxStatus: true,\n multiple: true,\n list: [],\n picUrl: \"\",\n pdfUrl:'',\n popupVisible:false,\n dialogVisible:false,\n fileSize:0,\n\n fileName:'',\n filePath:'',\n fileItem:'',\n jumpToPage:1,\n currentPage: 0, // pdf文件页码\n pageCount: 0, // pdf文件总页数\n //fileType: 'pdf', // 文件类型\n src: '', // pdf文件地址\n partialRefreshData:[],\n\n fieldValue:[],\n bigPic:'',\n picVisible:false,\n timer:'',\n suffixName:'',\n downloadUrl:'',\n downloadFilename:'',\n pageX:'', \n pageY:'', \n initX:'', \n initY:'', \n isTouch:false,\n start: [],\n scaleLength:'',\n touchespageX:'',\n touchespageY:'',\n scale:100,\n touchMoveX:'',\n touchMoveY:'',\n pageY1:'', \n pageX1:'', \n valLength:'',\n now:'',\n startVal:'',\n endVal:'',\n isZoom:false,\n uploadFile:[],\n isPdf:'',\n isOpen: false,\n pdfDoc: '',\n marks: 0,\n pdfScrollTop:'',\n pdfScrollBottom:'',\n movingDistanceY:'',\n touchLength:'',\n };\n },\n methods: {\n callback(ev){\n if(ev.name == '原版') {\n this.filePreviewVersion('1')\n }else {\n this.filePreviewVersion('2')\n }\n },\n\n filePreviewVersion(VType) {\n if(navigator.userAgent.indexOf('iPhone') !== -1) { //兼容苹果手机\n document.getElementById('pdfId').setAttribute('style','width:100%; height:calc(100% + 44px);margin-top:93px;-webkit-overflow-scrolling;touch;')\n }\n let field = this.field;\n let filePath = this.filePath,\n fileName = this.fileName;\n // 如果支持 popstate 一般移动端都支持了\n if (window.history && window.history.pushState) {\n // 往历史记录里面添加一条新的当前页面的url\n history.pushState(null, null, document.URL);\n // 给 popstate 绑定一个方法 监听页面刷新\n window.addEventListener('popstate', this.backChange, false);//false阻止默认事件\n } \n this.currentPage = 0;\n this.pageCount = 0;\n this.popupVisible = true; //改由企业微信或嗨办公打开隐藏该弹窗打开\n let arr = filePath.split('/');\n let id = arr[arr.length-1].split('.')[0];\n let len = arr[arr.length-1].split('.').length;\n let suffix = arr[arr.length-1].split('.')[len-1];\n let supportedDoc = ['doc','docx','txt','pdf','xls','xlsx','ppt','kms','wps'] \n if(suffix) {\n suffix = suffix.toLowerCase();\n if(supportedDoc.indexOf(suffix) < 0) {\n Toast({\n message: '不支持打开该格式文件',\n position: 'center',\n });\n return;\n }\n }\n this.isPdf = false;\n this.$api.readPDF(id, filePath, {\n onSucess: response => {\n let originalPdf = response.data.data;\n let minPdf = '';\n if(VType == '1') { //原版\n minPdf = originalPdf;\n }else {\n if(originalPdf) {\n minPdf = originalPdf.split('.')[0] + '.min.pdf';\n }\n }\n let accessToken = encodeURIComponent(\"?accessToken=\" + Constant.accessToken);\n let pdfUrl = obpmConfig.obpmFilePath + minPdf;\n let pdfPath = \"\";\n let statiContextPath = obpmConfig.statiContextPath;\n if(field.watermark != null) { //有水印\n let watermarkData = JSON.parse(field.watermark);\n this.$api.previewWaterMark(\n watermarkData,\n {\n onSucess: res => {\n let str = res.data.waterMarkStr;\n // let watermark = encodeURIComponent(\"&watermark=\" + str); \n sessionStorage.setItem(\"watermark_txt\", str)\n if(statiContextPath) { //5.0 trunk\n pdfPath = obpmConfig.statiContextPath + '/mobile/pdf/web/viewer.html?file=' + pdfUrl + accessToken;\n }else { //4.4 stable\n pdfPath = obpmConfig.obpmFilePath + '/mobile/pdf/web/viewer.html?file=' + pdfUrl + accessToken;\n }\n localStorage.setItem(\"fileName\", fileName)//(加入这个,将fileName放进本地存储)\n this.pdfUrl = pdfPath;\n }\n }\n )\n }else {\n sessionStorage.removeItem(\"watermark_txt\")\n if(statiContextPath) { //5.0 trunk\n pdfPath = obpmConfig.statiContextPath + '/mobile/pdf/web/viewer.html?file=' + pdfUrl + accessToken;\n }else { //4.4 stable\n pdfPath = obpmConfig.obpmFilePath + '/mobile/pdf/web/viewer.html?file=' + pdfUrl + accessToken;\n }\n localStorage.setItem(\"fileName\", fileName)//(加入这个,将fileName放进本地存储)\n this.pdfUrl = pdfPath;\n }\n }\n });\n },\n\n doBack(){\n this.popupVisible = false;\n this.pdfUrl = '';\n this.$router.go(-1);\n },\n\n backChange() {\n if(this.popupVisible) {\n this.popupVisible = false;\n }\n this.pdfUrl = '';\n },\n\n jumpTo(){\n if( parseInt(this.jumpToPage) >= 1 && parseInt(this.jumpToPage) <= this.pageCount) {\n this.currentPage = parseInt(this.jumpToPage);\n }\n \n },\n\n scroll(event) {\n let scrollBottom =\n event.target.scrollHeight -\n event.target.scrollTop -\n event.target.clientHeight;\n this.pdfScrollTop = event.target.scrollTop;\n this.pdfScrollBottom = scrollBottom; \n },\n\n touchstart(e) {\n\t\t\tthis.pageX = e.targetTouches[0].pageX;\n\t\t\tthis.pageY = e.targetTouches[0].pageY;\n\t\t\tthis.initX = e.target.offsetLeft;\n this.initY = e.target.offsetTop;\n if (e.touches.length >= 2) { //判断是否有两个点在屏幕上\n this.touchLength = e.touches.length;\n this.start = e.touches; //得到第一组两个点\n this.isTouch = true;\n\t\t\t}\n },\n\n touchmove(e) {\n\t\t\t// 一根 手指 执行 目标元素移动 操作\n\t\t\tif (e.touches.length == 1 && this.isTouch) {\n\t\t\t\t//移动目标的 X Y 坐标\n\t\t\t\tthis.touchMoveX = e.targetTouches[0].pageX,\n\t\t\t\tthis.touchMoveY = e.targetTouches[0].pageY;\n\t\t\t\t//设置当前点击元素的 top left 定位值\n\t\t\t\te.target.style.left = parseInt(this.touchMoveX) - parseInt(this.pageX) + parseInt(this.initX) + \"px\";\n e.target.style.top = parseInt(this.touchMoveX) - parseInt(this.pageY) + parseInt(this.initY) + \"px\";\n }\n \n if(e.touches.length == 1) {\n this.movingDistanceY = this.pageY - e.touches[0].pageY;\n }\n\n\t\t\t// 2 根 手指执行 目标元素放大操作\n\t\t\tif (e.touches.length >= 2 && this.isTouch) {\n e.preventDefault();\n\t\t\t\t//得到第二组两个点\n this.now = e.touches;\n let x = this.now[1].pageX - this.now[0].pageX;\n let y = this.now[1].pageY - this.now[0].pageY;\n this.startVal = Math.sqrt((x * x) + (y * y));\n\n let z = this.start[1].pageX - this.start[0].pageX;\n let j = this.start[1].pageY - this.start[0].pageY;\n this.endVal = Math.sqrt((z * z) + (j * j));\n this.valLength = this.startVal/this.endVal;\n this.isZoom = true;\n\t\t\t\t//this.scale = (getDistance(now[0], now[1]) / getDistance(this.start[0], this.start[1]));\n\t\t\t\t// 对缩放 比例 取整\n\t\t\t\t//e.scale = scale.toFixed(2);\n // 执行目标元素的缩放操作\n //this.scaleLength = e.scale\n\t\t\t\t//e.target.style.transform = \"scale(\" + scale + \")\";\n\t\t\t}\n },\n\n // getDistance(p1, p2) {\n // let x = p2.pageX - p1.pageX;\n // let y = p2.pageY - p1.pageY;\n // this.valLength = Math.sqrt((x * x) + (y * y));\n // return Math.sqrt((x * x) + (y * y));\n // },\n\n touchend(e) {\n if (this.isTouch) {\n\t\t\t\tthis.isTouch = false;\n }\n\n if (this.touchLength >= 2) {\n if(this.valLength>=1 && this.isZoom) {\n // this.scale += 15;\n // let pafList = this.$refs.pdf;\n // if(pafList.length > 0) {\n // for(let i=0; i 0) {\n // for(let i=0; i-1){//bcx-obs文件下载\n window.open(item.path)\n return\n }\n let data = {}\n data.filename = item.filename?item.filename:item.name\n data.filepath = item.filepath?item.filepath:item.path\n let op = obpmConfig.obpmFilePath\n let statiContextPath = obpmConfig.statiContextPath\n if(statiContextPath) { //5.0 trunk\n op = op + \"/api\"\n }\n \n let watermark = this.field.watermark\n if(watermark) {\n this.$api.downloadWaterMarkFile(\n\t\t\t\t\twatermark,\n\t\t\t\t\t'',\n\t\t\t\t\t'',\n\t\t\t\t\t{\n\t\t\t\t\t\tonSucess: res => {\n\t\t\t\t\t\t\tif(res.data.waterMarkStr) {\n console.log(\"obpmConfig.contextPath-->\",obpmConfig.contextPath)\n\t\t\t\t\t\t\t\tlet url = encodeURI(\n\t\t\t\t\t\t\t\t\tobpmConfig.contextPath + \"/runtime/file/download?filename=\" + data.filename + \n\t\t\t\t\t\t\t\t\t\"&filepath=\" + data.filepath + \n\t\t\t\t\t\t\t\t\t\"&watermarkStr=\" + res.data.waterMarkStr)\n window.open(url)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t)\n }else {\n let link = document.createElement('a')\n link.style.display = 'none'\n let accessToken = localStorage.getItem(\"accessToken\")\n let href = op + \"/runtime/file/download?filename=\" + data.filename + \"&filepath=\" + data.filepath + \"&accessToken=\"+ accessToken\n link.href = href\n link.setAttribute('download', data.filename)\n link.click()\n }\n },\n\n downloadfile(res) {\n let blob = new Blob([res.data], {type: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document;charset=utf-8'}); //application/vnd.openxmlformats-officedocument.wordprocessingml.document这里表示doc类型\n let contentDisposition = res.headers['content-disposition']; //从response的headers中获取filename, 后端response.setHeader(\"Content-disposition\", \"attachment; filename=xxxx.docx\") 设置的文件名;\n let patt = new RegExp(\"filename=([^;]+\\\\.[^\\\\.;]+);*\");\n var result = patt.exec(contentDisposition);\n let filename = result[1];\n let downloadElement = document.createElement('a');\n let href = window.URL.createObjectURL(blob); //创建下载的链接\n let reg = /^[\"](.*)[\"]$/g;\n downloadElement.style.display = 'none';\n downloadElement.href = href;\n downloadElement.download = decodeURI(filename.replace(reg,\"$1\")); //下载后文件名\n document.body.appendChild(downloadElement);\n downloadElement.click(); //点击下载\n document.body.removeChild(downloadElement); //下载完成移除元素\n window.URL.revokeObjectURL(href); //释放掉blob对象\n },\n\n // 改变PDF页码,val传过来区分上一页下一页的值,0上一页,1下一页\n changePdfPage (val) {\n if (val === 0 && this.currentPage > 1) {\n this.currentPage--\n }\n if (val === 1 && this.currentPage < this.pageCount) {\n this.currentPage++\n }\n },\n\n // pdf加载时\n loadPdfHandler (val) {\n // let canvas = this.$refs.pdfContainer.childNodes[0].childNodes[0];\n // let ctx = canvas.getContext(\"2d\"); //设置2D渲染区域\n // ctx.clearRect(0, 0, canvas.width, canvas.height);\n this.currentPage = 1 // 加载的时候先加载第一页\n \n },\n\n //文件预览\n filePreview(filePath, name, item) {\n \n console.log(filePath)\n console.log(name)\n console.log(item)\n let isImg = false;\n if(item.name) {\n let name = item.name.split('.')[item.name.split('.').length - 1];\n name = name.toLowerCase();\n if(\n name == 'png' || \n name == 'jpg' || \n name == 'jpeg' || \n name == 'gif' ) {\n isImg = true;\n }\n }\n if(isImg) {\n if(filePath.indexOf(\"http\")>-1){//bcx-obs文件预览\n this.bigPic=filePath \n }else{\n this.bigPic = obpmConfig.obpmFilePath + \"/\" + filePath + \"?accessToken=\" + Constant.accessToken;\n }\n this.picVisible = true;\n return;\n }else {\n if(filePath.indexOf(\"http\")>-1){//bcx-obs文件打开\n window.open(filePath)\n return\n }\n this.filePath = filePath;\n this.fileName = name;\n this.fileItem = item;\n this.sheetVisible = true;\n }\n },\n\n chooseType() { \n document.getElementById(this.field.divId).click();\n },\n\n close(index, item) {\n this.partialRefreshData = [];\n let appId = this.$root.appid;\n let formId = this.field.formId;\n let docId = this.field.docId;\n let path = item;\n API.deleteUpload(appId, formId, docId, path, {\n onSucess: () => {\n this.field.value.splice(index, 1);\n this.maxStatus = this.field.value.length == this.field.limitNumber ? false : true;\n if (this.field.refreshOnChanged){\n this.$parent.refresh(this.field.id);\n }\n }\n });\n },\n\n async inputChange(e) {\n let files = e.target.files;\n let arr = files[0].name.split(\".\");\n \n this.suffixName = arr[arr.length - 1];\n if(this.field.customizeType) {\n let arrCustomizeType = this.field.customizeType.split(\";\");\n if(arrCustomizeType.indexOf(this.suffixName) < 0) {\n this.$toast(`文件类型(仅支持'${this.field.customizeType}'格式)或大小错误`);\n return false;\n }\n \n }\n // if(this.field.customizeType && this.field.customizeType != this.suffixName) {\n // this.$toast(`文件类型(仅支持'${this.field.customizeType}'格式)或大小错误`);\n // return false;\n // }\n for(let i=0; i this.field.maxsize) {\n document.getElementById(this.field.divId).value = \"\";\n let size = this.field.maxsize / 1024\n this.$toast(`上传文件大小不能超过${size}M`);\n return;\n }\n\n //限制上传数量\n let len = this.field.value.length + files.length;\n let maxLength = this.field.limitNumber; //最大上传数量 \n if (len > maxLength) {\n document.getElementById(this.field.divId).value = \"\";\n this.$toast(`最多允许上传${maxLength}个文件`);\n this.fileSize = 0;\n return;\n }\n this.dialogVisible = true;\n [].slice.call(files, 0).map(this.upload);\n //let result = await Promise.all(uploadAll);\n document.getElementById(this.field.divId).value = \"\";\n },\n\n upload(file) {\n let that = this;\n return new Promise(async () => {\n let ob = {};\n ob.uid = file.lastModified;\n ob.name = file.name\n ob.marks = 0;\n ob.marksValue = '0%';\n\n let form = new FormData();\n form.append(\"files\", file);\n let files = form;\n let actionType = this.imageType;\n let appId = this.$root.appid;\n let allowedTypes = this.field.fileType;\n let fieldId = this.id;\n let fileSaveMode = this.field.fileSaveMode;\n let path = this.field.path;\n this.$api.uploadFile(\n files, \n appId, \n allowedTypes, \n fieldId, \n fileSaveMode, \n path, \n actionType,\n {\n onSucess: response => {\n let uploadTime = '';\n let date = new Date();\n let Y = date.getFullYear() + '-';\n let M = (date.getMonth()+1 < 10 ? '0'+(date.getMonth()+1) : date.getMonth()+1) + '-';\n let D = date.getDate() + ' ';\n let h = date.getHours() + ':';\n let m = date.getMinutes() + ':';\n let s = date.getSeconds(); \n uploadTime = Y+M+D+h+m+s;\n let doc = response.data.data[0];\n let obj = {\n name: doc.fileName,\n path: doc.filePath,\n size: doc.fileSize,\n fileType: doc.fileType,\n uploader: that.$root.user.name,\n uploadTime,\n };\n\n that.uploadFile.push(obj);\n that.field.value=that.uploadFile;\n that.field.downloadUrl = obpmConfig.obpmFilePath +\"/\";\n that.dialogVisible = false;\n if (that.field.refreshOnChanged){\n // that.$parent.refresh(that.id);\n let havePar = false;\n let par = '';\n while(!havePar) {\n par = par + '.$parent';\n let url = 'that' + par + '.refresh';\n if(eval(url)) {\n let path = url + '(' + \"'\"+ this.id +\"'\" + ')';\n eval(path);\n break\n }\n }\n }\n \n }\n },\n (res) =>{\n // debugger\n\n this.marks = res.num;\n // this.marksValue = res.complete;\n },\n file.lastModified,\n\n )\n\n // axios({\n // headers: {\n // \"content-type\": \"multipart/form-data;boundary=\" + Math.random()\n // },\n // data: files,\n // url:\n // \"/obpm/runtime/upload?applicationId=\" +\n // appId +\n // \"&allowedTypes=\" +\n // allowedTypes +\n // \"&fieldId=\" +\n // fieldId +\n // \"&fileSaveMode=\" +\n // fileSaveMode +\n // \"&path=\" +\n // path +\n // \"&actionType=\" +\n // actionType,\n // method: \"post\"\n // })\n // .then(function(response) {\n // let doc = response.data.data[0];\n // let obj = {\n // name: doc.fileName,\n // path: doc.filePath,\n // size: doc.fileSize,\n // fileType: doc.fileType,\n // };\n // that.uploadFile.push(obj);\n // that.field.value=that.uploadFile;\n // that.field.downloadUrl = \"http://\" + window.location.host + \"/obpm/\";\n // if (that.field.refreshOnChanged){\n // that.$parent.refresh(that.id);\n // }\n // that.dialogVisible = false;\n // })\n // .catch(function(error) {\n\n // });\n\n });\n }\n //\n }\n};\n",null]}