UNPKG

wt-vue-utils

Version:

vue常用工具函数、自定义指令

2 lines 15.7 kB
/*! For license information please see ../doc.txt */ var t={526:(t,e,r)=>{function n(t){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},n(t)}function o(){o=function(){return e};var t,e={},r=Object.prototype,i=r.hasOwnProperty,a=Object.defineProperty||function(t,e,r){t[e]=r.value},c="function"==typeof Symbol?Symbol:{},u=c.iterator||"@@iterator",l=c.asyncIterator||"@@asyncIterator",f=c.toStringTag||"@@toStringTag";function s(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{s({},"")}catch(t){s=function(t,e,r){return t[e]=r}}function d(t,e,r,n){var o=e&&e.prototype instanceof m?e:m,i=Object.create(o.prototype),c=new N(n||[]);return a(i,"_invoke",{value:T(t,r,c)}),i}function h(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=d;var p="suspendedStart",v="suspendedYield",y="executing",g="completed",b={};function m(){}function w(){}function O(){}var x={};s(x,u,(function(){return this}));var E=Object.getPrototypeOf,j=E&&E(E(R([])));j&&j!==r&&i.call(j,u)&&(x=j);var L=O.prototype=m.prototype=Object.create(x);function S(t){["next","throw","return"].forEach((function(e){s(t,e,(function(t){return this._invoke(e,t)}))}))}function P(t,e){function r(o,a,c,u){var l=h(t[o],t,a);if("throw"!==l.type){var f=l.arg,s=f.value;return s&&"object"==n(s)&&i.call(s,"__await")?e.resolve(s.__await).then((function(t){r("next",t,c,u)}),(function(t){r("throw",t,c,u)})):e.resolve(s).then((function(t){f.value=t,c(f)}),(function(t){return r("throw",t,c,u)}))}u(l.arg)}var o;a(this,"_invoke",{value:function(t,n){function i(){return new e((function(e,o){r(t,n,e,o)}))}return o=o?o.then(i,i):i()}})}function T(e,r,n){var o=p;return function(i,a){if(o===y)throw Error("Generator is already running");if(o===g){if("throw"===i)throw a;return{value:t,done:!0}}for(n.method=i,n.arg=a;;){var c=n.delegate;if(c){var u=A(c,n);if(u){if(u===b)continue;return u}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===p)throw o=g,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=y;var l=h(e,r,n);if("normal"===l.type){if(o=n.done?g:v,l.arg===b)continue;return{value:l.arg,done:n.done}}"throw"===l.type&&(o=g,n.method="throw",n.arg=l.arg)}}}function A(e,r){var n=r.method,o=e.iterator[n];if(o===t)return r.delegate=null,"throw"===n&&e.iterator.return&&(r.method="return",r.arg=t,A(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),b;var i=h(o,e.iterator,r.arg);if("throw"===i.type)return r.method="throw",r.arg=i.arg,r.delegate=null,b;var a=i.arg;return a?a.done?(r[e.resultName]=a.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,b):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,b)}function $(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function k(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function N(t){this.tryEntries=[{tryLoc:"root"}],t.forEach($,this),this.reset(!0)}function R(e){if(e||""===e){var r=e[u];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var o=-1,a=function r(){for(;++o<e.length;)if(i.call(e,o))return r.value=e[o],r.done=!1,r;return r.value=t,r.done=!0,r};return a.next=a}}throw new TypeError(n(e)+" is not iterable")}return w.prototype=O,a(L,"constructor",{value:O,configurable:!0}),a(O,"constructor",{value:w,configurable:!0}),w.displayName=s(O,f,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===w||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,O):(t.__proto__=O,s(t,f,"GeneratorFunction")),t.prototype=Object.create(L),t},e.awrap=function(t){return{__await:t}},S(P.prototype),s(P.prototype,l,(function(){return this})),e.AsyncIterator=P,e.async=function(t,r,n,o,i){void 0===i&&(i=Promise);var a=new P(d(t,r,n,o),i);return e.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},S(L),s(L,f,"Generator"),s(L,u,(function(){return this})),s(L,"toString",(function(){return"[object Generator]"})),e.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},e.values=R,N.prototype={constructor:N,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(k),!e)for(var r in this)"t"===r.charAt(0)&&i.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var r=this;function n(n,o){return c.type="throw",c.arg=e,r.next=n,o&&(r.method="next",r.arg=t),!!o}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],c=a.completion;if("root"===a.tryLoc)return n("end");if(a.tryLoc<=this.prev){var u=i.call(a,"catchLoc"),l=i.call(a,"finallyLoc");if(u&&l){if(this.prev<a.catchLoc)return n(a.catchLoc,!0);if(this.prev<a.finallyLoc)return n(a.finallyLoc)}else if(u){if(this.prev<a.catchLoc)return n(a.catchLoc,!0)}else{if(!l)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return n(a.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var n=this.tryEntries[r];if(n.tryLoc<=this.prev&&i.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var o=n;break}}o&&("break"===t||"continue"===t)&&o.tryLoc<=e&&e<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=t,a.arg=e,o?(this.method="next",this.next=o.finallyLoc,b):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),b},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),b}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:R(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),b}},e}function i(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function a(t,e){if("application/json"===t.data.type){var r=new FileReader;return r.readAsText(t.data,"utf-8"),r.onload=function(){var t=JSON.parse(r.result).message;e&&e(t)},!1}return!0}function c(t,e,r){if(a(t,r)){var n=new Blob([t.data]);f(window.URL.createObjectURL(n),e?e+".xls":"下载文件.xls")}}function u(t,e,r){if(a(t,r)){var n=new Blob([t.data],{type:"application/pdf;charset=utf-8"});f(window.URL.createObjectURL(n),e?e+".pdf":"下载文件.pdf")}}function l(t,e,r){if(a(t,r)){var n=new Blob([t.data]);f(window.URL.createObjectURL(n),e)}}function f(t,e){var r=document.createElement("a");r.id=Date().valueOf()+Math.random(),r.style.display="none",r.href=t,e&&(r.download=e),document.body.appendChild(r),r.click(),document.body.removeChild(r),window.URL.revokeObjectURL(t)}function s(t,e,r){if(r)return new Promise((function(n){setTimeout((function(){f(t,e),n()}),r)}));f(t,e)}function d(t,e){var r=new Blob([t.data]),n=window.URL.createObjectURL(r);if(!e){var o=t.headers["content-disposition"],i=/filename[^;=\n]*=((['"]).*?\2|[^;\n]*)/.exec(o);null!=i&&i[1]&&(e=decodeURIComponent(i[1].replace(/['"]/g,"")))}f(n,e)}function h(t){return p.apply(this,arguments)}function p(){var t;return t=o().mark((function t(e){var r,n;return o().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:r=0;case 1:if(!(r<e.length)){t.next=8;break}return n=e[r],t.next=5,s(n.path,n.fileName,1e3*r);case 5:r++,t.next=1;break;case 8:case"end":return t.stop()}}),t)})),p=function(){var e=this,r=arguments;return new Promise((function(n,o){var a=t.apply(e,r);function c(t){i(a,n,o,c,u,"next",t)}function u(t){i(a,n,o,c,u,"throw",t)}c(void 0)}))},p.apply(this,arguments)}r.r(e),r.d(e,{downloadExcel:()=>c,downloadFile:()=>s,downloadFileBlob:()=>d,downloadFileMultiple:()=>h,downloadPdf:()=>u,downloadPicture:()=>l})},754:(t,e,r)=>{function n(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:4,r=t,n=r.substr(0,1),o=r.substr(1,1);if(r.length>1&&0==+n&&"."!==o&&(r=r.substr(1,1)),"."===n&&(r=""),-1!==r.indexOf(".")){var i=r.substr(r.indexOf(".")+1);-1!==i.indexOf(".")&&(r=r.substr(0,r.indexOf(".")+i.indexOf(".")+1)),0===e?r=r.substr(0,r.indexOf(".")):i.length>e&&(r=r.substr(0,r.indexOf(".")+(e+1)))}return r=r.replace(/[^\d.]+/g,"")}r.r(e),r.d(e,{validateNumInput:()=>n})},912:(t,e,r)=>{function n(t){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},n(t)}function o(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function i(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?o(Object(r),!0).forEach((function(e){a(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):o(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function a(t,e,r){var o;return o=function(t,e){if("object"!=n(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var o=r.call(t,e||"default");if("object"!=n(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(e,"string"),(e="symbol"==n(o)?o:o+"")in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function c(t){return t.filter((function(e){var r=e.parentId;return 0===t.filter((function(t){if(t.id===r)return t.children||(t.children=[]),t.children.push(e),!0})).length}))}function u(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];return t.forEach((function(t){t.children?u(t.children,e):e.push(t)})),e}function l(t){var e=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"",r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];return t.forEach((function(t){t.children?l(t.children,r,e?e+"/"+t.label:t.label):e?r.push(i(i({},t),{},{label:e+"/"+t.label})):r.push(t)})),r}function f(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"id",n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"parentId",o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"sort",c=arguments.length>5&&void 0!==arguments[5]?arguments[5]:"children";return function e(u){var l=[];return t.filter((function(t){return t[n]===u})).forEach((function(t){l.push(i(i({},t),{},a({},c,e(t[r]))))})),l.sort((function(t,e){return t[o]-e[o]})),l}(e)}function s(t,e){for(var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"id",n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"children",o=0;o<e.length;o++){if(e[o][r]===t)return e[o];if(e[o][n]&&e[o][n].length>0){var i=s(t,e[o][n]);if(i)return i}}}r.r(e),r.d(e,{findTreeData:()=>s,lastChildren:()=>u,lastChildrenWithLabel:()=>l,listToTree:()=>c,toTreeDataWithSort:()=>f})},546:(t,e,r)=>{function n(t){var e,r=0,n=t.ownerDocument||t.document,o=n.defaultView||n.parentWindow;if(void 0!==o.getSelection){if((e=o.getSelection()).rangeCount>0){var i=e.getRangeAt(0),a=i.cloneRange();a.selectNodeContents(t),a.setEnd(i.endContainer,i.endOffset),r=a.toString().length}}else if((e=n.selection)&&"Control"!==e.type){var c=e.createRange(),u=n.body.createTextRange();u.moveToElementText(t),u.setEndPoint("EndToEnd",c),r=u.text.length}return r}function o(t,e){var r,n;n=e?t.lastChild.firstChild:t.firstChild,window.getSelection?(t.focus(),(r=window.getSelection()).selectAllChildren(n),r.collapseToEnd()):document.selection&&((r=document.selection.createRange()).moveToElementText(n),r.collapse(!1),r.select())}function i(t){return t=(t=(t=t.replace(/((\s|&nbsp;)*\r?\n){3,}/g,"\r\n\r\n")).replace(/^((\s|&nbsp;)*\r?\n)+/g,"")).replace(/((\s|&nbsp;)*\r?\n)+$/g,"")}function a(t){return i(t.replace(/\r?\n/g,"<br />").replace(/(\s|&nbsp;)+/g," "))}function c(t){return i(a(t))}r.r(e),r.d(e,{formatText:()=>c,getPosition:()=>n,keepLastIndex:()=>o,trimBr:()=>i,trimString:()=>a})},988:(t,e,r)=>{r.r(e),r.d(e,{isEmail:()=>m,isExist:()=>A,isExternal:()=>y,isHkGeneral:()=>j,isIdCard:()=>x,isLandlineNo:()=>b,isLiveCard:()=>E,isName:()=>w,isOtherIdCard:()=>P,isPassport:()=>S,isPassword:()=>T,isPhoneNo:()=>g,isSocialCode:()=>O,isTwGeneral:()=>L});var n=/^[1][0,1,2,3,4,5,6,7,8,9][0-9]{9}$/,o=/^(([0-9]{3,4}[-])?[0-9]{7,8}$)/,i=/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/,a=/^[1-9]\d{5}(?:18|19|20)\d{2}(?:0[1-9]|10|11|12)(?:0[1-9]|[1-2]\d|30|31)\d{3}[\dXx]$/,c=/^[HMhm]{1}([0-9]{10}|[0-9]{8})$/,u=/^\\d{8}|^[a-zA-Z0-9]{10}|^\\d{18}$/,l=/(^8)(10|20|30)([A-Za-z0-9]{15}$)/,f=/(^[A-Z]\d{8}$)|(^(([A-Z][A-Z])|(1[45]))\d{7}$)/,s=/^[0-9]{18}$/,d=/^([A-Z]{3})([0-9]{12})$/,h=/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)[a-zA-Z\d]{8,15}$/,p=/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[$@$!%*?&.])[A-Za-z\d$@$!%*?&.]{8,15}$/,v=/^([\u2E80-\uFE4F]{1}[\u2E80-\uFE4F\.·。]{0,48}[\u2E80-\uFE4F]{1}|[a-zA-Z\.\s]{1,50})$/;function y(t){return/^(https?:|mailto:|tel:)/.test(t)}function g(t){return n.test(t)}function b(t){return o.test(t)}function m(t){return i.test(t)}function w(t){return v.test(t)}function O(t){return/[0-9A-HJ-NPQRTUWXY]{2}\d{6}[0-9A-HJ-NPQRTUWXY]{10}/.test(t)}function x(t){return a.test(t)}function E(t){return l.test(t)}function j(t){return c.test(t)}function L(t){return u.test(t)}function S(t){return f.test(t)}function P(t){return s.test(t)||d.test(t)}function T(t){return h.test(t)||p.test(t)}function A(t){return Array.isArray(t)?t.length>0:null!=t&&""!==t||"[object Object]"===Object.prototype.toString.call(t)&&Object.keys(t).length>0}},577:(t,e,r)=>{var n={"./download.js":526,"./formatter.js":754,"./handleTree.js":912,"./selection.js":546,"./validate.js":988};function o(t){var e=i(t);return r(e)}function i(t){if(!r.o(n,t)){var e=new Error("Cannot find module '"+t+"'");throw e.code="MODULE_NOT_FOUND",e}return n[t]}o.keys=function(){return Object.keys(n)},o.resolve=i,t.exports=o,o.id=577}},e={};function r(n){var o=e[n];if(void 0!==o)return o.exports;var i=e[n]={exports:{}};return t[n](i,i.exports,r),i.exports}r.d=(t,e)=>{for(var n in e)r.o(e,n)&&!r.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},r.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var n={};(()=>{r.d(n,{A:()=>o,W:()=>t});var t={},e=r(577);e.keys().forEach((function(r){r.replace(/^\.\/(.*)\.\w+$/,"$1");var n=e(r),o=n.default||n;Object.keys(o).forEach((function(e){t[e]=o[e]}))}));var o=function e(r){e.installed||(r.prototype.$wt=t,e.installed=!0)};"undefined"!=typeof window&&window.Vue&&o(window.Vue)})();var o=n.A,i=n.W;export{o as default,i as utils};