{"remainingRequest":"D:\\jenkins\\workspace\\xq-web-fvue\\node_modules\\thread-loader\\dist\\cjs.js!D:\\jenkins\\workspace\\xq-web-fvue\\node_modules\\babel-loader\\lib\\index.js!D:\\jenkins\\workspace\\xq-web-fvue\\node_modules\\eslint-loader\\index.js??ref--13-0!D:\\jenkins\\workspace\\xq-web-fvue\\src\\plugs\\print.js","dependencies":[{"path":"D:\\jenkins\\workspace\\xq-web-fvue\\src\\plugs\\print.js","mtime":1667327529778},{"path":"D:\\jenkins\\workspace\\xq-web-fvue\\babel.config.js","mtime":1667327525434},{"path":"D:\\jenkins\\workspace\\xq-web-fvue\\node_modules\\cache-loader\\dist\\cjs.js","mtime":499162500000},{"path":"D:\\jenkins\\workspace\\xq-web-fvue\\node_modules\\thread-loader\\dist\\cjs.js","mtime":499162500000},{"path":"D:\\jenkins\\workspace\\xq-web-fvue\\node_modules\\babel-loader\\lib\\index.js","mtime":315532800000},{"path":"D:\\jenkins\\workspace\\xq-web-fvue\\node_modules\\eslint-loader\\index.js","mtime":499162500000}],"contextDependencies":[],"result":["import _typeof from \"D:/jenkins/workspace/xq-web-fvue/node_modules/@babel/runtime/helpers/esm/typeof.js\";\n\n// 打印类属性、方法定义\n\n/* eslint-disable */\nvar Print = function Print(dom, options) {\n  if (!(this instanceof Print)) return new Print(dom, options);\n  this.options = this.extend({\n    'noPrint': '.no-print'\n  }, options);\n\n  if (typeof dom === \"string\") {\n    this.dom = document.querySelector(dom);\n  } else {\n    this.isDOM(dom);\n    this.dom = this.isDOM(dom) ? dom : dom.$el;\n  }\n\n  this.init();\n};\n\nPrint.prototype = {\n  init: function init() {\n    var content = this.getStyle() + this.getHtml();\n    this.writeIframe(content);\n  },\n  extend: function extend(obj, obj2) {\n    for (var k in obj2) {\n      obj[k] = obj2[k];\n    }\n\n    return obj;\n  },\n  getStyle: function getStyle() {\n    var str = \"\",\n        styles = document.querySelectorAll('style,link');\n\n    for (var i = 0; i < styles.length; i++) {\n      str += styles[i].outerHTML;\n    }\n\n    str += \"<style>\" + (this.options.noPrint ? this.options.noPrint : '.no-print') + \"{display:none;}</style>\";\n    str += \"<style>html,body,div{height: auto!important;font-size:14px}</style>\";\n    return str;\n  },\n  iframes: null,\n  getHtml: function getHtml() {\n    var inputs = document.querySelectorAll('input');\n    var textareas = document.querySelectorAll('textarea');\n    var selects = document.querySelectorAll('select');\n    var iframes = document.querySelectorAll('iframe');\n\n    for (var k = 0; k < inputs.length; k++) {\n      if (inputs[k].type == \"checkbox\" || inputs[k].type == \"radio\") {\n        if (inputs[k].checked == true) {\n          inputs[k].setAttribute('checked', \"checked\");\n        } else {\n          inputs[k].removeAttribute('checked');\n        }\n      } else if (inputs[k].type == \"text\") {\n        inputs[k].setAttribute('value', inputs[k].value);\n      } else {\n        inputs[k].setAttribute('value', inputs[k].value);\n      }\n    }\n\n    for (var k2 = 0; k2 < textareas.length; k2++) {\n      if (textareas[k2].type == 'textarea') {\n        textareas[k2].innerHTML = textareas[k2].value;\n      }\n    }\n\n    for (var k3 = 0; k3 < selects.length; k3++) {\n      if (selects[k3].type == 'select-one') {\n        var child = selects[k3].children;\n\n        for (var i in child) {\n          if (child[i].tagName == 'OPTION') {\n            if (child[i].selected == true) {\n              child[i].setAttribute('selected', \"selected\");\n            } else {\n              child[i].removeAttribute('selected');\n            }\n          }\n        }\n      }\n    } // iframe 内容无法打印问题修复 富文本框的内容会闪一下 暂时不知道怎么处理\n\n\n    for (var k4 = 0; k4 < iframes.length; k4++) {\n      if (iframes[k4].contentDocument) {\n        var temp = iframes[k4];\n        iframes[k4].parentNode.innerHTML = temp.outerHTML + temp.contentDocument.querySelector(\"body\").innerHTML;\n      }\n    } // 包裹要打印的元素\n    // fix: https://github.com/xyl66/vuePlugs_printjs/issues/36\n\n\n    return this.wrapperRefDom(this.dom).outerHTML;\n  },\n  // 向父级元素循环，包裹当前需要打印的元素\n  // 防止根级别开头的 css 选择器不生效\n  wrapperRefDom: function wrapperRefDom(refDom) {\n    var prevDom = null;\n    var currDom = refDom;\n\n    while (currDom && currDom.tagName.toLowerCase() !== 'body') {\n      if (prevDom) {\n        var element = currDom.cloneNode(false);\n        element.appendChild(prevDom);\n        prevDom = element;\n      } else {\n        prevDom = currDom.cloneNode(true);\n      }\n\n      currDom = currDom.parentElement;\n    }\n\n    return currDom.tagName.toLowerCase() === 'body' ? currDom : prevDom;\n  },\n  writeIframe: function writeIframe(content) {\n    var w,\n        doc,\n        iframe = document.createElement('iframe'),\n        f = document.body.appendChild(iframe);\n    iframe.id = \"myIframe\"; //iframe.style = \"position:absolute;width:0;height:0;top:-10px;left:-10px;\";\n\n    iframe.setAttribute('style', 'position:absolute;width:0;height:0;top:-10px;left:-10px;');\n    w = f.contentWindow || f.contentDocument;\n    doc = f.contentDocument || f.contentWindow.document;\n    doc.open();\n    doc.write(content);\n    doc.close();\n\n    var _this = this;\n\n    iframe.onload = function () {\n      _this.toPrint(w);\n\n      setTimeout(function () {\n        document.body.removeChild(iframe);\n      }, 100);\n    };\n  },\n  toPrint: function toPrint(frameWindow) {\n    try {\n      setTimeout(function () {\n        frameWindow.focus();\n\n        try {\n          if (!frameWindow.document.execCommand('print', false, null)) {\n            frameWindow.print();\n          }\n        } catch (e) {\n          frameWindow.print();\n        }\n\n        frameWindow.close();\n      }, 10);\n    } catch (err) {\n      console.log('err', err);\n    }\n  },\n  isDOM: (typeof HTMLElement === \"undefined\" ? \"undefined\" : _typeof(HTMLElement)) === 'object' ? function (obj) {\n    return obj instanceof HTMLElement;\n  } : function (obj) {\n    return obj && _typeof(obj) === 'object' && obj.nodeType === 1 && typeof obj.nodeName === 'string';\n  }\n};\nvar MyPlugin = {};\n\nMyPlugin.install = function (Vue, options) {\n  // 4. 添加实例方法\n  Vue.prototype.$print = Print;\n};\n\nexport default MyPlugin;",null]}