@wdslib/go-utils 0.2.3 → 0.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import e from"axios";import t,{uniq as i}from"lodash";import r from"crypto-js";function o(e,t,i,r){return new(i||(i=Promise))((function(o,a){function n(e){try{l(r.next(e))}catch(e){a(e)}}function s(e){try{l(r.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(n,s)}l((r=r.apply(e,t||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const a=5e3,n=5e3,s=(t="",i)=>{let r=e.create({baseURL:t,timeout:a,headers:{"Content-Type":"application/x-www-form-urlencoded;charset=UTF-8"}});return r.interceptors.request.use((function(e){return sessionStorage.getItem("anov-go-token")&&"null"!=sessionStorage.getItem("anov-go-token")&&(e.headers["X-ANOV-ACCESS-TOKEN"]=sessionStorage.getItem("anov-go-token")),sessionStorage.getItem("unify-access-token")&&"null"!=sessionStorage.getItem("unify-access-token")&&(e.headers["X-UNIFY-ACCESS-TOKEN"]=sessionStorage.getItem("unify-access-token")),sessionStorage.getItem("dgcc_authorization")&&"null"!=sessionStorage.getItem("dgcc_authorization")&&(e.headers.dgcc_authorization=sessionStorage.getItem("dgcc_authorization")),"post"===e.method?(e.headers["Content-Type"]="application/json;",e):"get"===e.method?e:"put"===e.method?(e.headers["Content-Type"]="application/json; charset=UTF-8",e):"delete"===e.method?e:void 0}),(function(e){return Promise.reject(e)})),r.interceptors.response.use((function(e){return 200===e.status||e.data.code,i&&i(e),e.data}),(function(e){return i&&i(null==e?void 0:e.response),Promise.reject(e.response)})),r};function l(e,t=!1){return t?d(e)?e:JSON.stringify(e):d(e)?JSON.parse(e):e}const d=e=>{if("string"==typeof e)try{const t=JSON.parse(e);return"object"==typeof t&&null!==t}catch(e){return!1}return!1},c=(e,t)=>{try{const i=JSON.stringify(t);sessionStorage.setItem(e,i)}catch(t){console.error(`Error setting session data for key ${e}:`,t)}},u=e=>{const t=sessionStorage.getItem(e);if(t)try{return JSON.parse(t)}catch(t){console.error(`Error parsing session data for key ${e}:`,t)}return null},h=e=>{for(const t of e)t.code&&(t.code=t.code.replace(/&gt;/g,">").replace(/&lt;/g,"<"))},p=(e,t)=>{e instanceof Map?e.forEach((e=>{t([e])})):Array.isArray(e)&&e.forEach((e=>{t(e.children)}))},f=(e,t)=>{const i=e=>{var r,o,a;if(e)for(const n of e){const e=null===(a=null===(o=null===(r=null==n?void 0:n.tmpData)||void 0===r?void 0:r.source)||void 0===o?void 0:o.converse)||void 0===a?void 0:a.data;(null==e?void 0:e.length)&&h(e),t(n),n.children?i(n.children):n.dynamicChildren?p(n.dynamicChildren,i):n.stateChildren&&i(n.stateChildren)}};i(e)},m=(e,t,i,r)=>{const o=e.match(/({{[\w]*}})|((@)[\w]*)/gm);if(o){const e=o.map((e=>e.replace(/{{|}}|@/gm,"")));for(const o of e)if(o&&t&&!(t.findIndex((e=>e.mapField===o))<0))return i&&r&&g(r,o,i.cid),!0}return!1},g=(e,t,i)=>{if(!e)throw new Error("Share variable tree is not defined");if("string"!=typeof t)throw new Error("Variable name should be a string");if(!i)throw new Error("ID is required");Array.isArray(e[t])||(e[t]=[]),e[t].includes(i)||e[t].push(i)},v=(e,t,i)=>{var r;let o=!1;const a=null==t?void 0:t.converse;if(a&&a.use&&a.data.length)for(const t of a.data)if((null==t?void 0:t.dependVars)&&t.dependVars.includes(e))return!0;const n=null==t?void 0:t[null==t?void 0:t.type];return((null==n?void 0:n.inputSql)||(null==n?void 0:n.url)||(null==n?void 0:n.headers)||(null==n?void 0:n.params))&&(o=m(n.inputSql||n.url||(null===(r=n.headers)||void 0===r?void 0:r.value)||n.params,i)),o},b=(e,i,r=!1)=>{let o=null;const a=e=>{for(const n of e){if(n.cid===i){o=n,r&&t.remove(e,(e=>e.cid===i));break}if(n.children&&a(n.children),n.dynamicChildren&&Array.isArray(n.dynamicChildren))for(const[,e]of Array.from(n.dynamicChildren))a(e);n.stateChildren&&a(n.stateChildren)}};return a(e),o},y=(e,i,r)=>{let o=!1;const a=e=>{for(let n=0;n<e.length;n++){if(e[n].cid==i){o=e[n],r&&t.remove(e,(e=>e.cid==i));break}if(e[n].children)a(e[n].children);else if(e[n].dynamicChildren){if(e[n].dynamicChildren instanceof Map){let t=Array.from(e[n].dynamicChildren);for(let e=0;e<t.length;e++)if(t[e]instanceof Array){let i=t[e][1];a(i)}}else if(e[n].dynamicChildren instanceof Array){let t=e[n].dynamicChildren;for(let e=0;e<t.length;e++)if(t[e]instanceof Array){let i=t[e][1];a(i)}}}else e[n].stateChildren&&a(e[n].stateChildren)}};return a(e),o||!1};function w(e,t,i){const r={};i&&i.forEach((e=>{(null==e?void 0:e.name)&&(r[e.name]=e.value||e.originvalue)}));try{return new Function("data","vars",e)(t,r)}catch(e){return console.error(e),t}}function D(e,i){let r=t.cloneDeep(i);try{return new Function("data",e)(r)}catch(e){return console.error(e),r}}const N="anov@2019:helloX",C="anov@2020:helloX";function k(e){let t=r.enc.Utf8.parse(N),i=r.enc.Utf8.parse(C);return r.AES.encrypt(e,t,{iv:i,mode:r.mode.CBC,padding:r.pad.Pkcs7}).toString()}const A=new Blob(["\nfunction proxyObj(originObj) {\n const exposeObj = new Proxy(originObj, {\n has: (target, key) => {\n if (['fetch', 'XMLHttpRequest', 'postMessage'].indexOf(key) >= 0) {\n throw new Error('Illegal operation for key'+key)\n } else {\n return target[key]\n }\n },\n })\n return exposeObj\n}\nfunction compileCode(src) {\n src = 'with (exposeObj) {'+src+'}'\n //console.log(src)\n return new Function('exposeObj', src)\n}\nfunction run(code) {\n let proxy = proxyObj({})\n let result = compileCode(code)(proxy)\n return result\n}\n\nonmessage = (e) => {\n try {\n let result = run(e.data.code)\n postMessage({\n code: 1,\n result,\n })\n } catch (err) {\n postMessage({\n code: -1,\n err,\n })\n }\n}\n"]),V=URL.createObjectURL(A);function O(e,t){return o(this,arguments,void 0,(function*(e,t,i={},r="worker"){try{if("window"==r){let[r,o]=[["data"],[t]];"object"==typeof i&&Object.keys(i).forEach((e=>{r.push(e),o.push(i[e])}));const a=new Function(...r,e);return{success:!0,data:a(...o)}}{let[r,a,n]=[t,i,""];"object"==typeof r&&(r=JSON.stringify(t)),"object"==typeof i&&(a=JSON.stringify(i)),Object.keys(i).forEach((e=>n+=`${e},`));let s=`let data=eval(${r}); \n             let app=${JSON.stringify({})};`;s+=n?`let {${n}} = eval(${a}); `:"",s+=`${e}`;let l=yield function(e){return o(this,arguments,void 0,(function*(e,t=5e3){let i=new Worker(V);return new Promise(((r,o)=>{const a=()=>{clearTimeout(s),i.removeEventListener("message",n),i.terminate(),i=null},n=e=>{let{code:t,result:i,err:n}=e.data;a(),1===t?r(i):o(n)};i.postMessage({code:e}),i.addEventListener("message",n);let s=setTimeout((()=>{a(),o("timeout")}),t)}))}))}(s);return{success:!0,data:l}}}catch(e){return{success:!1,error:e,data:t}}}))}var T,F,x,E;!function(e){e.StaticFile="staticFile",e.DataSource="datasource"}(T||(T={})),function(e){e.json="application/json;charset=UTF-8",e.form="application/x-www-form-urlencoded; charset=UTF-8"}(F||(F={})),function(e){e.get="GET",e.post="POST",e.put="PUT",e.patch="PATCH",e.delete="DELETE"}(x||(x={}));class S{constructor(e){this.db=null,this.dbName=e.databaseName,this.tableName=e.tableName,this.keyPath=e.keyPath}static getInstance(e){return S.instance||(S.instance=new S(e)),S.instance}init(){return o(this,void 0,void 0,(function*(){return new Promise(((e,t)=>{const i=indexedDB.open(this.dbName,1);i.onerror=e=>{t(e.target.error)},i.onupgradeneeded=e=>{this.db=e.target.result,this.db.objectStoreNames.contains(this.tableName)||this.db.createObjectStore(this.tableName,{keyPath:this.keyPath})},i.onsuccess=t=>{this.db=t.target.result,e()}}))}))}addRecord(e){return o(this,void 0,void 0,(function*(){if(!this.db)throw new Error("数据库未初始化。");return new Promise(((t,i)=>{const r=this.db.transaction([this.tableName],"readwrite").objectStore(this.tableName).add(e);r.onsuccess=()=>{t()},r.onerror=e=>{i(e.target.error)}}))}))}deleteRecord(e){return o(this,void 0,void 0,(function*(){if(!this.db)throw new Error("数据库未初始化。");return new Promise(((t,i)=>{const r=this.db.transaction([this.tableName],"readwrite").objectStore(this.tableName).delete(e);r.onsuccess=()=>{t()},r.onerror=e=>{i(e.target.error)}}))}))}updateRecord(e){return o(this,void 0,void 0,(function*(){if(!this.db)throw new Error("数据库未初始化。");return new Promise(((t,i)=>{const r=this.db.transaction([this.tableName],"readwrite").objectStore(this.tableName).put(e);r.onsuccess=()=>{t()},r.onerror=e=>{i(e.target.error)}}))}))}getRecord(e){return o(this,void 0,void 0,(function*(){if(!this.db)throw new Error("数据库未初始化。");return new Promise(((t,i)=>{const r=this.db.transaction([this.tableName],"readonly").objectStore(this.tableName).get(e);r.onsuccess=()=>{t(r.result)},r.onerror=e=>{i(e.target.error)}}))}))}getAllRecords(){return o(this,void 0,void 0,(function*(){if(!this.db)throw new Error("数据库未初始化。");return new Promise(((e,t)=>{const i=this.db.transaction([this.tableName],"readonly").objectStore(this.tableName).getAll();i.onsuccess=()=>{e(i.result)},i.onerror=e=>{t(e.target.error)}}))}))}}S.instance=null,function(e){e[e.FATAL=0]="FATAL",e[e.ERROR=1]="ERROR",e[e.WARN=2]="WARN",e[e.INFO=3]="INFO",e[e.DEBUG=4]="DEBUG",e[e.TRACE=5]="TRACE"}(E||(E={}));const j={databaseName:"GODB",tableName:"go-log",keyPath:"time"};class P{constructor(){this.logLevel=E.INFO,this.indexedDBInstance=S.getInstance(j);try{this.indexedDBInstance.init(),console.log("IndexedDB 初始化成功。")}catch(e){console.error("初始化 IndexedDB 时出错:",e)}}static getInstance(){return P.instance||(P.instance=new P),P.instance}setLogLevel(e){this.logLevel=e}getColor(e){switch(e){case E.FATAL:return"";case E.ERROR:return"";case E.WARN:return"";case E.INFO:return"";case E.DEBUG:return"";case E.TRACE:return"";default:return""}}log(e,t){if(t<=this.logLevel){const i=(new Date).toISOString(),r=`[${i}] [${E[t]}]`,o=this.getColor(t);if(null===window||void 0===window?void 0:window.goDev)console.log(`${o}${r} ${e}`);else{let t=u("anov-go-userInfo"),a=u("anov-go-proid"),n=` [操作人:${null==t?void 0:t.userName} 项目ID:${a}] `;const s={time:i,value:`${e}`};try{this.indexedDBInstance.addRecord(s)}catch(e){console.error("添加记录时出错:",e)}console.log(`${o}${r} ${n} ${e}`)}}}fatal(e){this.log(e,E.FATAL)}error(e){this.log(e,E.ERROR)}warn(e){this.log(e,E.WARN)}info(e){this.log(e,E.INFO)}debug(e){this.log(e,E.DEBUG)}trace(e){this.log(e,E.TRACE)}}const I=P.getInstance(),U=(e,t)=>"string"!=typeof e?Promise.reject(new Error("URL should be a string")):s(e,t),$=s();let M=s();function R(e){return o(this,arguments,void 0,(function*(e,i="get",r={},a={}){try{const s={method:x[i],url:e,headers:a,timeout:n};["post","put"].includes(i.toLowerCase())?s.data=t.cloneDeep(r):s.params=t.cloneDeep(r);return/.json$/.test(e)?function(e){return o(this,void 0,void 0,(function*(){try{return(yield $({method:"get",url:e})).data}catch(e){throw console.error("JSON 数据请求:",e),e}}))}(e):function(e){return o(this,void 0,void 0,(function*(){try{return{code:2e4,data:(yield $(e)).data}}catch(e){throw console.error("请求数据发生错误-Error:",e),e}}))}(s)}catch(e){throw console.error("获取数据:Error:",e),e}}))}function q(e,t,i,r){return o(this,void 0,void 0,(function*(){try{const o=window.anUrl||"",a=o+(window.agentPath||"/ds/v1/api-proxy/v1/query"),n=l(i,!0);return yield $({url:a,method:"post",headers:{"Content-Type":"application/json;charset=UTF-8"},data:{body:"post"===e?n:void 0,headers:d(r)?JSON.parse(r):r,method:e,url:t}})}catch(e){throw console.error("代理请求数据:Error:",e),e}}))}function G(e,t,i,r,a){return o(this,void 0,void 0,(function*(){return a?q(t,e,i,r):R(e,t,i,r)}))}function H(e,t="",i){var r,o,n,s;const l=`${null!==(o=null===(r=null===window||void 0===window?void 0:window.BaseUrl)||void 0===r?void 0:r.replace("/management",""))&&void 0!==o?o:""}/ds/data-engine/v1/${e}/zb-query?${`token=${(null===(n=Z("YZH_EXCHANGE_TOKEN"))||void 0===n?void 0:n.YZH_EXCHANGE_TOKEN)||(null===(s=null===window||void 0===window?void 0:window.yzhAuth)||void 0===s?void 0:s.getToken())}&passid=${null===window||void 0===window?void 0:window.gdPassid}`}${(null===window||void 0===window?void 0:window.BASE_RELEASE)?"&preview=1":""}`;let d={};try{d=t?JSON.parse(t):{}}catch(e){d=t||{}}return $({method:"POST",url:l,data:{headers:i,param:d},timeout:a})}const L=(e,t)=>o(void 0,void 0,void 0,(function*(){const i=window.BaseUrl,{dateType:r="",endPeriod:o="",metricsName:n=e,startPeriod:s=""}=t;return M({method:"GET",url:`${i}ds/v1/metrics/v1/data-alarm?dateType=${r}&endPeriod=${o}&metricsName=${n}&startPeriod=${s}`,timeout:a})})),z=(e,t,i)=>o(void 0,void 0,void 0,(function*(){var r;const o=(null===(r=window.BaseUrl)||void 0===r?void 0:r.replace("/management",""))||"";t.newEncryption=!0;const n={staticFile:{method:"get",params:t,url:`${o}/ds/v1/file/v1/${e}/query`},datasource:{method:"post",url:`${o}/ds/v1/database/v1/${e}/query`,data:Object.assign({},t)}}[i];if(!n)throw new Error("Invalid data type provided");return $(Object.assign({timeout:a},n))})),B=e=>new Promise(((t,i)=>{let r;r=e.originData&&Object.keys(e.originData).length?e.originData:e.data,void 0!==r?t({data:r}):i("Failed to retrieve cdata")})),J=(e,t,i)=>{try{switch(t){case"api":{let t=te(e,i);return{requestType:t.requestType,url:t.url,params:t.params,headers:t.headers,agency:t.agency}}case"static":return{data:e};case"datasource":{const t=ee(e.inputSql,i);return{dsName:e.dsName,dsType:"1",sql:k(t),filter:e.sqlFilter}}case"staticFile":return{dsName:e.dsName,dsType:e.dsType,sql:""};case"indicator":return{zbId:e.zbId,params:ee(e.params,i),headers:ee(e.headers,i)};case"indicatorCQ":return{zbName:e.zbName,params:ee(e.params,i)};case"packData":return{};default:throw new Error("Invalid type")}}catch(t){console.log("准备请求数据发生错误",t,e)}},W=(e,t)=>o(void 0,void 0,void 0,(function*(){try{switch(t){case"api":return yield G(e.url,e.requestType,e.params,e.headers,e.agency);case"static":return yield B(e.data);case"datasource":return yield z(e.dsName,{dsType:e.dsType,sql:e.sql,filter:e.filter},"datasource");case"staticFile":return yield z(e.dsName,{dsType:e.dsType,sql:e.sql},"staticFile");case"indicator":return yield H(e.zbId,e.params,e.headers);case"indicatorCQ":return yield L(e.zbName,e.params);case"packData":return{};default:throw new Error("Invalid type")}}catch(e){return console.warn(e,"执行请求并获取数据发生错误"),yield new Promise(((e,t)=>{e({error:!0})}))}})),X=(e,t,i,...r)=>o(void 0,[e,t,i,...r],void 0,(function*(e,t,i,r=[],o=!1){const a=t||e.tmpData.source.dataType,n=e.tmpData.source["indicatorCQ"==a?"indicator":a];if("globalData"===a){const e=r.find((e=>e.key===n.id||e.key===n.key)),t=u(n.id);if(t&&!o)return t.data;if(e){let t=yield _(e,i),r={key:n.id,data:t};return c(n.id,r),t}return}const s=J(n,a,i),l=yield W(s,a);return(null==l?void 0:l.data)?l.data:l})),_=(e,t)=>o(void 0,void 0,void 0,(function*(){let i=Object.assign({},{tmpData:{source:e.value}});const r=i.tmpData.source.type,o=i.tmpData.source[r],a=J(o,r,t),n=yield W(a,r);return yield Q(n.data,i,!0,t)})),Q=(e,i,...r)=>o(void 0,[e,i,...r],void 0,(function*(e,i,r=!0,a){try{const{converse:n,mapFields:s}=i.tmpData.source;return n&&n.use&&r?yield new Promise(((i,r)=>{const s=function(e,i,r,a,n){return o(this,void 0,void 0,(function*(){let r,o=e,{use:n,data:s}=t.cloneDeep(i);if(n)for(let e=0;e<s.length;e++)if(s[e].use){let i=s[e].dependVars,n={};a&&n&&i&&i.length&&i.map((e=>{let i=t.cloneDeep(a).filter((t=>{let i=t.mapField==e;return i&&(n[e]=t.value),i}));i&&0!=i.length||(n[e]="")})),r=yield O(s[e].code,o,n,s[e].mode?s[e].mode:"worker"),o=r.data}return o}))}(e,n,0,a);i(s)})):yield new Promise(((t,i)=>{t(e)}))}catch(t){return console.error("执行过滤器发生错误:"+t),yield new Promise(((t,i)=>{t(e)}))}})),Y=(e,t,i)=>{const{source:r}=e.tmpData,o=r.type;i?("static"===o&&r[o]&&(r[o].originData=i),"indicatorCQ"===o?r.indicator.data=t:r[o].data=t):"indicatorCQ"===o?r.indicator.data=t:r[o].data=t,e.source=t},K=(e,t,...i)=>o(void 0,[e,t,...i],void 0,(function*(e,t,i=[],r,o,a){try{let n=e.tmpData.source.type,s=yield X(e,n,i,r,a||!1);if(null==s||!s)return o&&o({error:!0}),Promise.resolve({error:!0});let l=yield Q(s,e,t,i);return Y(e,l),o&&o(l),Promise.resolve(l)}catch(e){return o&&o(e),I.error("Error in updateComData"),console.error("Error in updateComData:",e),Promise.reject(e)}})),Z=e=>{const t={};if(e&&e.includes("?")){const i=e.split("?")[1].split("&");for(let e of i){const[i,r]=e.split("=").map(decodeURIComponent);t[i]=r}}return t},ee=(e,t)=>{if(!t)return e;if("string"==typeof e)return""===e.trim()?"":e.replace(/@(\w+)|{{(\w+)}}/g,((e,i,r)=>{const o=i||r,a=t.find((e=>e.mapField===o));return a?a.value||a.originalValue||"":e}));if(Array.isArray(e))return e.map((e=>ee(e,t)));if("object"==typeof e&&null!==e){const i={};for(let r in e)i[r]=ee(e[r],t);return i}return e},te=(e,t)=>{const i=e.agency,r=e,{url:o=null,headers:a,params:n,requestType:s}=r,l=o?ee(o,t):void 0,d=a&&a.use?ee(a.value,t):{};return{url:l,requestType:s,params:n?ee(n,t):{},headers:d,agency:i}},ie=(e,t,i,r,a)=>o(void 0,void 0,void 0,(function*(){if(e&&e.length)for(const o of e){v(t,o.value,i)&&(yield K({tmpData:{source:{type:"globalData",globalData:{id:o.key}}}},!0,i,e,(e=>{console.log("数据更新成功-变量改变全局数据跟新")}),!0),f(r,(t=>{var r,n,s;if("globalData"===(null===(n=null===(r=null==t?void 0:t.tmpData)||void 0===r?void 0:r.source)||void 0===n?void 0:n.type)){(null===(s=null==t?void 0:t.tmpData)||void 0===s?void 0:s.source.globalData).id===o.key&&K(t,!0,i,e,(e=>{a(t,e)}),!1)}})))}})),re=(e,t,i,r,a)=>o(void 0,void 0,void 0,(function*(){e&&(yield K({tmpData:{source:{type:"globalData",globalData:{id:e.key}}}},!0,t,i,(e=>{console.log("数据更新成功-数据源编辑")}),!0),f(r,(r=>{var o,n,s;if("globalData"===(null===(n=null===(o=null==r?void 0:r.tmpData)||void 0===o?void 0:o.source)||void 0===n?void 0:n.type)){(null===(s=null==r?void 0:r.tmpData)||void 0===s?void 0:s.source.globalData).id===e.key&&K(r,!0,t,i,(e=>{a(r,e)}),!1)}})))}));class oe{constructor(e,t){this.isUpdating=!1,this.des=e.des,this.field=e.field,this.id=e.id,this.key=e.key,this.mapping=e.mapping,this.mapField=e.mapField,this.type=e.type,this.originalValue=e.originalValue,this.model=(null==e?void 0:e.model)?null==e?void 0:e.model:1,this.converter=e.converter,this.converterCode=e.converterCode,this.fork=e.fork,this.delayUpdate=!!(null==e?void 0:e.delayUpdate),t&&(this.globalVariables=t),e.fork&&(this.model=5,this.forkValue=e.forkValue,this.originalValue=this.getForkedValue())}get value(){return this.fork&&(this.originalValue=this.getForkedValue()),this.converter&&this.converterCode?D(this.converterCode,this.originalValue):this.originalValue}getForkedValue(){if(this.forkValue&&Array.isArray(this.forkValue))return this.forkValue.map((e=>{const t=this.globalVariables.get(e);return t?t.value:null}));if(this.forkValue){const e=this.globalVariables.get(this.forkValue);return e?e.value:null}return null}updateValue(e,t){var r;const o=Object.assign({},this,e);this.des=o.des,this.field=o.field,this.mapping=o.mapping,this.type=o.type,this.originalValue=o.originalValue,this.converter=o.converter,this.converterCode=o.converterCode,this.fork=o.fork,this.delayUpdate=null==o?void 0:o.delayUpdate,this.model=null==o?void 0:o.model,e.id&&(this.id?"string"==typeof this.id?e.id instanceof Array?this.id=i([this.id,...e.id]):this.id=[this.id,e.id]:this.id instanceof Array&&(e.id instanceof Array?this.id=i([...this.id,...e.id]):this.id=i([...this.id,e.id])):this.id=e.id),e.fork&&(this.model=5,this.forkValue=null!==(r=e.forkValue)&&void 0!==r?r:this.forkValue,this.originalValue=this.getForkedValue()),t&&t(this)}updateWidthOriginalValue(e,t){var i;this.originalValue=e,this.fork&&(this.forkValue=null!==(i=this.forkValue)&&void 0!==i?i:this.forkValue,this.originalValue=this.getForkedValue()),t&&t(this)}renew(e){e&&e(this)}static create(e,t){return new oe(e,t)}}class ae{constructor(){this.variables=new Map,this.globalObservers=[],this.url=window.location.search,this.list=[]}clearVars(){this.list=[],this.variables.clear()}static getInstance(){return ae.instance||(ae.instance=new ae),ae.instance}getFullUrl(){this.url=window.location.search}getAllUrlParams(){const e=new URLSearchParams(window.location.search),t={};for(const[i,r]of e.entries())t[i]=r;return t}addUrlParamsToGlobalVars(){this.getFullUrl();let e=this.getAllUrlParams(),t=Object.keys(e),i=[];for(const r of t)i.push({mapField:r,originalValue:e[r],model:4});if(i.length)for(const e of i)this.addVariable(e)}addVariables(e){Array.isArray(e)?e.map(((e,t)=>{this.addVariable(e)})):this.addVariable(e),this.addUrlParamsToGlobalVars()}addVariable(e,t){if(!e||!(null==e?void 0:e.mapField))return console.error(e+"参数不合法!"),!1;if(this.isVariableNameExist(e.mapField)){console.warn("变量名已存在");let i=this.getVariable(e.mapField);return this.sameValue(i,e)?i:(this.editVariable(e,t),!1)}const i=oe.create(e,this.variables);return this.variables.set(i.mapField,i),this.addToObjectArray(this.list,i),t&&t(i),this.notifyGlobalObservers(i),i}toJSON(e){try{return!!e&&JSON.stringify(e)}catch(e){return!1}}sameValue(e,t){if(e.mapfield!==t.mapfield)return!1;for(const i in t)if(!(["mapfield","field","key","value","name","globalVariables"].includes(i)||i in e&&e[i]==t[i]))return!1;return!0}creatVarJson(e){const{des:t,field:i,id:r,key:o,mapping:a,mapField:n,type:s,value:l,originalValue:d,model:c,converter:u,converterCode:h,fork:p,forkValue:f,update:m,delayUpdate:g}=e,v={};return void 0!==t&&(v.des=t),void 0!==i&&(v.field=i),void 0!==r&&(v.id=r),void 0!==o&&(v.key=o),void 0!==a&&(v.mapping=a),void 0!==n&&(v.mapField=n),void 0!==s&&(v.type=s),void 0!==l&&(v.value=l),void 0!==d&&(v.originalValue=d),void 0!==c&&(v.model=c),void 0!==u&&(v.converter=u),void 0!==h&&(v.converterCode=h),void 0!==p&&(v.fork=p),void 0!==f&&(v.forkValue=f),void 0!==m&&(v.update=m),void 0!==g&&(v.delayUpdate=g),v}addToObjectArray(e,t){let i=!1;for(let r=0;r<e.length;r++)if(e[r].mapField==t.mapField){e[r]=this.creatVarJson(t),i=!0;break}i||e.push(t)}editVariable(e,t){const i=this.getVariable(e.mapField);if(i&&this.isVariableNameExist(e.mapField)){if(this.sameValue(i,e))return}const r=e=>{if(!e.isUpdating){e.isUpdating=!0,this.notifyGlobalObservers(e);const i=this.isMapFieldInForkValues(e.mapField);console.log(i,"mapFieldsmapFields"),i.forEach((e=>{let t=this.getVariable(e.mapField);t&&t.renew((e=>{this.addToObjectArray(this.list,e),this.notifyGlobalObservers(e)}))})),this.addToObjectArray(this.list,e),t&&t(e),e.isUpdating=!1}};i?i.updateValue(e,r):this.addVariable(e,r)}editVariableForValue(e,t,i){const r=this.getVariable(e),o=e=>{if(!e.isUpdating){e.isUpdating=!0,this.notifyGlobalObservers(e);this.isMapFieldInForkValues(e.mapField).forEach((e=>{let t=this.getVariable(e.mapField);t&&t.renew((e=>{this.addToObjectArray(this.list,e),this.notifyGlobalObservers(e)}))})),this.addToObjectArray(this.list,e),i&&i(e),e.isUpdating=!1}};r&&r.updateWidthOriginalValue(t,o)}isMapFieldInForkValues(e){return this.getAllVariables().filter((e=>e.fork&&e.forkValue)).filter((t=>t.forkValue==e||Array.from(t.forkValue).includes(e)))}isVariableNameExist(e){return this.variables.has(e)}checkExist(e,t){if("string"==typeof e&&this.isVariableNameExist(e)){let i=this.getVariable(e);return t==i.id&&!i.id.includes(t)&&[{key:e}]}if(Array.isArray(e)){const i=e.filter((e=>{let i=this.getVariable(e);return this.isVariableNameExist(e)&&t!=i.id&&!(i.id&&i.id.includes(t))})).map((e=>({key:e})));return!!i.length&&i}return!1}getVariable(e){return this.variables.get(e)}getVariableForId(e){var t;let i=[];for(const[,r]of this.variables)(r.id===e||(null===(t=r.id)||void 0===t?void 0:t.includes(e)))&&i.push(r);return i}getAllVariables(e=!1){return e?(this.list=Array.from(this.variables.values()),this.list):[...this.list]}restoreVariables(e){e.forEach((e=>{this.addVariable(e)}))}registerGlobalObserver(e){this.globalObservers.push(e)}notifyGlobalObservers(e){this.globalObservers.forEach((t=>{t.update(e)}))}}ae.instance=null;const ne=ae.getInstance(),se=(e,t)=>Array.isArray(t)?t.some((t=>e&&(void 0!==e[t]||e.hasOwnProperty(t)))):"string"==typeof t&&(e&&(void 0!==e[t]||e.hasOwnProperty(t))),le=(e,t,i,r)=>{const o=((e,t,i,r)=>{var o;let a;if(se(e,null==t?void 0:t.field)||se(e,null==t?void 0:t.forkValue))a=e[null==t?void 0:t.field]||"";else if(se(e.data,null==t?void 0:t.field)||se(e.data,null==t?void 0:t.forkValue))a=e.data[null==t?void 0:t.field]||"";else{const e=b(i,r),n=(null===(o=null==e?void 0:e.tmpData)||void 0===o?void 0:o.actions)||[];for(const e of n){const i=e.vars.find((e=>(null==e?void 0:e.mapField)===(null==t?void 0:t.mapField)));if(i){a=i.value;break}}}return a})(e,t,i,r);return void 0!==o?o:t.value},de=(e,t,i,r,o,a,n,s,l)=>{switch(e.type){case"link":window.open(e.link,e.target);break;case"page":l&&l(e);break;case"dynamic":((e,t,i,r,o)=>{const a=e.dynamic||[];for(const n of a){if(e.id!==t.cid)continue;const a=b(i,n.pid);a&&(a.activeDynamic=n.name,a.isShow=n.visible||!r||e.index===t.index-1,o({cid:a.cid,flag:n.visible}))}})(e,t,i,r,o);break;case"toggle":((e,t,i,r,o)=>{const a=e.children||[];for(const i of a){const a=i.visible&&(!r||e.index===t.index-1);o({cid:i.cid,flag:a})}})(e,t,0,r,o);break;case"update":((e,t,i,r,o)=>{const a=e.children||[];for(const e of a){const a=b(t,e.cid);a&&K(a,!0,i,r,(e=>{o({cid:a.cid,data:e})}))}})(e,i,a,n,s)}},ce=(e,t,i,r,o,a,n,s,l,d)=>{const{cid:c,actions:u,index:h}=o,{eventName:p,mode:f}=u,m=2===f;((e,t,i,r,o,a)=>{let n=ne.getVariableForId(t.cid);if(null==n?void 0:n.length)for(const s of n)if(s.type==e){let e=le(t,s,i,r);ne.editVariableForValue(s.mapField,e,(()=>{const e=o[s.mapField]||[];a&&a(s,e)}))}})(p,o,r,c,i,((e,t)=>{if(ie(l,e.mapFile,ne.getAllVariables(),r,((e,t)=>{n({cid:e.cid,data:t})})),null==t?void 0:t.length)for(const i of t){e.eventSourceId=i;const t=b(r,i);!(null==e?void 0:e.delayUpdate)&&t&&K(t,!0,ne.getAllVariables(),l,(e=>{n({cid:t.cid,data:e})}))}}));const g=((e,t,i,r,o)=>e.filter((e=>e.id===t&&e.eventType===i&&(!o||parseInt(e.index||"0")+1===parseInt(r||"0")))))(e,c,p,h,m);for(const e of g)de(e,o,r,m,a,ne.getAllVariables(),l,n,s)},ue=(e,t={})=>{let i={},r={type:"static",converse:{use:!1,data:[]},static:{data:e},api:{requestType:"get",url:"",headers:{use:!1,value:""},params:"",agency:!1,cookie:!0,autoUpdate:{open:!1,time:10},data:""}};return Object.assign(i,r,t),i},he=(e,i)=>{let{option:r,actions:o,data:a,optionDes:n,actionsDes:s,source:l,theme:d}=((e,i)=>{let{option:r,actions:o,data:a,optionDes:n,actionsDes:s,source:l,theme:d}=t.cloneDeep(i[e]);return{option:r,actions:o,data:a,optionDes:n,actionsDes:s,source:l,theme:d}})(e,i);return{iconClass:null,isAssembly:null,source:a,cid:(Math.random().toString().substr(3,10)+Date.now()).toString(),isLock:!1,isShow:!0,tmpData:{option:r,source:ue(a,l),actions:o},baseData:fe(),dynamic:null,filePath:"",origin:"anov-ui",name:"",componentType:"",viewComName:e,optionComName:"AnOptionPanel",dataComName:"AnSourcePanel",eventComName:"AnActionsPanel",assemblyDeveloper:"",devEmail:"",version:"",devDept:""}},pe=(e,i,r)=>{let o=he(e,i);return r?t.merge(o,r):o},fe=e=>{let t={left:0,top:0,width:100,height:100,angle:0,penetrate:0,opacity:100,perspective:100,rotateX:0,rotateY:0,rotateZ:0,transformOriginX:"center",transformOriginY:"center",transformSwitch:!1};return e?Object.assign(t,e):t};class me{constructor(e,t,i){this.theme=null,this.plant=null,this.list=[],this.titleHeqadeHeight=60,this.clearance=3,this.checkComponentIntersection=(e,t,i=10)=>{const r=e.left,o=e.left+e.width,a=e.top,n=e.top+e.height,s=t.left,l=t.left+t.width,d=t.top,c=t.top+t.height,u=r<l&&o>s&&a<c&&n>d,h=Math.abs(e.left+e.width/2-(t.left+t.width/2)),p=Math.abs(e.top+e.height/2-(t.top+t.height/2));return u||h<i&&p<i},this.calculateCombinedComponent=e=>{if(0===e.length)return{left:0,top:0,width:0,height:0};let t=e[0].left,i=e[0].top,r=e[0].left+e[0].width,o=e[0].top+e[0].height;for(let a=1;a<e.length;a++){const n=e[a];t=Math.min(t,n.left),i=Math.min(i,n.top),r=Math.max(r,n.left+n.width),o=Math.max(o,n.top+n.height)}return{left:t,top:i,width:r-t,height:o-i}},this.getAnTextNormaltText=e=>{var t,i;try{return null===(i=null===(t=null==e?void 0:e.tmpData)||void 0===t?void 0:t.option)||void 0===i?void 0:i.text}catch(e){return console.error("配置优化(ConfigOptimizer):",e),""}},this.initProp(e),this.upgradePlant(),this.staticComponentData=t,this.upgradeHeaderComponent(),this.upgradeTitleComponent(),this.upgradeGroupComponent(),i&&Object.assign(this,i)}isStringOrObject(e){return"string"==typeof e?"string":"object"==typeof e&&null!==e&&"object"}initProp(e){try{let t,i=this.isStringOrObject(e);if(i&&"string"===i)t=JSON.parse(e);else{if(!i||"object"!==i)throw new Error(`initProp fn error :-- 传入参数${e}不合法!`);t=e}if(t){this.originData=t;const{theme:e,plant:i,list:r}=t;this.theme=e,this.plant=i,this.list=r,this.filterFileGroup()}}catch(e){console.error("配置优化(ConfigOptimizer):",e)}}upgradePlant(){this.plant&&(this.plant.option.bg={type:1,code:"70942ec525344c96aa32b81b2c9155f6",path:"/anov-prod/resources/page/png/bg22 科技星球背景.png",thumb:"/anov-prod/resources/page/thumbnail/1e48f8fb26ec4edfb1a0f499627e84fc.png"})}areComponentsIntersecting(e,t){let i=e.baseData,r=t.baseData;const o=Math.max(0,Math.min(i.left+i.width,r.left+r.width)-Math.max(i.left,r.left)),a=Math.max(0,Math.min(i.top+i.height,r.top+r.height)-Math.max(i.top,r.top));return o>0&&a>0}filterFileGroup(){this.list=t.cloneDeep(this.list).map((e=>{var t,i;if(1===(null===(t=null==e?void 0:e.children)||void 0===t?void 0:t.length)&&!(null===(i=null==e?void 0:e.children[0])||void 0===i?void 0:i.children)){const t=e.children[0],{left:i,top:r}=e.baseData;return t.baseData.left=i,t.baseData.top=r,t}return e}))}getText(e,t,i){const r=document.createElement("canvas").getContext("2d");if(!r)throw new Error("Failed to get 2D context from canvas.");r.font=`${i}px ${t}`;return r.measureText(e).width}createIndicatorComponent(e,t,i){}calculateMaxWidths(e){const t=Math.min(...e.map((e=>e.width))),i=[];let r=[],o=e[0].width;for(const a of e){const e=a.width;Math.abs(e-o)<=t?r.push(e):(r.length>0&&i.push(r),r=[e]),o=e}r.length>0&&i.push(r);const a=[];for(const e of i){const t=Math.max(...e);a.push(t)}return a}findClosestValue(e,t){let i=t[0],r=Math.abs(e-i);for(const o of t){const t=Math.abs(e-o);t<r&&(r=t,i=o)}return i}adjustHeightAndTop(e,t){const i=t-e.height;return Object.assign(Object.assign({},e),{height:t,top:e.top-i/2})}findNearestComponent(e,i,r){let o=null,a=1/0;i.tmpData.option.textNormal.text;try{const n=t.cloneDeep(e).sort(((e,t)=>e.baseData.top-t.baseData.top)).sort(((e,t)=>e.baseData.left-t.baseData.left)).filter((e=>!(e.cid===i.cid||"AnTextNormal"===e.viewComName||r&&r.includes(e.cid)))),s=t.cloneDeep(i).baseData;s.top,s.height;for(const e of n){const t=e.baseData;t.top,t.height;if(s.left<t.left+t.width&&s.left+s.width>t.left){const i=t.top-s.top;i<a&&i<100&&(a=i,o=e)}}}catch(e){console.error("配置优化(ConfigOptimizer)- findNearestComponent :",e)}return o}findNearestComponentForPoint(e,t,i){let r=null,o=1/0;t.tmpData.option.textNormal.text;try{const a=e.sort(((e,t)=>e.baseData.top-t.baseData.top)).sort(((e,t)=>e.baseData.left-t.baseData.left)).filter((e=>!(e.cid===t.cid||"AnTextNormal"===e.viewComName||i&&i.includes(e.cid)))),n=t.baseData;n.top,n.height;for(const e of a){const t=e.baseData;let i=this.getDistance(n.left,n.top+n.height,t.left,t.top);i<o&&i<n.width&&(o=i,r=e)}}catch(e){console.error("配置优化(ConfigOptimizer)- findNearestComponent :",e)}return r}findNearestComponentForTitlePoint(e,t,i){let r=null,o=1/0;t.tmpData.option.textNormal.text;try{const a=e.sort(((e,t)=>e.baseData.top-t.baseData.top)).sort(((e,t)=>e.baseData.left-t.baseData.left)).filter((e=>!(e.cid===t.cid||"AnTextNormal"===e.viewComName||i&&i.includes(e.cid)))),n=t.baseData;n.top,n.height;for(const e of a){const t=e.baseData;let i=this.getDistance(n.left,n.top+n.height,t.left,t.top);i<o&&i<n.width&&t.top-n.top>100&&(o=i,r=e)}}catch(e){console.error("配置优化(ConfigOptimizer)- findNearestComponent :",e)}return r}findNearestTitleForPoint(e,t,i){let r=null,o=1/0;t.tmpData.option.textNormal.text;try{const a=e.sort(((e,t)=>e.baseData.top-t.baseData.top)).sort(((e,t)=>e.baseData.left-t.baseData.left)).filter((e=>!(e.cid===t.cid||"AnTextNormal"===e.viewComName||i&&i.includes(e.cid)))),n=t.baseData;n.top,n.height;for(const e of a){const t=e.baseData;let i=t.top-n.top;i<o&&i<n.width&&t.top-n.top>100&&(o=i,r=e)}}catch(e){console.error("配置优化(ConfigOptimizer)- findNearestComponent :",e)}return r}getDistance(e,t,i,r){return Math.sqrt(Math.pow(i-e,2)+Math.pow(r-t,2))}findNearestComponent2(e,i,r){let o=null,a=1/0,n=t.cloneDeep(e).sort(((e,t)=>e.baseData.top-t.baseData.top));try{const e=n.filter((e=>!(e.cid===i.cid||"AnTextNormal"===e.viewComName||r&&r.includes(e.cid)))),s=t.cloneDeep(i).baseData,l=s.top+s.height;for(const t of e){const e=t.baseData,i=e.top+e.height;if(s.left<e.left+e.width&&s.left+s.width>e.left){const e=i-l;e>=0&&e<a&&(a=e,o=t)}}}catch(e){console.error("配置优化(ConfigOptimizer)- findNearestComponent :",e)}return o}verticalDistance(e,t){e.left,e.width;const i=e.top+e.height,r=(t.left,t.width,t.top);return Math.abs(i-r)}extractAmount(e){const t=e.match(/(\d{1,3}(?:,\d{3})*)(\D+)/);if(t){const e=t[1].replace(/,/g,"");return[parseInt(e,10),t[2].trim()]}return[!1,!1]}getAnTextNormal(){return this.list.filter((e=>"AnTextNormal"==e.viewComName))}getAnDeckTitle3(){return this.list.filter((e=>"AnDeckTitle3"==e.viewComName)).sort(((e,t)=>e.baseData.left-t.baseData.left))}judgeAnOdometer(){let e=this.getAnTextNormal().sort(((e,t)=>e.baseData.left-t.baseData.left)),t=[],i=new Set;for(const r of e){if(i.has(r.cid))continue;let o=[];for(const t of e){if(!i.has(t.cid)&&r.cid!=t.cid){this.checkComponentIntersection(r.baseData,t.baseData)&&(i.add(t.cid),i.add(r.cid),o.push(t))}}t.push([r,...o])}let r=[];for(const e of t)for(const t of e){let i=this.getAnTextNormaltText(t);this.extractAmount(i).every((e=>e))&&r.push(e)}return r}createAnOdometer(){var e,i;let r=this.judgeAnOdometer();for(const o of r){let r,a,n,s=this.calculateCombinedComponent(o.map((e=>e.baseData)));for(const e of o){let i=this.getAnTextNormaltText(e),o=this.extractAmount(i);o.every((e=>!e))&&(r=i),o.every((e=>e))&&(a=o[0],n=o[1]),t.remove(this.list,(t=>t.cid==e.cid))}let l=pe("AnIndicatorNormal",this.staticComponentData,t.cloneDeep({baseData:s}));(null===(i=null===(e=null==l?void 0:l.tmpData)||void 0===e?void 0:e.source)||void 0===i?void 0:i.static)&&(l.tmpData.source.static.data={text:r,num:a,unit:n},l.tmpData.source.static.originData={text:r,num:a,unit:n}),this.list.push(l)}}upgradeHeaderComponent(){for(let e=0;e<this.list.length;e++){const t=this.list[e];"AnDeckHeader3"==t.viewComName&&(t.baseData.left=0,t.baseData.top=0)}}upgradeTitleComponent(){let e=this.getAnDeckTitle3().map((e=>e.baseData)),t=this.calculateMaxWidths(e);for(let e=0;e<this.list.length;e++){const i=this.list[e];if("AnDeckTitle3"==i.viewComName){let e=this.findClosestValue(i.baseData.width,t);i.baseData.width=e>300?e:300,i.baseData=this.adjustHeightAndTop(i.baseData,this.titleHeqadeHeight)}}this.removeErroneousComponents()}containsFractionStructure(e){return/\b\d+\/\d+\b/.test(e)}removeErroneousComponents(){let e=this.getAnDeckTitle3(),t=[];for(let i=0;i<e.length;i++){const r=e[i];let o=r.tmpData.option.textNormal.text;if(this.containsFractionStructure(o))for(let i=0;i<e.length;i++){const o=e[i];if(r.cid!=o.cid){this.areComponentsIntersecting(r,o)&&t.push(r.cid)}}}this.list=this.list.filter((e=>!t.includes(e.cid)))}upgradeGroupComponent(){try{let e=this.getAnDeckTitle3(),t=this.list.filter((e=>"AnDeckTitle3"!=e.viewComName&&"AnDeckHeader3"!=e.viewComName&&"AnTextNormal"!=e.viewComName)),i=[],r=[];for(let o=0;o<e.length;o++){const a=e[o];let n=this.findNearestComponentForPoint(t,a,i);if(n&&n.cid&&i.push(n.cid),n){a.baseData.left=n.baseData.left;let t=this.upgradeComponentHeight(a,e,r);t&&t>=30&&(n.baseData=Object.assign({},n.baseData,{top:a.baseData.top+a.baseData.height+this.clearance}))}}}catch(e){console.error("配置优化(ConfigOptimizer):",e)}}upgradeComponentHeight(e,i,r=[]){const o=e;let a=this.findNearestTitleForPoint(t.cloneDeep(i),o);return a?a.baseData.top-o.baseData.top-this.titleHeqadeHeight:1080-o.baseData.top-this.titleHeqadeHeight}getData(){return this.originData.list=this.list,this.originData.plant=this.plant,this.originData}}console.log(123);export{me as ConfigOptimizer,ae as GlobalVariables,U as Http,I as Log,q as agentData,Y as editItem,ce as emitEvent,_ as fetchDataByGlobal,X as fetchDataByType,Q as filterData,b as findItemDeep,y as findItemDeep2,R as getData,G as getDataForApi,z as getDataForSource,B as getDataForStatic,H as getDataForZb,L as getDataForZbCQ,u as getSessionData,l as getStandardData,m as getStringVars,le as getVarDefaultVal,ne as globalVars,v as hasVar,d as isJSON,f as recursion,w as safeEval,D as safeEvalForCode,c as setSessionData,ie as updataGlobalDataSourceForVar,K as updateComData,re as updateGlobalDataSource};
1
+ import e from"axios";import t,{uniq as i}from"lodash";import r from"crypto-js";function o(e,t,i,r){return new(i||(i=Promise))((function(o,a){function n(e){try{l(r.next(e))}catch(e){a(e)}}function s(e){try{l(r.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(n,s)}l((r=r.apply(e,t||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const a=5e3,n=5e3,s=(t="",i)=>{let r=e.create({baseURL:t,timeout:a,headers:{"Content-Type":"application/x-www-form-urlencoded;charset=UTF-8"}});return r.interceptors.request.use((function(e){return sessionStorage.getItem("anov-go-token")&&"null"!=sessionStorage.getItem("anov-go-token")&&(e.headers["X-ANOV-ACCESS-TOKEN"]=sessionStorage.getItem("anov-go-token")),sessionStorage.getItem("unify-access-token")&&"null"!=sessionStorage.getItem("unify-access-token")&&(e.headers["X-UNIFY-ACCESS-TOKEN"]=sessionStorage.getItem("unify-access-token")),sessionStorage.getItem("dgcc_authorization")&&"null"!=sessionStorage.getItem("dgcc_authorization")&&(e.headers.dgcc_authorization=sessionStorage.getItem("dgcc_authorization")),"post"===e.method?(e.headers["Content-Type"]="application/json;",e):"get"===e.method?e:"put"===e.method?(e.headers["Content-Type"]="application/json; charset=UTF-8",e):"delete"===e.method?e:void 0}),(function(e){return Promise.reject(e)})),r.interceptors.response.use((function(e){return 200===e.status||e.data.code,i&&i(e),e.data}),(function(e){return i&&i(null==e?void 0:e.response),Promise.reject(e.response)})),r};function l(e,t=!1){return t?d(e)?e:JSON.stringify(e):d(e)?JSON.parse(e):e}const d=e=>{if("string"==typeof e)try{const t=JSON.parse(e);return"object"==typeof t&&null!==t}catch(e){return!1}return!1},c=(e,t)=>{try{const i=JSON.stringify(t);sessionStorage.setItem(e,i)}catch(t){console.error(`Error setting session data for key ${e}:`,t)}},u=e=>{const t=sessionStorage.getItem(e);if(t)try{return JSON.parse(t)}catch(t){console.error(`Error parsing session data for key ${e}:`,t)}return null},h=e=>{for(const t of e)t.code&&(t.code=t.code.replace(/&gt;/g,">").replace(/&lt;/g,"<"))},p=(e,t)=>{e instanceof Map?e.forEach((e=>{t([e])})):Array.isArray(e)&&e.forEach((e=>{t(e.children)}))},f=(e,t)=>{const i=e=>{var r,o,a;if(e)for(const n of e){const e=null===(a=null===(o=null===(r=null==n?void 0:n.tmpData)||void 0===r?void 0:r.source)||void 0===o?void 0:o.converse)||void 0===a?void 0:a.data;(null==e?void 0:e.length)&&h(e),t(n),n.children?i(n.children):n.dynamicChildren?p(n.dynamicChildren,i):n.stateChildren&&i(n.stateChildren)}};i(e)},m=(e,t,i,r)=>{const o=e.match(/({{[\w]*}})|((@)[\w]*)/gm);if(o){const e=o.map((e=>e.replace(/{{|}}|@/gm,"")));for(const o of e)if(o&&t&&!(t.findIndex((e=>e.mapField===o))<0))return i&&r&&g(r,o,i.cid),!0}return!1},g=(e,t,i)=>{if(!e)throw new Error("Share variable tree is not defined");if("string"!=typeof t)throw new Error("Variable name should be a string");if(!i)throw new Error("ID is required");Array.isArray(e[t])||(e[t]=[]),e[t].includes(i)||e[t].push(i)},v=(e,t,i)=>{var r;let o=!1;const a=null==t?void 0:t.converse;if(a&&a.use&&a.data.length)for(const t of a.data)if((null==t?void 0:t.dependVars)&&t.dependVars.includes(e))return!0;const n=null==t?void 0:t[null==t?void 0:t.type];return((null==n?void 0:n.inputSql)||(null==n?void 0:n.url)||(null==n?void 0:n.headers)||(null==n?void 0:n.params))&&(o=m(n.inputSql||n.url||(null===(r=n.headers)||void 0===r?void 0:r.value)||n.params,i)),o},b=(e,i,r=!1)=>{let o=null;const a=e=>{for(const n of e){if(n.cid===i){o=n,r&&t.remove(e,(e=>e.cid===i));break}if(n.children&&a(n.children),n.dynamicChildren&&Array.isArray(n.dynamicChildren))for(const[,e]of Array.from(n.dynamicChildren))a(e);n.stateChildren&&a(n.stateChildren)}};return a(e),o},y=(e,i,r)=>{let o=!1;const a=e=>{for(let n=0;n<e.length;n++){if(e[n].cid==i){o=e[n],r&&t.remove(e,(e=>e.cid==i));break}if(e[n].children)a(e[n].children);else if(e[n].dynamicChildren){if(e[n].dynamicChildren instanceof Map){let t=Array.from(e[n].dynamicChildren);for(let e=0;e<t.length;e++)if(t[e]instanceof Array){let i=t[e][1];a(i)}}else if(e[n].dynamicChildren instanceof Array){let t=e[n].dynamicChildren;for(let e=0;e<t.length;e++)if(t[e]instanceof Array){let i=t[e][1];a(i)}}}else e[n].stateChildren&&a(e[n].stateChildren)}};return a(e),o||!1};function w(e,t,i){const r={};i&&i.forEach((e=>{(null==e?void 0:e.name)&&(r[e.name]=e.value||e.originvalue)}));try{return new Function("data","vars",e)(t,r)}catch(e){return console.error(e),t}}function D(e,i){let r=t.cloneDeep(i);try{return new Function("data",e)(r)}catch(e){return console.error(e),r}}const N=e=>{let t=window.goFetchList;return t||(window.goFetchList={},t=window.goFetchList),t[e]?!t[e]&&void 0:(t[e]={id:e,time:(new Date).getTime()},!0)},k=e=>{let t=window.goFetchList;t&&t[e]&&delete t[e]},C="anov@2019:helloX",V="anov@2020:helloX";function A(e){let t=r.enc.Utf8.parse(C),i=r.enc.Utf8.parse(V);return r.AES.encrypt(e,t,{iv:i,mode:r.mode.CBC,padding:r.pad.Pkcs7}).toString()}const O=new Blob(["\nfunction proxyObj(originObj) {\n const exposeObj = new Proxy(originObj, {\n has: (target, key) => {\n if (['fetch', 'XMLHttpRequest', 'postMessage'].indexOf(key) >= 0) {\n throw new Error('Illegal operation for key'+key)\n } else {\n return target[key]\n }\n },\n })\n return exposeObj\n}\nfunction compileCode(src) {\n src = 'with (exposeObj) {'+src+'}'\n //console.log(src)\n return new Function('exposeObj', src)\n}\nfunction run(code) {\n let proxy = proxyObj({})\n let result = compileCode(code)(proxy)\n return result\n}\n\nonmessage = (e) => {\n try {\n let result = run(e.data.code)\n postMessage({\n code: 1,\n result,\n })\n } catch (err) {\n postMessage({\n code: -1,\n err,\n })\n }\n}\n"]),F=URL.createObjectURL(O);function T(e,t,i={},r="worker"){return o(this,void 0,void 0,(function*(){try{if("window"==r){let[r,o]=[["data"],[t]];"object"==typeof i&&Object.keys(i).forEach((e=>{r.push(e),o.push(i[e])}));const a=new Function(...r,e);return{success:!0,data:a(...o)}}{let[r,a,n]=[t,i,""];"object"==typeof r&&(r=JSON.stringify(t)),"object"==typeof i&&(a=JSON.stringify(i)),Object.keys(i).forEach((e=>n+=`${e},`));let s=`let data=eval(${r}); \n             let app=${JSON.stringify({})};`;s+=n?`let {${n}} = eval(${a}); `:"",s+=`${e}`;let l=yield function(e,t=5e3){return o(this,void 0,void 0,(function*(){let i=new Worker(F);return new Promise(((r,o)=>{const a=()=>{clearTimeout(s),i.removeEventListener("message",n),i.terminate(),i=null},n=e=>{let{code:t,result:i,err:n}=e.data;a(),1===t?r(i):o(n)};i.postMessage({code:e}),i.addEventListener("message",n);let s=setTimeout((()=>{a(),o("timeout")}),t)}))}))}(s);return{success:!0,data:l}}}catch(e){return{success:!1,error:e,data:t}}}))}var x,E,S,j;!function(e){e.StaticFile="staticFile",e.DataSource="datasource"}(x||(x={})),function(e){e.json="application/json;charset=UTF-8",e.form="application/x-www-form-urlencoded; charset=UTF-8"}(E||(E={})),function(e){e.get="GET",e.post="POST",e.put="PUT",e.patch="PATCH",e.delete="DELETE"}(S||(S={}));class P{constructor(e){this.db=null,this.dbName=e.databaseName,this.tableName=e.tableName,this.keyPath=e.keyPath}static getInstance(e){return P.instance||(P.instance=new P(e)),P.instance}init(){return o(this,void 0,void 0,(function*(){return new Promise(((e,t)=>{const i=indexedDB.open(this.dbName,1);i.onerror=e=>{t(e.target.error)},i.onupgradeneeded=e=>{this.db=e.target.result,this.db.objectStoreNames.contains(this.tableName)||this.db.createObjectStore(this.tableName,{keyPath:this.keyPath})},i.onsuccess=t=>{this.db=t.target.result,e()}}))}))}addRecord(e){return o(this,void 0,void 0,(function*(){if(!this.db)throw new Error("数据库未初始化。");return new Promise(((t,i)=>{const r=this.db.transaction([this.tableName],"readwrite").objectStore(this.tableName).add(e);r.onsuccess=()=>{t()},r.onerror=e=>{i(e.target.error)}}))}))}deleteRecord(e){return o(this,void 0,void 0,(function*(){if(!this.db)throw new Error("数据库未初始化。");return new Promise(((t,i)=>{const r=this.db.transaction([this.tableName],"readwrite").objectStore(this.tableName).delete(e);r.onsuccess=()=>{t()},r.onerror=e=>{i(e.target.error)}}))}))}updateRecord(e){return o(this,void 0,void 0,(function*(){if(!this.db)throw new Error("数据库未初始化。");return new Promise(((t,i)=>{const r=this.db.transaction([this.tableName],"readwrite").objectStore(this.tableName).put(e);r.onsuccess=()=>{t()},r.onerror=e=>{i(e.target.error)}}))}))}getRecord(e){return o(this,void 0,void 0,(function*(){if(!this.db)throw new Error("数据库未初始化。");return new Promise(((t,i)=>{const r=this.db.transaction([this.tableName],"readonly").objectStore(this.tableName).get(e);r.onsuccess=()=>{t(r.result)},r.onerror=e=>{i(e.target.error)}}))}))}getAllRecords(){return o(this,void 0,void 0,(function*(){if(!this.db)throw new Error("数据库未初始化。");return new Promise(((e,t)=>{const i=this.db.transaction([this.tableName],"readonly").objectStore(this.tableName).getAll();i.onsuccess=()=>{e(i.result)},i.onerror=e=>{t(e.target.error)}}))}))}}P.instance=null,function(e){e[e.FATAL=0]="FATAL",e[e.ERROR=1]="ERROR",e[e.WARN=2]="WARN",e[e.INFO=3]="INFO",e[e.DEBUG=4]="DEBUG",e[e.TRACE=5]="TRACE"}(j||(j={}));const I={databaseName:"GODB",tableName:"go-log",keyPath:"time"};class U{constructor(){this.logLevel=j.INFO,this.indexedDBInstance=P.getInstance(I);try{this.indexedDBInstance.init(),console.log("IndexedDB 初始化成功。")}catch(e){console.error("初始化 IndexedDB 时出错:",e)}}static getInstance(){return U.instance||(U.instance=new U),U.instance}setLogLevel(e){this.logLevel=e}getColor(e){switch(e){case j.FATAL:return"";case j.ERROR:return"";case j.WARN:return"";case j.INFO:return"";case j.DEBUG:return"";case j.TRACE:return"";default:return""}}log(e,t){if(t<=this.logLevel){const i=(new Date).toISOString(),r=`[${i}] [${j[t]}]`,o=this.getColor(t);if(null===window||void 0===window?void 0:window.goDev)console.log(`${o}${r} ${e}`);else{let t=u("anov-go-userInfo"),a=u("anov-go-proid"),n=` [操作人:${null==t?void 0:t.userName} 项目ID:${a}] `;const s={time:i,value:`${e}`};try{this.indexedDBInstance.addRecord(s)}catch(e){console.error("添加记录时出错:",e)}console.log(`${o}${r} ${n} ${e}`)}}}fatal(e){this.log(e,j.FATAL)}error(e){this.log(e,j.ERROR)}warn(e){this.log(e,j.WARN)}info(e){this.log(e,j.INFO)}debug(e){this.log(e,j.DEBUG)}trace(e){this.log(e,j.TRACE)}}const $=U.getInstance(),M=(e,t)=>"string"!=typeof e?Promise.reject(new Error("URL should be a string")):s(e,t),R=s();let q=s();function L(e,i="get",r={},a={}){return o(this,void 0,void 0,(function*(){try{const s={method:S[i],url:e,headers:a,timeout:n};["post","put"].includes(i.toLowerCase())?s.data=t.cloneDeep(r):s.params=t.cloneDeep(r);return/.json$/.test(e)?function(e){return o(this,void 0,void 0,(function*(){try{return(yield R({method:"get",url:e})).data}catch(e){throw console.error("JSON 数据请求:",e),e}}))}(e):function(e){return o(this,void 0,void 0,(function*(){try{return{code:2e4,data:(yield R(e)).data}}catch(e){throw console.error("请求数据发生错误-Error:",e),e}}))}(s)}catch(e){throw console.error("获取数据:Error:",e),e}}))}function H(e,t,i,r){return o(this,void 0,void 0,(function*(){try{const o=window.anUrl||"",a=o+(window.agentPath||"/ds/v1/api-proxy/v1/query"),n=l(i,!0);return yield R({url:a,method:"post",headers:{"Content-Type":"application/json;charset=UTF-8"},data:{body:"post"===e?n:void 0,headers:d(r)?JSON.parse(r):r,method:e,url:t}})}catch(e){throw console.error("代理请求数据:Error:",e),e}}))}function G(e,t,i,r,a){return o(this,void 0,void 0,(function*(){return a?H(t,e,i,r):L(e,t,i,r)}))}function z(e,t="",i){var r,o,n,s;const l=`${null!==(o=null===(r=null===window||void 0===window?void 0:window.BaseUrl)||void 0===r?void 0:r.replace("/management",""))&&void 0!==o?o:""}/ds/data-engine/v1/${e}/zb-query?${`token=${(null===(n=te("YZH_EXCHANGE_TOKEN"))||void 0===n?void 0:n.YZH_EXCHANGE_TOKEN)||(null===(s=null===window||void 0===window?void 0:window.yzhAuth)||void 0===s?void 0:s.getToken())}&passid=${null===window||void 0===window?void 0:window.gdPassid}`}${(null===window||void 0===window?void 0:window.BASE_RELEASE)?"&preview=1":""}`;let d={};try{d=t?JSON.parse(t):{}}catch(e){d=t||{}}return R({method:"POST",url:l,data:{headers:i,param:d},timeout:a})}const B=(e,t)=>o(void 0,void 0,void 0,(function*(){const i=window.BaseUrl,{dateType:r="",endPeriod:o="",metricsName:n=e,startPeriod:s=""}=t;return q({method:"GET",url:`${i}ds/v1/metrics/v1/data-alarm?dateType=${r}&endPeriod=${o}&metricsName=${n}&startPeriod=${s}`,timeout:a})})),J=(e,t,i)=>o(void 0,void 0,void 0,(function*(){var r;const o=(null===(r=window.BaseUrl)||void 0===r?void 0:r.replace("/management",""))||"";t.newEncryption=!0;const n={staticFile:{method:"get",params:t,url:`${o}/ds/v1/file/v1/${e}/query`},datasource:{method:"post",url:`${o}/ds/v1/database/v1/${e}/query`,data:Object.assign({},t)}}[i];if(!n)throw new Error("Invalid data type provided");return R(Object.assign({timeout:a},n))})),W=e=>new Promise(((t,i)=>{let r;r=e.originData&&Object.keys(e.originData).length?e.originData:e.data,void 0!==r?t({data:r}):i("Failed to retrieve cdata")})),X=(e,t,i)=>{try{switch(t){case"api":{let t=re(e,i);return{requestType:t.requestType,url:t.url,params:t.params,headers:t.headers,agency:t.agency}}case"static":return{data:e};case"datasource":{const t=ie(e.inputSql,i);return{dsName:e.dsName,dsType:"1",sql:A(t),filter:e.sqlFilter}}case"staticFile":return{dsName:e.dsName,dsType:e.dsType,sql:""};case"indicator":return{zbId:e.zbId,params:ie(e.params,i),headers:ie(e.headers,i)};case"indicatorCQ":return{zbName:e.zbName,params:ie(e.params,i)};case"packData":return{};default:throw new Error("Invalid type")}}catch(t){console.log("准备请求数据发生错误",t,e)}},_=(e,t)=>o(void 0,void 0,void 0,(function*(){try{switch(t){case"api":return yield G(e.url,e.requestType,e.params,e.headers,e.agency);case"static":return yield W(e.data);case"datasource":return yield J(e.dsName,{dsType:e.dsType,sql:e.sql,filter:e.filter},"datasource");case"staticFile":return yield J(e.dsName,{dsType:e.dsType,sql:e.sql},"staticFile");case"indicator":return yield z(e.zbId,e.params,e.headers);case"indicatorCQ":return yield B(e.zbName,e.params);case"packData":return{};default:throw new Error("Invalid type")}}catch(e){return console.warn(e,"执行请求并获取数据发生错误"),yield new Promise(((e,t)=>{e({error:!0})}))}})),Q=(e,t,i,r=[],a=!1)=>o(void 0,void 0,void 0,(function*(){const o=t||e.tmpData.source.dataType,n=e.tmpData.source["indicatorCQ"==o?"indicator":o];if("globalData"===o){const e=r.find((e=>e.key===n.id||e.key===n.key)),t=u(n.id);if(t&&!a)return t.data;if(e){let t=yield Y(e,i),r={key:n.id,data:t};return c(n.id,r),t}return}const s=X(n,o,i),l=yield _(s,o);return(null==l?void 0:l.data)?l.data:l})),Y=(e,t)=>o(void 0,void 0,void 0,(function*(){let i=Object.assign({},{tmpData:{source:e.value}});const r=i.tmpData.source.type,o=i.tmpData.source[r],a=X(o,r,t),n=yield _(a,r);return yield K(n.data,i,!0,t)})),K=(e,i,r=!0,a)=>o(void 0,void 0,void 0,(function*(){try{const{converse:n,mapFields:s}=i.tmpData.source;return n&&n.use&&r?yield new Promise(((i,r)=>{const s=function(e,i,r,a,n){return o(this,void 0,void 0,(function*(){let r,o=e,{use:n,data:s}=t.cloneDeep(i);if(n)for(let e=0;e<s.length;e++)if(s[e].use){let i=s[e].dependVars,n={};a&&n&&i&&i.length&&i.map((e=>{let i=t.cloneDeep(a).filter((t=>{let i=t.mapField==e;return i&&(n[e]=t.value),i}));i&&0!=i.length||(n[e]="")})),r=yield T(s[e].code,o,n,s[e].mode?s[e].mode:"worker"),o=r.data}return o}))}(e,n,0,a);i(s)})):yield new Promise(((t,i)=>{t(e)}))}catch(t){return console.error("执行过滤器发生错误:"+t),yield new Promise(((t,i)=>{t(e)}))}})),Z=(e,t,i)=>{const{source:r}=e.tmpData,o=r.type;i?("static"===o&&r[o]&&(r[o].originData=i),"indicatorCQ"===o?r.indicator.data=t:r[o].data=t):"indicatorCQ"===o?r.indicator.data=t:r[o].data=t,e.source=t},ee=(e,t,i=[],r,a,n)=>o(void 0,void 0,void 0,(function*(){try{if(null==e?void 0:e.cid){if(!N(e.cid))return void console.warn("请求已经执行!")}let o=e.tmpData.source.type,s=yield Q(e,o,i,r,n||!1);if(null==s||!s)return a&&a({error:!0}),Promise.resolve({error:!0});let l=yield K(s,e,t,i);return Z(e,l),a&&a(l),(null==e?void 0:e.cid)&&k(e.cid),Promise.resolve(l)}catch(e){return a&&a(e),$.error("Error in updateComData"),console.error("Error in updateComData:",e),Promise.reject(e)}})),te=e=>{const t={};if(e&&e.includes("?")){const i=e.split("?")[1].split("&");for(let e of i){const[i,r]=e.split("=").map(decodeURIComponent);t[i]=r}}return t},ie=(e,t)=>{if(!t)return e;if("string"==typeof e)return""===e.trim()?"":e.replace(/@(\w+)|{{(\w+)}}/g,((e,i,r)=>{const o=i||r,a=t.find((e=>e.mapField===o));return a?a.value||a.originalValue||"":e}));if(Array.isArray(e))return e.map((e=>ie(e,t)));if("object"==typeof e&&null!==e){const i={};for(let r in e)i[r]=ie(e[r],t);return i}return e},re=(e,t)=>{const i=e.agency,r=e,{url:o=null,headers:a,params:n,requestType:s}=r,l=o?ie(o,t):void 0,d=a&&a.use?ie(a.value,t):{};return{url:l,requestType:s,params:n?ie(n,t):{},headers:d,agency:i}},oe=(e,t,i,r,a)=>o(void 0,void 0,void 0,(function*(){if(e&&e.length)for(const o of e){v(t,o.value,i)&&(yield ee({tmpData:{source:{type:"globalData",globalData:{id:o.key}}}},!0,i,e,(e=>{console.log("数据更新成功-变量改变全局数据跟新")}),!0),f(r,(t=>{var r,n,s;if("globalData"===(null===(n=null===(r=null==t?void 0:t.tmpData)||void 0===r?void 0:r.source)||void 0===n?void 0:n.type)){(null===(s=null==t?void 0:t.tmpData)||void 0===s?void 0:s.source.globalData).id===o.key&&ee(t,!0,i,e,(e=>{a(t,e)}),!1)}})))}})),ae=(e,t,i,r,a)=>o(void 0,void 0,void 0,(function*(){e&&(yield ee({tmpData:{source:{type:"globalData",globalData:{id:e.key}}}},!0,t,i,(e=>{console.log("数据更新成功-数据源编辑")}),!0),f(r,(r=>{var o,n,s;if("globalData"===(null===(n=null===(o=null==r?void 0:r.tmpData)||void 0===o?void 0:o.source)||void 0===n?void 0:n.type)){(null===(s=null==r?void 0:r.tmpData)||void 0===s?void 0:s.source.globalData).id===e.key&&ee(r,!0,t,i,(e=>{a(r,e)}),!1)}})))}));class ne{constructor(e,t){this.isUpdating=!1,this.des=e.des,this.field=e.field,this.id=e.id,this.key=e.key,this.mapping=e.mapping,this.mapField=e.mapField,this.type=e.type,this.originalValue=e.originalValue,this.model=(null==e?void 0:e.model)?null==e?void 0:e.model:1,this.converter=e.converter,this.converterCode=e.converterCode,this.fork=e.fork,this.delayUpdate=!!(null==e?void 0:e.delayUpdate),t&&(this.globalVariables=t),e.fork&&(this.model=5,this.forkValue=e.forkValue,this.originalValue=this.getForkedValue())}get value(){return this.fork&&(this.originalValue=this.getForkedValue()),this.converter&&this.converterCode?D(this.converterCode,this.originalValue):this.originalValue}getForkedValue(){if(this.forkValue&&Array.isArray(this.forkValue))return this.forkValue.map((e=>{const t=this.globalVariables.get(e);return t?t.value:null}));if(this.forkValue){const e=this.globalVariables.get(this.forkValue);return e?e.value:null}return null}updateValue(e,t){var r;const o=Object.assign({},this,e);this.des=o.des,this.field=o.field,this.mapping=o.mapping,this.type=o.type,this.originalValue=o.originalValue,this.converter=o.converter,this.converterCode=o.converterCode,this.fork=o.fork,this.delayUpdate=null==o?void 0:o.delayUpdate,this.model=null==o?void 0:o.model,e.id&&(this.id?"string"==typeof this.id?e.id instanceof Array?this.id=i([this.id,...e.id]):this.id=[this.id,e.id]:this.id instanceof Array&&(e.id instanceof Array?this.id=i([...this.id,...e.id]):this.id=i([...this.id,e.id])):this.id=e.id),e.fork&&(this.model=5,this.forkValue=null!==(r=e.forkValue)&&void 0!==r?r:this.forkValue,this.originalValue=this.getForkedValue()),t&&t(this)}updateWidthOriginalValue(e,t){var i;console.log(this.mapField,e,"--------"),this.originalValue=e,this.fork&&(this.forkValue=null!==(i=this.forkValue)&&void 0!==i?i:this.forkValue,this.originalValue=this.getForkedValue()),t&&t(this)}renew(e){e&&e(this)}static create(e,t){return new ne(e,t)}}class se{constructor(){this.variables=new Map,this.globalObservers=[],this.url=window.location.search,this.list=[]}clearVars(){this.list=[],this.variables.clear()}static getInstance(){return se.instance||(se.instance=new se),se.instance}getFullUrl(){this.url=window.location.search}getAllUrlParams(){const e=new URLSearchParams(window.location.search),t={};for(const[i,r]of e.entries())t[i]=r;return t}delVariable(e,t){this.variables.delete(e),this.list=this.list.filter((t=>t.mapField!=e)),t&&t()}addUrlParamsToGlobalVars(){this.getFullUrl();let e=this.getAllUrlParams(),t=Object.keys(e),i=[];for(const r of t)i.push({mapField:r,originalValue:e[r],model:4});if(i.length)for(const e of i)this.addVariable(e)}addVariables(e){Array.isArray(e)?e.map(((e,t)=>{this.addVariable(e)})):this.addVariable(e),this.addUrlParamsToGlobalVars()}addVariable(e,t){if(!e||!(null==e?void 0:e.mapField))return console.error(e+"参数不合法!"),!1;if(this.isVariableNameExist(e.mapField)){console.warn("变量名已存在");let i=this.getVariable(e.mapField);return this.sameValue(i,e)?i:(this.editVariable(e,t),!1)}const i=ne.create(e,this.variables);return this.variables.set(i.mapField,i),this.addToObjectArray(this.list,i),t&&t(i),this.notifyGlobalObservers(i),i}toJSON(e){try{return!!e&&JSON.stringify(e)}catch(e){return!1}}sameValue(e,t){if(e.mapfield!==t.mapfield)return!1;for(const i in t)if(!(["mapfield","field","key","value","name","globalVariables"].includes(i)||i in e&&e[i]==t[i]))return!1;return!0}creatVarJson(e){const{des:t,field:i,id:r,key:o,mapping:a,mapField:n,type:s,value:l,originalValue:d,model:c,converter:u,converterCode:h,fork:p,forkValue:f,update:m,delayUpdate:g}=e,v={};return void 0!==t&&(v.des=t),void 0!==i&&(v.field=i),void 0!==r&&(v.id=r),void 0!==o&&(v.key=o),void 0!==a&&(v.mapping=a),void 0!==n&&(v.mapField=n),void 0!==s&&(v.type=s),void 0!==l&&(v.value=l),void 0!==d&&(v.originalValue=d),void 0!==c&&(v.model=c),void 0!==u&&(v.converter=u),void 0!==h&&(v.converterCode=h),void 0!==p&&(v.fork=p),void 0!==f&&(v.forkValue=f),void 0!==m&&(v.update=m),void 0!==g&&(v.delayUpdate=g),v}addToObjectArray(e,t){let i=!1;for(let r=0;r<e.length;r++)if(e[r].mapField==t.mapField){e[r]=this.creatVarJson(t),i=!0;break}i||e.push(t)}editVariable(e,t){const i=this.getVariable(e.mapField);if(i&&this.isVariableNameExist(e.mapField)){if(this.sameValue(i,e))return}const r=e=>{if(!e.isUpdating){e.isUpdating=!0,this.notifyGlobalObservers(e);this.isMapFieldInForkValues(e.mapField).forEach((e=>{let t=this.getVariable(e.mapField);t&&t.renew((e=>{this.addToObjectArray(this.list,e),this.notifyGlobalObservers(e)}))})),this.addToObjectArray(this.list,e),t&&t(e),e.isUpdating=!1}};i?i.updateValue(e,r):this.addVariable(e,r)}getForkList(e){let t=this.isMapFieldInForkValues(e);return t||[]}editVariableForValue(e,t,i,r){const o=this.getVariable(e),a=e=>{if(!e.isUpdating){e.isUpdating=!0,this.notifyGlobalObservers(e);this.isMapFieldInForkValues(e.mapField).forEach((e=>{let t=this.getVariable(e.mapField);t&&t.renew((e=>{this.addToObjectArray(this.list,e),this.notifyGlobalObservers(e)}))})),this.addToObjectArray(this.list,e),i&&i(e),e.isUpdating=!1}};o&&o.updateWidthOriginalValue(t,a)}isMapFieldInForkValues(e){return this.getAllVariables().filter((e=>e.fork&&e.forkValue)).filter((t=>t.forkValue==e||Array.from(t.forkValue).includes(e)))}isVariableNameExist(e){return this.variables.has(e)}checkExist(e,t){if("string"==typeof e&&this.isVariableNameExist(e)){let i=this.getVariable(e);return t==i.id&&!i.id.includes(t)&&[{key:e}]}if(Array.isArray(e)){const i=e.filter((e=>{let i=this.getVariable(e);return this.isVariableNameExist(e)&&t!=i.id&&!(i.id&&i.id.includes(t))})).map((e=>({key:e})));return!!i.length&&i}return!1}getVariable(e){return this.variables.get(e)}getVariableForId(e){var i;let r=[];for(const[,t]of this.variables)(t.id===e||(null===(i=t.id)||void 0===i?void 0:i.includes(e)))&&r.push(t);return t.uniq(r)}getAllVariables(e=!1){return e?(this.list=Array.from(this.variables.values()),this.list):[...this.list]}restoreVariables(e){e.forEach((e=>{this.addVariable(e)}))}registerGlobalObserver(e){this.globalObservers.push(e)}notifyGlobalObservers(e){this.globalObservers.forEach((t=>{t.update(e)}))}}se.instance=null;const le=se.getInstance(),de=(e,t)=>Array.isArray(t)?t.some((t=>e&&(void 0!==e[t]||e.hasOwnProperty(t)))):"string"==typeof t&&(e&&(void 0!==e[t]||e.hasOwnProperty(t))),ce=(e,t,i,r)=>{const o=((e,t,i,r)=>{var o;let a;if(de(e,null==t?void 0:t.field)||de(e,null==t?void 0:t.forkValue))a=e[null==t?void 0:t.field]||"";else if(de(e.data,null==t?void 0:t.field)||de(e.data,null==t?void 0:t.forkValue))a=e.data[null==t?void 0:t.field]||"";else{const e=b(i,r),n=(null===(o=null==e?void 0:e.tmpData)||void 0===o?void 0:o.actions)||[];for(const e of n){const i=e.vars.find((e=>(null==e?void 0:e.mapField)===(null==t?void 0:t.mapField)));if(i){a=i.value;break}}}return a})(e,t,i,r);return void 0!==o?o:t.value},ue=(e,t,i,r,o,a,n,s,l)=>{switch(e.type){case"link":window.open(e.link,e.target);break;case"page":l&&l(e);break;case"dynamic":((e,t,i,r,o)=>{const a=e.dynamic||[];for(const n of a){if(e.id!==t.cid)continue;const a=b(i,n.pid);a&&(a.activeDynamic=n.name,a.isShow=n.visible||!r||e.index===t.index-1,o({cid:a.cid,flag:n.visible}))}})(e,t,i,r,o);break;case"toggle":((e,t,i,r,o)=>{const a=e.children||[];for(const i of a){const a=i.visible&&(!r||e.index===t.index-1);o({cid:i.cid,flag:a})}})(e,t,0,r,o);break;case"update":((e,t,i,r,o)=>{const a=e.children||[];for(const e of a){const a=b(t,e.cid);a&&ee(a,!0,i,r,(e=>{o({cid:a.cid,data:e})}))}})(e,i,a,n,s)}},he=(e,i,r,o,a,n,s,l,d,c)=>{const{cid:u,actions:h,index:p}=a,{eventName:f,mode:m}=h,g=2===m;((e,i,r,o,a,n)=>{let s=le.getVariableForId(i.cid);if(console.log("changeVarNew"),null==s?void 0:s.length)for(const l of s)if(l.type==e){let e=ce(i,l,r,o);le.editVariableForValue(l.mapField,e,(()=>{let e=a[l.mapField]||[],i=le.getForkList(l.mapField);if(i)for(const r of i){let i=a[r.mapField];e=t.concat(e,i)}n&&n(l,t.uniq(e))}))}})(f,a,o,u,r,((e,t)=>{if(oe(d,e.mapFile,le.getAllVariables(),o,((e,t)=>{s({cid:e.cid,data:t})})),null==t?void 0:t.length)for(const i of t){e.eventSourceId=i;const t=b(o,i);!(null==e?void 0:e.delayUpdate)&&t&&ee(t,!0,le.getAllVariables(),d,(e=>{s({cid:t.cid,data:e})}))}}));const v=((e,t,i,r,o)=>e.filter((e=>e.id===t&&e.eventType===i&&(!o||parseInt(e.index||"0")+1===parseInt(r||"0")))))(e,u,f,p,g);for(const e of v)ue(e,a,o,g,n,le.getAllVariables(),d,s,l)},pe=(e,t={})=>{let i={},r={type:"static",converse:{use:!1,data:[]},static:{data:e},api:{requestType:"get",url:"",headers:{use:!1,value:""},params:"",agency:!1,cookie:!0,autoUpdate:{open:!1,time:10},data:""}};return Object.assign(i,r,t),i},fe=(e,i)=>{let{option:r,actions:o,data:a,optionDes:n,actionsDes:s,source:l,theme:d}=((e,i)=>{let{option:r,actions:o,data:a,optionDes:n,actionsDes:s,source:l,theme:d}=t.cloneDeep(i[e]);return{option:r,actions:o,data:a,optionDes:n,actionsDes:s,source:l,theme:d}})(e,i);return{iconClass:null,isAssembly:null,source:a,cid:(Math.random().toString().substr(3,10)+Date.now()).toString(),isLock:!1,isShow:!0,tmpData:{option:r,source:pe(a,l),actions:o},baseData:ge(),dynamic:null,filePath:"",origin:"anov-ui",name:"",componentType:"",viewComName:e,optionComName:"AnOptionPanel",dataComName:"AnSourcePanel",eventComName:"AnActionsPanel",assemblyDeveloper:"",devEmail:"",version:"",devDept:""}},me=(e,i,r)=>{let o=fe(e,i);return r?t.merge(o,r):o},ge=e=>{let t={left:0,top:0,width:100,height:100,angle:0,penetrate:0,opacity:100,perspective:100,rotateX:0,rotateY:0,rotateZ:0,transformOriginX:"center",transformOriginY:"center",transformSwitch:!1};return e?Object.assign(t,e):t};class ve{constructor(e,t,i){this.theme=null,this.plant=null,this.list=[],this.titleHeqadeHeight=70,this.clearance=3,this.checkComponentIntersection=(e,t,i=10)=>{const r=e.left,o=e.left+e.width,a=e.top,n=e.top+e.height,s=t.left,l=t.left+t.width,d=t.top,c=t.top+t.height,u=r<l&&o>s&&a<c&&n>d,h=Math.abs(e.left+e.width/2-(t.left+t.width/2)),p=Math.abs(e.top+e.height/2-(t.top+t.height/2));return u||h<i&&p<i},this.calculateCombinedComponent=e=>{if(0===e.length)return{left:0,top:0,width:0,height:0};let t=e[0].left,i=e[0].top,r=e[0].left+e[0].width,o=e[0].top+e[0].height;for(let a=1;a<e.length;a++){const n=e[a];t=Math.min(t,n.left),i=Math.min(i,n.top),r=Math.max(r,n.left+n.width),o=Math.max(o,n.top+n.height)}return{left:t,top:i,width:r-t,height:o-i}},this.getAnTextNormaltText=e=>{var t,i;try{return null===(i=null===(t=null==e?void 0:e.tmpData)||void 0===t?void 0:t.option)||void 0===i?void 0:i.text}catch(e){return console.error("配置优化(ConfigOptimizer):",e),""}},this.initProp(e),this.upgradePlant(),this.staticComponentData=t,this.upgradeHeaderComponent(),i&&Object.assign(this,i)}isStringOrObject(e){return"string"==typeof e?"string":"object"==typeof e&&null!==e&&"object"}initProp(e){try{let t,i=this.isStringOrObject(e);if(i&&"string"===i)t=JSON.parse(e);else{if(!i||"object"!==i)throw new Error(`initProp fn error :-- 传入参数${e}不合法!`);t=e}if(t){this.originData=t;const{theme:e,plant:i,list:r}=t;this.theme=e,this.plant=i,this.list=r,this.filterFileGroup()}}catch(e){console.error("配置优化(ConfigOptimizer):",e)}}upgradePlant(){this.plant&&(this.plant.option.bg={type:1,code:"70942ec525344c96aa32b81b2c9155f6",path:"/anov-prod/resources/page/png/bg22 科技星球背景.png",thumb:"/anov-prod/resources/page/thumbnail/1e48f8fb26ec4edfb1a0f499627e84fc.png"})}areComponentsIntersecting(e,t){let i=e.baseData,r=t.baseData;const o=Math.max(0,Math.min(i.left+i.width,r.left+r.width)-Math.max(i.left,r.left)),a=Math.max(0,Math.min(i.top+i.height,r.top+r.height)-Math.max(i.top,r.top));return o>0&&a>0}filterFileGroup(){this.list=t.cloneDeep(this.list).map((e=>{var t,i;if(1===(null===(t=null==e?void 0:e.children)||void 0===t?void 0:t.length)&&!(null===(i=null==e?void 0:e.children[0])||void 0===i?void 0:i.children)){const t=e.children[0],{left:i,top:r}=e.baseData;return t.baseData.left=i,t.baseData.top=r,t}return e}))}getText(e,t,i){const r=document.createElement("canvas").getContext("2d");if(!r)throw new Error("Failed to get 2D context from canvas.");r.font=`${i}px ${t}`;return r.measureText(e).width}calculateMaxWidths(e){const t=Math.min(...e.map((e=>e.width))),i=[];let r=[],o=e[0].width;for(const a of e){const e=a.width;Math.abs(e-o)<=t?r.push(e):(r.length>0&&i.push(r),r=[e]),o=e}r.length>0&&i.push(r);const a=[];for(const e of i){const t=Math.max(...e);a.push(t)}return a}findClosestValue(e,t){let i=t[0],r=Math.abs(e-i);for(const o of t){const t=Math.abs(e-o);t<r&&(r=t,i=o)}return i}adjustHeightAndTop(e,t){const i=t-e.height;return Object.assign(Object.assign({},e),{height:t,top:e.top-i/2})}findNearestComponent(e,i,r){let o=null,a=1/0;i.tmpData.option.textNormal.text;try{const n=t.cloneDeep(e).sort(((e,t)=>e.baseData.top-t.baseData.top)).sort(((e,t)=>e.baseData.left-t.baseData.left)).filter((e=>!(e.cid===i.cid||"AnTextNormal"===e.viewComName||r&&r.includes(e.cid)))),s=t.cloneDeep(i).baseData;s.top,s.height;for(const e of n){const t=e.baseData;t.top,t.height;if(s.left<t.left+t.width&&s.left+s.width>t.left){const i=t.top-s.top;i<a&&i<100&&(a=i,o=e)}}}catch(e){console.error("配置优化(ConfigOptimizer)- findNearestComponent :",e)}return o}findNearestComponentForPoint(e,t,i){let r=null,o=1/0;t.tmpData.option.textNormal.text;try{const a=e.sort(((e,t)=>e.baseData.top-t.baseData.top)).sort(((e,t)=>e.baseData.left-t.baseData.left)).filter((e=>!(e.cid===t.cid||"AnTextNormal"===e.viewComName||i&&i.includes(e.cid)))),n=t.baseData;n.top,n.height;for(const e of a){const t=e.baseData;let i=this.getDistance(n.left,n.top+n.height,t.left,t.top);i<o&&i<n.width&&(o=i,r=e)}}catch(e){console.error("配置优化(ConfigOptimizer)- findNearestComponent :",e)}return r}findNearestComponentForTitlePoint(e,t,i){let r=null,o=1/0;t.tmpData.option.textNormal.text;try{const a=e.sort(((e,t)=>e.baseData.top-t.baseData.top)).sort(((e,t)=>e.baseData.left-t.baseData.left)).filter((e=>!(e.cid===t.cid||"AnTextNormal"===e.viewComName||i&&i.includes(e.cid)))),n=t.baseData;n.top,n.height;for(const e of a){const t=e.baseData;let i=this.getDistance(n.left,n.top+n.height,t.left,t.top);i<o&&i<n.width&&t.top-n.top>100&&(o=i,r=e)}}catch(e){console.error("配置优化(ConfigOptimizer)- findNearestComponent :",e)}return r}findNearestTitleForPoint(e,t,i){let r=null,o=1/0;t.tmpData.option.textNormal.text;try{const a=e.sort(((e,t)=>e.baseData.top-t.baseData.top)).sort(((e,t)=>e.baseData.left-t.baseData.left)).filter((e=>!(e.cid===t.cid||"AnTextNormal"===e.viewComName||i&&i.includes(e.cid)))),n=t.baseData;n.top,n.height;for(const e of a){const t=e.baseData;let i=t.top-n.top;i<o&&i<n.width&&t.top-n.top>100&&(o=i,r=e)}}catch(e){console.error("配置优化(ConfigOptimizer)- findNearestComponent :",e)}return r}getDistance(e,t,i,r){return Math.sqrt(Math.pow(i-e,2)+Math.pow(r-t,2))}findNearestComponent2(e,i,r){let o=null,a=1/0,n=t.cloneDeep(e).sort(((e,t)=>e.baseData.top-t.baseData.top));try{const e=n.filter((e=>!(e.cid===i.cid||"AnTextNormal"===e.viewComName||r&&r.includes(e.cid)))),s=t.cloneDeep(i).baseData,l=s.top+s.height;for(const t of e){const e=t.baseData,i=e.top+e.height;if(s.left<e.left+e.width&&s.left+s.width>e.left){const e=i-l;e>=0&&e<a&&(a=e,o=t)}}}catch(e){console.error("配置优化(ConfigOptimizer)- findNearestComponent :",e)}return o}verticalDistance(e,t){e.left,e.width;const i=e.top+e.height,r=(t.left,t.width,t.top);return Math.abs(i-r)}extractAmount(e){const t=e.match(/(\d{1,3}(?:,\d{3})*)(\D+)/);if(t){const e=t[1].replace(/,/g,"");return[parseInt(e,10),t[2].trim()]}return[!1,!1]}getAnTextNormal(){return this.list.filter((e=>"AnTextNormal"==e.viewComName))}getAnDeckTitle3(){return this.list.filter((e=>"AnDeckTitle3"==e.viewComName)).sort(((e,t)=>e.baseData.left-t.baseData.left))}judgeAnOdometer(){let e=this.getAnTextNormal().sort(((e,t)=>e.baseData.left-t.baseData.left)),t=[],i=new Set;for(const r of e){if(i.has(r.cid))continue;let o=[];for(const t of e){if(!i.has(t.cid)&&r.cid!=t.cid){this.checkComponentIntersection(r.baseData,t.baseData)&&(i.add(t.cid),i.add(r.cid),o.push(t))}}t.push([r,...o])}let r=[];for(const e of t)for(const t of e){let i=this.getAnTextNormaltText(t);this.extractAmount(i).every((e=>e))&&r.push(e)}return r}createAnOdometer(){var e,i;let r=this.judgeAnOdometer();for(const o of r){let r,a,n,s=this.calculateCombinedComponent(o.map((e=>e.baseData)));for(const e of o){let i=this.getAnTextNormaltText(e),o=this.extractAmount(i);o.every((e=>!e))&&(r=i),o.every((e=>e))&&(a=o[0],n=o[1]),t.remove(this.list,(t=>t.cid==e.cid))}let l=me("AnIndicatorNormal",this.staticComponentData,t.cloneDeep({baseData:s}));(null===(i=null===(e=null==l?void 0:l.tmpData)||void 0===e?void 0:e.source)||void 0===i?void 0:i.static)&&(l.tmpData.source.static.data={text:r,num:a,unit:n},l.tmpData.source.static.originData={text:r,num:a,unit:n}),this.list.push(l)}}upgradeHeaderComponent(){for(let e=0;e<this.list.length;e++){const t=this.list[e];"AnDeckHeader3"==t.viewComName&&(t.baseData.left=0,t.baseData.top=0)}}upgradeTitleComponent(){let e=this.getAnDeckTitle3().map((e=>e.baseData)),t=this.calculateMaxWidths(e);for(let e=0;e<this.list.length;e++){const i=this.list[e];if("AnDeckTitle3"==i.viewComName){let e=this.findClosestValue(i.baseData.width,t);i.baseData.width=e>300?e:300,i.baseData=this.adjustHeightAndTop(i.baseData,this.titleHeqadeHeight)}}this.removeErroneousComponents()}containsFractionStructure(e){return/\b\d+\/\d+\b/.test(e)}removeErroneousComponents(){let e=this.getAnDeckTitle3(),t=[];for(let i=0;i<e.length;i++){const r=e[i];let o=r.tmpData.option.textNormal.text;if(this.containsFractionStructure(o))for(let i=0;i<e.length;i++){const o=e[i];if(r.cid!=o.cid){this.areComponentsIntersecting(r,o)&&t.push(r.cid)}}}this.list=this.list.filter((e=>!t.includes(e.cid)))}upgradeGroupComponent(){try{let e=this.getAnDeckTitle3(),t=this.list.filter((e=>"AnDeckTitle3"!=e.viewComName&&"AnDeckHeader3"!=e.viewComName&&"AnTextNormal"!=e.viewComName)),i=[],r=[];for(let o=0;o<e.length;o++){const a=e[o];let n=this.findNearestComponentForPoint(t,a,i);if(n&&n.cid&&i.push(n.cid),n){a.baseData.left=n.baseData.left;let t=this.upgradeComponentHeight(a,e,r);t&&t>=30&&(n.baseData=Object.assign({},n.baseData,{top:a.baseData.top+a.baseData.height+this.clearance}))}}}catch(e){console.error("配置优化(ConfigOptimizer):",e)}}upgradeComponentHeight(e,i,r=[]){const o=e;let a=this.findNearestTitleForPoint(t.cloneDeep(i),o);return a?a.baseData.top-o.baseData.top-this.titleHeqadeHeight:1080-o.baseData.top-this.titleHeqadeHeight}getData(){return this.originData.list=this.list,this.originData.plant=this.plant,this.originData}}console.log(123);export{ve as ConfigOptimizer,se as GlobalVariables,M as Http,$ as Log,H as agentData,k as delFetchStatus,Z as editItem,he as emitEvent,Y as fetchDataByGlobal,Q as fetchDataByType,K as filterData,b as findItemDeep,y as findItemDeep2,L as getData,G as getDataForApi,J as getDataForSource,W as getDataForStatic,z as getDataForZb,B as getDataForZbCQ,u as getSessionData,l as getStandardData,m as getStringVars,ce as getVarDefaultVal,le as globalVars,v as hasVar,d as isJSON,f as recursion,w as safeEval,D as safeEvalForCode,N as setFetchStatus,c as setSessionData,oe as updataGlobalDataSourceForVar,ee as updateComData,ae as updateGlobalDataSource};
@@ -45,7 +45,6 @@ export declare class ConfigOptimizer {
45
45
  * @memberof ConfigOptimizer
46
46
  */
47
47
  getText(text: string, font: string, fontSize: number): number;
48
- createIndicatorComponent(text: string, num: number, unit: string): void;
49
48
  /**
50
49
  * 计算接近的 width 值的均值
51
50
  * @param data 数据项数组
@@ -83,20 +82,20 @@ export declare class ConfigOptimizer {
83
82
  */
84
83
  findNearestComponentForPoint(data: any[], targetComponent: any, excluded?: any[]): any | null;
85
84
  /**
86
- * 找到离目标组件下方最近的组件(两个顶点距离)-标题,
87
- * @param data 数据项数组
88
- * @param targetComponent 目标组件
89
- * @param excluded 要排除的组件列表
90
- * @returns 最近的组件,如果没有找到符合条件的组件则返回 null
91
- */
85
+ * 找到离目标组件下方最近的组件(两个顶点距离)-标题,
86
+ * @param data 数据项数组
87
+ * @param targetComponent 目标组件
88
+ * @param excluded 要排除的组件列表
89
+ * @returns 最近的组件,如果没有找到符合条件的组件则返回 null
90
+ */
92
91
  findNearestComponentForTitlePoint(data: any[], targetComponent: any, excluded?: any[]): any | null;
93
92
  /**
94
- * 找到离目标组件下方最近的组件(两个顶点距离)-标题,
95
- * @param data 数据项数组
96
- * @param targetComponent 目标组件
97
- * @param excluded 要排除的组件列表
98
- * @returns 最近的组件,如果没有找到符合条件的组件则返回 null
99
- */
93
+ * 找到离目标组件下方最近的组件(两个顶点距离)-标题,
94
+ * @param data 数据项数组
95
+ * @param targetComponent 目标组件
96
+ * @param excluded 要排除的组件列表
97
+ * @returns 最近的组件,如果没有找到符合条件的组件则返回 null
98
+ */
100
99
  findNearestTitleForPoint(data: any[], targetComponent: any, excluded?: any[]): any | null;
101
100
  getDistance(x1: number, y1: number, x2: number, y2: number): number;
102
101
  findNearestComponent2(data: any[], targetComponent: any, excluded?: any[]): any | null;
@@ -177,10 +176,10 @@ export declare class ConfigOptimizer {
177
176
  upgradeTitleComponent(): void;
178
177
  containsFractionStructure(text: string): boolean;
179
178
  /**
180
- *
181
- * 去除识别错误产生的标题组件
182
- * @memberof ConfigOptimizer
183
- */
179
+ *
180
+ * 去除识别错误产生的标题组件
181
+ * @memberof ConfigOptimizer
182
+ */
184
183
  removeErroneousComponents(): void;
185
184
  /**
186
185
  *
@@ -1,4 +1,4 @@
1
- import { StaticComponentData, GoComponentConfig } from '../common/type';
1
+ import { StaticComponentData, GoComponentConfig } from "../common/type";
2
2
  /**
3
3
  *
4
4
  * 更新组件配置信息
@@ -1,5 +1,5 @@
1
- import { GlobalEvent, GlobalVar } from './type';
2
- import { GlobalDataSourceItem, GoComponent } from '../fetchUtils/type';
1
+ import { GlobalEvent, GlobalVar } from "./type";
2
+ import { GlobalDataSourceItem, GoComponent } from "../fetchUtils/type";
3
3
  export declare const filterCurrentEvent: (globalEvents: GlobalEvent[], cid: string, eventName: string, index: any, isMode2: boolean) => GlobalEvent[];
4
4
  /**
5
5
  * 处理 dynamic 类型事件
@@ -35,17 +35,17 @@ export declare const handleToggleEvent: (item: any, element: GoComponent, list:
35
35
  */
36
36
  export declare const handleUpdateEvent: (item: any, list: any, globalVars: GlobalVar[], globalSource?: GlobalDataSourceItem[], updataSourceForComponent?: any) => void;
37
37
  /**
38
- * 处理不同类型的事件
39
- * @param {Object} item - 当前事件
40
- * @param {GoComponent} element - 当前组件
41
- * @param {Object} list - 组件列表
42
- * @param {boolean} isMode2 - 是否为模式2
43
- * @param {Function} changeShow - 更新组件显示状态的函数
44
- * @param {Function} callback - 回调函数
45
- * @param {GlobalVar[]} globalVars - 全局变量列表
46
- * @param {GlobalDataSourceItem[]} globalSource - 全局数据源列表
47
- * @param {Function} updataSourceForComponent - 更新组件数据的函数
48
- */
38
+ * 处理不同类型的事件
39
+ * @param {Object} item - 当前事件
40
+ * @param {GoComponent} element - 当前组件
41
+ * @param {Object} list - 组件列表
42
+ * @param {boolean} isMode2 - 是否为模式2
43
+ * @param {Function} changeShow - 更新组件显示状态的函数
44
+ * @param {Function} callback - 回调函数
45
+ * @param {GlobalVar[]} globalVars - 全局变量列表
46
+ * @param {GlobalDataSourceItem[]} globalSource - 全局数据源列表
47
+ * @param {Function} updataSourceForComponent - 更新组件数据的函数
48
+ */
49
49
  export declare const handleEventType: (item: any, element: GoComponent, list: any, isMode2: boolean, changeShow: (props: {
50
50
  cid: string;
51
51
  flag: boolean;
@@ -1,6 +1,6 @@
1
- import { GlobalEvent, GlobalVar } from './type';
2
- import { GlobalDataSourceItem, GoComponent } from '../fetchUtils/type';
3
- import { getVarDefaultVal } from './changeVar';
1
+ import { GlobalEvent, GlobalVar } from "./type";
2
+ import { GlobalDataSourceItem, GoComponent } from "../fetchUtils/type";
3
+ import { getVarDefaultVal } from "./changeVar";
4
4
  export { getVarDefaultVal };
5
5
  /**
6
6
  * 触发并处理组件事件
@@ -1,4 +1,4 @@
1
- import { BasicVariable, BasicVariableParams } from './BasicVariable';
1
+ import { BasicVariable, BasicVariableParams } from "./BasicVariable";
2
2
  type CallbackFunction = (result?: any) => void;
3
3
  interface GlobalObserver {
4
4
  update(variable: BasicVariable): void;
@@ -16,6 +16,7 @@ declare class GlobalVariables {
16
16
  getAllUrlParams(): {
17
17
  [key: string]: string;
18
18
  };
19
+ delVariable(mapField: string, callback?: CallbackFunction): void;
19
20
  addUrlParamsToGlobalVars(): void;
20
21
  addVariables(variablesData: BasicVariableParams[] | BasicVariableParams): void;
21
22
  addVariable(variableData: BasicVariableParams, callback?: CallbackFunction): BasicVariable;
@@ -24,7 +25,13 @@ declare class GlobalVariables {
24
25
  creatVarJson(item: BasicVariable | BasicVariableParams): any;
25
26
  private addToObjectArray;
26
27
  editVariable(variableData: BasicVariableParams, callback?: CallbackFunction): void;
27
- editVariableForValue(mapfield: string, value: any, callback?: CallbackFunction): void;
28
+ /**
29
+ *
30
+ *
31
+ * @memberof GlobalVariables
32
+ */
33
+ getForkList(mapFiled: string): any[];
34
+ editVariableForValue(mapfield: string, value: any, callback?: CallbackFunction, callback2?: CallbackFunction): void;
28
35
  isMapFieldInForkValues(mapField: string): BasicVariable[];
29
36
  private isVariableNameExist;
30
37
  checkExist(parameter: string | string[], cid: string): false | {
@@ -1,6 +1,6 @@
1
1
  export * from "./fetchUtils";
2
2
  export * from "./log";
3
3
  export * from "./event";
4
- export * from './tool';
5
- export * from './globalVars';
6
- export * from './ConfigOptimizer';
4
+ export * from "./tool";
5
+ export * from "./globalVars";
6
+ export * from "./ConfigOptimizer";
@@ -73,3 +73,11 @@ export declare function safeEval(code: string, params: any, globalVars?: any): a
73
73
  * @returns {any} - 执行结果或默认参数值
74
74
  */
75
75
  export declare function safeEvalForCode(code: string, _params: any): any;
76
+ /**
77
+ * 设置请求状态
78
+ *
79
+ * @param {string} fetchId
80
+ * @return {*}
81
+ */
82
+ export declare const setFetchStatus: (fetchId: string) => any;
83
+ export declare const delFetchStatus: (fetchId: string) => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wdslib/go-utils",
3
- "version": "0.2.3",
3
+ "version": "0.2.4",
4
4
  "description": "go-core utils",
5
5
  "main": "dist/index.js",
6
6
  "typings": "dist/types/index.d.ts",