sm-tool
Version:
sm-tool工具包
56 lines (35 loc) • 30.4 kB
JavaScript
;
Object.defineProperty(exports, '__esModule', { value: true });
var rxjs = require('rxjs');
var o = require('clipboard');
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
var o__default = /*#__PURE__*/_interopDefaultLegacy(o);
class StringUtil{static hasLength(t){return null!=t&&("string"==typeof t&&0!=(null==t?void 0:t.length)||"number"==typeof t)}static subStringWith(t,e,r){if(!(t&&t.includes(e)&&t.includes(r)))return "";const n=t.indexOf(e)+e.length,i=t.indexOf(r);return n<i?t.substring(n,i):""}static isNumberString(t,e){return this.hasLength(t)&&(e?/^\d+(\.\d+)?$/.test(t):/^\d+$/.test(t))}static jointStr2Arr(t,e=","){return t?(e||(e=","),t.includes(e)?t.split(e):[t]):[]}static trimAll(t){return this.hasLength(t)?t.replace(/\s/g,""):""}static desensitized(t,e,r,n="*"){if(!t)return "";if(e<0&&(e=0),e>=t.length&&(e=t.length-1),r<0&&(r=0),r>t.length&&(r=t.length),e>r){const t=e;e=r,r=t;}let i="";for(let t=0;t<(r-e||1);t++)i+=n||"";return t.substring(0,e)+i+t.substring(r)}static hasEmojiCharacter(t){let e;if(!t)return !1;if((null==t?void 0:t.length)>0)for(let r=0;r<t.length;r++){const n=t.charCodeAt(r);if(55296<=n&&n<=56319){if(t.length>1){e=t.charCodeAt(r+1);const i=1024*(n-55296)+(e-56320)+65536;if(118784<=i&&i<=128895)return !0}}else if(t.length>1){if(e=t.charCodeAt(r+1),8419==e)return !0}else {if(8448<=n&&n<=10239)return !0;if(11013<=n&&n<=11015)return !0;if(10548<=n&&n<=10549)return !0;if(12951<=n&&n<=12953)return !0;if(169==n||174==n||12349==n||12336==n||11093==n||11036==n||11035==n||11088==n)return !0}}return !1}}
class DictUtil{static obj2TextValueArray(t){return t?Object.keys(t).map((e=>({value:e,text:t[e],o:{value:e,text:t[e]}}))):[]}static objArray2TextValueArray(t,e="key",r="value",n="list",l="key",s="value"){var a;if(!t||0==t.length)return [];let o=[];for(let u of t){let t=[],i=u.hasOwnProperty(n);if(i){let e=u[n];if(e&&e.length>0)for(let r of e)r.hasOwnProperty(l)&&r.hasOwnProperty(s)&&t.push({value:r[l],text:r[s],o:{value:r[l],text:r[s],o:r}});}if(u.hasOwnProperty(e)&&u.hasOwnProperty(r)){let n={value:u[e],text:u[r],o:{value:u[e],text:u[r],o:u,subArr:t}};if(!i)try{null===(a=null==n?void 0:n.o)||void 0===a||delete a.subArr;}catch(t){console.warn(t);}o.push(n);}}return o}static objArray2KvOptsRecursive(t,e="value",r="value",n="label",l="text",s="children",a="children"){return Array.isArray(t)&&t.length>0?t.map((t=>{if(!t.hasOwnProperty(r)&&t.hasOwnProperty(e)&&(t[r]=t[e],delete t[e]),!t.hasOwnProperty(l)&&t.hasOwnProperty(n)&&(t[l]=t[n],delete t[n]),!t.hasOwnProperty(a)&&t.hasOwnProperty(s)&&(t[a]=t[s],delete t[s]),t[a]&&t[a].length>0)t[a]=DictUtil.objArray2KvOptsRecursive(t[a],e,r,n,l,s,a);else try{delete t[a];}catch(t){console.warn(t);}return t})):[]}static k2vTextValue(t,e){const r=(e||[]).find((e=>e.value===t));return r?r.text:""}static k2TextValue(t,e){return (e||[]).find((e=>e.value===t))}static v2kTextValue(t,e){const r=e||[];let n=0,l=null;for(const{value:e,text:s}of r)t===s&&(l=e,n++);return 1===n?l:null}static getTextsByKeys(t,e,r="value",n="text",l="children"){return DictUtil.getValuesOrItemsByKeys(t,e,!1,r,n,l)}static getItemsByKeys(t,e,r="value",n="text",l="children"){return DictUtil.getValuesOrItemsByKeys(t,e,!0,r,n,l)}static getValuesOrItemsByKeys(t,e,r=!1,n="value",l="text",s="children"){const a=[],o=(e||{length:0}).length;for(let t=0;t<o;t++)a.push("");if(!(t&&t.length>0&&(e||{length:0}).length>0))return a;const u=new Map,i=t=>{t&&t.length>0&&t.forEach((t=>{u.set(t[n],r?t:t[l]),i(t[s]);}));};return i(t),e.map((t=>u.get(t)))}static obj2SvInfoArray(t){return t?Object.keys(t).map((e=>({v:e,s:t[e],o:{v:e,s:t[e]}}))):[]}static objArray2SvInfoArray(t,e="key",r="value",n="list",l="key",s="value"){if(!t||0==t.length)return [];let a=[];for(let o of t){let t=[],u=o.hasOwnProperty(n);if(u){let e=o[n];if(e&&e.length>0)for(let r of e)r.hasOwnProperty(l)&&r.hasOwnProperty(s)&&t.push({v:r[l],s:r[s],o:{v:r[l],s:r[s],o:r}});}if(o.hasOwnProperty(e)&&o.hasOwnProperty(r)){let n={v:o[e],s:o[r],o:{v:o[e],s:o[r],o,subSvInfos:t}};if(!u)try{delete n.o.subSvInfos;}catch(t){console.warn(t);}a.push(n);}}return a}static k2vSVInfo(t,e){const r=(e||[]).find((e=>e.v===t));return r?r.s:""}static k2SVInfo(t,e){return (e||[]).find((e=>e.v===t))}static v2kSVInfo(t,e){const r=e||[];let n=0,l=null;for(const{v:t,s:e}of r)t===e&&(l=t,n++);return 1===n?l:null}static topUpKvOpts(t,e,r="value"){if(!(t&&t.length>0&&e))return t;const n=t.findIndex((t=>t[r]===e));if(-1===n)return t;const l=t[0];return t[0]=t[n],t[n]=l,t}static jointStr2Arr(e,r=","){return StringUtil.jointStr2Arr(e,r)}}
exports.PlatformType = void 0;!function(e){e[e.IOS_TYPE=1]="IOS_TYPE",e[e.ANDROID_TYPE=2]="ANDROID_TYPE",e[e.OTHER_TYPE=3]="OTHER_TYPE",e[e.WeiXinBrowser_TYPE=4]="WeiXinBrowser_TYPE";}(exports.PlatformType||(exports.PlatformType={}));class OtherUtil{static debounce(e,t=300,r="_custom_debounce"){const o=Symbol.for(r);let n=window[o];const i=(e,t)=>{t&&n&&clearTimeout(n),n=e,window[o]=e;};return function(){n&&i(void 0,!0),i(setTimeout(e,t));}}static throttle(e,t=300,r="_custom_throttle"){const o=Symbol.for(r);let n=window[o];const i=e=>{n=e,window[o]=e;};return null==n&&i(0),function(){const r=(new Date).getTime();r-n>t&&(e(),i(r));}}static logThisData(e){if(!e)return void console.warn("没有传入_this参数");const t={};Object.keys(e).filter((t=>!(t.startsWith("$")||t.startsWith("_")||e[t]instanceof Function||-1!==["options","route"].indexOf(t)||t.endsWith("Util")))).forEach((r=>t[r]=e[r]));let r=e.route;r.includes("/")&&(r=r.split("/"),r.length>=2&&"index"===r[r.length-1]&&(r=r[r.length-2])),console.log(`【${r}】数据:`,t);}static deepCopy(e){let t=e;if(Array.isArray(e)){t=[];for(let r=0;r<e.length;r++)t.push(this.deepCopy(e[r]));}else {if("object"!=typeof e||null==e)return t;t={};for(let r in e)t[r]=this.deepCopy(e[r]);}return t}static deleteAttributes(e,t=[],r){try{if(r){if("object"==typeof e&&null!=e)for(const r in e)e.hasOwnProperty(r)&&(null==t?void 0:t.indexOf(r))>-1&&delete e[r];}else if(Array.isArray(e))for(const o of e)this.deleteAttributes(o,t,r);else if("object"==typeof e&&null!=e)for(const o in e)e.hasOwnProperty(o)&&((null==t?void 0:t.indexOf(o))>-1?delete e[o]:this.deleteAttributes(e[o],t,r)),this.deleteAttributes(e[o],t,r);}catch(e){console.warn(e);}}static slimApiData(e,t=30){try{if(Array.isArray(e))for(let r=0;r<e.length;r++)e[r]=this.slimApiData(e[r],t);else if("object"==typeof e&&null!=e)for(const r in e)e.hasOwnProperty(r)&&(e[r]=this.slimApiData(e[r],t));else if("string"==typeof e&&(null==e?void 0:e.length)>t)return e.substring(0,t)}catch(e){console.warn(e);}return e}static generateApiInterface(e,t={},r=[],o="@"){const n=(e,t={},r=[],o="@")=>{if(e){if("object"==typeof e){for(const i in e)if(e.hasOwnProperty(i)){const s=e[i];if("string"==typeof s)t[i]=`${o}string; // "${s}"${o}`;else if("number"==typeof s)t[i]=`${o}number; // ${s}${o}`;else if("boolean"==typeof s)t[i]=`${o}boolean; // ${s}${o}`;else if(s){if(Array.isArray(s))if(0===s.length)t[i]=`${o}any[]${o}`;else {const e=s[0];"string"==typeof e?t[i]=`${o}string[]; // [${s}]${o}`:"number"==typeof e?t[i]=`${o}number[]; // [${s}]${o}`:"boolean"==typeof e?t[i]=`${o}boolean[]; // [${s}]${o}`:e||(t[i]=`${o}any[]; // [${s}]${o}`);}else if("object"==typeof s){const e="I"+i.charAt(0).toUpperCase()+i.substring(1);r.push(`export interface ${e} {}`),t[i]=n(s,t[i],r,o);}}else t[i]=`${o}any; // ${s}${o}`;}}else console.error("必须传入object类型");return t}},i=n(e,t,r,o);return i?{templateApi:i,subInterfaceArrStr:r.join("\n")}:{templateApi:null,subInterfaceArrStr:""}}static unquoteKeys(e){return e.replace(/"(\\[^]|[^\\"])*"\s*:?/g,(e=>/:$/.test(e)?e.replace(/^"|"(?=\s*:$)/g,""):e))}static getJsType(e){return Object.prototype.toString.call(e).slice(8,-1)}static isArrayHasLength(e){return e&&Array.isArray(e)&&e.length>0}static getSystemPlatformType(){return /(iPhone|iPad|iPod|iOS)/i.test(navigator.userAgent)?exports.PlatformType.IOS_TYPE:/(Android)/i.test(navigator.userAgent)?exports.PlatformType.ANDROID_TYPE:exports.PlatformType.OTHER_TYPE}static isPlatformWeiXinBrowser(){return /micromessenger/i.test(navigator.userAgent)}static filterMoney(e,t){let r="";for(let t of e)"0123456789.".indexOf(t)>-1&&(r+=t);let o=r.indexOf(".");o>-1&&(r=r.replace(/\./g,""),r=r.slice(0,o)+"."+r.slice(o));/(^[1-9][0-9]*$|^0$)|((^[1-9][0-9]*|^0)[\.](\d)*$)/.test(r)||(r=r.slice(0,-1));let n=/\d+\.(\d*)$/g.exec(r);return n&&n.length>0&&n[1].length>t&&(r=r.slice(0,-1)),r}static deepToRaw(e,t=(e=>e)){if("object"!=typeof e||null===e)return e;if(Array.isArray(e))return e.map((e=>OtherUtil.deepToRaw(e,t)));const r=t(e);for(const o in e)e.hasOwnProperty(o)&&(r[o]=OtherUtil.deepToRaw(e[o],t));return r}}
class DataConverterUtil{static convert2ObjIfNeed(e){if("string"==typeof e)try{return JSON.parse(e)}catch(t){return console.log("转换Json字符串失败"),e}return e}static convert2UrlParams(e){if(!e)return "";let t="";for(const n of Object.keys(e)){const i=e[n];var r=encodeURIComponent(n)+"=";if(null!==i&&""!==i&&void 0!==i)if("object"==typeof i){for(const e of Object.keys(i))if(null!==i[e]&&""!==i[e]&&void 0!==i[e]){t+=encodeURIComponent(n+"["+e+"]")+"="+encodeURIComponent(i[e])+"&";}}else t+=r+encodeURIComponent(i)+"&";}return t}static getParamFromUrl(e,t){if(!e||!/[?]/.test(e))return null;const r=e.split("?")[1].split("&");let n={};for(let e=0;e<r.length;e++){const t=r[e].split("=");n[t[0]]=t.length>1?t[1]:"";}return t?n[t]:n}static jointStr2Arr(t,r=","){return StringUtil.jointStr2Arr(t,r)}static format2Percent(e,t=2){if(null==e)return "";if(0==e)return 0;if((e+"").endsWith("%"))return e;null==t&&(t=2);try{let r=Number(e);return isNaN(r)?e:(100*r).toFixed(t).replace(".00","")+"%"}catch(e){console.error("转换百分数失败",e);}}static formatPercent2Decimal(e,t=2){if(null==e)return 0;if((null==t||t<0)&&(t=2),"number"==typeof e)return Number(Number(e).toFixed(t));if("string"==typeof e){if(/%$/.test(e)){let r=Number(e.substring(0,e.length-1));if(!isNaN(r))return Number((r/100).toFixed(t))}if(!isNaN(Number(e)))return Number(Number(e).toFixed(t))}return 0}static format2Currency(e,t=""){return null==e?"":(e+"").replace(/\B(?=(\d{3})+$)/g,",")+t}static deepMergeWithDedupe(e,t){if(Array.isArray(e)&&Array.isArray(t)){const r=[...e,...t].reduce(((e,t)=>{const r=DataConverterUtil.findIndex(e,(e=>DataConverterUtil.isSameTypeElement(e,t)));return r>-1?e[r]=DataConverterUtil.deepMergeWithDedupe(e[r],t):e.push(DataConverterUtil.deepClone(t)),e}),[]);return DataConverterUtil.deduplicateArray(r)}if(DataConverterUtil.isPlainObject(e)&&DataConverterUtil.isPlainObject(t)){const r=Object.assign({},e);for(const e of Object.keys(t)){const n=t[e];e in r&&null!=n?r[e]=DataConverterUtil.deepMergeWithDedupe(r[e],n):null!=DataConverterUtil.deepClone(n)&&(r[e]=DataConverterUtil.deepClone(n));}return r}return DataConverterUtil.deepClone(t)}}DataConverterUtil.isPlainObject=e=>"[object Object]"===Object.prototype.toString.call(e),DataConverterUtil.isSameTypeElement=(e,t)=>typeof e==typeof t&&(Array.isArray(e)===Array.isArray(t)&&(DataConverterUtil.isPlainObject(e)&&DataConverterUtil.isPlainObject(t)?JSON.stringify(e)===JSON.stringify(t):e===t)),DataConverterUtil.deduplicateArray=e=>e.filter(((t,r,n)=>r===DataConverterUtil.findIndex(e,(e=>JSON.stringify(e)===JSON.stringify(t))))),DataConverterUtil.deepClone=e=>void 0===e?void 0:JSON.parse(JSON.stringify(e)),DataConverterUtil.findIndex=(e,t)=>{for(let r=0;r<e.length;r++)if(t(e[r]))return r;return -1};
class DateUtil{static dateFormat(e,t="yyyy-MM-dd"){if(null==e)return "";const r={Year:0,TYear:"0",Month:0,TMonth:"0",Day:0,TDay:"0",Hour:0,THour:"0",hour:0,Thour:"0",Minute:0,TMinute:"0",Second:0,TSecond:"0",Millisecond:0};let i;return i="number"==typeof e?new Date(e):"string"==typeof e?new Date(DateUtil.compatibleDateOfIos(e)):e,r.Year=i.getFullYear(),r.TYear=String(r.Year).substr(2),r.Month=i.getMonth()+1,r.TMonth=r.Month<10?"0"+r.Month:String(r.Month),r.Day=i.getDate(),r.TDay=r.Day<10?"0"+r.Day:String(r.Day),r.Hour=i.getHours(),r.THour=r.Hour<10?"0"+r.Hour:String(r.Hour),r.hour=r.Hour<13?r.Hour:r.Hour-12,r.Thour=r.hour<10?"0"+r.hour:String(r.hour),r.Minute=i.getMinutes(),r.TMinute=r.Minute<10?"0"+r.Minute:String(r.Minute),r.Second=i.getSeconds(),r.TSecond=r.Second<10?"0"+r.Second:String(r.Second),r.Millisecond=i.getMilliseconds(),t.replace(/yyyy/gi,String(r.Year)).replace(/yyy/gi,String(r.Year)).replace(/yy/gi,r.TYear).replace(/y/gi,r.TYear).replace(/MM/g,r.TMonth).replace(/M/g,String(r.Month)).replace(/dd/gi,r.TDay).replace(/d/gi,String(r.Day)).replace(/HH/g,r.THour).replace(/H/g,String(r.Hour)).replace(/hh/g,r.Thour).replace(/h/g,String(r.hour)).replace(/mm/g,r.TMinute).replace(/m/g,String(r.Minute)).replace(/ss/gi,r.TSecond).replace(/s/gi,String(r.Second)).replace(/fff/gi,String(r.Millisecond)).replace(/SSS/gi,String(r.Millisecond)).replace(/sss/gi,String(r.Millisecond))}static compatibleDateOfIos(e){"string"==typeof e&&(e.indexOf(".")>-1&&(e=e.substring(0,e.indexOf("."))),e=e.replace(/-/g,"/"));if(2===e.split("").reduce(((e,t,r,i)=>e+("/"===t?1:0)),0)){const t=e.split("/"),r=t[1],i=t[2].indexOf(" ")>-1?t[2].split(" ")[0]:t[2];1===r.length&&(t[1]="0"+r),1===i.length&&(t[2]="0"+t[2]),e=t.join("/");}return e}static compare(e,t){if(!e&&t)return -1;if(e&&!t)return 1;if(!e&&!t)return 0;const r=DateUtil.compatibleDateOfIos(e),i=DateUtil.compatibleDateOfIos(t);return r<i?-1:r>i?1:0}}
class FileUtil{static base64ToFile(e,t="文件名称.png",n="image/png"){const a=e.split(","),r=atob(a[1]),o={type:n,endings:"native"},s=new Uint8Array(r.length);for(let e=0;e<r.length;e++)s[e]=r.charCodeAt(e);return new File([s],t,o)}static fileToBase64(e,t="image/png"){return `data:${t};base64,`+btoa(new Uint8Array(e).reduce(((e,t)=>e+String.fromCharCode(t)),""))}static fileToBase64Async(e){return new Promise(((t,n)=>{const a=new FileReader;a.onload=function(e){var n;const a=(null===(n=null==e?void 0:e.target)||void 0===n?void 0:n.result)||"";t(a);},a.readAsDataURL(e);}))}static base64ToBlob(e,t="image/png"){t=this.base64MimeType(e)||t;const n=atob(this.base64PrefixRemove(e));let a=n.length;const r=new Uint8Array(a);for(;a--;)r[a]=n.charCodeAt(a);return new Blob([r],{type:t})}static blob2Base64(e,n){return new rxjs.Observable((t=>{"text/xml"===e.type&&t.error("不支持text/xml的文件类型转成base64");const a=new FileReader;a.readAsDataURL(e),a.onload=e=>{let a=e.target.result.toString();const r=a.substring(a.indexOf(",")+1,a.length);(null==a?void 0:a.indexOf("application/octet-stream"))>-1&&(null==n?void 0:n.length)>0&&(a="data:image/jpeg;base64,".replace("jpeg",n.substring(n.indexOf(".")+1))+r),t.next(a),t.complete();},a.onerror=e=>{console.log("文件流转换base64失败:"+e),t.error(e);};}))}static anyPicBase64ToAnyPicBase64(e,t="image/png"){return new Promise(((n,a)=>{if(e)try{let r=FileUtil.base64ToBlob(e,t),o=URL.createObjectURL(r),s=new Image;s.onload=function(){let e=document.createElement("canvas");e.width=s.width,e.height=s.height;let r=e.getContext("2d");if(r){r.drawImage(s,0,0);let a=e.toDataURL(t);n(a),URL.revokeObjectURL(o);}else a("创建Canvas实例失败");},s.src=o;}catch(e){a("转换图片格式失败");}else n("");}))}static blob2Base64s(n,a){if((null==n?void 0:n.length)<=0)return new rxjs.Observable((e=>{e.next([]),e.complete();}));const r=[];for(let e=0;e<n.length;e++)r.push(this.blob2Base64(n[e],(null==a?void 0:a.length)>0?a[e]:".png"));return rxjs.forkJoin(r)}static file2Utf8Str(e){return new rxjs.Observable((t=>{const n=new FileReader;n.onload=e=>{const n=e.target.result.split(","),a=atob(n[1]),r=new TextDecoder("utf-8").decode(new Uint8Array(a.length).map(((e,t)=>a.charCodeAt(t))));t.next(r),t.complete();},n.readAsDataURL(e);}))}static base64PrefixAdd(e,t="data:image/png;base64,"){return !e||e&&e.indexOf("base64,")>-1?e:t+e}static base64PrefixAddPng(e){return this.base64PrefixAdd(e,"data:image/png;base64,")}static base64PrefixAddSvg(e){return this.base64PrefixAdd(e,"data:image/svg+xml;base64,")}static base64PrefixRemove(e){return e&&e.indexOf("base64,")>-1?e.substring(e.indexOf("base64,")+7):e}static base64Prefix(e){return (null==e?void 0:e.indexOf(","))>-1?e.split(",")[0]:""}static base64MimeType(e){return (null==e?void 0:e.indexOf(":"))>-1&&(null==e?void 0:e.indexOf(";"))>-1?StringUtil.subStringWith(e,":",";"):""}static downLoadFileWithBlobUrl(e,t="pdf",n="file.pdf"){if(!e)return;let a=new XMLHttpRequest;a.open("get",e),a.send(null),a.responseType="arraybuffer",a.onreadystatechange=()=>{if(4==a.readyState&&200==a.status&&(console.log(a.response),"object"==typeof a.response)){const e=a.response,r=new Blob([e],{type:t});try{if(window.navigator.msSaveOrOpenBlob)navigator.msSaveBlob(r,n);else {const e=document.createElement("a"),t=document.querySelector("body");e.href=window.URL.createObjectURL(r),e.download=n,e.style.display="none",t&&(t.appendChild(e),e.click(),t.removeChild(e),window.URL.revokeObjectURL(e.href));}}catch(e){console.error("当前设备环境不支持下载",e);}}};}static compressImg(e,t=.66,n="image/png"){return new Promise(((a,r)=>{const o=new FileReader;o.readAsDataURL(e),o.onload=()=>{const r=new Image;r.src=o.result,r.onload=()=>{const o=r.width,s=r.height,i=document.createElement("canvas");i.width=o,i.height=s;const l=i.getContext("2d");if(l){l.fillStyle="#fff",l.fillRect(0,0,i.width,i.height),l.drawImage(r,0,0,o,s);const e=i.toDataURL(n,t),c=this.base64ToBlob(e);console.log("压缩后的file:",c),a(c);}else console.warn("当前环境不支持Canvas,无法压缩图片"),a(e);};};}))}static uBytes2Blob(e,t="text/plain"){const n=new Array(e.length);for(let t=0;t<e.length;t++)n[t]=e.charCodeAt(t);return new Blob([new Uint8Array(n)],{type:`${t};charset=UTF-8`})}static encodeStr2Hex(e){const t=[];for(let n=0;n<e.length;n++)t[n]=("00"+e.charCodeAt(n).toString(16)).slice(-4);return "\\u"+t.join("\\u")}static decodeHex2Str(e){try{return unescape(e.replace(/\\/g,"%"))}catch(t){return console.warn("解码异常",t),e}}}
class IdCardUtil{static isIDCard(t,r,n){let e,s;const i=[7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2],d=["","","","","","","","","","","","北京","天津","河北","山西","内蒙古","","","","","","辽宁","吉林","黑龙江","","","","","","","","上海","江苏","浙江","安微","福建","江西","山东","","","","河南","湖北","湖南","广东","广西","海南","","","","重庆","四川","贵州","云南","西藏","","","","","","","陕西","甘肃","青海","宁夏","新疆","","","","","","台湾","","","","","","","","","","香港","澳门","","","","","","","","","国外"];let u,o,c=t.match(/^(\d{2})\d{4}(((\d{2})(\d{2})(\d{2})(\d{3}))|((\d{4})(\d{2})(\d{2})((\d{3})[X\d])))$/i);if(null==c)return !1;if(c[1]>=d.length||""==d[c[1]])return !1;if(12==c[2].length?(s=t.substr(0,17),u=[c[9],c[10],c[11]].join("-"),o=c[13]):(s=t.substr(0,6)+"19"+t.substr(6),u=["19"+c[4],c[5],c[6]].join("-"),o=c[7]),n&&""!=n&&o%2!=n%2)return !1;if(r&&""!=r&&r!=u)return !1;if(c=u.match(/^((19|20)\d{2})[-](\d{2})[-](\d{2})$/),!c)return !1;const g=c[1],a=1*c[3]-1,l=c[4];if(e=new Date(g,a,l),"object"!=typeof e||e.getFullYear()!=g||e.getMonth()!=a||e.getDate()!=l)return !1;let b=0;for(let t=0;t<=16;t++)b+=s.charAt(t)*i[t];return s+="10X98765432".charAt(b%11),15==t.length||18==t.length&&t==s}static isIdCard18(t){return /^(\d{6})(\d{4})(\d{2})(\d{2})(\d{3})([0-9]|X)$/.test(t)}static getSexByIdCard(t){if(!this.isIDCard(t))return console.error("传入的参数不是有效的身份证号码:"+t),0;const r=18===t.length?t.charAt(16):t.charAt(14);return Number(r)%2==0?2:1}static getBirthdayByIdCard(t){let r="";return this.isIDCard(t)?(18==t.length?r=t.substring(6,10)+"-"+t.substring(10,12)+"-"+t.substring(12,14):15==t.length&&(r="19-"+t.substring(6,8)+"-"+t.substring(8,10)),r):(console.error("传入的参数不是有效的身份证号码:"+t),r)}static getArea(t){const r=t,n={Province:"",City:"",Country:""};let e=0;const s=r.indexOf("省");-1===s?(e=r.indexOf("自治区"),n.Province=-1!==e?r.substring(0,e+3):r.substring(0,0)):n.Province=r.substring(0,s+1);const i=r.indexOf("市");n.City=-1===e?r.substring(e+1,i+1):0===e?r.substring(s+1,i+1):r.substring(e+3,i+1);let d=r.lastIndexOf("区");return -1===d?(d=r.indexOf("县"),n.Country=r.substring(i+1,d+1)):n.Country=r.substring(i+1,d+1),""===n.Province&&""!==n.City&&-1!=["北京市","上海市","重庆市","天津市"].indexOf(n.City)&&(n.Province=n.City),n}}
class RandomUtil{static randomChoose(t){if(!t||0===t.length)return null;const a=t.length;return t[Math.floor(Math.random()*a)]}static randomChooseBatches(t,a=1){if(!t||0===t.length)return null;const r=t.filter((()=>!0)),o=r.length;let e=a>=1&&a<=o?a:Math.ceil(Math.random()*o),n=[];for(;e-- >0;)n=n.concat(r.splice(Math.floor(Math.random()*r.length),1));return n}static randomInt(t,a){const r=t<=a?t:a,o=t<=a?a:t;return Math.floor(Math.random()*(o-r))+r}static randomColor(t){const a=Math.floor(256*Math.random()),r=Math.floor(256*Math.random()),o=Math.floor(256*Math.random());if(t){const t=t=>Number(t).toString(16).toUpperCase();return `#${t(a)}${t(r)}${t(o)}`}return `rgba(${a}, ${r}, ${o}, 1)`}static randomCreate(t){let a="";switch(t){case"MOBILE_PHONE":a=this.randomCreateMobilePhone();break;case"ID_CARD":a=this.randomCreateIdCard();break;case"PERSON_NAME":a=this.randomCreatePersonName();break;case"BANK_CARD_NO":a=this.randomCreateBankCardNo();}return a}static randomCreateMobilePhone(){const t=["130","131","132","133","135","137","138","170","187","189"];let a=t[Math.floor(Math.random()*t.length)];for(let t=0;t<8;t++)a+=Math.floor(10*Math.random());return a}static randomCreateIdCard(){const t=["7","9","10","5","8","4","2","1","6","3","7","9","10","5","8","4","2"],a="420101",r="19810101",o=Math.floor(10*Math.random()).toString()+Math.floor(10*Math.random()).toString()+Math.floor(10*Math.random()).toString(),e=(a+r+o).split("");let n=0;for(let a in e)n+=parseInt(e[a])*parseInt(t[a]);return a+r+o+["1","0","X","9","8","7","6","5","4","3","2"][parseInt(String(n%11))]}static randomCreatePersonName(){const t=["赵","钱","孙","李","周","吴","郑","王","冯","陈","褚","卫","蒋","沈","韩","杨","朱","秦","尤","许","何","吕","施","张","孔","曹","严","华","金","魏","陶","姜","戚","谢","邹","喻","柏","水","窦","章","云","苏","潘","葛","奚","范","彭","郎","鲁","韦","昌","马","苗","凤","花","方","俞","任","袁","柳","酆","鲍","史","唐","费","廉","岑","薛","雷","贺","倪","汤","滕","殷","罗","毕","郝","邬","安","常","乐","于","时","傅","皮","卞","齐","康","伍","余","元","卜","顾","孟","平","黄","和","穆","萧","尹"],a=["子璇","淼","国栋","夫子","瑞堂","甜","敏","尚","国贤","贺祥","晨涛","昊轩","易轩","益辰","益帆","益冉","瑾春","瑾昆","春齐","杨","文昊","东东","雄霖","浩晨","熙涵","溶溶","冰枫","欣欣","宜豪","欣慧","建政","美欣","淑慧","文轩","文杰","欣源","忠林","榕润","欣汝","慧嘉","新建","建林","亦菲","林","冰洁","佳欣","涵涵","禹辰","淳美","泽惠","伟洋","涵越","润丽","翔","淑华","晶莹","凌晶","苒溪","雨涵","嘉怡","佳毅","子辰","佳琪","紫轩","瑞辰","昕蕊","萌","明远","欣宜","泽远","欣怡","佳怡","佳惠","晨茜","晨璐","运昊","汝鑫","淑君","晶滢","润莎","榕汕","佳钰","佳玉","晓庆","一鸣","语晨","添池","添昊","雨泽","雅晗","雅涵","清妍","诗悦","嘉乐","晨涵","天赫","玥傲","佳昊","天昊","萌萌","若萌"];return t[Math.floor(Math.random()*t.length)]+a[Math.floor(Math.random()*a.length)]}static randomCreateBankCardNo(t){let a={104:"621661",302:"622689",304:"622630",305:"622622",309:"622908",310:"621717",315:"622323",316:"622309","0102":"622202","0103":"622848","0105":"622700","0301":"622262","0303":"622666","0306":"622556","0308":"622588","0410":"622155"},r="";if(!t){const r=Object.keys(a);t=r[Math.floor(Math.random()*r.length)];}r=a[t];for(let t=0;t<13;t++)r+=Math.floor(10*Math.random());return r}static randomPageData(t,a=1,r=10,o=52){const e={pageNo:a,pageSize:r,totalCount:t&&Array.isArray(t)?t.length:o,pageCount:0,resultList:[]},n=Math.ceil(e.totalCount/e.pageSize),l=e.totalCount%e.pageSize;if(e.pageCount=n,0==n||a>n||a<0||parseInt(a+"")!=a)e.resultList=[];else {const o=0!=l&&a==n?l:e.pageSize;let s=null;for(let n=0;n<o;n++)s=t&&"function"==typeof t?t(r*(a-1)+(n+1)):t&&Array.isArray(t)?t[e.pageSize*(e.pageNo-1)+n]:{id:`id-${r*(a-1)+(n+1)}`,name:RandomUtil.randomCreate("PERSON_NAME"),position:RandomUtil.randomChoose(["职员","经理人","CEO","董事长"])},e.resultList.push(s);}return e}}
class RegularUtil{}RegularUtil.Email=/^([a-z0-9A-Z]+[-|.]?)+[a-z0-9A-Z]@([a-z0-9A-Z]+(-[a-z0-9A-Z]+)?\.)+[a-zA-Z]{2,}$/,RegularUtil.PostCode=/^\d{6}$/,RegularUtil.Mobile=/^1[23456789]\d{9}$/,RegularUtil.Telephone=/^\d{2,5}-?\d{7,8}$/,RegularUtil.Base64=/^\s*data:([a-z]+\/[a-z0-9-+.]+(;[a-z-]+=[a-z0-9-]+)?)?(;base64)?,([a-z0-9!$&',()*+;=\-._~:@\/?%\s]*?)\s*$/i;
class ValidatorUtil{static isEmpty(t,i=["null","undefined"]){return !!(null==t||""===t||i&&i.indexOf(t)>-1)||(t instanceof Array&&0===t.length||t instanceof Object&&"{}"===JSON.stringify(t))}static isNullOrUndefined(t){return null==t}static isArrayEmpty(t){return !(Array.isArray(t)&&t&&t.length>0)}static isMobile(i){return RegularUtil.Mobile.test(i)}static isTelephone(i){return RegularUtil.Telephone.test(i)}static isMobileOrTelephone(t){return this.isMobile(t)||this.isTelephone(t)}static isEmail(i){return RegularUtil.Email.test(i)}static isPostCode(i){return RegularUtil.PostCode.test(i)}static isSocialUnicode(t){return /^[^_IOZSVa-z\W]{2}\d{6}[^_IOZSVa-z\W]{10}$/g.test(t)}static isNumberString(t,e){return StringUtil.isNumberString(t,e)}static isPureHanZi(t){return /[\u4e00-\u9fa5]/g.test(t)}static isBlob(t){return "application/json"!==(null==t?void 0:t.type)}static isPropertyHasValue(t,i){return (null==t?void 0:t.hasOwnProperty(i))&&null!=t[i]&&null!=t[i]}}
class HtmlUtil{static copyTextPcAndMobile(e,c){try{if(!o__default["default"])return void console.log("需要安装clipboard插件");if(o__default["default"].isSupported()){const t=o__default["default"].copy(e);console.log(t),(null==t?void 0:t.length)>0&&c&&c(!0,"复制成功");}else c&&c(!1,"不支持该设备");}catch(o){console.error(o);}}static copyTextPc(o,e){if(navigator.clipboard)navigator.clipboard.writeText(o).then((()=>{e&&e(!0,"复制成功!");})).catch((()=>{e&&e(!0,"复制失败!");}));else {const c=document.createElement("input");c.value=o,document.body.appendChild(c),c.select();try{document.execCommand("copy"),document.body.removeChild(c),document.execCommand("copy")?e&&e(!0,"复制成功!"):e&&e(!1,"复制失败!");}catch(o){console.error(o),e&&e(!1,"复制失败!");}document.execCommand("copy"),document.body.removeChild(c),document.execCommand("copy")?e&&e(!0,"复制成功!"):e&&e(!1,"复制失败!");}}}
class TreeUtil{static toTree(r,e="id",t="parentId",n="children",i="level",s=1,l){i||(i="level");const o=[];let a={};if(!r)return [];for(let t in r)a[r[t][e]]=r[t];r.forEach((r=>{let e=a[r[t]];e?(e[n]||(e[n]=[])).push(r):o.push(r);}));const c=(r,e)=>{if(r)if(Array.isArray(r))for(let t=0;t<r.length;t++)Object.prototype.hasOwnProperty.call(r[t],i)||(r[t][i]=e),c(r[t][n],e+1),l&&l(r[t]);else Object.prototype.hasOwnProperty.call(r,i)||(r[i]=e),l&&l(r);};return c(o,s),o}static toList(r,e="children"){if(!r)return [];const t=(r,n=[])=>{if(!r)return n||[];if(Array.isArray(r)&&r.length>=0)for(let e of r)t(e,n);else {const i=r[e];delete r[e],n.push(r),t(i,n);}return n};return t(r)}static toListWithCallback(r,e="children",t){const n=[],i=r=>{if(r&&(!Array.isArray(r)||0!==r.length))if(Array.isArray(r))for(const e of r)i(e);else {t&&t(r);const s=r[e];delete r[e],n.push(r),i(s);}};return i(r),n}static searchTree(r,e="id",t="parentId",n="children",i=(r=>!0)){if(!r)return [];const s=(r,t={})=>{if(!r)return t;if(Array.isArray(r)&&r.length>=0)for(let e of r)s(e,t);else i&&i(r)&&(t[r[e]]=1),s(r[n],t);return t},l=s(r),o=r=>!!r&&(!!l[r[e]]||!!(Array.isArray(r[n])&&r[n].length>0)&&r[n].some((r=>o(r)))),a=(r,e=[])=>{if(!r)return e||[];if(Array.isArray(r)&&r.length>=0)for(let t of r)a(t,e);else {const t=r[n];if(o(r)){const t=Object.assign({},r);delete t[n],e.push(t);}a(t,e);}return e},c=a(r);return this.toTree(c,e,t,n)}static findNodeById(r,e,t="id",n="children"){const i=r=>{if(!r||Array.isArray(r)&&0===r.length)return null;if(Array.isArray(r)){let e=null;for(const t of r)if(e=i(t),e)return e;return null}return r[t]===e?r:i(r[n])};return i(r)}static findParentNode(r,e,t="id",n="parentId",i="children"){const s=this.findNodeById(r,e,t,i);return s?this.findNodeById(r,s[n],t,i):null}}
class CacheUtil{static set(t,e){localStorage&&null!=t&&null!=e&&localStorage.setItem(t,e);}static get(t){return localStorage?null==t?null:localStorage.getItem(t):null}static setJSON(t,e){null!=e&&this.set(t,JSON.stringify(e));}static getJSON(t){const e=this.get(t);if(null!=e)return JSON.parse(e)}static remove(t){localStorage.removeItem(t);}static setSession(t,e){sessionStorage&&null!=t&&null!=e&&sessionStorage.setItem(t,e);}static getSession(t){return sessionStorage?null==t?null:sessionStorage.getItem(t):null}static setJSONSession(t,e){null!=e&&this.set(t,JSON.stringify(e));}static getJSONSession(t){const e=this.get(t);if(null!=e)return JSON.parse(e)}static removeSession(t){sessionStorage.removeItem(t);}}
class CacheTtlUtil{}
class CustomUtil{constructor(){}}CustomUtil.DateUtil=DateUtil,CustomUtil.StringUtil=StringUtil,CustomUtil.DictUtil=DictUtil,CustomUtil.ValidatorUtil=ValidatorUtil,CustomUtil.RegularUtil=RegularUtil,CustomUtil.RandomUtil=RandomUtil,CustomUtil.IdCardUtil=IdCardUtil,CustomUtil.FileUtil=FileUtil,CustomUtil.DataConverterUtil=DataConverterUtil,CustomUtil.HtmlUtil=HtmlUtil,CustomUtil.TreeUtil=TreeUtil,CustomUtil.CacheUtil=CacheUtil,CustomUtil.CacheTtlUtil=CacheTtlUtil,CustomUtil.OtherUtil=OtherUtil;
exports.CacheTtlUtil = CacheTtlUtil;
exports.CacheUtil = CacheUtil;
exports.CustomUtil = CustomUtil;
exports.DataConverterUtil = DataConverterUtil;
exports.DateUtil = DateUtil;
exports.DictUtil = DictUtil;
exports.FileUtil = FileUtil;
exports.HtmlUtil = HtmlUtil;
exports.IdCardUtil = IdCardUtil;
exports.OtherUtil = OtherUtil;
exports.RandomUtil = RandomUtil;
exports.RegularUtil = RegularUtil;
exports.StringUtil = StringUtil;
exports.ValidatorUtil = ValidatorUtil;