@ibiz-template/runtime 0.7.2 → 0.7.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.
@@ -1 +1 @@
1
- System.register(["@ibiz-template/core","lodash-es","ramda","qx-util","qs","dayjs","async-validator","path-browserify"],(function(t,e){"use strict";var a,i,s,n,o,r,c,d,l,h,u,p,m,f,g,w,E,y,v,I,D,C,b,A,P,T,x,N,S,R,M,O,L,_,F,V,k,z,W,U,B,G,j,K,X,H,q,Y,Q,$,J,Z,tt,et,at,it,st,nt,ot,rt,ct,dt,lt,ht,ut,pt,mt,ft,gt,wt,Et,yt,vt,It;return{setters:[function(t){a=t.RuntimeModelError,i=t.ModelError,s=t.HttpError,n=t.NoticeError,o=t.RuntimeError,r=t.recursiveIterate,c=t.downloadFileFromBlob,d=t.IBizContext,l=t.DataTypes,h=t.clone,u=t.CoreConst,p=t.HttpResponse,m=t.updateKeyDefine,f=t.Net,g=t.getToken,w=t.NOOP,E=t.selectFile,y=t.IBizParams,v=t.isElementSame,I=t.findRecursiveChild,D=t.StringUtil,C=t.debounceAndAsyncMerge,b=t.EntityError,A=t.isOverlap,P=t.BitMask,T=t.mergeInLeft,x=t.awaitTimeout,N=t.mergeDefaultInLeft,S=t.plus,R=t.toNumberOrNil},function(t){M=t.isEmpty,O=t.isNil,L=t.isString,_=t.isArray,F=t.isObject,V=t.debounce,k=t.camelCase,z=t.eq,W=t.gt,U=t.gte,B=t.findIndex,G=t.lt,j=t.lte,K=t.upperFirst,X=t.snakeCase,H=t.kebabCase,q=t.isFunction,Y=t.isNumber},function(t){Q=t.isNil,$=t.mergeRight,J=t.isEmpty,Z=t.clone,tt=t.equals,et=t.where,at=t.mergeLeft,it=t.isNotNil,st=t.mergeDeepRight},function(t){nt=t.notNilEmpty,ot=t.isNilOrEmpty,rt=t.AsyncSeriesHook,ct=t.createUUID,dt=t.QXEvent,lt=t.isArray,ht=t.getCookie,ut=t.setCookie,pt=t.clearCookie,mt=t.ascSort,ft=t.descSort,gt=t.clearAll,wt=t.isNumber},function(t){Et=t.default},function(t){yt=t.default},function(t){vt=t.default},function(t){It=t.default}],execute:function(){t({SearchCondEx2filterNode:Cd,asyncImportData:or,calcContentAlignStyle:function(t){const{valignSelf:e,halignSelf:a}=t;let i;if(e||a){switch(i={display:"flex"},e){case"TOP":Object.assign(i,{"align-items":"flex-start"});break;case"MIDDLE":Object.assign(i,{"align-items":"center"});break;case"BOTTOM":Object.assign(i,{"align-items":"flex-end"})}switch(a){case"LEFT":Object.assign(i,{"justify-content":"flex-start"});break;case"CENTER":Object.assign(i,{"justify-content":"center"});break;case"RIGHT":Object.assign(i,{"justify-content":"flex-end"});break;case"JUSTIFY":Object.assign(i,{"justify-content":"space-between"})}}return i},calcDeCodeNameById:ve,calcDynaClass:we,calcDynaSysParams:async function(t,e,a={}){const i=a.appId||e.srfappid,s=a.viewParams||{},n={},o=await ibiz.hub.getAppDataEntity(t,i);if(s.srfkey)n.srfkey=s.srfkey;else{const t=e[o.codeName.toLowerCase()];t&&(n.srfkey=t)}if(s.srfparentkey&&s.srfparentdename)n.srfparentkey=s.srfparentkey,n.srfparentdename=s.srfparentdename;else{const t=an(e,o);if(t&&t.keys.length>1){const a=t.keys[t.keys.length-2];n.srfparentkey=s.srfparentkey||e[a],n.srfparentdename=s.srfparentdename||a}}return n},calcFilterModelBySchema:gd,calcGridLayoutPos:function(t){const{layout:e,colXS:a,colXSOffset:i,colSM:s,colSMOffset:n,colMD:o,colMDOffset:r,colLG:c,colLGOffset:d}=t,l=(t,a)=>({span:(t&&-1!==t?t:"TABLE_24COL"===e?24:12)*("TABLE_24COL"===e?1:2),offset:a&&-1!==a?a:void 0});return{xs:l(a,i),sm:l(s,n),md:l(o,r),lg:l(c,d)}},calcLayoutHeightWidth:ge,calcMainStateOPPrivsStrs:ye,calcNavParams:le,calcResPath:sn,calcSearchCondExs:Ad,calcSearchConds:Dd,compare:je,compareNumber:Ke,contains:Xe,convertNavData:oe,convertNavDataByArray:ce,convertObjectToNavParams:ne,downloadImportTemplate:ur,execDELogic:Qn,execDELogicAction:Jn,execDELogicById:$n,execFieldLogics:to,execUILogic:uc,exportData:dr,fieldValueToBoolean:on,filterFieldLogics:Ce,filterNode2SearchCond:Id,filterNode2SearchCondEx:bd,filterValueRules:ga,findAppDEMethod:fe,findChildFormDetails:Se,findDELogic:De,findEditItem:Ne,findFieldById:be,findModelChild:he,formatMultiData:de,generateEditorRules:er,generateRules:tr,getAllPanelField:ke,getAppCounterProvider:$i,getAppMenuItemProvider:Gs,getAppViewRef:function(t,e){var a,i;let s=t.appViewRefs||[];(null==(i=null==(a=t.viewLayoutPanel)?void 0:a.appViewRefs)?void 0:i.length)&&(s=s.concat(t.viewLayoutPanel.appViewRefs));return s.find((t=>t.name===e||t.id===e))},getAsyncActionProvider:function(t){const e=(a=t.actiontype||"DEFAULT",ibiz.register.get("".concat(As,"_").concat(a)));var a;if(e)return e;throw new o("找不异步操作类型".concat(t.actiontype,"对应的适配器"))},getChildNodeRSs:xe,getControl:ue,getControlPanel:me,getControlProvider:es,getControlsByView:Me,getCtrlTeleportParams:function(t){var e,a,i,s;const n=null==(a=null==(e=t.controlParam)?void 0:e.ctrlParams)?void 0:a.TELEPORTTAG,o="true"===(null==(s=null==(i=t.controlParam)?void 0:i.ctrlParams)?void 0:s.TELEPORTFLAG);return{teleportTag:n,teleportFlag:o}},getDEMethodProvider:Vs,getDERedirectToView:Be,getDataImportModels:lr,getDeACMode:async function(t,e,a){var i;const s=await ibiz.hub.getAppDataEntity(e,a);return null==(i=s.appDEACModes)?void 0:i.find((e=>e.id===t))},getDefaultValue:ir,getEditorProvider:ss,getEntitySchema:mr,getErrorViewProvider:function(t){let e;e||(a=t,e=ibiz.register.get("".concat(Ks,"_").concat(a)));var a;return e},getFormDetailProvider:rs,getGridColumnProvider:ls,getInternalMessageProvider:function(t){const e=(a=t.content_type||"DEFAULT",ibiz.register.get("".concat(js,"_").concat(a)));var a;if(e)return e;throw new o("找不站内信类型".concat(t.content_type,"对应的适配器"))},getMatchResPath:an,getOriginData:Zo,getOriginFilterNodes:yd,getPFPlugin:function(t,e){const i=ibiz.hub.getApp(e);if(!i)throw new a(i,"未找到应用");const{model:s}=i;if(!s.appPFPluginRefs)throw new a(s,"应用未配置插件");const n=s.appPFPluginRefs.find((e=>e.pluginCode.toLowerCase()===t.toLowerCase()));if(!n)throw new Error("未找到插件".concat(t));return n},getPanelItemProvider:ps,getPlatformProvider:Os,getPlatformType:Ns,getPortletProvider:gs,getRootNode:Pe,getTreeGridExColumnProvider:Ws,getTreeNode:Te,getUIActionById:Ae,getUIActionItemsByActionLevel:function(t,e){const a=[];return r(t,(t=>{if("DEUIACTION"===t.itemType){const i=t;i.actionLevel===e&&a.push(i)}}),{childrenFields:["detoolbarItems"]}),a},getUIActionProvider:vs,getUILogicNodeProvider:Ds,getViewEngines:Le,getViewLogics:Oe,getViewProvider:async function(t){let e;const{viewType:a,viewStyle:i,sysPFPluginId:s,appId:n}=t;if(s){const t=await Hi(s,n);if(t&&(e=bs(t)),e)return e;ibiz.log.error("找不到视图插件".concat(t,"对应的适配器"))}if(i&&"DEFAULT"!==i){if(e=bs("".concat(a,"_").concat(i)),e)return e;ibiz.log.error("找不到视图类型:[".concat(a,"]的视图样式:[").concat(i,"]对应的适配器"),t)}e||(e=bs(a));e||(e=bs("DEFAULT"));return e},getWFContext:aa,getWFSubmitViewId:function(t,e){var a;const{type:i,sequenceflowview:s,sequenceflowmobview:n}=e,o=(null==(a=t.viewLayoutPanel)?void 0:a.appViewRefs)||t.appViewRefs,r=i?"WFUTILACTION@".concat(i.toUpperCase()):"WFACTION@".concat(ibiz.env.isMob?n:s),c=null==o?void 0:o.find((t=>-1!==t.name.indexOf(r)));return null==c?void 0:c.refAppViewId},handleAllSettled:ba,hasDeCodeName:Ie,hasSubRoute:$o,importData:rr,importData2:cr,install:function(){const{ibiz:t}=window;t.util=new al,t.hub=new Jd,t.register=new Lt,t.config=new Ot,t.auth=new Cn,t.engine=new Zd,t.uiDomainManager=new Ia,t.markOpenData=new co,Mo(),vc(),oo(),Ys(),ibiz.scheduler=new hl,ibiz.scheduler.triggerFactory.register("ITEMVISIBLE",((t,e)=>new ml(t,e))),ibiz.scheduler.triggerFactory.register("ITEMENABLE",((t,e)=>new ml(t,e))),ibiz.scheduler.triggerFactory.register("ITEMBLANK",((t,e)=>new ml(t,e))),ibiz.scheduler.triggerFactory.register("TIMER",((t,e)=>new fl(t,e))),ibiz.scheduler.triggerFactory.register("CUSTOM",((t,e)=>new pl(t,e))),ibiz.scheduler.triggerFactory.register("VIEWEVENT",((t,e)=>new wl(t,e))),ibiz.scheduler.triggerFactory.register("CTRLEVENT",((t,e)=>new El(t,e))),ibiz.scheduler.executorFactory.register("SCRIPT",((t,e)=>new nl(t,e))),ibiz.scheduler.executorFactory.register("APPDEUILOGIC",((t,e)=>new ol(t,e))),ibiz.scheduler.executorFactory.register("DEUILOGIC",((t,e)=>new ol(t,e))),ibiz.scheduler.executorFactory.register("APPUILOGIC",((t,e)=>new gl(t,e))),ibiz.scheduler.executorFactory.register("APPDEUIACTION",((t,e)=>new yl(t,e))),function(){const t=new Ts;Rs("Browser",(()=>t))}(),t.platform=Os()},installCommand:Mo,isDataContainer:_e,isFormDataContainer:Re,isHiddenFilter:od,isSimpleItems:nd,isValueChange:Jo,matchMainState:Ee,openDataImport:hr,openRedirectView:We,parseSubFieldInfo:rd,parseUserParams:pe,parseViewProtocol:ze,presetAppCounterProvider:Ys,presetDEMethodProvider:oo,presetUIActionProvider:vc,registerAppCounterProvider:Yi,registerAppMenuItemProvider:function(t,e){ibiz.register.register("".concat(Us,"_").concat(t),e)},registerAsyncActionProvider:function(t,e){ibiz.register.register("".concat(As,"_").concat(t),e)},registerControlProvider:function(t,e){ibiz.register.register("".concat(Zi,"_").concat(t),e)},registerDEMethodProvider:_s,registerEditorProvider:function(t,e){ibiz.register.register("".concat(as,"_").concat(t),e)},registerErrorViewProvider:function(t,e){ibiz.register.register("".concat(Ks,"_").concat(t),e)},registerFormDetailProvider:function(t,e){ibiz.register.register("".concat(ns,"_").concat(t),e)},registerGridColumnProvider:function(t,e){ibiz.register.register("".concat(cs,"_").concat(t),e)},registerInternalMessageProvider:function(t,e){ibiz.register.register("".concat(js,"_").concat(t),e)},registerPanelItemProvider:function(t,e){ibiz.register.register("".concat(hs,"_").concat(t.toUpperCase()),e)},registerPlatformProvider:Rs,registerPortletProvider:function(t,e){ibiz.register.register("".concat(ms,"_").concat(t),e)},registerTreeGridExColumnProvider:function(t,e){ibiz.register.register("".concat(ks,"_").concat(t),e)},registerUIActionProvider:Es,registerUILogicNodeProvider:function(t,e){ibiz.register.register("".concat(Is,"_").concat(t),e)},registerViewProvider:function(t,e){ibiz.register.register("".concat(Cs,"_").concat(t),e)},selectAndImport:pr,strContain:He,testCond:Ge,toLocalOpenWFRedirectView:async function(t,e,a={}){const i=await Ue(t,e,a);await ibiz.commands.execute(No.TAG,i.viewId,i.context,i.params,i.opts)},validateFilterNodes:vd,verifyDeRules:$e,verifyFormGroupLogic:Ze,verifyPanelGroupLogic:ta});"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;function Dt(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Ct={exports:{}};!function(t,e){t.exports=function(t,e,a){var i=function(t,e){if(!e||!e.length||1===e.length&&!e[0]||1===e.length&&Array.isArray(e[0])&&!e[0].length)return null;var a;1===e.length&&e[0].length>0&&(e=e[0]),a=(e=e.filter((function(t){return t})))[0];for(var i=1;i<e.length;i+=1)e[i].isValid()&&!e[i][t](a)||(a=e[i]);return a};a.max=function(){var t=[].slice.call(arguments,0);return i("isAfter",t)},a.min=function(){var t=[].slice.call(arguments,0);return i("isBefore",t)}}}(Ct);var bt=Dt(Ct.exports),At={exports:{}};!function(t,e){t.exports=function(t,e){e.prototype.isSameOrBefore=function(t,e){return this.isSame(t,e)||this.isBefore(t,e)}}}(At);var Pt=Dt(At.exports),Tt={exports:{}};!function(t,e){var a,i;t.exports=(a="month",i="quarter",function(t,e){var s=e.prototype;s.quarter=function(t){return this.$utils().u(t)?Math.ceil((this.month()+1)/3):this.month(this.month()%3+3*(t-1))};var n=s.add;s.add=function(t,e){return t=Number(t),this.$utils().p(e)===i?this.add(3*t,a):n.bind(this)(t,e)};var o=s.startOf;s.startOf=function(t,e){var s=this.$utils(),n=!!s.u(e)||e;if(s.p(t)===i){var r=this.quarter()-1;return n?this.month(3*r).startOf(a).startOf("day"):this.month(3*r+2).endOf(a).endOf("day")}return o.bind(this)(t,e)}})}(Tt);var xt=Dt(Tt.exports),Nt={exports:{}};!function(t,e){var a,i;t.exports=(a="week",i="year",function(t,e,s){var n=e.prototype;n.week=function(t){if(void 0===t&&(t=null),null!==t)return this.add(7*(t-this.week()),"day");var e=this.$locale().yearStart||1;if(11===this.month()&&this.date()>25){var n=s(this).startOf(i).add(1,i).date(e),o=s(this).endOf(a);if(n.isBefore(o))return 1}var r=s(this).startOf(i).date(e).startOf(a).subtract(1,"millisecond"),c=this.diff(r,a,!0);return c<0?s(this).startOf("week").week():Math.ceil(c)},n.weeks=function(t){return void 0===t&&(t=null),this.week(t)}})}(Nt);var St=Dt(Nt.exports),Rt={exports:{}};!function(t,e){var a;t.exports=(a="day",function(t,e,i){var s=function(t){return t.add(4-t.isoWeekday(),a)},n=e.prototype;n.isoWeekYear=function(){return s(this).year()},n.isoWeek=function(t){if(!this.$utils().u(t))return this.add(7*(t-this.isoWeek()),a);var e,n,o,r=s(this),c=(e=this.isoWeekYear(),o=4-(n=(this.$u?i.utc:i)().year(e).startOf("year")).isoWeekday(),n.isoWeekday()>4&&(o+=7),n.add(o,a));return r.diff(c,"week")+1},n.isoWeekday=function(t){return this.$utils().u(t)?this.day()||7:this.day(this.day()%7?t:t-7)};var o=n.startOf;n.startOf=function(t,e){var a=this.$utils(),i=!!a.u(e)||e;return"isoweek"===a.p(t)?i?this.date(this.date()-(this.isoWeekday()-1)).startOf("day"):this.date(this.date()-1-(this.isoWeekday()-1)+7).endOf("day"):o.bind(this)(t,e)}})}(Rt);var Mt=Dt(Rt.exports),Ot=class{constructor(){this.view={enableDataInfoBar:!0,expCacheMode:"TABEXPPANEL:",disableHomeTabs:!1},this.grid={editShowMode:"row",editSaveMode:"cell-blur",overflowMode:"wrap"},this.appMenu={enableEcho:!0},this.codeList={timeout:36e5},this.form={mdCtrlConfirmBeforeRemove:!0},this.pickerEditor={overflowMode:"auto"}}},Lt=t("RegisterCenter",class{constructor(){this.providers=new Map}register(t,e){this.providers.set(t,e)}unRegister(t){this.providers.delete(t)}get(t,...e){const a=this.providers.get(t);if(a)return a(...e)}}),_t=t("DefaultErrorHandler",class{handle(t){return t instanceof a||t instanceof i?ibiz.message.error(t.message,10,!0):t instanceof s?401===t.status?ibiz.message.error("没有注册无权限错误处理器"):ibiz.notification.error({title:"",desc:t.message,duration:10}):t instanceof n?ibiz.message.error(t.message,t.duration,0===t.duration):t instanceof o&&ibiz.message.error(t.message,10,!0),ibiz.log.error(t),!0}}),Ft=t("ErrorHandlerCenter",class{constructor(){this.handlers=[]}register(t){this.handlers.unshift(t)}handleSingle(t){this.handlers.find((e=>!!e.handle(t)))||ibiz.log.error("没有找到能处理该错误的处理器",t)}handle(t){t instanceof Array?t.forEach((t=>{this.handleSingle(t)})):this.handleSingle(t)}}),Vt=class{static isHelperName(t){return this.helperNames.includes(t)}static handleJudgmentExecute(t,e,a){return a.fn?e?a.fn(t):a.inverse(t):e?a.hash.yes=!0:a.hash.no=!1}};Vt.helperNames=["lookup","log","and","camelCase","concat","eq","gt","get","lowerCase","lt","lte","neq","not","or","pascalCase","pluralize","snakeCase","spinalCase","upperCase"];var kt=class{constructor(t,e){t.registerHelper(e,this.onExecute)}},zt=class extends kt{constructor(t){super(t,"and")}onExecute(...t){const e=t[t.length-1];t.pop();const a=t.filter((t=>!!t)).length===t.length;return Vt.handleJudgmentExecute(this,a,e)}},Wt=class extends kt{constructor(t){super(t,"camelCase")}onExecute(t){return t?k(t):""}},Ut=class extends kt{constructor(t){super(t,"concat")}onExecute(...t){return t.pop(),t.join("")}},Bt=class extends kt{constructor(t){super(t,"eq")}onExecute(t,e,a){const i=z(t,e);return Vt.handleJudgmentExecute(this,i,a)}},Gt=class extends kt{constructor(t){super(t,"gt")}onExecute(t,e,a){const i=W(t,e);return Vt.handleJudgmentExecute(this,i,a)}},jt=class extends kt{constructor(t){super(t,"gte")}onExecute(t,e,a){const i=U(t,e);return Vt.handleJudgmentExecute(this,i,a)}},Kt=class extends kt{constructor(t){super(t,"eqPropertyValue")}onExecute(t,e,a,i){let s=!1;return s=_(t)?!z(B(t,(t=>z(t[e],a))),-1):t.hasOwnProperty(e)&&(s=z(t[e],a)),Vt.handleJudgmentExecute(this,s,i)}},Xt=class extends kt{constructor(t){super(t,"jsonParse")}onExecute(t){return JSON.parse(t)}},Ht=class extends kt{constructor(t){super(t,"jsonStringify")}onExecute(t,e){return JSON.stringify(t,null,"number"==typeof e?e:void 0)}},qt=class extends kt{constructor(t){super(t,"lowerCase")}onExecute(t){return t?t.toLowerCase():""}},Yt=class extends kt{constructor(t){super(t,"lt")}onExecute(t,e,a){const i=G(t,e);return Vt.handleJudgmentExecute(this,i,a)}},Qt=class extends kt{constructor(t){super(t,"lte")}onExecute(t,e,a){const i=j(t,e);return Vt.handleJudgmentExecute(this,i,a)}},$t=class extends kt{constructor(t){super(t,"neq")}onExecute(t,e,a){const i=!z(t,e);return Vt.handleJudgmentExecute(this,i,a)}},Jt=class extends kt{constructor(t){super(t,"not")}onExecute(t,e){const a=J(t)||Q(t);return Vt.handleJudgmentExecute(this,a,e)}},Zt=class extends kt{constructor(t){super(t,"or")}onExecute(...t){var e;const a=t[t.length-1];t.pop();const i=t.find((t=>!!t));if(a.fn){const t=(null==(e=a.data)?void 0:e.root)||{};return i?a.fn(t):a.inverse(t)}return i||""}},te=class extends kt{constructor(t){super(t,"pascalCase")}onExecute(t){return t?K(t):""}},ee=class extends kt{constructor(t){super(t,"snakeCase")}onExecute(t){return t?X(t):""}},ae=class extends kt{constructor(t){super(t,"spinalCase")}onExecute(t){return t?H(t):""}},ie=class extends kt{constructor(t){super(t,"upperCase")}onExecute(t){return t?t.toUpperCase():""}};var se=t("HandlebarsUtil",class{constructor(){this.p=null}get isInit(){return!!this.hsb}async init(){if(this.isInit)return;if(this.p)return this.p;this.p=e.import("handlebars");const t=await this.p;var a;return this.hsb=t.default||t,this.p=null,a=this.hsb,new zt(a),new Wt(a),new Ut(a),new Bt(a),new Gt(a),new jt(a),new Xt(a),new Ht(a),new qt(a),new Yt(a),new Qt(a),new $t(a),new Jt(a),new Zt(a),new te(a),new ee(a),new ae(a),new ie(a),new Kt(a),this.hsb}async render(t,e){this.hsb||await this.init();return this.hsb.compile(t)(e)}syncRender(t,e){if(!this.hsb)throw new Error("handlebars not init");return this.hsb.compile(t)(e)}});function ne(t){const e=[],a=/^%(.+)%$/;for(const i in t){let s=!0,n=t[i];nt(t[i])&&a.test(t[i])&&(s=!1,n=t[i].substring(1,t[i].length-1)),e.push({key:i.toLowerCase(),rawValue:s,value:n})}return e}function oe(t,...e){if(!t||M(t))return{};return ce(Array.isArray(t)?t:ne(t),...e)}function re(t,e){const a=t.find((t=>!ot(t)&&(t[e]||Object.prototype.hasOwnProperty.call(t,e))));return{find:!!a,value:null==a?void 0:a[e]}}function ce(t,...e){const a=/\$\{[^}]*\}/g,i={};for(const s of t)if(s.rawValue)i[s.key.toLowerCase()]=s.value||null;else{const t=s.value.match(a);if(null!==t){let a=s.value;t.forEach((t=>{const{find:i,value:s}=re(e,t.slice(2,-1).toLowerCase());i&&(a=a.replace(t,"".concat(O(s)?"":s)))})),i[s.key.toLowerCase()]=a}else{const{find:t,value:a}=re(e,s.value.toLowerCase());t&&(i[s.key.toLowerCase()]=a)}}return i}function de(t,e){const a={};if(!t)return a;const i=Array.isArray(t)?t:ne(t),s=e[0];return i.forEach((t=>{const{rawValue:i,value:n}=t;!i&&n&&Object.prototype.hasOwnProperty.call(s,n)&&(a[n]=e.map((t=>t[n])).join(";"))})),a}function le(t,e){const{deName:a,navFilter:i,pickupDEFName:s,navContexts:n,navParams:o}=t,{context:r,params:c,data:d,derValue:l}=e,h={},u={},p=l||d.srfkey;p&&(a&&(h[a]=p),i&&(u[i]=p),s&&(u["n_".concat(s.toLowerCase(),"_eq")]=p));const m=oe(n,d,c,r),f=oe(o,d,c,r);return Object.assign(h,m),Object.assign(u,f),{resultContext:h,resultParams:u}}function he(t,e){if(t&&e){const a=t.find((t=>!!t.id&&t.id.toLowerCase()===e.toLowerCase()));if(a)return a}return null}function ue(t,e){var a,i;let s=t.controls||[];return(null==(i=null==(a=t.viewLayoutPanel)?void 0:a.controls)?void 0:i.length)&&(s=s.concat(t.viewLayoutPanel.controls)),s.find((t=>t.name===e||t.codeName===e||t.id===e))}function pe(t){const e={},a={},i={};for(const s in t)if(Object.prototype.hasOwnProperty.call(t,s)){const n=t[s];if(-1!==s.indexOf(".")){const t=s.split(".");switch(t[0]){case"SRFNAVPARAM":Object.assign(a,{[t[1]]:n});break;case"SRFNAVCTX":Object.assign(e,{[t[1]]:n});break;default:Object.assign(i,{key:n})}}}return{navigateContexts:e,navigateParams:a,other:i}}function me(t){let e;if(t.controlRenders){const a=t.controlRenders.find((t=>"LAYOUTPANEL"===t.renderType&&!!t.layoutPanel));e=null==a?void 0:a.layoutPanel}return e}function fe(t,e){const a=t.appDEMethods;if(a&&e){const t=he(a,e);if(t)return t;const i=a.find((t=>{switch(t.methodType){case"DEACTION":{const{actionTag:a}=t;return(null==a?void 0:a.toLowerCase())===e.toLowerCase()}case"FETCH":{const{dataSetTag:a}=t;return"fetch".concat(null==a?void 0:a.toLowerCase())===e.toLowerCase()}default:return!1}}));if(i)return i}return null}function ge(t){const{width:e,height:a,widthMode:i,heightMode:s}=t,n={width:"",height:""};return"FULL"===i?n.width="100%":e&&e>0&&(n.width=e>0&&e<=1?"".concat(100*e,"%"):"".concat(e,"PERCENTAGE"===i?"%":"px")),"FULL"===s?n.height="100%":a&&a>0&&(n.height=a>0&&a<=1?"".concat(100*a,"%"):"".concat(a,"PERCENTAGE"===s?"%":"px")),n}function we(t,e){const a=[],i=Qe.execScriptFn({data:e},t,{singleRowReturn:!0,isAsync:!1});return L(i)?a.push(i):_(i)?a.push(...i):F(i)&&Object.keys(i).forEach((t=>{i[t]&&a.push(t)})),a}function Ee(t,e){const{mainStateAppDEFieldIds:a,demainStates:i}=t;if(a&&i){const t=[];return a.forEach((a=>{t.push(e[a])})),i.find((e=>{const{stateValue:a,state2Value:i,state3Value:s}=e;let n=!0;const o=[a,i,s];for(let e=0;e<t.length;e++)if("".concat(t[e])!=="".concat(o[e])){n=!1;break}return n}))}}function ye(t,e){const a=ibiz.hub.getApp(e.appId).model,{demainStateOPPrivs:i,opprivAllowMode:s}=t,n=(null==i?void 0:i.map((t=>t.name)))||[];let o=[];if(s)o=n;else{o=[...a.deopprivs,...e.deopprivs].filter((t=>!n.includes(t.name))).map((t=>t.name))}return o}function ve(t){return t.split(".").pop()}function Ie(t,e){const a=ve(e);return nt(t[a])}function De(t,e){var a;return null==(a=e.appDELogics)?void 0:a.find((e=>e.id===t))}function Ce(t,e){var a,i;const s=[];return null==(a=t.appDEFields)||a.forEach((t=>{"compute"===e&&t.computeAppDEFLogicId?s.push(t.computeAppDEFLogicId):"change"===e&&t.onChangeAppDEFLogicId?s.push(t.onChangeAppDEFLogicId):"default"===e&&t.defaultValueAppDEFLogicId&&s.push(t.defaultValueAppDEFLogicId)})),(null==(i=t.appDELogics)?void 0:i.filter((t=>s.includes(t.id))))||[]}function be(t,e){var a;return null==(a=t.appDEFields)?void 0:a.find((t=>t.id===e))}async function Ae(t,e){return ibiz.hub.getApp(e).getUIAction(t)}function Pe(t){return t.detreeNodes.find((t=>t.rootNode))}function Te(t,e){return t.detreeNodes.find((t=>t.id===e))}function xe(t,e){const a=e.parentId||Pe(t).id;return t.detreeNodeRSs.filter((t=>{return t.parentDETreeNodeId===a&&(i=t.searchMode,s=e.hasQuery,3===i||(s?1===i:2===i));var i,s}))}function Ne(t,e){var a;return null==(a=t.degridEditItems)?void 0:a.find((t=>t.codeName===e))}function Se(t){let e;switch(t.detailType){case"TABPANEL":e=t.deformTabPages;break;case"FORMPAGE":case"TABPAGE":case"GROUPPANEL":e=t.deformDetails}return e||[]}function Re(t){return"MDCTRL"===t.detailType}function Me(t){const{viewLayoutPanel:e}=t,a=t.controls||[];return e&&a.push(...e.controls||[]),a}function Oe(t){const{viewLayoutPanel:e}=t,a=t.appViewLogics||[];return e&&a.push(...e.appViewLogics||[]),a}function Le(t){const{viewLayoutPanel:e}=t,a=t.appViewEngines||[];return e&&a.push(...e.appViewEngines||[]),a.filter((t=>"CTRL"!==t.engineCat||(ibiz.log.warn("未支持的引擎分类:".concat(t.engineType)),!1)))}function _e(t){return"CONTAINER"===t.itemType&&["CONTAINER_MULTIDATA","CONTAINER_SINGLEDATA"].includes(t.predefinedType)}var Fe=["panelItems","panelTabPages","rootPanelItems"];function Ve(t){let e=[];for(const a of Fe)if(t[a]&&t[a].length&&t[a].length>0){e=t[a];break}const a=[];return e.length&&(a.push(...e.filter((t=>"FIELD"===t.itemType))),e.forEach((t=>{_e(t)||a.push(...Ve(t))}))),a}function ke(t){return Ve(t)}function ze(t){const e=new URL(t),a={},i={};let s="";if(e.searchParams.size>0){const s=e.searchParams.get("srfnavctx");if(s){try{Object.assign(a,JSON.parse(s))}catch(e){ibiz.log.error("重定向[".concat(t,"] 中 srfnavctx 参数解析失败"),e)}e.searchParams.delete("srfnavctx")}e.searchParams.forEach(((t,e)=>{i[e]=t}))}const n=e.pathname.replace("//","").split("/"),[o,r]=n;return s=r||o,{context:a,params:i,viewId:s}}async function We(t,e,a={},i={}){return async function(t,e,a={},i={}){let s;try{s=await Be(t,e,a,i)}catch(t){return ibiz.log.error(t),{ok:!1,data:[]}}if("url"===s.type){const t=s.url;return new Promise((e=>{const a=window.open(t,"_blank");a&&(a.callback=()=>{e({ok:!0,data:[]})})}))}return await ibiz.commands.execute(No.TAG,s.viewId,s.context,s.params,s.opts)||{ok:!0,data:[]}}(t,e,a,i)}async function Ue(t,e,a={}){const i=e.lastIndexOf("?"),s=decodeURIComponent(e.substring(i+1,e.length)),n=Et.parse(s,{delimiter:";"}),r=n.srfdename||"";if(!r)throw new o("重定向参数缺少实体名称");const c=ibiz.hub.getApp(t.srfappid).deName2DeCodeName.get(r.toUpperCase());if(!c)throw new o("未找到指定实体的codeName: ".concat(r));n[c.toLowerCase()]=n[r.toLowerCase()];const d="".concat(c).concat(ibiz.env.isMob?"Mob":"","RedirectView"),l=await ibiz.hub.getAppView(d);if(delete n.srfdename,"undo"!==n.srfwf){const t=n.processDefinitionKey.split("-")[3],e=t.substring(0,t.lastIndexOf("v")),a=t.substring(t.lastIndexOf("v"));n.wf=e,n.wfVersion=a}return n.srfprocessinstanceid&&(t.srfprocessinstanceid=n.srfprocessinstanceid,delete n.srfprocessinstanceid),{context:t,params:n,opts:a,viewId:l.id}}async function Be(t,e,i={},s={}){var n;const r=oe(t.appViewNavContexts||[],i,e);e=Object.assign(e.clone(),r);const c=oe(t.appViewNavParams||[],i,e);Object.assign(i,c);const d=t.appDataEntityId,l=ve(d);let h=(null==(n=s.data)?void 0:n[0])||{};e[l]=h[l]||e[l]||i[l];const u=t.getDataAppDEActionId,p=ibiz.hub.getApp(t.appId),m=await p.deService.getService(e,d);ibiz.loading.showRedirect();try{const t=await m.exec(u||"get",e,i);if(t.ok){h=t.data;let a=h.linkurl;if(a){if(e.srfprocessinstanceid&&(a+=";srfprocessinstanceid=".concat(e.srfprocessinstanceid)),ibiz.env.dev&&-1!==a.indexOf("appredirectview?")&&(a=a.slice(a.indexOf("appredirectview?"))),a.startsWith("http://")||a.startsWith("https://"))return{type:"url",url:a};if(a.startsWith("appredirectview?")){return{type:"view",...await Ue(e,a,s)}}throw new o("未支持的linkUrl格式:".concat(a))}}}finally{ibiz.loading.hideRedirect()}const f=await ibiz.hub.getAppDataEntity(d,t.appId),g=await async function(t,e,a,i){let s="";const n=e.typeAppDEFieldId;if(n){const{codeName:a}=be(t,n),s=i[a.toLowerCase()];if(nt(s))return s.startsWith("view://")?s:"".concat(s.toUpperCase());ibiz.log.warn("重定向视图[".concat(e.name,"]自定义类别属性[").concat(n,"]值为空"),i)}const o="".concat(ibiz.env.isMob?"MOB":"","EDITVIEW"),r=a.srfwf;if(nt(r))return nt(a.wf)?"".concat(o,":").concat(r.toUpperCase(),":").concat(a.wf.toUpperCase()):"".concat(o,":").concat(r.toUpperCase());let c="";if(t.indexTypeAppDEFieldId){const{codeName:e}=be(t,t.indexTypeAppDEFieldId);c=i[e.toLowerCase()]}if(ot(c)&&t.formTypeAppDEFieldId){const{codeName:e}=be(t,t.formTypeAppDEFieldId);c=i[e.toLowerCase()]}s=nt(c)?"".concat(o,":").concat(c.toString().toUpperCase()):"".concat(o);return s}(f,t,i,h);let w="";if(!g.startsWith("view://")){const n=g.split(":"),o=2===n.length?g:n.slice(0,2).join(":"),r="".concat(f.name.toUpperCase(),":").concat(g),c=[];t.redirectAppViewRefs&&c.push(...t.redirectAppViewRefs),t.appViewRefs&&c.push(...t.appViewRefs);const d=c.find((t=>{const e=t.name||t.id;return e===r||e===g||e===o}));if(d){if(w=d.refAppViewId,d.openMode&&(s.openMode=d.openMode),w)return{type:"view",viewId:w,context:e,params:i,opts:{...s,data:[h]}};throw new a(d,"未配置实际引用视图")}throw ibiz.log.error("重定向视图引用有:",null==c?void 0:c.map((({refAppViewId:t,name:e,realTitle:a})=>({viewId:t,tag:e,title:a})))),new a(t,"未找到重定向标识[".concat(g,"]或[").concat(r,"]或工作流[").concat(o,"]对应视图"))}{const t=ze(g);Object.assign(e,t.context),Object.assign(i,t.params),w=t.viewId}if(w)return{type:"view",viewId:w,context:e,params:i,opts:{...s,data:[h]}};throw new a(t,"标识[".concat(g,"]未匹配到实际引用视图"))}function Ge(t,e,a){if(Object.is(e,"IN"))return Xe(t,a);if(Object.is(e,"NOTIN"))return!Xe(t,a);switch(e){case"EQ":return"".concat(t)==="".concat(a);case"NOTEQ":return"".concat(t)!=="".concat(a);case"LT":return je(t,a)<0;case"LTANDEQ":return je(t,a)<=0;case"GT":return je(t,a)>0;case"GTANDEQ":return je(t,a)>=0;case"ISNULL":return ot(t);case"ISNOTNULL":return nt(t);case"TESTNULL":return Q(t);case"IN":return Xe(t,a);case"NOTIN":return!Xe(t,a);case"LIKE":return He(t,a);case"LEFTLIKE":return He(t,a,"start");case"RIGHTLIKE":return He(t,a,"end");default:throw new o("值操作:".concat(e,",暂未支持"))}}function je(t,e){const a=Number(t),i=Number(e);if(!Number.isNaN(a)&&!Number.isNaN(i))return Ke(a,i);const s=new Date(t).getTime(),n=new Date(e).getTime();if(!Number.isNaN(s)&&!Number.isNaN(n))return Ke(s,n);throw new o("".concat(t," 和 ").concat(e," 无法比较大小"))}function Ke(t,e){return Number.isNaN(t)&&(t=0),Number.isNaN(e)&&(e=0),t>e?1:t<e?-1:0}function Xe(t,e){if(!e||"string"!=typeof e)throw new o("范围比较的条件值不存或者不是字符串");if(t){return e.split(",").includes("".concat(t))}return!1}function He(t,e,a){if(!t||!e)return!1;const i="".concat(t).toUpperCase(),s="".concat(e).toUpperCase(),n=i.indexOf(s);switch(a){case"start":return 0===n;case"end":return n+s.length===i.length;default:return-1!==n}}var qe={singleRowReturn:!1,isAsync:!0},Ye=t("ScriptFunction",class{constructor(t,e,a=qe){this.argKeys=[],this.options=a;const i=this.formatCode(e,a);this.calcArgKeys(t,a);const s=new Function(...this.argKeys,i);this.scriptFn=function(...t){try{return s.apply({},t)}catch(t){throw ibiz.log.error("报错脚本",i),t}}}formatCode(t,e){let a=t;return e.singleRowReturn&&(a="return (".concat(a,")")),e.isAsync&&(a="return (async function() { ".concat(a,"} )();")),a}calcArgKeys(t,e){const a=e.presetParams?Object.keys(e.presetParams):[];a.push(...t);a.push("document","el","selector","env","appSession","topViewSession","viewSession","context","viewParam","activeData","data","app","topView","parentView","view","parent","util","ctrl"),this.argKeys=Array.from(new Set(a))}convertArgs(t){const{presetParams:e}=this.options,a=e?$(e,t):t;a.document=document,a.selector=t=>document.getElementsByClassName(t);const i=[];return this.argKeys.forEach((t=>{void 0===a[t]&&this.fillDefaultParams(t,a),i.push(a[t])})),i}fillDefaultParams(t,e){switch(t){case"util":e.util={message:ibiz.message,notification:ibiz.notification,modal:ibiz.modal,confirm:ibiz.confirm,openView:ibiz.openView};break;case"viewParam":e.viewParam=e.params;break;case"env":e.env=ibiz.env;break;case"app":e.app=ibiz.hub.controller;break;case"appSession":e.appSession=ibiz.hub.controller.session}const a=e.view;if(a)switch(t){case"parent":e.parent=a.parentView;break;case"topView":e.topView=a.getTopView();break;case"parentView":e.parentView=a.parentView;break;case"topViewSession":e.topViewSession=a.getTopView().session;break;case"viewSession":e.viewSession=a.session}}exec(t){const e=this.convertArgs(t);return this.scriptFn(...e)}}),Qe=t("ScriptFactory",class{static createScriptFn(t,e,a){return new Ye(t,e,a)}static execScriptFn(t,e,a){return this.createScriptFn(Object.keys(t),e,a).exec(t)}static execSingleLine(t,e={}){return this.execScriptFn(e,t,{singleRowReturn:!0,isAsync:!1})}});function $e(t,e,a){const i={isPast:!0,infoMessage:a.ruleInfo};if(function(t){return"GROUP"===t.condType}(a)){const s=a.conds;s&&s.length>0&&(i.isPast=function(t,e,a="AND",i=!1){if(!((null==t?void 0:t.length)>0))return!1;let s="AND"===a;for(let i=0,n=t.length;i<n;i++){const n=e(t[i],i);if("AND"===a){if(!n){s=!1;break}}else if("OR"===a&&n){s=!0;break}}return i?!s:s}(s,(a=>{const{isPast:s,infoMessage:n}=$e(t,e,a);return i.infoMessage=n,s}),a.condOp,!!a.notMode),!i.isPast&&("AND"===a.condOp&&a.notMode||"OR"===a.condOp&&!a.notMode)&&(i.infoMessage=a.ruleInfo))}else{t=(null==a?void 0:a.defname.toLowerCase())||t;try{if(function(t){return"SIMPLE"===t.condType}(a))i.isPast=!function(t,e,a,i,s,n,r){Object.is(s,"CURTIME")&&(a="".concat(new Date));if(Object.is(s,"ENTITYFIELD")){a=n[a=a?a.toLowerCase():""]?n[a]:a}(Q(i)||J(i))&&(i="内容必须符合值规则");const c=Ge(t,e,a);if(!c&&r)throw new o(i);return!c}(e[t],a.condOp,a.paramValue,a.ruleInfo,a.paramType,e,a.keyCond);else if(function(t){return"VALUERANGE2"===t.condType}(a))i.isPast=!function(t,e,a,i,s,n,r){ot(n)&&(n="值必须符合值范围规则");if(ot(t)){if(r)throw new o("值为空");return n="值为空",!0}if(Je(t,/^-?\d*\.?\d+$/,"",r))return!0;const c=Number.parseFloat(t);if(null!==e)if(a){if(c<e){if(r)throw new o(n);return!0}}else if(c<=e){if(r)throw new o(n);return!0}if(null!=i)if(s){if(c>i){if(r)throw new o(n);return!0}}else if(c>=i){if(r)throw new o(n);return!0}return n="",!1}(e[t],a.minValue,a.includeMinValue,a.maxValue,a.includeMaxValue,a.ruleInfo,a.keyCond);else if(function(t){return"REGEX"===t.condType}(a))i.isPast=!Je(e[t],a.regExCode,a.ruleInfo,a.keyCond);else if(function(t){return"STRINGLENGTH"===t.condType}(a))i.isPast=!function(t,e,a,i,s,n,r){ot(n)&&(n="内容长度必须符合范围规则");if(ot(t)){if(r)throw new o("值为空");return n="值为空",!0}const c=t.length;if(null!==e)if(a){if(c<e){if(r)throw new o(n);return!0}}else if(c<=e){if(r)throw new o(n);return!0}if(null!==i)if(s){if(c>i){if(r)throw new o(n);return!0}}else if(c>=i){if(r)throw new o(n);return!0}return n="",!1}(e[t],a.minValue,a.includeMinValue,a.maxValue,a.includeMaxValue,a.ruleInfo,a.keyCond);else if(function(t){return"SYSVALUERULE"===t.condType}(a)&&(null==a?void 0:a.sysValueRule)){const{ruleType:s,regExCode:n,scriptCode:r,ruleInfo:c}=a.sysValueRule;if(i.infoMessage=a.ruleInfo||c,"REG"===s)i.isPast=!Je(e[t],n,i.infoMessage,a.keyCond);else if("SCRIPT"===s){const{isPast:s,infoMessage:n}=function(t,e,a,i,s){ot(i)&&(i="值必须符合脚本规则");const n=e;let r="",c=!0;const d=t=>{c=!1,(null==t?void 0:t.length)>0?t.forEach((t=>{(null==t?void 0:t.message)&&(r+=t.message)})):(null==t?void 0:t.message)&&(r=t.message)};try{const e=Qe.execScriptFn({value:t,data:n},a,{isAsync:!1});"boolean"==typeof e&&(c=e)}catch(t){ibiz.log.error(t),d(t)}if(i="",!c&&s)throw new o(i);return{isPast:c,infoMessage:r||i}}(e[t],e,r,i.infoMessage,a.keyCond);i.isPast=s,i.infoMessage=n||i.infoMessage}}}catch(t){i.isPast=!1}i.isPast=a.notMode?!i.isPast:i.isPast}return i}function Je(t,e,a,i){ot(a)&&(a="值必须符合正则规则");if(ot(t)){if(i)throw new o("值为空");return a="值为空",!0}if(!new RegExp(e).test(t)){if(i)throw new o(a);return!0}return a="",!1}function Ze(t,e){if(function(t){return"GROUP"===t.logicType}(e)){const i=e.defdlogics;if(!i||0===i.length)throw new a(e,"发现空逻辑组,逻辑无法正常执行!");let s=!0;if("AND"===e.groupOP){s=void 0===i.find((e=>!Ze(t,e)))}else if("OR"===e.groupOP){s=void 0!==e.defdlogics.find((e=>Ze(t,e)))}return e.notMode?!s:s}if(function(t){return"SINGLE"===t.logicType}(e))return Ge(t[e.defdname.toLowerCase()],e.condOP,e.value);throw new i(e,"未支持的逻辑类型".concat(e.logicType))}function ta(t,e){if(function(t){return"GROUP"===t.logicType}(e)){const i=e.panelItemLogics;if(!i||0===i.length)throw new a(e,"发现空逻辑组,逻辑无法正常执行!");let s=!0;if("AND"===e.groupOP){s=void 0===i.find((e=>!ta(t,e)))}else if("OR"===e.groupOP){s=void 0!==e.panelItemLogics.find((e=>ta(t,e)))}return e.notMode?!s:s}if(function(t){return"SINGLE"===t.logicType}(e))return Ge(t[e.dstModelField.toLowerCase()],e.condOp,e.value);throw new i(e,"未支持的逻辑类型".concat(e.logicType))}var ea=t("LayoutPanelUtil",class{constructor(){this.cache=new Map}register(t,e){this.cache.set(t,e)}get(t){return this.cache.get(t)}fill(t){const{viewLayoutPanel:e}=t;if(!e||!0===e.useDefaultLayout){const e=this.calcLayoutTag(t);if(this.cache.has(e)){const a=Z(this.cache.get(e));t.viewLayoutPanel=a,t.appCounterRefs&&(a.appCounterRefs=t.appCounterRefs,delete t.appCounterRefs),t.appViewEngines&&(a.appViewEngines=t.appViewEngines,delete t.appViewEngines),t.appViewLogics&&(a.appViewLogics=t.appViewLogics,delete t.appViewLogics),t.appViewRefs&&(a.appViewRefs=t.appViewRefs,delete t.appViewRefs),t.controls&&(a.controls=t.controls,delete t.controls)}}return t}calcLayoutTag(t){const{viewType:e,viewStyle:a}=t;return"APPINDEXVIEW"===e?this.calcIndexViewLayoutTag(t):"".concat(e,"_").concat(a)}calcIndexViewLayoutTag(t){const{viewType:e,viewStyle:a,blankMode:i,mainMenuAlign:s}=t;let n="";i?n="BLANK_MODE":s&&(n=s.toUpperCase());let o="";return o=""!==n?"".concat(e,"_").concat(a,"_").concat(n):"".concat(e,"_").concat(a),ibiz.config.view.disableHomeTabs&&["APPINDEXVIEW_DEFAULT","APPINDEXVIEW_DEFAULT_LEFT","APPINDEXVIEW_DEFAULT_TOP"].includes(o)&&(o+="_NO_NAV"),o}});function aa(t){const e={};return t.param09&&(e.srfprocessinstanceid=t.param09),e}var ia=t("ControlType",(t=>(t.APP_MENU="APPMENU",t.GRID="GRID",t.FORM="FORM",t.SEARCHFORM="SEARCHFORM",t.TOOLBAR="TOOLBAR",t.DRBAR="DRBAR",t.VIEWPANEL="VIEWPANEL",t.PICKUP_VIEW_PANEL="PICKUPVIEWPANEL",t.DATAVIEW="DATAVIEW",t.TREEGRID="TREEGRID",t.WF_EXPBAR="WFEXPBAR",t.TREEVIEW="TREEVIEW",t.TREE_EXP_BAR="TREEEXPBAR",t.TAB_VIEWPANEL="TABVIEWPANEL",t.DRTAB="DRTAB",t.CHART="CHART",t.REPORT_PANEL="REPORTPANEL",t.LIST="LIST",t.MOB_MDCTRL="MOBMDCTRL",t.MULTI_EDIT_VIEWPANEL="MULTIEDITVIEWPANEL",t.WIZARD_PANEL="WIZARDPANEL",t.UPDATE_PANEL="UPDATEPANEL",t.SEARCHBAR="SEARCHBAR",t.DASHBOARD="DASHBOARD",t.CALENDAR="CALENDAR",t.PANEL="PANEL",t.VIEW_LAYOUT_PANEL="VIEWLAYOUTPANEL",t.MAP="MAP",t.GANTT="GANTT",t.TREE_GRIDEX="TREEGRIDEX",t.KANBAN="KANBAN",t.CALENDAR_EXPBAR="CALENDAREXPBAR",t.CHART_EXPBAR="CHARTEXPBAR",t.DATA_VIEW_EXPBAR="DATAVIEWEXPBAR",t.GANTT_EXPBAR="GANTTEXPBAR",t.GRID_EXPBAR="GRIDEXPBAR",t.LIST_EXPBAR="LISTEXPBAR",t.MAP_EXPBAR="MAPEXPBAR",t.STATE_WIZARD_PANEL="STATEWIZARDPANEL",t.TAB_EXP_PANEL="TABEXPPANEL",t.CUSTOM="CUSTOM",t.CAPTIONBAR="CAPTIONBAR",t.CONTEXT_MENU="CONTEXTMENU",t))(ia||{})),sa=t("PlatformType",(t=>(t.IOS="IOS",t.ANDROID="Android",t.WECHAT="WeChat",t.QQ="QQ",t.DINGTALK="DingTalk",t.BROWSER="Browser",t.WCMP="WeChatMiniProgram",t.DESKTOP="Desktop",t))(sa||{})),na=t("RouteConst",(t=>(t.ROUTE_MODAL_TAG="route-modal",t))(na||{})),oa=t("StudioViewEvents",class{});oa.onViewMounted="onMounted",oa.onViewDestroyed="onDestroyed";var ra=t("StudioPanelEvents",class{});ra.onClick="onClick",ra.onChange="onChange",ra.onEnter="onEnter",ra.onLeave="onLeave";var ca=t("StudioControlEvents",class{});ca.onBeforeLoad="onBeforeLoad",ca.onLoadSuccess="onLoadSuccess",ca.onLoadError="onLoadError",ca.onBeforeLoadDraft="onBeforeLoadDraft",ca.onLoadDraftSuccess="onLoadDraftSuccess",ca.onLoadDraftError="onLoadDraftError",ca.onBeforeSave="onBeforeSave",ca.onSaveSuccess="onSaveSuccess",ca.onSaveError="onSaveError",ca.onBeforeRemove="onBeforeRemove",ca.onRemoveSuccess="onRemoveSuccess",ca.onRemoveError="onRemoveError",ca.CLICK="onClick";var da=t("SysUIActionTag",(t=>(t.NEW="New",t.EDIT="Edit",t.REFRESH="Refresh",t.EXIT="Exit",t.SAVE_AND_EXIT="SaveAndExit",t.SAVE_AND_NEW="SaveAndNew",t.SAVE="Save",t.SAVE_ROW="SaveRow",t.REMOVE="Remove",t.REMOVE_AND_EXIT="RemoveAndExit",t.NEW_ROW="NewRow",t.TOGGLE_FILTER="ToggleFilter",t.IMPORT="Import",t.EXPORT_EXCEL="ExportExcel",t.SAVE_AND_START="SaveAndStart",t.VIEW_WF_STEP="ViewWFStep",t.NO="No",t.YES="Yes",t.CANCEL="Cancel",t.OK="Ok",t.SEARCH="Search",t.RESET="Reset",t.FINISH="Finish",t.NEXT_STEP="NextStep",t.PREV_STEP="PrevStep",t.ADD_SELECTION="AddSelection",t.REMOVE_SELECTION="RemoveSelection",t.REMOVE_ALL="RemoveAll",t.ADD_ALL="AddAll",t.LOGOUT="Logout",t.LOGIN="Login",t.CANCEL_CHANGES="CancelChanges",t.COPY="Copy",t.VIEW="View",t.TOGGLE_ROW_EDIT="ToggleRowEdit",t.REFRESH_ALL="RefreshAll",t.REFRESH_PARENT="RefreshParent",t.FIRST_RECORD="FirstRecord",t.LAST_RECORD="LastRecord",t.PREV_RECORD="PrevRecord",t.NEXT_RECORD="NextRecord",t.LOAD_MORE="LoadMore",t))(da||{})),la=t("ValueOP",(t=>(t.EQ="EQ",t.NOT_EQ="NOTEQ",t.GT="GT",t.GT_AND_EQ="GTANDEQ",t.LT="LT",t.LT_AND_EQ="LTANDEQ",t.IS_NULL="ISNULL",t.IS_NOT_NULL="ISNOTNULL",t.IN="IN",t.NOT_IN="NOTIN",t.LIKE="LIKE",t.LIFT_LIKE="LIFTLIKE",t.RIGHT_LIKE="RIGHT_LIKE",t.CHILD_OF="CHILDOF",t.USER_LIKE="USERLIKE",t.BIT_AND="BITAND",t.EXISTS="EXISTS",t.NOT_EXISTS="NOTEXISTS",t))(la||{})),ha=t("ViewCallTag",(t=>(t.LOAD="Load",t.GET_DATA="GetData",t.GET_ALL_DATA="GetAllData",t.VALIDATE="Validate",t.TOGGLE_COLLAPSE="ToggleCollapse",t.WF_WITHDRAW="WFWithdraw",t))(ha||{})),ua=t("ViewMode",(t=>(t.ROUTE="ROUTE",t.ROUTE_MODAL="ROUTE_MODAL",t.MODAL="MODAL",t.DRAWER="DRAWER",t.EMBED="EMBED",t.POPOVER="POPOVER",t))(ua||{})),pa=t("ViewType",(t=>(t.APP_INDEX_VIEW="APPINDEXVIEW",t.DE_GRID_VIEW="DEGRIDVIEW",t.DE_EDIT_VIEW="DEEDITVIEW",t.APP_DATA_UPLOAD_VIEW="APPDATAUPLOADVIEW",t.APP_ERROR_VIEW="APPERRORVIEW",t.APP_FILE_UPLOAD_VIEW="APPFILEUPLOADVIEW",t.APP_FUN_PICKUP_VIEW="APPFUNCPICKUPVIEW",t.APP_LOGIN_VIEW="APPLOGINVIEW",t.APP_LOGOUT_VIEW="APPLOGOUTVIEW",t.APP_PANEL_VIEW="APPPANELVIEW",t.APP_PIC_UPLOAD_VIEW="APPPICUPLOADVIEW",t.APP_PORTAL_VIEW="APPPORTALVIEW",t.APP_REDIRECT_VIEW="APPREDIRECTVIEW",t.APP_START_VIEW="APPSTARTVIEW",t.APP_WELCOME_VIEW="APPWELCOMEVIEW",t.APP_WF_ADD_STEP_AFTER_VIEW="APPWFADDSTEPAFTERVIEW",t.APP_WF_ADD_STEP_BEFORE_VIEW="APPWFADDSTEPBEFOREVIEW",t.APP_WF_REDIRECT_VIEW="APPWFREDIRECTVIEW",t.APP_WF_SENDBAC_VIEW="APPWFSENDBACKVIEW",t.APP_WF_STEP_ACTOR_VIEW="APPWFSTEPACTORVIEW",t.APP_WF_STEP_DATA_VIEW="APPWFSTEPDATAVIEW",t.APP_WF_STEP_TRACE_VIEW="APPWFSTEPTRACEVIEW",t.APP_WF_SUPPLY_INFO_VIEW="APPWFSUPPLYINFOVIEW",t.APP_WF_TAKE_ADVICE_VIEW="APPWFTAKEADVICEVIEW",t.DE_CALENDAR_EXP_VIEW="DECALENDAREXPVIEW",t.DE_CALENDAR_VIEW="DECALENDARVIEW",t.DE_CHART_EXP_VIEW="DECHARTEXPVIEW",t.DE_CHART_VIEW="DECHARTVIEW",t.DE_CHART_VIEW9="DECHARTVIEW9",t.DE_CUSTOM_VIEW="DECUSTOMVIEW",t.DE_DATA_VIEW="DEDATAVIEW",t.DE_DATA_VIEW9="DEDATAVIEW9",t.DE_DATAVIEW_EXP_VIEW="DEDATAVIEWEXPVIEW",t.DE_EDIT_VIEW2="DEEDITVIEW2",t.DE_EDIT_VIEW3="DEEDITVIEW3",t.DE_EDIT_VIEW4="DEEDITVIEW4",t.DE_EDIT_VIEW9="DEEDITVIEW9",t.DE_FORM_PICKUP_DATA_VIEW="DEFORMPICKUPDATAVIEW",t.DE_GANTT_EXP_VIEW="DEGANTTEXPVIEW",t.DE_GANTT_VIEW="DEGANTTVIEW",t.DE_GANTT_VIEW9="DEGANTTVIEW9",t.DE_GRID_EXP_VIEW="DEGRIDEXPVIEW",t.DE_GRID_VIEW2="DEGRIDVIEW2",t.DE_GRID_VIEW4="DEGRIDVIEW4",t.DE_GRID_VIEW8="DEGRIDVIEW8",t.DE_GRID_VIEW9="DEGRIDVIEW9",t.DE_HTML_VIEW="DEHTMLVIEW",t.DE_INDEX_PICKUP_DATA_VIEW="DEINDEXPICKUPDATAVIEW",t.DE_INDEX_VIEW="DEINDEXVIEW",t.DE_KANBAN_VIEW="DEKANBANVIEW",t.DE_KANBAN_VIEW9="DEKANBANVIEW9",t.DE_LIST_EXP_VIEW="DELISTEXPVIEW",t.DE_LIST_VIEW="DELISTVIEW",t.DE_LIST_VIEW9="DELISTVIEW9",t.DE_MAP_EXP_VIEW="DEMAPEXPVIEW",t.DE_MAP_VIEW="DEMAPVIEW",t.DE_MAP_VIEW9="DEMAPVIEW9",t.DE_MD_CUSTOM_VIEW="DEMDCUSTOMVIEW",t.DE_MEDITVIEW9="DEMEDITVIEW9",t.DE_MOB_CALENDAR_EXP_VIEW="DEMOBCALENDAREXPVIEW",t.DE_MOB_CALENDAR_VIEW="DEMOBCALENDARVIEW",t.DE_MOB_CALENDAR_VIEW9="DEMOBCALENDARVIEW9",t.DE_MOB_CHART_EXP_VIEW="DEMOBCHARTEXPVIEW",t.DE_MO_BCHART_VIEW="DEMOBCHARTVIEW",t.D_EMOB_CHART_VIEW9="DEMOBCHARTVIEW9",t.DE_MOB_CUSTOM_VIEW="DEMOBCUSTOMVIEW",t.DE_MOB_DATA_VIEW="DEMOBDATAVIEW",t.DE_MOB_DATA_VIEW_EXP_VIEW="DEMOBDATAVIEWEXPVIEW",t.DE_MOB_EDIT_VIEW="DEMOBEDITVIEW",t.DE_MOB_EDIT_VIEW3="DEMOBEDITVIEW3",t.DE_MOB_EDITVIEW9="DEMOBEDITVIEW9",t.DE_MOB_FORM_PICKUP_MDVIEW="DEMOBFORMPICKUPMDVIEW",t.DE_MOB_GANTT_EXP_VIEW="DEMOBGANTTEXPVIEW",t.DE_MOB_GANTT_VIEW="DEMOBGANTTVIEW",t.DE_MOB_GANTT_VIEW9="DEMOBGANTTVIEW9",t.DE_MOB_HTML_VIEW="DEMOBHTMLVIEW",t.DE_MOB_INDEX_PICKUP_MDVIEW="DEMOBINDEXPICKUPMDVIEW",t.DE_MOB_LIST_EXP_VIEW="DEMOBLISTEXPVIEW",t.DE_MOB_LIST_VIEW="DEMOBLISTVIEW",t.DE_MOB_MAP_VIEW="DEMOBMAPVIEW",t.DE_MOB_MAP_VIEW9="DEMOBMAPVIEW9",t.DE_MOB_MDVIEW="DEMOBMDVIEW",t.DE_MOB_MDVIEW9="DEMOBMDVIEW9",t.DE_MOB_MEDIT_VIEW9="DEMOBMEDITVIEW9",t.DE_MOB_MPICKUP_VIEW="DEMOBMPICKUPVIEW",t.DE_MOB_OPT_VIEW="DEMOBOPTVIEW",t.DE_MOB_PANEL_VIEW="DEMOBPANELVIEW",t.DE_MOB_PANEL_VIEW9="DEMOBPANELVIEW9",t.DE_MOB_PICKUP_LIST_VIEW="DEMOBPICKUPLISTVIEW",t.DE_MOB_PICKUP_MDVIEW="DEMOBPICKUPMDVIEW",t.DE_MOB_PICKUP_TREE_VIEW="DEMOBPICKUPTREEVIEW",t.DE_MOB_PICKUP_VIEW="DEMOBPICKUPVIEW",t.DE_MOB_PORTAL_VIEW="DEMOBPORTALVIEW",t.DE_MOB_PORTAL_VIEW9="DEMOBPORTALVIEW9",t.DE_MOB_REDIRECT_VIEW="DEMOBREDIRECTVIEW",t.DE_MOB_REPORT_VIEW="DEMOBREPORTVIEW",t.DE_MOB_TAB_EXP_VIEW="DEMOBTABEXPVIEW",t.DE_MOB_TAB_EXP_VIEW9="DEMOBTABEXPVIEW9",t.DE_MOB_TAB_SEARCH_VIEW="DEMOBTABSEARCHVIEW",t.DE_MOB_TAB_SEARCH_VIEW9="DEMOBTABSEARCHVIEW9",t.DE_MOB_TREE_EXP_VIEW="DEMOBTREEEXPVIEW",t.DEMOBTREEEXPVIEW9="DEMOBTREEEXPVIEW9",t.DE_MOB_TREE_VIEW="DEMOBTREEVIEW",t.DE_MOB_WFACTION_VIEW="DEMOBWFACTIONVIEW",t.DE_MOB_WF_DATA_REDIRECT_VIEW="DEMOBWFDATAREDIRECTVIEW",t.DE_MOB_WF_DYNAACTIO_NVIEW="DEMOBWFDYNAACTIONVIEW",t.DE_MOB_WFDYNA_EDIT_VIEW="DEMOBWFDYNAEDITVIEW",t.DE_MOB_WF_DYNA_EDIT_VIEW3="DEMOBWFDYNAEDITVIEW3",t.DE_MOB_WF_DYNA_EXP_MDVIEW="DEMOBWFDYNAEXPMDVIEW",t.DE_MO_BWF_DYNA_START_VIEW="DEMOBWFDYNASTARTVIEW",t.DE_MOB_WF_EDIT_VIEW="DEMOBWFEDITVIEW",t.DE_MOB_WF_EDIT_VIEW3="DEMOBWFEDITVIEW3",t.DE_MOB_WF_MDVIEW="DEMOBWFMDVIEW",t.DE_MOB_WF_PROXY_RESULT_VIEW="DEMOBWFPROXYRESULTVIEW",t.DE_MOB_WF_PROXY_START_VIEW="DEMOBWFPROXYSTARTVIEW",t.DE_MOB_WF_START_VIEW="DEMOBWFSTARTVIEW",t.DE_MOB_WIZARD_VIEW="DEMOBWIZARDVIEW",t.DE_MPICKUP_VIEW="DEMPICKUPVIEW",t.DE_MPICKUP_VIEW2="DEMPICKUPVIEW2",t.DE_OPT_VIEW="DEOPTVIEW",t.DE_PANEL_VIEW="DEPANELVIEW",t.DE_PANEL_VIEW9="DEPANELVIEW9",t.DE_PICKUP_DATA_VIEW="DEPICKUPDATAVIEW",t.DE_PICKUP_GRID_VIEW="DEPICKUPGRIDVIEW",t.DE_PICKUP_TREE_VIEW="DEPICKUPTREEVIEW",t.DE_PICKUP_VIEW="DEPICKUPVIEW",t.DE_PICKUP_VIEW2="DEPICKUPVIEW2",t.DE_PICK_UP_VIEW3="DEPICKUPVIEW3",t.DE_PORTAL_VIEW="DEPORTALVIEW",t.DE_PORTAL_VIEW9="DEPORTALVIEW9",t.DE_REDIRECT_VIEW="DEREDIRECTVIEW",t.DE_REPORT_VIEW="DEREPORTVIEW",t.DE_TAB_EXP_VIEW="DETABEXPVIEW",t.DE_TAB_EXP_VIEW9="DETABEXPVIEW9",t.DE_TAB_SEARCH_VIEW="DETABSEARCHVIEW",t.DE_TAB_SEARCH_VIEW9="DETABSEARCHVIEW9",t.DE_TREE_EXP_VIEW="DETREEEXPVIEW",t.DE_TREE_EXP_VIEW2="DETREEEXPVIEW2",t.DE_TREE_EXP_VIEW3="DETREEEXPVIEW3",t.DE_TREE_GRID_EXVIEW="DETREEGRIDEXVIEW",t.DE_TREE_GRID_EXVIEW9="DETREEGRIDEXVIEW9",t.DE_TREE_GRID_VIEW="DETREEGRIDVIEW",t.DE_TREE_GRID_VIEW9="DETREEGRIDVIEW9",t.DE_TREE_VIEW="DETREEVIEW",t.DE_TREE_VIEW9="DETREEVIEW9",t.DE_WF_ACTION_VIEW="DEWFACTIONVIEW",t.DE_WF_DATA_REDIRECT_VIEW="DEWFDATAREDIRECTVIEW",t.DE_WF_DYNA_ACTION_VIEW="DEWFDYNAACTIONVIEW",t.DE_WF_DYNA_EDIT_VIEW="DEWFDYNAEDITVIEW",t.DE_WF_DYNA_EDIT_VIEW3="DEWFDYNAEDITVIEW3",t.DE_WF_DYNA_EXP_GRID_VIEW="DEWFDYNAEXPGRIDVIEW",t.DE_WF_DYNA_START_VIEW="DEWFDYNASTARTVIEW",t.DE_WF_EDIT_PROXY_DATA_VIEW="DEWFEDITPROXYDATAVIEW",t.DE_WF_EDIT_VIEW="DEWFEDITVIEW",t.DE_WF_EDIT_VIEW2="DEWFEDITVIEW2",t.DE_WF_EDIT_VIEW3="DEWFEDITVIEW3",t.DE_WF_EDIT_VIEW9="DEWFEDITVIEW9",t.DE_WF_EXP_VIEW="DEWFEXPVIEW",t.DE_WF_GRID_VIEW="DEWFGRIDVIEW",t.DE_WF_PROXY_DATA_VIEW="DEWFPROXYDATAVIEW",t.DE_WF_PROXY_RESULT_VIEW="DEWFPROXYRESULTVIEW",t.DE_WF_PROXY_START_VIEW="DEWFPROXYSTARTVIEW",t.DE_WF_START_VIEW="DEWFSTARTVIEW",t.DE_WIZARD_VIEW="DEWIZARDVIEW",t.DE_SUB_APP_REF_VIEW="DESUBAPPREFVIEW",t))(pa||{})),ma=t("PresetIdentifier",(t=>(t.MESSAGE="preset-message",t))(ma||{})),fa=t("Modal",class{constructor(t){this.mode="EMBED",this.viewUsage=4,this.ignoreDismissCheck=!1,this.hooks={shouldDismiss:new rt,beforeDismiss:new rt},this._dismiss=t=>{ibiz.log.error("外部关闭能力未注册",t)},t.mode&&(this.mode=t.mode),t.routeDepth&&(this.routeDepth=t.routeDepth),t.viewUsage&&(this.viewUsage=t.viewUsage),t.dismiss&&(this._dismiss=t.dismiss)}injectDismiss(t){this._dismiss=t}async dismiss(t={ok:!1,data:[]}){const e={};return!0!==this.ignoreDismissCheck&&await this.hooks.shouldDismiss.call(e),!1===e.allowClose?(ibiz.log.debug("shouldDismiss结果为false,关闭中断。"),!1):(await this.hooks.beforeDismiss.call(t),this._dismiss(t),this.destroy(),!0)}destroy(){this.hooks.shouldDismiss.clear(),this.hooks.beforeDismiss.clear()}});function ga(t,e){return t.filter((t=>{const{checkMode:a}=t,i=t.deformItemName||t.degridEditItemName;return 2!==a&&i===e}))}var wa=t("TextUtil",class{constructor(){this.inputElement=null}format(t,e){return t}copy(t){return this.inputElement||(this.inputElement=document.createElement("input"),this.inputElement.style.position="absolute",this.inputElement.style.left="-9999px",document.body.appendChild(this.inputElement)),this.inputElement.value=t,this.inputElement.select(),document.execCommand("copy")}}),Ea=t("ThemeUtil",class{constructor(){this.html=document.getElementsByTagName("html")[0]}async loadTheme(t){const e=Z(t.themeParams||{}),a=e["theme-package-path"];delete e.appId,delete e["theme-package-path"],await ibiz.plugin.loadPlugin({runtimeObject:!0,rtobjectName:t.name,rtobjectRepo:a}),this.setThemeParams(t,e),this.setTheme(t.themeTag)}setThemeParams(t,e){if(document.getElementById(t.themeTag))return;let a=":root.".concat(t.themeTag,"{");for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t)){const i=e[t];a+="".concat(t,": ").concat(i).concat(i.endsWith(";")?"":";")}a+="}";const i=document.createElement("style");i.id=t.themeTag,i.type="text/css",i.innerHTML=a,document.head.appendChild(i)}setTheme(t){const e=this.getTheme();this.html.classList.remove(e),this.html.setAttribute("theme",t),this.html.classList.add(t)}getTheme(){return this.html.getAttribute("theme")}}),ya=class{constructor(){this.commitQueue=new Map,this.state={isOpen:!1,isChange:!1}}open(){this.state.isOpen?ibiz.log.warn("事务已经开启, 单个界面域只能开启一个事务"):this.state.isOpen=!0}change(t,e){this.state.isChange=!0,this.commitQueue.set(t,e)}commit(){const t=Array.from(this.commitQueue.values()).reverse();for(const e of t)e();this.commitQueue.clear(),this.state.isChange=!1}rollback(){this.commitQueue.clear(),this.state.isChange=!1}close(){if(this.state.isChange)throw new Error("当前事务未提交,不可以直接关闭事务");this.state.isOpen=!1}},va=t("UIDomain",class{constructor(t){this.state={rsInit:!1},this.rsMap=new Map,this.rs2Map=new Map,this.transaction=new ya,this.dataModification=!1,this.id=t||ct()}dataChange(){this.dataModification=!0}dataChangeCompleted(){this.dataModification=!1}setDERConfig(t,e){this.rsMap.set(t,e)}getDERConfig(t){return this.rsMap.has(t)?this.rsMap.get(t):[]}getDERConfigByMajor(t){return this.rs2Map.has(t)?this.rs2Map.get(t):[]}calcParentRs(){this.rs2Map.clear(),this.rsMap.forEach(((t,e)=>{t.forEach((t=>{t.minorAppDataEntityId=e;const a=t.majorAppDataEntityId;this.rs2Map.has(a)||this.rs2Map.set(a,[]),this.rs2Map.get(a).push(t)}))}))}destroy(){this.rsMap.clear();ibiz.hub.getAllApps().forEach((t=>{t.deService.reset({srfappid:t.appId,srfsessionid:this.id})}))}}),Ia=t("UIDomainManager",class{constructor(){this.domainMap=new Map}create(t){const e=new va(t);return this.domainMap.set(e.id,e),e}get(t){if(this.domainMap.has(t))return this.domainMap.get(t);throw new Error("无效的界面域标识[".concat(t,"]"))}destroy(t){this.domainMap.has(t)&&(this.domainMap.get(t).destroy(),this.domainMap.delete(t))}}),Da=t("RawValueUtil",class{isNumber(t){return/^-?\d+(\.\d+)?$/.test(t)}format(t){let e=t;return void 0!==t&&("true"===t||"false"===t?e="true"===t:this.isNumber(t)&&(e=parseFloat(t))),e}}),Ca=t("ViewStack",class{constructor(){this.stackMap=new Map,this.stack=[],this.activeStack=[],this.evt=new dt}add(t,e){this.stack.push(e),this.stackMap.set(t,e),this.recalculateActiveStack(),this.evt.emit("add",e),this.evt.emit("change",{type:"add",view:e})}remove(t){const e=this.stackMap.get(t);e&&(this.stack.splice(this.stack.indexOf(e),1),this.stackMap.delete(t),this.recalculateActiveStack(),this.evt.emit("remove",e),this.evt.emit("change",{type:"remove",view:e}))}getActives(){return this.activeStack}active(t){const e=this.stackMap.get(t);e&&(this.recalculateActiveStack(),this.evt.emit("active",e),this.evt.emit("change",{type:"active",view:e}))}deactivate(t){const e=this.stackMap.get(t);e&&(this.recalculateActiveStack(),this.evt.emit("deactivate",e),this.evt.emit("change",{type:"deactivate",view:e}))}getView(t){return this.stackMap.get(t)}recalculateActiveStack(){this.activeStack=this.stack.filter((t=>!0===t.isActive))}});async function ba(t,e=!0){const a=await Promise.allSettled(t),i=[],s=[];if(a.forEach((t=>{"fulfilled"===t.status?i.push(t.value):s.push(t.reason)})),s.length>0){const t=1===s.length?s[0]:s;if(e)throw t;ibiz.util.error.handle(t)}return i}var Aa={position:"fixed",zIndex:"10000"};function Pa(t,e=document.body,a=!0){const i=xa(t);if(null==i)throw new Error("Cannot clone a null or undefined element.");const s=i.cloneNode(!0);if(a)for(;s.firstChild;)s.removeChild(s.firstChild);return function(t,{width:e,height:a,boundingLeft:i,boundingTop:s}){t.style.left="".concat(i,"px"),t.style.top="".concat(s,"px"),t.style.width="".concat(e,"px"),t.style.height="".concat(a,"px"),Object.assign(t.style,Aa)}(s,Ta(i)),e.appendChild(s),s}function Ta(t){const e=t.offsetWidth,a=t.offsetHeight,i=window.getComputedStyle(t),s=parseFloat(i.padding),{left:n,top:o}=t.getBoundingClientRect();return{width:e,height:a,padding:s,boundingLeft:n,boundingTop:o}}function xa(t){return"string"==typeof t?document.querySelector(t):t}var Na={update:null,begin:null,loopBegin:null,changeBegin:null,change:null,changeComplete:null,loopComplete:null,complete:null,loop:1,direction:"normal",autoplay:!0,timelineOffset:0},Sa={duration:1e3,delay:0,endDelay:0,easing:"easeOutElastic(1, .5)",round:0},Ra=["translateX","translateY","translateZ","rotate","rotateX","rotateY","rotateZ","scale","scaleX","scaleY","scaleZ","skew","skewX","skewY","perspective","matrix","matrix3d"],Ma={CSS:{},springs:{}};function Oa(t,e,a){return Math.min(Math.max(t,e),a)}function La(t,e){return t.indexOf(e)>-1}function _a(t,e){return t.apply(null,e)}var Fa={arr:function(t){return Array.isArray(t)},obj:function(t){return La(Object.prototype.toString.call(t),"Object")},pth:function(t){return Fa.obj(t)&&t.hasOwnProperty("totalLength")},svg:function(t){return t instanceof SVGElement},inp:function(t){return t instanceof HTMLInputElement},dom:function(t){return t.nodeType||Fa.svg(t)},str:function(t){return"string"==typeof t},fnc:function(t){return"function"==typeof t},und:function(t){return void 0===t},nil:function(t){return Fa.und(t)||null===t},hex:function(t){return/(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(t)},rgb:function(t){return/^rgb/.test(t)},hsl:function(t){return/^hsl/.test(t)},col:function(t){return Fa.hex(t)||Fa.rgb(t)||Fa.hsl(t)},key:function(t){return!Na.hasOwnProperty(t)&&!Sa.hasOwnProperty(t)&&"targets"!==t&&"keyframes"!==t}};function Va(t){var e=/\(([^)]+)\)/.exec(t);return e?e[1].split(",").map((function(t){return parseFloat(t)})):[]}function ka(t,e){var a=Va(t),i=Oa(Fa.und(a[0])?1:a[0],.1,100),s=Oa(Fa.und(a[1])?100:a[1],.1,100),n=Oa(Fa.und(a[2])?10:a[2],.1,100),o=Oa(Fa.und(a[3])?0:a[3],.1,100),r=Math.sqrt(s/i),c=n/(2*Math.sqrt(s*i)),d=c<1?r*Math.sqrt(1-c*c):0,l=1,h=c<1?(c*r-o)/d:-o+r;function u(t){var a=e?e*t/1e3:t;return a=c<1?Math.exp(-a*c*r)*(l*Math.cos(d*a)+h*Math.sin(d*a)):(l+h*a)*Math.exp(-a*r),0===t||1===t?t:1-a}return e?u:function(){var e=Ma.springs[t];if(e)return e;for(var a=1/6,i=0,s=0;;)if(1===u(i+=a)){if(++s>=16)break}else s=0;var n=i*a*1e3;return Ma.springs[t]=n,n}}function za(t){return void 0===t&&(t=10),function(e){return Math.ceil(Oa(e,1e-6,1)*t)*(1/t)}}var Wa,Ua,Ba=function(){var t=.1;function e(t,e){return 1-3*e+3*t}function a(t,e){return 3*e-6*t}function i(t){return 3*t}function s(t,s,n){return((e(s,n)*t+a(s,n))*t+i(s))*t}function n(t,s,n){return 3*e(s,n)*t*t+2*a(s,n)*t+i(s)}return function(e,a,i,o){if(0<=e&&e<=1&&0<=i&&i<=1){var r=new Float32Array(11);if(e!==a||i!==o)for(var c=0;c<11;++c)r[c]=s(c*t,e,i);return function(t){return e===a&&i===o||0===t||1===t?t:s(d(t),a,o)}}function d(a){for(var o=0,c=1;10!==c&&r[c]<=a;++c)o+=t;--c;var d=o+(a-r[c])/(r[c+1]-r[c])*t,l=n(d,e,i);return l>=.001?function(t,e,a,i){for(var o=0;o<4;++o){var r=n(e,a,i);if(0===r)return e;e-=(s(e,a,i)-t)/r}return e}(a,d,e,i):0===l?d:function(t,e,a,i,n){var o,r,c=0;do{(o=s(r=e+(a-e)/2,i,n)-t)>0?a=r:e=r}while(Math.abs(o)>1e-7&&++c<10);return r}(a,o,o+t,e,i)}}}(),Ga=(Wa={linear:function(){return function(t){return t}}},Ua={Sine:function(){return function(t){return 1-Math.cos(t*Math.PI/2)}},Expo:function(){return function(t){return t?Math.pow(2,10*t-10):0}},Circ:function(){return function(t){return 1-Math.sqrt(1-t*t)}},Back:function(){return function(t){return t*t*(3*t-2)}},Bounce:function(){return function(t){for(var e,a=4;t<((e=Math.pow(2,--a))-1)/11;);return 1/Math.pow(4,3-a)-7.5625*Math.pow((3*e-2)/22-t,2)}},Elastic:function(t,e){void 0===t&&(t=1),void 0===e&&(e=.5);var a=Oa(t,1,10),i=Oa(e,.1,2);return function(t){return 0===t||1===t?t:-a*Math.pow(2,10*(t-1))*Math.sin((t-1-i/(2*Math.PI)*Math.asin(1/a))*(2*Math.PI)/i)}}},["Quad","Cubic","Quart","Quint"].forEach((function(t,e){Ua[t]=function(){return function(t){return Math.pow(t,e+2)}}})),Object.keys(Ua).forEach((function(t){var e=Ua[t];Wa["easeIn"+t]=e,Wa["easeOut"+t]=function(t,a){return function(i){return 1-e(t,a)(1-i)}},Wa["easeInOut"+t]=function(t,a){return function(i){return i<.5?e(t,a)(2*i)/2:1-e(t,a)(-2*i+2)/2}},Wa["easeOutIn"+t]=function(t,a){return function(i){return i<.5?(1-e(t,a)(1-2*i))/2:(e(t,a)(2*i-1)+1)/2}}})),Wa);function ja(t,e){if(Fa.fnc(t))return t;var a=t.split("(")[0],i=Ga[a],s=Va(t);switch(a){case"spring":return ka(t,e);case"cubicBezier":return _a(Ba,s);case"steps":return _a(za,s);default:return _a(i,s)}}function Ka(t){try{return document.querySelectorAll(t)}catch(t){return}}function Xa(t,e){for(var a=t.length,i=arguments.length>=2?arguments[1]:void 0,s=[],n=0;n<a;n++)if(n in t){var o=t[n];e.call(i,o,n,t)&&s.push(o)}return s}function Ha(t){return t.reduce((function(t,e){return t.concat(Fa.arr(e)?Ha(e):e)}),[])}function qa(t){return Fa.arr(t)?t:(Fa.str(t)&&(t=Ka(t)||t),t instanceof NodeList||t instanceof HTMLCollection?[].slice.call(t):[t])}function Ya(t,e){return t.some((function(t){return t===e}))}function Qa(t){var e={};for(var a in t)e[a]=t[a];return e}function $a(t,e){var a=Qa(t);for(var i in t)a[i]=e.hasOwnProperty(i)?e[i]:t[i];return a}function Ja(t,e){var a=Qa(t);for(var i in e)a[i]=Fa.und(t[i])?e[i]:t[i];return a}function Za(t){return Fa.rgb(t)?(a=/rgb\((\d+,\s*[\d]+,\s*[\d]+)\)/g.exec(e=t))?"rgba("+a[1]+",1)":e:Fa.hex(t)?function(t){var e=t.replace(/^#?([a-f\d])([a-f\d])([a-f\d])$/i,(function(t,e,a,i){return e+e+a+a+i+i})),a=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);return"rgba("+parseInt(a[1],16)+","+parseInt(a[2],16)+","+parseInt(a[3],16)+",1)"}(t):Fa.hsl(t)?function(t){var e,a,i,s=/hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.exec(t)||/hsla\((\d+),\s*([\d.]+)%,\s*([\d.]+)%,\s*([\d.]+)\)/g.exec(t),n=parseInt(s[1],10)/360,o=parseInt(s[2],10)/100,r=parseInt(s[3],10)/100,c=s[4]||1;function d(t,e,a){return a<0&&(a+=1),a>1&&(a-=1),a<1/6?t+6*(e-t)*a:a<.5?e:a<2/3?t+(e-t)*(2/3-a)*6:t}if(0==o)e=a=i=r;else{var l=r<.5?r*(1+o):r+o-r*o,h=2*r-l;e=d(h,l,n+1/3),a=d(h,l,n),i=d(h,l,n-1/3)}return"rgba("+255*e+","+255*a+","+255*i+","+c+")"}(t):void 0;var e,a}function ti(t){var e=/[+-]?\d*\.?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?(%|px|pt|em|rem|in|cm|mm|ex|ch|pc|vw|vh|vmin|vmax|deg|rad|turn)?$/.exec(t);if(e)return e[1]}function ei(t,e){return Fa.fnc(t)?t(e.target,e.id,e.total):t}function ai(t,e){return t.getAttribute(e)}function ii(t,e,a){if(Ya([a,"deg","rad","turn"],ti(e)))return e;var i=Ma.CSS[e+a];if(!Fa.und(i))return i;var s=document.createElement(t.tagName),n=t.parentNode&&t.parentNode!==document?t.parentNode:document.body;n.appendChild(s),s.style.position="absolute",s.style.width=100+a;var o=100/s.offsetWidth;n.removeChild(s);var r=o*parseFloat(e);return Ma.CSS[e+a]=r,r}function si(t,e,a){if(e in t.style){var i=e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase(),s=t.style[e]||getComputedStyle(t).getPropertyValue(i)||"0";return a?ii(t,s,a):s}}function ni(t,e){return Fa.dom(t)&&!Fa.inp(t)&&(!Fa.nil(ai(t,e))||Fa.svg(t)&&t[e])?"attribute":Fa.dom(t)&&Ya(Ra,e)?"transform":Fa.dom(t)&&"transform"!==e&&si(t,e)?"css":null!=t[e]?"object":void 0}function oi(t){if(Fa.dom(t)){for(var e,a=t.style.transform||"",i=/(\w+)\(([^)]*)\)/g,s=new Map;e=i.exec(a);)s.set(e[1],e[2]);return s}}function ri(t,e,a,i){var s=La(e,"scale")?1:0+function(t){return La(t,"translate")||"perspective"===t?"px":La(t,"rotate")||La(t,"skew")?"deg":void 0}(e),n=oi(t).get(e)||s;return a&&(a.transforms.list.set(e,n),a.transforms.last=e),i?ii(t,n,i):n}function ci(t,e,a,i){switch(ni(t,e)){case"transform":return ri(t,e,i,a);case"css":return si(t,e,a);case"attribute":return ai(t,e);default:return t[e]||0}}function di(t,e){var a=/^(\*=|\+=|-=)/.exec(t);if(!a)return t;var i=ti(t)||0,s=parseFloat(e),n=parseFloat(t.replace(a[0],""));switch(a[0][0]){case"+":return s+n+i;case"-":return s-n+i;case"*":return s*n+i}}function li(t,e){if(Fa.col(t))return Za(t);if(/\s/g.test(t))return t;var a=ti(t),i=a?t.substr(0,t.length-a.length):t;return e?i+e:i}function hi(t,e){return Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2))}function ui(t){for(var e,a=t.points,i=0,s=0;s<a.numberOfItems;s++){var n=a.getItem(s);s>0&&(i+=hi(e,n)),e=n}return i}function pi(t){if(t.getTotalLength)return t.getTotalLength();switch(t.tagName.toLowerCase()){case"circle":return function(t){return 2*Math.PI*ai(t,"r")}(t);case"rect":return function(t){return 2*ai(t,"width")+2*ai(t,"height")}(t);case"line":return function(t){return hi({x:ai(t,"x1"),y:ai(t,"y1")},{x:ai(t,"x2"),y:ai(t,"y2")})}(t);case"polyline":return ui(t);case"polygon":return function(t){var e=t.points;return ui(t)+hi(e.getItem(e.numberOfItems-1),e.getItem(0))}(t)}}function mi(t,e){var a=e||{},i=a.el||function(t){for(var e=t.parentNode;Fa.svg(e)&&Fa.svg(e.parentNode);)e=e.parentNode;return e}(t),s=i.getBoundingClientRect(),n=ai(i,"viewBox"),o=s.width,r=s.height,c=a.viewBox||(n?n.split(" "):[0,0,o,r]);return{el:i,viewBox:c,x:c[0]/1,y:c[1]/1,w:o,h:r,vW:c[2],vH:c[3]}}function fi(t,e,a){function i(a){void 0===a&&(a=0);var i=e+a>=1?e+a:0;return t.el.getPointAtLength(i)}var s=mi(t.el,t.svg),n=i(),o=i(-1),r=i(1),c=a?1:s.w/s.vW,d=a?1:s.h/s.vH;switch(t.property){case"x":return(n.x-s.x)*c;case"y":return(n.y-s.y)*d;case"angle":return 180*Math.atan2(r.y-o.y,r.x-o.x)/Math.PI}}function gi(t,e){var a=/[+-]?\d*\.?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?/g,i=li(Fa.pth(t)?t.totalLength:t,e)+"";return{original:i,numbers:i.match(a)?i.match(a).map(Number):[0],strings:Fa.str(t)||e?i.split(a):[]}}function wi(t){return Xa(t?Ha(Fa.arr(t)?t.map(qa):qa(t)):[],(function(t,e,a){return a.indexOf(t)===e}))}function Ei(t){var e=wi(t);return e.map((function(t,a){return{target:t,id:a,total:e.length,transforms:{list:oi(t)}}}))}function yi(t,e){var a=Qa(e);if(/^spring/.test(a.easing)&&(a.duration=ka(a.easing)),Fa.arr(t)){var i=t.length;2===i&&!Fa.obj(t[0])?t={value:t}:Fa.fnc(e.duration)||(a.duration=e.duration/i)}var s=Fa.arr(t)?t:[t];return s.map((function(t,a){var i=Fa.obj(t)&&!Fa.pth(t)?t:{value:t};return Fa.und(i.delay)&&(i.delay=a?0:e.delay),Fa.und(i.endDelay)&&(i.endDelay=a===s.length-1?e.endDelay:0),i})).map((function(t){return Ja(t,a)}))}function vi(t,e){var a=[],i=e.keyframes;for(var s in i&&(e=Ja(function(t){for(var e=Xa(Ha(t.map((function(t){return Object.keys(t)}))),(function(t){return Fa.key(t)})).reduce((function(t,e){return t.indexOf(e)<0&&t.push(e),t}),[]),a={},i=function(i){var s=e[i];a[s]=t.map((function(t){var e={};for(var a in t)Fa.key(a)?a==s&&(e.value=t[a]):e[a]=t[a];return e}))},s=0;s<e.length;s++)i(s);return a}(i),e)),e)Fa.key(s)&&a.push({name:s,tweens:yi(e[s],t)});return a}function Ii(t,e){var a;return t.tweens.map((function(i){var s=function(t,e){var a={};for(var i in t){var s=ei(t[i],e);Fa.arr(s)&&1===(s=s.map((function(t){return ei(t,e)}))).length&&(s=s[0]),a[i]=s}return a.duration=parseFloat(a.duration),a.delay=parseFloat(a.delay),a}(i,e),n=s.value,o=Fa.arr(n)?n[1]:n,r=ti(o),c=ci(e.target,t.name,r,e),d=a?a.to.original:c,l=Fa.arr(n)?n[0]:d,h=ti(l)||ti(c),u=r||h;return Fa.und(o)&&(o=d),s.from=gi(l,u),s.to=gi(di(o,l),u),s.start=a?a.end:0,s.end=s.start+s.delay+s.duration+s.endDelay,s.easing=ja(s.easing,s.duration),s.isPath=Fa.pth(n),s.isPathTargetInsideSVG=s.isPath&&Fa.svg(e.target),s.isColor=Fa.col(s.from.original),s.isColor&&(s.round=1),a=s,s}))}var Di={css:function(t,e,a){return t.style[e]=a},attribute:function(t,e,a){return t.setAttribute(e,a)},object:function(t,e,a){return t[e]=a},transform:function(t,e,a,i,s){if(i.list.set(e,a),e===i.last||s){var n="";i.list.forEach((function(t,e){n+=e+"("+t+") "})),t.style.transform=n}}};function Ci(t,e){Ei(t).forEach((function(t){for(var a in e){var i=ei(e[a],t),s=t.target,n=ti(i),o=ci(s,a,n,t),r=di(li(i,n||ti(o)),o),c=ni(s,a);Di[c](s,a,r,t.transforms,!0)}}))}function bi(t,e){return Xa(Ha(t.map((function(t){return e.map((function(e){return function(t,e){var a=ni(t.target,e.name);if(a){var i=Ii(e,t),s=i[i.length-1];return{type:a,property:e.name,animatable:t,tweens:i,duration:s.end,delay:i[0].delay,endDelay:s.endDelay}}}(t,e)}))}))),(function(t){return!Fa.und(t)}))}function Ai(t,e){var a=t.length,i=function(t){return t.timelineOffset?t.timelineOffset:0},s={};return s.duration=a?Math.max.apply(Math,t.map((function(t){return i(t)+t.duration}))):e.duration,s.delay=a?Math.min.apply(Math,t.map((function(t){return i(t)+t.delay}))):e.delay,s.endDelay=a?s.duration-Math.max.apply(Math,t.map((function(t){return i(t)+t.duration-t.endDelay}))):e.endDelay,s}var Pi=0;var Ti=[],xi=function(){var t;function e(a){for(var i=Ti.length,s=0;s<i;){var n=Ti[s];n.paused?(Ti.splice(s,1),i--):(n.tick(a),s++)}t=s>0?requestAnimationFrame(e):void 0}return"undefined"!=typeof document&&document.addEventListener("visibilitychange",(function(){Si.suspendWhenDocumentHidden&&(Ni()?t=cancelAnimationFrame(t):(Ti.forEach((function(t){return t._onDocumentVisibility()})),xi()))})),function(){t||Ni()&&Si.suspendWhenDocumentHidden||!(Ti.length>0)||(t=requestAnimationFrame(e))}}();function Ni(){return!!document&&document.hidden}function Si(t){void 0===t&&(t={});var e,a=0,i=0,s=0,n=0,o=null;function r(t){var e=window.Promise&&new Promise((function(t){return o=t}));return t.finished=e,e}var c=function(t){var e=$a(Na,t),a=$a(Sa,t),i=vi(a,t),s=Ei(t.targets),n=bi(s,i),o=Ai(n,a),r=Pi;return Pi++,Ja(e,{id:r,children:[],animatables:s,animations:n,duration:o.duration,delay:o.delay,endDelay:o.endDelay})}(t);function d(){var t=c.direction;"alternate"!==t&&(c.direction="normal"!==t?"normal":"reverse"),c.reversed=!c.reversed,e.forEach((function(t){return t.reversed=c.reversed}))}function l(t){return c.reversed?c.duration-t:t}function h(){a=0,i=l(c.currentTime)*(1/Si.speed)}function u(t,e){e&&e.seek(t-e.timelineOffset)}function p(t){for(var e=0,a=c.animations,i=a.length;e<i;){var s=a[e],n=s.animatable,o=s.tweens,r=o.length-1,d=o[r];r&&(d=Xa(o,(function(e){return t<e.end}))[0]||d);for(var l=Oa(t-d.start-d.delay,0,d.duration)/d.duration,h=isNaN(l)?1:d.easing(l),u=d.to.strings,p=d.round,m=[],f=d.to.numbers.length,g=void 0,w=0;w<f;w++){var E=void 0,y=d.to.numbers[w],v=d.from.numbers[w]||0;E=d.isPath?fi(d.value,h*y,d.isPathTargetInsideSVG):v+h*(y-v),p&&(d.isColor&&w>2||(E=Math.round(E*p)/p)),m.push(E)}var I=u.length;if(I){g=u[0];for(var D=0;D<I;D++){u[D];var C=u[D+1],b=m[D];isNaN(b)||(g+=C?b+C:b+" ")}}else g=m[0];Di[s.type](n.target,s.property,g,n.transforms),s.currentValue=g,e++}}function m(t){c[t]&&!c.passThrough&&c[t](c)}function f(t){var h=c.duration,f=c.delay,g=h-c.endDelay,w=l(t);c.progress=Oa(w/h*100,0,100),c.reversePlayback=w<c.currentTime,e&&function(t){if(c.reversePlayback)for(var a=n;a--;)u(t,e[a]);else for(var i=0;i<n;i++)u(t,e[i])}(w),!c.began&&c.currentTime>0&&(c.began=!0,m("begin")),!c.loopBegan&&c.currentTime>0&&(c.loopBegan=!0,m("loopBegin")),w<=f&&0!==c.currentTime&&p(0),(w>=g&&c.currentTime!==h||!h)&&p(h),w>f&&w<g?(c.changeBegan||(c.changeBegan=!0,c.changeCompleted=!1,m("changeBegin")),m("change"),p(w)):c.changeBegan&&(c.changeCompleted=!0,c.changeBegan=!1,m("changeComplete")),c.currentTime=Oa(w,0,h),c.began&&m("update"),t>=h&&(i=0,c.remaining&&!0!==c.remaining&&c.remaining--,c.remaining?(a=s,m("loopComplete"),c.loopBegan=!1,"alternate"===c.direction&&d()):(c.paused=!0,c.completed||(c.completed=!0,m("loopComplete"),m("complete"),!c.passThrough&&"Promise"in window&&(o(),r(c)))))}return r(c),c.reset=function(){var t=c.direction;c.passThrough=!1,c.currentTime=0,c.progress=0,c.paused=!0,c.began=!1,c.loopBegan=!1,c.changeBegan=!1,c.completed=!1,c.changeCompleted=!1,c.reversePlayback=!1,c.reversed="reverse"===t,c.remaining=c.loop,e=c.children;for(var a=n=e.length;a--;)c.children[a].reset();(c.reversed&&!0!==c.loop||"alternate"===t&&1===c.loop)&&c.remaining++,p(c.reversed?c.duration:0)},c._onDocumentVisibility=h,c.set=function(t,e){return Ci(t,e),c},c.tick=function(t){s=t,a||(a=s),f((s+(i-a))*Si.speed)},c.seek=function(t){f(l(t))},c.pause=function(){c.paused=!0,h()},c.play=function(){c.paused&&(c.completed&&c.reset(),c.paused=!1,Ti.push(c),h(),xi())},c.reverse=function(){d(),c.completed=!c.reversed,h()},c.restart=function(){c.reset(),c.play()},c.remove=function(t){Mi(wi(t),c)},c.reset(),c.autoplay&&c.play(),c}function Ri(t,e){for(var a=e.length;a--;)Ya(t,e[a].animatable.target)&&e.splice(a,1)}function Mi(t,e){var a=e.animations,i=e.children;Ri(t,a);for(var s=i.length;s--;){var n=i[s],o=n.animations;Ri(t,o),o.length||n.children.length||i.splice(s,1)}a.length||i.length||e.pause()}Si.version="3.2.1",Si.speed=1,Si.suspendWhenDocumentHidden=!0,Si.running=Ti,Si.remove=function(t){for(var e=wi(t),a=Ti.length;a--;){Mi(e,Ti[a])}},Si.get=ci,Si.set=Ci,Si.convertPx=ii,Si.path=function(t,e){var a=Fa.str(t)?Ka(t)[0]:t,i=e||100;return function(t){return{property:t,el:a,svg:mi(a),totalLength:pi(a)*(i/100)}}},Si.setDashoffset=function(t){var e=pi(t);return t.setAttribute("stroke-dasharray",e),e},Si.stagger=function(t,e){void 0===e&&(e={});var a=e.direction||"normal",i=e.easing?ja(e.easing):null,s=e.grid,n=e.axis,o=e.from||0,r="first"===o,c="center"===o,d="last"===o,l=Fa.arr(t),h=l?parseFloat(t[0]):parseFloat(t),u=l?parseFloat(t[1]):0,p=ti(l?t[1]:t)||0,m=e.start||0+(l?h:0),f=[],g=0;return function(t,e,w){if(r&&(o=0),c&&(o=(w-1)/2),d&&(o=w-1),!f.length){for(var E=0;E<w;E++){if(s){var y=c?(s[0]-1)/2:o%s[0],v=c?(s[1]-1)/2:Math.floor(o/s[0]),I=y-E%s[0],D=v-Math.floor(E/s[0]),C=Math.sqrt(I*I+D*D);"x"===n&&(C=-I),"y"===n&&(C=-D),f.push(C)}else f.push(Math.abs(o-E));g=Math.max.apply(Math,f)}i&&(f=f.map((function(t){return i(t/g)*g}))),"reverse"===a&&(f=f.map((function(t){return n?t<0?-1*t:-t:Math.abs(g-t)})))}return m+(l?(u-h)/g:h)*(Math.round(100*f[e])/100)+p}},Si.timeline=function(t){void 0===t&&(t={});var e=Si(t);return e.duration=0,e.add=function(a,i){var s=Ti.indexOf(e),n=e.children;function o(t){t.passThrough=!0}s>-1&&Ti.splice(s,1);for(var r=0;r<n.length;r++)o(n[r]);var c=Ja(a,$a(Sa,t));c.targets=c.targets||t.targets;var d=e.duration;c.autoplay=!1,c.direction=e.direction,c.timelineOffset=Fa.und(i)?d:di(i,d),o(e),e.seek(c.timelineOffset);var l=Si(c);o(l),n.push(l);var h=Ai(n,t);return e.delay=h.delay,e.endDelay=h.endDelay,e.duration=h.duration,e.seek(0),e.reset(),e.autoplay&&e.play(),e},e},Si.easing=ja,Si.penner=Ga,Si.random=function(t,e){return Math.floor(Math.random()*(e-t+1))+t};var Oi=Si,Li={duration:1e3,loop:!1,easing:"easeInOutSine"};function _i(t,e){const a={};if(e.complete&&t.complete){const i=e.complete,s=t.complete;a.complete=t=>{i(t),s(t)}}return{...t,...e,...a}}function Fi(t,e,a={}){const{left:i,top:s}=t.getBoundingClientRect(),{left:n,top:o}=e.getBoundingClientRect(),r=n-i,c=o-s;return new Promise((e=>{const i=_i({targets:t,translateX:r,translateY:c,...Li,complete:()=>{e(!0)}},a);Oi(i)}))}var Vi=t("AnimeUtil",class{async movePoint(t,e,a={}){const i=xa(e);if(!i)return ibiz.log.debug("终点元素不存在"),!1;const s=Pa(t,document.body);if(!s)return ibiz.log.debug("动画元素不存在"),!1;const{padding:n,width:o,height:r}=Ta(s),c={borderRadius:["0%","50%"],maxWidth:[o,"6px"],maxHeight:[r,"6px"],minWidth:[o,"6px"],minHeight:[r,"6px"],padding:[n,"6px"],duration:700};Object.assign(c,a);const d=await Fi(s,i,c);var l;return(l=s)&&l.remove(),d}moveToTarget(t,e,a={}){return Fi(t,e,a)}resize(t,e={}){return function(t,e={}){return new Promise((a=>{const i=_i({scale:[1,.8,1],targets:t,...Li,complete:()=>{a(!0)}},e);Oi(i)}))}(t,e)}async moveAndResize(t,e,a={}){const i=await this.movePoint(t,e,a);return i&&await this.resize(e,{duration:500}),i}}),ki=t("FileUtil",class{calcOSSCatUrl(t,e,a){var i;let s="".concat(ibiz.env.baseUrl,"/").concat(ibiz.env.appId).concat(t);const n=ibiz.hub.getApp(e.srfappid),o=a||n.model.defaultOSSCat||(null==(i=n.model.userParam)?void 0:i.DefaultOSSCat);return s=s.replace("/{cat}",o?"/".concat(o):""),s}calcFileUpDownUrl(t,e,a={},i={}){const{uploadParams:s,exportParams:n,osscat:o}=i;let r=this.calcOSSCatUrl(ibiz.env.uploadFileUrl,t,o),c=this.calcOSSCatUrl("".concat(ibiz.env.downloadFileUrl,"/%fileId%"),t,o),d={},l={};return s&&(d=oe(s,a,e,t)),n&&(l=oe(n,a,e,t)),r+=Et.stringify(d,{addQueryPrefix:!0}),c+=Et.stringify(l,{addQueryPrefix:!0}),{uploadUrl:r,downloadUrl:c}}async fileDownload(t,e){const a=await ibiz.net.request(t,{method:"get",responseType:"blob",baseURL:""});if(200!==a.status)throw new o("下载文件失败");if(!a.data)throw new o("文件流数据不存在");{const t=e;c(a.data,t)}}async fileUpload(t,e,a){const i=new FormData;i.append("file",e);const s=await ibiz.net.axios({url:t,method:"post",headers:a,data:i});if(200!==s.status)throw new o("文件上传失败");return s.data}}),zi=class{constructor(){this.psModelGroupCondBase=null}parse(t){if(t instanceof Array){const e=this.createPSModelGroupCond();e.parse(t),this.psModelGroupCondBase=e}}testSingleCond(t,e,a){try{if("ISNULL"===t)return null==e;if("ISNOTNULL"===t)return null!=e;if("EQ"===t||"ABSEQ"===t||"GT"===t||"GTANDEQ"===t||"LT"===t||"LTANDEQ"===t||"NOTEQ"===t){if(null==e||null==a)return!1;let i=-1;if(e==a?i=0:e>a&&(i=1),"EQ"===t||"ABSEQ"===t)return 0===i;if("GT"===t)return i>0;if("GTANDEQ"===t)return i>=0;if("LT"===t)return i<0;if("LTANDEQ"===t)return i<=0;if("NOTEQ"===t)return 0!==i}if("LIKE"===t)return null!=e&&null!=a&&-1!==e.toString().toUpperCase().indexOf(a.toString().toUpperCase());if("LEFTLIKE"===t)return null!=e&&null!=a&&0===e.toString().toUpperCase().indexOf(a.toString().toUpperCase())}catch(t){ibiz.log.error(t)}return!1}getPSModelGroupCondBase(){return this.psModelGroupCondBase}},Wi=class{constructor(){this.strCondOp=null}getCondOp(){return this.strCondOp}setCondOp(t){this.strCondOp=t}},Ui=class extends Wi{parse(t){const e=t.length;let a=!0,i=!1,s=!1;for(let n=0;n<e;n++)if(a){const e=t[n];this.setCondOp(e),a=!1,i=!0}else if(i){const e=t[n];this.setParam(e),i=!1,s=!0}else if(s){const e=t[n];if(e instanceof Object&&!(e instanceof Array)){const t=e;null!=t.type&&this.setValueType(t.type.toString()),null!=t.value&&this.setValue(t.value.toString())}else this.setValue(e);break}}getValueType(){return this.strValueType}setValueType(t){this.strValueType=t}getValue(){return this.strValue}setValue(t){this.strValue=t}getParamType(){return this.strParamType}setParamType(t){this.strParamType=t}getParam(){return this.strParam}setParam(t){this.strParam=t}},Bi=class t extends Wi{constructor(){super(...arguments),this.childCondList=[],this.bNotMode=!1}parse(e){const a=e.length;let i=!0,s=!0,n=!1;for(let r=0;r<a;r++){if(i&&s){if("!"===e[r]){this.setNotMode(!0),i=!1;continue}}if(s){const t=e[r];this.setCondOp(t),s=!1,i=!1,n=!0}else if(n){const a=e[r];if(!(a instanceof Array))throw new o("值必须为数组");a.forEach((e=>{if(e.length>0){const a=e[0].toString();if("!"===a||"OR"===a||"AND"===a){const a=new t;a.parse(e),this.childCondList.push(a)}else{const t=new Ui;t.parse(e),this.childCondList.push(t)}}}))}}}setNotMode(t){this.bNotMode=t}isNotMode(){return this.bNotMode}getChildPSModelCondBases(){return this.childCondList}},Gi=class extends Bi{},ji=class extends Ui{},Ki=class t extends zi{test(t,e){return this.testCond(this.getPSModelGroupCondBase(),t,e)}testCond(e,a,i){if(e instanceof Bi){const t=e.getChildPSModelCondBases();if(null==t||J(t))return!e.isNotMode();const s="AND"===e.getCondOp();let n=s;for(let e=0;e<t.length;e++){const o=t[e];if(this.testCond(o,a,i)){if(!s){n=!0;break}}else if(s){n=!1;break}}return e.isNotMode()?!n:n}if(e instanceof Ui){J(e.getParam())&&ibiz.log.warn("没有指定属性名称",e);const s=a[e.getParam().toLowerCase()];let n=null;const o=e.getValueType(),r=e.getValue();return null==o||J(o)?n=e.getValue():(J(r)&&ibiz.log.warn("没有指定上下文参数名称"),t.PARAMTYPE_WEBCONTEXT===o?n=i.data[r.toLowerCase()]:t.PARAMTYPE_DATACONTEXT===o&&(n=i.getValue(r.toLowerCase()))),this.testSingleCond(e.getCondOp(),s,n)}return ibiz.log.warn("无法识别的条件对象",e),!1}createPSModelSingleCond(){return new ji}createPSModelGroupCond(){return new Gi}};Ki.PARAMTYPE_DATACONTEXT="DATACONTEXT",Ki.PARAMTYPE_WEBCONTEXT="WEBCONTEXT";var Xi=t("PSDEDQCondEngine",Ki);async function Hi(t,e){var a;const i=null==(a=ibiz.hub.getApp(e).model.appPFPluginRefs)?void 0:a.find((e=>e.pluginCode.toLowerCase()===t));if(i)return await ibiz.plugin.loadPlugin(i),"".concat(i.pluginType,"_").concat(i.pluginCode);ibiz.log.error("未匹配到插件[".concat(t,"]模型"))}var qi=t("APP_COUNTER_PROVIDER_PREFIX","APPCOUNTER");function Yi(t,e){ibiz.register.register("".concat(qi,"_").concat(t),e)}function Qi(t){return ibiz.register.get("".concat(qi,"_").concat(t))}async function $i(t){let e;const{codeName:a,counterType:i,sysPFPluginId:s,appId:n}=t;if(s){const t=await Hi(s,n);if(t&&(e=Qi(t)),e)return e;ibiz.log.error("找不到系统计数器插件".concat(t,"对应的适配器"))}if("CUSTOM"===i){if(e=Qi(a),e)return e;throw new o("找不到自定义系统计数器".concat(a,"对应的适配器"))}if(e=Qi(i),e)return e;throw new o("找不系统计数器类型".concat(i,"对应的适配器"))}var Ji=class{static getRegisterKey(t,e){switch(t){case hs:return this.calcKeyByView(e);case ns:case cs:case Zi:return this.calcKeyByCtrl(e);default:return""}}static calcKeyByView(t){const{controlItemModel:e,controlModel:a,viewModel:i}=t;let s="";return(null==i?void 0:i.codeName)&&(s+="".concat(i.codeName.toUpperCase())),(null==a?void 0:a.codeName)&&(s+="@".concat(a.codeName.toUpperCase())),(null==e?void 0:e.id)&&(s+="@".concat(e.id.toUpperCase())),s}static calcKeyByCtrl(t){const{controlModel:e,controlItemModel:a}=t;let i="",s="APP";if(e){const{appDataEntityId:t,controlType:a,codeName:n}=e;t&&(s=ve(t).toUpperCase()),a&&(i+="@".concat(a.toUpperCase())),n&&(i+="@".concat(n.toUpperCase()))}return(null==a?void 0:a.codeName)&&(i+="@".concat(a.codeName.toUpperCase())),i=s+i,i}},Zi=t("CONTROL_PROVIDER_PREFIX","CONTROL");function ts(t){return ibiz.register.get("".concat(Zi,"_").concat(t))}async function es(t){let e;const{controlType:a,controlStyle:i,sysPFPluginId:s,appId:n}=t,o=Ji.getRegisterKey(Zi,{controlModel:t});if(e=ts(o),e)return e;if(ibiz.log.debug("找不到自定义注册标识为[".concat(o,"]对应的适配器")),s){const t=await Hi(s,n);if(t&&(e=ts(t)),e)return e;ibiz.log.error("找不到部件插件".concat(t,"对应的适配器"))}if(i&&"DEFAULT"!==i){if(e=ts("".concat(a,"_").concat(i)),e)return e;ibiz.log.error("找不到部件类型:[".concat(a,"]的部件样式:[").concat(i,"]对应的适配器"),t)}if(e=ts(a),e)return e;"DATAINFOBAR"!==a&&ibiz.log.error("找不到部件类型".concat(a,"对应的适配器"))}var as=t("EDITOR_PROVIDER_PREFIX","EDITOR");function is(t){return ibiz.register.get("".concat(as,"_").concat(t))}async function ss(t){let e;const{editorType:a,editorStyle:i,predefinedType:s,sysPFPluginId:n,appId:o}=t;if(n){const t=await Hi(n,o);if(t&&(e=is(t)),e)return e;ibiz.log.error("找不到编辑器插件".concat(t,"对应的适配器"))}if(i&&"DEFAULT"!==i){if(e=is("".concat(a,"_").concat(i)),e)return e;ibiz.log.error("找不到编辑器类型:[".concat(a,"]的编辑器样式:[").concat(i,"]对应的适配器"),t)}if(s){let n="".concat(s,"_").concat(a);if(i&&"DEFAULT"!==i&&(n+="_".concat(i)),e=is(n),e)return e;ibiz.log.error("找不到编辑器类型:[".concat(a,"]的预置类型:[").concat(s,"]对应的适配器"),t)}if(e=is(a),e)return e;ibiz.log.error("找不到编辑器类型".concat(a,"对应的适配器"))}var ns=t("FORMDETAIL_PROVIDER_PREFIX","FORMDETAIL");function os(t){return ibiz.register.get("".concat(ns,"_").concat(t))}async function rs(t,e){let a;const{detailType:i,sysPFPluginId:s,appId:n}=t,o=Ji.getRegisterKey(ns,{controlItemModel:t,controlModel:e});if(a=os(o),a)return a;if(ibiz.log.debug("找不到自定义注册标识为[".concat(o,"]对应的适配器")),s){const t=await Hi(s,n);if(t&&(a=os(t)),a)return a;ibiz.log.error("找不到表单成员插件".concat(t,"对应的适配器"))}if(a=os(i),a)return a;ibiz.log.error("找不到表单成员类型".concat(i,"对应的适配器"))}var cs=t("GRIDCOLUMN_PROVIDER_PREFIX","GRIDCOLUMN");function ds(t){return ibiz.register.get("".concat(cs,"_").concat(t))}async function ls(t,e){let a;const{columnType:i,enableRowEdit:s,sysPFPluginId:n,appId:o}=t,r=Ji.getRegisterKey(cs,{controlItemModel:t,controlModel:e});if(a=ds(r),a)return a;if(ibiz.log.debug("找不到自定义注册标识为[".concat(r,"]对应的适配器")),n){const t=await Hi(n,o);if(t&&(a=ds(t)),a)return a;ibiz.log.error("找不到表格列插件".concat(t,"对应的适配器"))}const c=s?"".concat(i,"_EDIT"):i;if(a=ds(c),a)return a;ibiz.log.error("找不到表格列类型".concat(c,"对应的适配器"))}var hs=t("PANELITEM_PROVIDER_PREFIX","PANELITEM");function us(t){return ibiz.register.get("".concat(hs,"_").concat(t.toUpperCase()))}async function ps(t,e,a){var i;let s;const{itemType:n,sysPFPluginId:o,appId:r,controlRenders:c}=t,d=Ji.getRegisterKey(hs,{controlItemModel:t,controlModel:e,viewModel:a});if(s=us(d),s)return s;if(ibiz.log.debug("找不到自定义注册标识为[".concat(d,"]对应的适配器")),o){const t=await Hi(o,r);if(t&&(s=us(t)),s)return s;ibiz.log.error("找不到面板成员插件".concat(t,"对应的适配器"))}if(c&&c.length>0)s=us("PREDEFINE_RENDER");else{if("CONTAINER"===n){const e=t.predefinedType||"DEFAULT",a="CONTAINER_".concat(e);if(s=us(a),s)return s;ibiz.log.error("找不到面板容器预置类型为".concat(e,"的适配器,注册key为").concat(a))}if("RAWITEM"===n){const e=(null==(i=t.rawItem)?void 0:i.predefinedType)||"DEFAULT",a="RAWITEM_".concat(e);if(s=us(a),s)return s;ibiz.log.error("找不到面板成员直接内容预置类型为".concat(e,"的适配器,注册key为").concat(a))}if("FIELD"===n){const{editor:e}=t;if(e&&e.predefinedType){if(s=us("FIELD_".concat(e.predefinedType.toUpperCase())),s)return s}}s=us(n)}if(s)return s;ibiz.log.error("找不到面板成员类型".concat(n,"对应的适配器"))}var ms=t("PORTLET_PROVIDER_PREFIX","PORTLET");function fs(t){return ibiz.register.get("".concat(ms,"_").concat(t))}async function gs(t){let e;const{portletType:a,sysPFPluginId:i,appId:s}=t;if(i){const t=await Hi(i,s);if(t&&(e=fs(t)),e)return e;ibiz.log.error("找不到门户部件插件".concat(t,"对应的适配器"))}if(e=fs(a),e)return e;ibiz.log.error("找不到门户部件成员类型".concat(a,"对应的适配器"))}var ws=t("UIACTION_PROVIDER_PREFIX","UIACTION");function Es(t,e){ibiz.register.register("".concat(ws,"_").concat(t),e)}function ys(t){return ibiz.register.get("".concat(ws,"_").concat(t))}async function vs(t){let e;const{uiactionMode:a,sysPFPluginId:i,appId:s,uiactionTag:n}=t;if(i){const t=await Hi(i,s);if(t&&(e=ys(t)),e)return e;ibiz.log.error("找不到界面行为插件".concat(t,"对应的适配器"))}if(e=ys("".concat(a,"_").concat(n)),e)return e;if(e=ys(a),e)return e;throw new o("找不界面行为模式".concat(a,"对应的适配器"))}var Is=t("UILOGINNODE_PROVIDER_PREFIX","UI_LOGIN_NODE");async function Ds(t){let e;const{sysPFPluginId:a,appId:i}=t,s=await Hi(a,i);if(s){if(e=ibiz.register.get("".concat(Is,"_").concat(s)),e)return e;throw new o("找不到界面逻辑前端插件节点,插件".concat(s,"对应的适配器"))}}var Cs=t("VIEW_PROVIDER_PREFIX","VIEW");function bs(t){return ibiz.register.get("".concat(Cs,"_").concat(t))}var As=t("ASYNC_ACTION_PROVIDER_PREFIX","ASYNC_ACTION");var Ps=t("PlatformProviderBase",class{back(){throw new Error("Method not implemented.")}init(){throw new Error("Method not implemented.")}async login(t,e,a){return ibiz.auth.login(t,e)}async download(t,e){const a=await ibiz.net.request(t,{method:"get",responseType:"blob",baseURL:""});if(200!==a.status)throw new o("下载文件失败");if(a.data){const t=e;return c(a.data,t),Promise.resolve(!0)}throw new o("文件流数据不存在")}}),Ts=t("BrowserPlatformProvider",class extends Ps{});var xs=window.navigator.userAgent.toLowerCase();function Ns(){return/Android|Adr/i.test(xs)?"Android":/iPhone|iPod|iPad/i.test(xs)?"IOS":/MicroMessenger/i.test(xs)?"WeChat":/DingTalk/i.test(xs)?"DingTalk":/miniProgram/i.test(xs)||"miniprogram"===window.__wxjs_environment?"WeChatMiniProgram":"Browser"}var Ss=t("PLATFORM_PROVIDER_PREFIX","PLATFORM");function Rs(t,e){ibiz.register.register("".concat(Ss,"_").concat(t),e)}function Ms(t){return ibiz.register.get("".concat(Ss,"_").concat(t))}function Os(){const t=Ms(Ns());return t||Ms("Browser")}var Ls=t("DEMETHOD_PROVIDER_PREFIX","DEMETHOD");function _s(t,e){ibiz.register.register("".concat(Ls,"_").concat(t),e)}function Fs(t){return ibiz.register.get("".concat(Ls,"_").concat(t))}async function Vs(t){let e;const{methodType:a,sysPFPluginId:i,appId:s}=t;if(i){const t=await Hi(i,s);if(t&&(e=Fs(t)),e)return e;ibiz.log.error("找不到实体行为插件".concat(t,"对应的适配器"))}if(e=Fs(a),e)return e;throw new o("找不实体行为方法类型为".concat(a,"的适配器"))}var ks=t("TREEGRIDEX_COLUMN_PROVIDER_PREFIX","TREEGRIDEX_COLUMN");function zs(t){return ibiz.register.get("".concat(ks,"_").concat(t))}async function Ws(t){let e;const{columnType:a,appId:i,renderSysPFPluginId:s}=t;if(s){const t=await Hi(s,i);if(t&&(e=zs(t)),e)return e;ibiz.log.error("找不到树表格列插件".concat(t,"对应的适配器"))}if(e=zs(a),e)return e;ibiz.log.error("找不到表格列类型".concat(a,"对应的适配器"))}var Us=t("APPMENUITEM_PROVIDER_PREFIX","APPMENUITEM");function Bs(t){return ibiz.register.get("".concat(Us,"_").concat(t))}async function Gs(t){let e;const{sysPFPluginId:a,appId:i,itemType:s}=t;if(a){const t=await Hi(a,i);if(t&&(e=Bs(t)),e)return e;ibiz.log.error("找不到应用菜单项插件".concat(t,"对应的适配器"))}return e=Bs(s),e}var js=t("INTERNAL_MESSAGE_PROVIDER_PREFIX","INTERNAL_MESSAGE");var Ks=t("ERROR_VIEW_PROVIDER_PREFIX","ERROR_VIEW");var Xs=t("AppCounter",class{constructor(t){this.model=t,this.destroyed=!1,this.context=d.create(),this.params={},this.evt=new dt,this.data={},this.countChange=this.countChange.bind(this)}get isDestroyed(){return this.destroyed}async init(t,e){this.setParams(t,e),this.interval(),await this.load(),this.model.appDataEntityId&&ibiz.mc.command.change.on(this.countChange)}countChange(t){const e=t.data;if(this.model.appDataEntityId){const t=ve(this.model.appDataEntityId);e&&e.srfdecodename&&e.srfdecodename.toLowerCase()===t&&this.refresh()}}setParams(t,e){t&&(this.context=Z(t)),e&&(this.params=Z(e))}interval(){this.destroyInterval(),this.intervalTimer=setInterval((()=>{this.evt.getSize("change")>0&&this.load()}),this.model.timer||6e3)}destroyInterval(){this.intervalTimer&&(clearInterval(this.intervalTimer),this.intervalTimer=null)}async load(){throw new o("未实现计数器加载方法")}refresh(t,e){return this.setParams(t,e),this.load()}onChange(t,e=!0){this.evt.on("change",t),e&&nt(this.data)&&t(this.data)}offChange(t){this.evt.off("change",t)}getCounter(t){return this.data[t.toLowerCase()]||0}destroy(){this.destroyed=!0,this.context.destroy(),this.destroyInterval(),this.evt.reset(),ibiz.mc.command.change.off(this.countChange)}}),Hs=t("AppDECounter",class extends Xs{async init(t,e){this.appDataEntityId=this.model.appDataEntityId;const i=this.model.getAppDEActionId;if(!i)throw new a(this.model,"未找到获取计数器行为!");this.action=i,await super.init(t,e)}async load(){const t=ibiz.hub.getApp(this.context.srfappid),e=await t.deService.exec(this.appDataEntityId,this.action,this.context,this.params);return e.ok&&(this.data=e.data,this.evt.emit("change",this.data)),this.data}}),qs=t("AppDECounterProvider",class{createCounter(t){return new Hs(t)}});function Ys(){Yi("DEDR",(()=>new qs))}var Qs=t("DEDQCondUtil",class{static getCond(t){if(this.map.has(t))return this.map.get(t);const e=t.dedqgroupConditions;if(e){const a=new Xi;return 1===e.length?a.parse(this.calcCond(e)[0]):e.length>1&&a.parse(["AND",this.calcCond(e)][0]),this.map.set(t,a),a}return null}static calcCond(t){const e=[];return t.forEach((t=>{const a=[];if("GROUP"===t.condType){const e=t;e.notMode&&a.push("!"),a.push(t.condOp);const i=e.dedqconditions;if(i){const t=this.calcCond(i);a.push(t)}}else{if("SINGLE"!==t.condType)throw new i(t,"暂未支持的查询条件类型: ".concat(t.condType));{const e=t;a.push(e.condOp),a.push(e.fieldName),e.condValue?e.vartypeId?a.push({type:e.vartypeId,value:e.condValue}):a.push(e.condValue):a.push("")}}e.push(a)})),e}});Qs.map=new WeakMap;var $s=t("DynamicCodeListCache",class{constructor(t){this.cache=new Map,this.isPredefined=!1,this.context=d.create(),this.params={},this.evt=new dt,this.commonKeys=["query","queryconds"],this.codeList=t,this.codelistChange=this.codelistChange.bind(this);const{appDataEntityId:e,appDEDataSetId:a}=this.codeList;e&&a&&ibiz.mc.command.change.on(this.codelistChange)}setParams(t,e){t&&(this.context=Z(t)),e&&(this.params=Z(e))}async init(){return this.initPromise=(async()=>{const{predefinedType:t}=this.codeList;if(t){if(this.isPredefined=!0,!["OPERATOR","RUNTIME","DEMAINSTATE"].includes(t))throw new i(this.codeList,"预定义类型".concat(t,"暂不支持"))}else this.initPromise=void 0})(),this.initPromise}convertData(t){const e={},{valueAppDEFieldId:a,textAppDEFieldId:i,iconClsAppDEFieldId:s,iconClsXAppDEFieldId:n,iconPathAppDEFieldId:o,iconPathXAppDEFieldId:r,disableAppDEFieldId:c,dataAppDEFieldId:d,clsAppDEFieldId:l,colorAppDEFieldId:h}=this.codeList,u=a?t[a]:t.srfkey;if(e.id=u,e.value=u,e.text=i?t[i]:t.srfmajortext,(s||n||o||r)&&(e.sysImage={appId:this.codeList.appId},s&&(e.sysImage.cssClass=t[s]),n&&(e.sysImage.cssClassX=t[n]),o&&(e.sysImage.imagePath=t[o]),r&&(e.sysImage.imagePathX=t[r])),c&&(e.disableSelect=on(t[c])),l&&(e.textCls=t[l]),h&&(e.color=t[h]),d&&t[d])try{e.data=Qe.execSingleLine(t[d])}catch(t){ibiz.log.error("动态代码表数据属性返回值不为对象格式的字符串,无法转换!")}return e}presetconvertData(t){const e={},{color:a,bkcolor:i,disabled:s,id:n,text:o,label:r,value:c,cls:d}=t;return e.value=c,e.color=a,e.bkcolor=i,e.text=o,e.id=n,e.id=r,e.disableSelect=s,e.cls=d,e}sortShoworder(t){return t.forEach((t=>{"showorder"in t||Object.assign(t,{showorder:1e3})})),t.sort(((t,e)=>t.showorder-e.showorder))}async load(t,e={}){const i={...e};this.commonKeys.forEach((t=>{delete i[t]})),this.setParams(t,i);const s=ibiz.hub.getApp(t.srfappid),{appDataEntityId:n,appDEDataSetId:o,minorSortAppDEFieldId:r,minorSortDir:c,pvalueAppDEFieldId:d,customCond:l}=this.codeList;if(r&&c&&Object.assign(i,{sort:"".concat(r.toLowerCase(),",").concat(c.toLowerCase())}),l){const e=oe(Qe.execSingleLine(l),i,t);Object.assign(i,e)}if(i.size||(i.size=1e4),this.isPredefined&&this.codeList.codeName){let t=this.codeList.codeName;if("OPERATOR"===this.codeList.predefinedType){const e=this.codeList.codeName.indexOf("__");t=-1!==e?this.codeList.codeName.substring(e+2):this.codeList.codeName}const e=await s.net.get("/dictionaries/codelist/".concat(t),i),a=[],{items:n}=e.data;return this.sortShoworder(n).length&&n.forEach((t=>{a.push(this.presetconvertData(t))})),Object.freeze(a)}if(!n)throw new a(this.codeList,"未配置应用实体");if(!o)throw new a(this.codeList,"未配置数据集");const h=await s.deService.exec(n,o,t,void 0,i);let u=[];if(h.data.length)if(d){const t=this.prepareTreeData(h.data);t&&(u=t)}else h.data.forEach((t=>{u.push(this.convertData(t))}));return Object.freeze(u)}prepareTreeData(t){const{valueAppDEFieldId:e,pvalueAppDEFieldId:a}=this.codeList,i={},s=[];return t.forEach((t=>{i[t[e]]=this.convertData(t)})),t.forEach((t=>{const n=i[t[a]];n?(n.children=n.children||[],n.children.push(i[t[e]])):s.push(i[t[e]])})),s}async get(t,e={}){if(this.initPromise&&await this.initPromise,!this.codeList.enableCache)return this.load(t,e);const a=JSON.stringify(t)+JSON.stringify(e);if(this.cache.has(a)){const t=this.cache.get(a);if(t.expirationTime>(new Date).getTime())return t.promise?t.promise:t.items;this.cache.delete(a)}const i=this.load(t,e),{cacheTimeout:s}=this.codeList,n=-1===s||Q(s)?ibiz.config.codeList.timeout:this.codeList.cacheTimeout,o={expirationTime:(new Date).getTime()+n,promise:i};this.cache.set(a,o);const r=await i;return o.items=r,delete o.promise,r}codelistChange(t){const e=t.data,{appDataEntityId:a}=this.codeList;if(a){const t=ve(a);e&&e.srfdecodename&&e.srfdecodename.toLowerCase()===t&&this.refresh()}}async refresh(){const t=JSON.stringify(this.context)+JSON.stringify(this.params);this.cache.delete(t);const e=await this.get(this.context,this.params);this.evt.emit("change",e)}onChange(t,e=!0){this.evt.on("change",t);const a=JSON.stringify(this.context)+JSON.stringify(this.params),i=this.cache.get(a);e&&nt(i)&&t(i.items)}offChange(t){this.evt.off("change",t)}destroy(){const{appDataEntityId:t,appDEDataSetId:e}=this.codeList;t&&e&&ibiz.mc.command.change.off(this.codelistChange)}});function Js(t,e){if(null!=e){const{srfkey:t}=e;if(!Q(t)&&!J(t))return!0}throw new o("执行「".concat(t,"」不存在「srfkey」无法处理"))}function Zs(t,e){const{srfsessionid:a}=e;if(!Q(a)&&!J(a))return!0;throw new o("执行「".concat(t,"」不存在「srfsessionid」无法处理"))}var tn=t("DECache",class{constructor(t){this.entity=t,this.cacheMap=new Map}get isUnionKey(){var t;return!!(null==(t=this.entity.unionKeyValueAppDEFieldIds)?void 0:t.length)}forceAdd(t,e){const a=this.cacheMap.get(e.srfkey);a&&(a.assign(e),ibiz.log.warn("forceAdd",e.srfkey,e))}forceUpdate(t,e){this.cacheMap.set(e.srfkey,Z(e)),ibiz.log.warn("forceUpdate",e.srfkey,e)}forceDelete(t,e){this.cacheMap.delete(e),ibiz.log.warn("forceDelete",e)}add(t,e){if(this.isUnionKey&&(this.calcUnionKey(e),this.checkData(t,e.srfkey)))throw new o("新建联合主键数据失败,已有主键为".concat(e.srfkey,"的数据"));try{Zs("add",t),(Q(e.srfkey)||J(e.srfkey))&&(e.srfkey=ct()),e.srftempdate=(new Date).getTime();const a=()=>{this.cacheMap.set(e.srfkey,Z(e)),ibiz.log.warn("add",e.srfkey,e)},i=this.getTransaction(t);return i?i.change(e.srfkey,(()=>{a()})):a(),e}catch(t){return ibiz.log.error(t),null}}get(t,e){try{Zs("get",t);const a=this.cacheMap.get(e);return ibiz.log.warn("get",e,a),Z(a)}catch(t){return ibiz.log.error(t),null}}update(t,e){const a=e.srfkey;if(this.isUnionKey&&(this.calcUnionKey(e),a!==e.srfkey&&this.checkData(t,e.srfkey)))throw new o("更新联合主键数据失败,已有主键为".concat(e.srfkey,"的数据"));try{Zs("update",t),Js("update",e),e.srftempdate=(new Date).getTime();const i=this.cacheMap.get(a);if(i){const s=Z(i);s.assign(e);const n=()=>{i.assign(e),a!==e.srfkey&&this.cacheMap.delete(a),this.cacheMap.set(e.srfkey,i),ibiz.log.warn("update",e.srfkey,e)},o=this.getTransaction(t);return o?o.change(e.srfkey,(()=>{n()})):n(),s}throw new Error("数据不存在,无法更新!")}catch(t){return ibiz.log.error(t),null}}delete(t,e){try{Zs("delete",t);const a=e;if(this.cacheMap.has(a)){const e=this.cacheMap.get(a),i=()=>{this.cacheMap.delete(a),ibiz.log.warn("delete",a)},s=this.getTransaction(t);return s?s.change(a,(()=>{i()})):i(),e}return null}catch(t){return ibiz.log.error(t),null}}createBatch(t,e){try{Zs("add",t);const a=t=>{this.cacheMap.set(t.srfkey,t),ibiz.log.warn("add",t.srfkey,t)},i=this.getTransaction(t);for(let t=0;t<e.length;t++){const s=e[t];(Q(s.srfkey)||J(s.srfkey))&&(s.srfkey=ct()),s.srftempdate=(new Date).getTime();const n=Z(s);i?i.change(n.srfkey,(()=>{a(n)})):a(n)}return e}catch(t){ibiz.log.error(t)}return[]}updateBatch(t,e){try{Zs("update",t);const a=(t,e)=>{e!==t.srfkey&&this.cacheMap.delete(e),this.cacheMap.set(t.srfkey,t),ibiz.log.warn("update",t.srfkey,t)},i=this.getTransaction(t);for(let s=0;s<e.length;s++){const n=e[s];Js("update",n);const r=n.srfkey;if(this.isUnionKey&&(this.calcUnionKey(n),r!==n.srfkey&&this.checkData(t,n.srfkey)))throw new o("更新联合主键数据失败,已有主键为".concat(n.srfkey,"的数据"));n.srftempdate=(new Date).getTime();const c=this.cacheMap.get(n.srfkey);if(!c)throw new Error("数据[".concat(n.srfdename,"-").concat(n.srfmajortext,"(").concat(n.srfkey,")]不存在,无法更新!"));{const t=Z(c);t.assign(n),e[s]=t,i?i.change(n.srfkey,(()=>{c.assign(n),a(c,r)})):(c.assign(n),a(c,r))}}return e}catch(t){return ibiz.log.error(t),null}}deleteBatch(t,e){try{Zs("delete",t)}catch(t){return ibiz.log.error(t),e}const a=[];for(let t=0;t<e.length;t++){const i=e[t];this.cacheMap.has(i)||a.push(i)}if(a.length>0)throw new Error("未找到以下数据「".concat(a.join("、"),"」,无法删除!"));const i=t=>{this.cacheMap.delete(t),ibiz.log.warn("delete",t)},s=this.getTransaction(t);for(let t=0;t<e.length;t++){const a=e[t];s?s.change(a,(()=>{i(a)})):i(a)}return[]}checkData(t,e){return!!this.cacheMap.get(e)}getList(){const t=this.cacheMap.values();return Array.from(t)}generatePred(t={}){const e={};t.srfkey&&(e.srfkey=tt(t.srfkey)),delete t.srfkey;for(const a in t)if(Object.prototype.hasOwnProperty.call(t,a)){const i=t[a];e[a]=tt(i)}return et(e)}clear(){this.cacheMap.clear()}calcUnionKey(t){const e=this.entity.unionKeyValueAppDEFieldIds.map((t=>he(this.entity.appDEFields||[],t).codeName.toLowerCase())).map((e=>Q(t[e])?"__empty__":t[e]));t.srfkey=e.join("||")}getTransaction(t){const e=ibiz.uiDomainManager.get(t.srfsessionid);return e&&!0===e.transaction.state.isOpen?e.transaction:null}}),en=/\$\{(.*?)\}/g;function an(t,e){const a=(e.requestPaths||[]).map((t=>{const e=t.match(en);return{path:t,keys:(null==e?void 0:e.map((t=>t.substring(2,t.length-1))))||[]}})).filter((e=>{const{keys:a}=e;return 0===a.length||a.every(((e,i)=>i===a.length-1||null!=t[e]))})).sort(((t,e)=>e.keys.length-t.keys.length));if(a.length>0)return a[0]}function sn(t,e){const a=an(t,e);if(a){if(a.keys.length>0){let{path:e}=a;return a.keys.forEach(((i,s)=>{e=s===a.keys.length-1?e.replace(new RegExp("/[^/]+/\\$\\{".concat(i,"\\}")),""):e.replace("${".concat(i,"}"),t[i])})),e}return a.path}return""}var nn=t("SearchFilter",class{constructor(t,e){if(this.page=0,this.size=1e3,this.data={},this.sortField="srfordervalue",this.sortMode="ASC",this.context=t,e){if(Q(e.page)||J(e.page)||(this.page=e.page),Q(e.size)||J(e.size)||(this.size=e.size),Q(e.query)||J(e.query)||(this.query=e.query),!Q(e.sort)&&!J(e.sort)){const t=e.sort.split(",");t.length>=1&&([this.sortField]=t),t.length>=2&&(this.sortMode=t[1].toUpperCase())}this.data={...e},delete this.data.page,delete this.data.size,delete this.data.query,delete this.data.sort}}getValue(t){return this.data[t]?this.data[t]:this.context[t]}});function on(t){if("boolean"==typeof t)return t;if("number"==typeof t)return t>0;if("string"!=typeof t)return!!t;switch(t){case"true":return!0;case"false":return!1;default:{const e=Number(t);return!Number.isNaN(e)&&e>0}}}function rn(t){const e={};if(!t)return e;const a=t.split(",");return a&&a.length>0&&a.forEach((t=>{const[a,i]=t.split(":");e[a]=parseInt(i,10)})),e}var cn=t("CodeListService",class{constructor(t){this.appModel=t,this.allCodeLists=new Map,this.cache=new Map}getStatic(t){const e=t.codeName;if(this.cache.has(e))return this.cache.get(e);const a=t.codeItems;let i=[];return(null==a?void 0:a.length)&&(i=this.formatStaticItems(a,t.codeItemValueNumber)),this.cache.set(e,Object.freeze(i)),i}setCodeList(t){const{id:e,codeName:a}=t;this.allCodeLists.set(e,t),this.allCodeLists.set(a,t)}getCodeList(t){return this.allCodeLists.get(t)}formatStaticItems(t,e){return t.map((t=>{var a;let i=t.text;t.textLanguageRes&&(i=ibiz.i18n.t(t.textLanguageRes.lanResTag,t.text));let{tooltip:s}=t;t.tooltipLanguageRes&&(s=ibiz.i18n.t(t.tooltipLanguageRes.lanResTag,t.tooltip));const n={text:i,value:e?Number(t.value):t.value,color:t.color,id:t.codeName,textCls:t.textCls,disableSelect:t.disableSelect,tooltip:s,data:t.data?Qe.execSingleLine(t.data):void 0,sysImage:t.sysImage,userData:t.userData};return(null==(a=t.codeItems)?void 0:a.length)&&(n.children=this.formatStaticItems(t.codeItems,e)),Object.freeze(n)}))}async getDynamicCodeList(t,e,a={}){let i;const s=t.codeName;return this.cache.has(s)?i=this.cache.get(s):(i=new $s(t),this.cache.set(s,i),await i.init()),i.get(e,a)}async get(t,e,a){const i=this.allCodeLists.get(t);if(!i)throw new o("找不到".concat(t,"代码表"));return"STATIC"===i.codeListType?this.getStatic(i):"DYNAMIC"===i.codeListType?this.getDynamicCodeList(i,e,a):[]}async getCodeListInstance(t){let e;const a=this.allCodeLists.get(t);if(!a)throw new o("找不到".concat(t,"代码表"));if("DYNAMIC"===a.codeListType){const t=a.codeName;this.cache.has(t)?e=this.cache.get(t):(e=new $s(a),this.cache.set(t,e),await e.init())}return e}destroy(){Array.from(this.cache.values()).forEach((t=>{t instanceof $s&&t.destroy()}))}}),dn=t("ConfigService",class{constructor(t,e,a){this.appId=t,this.folder=e,this.tag=a,this.app=ibiz.hub.getApp(t)}async save(t){const e=await this.app.net.put("/configs/".concat(this.folder,"/").concat(this.tag),t);return!!e.ok&&e.data}async load(){const t=await this.app.net.get("/configs/".concat(this.folder,"/").concat(this.tag));return t.ok&&t.data||{}}}),ln=t("CounterService",class{static async getCounter(t,e,a){let i=t.id;if(a&&a.customId&&(i=a.customId),this.counterMap.has(i)){const t=this.counterMap.get(i);if(!1===t.isDestroyed)return t;this.counterMap.delete(i)}const s=(await $i(t)).createCounter(t);return await s.init(e,a),this.counterMap.set(i,s),s}static async getCounterByRef(t,e,i){const{appCounter:s}=t;if(!s)throw new a(t,"未配置应用计数器!");return this.getCounter(s,e,i)}});ln.counterMap=new Map;var hn=t("WorkFlowService",class{constructor(t){this.model=t,this.commonBaseUrl="",this.app=ibiz.hub.getApp(t.appId);const e=ibiz.appData.context;this.commonBaseUrl="/wfcore/".concat(e.srfsystemid,"-app-").concat(this.app.model.codeName.toLowerCase(),"/").concat(this.model.name.toLowerCase())}getBaseUrl(){return this.commonBaseUrl}getActiveData(t,e){return e.srfprocessinstanceid&&(t.srfprocessinstanceid=e.srfprocessinstanceid),t}getWFInstanceTag(t){return t.srfprocessinstanceid||"alls"}async getWFStep(t){const{processDefinitionKey:e,taskDefinitionKey:a}=t;return this.app.net.get("".concat(this.getBaseUrl(),"/process-definitions/").concat(e,"/usertasks/").concat(a))}async getWFLink(t,e){const a=t[this.model.codeName.toLowerCase()],{taskDefinitionKey:i}=t;return this.app.net.post("".concat(this.getBaseUrl(),"/").concat(a,"/usertasks/").concat(i,"/ways"),{activedata:this.getActiveData(e,t)})}async getWFHistory(t){const e=t[this.model.codeName.toLowerCase()];return this.app.net.get("".concat(this.getBaseUrl(),"/").concat(e,"/process-instances/").concat(this.getWFInstanceTag(t),"/history"))}async getWFProcessDiagram(t){const e=t[this.model.codeName.toLowerCase()];return this.app.net.request("".concat(this.getBaseUrl(),"/").concat(e,"/process-instances/").concat(this.getWFInstanceTag(t),"/processdiagram"),{method:"post",data:{},responseType:"blob"})}async getWFVersion(t){return this.app.net.get("/wfcore/".concat(ibiz.appData.context.srfsystemid,"-app-").concat(this.app.model.codeName.toLowerCase(),"/").concat(this.model.name.toLowerCase()).concat(t?"-".concat(t):"","/process-definitions2"))}async wfStart(t,e,a){return this.app.net.post("".concat(this.getBaseUrl(),"/").concat(t[this.model.codeName.toLowerCase()],"/process-instances"),{...e,activedata:this.getActiveData(a,t)})}async wfSubmit(t,e,a){return this.app.net.post("".concat(this.getBaseUrl(),"/").concat(t[this.model.codeName.toLowerCase()],"/tasks/").concat(e.taskId),{...e,activedata:this.getActiveData(a,t)})}async wfWithdraw(t,e,a){return this.app.net.post("".concat(this.getBaseUrl(),"/").concat(t[this.model.codeName.toLowerCase()],"/tasks/").concat(e.taskId,"/withdraw"),{...e,activedata:this.getActiveData(a,t)})}async wfReassign(t,e,a){return ibiz.net.post("".concat(this.getBaseUrl(),"/").concat(t[this.model.codeName.toLowerCase()],"/tasks/").concat(e.taskId,"/transfer"),{...e,activedata:this.getActiveData(a,t)})}async wfAddStepBefore(t,e,a){return ibiz.net.post("".concat(this.getBaseUrl(),"/").concat(t[this.model.codeName.toLowerCase()],"/tasks/").concat(e.taskId,"/beforesign"),{...e,activedata:this.getActiveData(a,t)})}async wfAddStepAfter(t,e,a){return ibiz.net.post("".concat(this.getBaseUrl(),"/").concat(t[this.model.codeName.toLowerCase()],"/tasks/").concat(e.taskId,"/aftersign"),{...e,activedata:this.getActiveData(a,t)})}async wfSendBack(t,e,a){return ibiz.net.post("".concat(this.getBaseUrl(),"/").concat(t[this.model.codeName.toLowerCase()],"/tasks/").concat(e.taskId,"/sendback"),{...e,activedata:this.getActiveData(a,t)})}async wfSendCopy(t,e,a){return ibiz.net.post("".concat(this.getBaseUrl(),"/").concat(t[this.model.codeName.toLowerCase()],"/tasks/").concat(e.taskId,"/sendcopy"),{...e,activedata:this.getActiveData(a,t)})}async exec(t,e,a={},i={}){switch(t){case"wfstart":return this.wfStart(e,a,i);case"wfsubmit":return this.wfSubmit(e,a,i);case"reassign":return this.wfReassign(e,a,i);case"addstepbefore":return this.wfAddStepBefore(e,a,i);case"addstepafter":return this.wfAddStepAfter(e,a,i);case"sendback":return this.wfSendBack(e,a,i);case"sendcopy":return this.wfSendCopy(e,a,i);default:throw new o("「".concat(t,"」未实现"))}}}),un=class{constructor(t){this.model=t}exportData(t,e,a,i){const s=sn(a,this.model),n="".concat(s,"/").concat(this.model.deapicodeName2,"/exportdata/").concat(e.toLowerCase(),"/?srfexporttag=").concat(t.codeName);return ibiz.net.request(n,{method:"post",data:i,responseType:"blob"})}},pn=t("Srfuf",(t=>(t[t.CREATE=0]="CREATE",t[t.UPDATE=1]="UPDATE",t))(pn||{})),mn=t("AppDataEntity",class t{get srfuf(){return this.srfkey===this.tempsrfkey?1:0}constructor(e,a={}){Object.defineProperty(this,"_entity",{enumerable:!1,configurable:!0,value:e}),Object.defineProperty(this,"_data",{enumerable:!1,configurable:!0,value:Z(a instanceof t?a._data:a)}),Object.defineProperty(this,"srfdeid",{get:()=>e.id}),Object.defineProperty(this,"srfdecodename",{get:()=>e.codeName});const i=he(e.appDEFields||[],e.keyAppDEFieldId);if(i){const t=i.codeName.toLowerCase();Object.defineProperty(this,"srfkeyfield",{get:()=>t}),Object.defineProperty(this,"srfkey",{set(e){this._data[t]=e},get(){return this._data[t]}})}else ibiz.log.warn("实体[".concat(e.codeName,"]未配置主键字段"));const s=he(e.appDEFields||[],e.majorAppDEFieldId);if(s){const t=s.codeName.toLowerCase();Object.defineProperty(this,"srfmajorfield",{get:()=>t}),Object.defineProperty(this,"srfmajortext",{set(e){this._data[t]=e},get(){return this._data[t]}})}else ibiz.log.warn("实体[".concat(e.codeName,"]未配置主文本字段"));Object.defineProperty(this,"tempsrfkey",{enumerable:!1,configurable:!0,writable:!0,value:Q(this.srfkey)?ct():this.srfkey}),this.defineProperties()}defineProperties(){var t;const{_data:e,convertVal:a}=this,i={};Object.keys(e).forEach((t=>{i[t]={enumerable:!0,set(a){e[t]=a},get:()=>e[t]}})),null==(t=this._entity.appDEFields)||t.forEach((t=>{const s=t.codeName.toLowerCase();i[s]={enumerable:!0,set(i){e[s]=a(i,t.stdDataType)},get:()=>e[s]},e[s]=a(e[s],t.stdDataType)})),Object.defineProperties(this,i)}clone(){const e=new t(this._entity,this._data);return e.srfkey=this.srfkey,e}assign(e){let a={};return a=e instanceof t?e._data:e,Object.keys(a).forEach((t=>{void 0===a[t]&&delete a[t]})),Object.assign(this._data,a),this}convertVal(t,e){if(null==t)return t;if(Q(e))return t;if(l.isNumber(e)){const e=Q(t)||""===t?t:Number(t);return Number.isNaN(e)?(ibiz.log.debug("".concat(t,"不能转换成数字")),t):e}return t}}),fn=t("MethodDto",class{constructor(t,e,a,i){this.service=t,this.entity=e,this.isLocalMode=a,this.dto=i,this.dtoMap=new Map,i?(this.app=ibiz.hub.getApp(e.appId),this.fields=i.appDEMethodDTOFields||[]):this.fields=[]}convertArrayToListMap(t){const e={};return t.forEach(((t,a)=>{e[a+1]=t})),e}convertListMapToArray(t){const e=[];return Object.keys(t).forEach((a=>{const i=parseInt(a,10);e[i-1]=t[i]})),e}async get(t,e,s=!1){if(!0===t.srfsimple&&!1===this.isLocalMode)return e;const n={},o=ibiz.uiDomainManager.get(t.srfsessionid);for(let r=0;r<this.fields.length;r++){const c=this.fields[r],d=c.codeName.toLowerCase();switch(c.type){case"SIMPLE":case"SIMPLES":case"DTO":break;case"DTOS":if(c.listMap)e[d]&&(n[d]=0===e[d].length?null:this.convertArrayToListMap(e[d]));else{if(void 0!==e[d]&&!1===s)break;if(!c.refAppDataEntityId)break;const i=o.getDERConfig(c.refAppDataEntityId),r=await this.getFieldDto(t,c),l=await ibiz.hub.getAppDEService(r.entity.appId,c.refAppDataEntityId,t),h=i.find((t=>t.majorAppDataEntityId===this.entity.id));let u;if(h&&h.nestedAppDEDataSetId){const a=Z(t);a[this.entity.codeName.toLowerCase()]=e.srfkey;const i={};h.parentAppDEFieldId&&(i[h.parentAppDEFieldId]=e.srfkey),u=await l.exec(h.nestedAppDEDataSetId,a,i)}else{if(r.entity.id===this.entity.id)throw new a(c,"子关系未配置嵌套关系数据集, 会导致递归查询死循环,请配置!");u=await l.exec("FetchDefault",t)}if(u.ok){const e=u.data,a=[];for(let i=0;i<e.length;i++)a.push(await r.get(t,e[i],!0));n[d]=a}}break;default:throw new i(c,"未支持的应用实体方法输入属性类型: ".concat(c.type))}}return{...e,...n}}async sets(t,e){if(!0===t.srfsimple&&!1===this.isLocalMode)return e&&e.length>0?e.map((t=>this.service.createEntity(t))):[];const a=ibiz.uiDomainManager.get(t.srfsessionid);return Promise.all(e.map((async e=>{const i=this.fields.filter((t=>"DTOS"===t.type)).map((async i=>{const s=i.codeName.toLowerCase();if(i.listMap&&"object"==typeof e[s])e[s]=this.convertListMapToArray(e[s]);else{if(!i.refAppDataEntityId)return;const n=a.getDERConfig(i.refAppDataEntityId).find((t=>t.majorAppDataEntityId===this.entity.id)),o=await this.getFieldDto(t,i);n||o.service.local.clear();const r=e[s];if(r&&r.length>0){const a=e[this.entity.keyAppDEFieldId];i.refPickupAppDEFieldId&&r.forEach((t=>{t[i.refPickupAppDEFieldId]=a})),await o.sets(t,r)}else await o.sets(t,[])}}));for(let t=0;t<i.length;t++)await i[t];const s=this.service.createEntity(e);return this.isLocalMode&&await this.service.local.add(t,s),s})))}async calcRs(t,e=0){if(e>10)return;e+=1;const a=ibiz.uiDomainManager.get(t.srfsessionid),i=this.fields.filter((t=>"DTOS"===t.type));for(let s=0;s<i.length;s++){const n=i[s];if(!n.refAppDataEntityId)continue;if(0===a.getDERConfig(n.refAppDataEntityId).length){const i=await this.getFieldDto(t,n);i.entity.minorAppDERSs&&a.setDERConfig(n.refAppDataEntityId,i.entity.minorAppDERSs.filter((t=>1===t.rsmode))),await i.calcRs(t,e)}}}async getFieldDto(t,e){if(this.dtoMap.has(e.codeName))return this.dtoMap.get(e.codeName);const a=await ibiz.hub.getAppDataEntity(e.refAppDataEntityId,this.entity.appId),i=he(a.appDEMethodDTOs||[],e.refAppDEMethodDTOId),s=await this.app.deService.getService(t,a.id);s.isLocalMode=!0;const n=s.createMethodDto(i,{isLocalMode:!0});return this.dtoMap.set(e.codeName,n),n}}),gn=t("DEService",class{constructor(t,e){this.srfSessionId=t,this.model=e,this.methodMap=new Map,this.isLocalMode=!1,this.local=new tn(e),this.configCache=new dn(e.appId,"PSAppDataEntity",e.codeName),this.wf=new hn(e),this.file=new un(e)}async getMethod(t,e=!1){const s=e?"ac-".concat(t):t;if(this.methodMap.has(s))return this.methodMap.get(s);const n=fe(this.model,t);if(!n)throw new a(this.model,"未找到服务方法: ".concat(t));const o=await Vs(n);if(!o)throw new i(n,"未支持的服务方法类型: ".concat(n.methodType));const r=o.create(this,this.model,n,{acMode:e,localMode:this.isLocalMode});return this.methodMap.set(s,r),r}async exec(t,e,a,i,s){const n=await this.getMethod(t);if(n)return n.exec(e,a,i,s);throw new o("".concat(this.model.codeName,"未支持「").concat(t,"」方法"))}getDraft(t,e,a){return this.exec("GetDraft",t,e,a)}create(t,e,a){return this.exec("Create",t,e,a)}get(t,e,a){return this.exec("Get",t,e,a)}update(t,e,a){return this.exec("Update",t,e,a)}remove(t,e,a){return this.exec("Remove",t,e,a)}fetchDefault(t,e,a){return this.exec("FetchDefault",t,e,a)}getDraftTemp(t,e,a){return this.exec("GetDraftTemp",t,e,a)}createTemp(t,e,a){return this.exec("CreateTemp",t,e,a)}getTemp(t,e,a){return this.exec("GetTemp",t,e,a)}updateTemp(t,e,a){return this.exec("UpdateTemp",t,e,a)}removeTemp(t,e,a){return this.exec("RemoveTemp",t,e,a)}fetchTempDefault(t,e,a){return this.exec("FetchTempDefault",t,e,a)}async execAc(t,e,a,i={}){const s=await this.getMethod(t,!0);if(s)return s.exec(e,a,i);throw new o("".concat(this.model.codeName,"未支持「").concat(t,"」方法"))}aiChatSse(t,e,a={},i={}){const s=ibiz.hub.getApp(this.model.appId),n=this.calcSsePath(e);return new Promise(((e,o)=>{s.net.sse("/".concat(n),{srfactag:"AIChat",...a},{headers:{"Content-Type":"application/json"},body:JSON.stringify(i),onmessage:e=>{if(e.data){const a=JSON.parse(e.data);t(a)}},onclose:()=>{e()},onerror:t=>{o(t)}})}))}aiChatHistory(t,e={},a={}){const i=ibiz.hub.getApp(this.model.appId),s=this.calcSsePath(t,!0);return i.net.post(s,a,{srfactag:"AIChat",...e})}calcSsePath(t,e=!1){const a=t[this.model.codeName.toLowerCase()],i="/".concat(this.model.deapicodeName2,"/ssechatcompletion").concat(e?"/histories":"").concat(a?"/".concat(a):"");return sn(t,this.model)+i}newEntity(t){return t instanceof mn?t.clone():new mn(this.model,t)}createEntity(t){return Array.isArray(t)?t.map((t=>this.newEntity(t))):this.newEntity(t)}async destroy(){this.local.clear()}createMethodDto(t,e){return new fn(this,this.model,null==e?void 0:e.isLocalMode,t)}}),wn=["srfkey","srfmajortext","srfmajorfield","srfkeyfield","tempsrfkey","srfuf","srfdeid","srfdecodename"],En=t("ControlVO",class t{constructor(t={},e=new Map){Object.defineProperty(this,"$origin",{enumerable:!1,configurable:!0,value:t||{}}),Object.defineProperty(this,"$dataUIMap",{enumerable:!1,configurable:!0,value:e||new Map}),Object.defineProperty(this,"srfactionparam",{get(){return this.$origin.srfactionparam},set(t){this.$origin.srfactionparam=t},enumerable:!0,configurable:!0}),["srfkey","srfmajortext"].forEach((t=>{if(Object.prototype.hasOwnProperty.call(this.$origin,t))Object.defineProperty(this,t,{get(){return this.$origin[t]},set(e){this.$origin[t]=e},enumerable:!1,configurable:!0});else if(this.$dataUIMap.has(t)){const{dataKey:e}=this.$dataUIMap.get(t);Object.defineProperty(this,t,{get(){return this.$origin[e]},set(t){this.$origin[e]=t},enumerable:!1,configurable:!0})}else Object.defineProperty(this,t,{enumerable:!1,configurable:!0,writable:!0,value:null})})),Object.prototype.hasOwnProperty.call(this.$origin,"tempsrfkey")?Object.defineProperty(this,"tempsrfkey",{get(){return this.$origin.tempsrfkey},set(t){this.$origin.tempsrfkey=t},enumerable:!1,configurable:!0}):Object.defineProperty(this,"tempsrfkey",{enumerable:!1,configurable:!0,writable:!0,value:Q(this.srfkey)?ct():this.srfkey}),Object.defineProperty(this,"srfuf",{get(){return Object.prototype.hasOwnProperty.call(this.$origin,"srfuf")?this.$origin.srfuf:this.srfkey===this.tempsrfkey?1:0},enumerable:!1,configurable:!0}),["srfdeid","srfdecodename","srfkeyfield","srfmajorfield"].forEach((t=>{Object.defineProperty(this,t,{get(){return this.$origin[t]},enumerable:!1,configurable:!0})})),this.$dataUIMap.forEach(((t,e)=>{const a=t.dataKey;this.linkProperty(e,a,t)})),Object.keys(t).forEach((t=>{Object.prototype.hasOwnProperty.call(this,t)||this.linkProperty(t,t)}))}linkProperty(t,e,a){const i=!a||a.isOriginField;wn.includes(t)||(i||Object.prototype.hasOwnProperty.call(this.$origin,t)?Object.defineProperty(this,t,{enumerable:!0,configurable:!0,get(){return this.$origin[e]},set(t){this.$origin[e]=t}}):Object.defineProperty(this,t,{enumerable:!0,configurable:!0,writable:!0,value:null}))}getOrigin(){return this.$origin}setOrigin(e){this.$origin=e instanceof t?e.getOrigin():e}clone(){const e=Z(this.$origin),a=new t(e,this.$dataUIMap);return Object.keys(this).forEach((t=>{a[t]=this[t]})),a}}),yn=t("ControlService",class{constructor(t){this.dataUIMap=new Map,this.model=t}async init(t){this.app=ibiz.hub.getApp(this.model.appId),this.initUIDataMap()}initUIDataMap(){}async exec(t,e,a,i){const s=this.handleCustomRequestHeader(),n=await this.app.deService.exec(this.model.appDataEntityId,t,e,a,i,s);return await this.handleItemPrivilege(n.data,e),n}async handleItemPrivilege(t,e){const{enableItemPrivilege:a,appDataEntityId:i}=this.model;if(a&&i){const a=await this.app.authority.getService(i);(Array.isArray(t)?t:[t]).forEach((t=>{a.setDataAccAction({srfkey:t.srfkey,srfsessionid:e.srfsessionid},t.srfdataaccaction)}))}}handleCustomRequestHeader(){const t={},{enableItemPrivilege:e}=this.model;return e&&Object.assign(t,{srfdataaccaction:!0}),t}handleResponse(t){return h(t)}toUIData(t){return new En(t,this.dataUIMap)}}),vn=t("MDControlService",class extends yn{async fetch(t,e={}){var a;const i=(null==(a=this.model.fetchControlAction)?void 0:a.appDEMethodId)||"fetchdefault";let s=await this.exec(i,t,e);return s=this.handleResponse(s),s}async get(t,e={}){var a;const i=(null==(a=this.model.getControlAction)?void 0:a.appDEMethodId)||"get";let s=await this.exec(i,t,void 0,e);return s=this.handleResponse(s),s}async getDraft(t,e={}){var a;const i=(null==(a=this.model.getDraftControlAction)?void 0:a.appDEMethodId)||"getdraft";let s=await this.exec(i,t,void 0,e);return s=this.handleResponse(s),s}async remove(t,e={}){var a;const i=(null==(a=this.model.removeControlAction)?void 0:a.appDEMethodId)||"remove";return await this.exec(i,t,void 0,e)}async create(t,e){var a;const i=(null==(a=this.model.createControlAction)?void 0:a.appDEMethodId)||"create";let s=await this.exec(i,t,e.getOrigin());return s=this.handleResponse(s),s}async update(t,e){var a;const i=(null==(a=this.model.updateControlAction)?void 0:a.appDEMethodId)||"update";let s=await this.exec(i,t,e.getOrigin());return s=this.handleResponse(s),s}async updateBatch(t,e){var a;const i=(null==(a=this.model.updateControlAction)?void 0:a.appDEMethodId)||"update";let s=await this.exec(i,t,e.map((t=>t.getOrigin())));return s=this.handleResponse(s),s}async exportData(t,e,a={}){throw new o("未实现")}handleResponse(t){const e=super.handleResponse(t);return e.headers&&(e.headers["x-page"]&&(e.page=Number(e.headers["x-page"])),e.headers["x-per-page"]&&(e.size=Number(e.headers["x-per-page"])),e.headers["x-total"]&&(e.total=Number(e.headers["x-total"])),e.headers["x-total-pages"]&&(e.totalPages=Number(e.headers["x-total-pages"]))),e.ok&&(lt(e.data)?e.data=e.data.map((t=>this.toUIData(t))):e.data=this.toUIData(e.data)),e}}),In=t("DeAuthorityService",class{constructor(t){this.entityModel=t,this.dataAccActionMap=new Map}setDataAccAction(t,e){t.srfsessionid&&this.dataAccActionMap.set("".concat(t.srfsessionid,"-").concat(t.srfkey),e),this.dataAccActionMap.set(t.srfkey,e)}getDataAccAction(t){return this.dataAccActionMap.get(t)}async calcByDataAccessAction(t,e,a,i){if(i){if(!await this.calcDeDataAccAction(t,e,a))return!1}return!!await this.calcByDeMainState(t,e)}async calcMajorDataAccAction(t){const{minorAppDERSs:e}=this.entityModel;if(!e)return;const a=null==e?void 0:e.find((e=>{const a=ve(e.majorAppDataEntityId);return Object.prototype.hasOwnProperty.call(t,a)&&t[a]}));if(!a)return;const i=await ibiz.hub.getApp(t.srfappid),s=await i.authority.getService(a.majorAppDataEntityId);if(!s)return;const n=ve(a.majorAppDataEntityId);return s.getDataAccAction("".concat(t.srfsessionid,"-").concat(t[n]))||s.getDataAccAction("".concat(t[n]))}async calcDeDataAccAction(t,e,a){let i,s=!0;const{dataAccCtrlMode:n}=this.entityModel;switch(n){case 1:i=(null==e?void 0:e.srfdataaccaction)?rn(e.srfdataaccaction):void 0;break;case 2:i=rn(await this.calcMajorDataAccAction(a));break;case 3:i=rn(await this.calcMajorDataAccAction(a)),!Object.prototype.hasOwnProperty.call(i,t)&&e&&e.srfdataaccaction&&(i=rn(e.srfdataaccaction))}return i&&t&&!i[t]&&(s=!1),s}async calcByDeMainState(t,e={}){let a=!0;if(0===Object.keys(e).length)return a;const i=this.entityModel;if(!i.enableDEMainState)return ibiz.log.debug("".concat(i.codeName,"实体不存在或者为启用主状态,返回true")),a;ibiz.log.debug("操作标识".concat(t,"主状态计算开始"),e,i);const s=Ee(i,e);if(s){ibiz.log.debug("匹配主状态",s);const e=ye(s,i);ibiz.log.debug("允许的主状态权限集合",e),a=e.includes(t)}else ibiz.log.debug("没匹配主状态,返回false"),a=!1;return ibiz.log.debug("操作标识".concat(t,"权限计算结束:").concat(a)),a}}),Dn=t("AuthorityService",class{constructor(t){this.appModel=t,this.cache=new Map,this.constructorCache=new Map,this.resCodes=[],this.enablePermission=!1}register(t,e){this.constructorCache.set(t,e)}async getService(t){if(!this.cache.has(t)){const e=await ibiz.hub.getAppDataEntity(t,this.appModel.appId);if(!e)throw new o("未找到应用实体[".concat(t,"]"));const a=this.constructorCache.get(t);let i;i=a?await a(e):new In(e),this.cache.set(t,i)}return this.cache.get(t)}async init(t=ibiz.appData){t&&(t.unires&&(this.resCodes=t.unires),!0===t.enablepermissionvalid&&ibiz.env.enablePermission&&(this.enablePermission=!0))}calcByResCode(t){return!this.enablePermission||this.resCodes.includes(t)}async calcByDataAccessAction(t,e,a,i){if(this.enablePermission){const e=await ibiz.hub.getApp(this.appModel.appId),a=await e.getOPPriv(t,i);if(a&&a.mapSysUniResMode&&a.mapSysUniResCode)return!!this.calcByResCode(a.mapSysUniResCode)}if(i){return(await this.getService(i)).calcByDataAccessAction(t,a,e,this.enablePermission)}return!0}}),Cn=t("V7AuthService",class{get isAnonymous(){return"1"===ht(u.IS_ANONYMOUS)}async anonymousLogin(){const{anonymousUser:t,anonymousPwd:e}=ibiz.env;if(!t||!e)return ibiz.log.error("未找到匿名登录配置用户名或密码"),!1;const a=await this.login(t,e);if(a){ut(u.IS_ANONYMOUS,"1",0,!0);const t=ht(u.TOKEN),e=ht(u.TOKEN_EXPIRES),a=ht(u.TOKEN_REMEMBER),i=ht(u.REFRESH_TOKEN);ut(u.TOKEN,t,0,!0),ut(u.TOKEN_EXPIRES,e,0,!0),ut(u.TOKEN_REMEMBER,a,0,!0),i&&ut(u.REFRESH_TOKEN,i,0,!0)}return a}async login(t,e,a){try{const i=await ibiz.net.post("/v7/login",{loginname:t,password:e,rememberme:a}),{data:s}=i;if(s&&s.token){const t=a?30:0;a&&ut(u.TOKEN_REMEMBER,"1",t,!0),ut(u.TOKEN,s.token,t,!0);const e=(new Date).getTime()+1e3*(s.expirein||7199);ut(u.TOKEN_EXPIRES,"".concat(e),t,!0),s.refresh_token&&ut(u.REFRESH_TOKEN,s.refresh_token,t,!0),pt(u.IS_ANONYMOUS)}return!0}catch(t){ibiz.notification.error({title:"登录失败",desc:t.message||""})}return!1}async logout(){try{return await ibiz.net.get("/v7/logout"),pt(u.TOKEN),pt(u.TOKEN_EXPIRES),pt(u.TOKEN_REMEMBER),pt(u.REFRESH_TOKEN),pt(u.IS_ANONYMOUS),ibiz.appData=void 0,ibiz.orgData=void 0,!0}catch(t){ibiz.notification.error({title:"登出失败",desc:t.message||""})}return!1}async extendLogin(){if(this.isAnonymous)return;const t=ht(u.TOKEN),e=ht(u.TOKEN_EXPIRES);if(t&&e){let t=Number(e)-(new Date).getTime();const a=3e5;t=t>a?t-a:0,setTimeout((async()=>{const t=ht(u.TOKEN_REMEMBER),e=ht(u.REFRESH_TOKEN),a=t?30:0;let i;if(i=null!=e&&""!==e?await ibiz.net.get("/uaa/refresh_token/".concat(e)):await ibiz.net.get("/uaa/refreshtoken2"),i.ok){t&&ut(u.TOKEN_REMEMBER,"1",a,!0),ut(u.TOKEN,i.data.token,a,!0);const e=(new Date).getTime()+1e3*(i.data.expirein||7199);ut(u.TOKEN_EXPIRES,"".concat(e),a,!0),i.data.refresh_token&&ut(u.REFRESH_TOKEN,i.data.refresh_token,a,!0),await this.loadAppData(),ibiz.hub.getAllApps().forEach((t=>{t.initMqtt()}))}this.extendLogin()}),t)}}async refreshToken(){const t=ht(u.TOKEN_REMEMBER),e=ht(u.REFRESH_TOKEN);if(null!=e&&""!==e){const a=await ibiz.net.get("/uaa/refresh_token/".concat(e));if(a.ok){const e=t?30:0;t&&ut(u.TOKEN_REMEMBER,"1",e,!0),ut(u.TOKEN,a.data.token,e,!0);const i=(new Date).getTime()+1e3*(a.data.expirein||7199);ut(u.TOKEN_EXPIRES,"".concat(i),e,!0),a.data.refresh_token&&ut(u.REFRESH_TOKEN,a.data.refresh_token,e,!0),pt(u.IS_ANONYMOUS)}}}getAuthInfo(){const t=ht(u.TOKEN),e=!!ht(u.IS_ANONYMOUS);return t?{token:t,isAnonymous:e}:void 0}async loadAppData(){const t=await ibiz.net.get("/appdata");t.ok&&(ibiz.appData=t.data)}}),bn=t("AsyncActionService",class{async fetch(t={}){const e=await ibiz.net.post("/portal/asyncaction/all",t);return Q(e.data)&&(e.data=[]),e}async get(t){return await ibiz.net.get("/portal/asyncaction/".concat(t))}}),An=t("MethodInput",class{constructor(t,e,a,i=!1){this.service=t,this.entity=e,this.method=a,this.isLocalMode=i;const s=a.appDEMethodInput;if(s){const a=he(e.appDEMethodDTOs||[],s.appDEMethodDTOId);a&&(this.dto=t.createMethodDto(a,{isLocalMode:this.isLocalMode}))}}async handle(t,e){return this.dto?this.dto.get(t,e):e}}),Pn=t("MethodReturn",class{constructor(t,e,a,i=!1){this.service=t,this.entity=e,this.method=a,this.isLocalMode=i;const s=a.appDEMethodReturn;if(s){const a=he(e.appDEMethodDTOs||[],s.appDEMethodDTOId);a&&(this.dto=t.createMethodDto(a,{isLocalMode:this.isLocalMode}))}}async handle(t,e){if(this.dto){const a=ibiz.hub.getApp(this.entity.appId),i=ibiz.uiDomainManager.get(t.srfsessionid);i&&!0!==i.state.rsInit&&(await this.dto.calcRs(t),i.calcParentRs(),i.state.rsInit=!0),i.dataChangeCompleted(),a.deService.clearTempCacheByRs({srfappid:a.appId,srfsessionid:t.srfsessionid},this.entity.id);return(await this.dto.sets(t,[e]))[0]}return ot(e)&&(e={}),new mn(this.entity,e)}}),Tn=t("Method",class{constructor(t,e,a,i=!1){this.service=t,this.entity=e,this.method=a,this.isLocalMode=i,this.app=ibiz.hub.getApp(e.appId),this.input=new An(t,e,a),this.result=new Pn(t,e,a)}async request(t,e,i,s,n){const{actionType:o,requestMethod:r}=this.method;if("REMOTE"===o){const e=this.method.requestPath;let o=null;switch(r){case"POST":o=await this.app.net.post(this.mergeRequestPath(t,e),i||s||{},{},n);break;case"GET":o=await this.app.net.get(this.mergeRequestPath(t,e),i||s,n);break;case"PUT":o=await this.app.net.put(this.mergeRequestPath(t,e),i||s||{},n);break;case"DELETE":o=await this.app.net.delete(this.mergeRequestPath(t,e),i||s);break;default:throw new a(this.method,r?"未支持的请求方式: ".concat(r):"未配置请求方式")}return o}throw new a(this.method,"未支持的行为类型[".concat(o,"]"))}mergeRequestPath(t,e){return e?"".concat(t).concat(e):"".concat(t)}calcPath(t){const e="/".concat(this.entity.deapicodeName2);return sn(t,this.entity)+e}createEntity(t){return this.service.createEntity(t)}}),xn=class{constructor(t,e,a,i){this.deLogicParams=t,this.params={},this.result=null,this.isEndNode=!1,this.defaultParamName="Default",this.parameters={context:e,data:_(a)?a:[a],params:i}}get context(){return Object.prototype.hasOwnProperty.call(this.params,"context")?this.params.context:this.parameters.context}get data(){return this.parameters.data}get viewParam(){return Object.prototype.hasOwnProperty.call(this.params,"viewParam")?this.params.viewParam:this.parameters.params}resetParam(t){var e;null==(e=this.deLogicParams.get(t))||e.calc(this)}renewParam(t){var e;null==(e=this.deLogicParams.get(t))||e.renew(this)}setLastReturn(t){this.lastReturn=t}initLastReturnParam(t){Object.defineProperty(this.params,t,{enumerable:!0,configurable:!0,get:()=>this.lastReturn})}isEntityParam(t){const e=this.deLogicParams.get(t);return!(!e||!e.model.entityParam)}},Nn=class{},Sn=class extends Nn{constructor(t){super(),this.model=t,this.srcParam=t.srcLogicParamId,this.dstParam=t.dstLogicParamId}get dstField(){return this.model.dstFieldName.toLowerCase()}get op(){return this.model.condOP}get type(){return this.model.paramType}get value(){return this.model.paramValue}test(t,e,s){const n=t.params[this.dstParam];let o,r;switch(this.type){case"ENTITYFIELD":{if(!this.value)throw new a(this.model,"当前条件值类型为[数据对象属性],缺少配置条件值");const t=null!=s[this.value]?s[this.value]:e[this.value];r=t,o=Ge(n[this.dstField],this.op,t);break}case"SRCENTITYFIELD":{if(!this.value)throw new a(this.model,"当前条件值类型为[源数据对象属性],缺少配置条件值");const e=t.params[this.srcParam];r=e[this.value],o=Ge(n[this.dstField],this.op,e[this.value]);break}case"CURTIME":throw new i(this.model,"暂未支持条件值类型为[当前时间]");default:r=this.value,o=Ge(n[this.dstField],this.op,this.value)}return ibiz.log.debug("实体逻辑连接条件项:".concat(this.model.name,"-条件值类型:").concat(this.type,"-源属性名称:").concat(this.dstField,"-源对象值:"),n[this.dstField],"-对比条件:".concat(this.op),"-对比值",r,"-对比结果:",o),o}},Rn=class t extends Nn{constructor(e){super(),this.model=e;const a=e.conds||[];this.conds=a.map((e=>"SINGLE"===e.logicType?new Sn(e):new t(e)))}get op(){return this.model.groupOP}get notMode(){return!0===this.model.notMode}test(t,e,i){let s=!0;if(0===this.conds.length)throw new a(this.model,"界面连接条件逻辑组未配置逻辑项");for(let a=0;a<this.conds.length;a++){const n=this.conds[a].test(t,e,i);if("AND"===this.op&&!1===n){s=!1;break}if("OR"===this.op&&!0===n){s=!0;break}}const n=this.notMode?!s:s;return ibiz.log.debug("实体逻辑连接条件组名称:".concat(this.model.name,"-条件组标识:").concat(this.model.id,"-运行结果:"),n),n}},Mn=class{constructor(t){this.model=t,this.srcNode=null,this.dstNode=null,this.groupCond=null;const e=this.model.delogicLinkGroupCond;e&&(this.groupCond=new Rn(e))}async exec(t){const{defaultLink:e}=this.model;return!(!e&&this.groupCond)||this.groupCond.test(t,t.context,t.data[0]||{})}},On=class{constructor(t){var e;this.model=t,this.links=null==(e=t.links||[])?void 0:e.map((t=>new Mn(t)))}},Ln=class extends On{async exec(t){const{dstAppDataEntityId:e,dstAppDEActionId:i,dstDELogicParamId:s,retDELogicParamId:n}=this.model;if(!e)throw new a(this.model,"未指定应用实体");if(!i)throw new a(this.model,"未指定实体行为");const o=t.params[s],r=ibiz.hub.getApp(t.context.srfappid),c=await r.deService.exec(e,i,t.context,o,t.viewParam);c.ok&&(t.params[n]=c.data),ibiz.log.debug("实体逻辑节点(实体行为):".concat(this.model.id,"-界面行为所属实体:").concat(e,"-实体行为标识:").concat(i,"-参数名称:").concat(n,"-值:"),t.params[n])}},_n=class extends On{async exec(t){ibiz.log.debug("实体逻辑节点(启动节点):".concat(this.model.id))}},Fn=class extends On{async exec(t){t.isEndNode=!0;const{returnParamId:e,returnType:a,rawValue:s}=this.model;if(a){switch(a){case"NONEVALUE":t.result=void 0;break;case"NULLVALUE":t.result=null;break;case"SRCVALUE":t.result=ibiz.util.rawValue.format(s);break;case"LOGICPARAM":t.result=t.params[e];break;default:throw new i(this.model,"暂未支持的结束节点返回值类型: ".concat(a))}ibiz.log.debug("实体逻辑节点(结束节点):".concat(this.model.id,"-返回值类型:").concat(a,"-返回值:"),t.result)}}};function Vn(t,e){const{srcDELogicParamId:a,srcFieldName:s,srcValue:n,expression:o}=e,r=e.srcValueType||"SRCDLPARAM";let c,d=s;switch(r){case"SRCDLPARAM":c=t.params[a],t.isEntityParam(a)&&(d=null==d?void 0:d.toLowerCase());break;case"NULLVALUE":return null;case"NONEVALUE":return;case"SRCVALUE":return ibiz.util.rawValue.format(n);case"WEBCONTEXT":case"VIEWPARAM":c=t.parameters.params;break;case"APPLICATION":case"SESSION":case"APPDATA":case"DATACONTEXT":c=t.parameters.context;break;case"ENVPARAM":c=Z(ibiz.env);break;case"EXPRESSION":if(!o)throw new i(e,"表达式为空");c=Qe.execScriptFn(t,o,{singleRowReturn:!0,isAsync:!1});break;default:throw new i(e,"暂未支持源值类型".concat(r))}if(c&&d)try{c=Array.isArray(c)?c[Number(d)]:Qe.execScriptFn({srcValue:c},"srcValue.".concat(d),{singleRowReturn:!0,isAsync:!1})}catch(t){throw ibiz.log.error("从源参数取属性".concat(d,"报错,源参数:"),c),t}return c}var kn=class extends On{async exec(t){const e=this.model.delogicNodeParams;(null==e?void 0:e.length)&&await Promise.all(e.map((e=>{let a,s;switch(e.dstDELogicParamId&&"DEBUG"===ibiz.env.logLevel&&(s=Z(t.params[e.dstDELogicParamId])),e.paramAction){case"SETPARAMVALUE":a=this.setParamValue(e,t);break;case"RESETPARAM":a=this.resetParam(e,t);break;case"COPYPARAM":a=this.copyParam(e,t);break;case"BINDPARAM":a=this.bindParam(e,t);break;case"RENEWPARAM":a=this.renewParam(e,t);break;case"APPENDPARAM":a=this.appendParam(e,t);break;case"SORTPARAM":a=this.sortParam(e,t);break;default:throw new i(e,"暂未支持逻辑处理参数操作".concat(e.paramAction))}return ibiz.log.debug("实体逻辑节点(准备参数):".concat(this.model.id,"-参数处理操作:").concat(e.paramAction,"-目标逻辑参数:").concat(e.dstDELogicParamId,"-源参数(值):"),s,"-目标参数(值):",t.params[e.dstDELogicParamId]),a})))}copyParam(t,e){const{dstDELogicParamId:a}=t,i=Vn(e,t);e.params[a]=Z(i)}bindParam(t,e){const a=Vn(e,t);e.params[t.dstDELogicParamId]=a}setParamValue(t,e){const{dstFieldName:a,dstDELogicParamId:i}=t;let s=a;e.isEntityParam(i)&&(s=null==s?void 0:s.toLowerCase());const n=Vn(e,t);s?e.params[i][s]=n:e.params[i]=n}resetParam(t,e){const{dstDELogicParamId:a}=t;e.resetParam(a)}renewParam(t,e){const{dstDELogicParamId:a}=t;e.renewParam(a)}appendParam(t,e){const{dstDELogicParamId:a,dstIndex:i,srcIndex:s,srcSize:n}=t,o=Vn(e,t),r=i||0,c=s||0,d=n||o.length;e.params[a].splice(r,0,...o.slice(c,d))}sortParam(t,e){const{dstDELogicParamId:a,dstFieldName:i,dstSortDir:s}=t,n=i.toLowerCase();e.params[a].sort(((t,e)=>"ASC"===s?t[n]-e[n]:e[n]-t[n]))}},zn=class extends On{async exec(t){const{dstAppDEDataSetId:e,dstAppDataEntityId:a,dstDELogicParamId:i,retDELogicParamId:s}=this.model,n=t.params[i],o=ibiz.hub.getApp(t.context.srfappid),r=await o.deService.exec(a,e,t.context,n);r.ok&&(t.params[s]=r.data),ibiz.log.debug("实体逻辑节点(数据集合):".concat(this.model.id,"-数据集实体标识:").concat(a,"-数据集标识:").concat(e,"-参数名称:").concat(s,"-值:"),t.params[s])}},Wn=class extends On{async exec(t){const{dstDELogicParamId:e,srcDELogicParamId:i}=this.model;if(!e||!i)throw new a(this.model,"缺少目标参数对象或者源参数对象配置");const s=Vn(t,this.model);t.params[e]=s,ibiz.log.debug("实体逻辑节点(绑定参数):".concat(this.model.id,"-参数名称:").concat(e,"-值:"),s)}},Un=class extends On{async exec(t){const{dstDELogicParamId:e}=this.model;if(!e)throw new a(this.model,"缺少目标参数对象配置");t.resetParam(e),ibiz.log.debug("实体逻辑节点(重置参数):".concat(this.model.id,"-重置参数:").concat(e))}},Bn=class extends On{async exec(t){const{dstDELogicParamId:e}=this.model;if(!e)throw new a(this.model,"缺少目标参数对象配置");t.renewParam(e),ibiz.log.debug("实体逻辑节点(重新建立参数):".concat(this.model.id,"-重建参数:").concat(e))}},Gn=class extends On{async exec(t){const{dstDELogicParamId:e,srcDELogicParamId:i}=this.model;if(!e||!i)throw new a(this.model,"缺少目标参数对象或者源参数对象配置");const s=Vn(t,this.model);t.params[e]=Z(s),ibiz.log.debug("实体逻辑节点(拷贝参数):".concat(this.model.id,"-参数名称:").concat(e,"-值:"),s)}},jn=class extends On{async exec(t){const{dstDELogicParamId:e,dstSortDir:i,dstFieldName:s}=this.model;if(!e||!s)throw new a(this.model,"缺少目标参数对象或目标属性配置");const n=s.toLowerCase(),o=t.params[e];o.sort(((t,e)=>"ASC"===i?t[n]-e[n]:e[n]-t[n])),ibiz.log.debug("实体逻辑节点(排序数组参数):".concat(this.model.id,"-排序属性:").concat(s,"-排序模式:").concat(i,"-参数名称:").concat(e,"-排序后数组:"),o)}},Kn=class extends On{async exec(t){const{dstDELogicParamId:e,srcDELogicParamId:i,dstIndex:s,srcIndex:n,srcSize:o}=this.model;if(!e||!i)throw new a(this.model,"缺少目标参数对象或者源参数对象配置");const r=Vn(t,this.model),c=s||0,d=n||0,l=o||r.length;t.params[e].splice(c,0,...r.slice(d,l)),ibiz.log.debug("实体逻辑节点(附加到数组):".concat(this.model.id,"-附加参数:"),t.params,"-附加值:",r.slice(d,l))}},Xn=class extends On{async exec(t){const{errorCode:e,errorInfo:a}=this.model;throw ibiz.log.debug("实体逻辑节点(抛出异常):".concat(this.model.id,"-错误代码:").concat(e,"-错误信息:").concat(a)),new s({response:{status:e,statusText:a}})}},Hn=class{constructor(t){this.model=t}calc(t){const e=this.model.id,a=this.model;if(a.default)a.entityListParam?t.params[e]=t.data||[]:t.params[e]=t.data[0]||{};else if(a.appGlobalParam)t.params[e]=Z(ibiz.env);else if(a.entityListParam)t.params[e]=[];else if(a.entityPageParam)t.params[e]={};else if(a.entityParam)t.params[e]={};else if(a.lastReturnParam)t.initLastReturnParam(e);else if(a.appContextParam)t.params[e]=t.parameters.context;else if(a.simpleListParam)t.params[e]=[];else if(a.simpleParam)t.params[e]={};else if(a.cloneParam)t.params[e]=Z(t.data||{});else{if(a.envParam)throw new i(a,"未支持的逻辑参数类型: 系统环境变量");if(a.fileListParam)throw new i(a,"未支持的逻辑参数类型: 文件对象列表变量");if(a.fileParam)throw new i(a,"未支持的逻辑参数类型: 文件对象变量");if(a.filterParam)throw new i(a,"未支持的逻辑参数类型: 过滤器对象变量");if(a.lastParam)throw new i(a,"未支持的逻辑参数类型: 最后数据变量");if(a.originEntity)throw new i(a,"未支持的逻辑参数类型: 原始数据对象");if(a.sessionParam)throw new i(a,"未支持的逻辑参数类型: 操作会话变量")}ibiz.log.debug("计算实体逻辑参数,标识:".concat(e),"-值:",t.params[e])}renew(t){const e=this.model.id,a=this.model;if(a.entityListParam||a.simpleListParam||a.entityPageParam)t.params[e]=[];else{if(!a.simpleParam&&!a.entityParam)throw new i(a,"未支持的逻辑参数类型重新建立变量");t.params[e]={}}ibiz.log.debug("重新建立实体逻辑参数,标识:".concat(e),"-值:",t.params[e])}},qn=class{constructor(t){var e,s;if(this.model=t,this.nodes=new Map,this.params=new Map,t.customCode){if(!t.scriptCode)throw new a(t,"脚本代码模式没有配置脚本代码");this.scriptFn=Qe.createScriptFn([],t.scriptCode,{isAsync:!0})}else{if(!(null==(e=t.delogicNodes)?void 0:e.length))throw new a(t,"实体逻辑没有配置逻辑节点");t.delogicNodes.forEach((t=>{const{logicNodeType:e}=t;let a;switch(e){case"BEGIN":a=new _n(t);break;case"END":a=new Fn(t);break;case"DEACTION":a=new Ln(t);break;case"PREPAREPARAM":a=new kn(t);break;case"DEDATASET":a=new zn(t);break;case"THROWEXCEPTION":a=new Xn(t);break;case"BINDPARAM":a=new Wn(t);break;case"RESETPARAM":a=new Un(t);break;case"COPYPARAM":a=new Gn(t);break;case"RENEWPARAM":a=new Bn(t);break;case"APPENDPARAM":a=new Kn(t);break;case"SORTPARAM":a=new jn(t);break;default:throw new i(t,"未支持的逻辑节点类型: ".concat(e))}this.nodes.set(t.id,a)})),null==(s=t.delogicParams)||s.forEach((t=>{this.params.set(t.id,new Hn(t))})),this.nodes.forEach((t=>{t.links.forEach((e=>{e.srcNode=t,this.nodes.has(e.model.thenId)&&(e.dstNode=this.nodes.get(e.model.thenId))}))}))}}initLogicParams(t){this.params.forEach((e=>{e.model.default&&(t.defaultParamName=e.model.id),e.calc(t)}))}async exec(t,e,i){if(this.scriptFn)return this.scriptFn.exec({context:t,data:e,params:i});const s=new xn(this.params,t,e,i);this.initLogicParams(s);const{startDELogicNodeId:n}=this.model;if(!n||!this.nodes.has(n))throw new a(this.model,"未设置起始节点");{const t=this.nodes.get(n);await this.deepExec(t,s)}return s.isEndNode?s.result:s.params[s.defaultParamName]?s.params[s.defaultParamName]:null}async deepExec(t,e){await t.exec(e);const{links:a}=t;for(let i=0;i<a.length;i++){const s=a[i];if(await s.exec(e)&&s.dstNode&&(await this.deepExec(s.dstNode,e),!0!==t.model.parallelOutput))break}}},Yn=new Map;async function Qn(t,e,a={},i={}){Yn.has(t)||Yn.set(t,new qn(t)),ibiz.log.debug("开始执行实体逻辑,逻辑标识:".concat(t.id,"-逻辑名称:").concat(t.name));const s=Yn.get(t),n=await s.exec(e,a,i);return ibiz.log.debug("结束执行实体逻辑,逻辑标识:".concat(t.id,"-逻辑名称:").concat(t.name)),n}async function $n(t,e,a,i,s){const n=await async function(t,e,a){return De(t,await ibiz.hub.getAppDataEntity(e,a))}(t,e,a.srfappid);if(!n)throw new o("".concat(e,"找不到实体逻辑").concat(t));return Qn(n,a,i,s)}async function Jn(t,e,a,i){const n=Z(e),o=a?Z(a):a,r=i?Z(i):i;try{const e=await Qn(t,n,o,r);return new p(e)}catch(t){if(t instanceof s)return new p(t,500);throw t}}async function Zn(t,e,a,i,s){const n=Ce(t,e);if(n.length){(await Promise.all(n.map((t=>Qn(t,a,i,s))))).forEach((t=>{Object.assign(i,t)}))}}async function to(t,e,a,i,s={}){if(i){if(!_(i))return Zn(t,e,a,i,s);await Promise.all(i.map((i=>Zn(t,e,a,i,s))))}}var eo=t("DEActionMethod",class extends Tn{async inputHandle(t,e){return _(e)?e:this.input.handle(t,e)}async exec(t,e,i,s){let n;if(e&&!["READ","GETDRAFT"].includes(this.method.actionMode)&&await to(this.entity,"change",t,e,i),"DELOGIC"===this.method.actionType){const s=De(this.method.appDELogicId,this.entity);if(!s)throw new a(this.method,"缺少实体处理逻辑");n=await Jn(s,t,e,i)}else{e&&!this.isLocalMode&&(e=await this.inputHandle(t,e));switch(this.method.actionTag?this.method.actionTag.toUpperCase():this.method.codeName.toUpperCase()){case"CREATE":n=await this.create(t,e,i||{},s);break;case"GET":n=await this.get(t,i,s);break;case"GETDRAFT":n=await this.getDraft(t,i,s);break;case"REMOVE":n=await this.remove(t,i);break;case"UPDATE":n=await this.update(t,e,i,s);break;case"CREATETEMP":n=await this.createTemp(t,e);break;case"GETTEMP":n=await this.getTemp(t,e);break;case"GETDRAFTTEMP":n=await this.getDraftTemp(t,i);break;case"REMOVETEMP":n=await this.removeTemp(t,e);break;case"UPDATETEMP":n=await this.updateTemp(t,e);break;default:{let a=this.calcPath(t);if(this.method.needResourceKey){let i=t[this.entity.codeName.toLowerCase()];O(i)&&(i=_(e)?null:null==e?void 0:e[this.entity.keyAppDEFieldId]),a="".concat(a,"/").concat(i)}const o=await this.request(a,t,e,i,s);o.data=await this.result.handle(t,o.data),n=o}}}return n.data&&await to(this.entity,"compute",t,n.data,i),n}async create(t,e,a,i){if(!e)throw new o("create行为没有传data");if(this.isLocalMode)return this.createTemp(t,this.createEntity(e));const s=this.calcPath(t),n=await this.app.net.post(s,e,a,i);return n.data=await this.result.handle(t,n.data),n}async remove(t,e,a){if(this.isLocalMode)return this.removeTemp(t,e);const i=this.calcPath(t);return await this.app.net.delete("".concat(i,"/").concat(t[this.entity.codeName.toLowerCase()]),e,a)}async update(t,e,a,i){if(!e)throw new o("update行为没有传data");if(this.isLocalMode)return this.updateTemp(t,this.createEntity(e));const s=this.calcPath(t),n=await this.app.net.put("".concat(s,"/").concat(t[this.entity.codeName.toLowerCase()]),e,a,i);return n.data=await this.result.handle(t,n.data),n}async get(t,e={},a={}){if(this.isLocalMode)return this.getTemp(t,e);const i=this.calcPath(t),s=await this.app.net.get("".concat(i,"/").concat(t[this.entity.codeName.toLowerCase()]),e,a);return s.data=await this.result.handle(t,s.data),s}async getDraft(t,e,a){if(this.isLocalMode)return this.getDraftTemp(t,e);const i=this.calcPath(t),s=await this.app.net.get(this.mergeRequestPath(i,this.method.requestPath),e,a);return s.data=await this.result.handle(t,s.data),s}async createTemp(t,e){try{const a=this.createEntity(e);let i;i=_(a)?await Promise.all(a.map((e=>this.service.local.add(t,this.attach(t,e))))):await this.service.local.add(t,this.attach(t,a));const s=ibiz.uiDomainManager.get(t.srfsessionid);return s&&s.dataChange(),new p(i)}catch(t){throw new s(t)}}async getDraftTemp(t,e){try{const t=this.createEntity({});return t?new p(t):new p(t,500)}catch(t){return new p(t,500)}}async removeTemp(t,e){try{let a=null;e&&(a=e[this.entity.keyAppDEFieldId.toLowerCase()]),!a&&t&&(a=t[this.entity.codeName.toLowerCase()]);try{await this.associationDeletion(a,t,e)}catch(t){throw new s({response:new p(null,500,t.message)})}const i=this.service.local.delete(t,a);if(i){const e=ibiz.uiDomainManager.get(t.srfsessionid);return e&&e.dataChange(),new p(i)}return new p(i,500)}catch(t){throw new s(t)}}async associationDeletion(t,e,i){const s=ibiz.uiDomainManager.get(e.srfsessionid),n=s.transaction;let o=!1;!1===n.state.isOpen&&(n.open(),o=!0);try{let i=s.getDERConfigByMajor(this.entity.id);if(i.length>0){const s=this.service.local.get(e,t);i=mt(i,"removeOrder");for(const n of i){if("DER1N"!==n.rstype)throw new a(n,"目前只支持[DER1N]关系类型关联删除删除");const{removeActionType:i,removeRejectMsg:o,minorAppDataEntityId:r,nestedAppDEDataSetId:c="FetchDefault"}=n,d=ibiz.hub.getApp(this.entity.appId),l=await d.deService.getService(e,r),h=Z(e);h[this.entity.codeName.toLowerCase()]=t;const u=(await l.exec(c,h)).data||[];switch(i){case 1:for(let t=0;t<u.length;t++){const e=u[t];h[l.model.codeName.toLowerCase()]=e.srfkey;const a=await l.remove(h,e);if(!1===a.ok)throw new Error(a.statusText)}break;case 2:for(let t=0;t<u.length;t++){const e=u[t];h[l.model.codeName.toLowerCase()]=e.srfkey,e[n.parentAppDEFieldId.toLowerCase()]=void 0;const a=await l.updateTemp(h,e);if(!1===a.ok)throw new Error(a.statusText)}break;case 3:if(u.length>0){const t=u.map((t=>t.srfmajortext)).join("、"),e="无法删除[".concat(this.entity.logicName,"-").concat(s.srfmajortext,"], 数据被[").concat(l.model.logicName,"-").concat(t,"]引用");throw new Error(o||e)}}}}o&&n.state.isOpen&&n.commit()}catch(t){throw o&&n.state.isOpen&&n.rollback(),t}finally{o&&n.state.isOpen&&n.close()}}async updateTemp(t,e){try{const a=this.createEntity(e);let i;if(i=_(a)?await Promise.all(a.map((e=>this.service.local.update(t,this.attach(t,e))))):await this.service.local.update(t,this.attach(t,a)),i){const e=ibiz.uiDomainManager.get(t.srfsessionid);return e&&e.dataChange(),new p(i)}return new p(i,500)}catch(t){throw new s(t)}}async getTemp(t,e){try{let a=null;e&&(a=e[this.entity.keyAppDEFieldId.toLowerCase()]),!a&&t&&(a=t[this.entity.codeName.toLowerCase()]);const i=this.service.local.get(t,a);return i?new p(i):new p(i,500)}catch(t){throw new s(t)}}async removeBatchTemp(t,e){return new p(!0)}attach(t,e){const a=t.srfsessionid,i=ibiz.uiDomainManager.get(a).getDERConfig(this.entity.id);return i.length>0&&i.forEach((a=>{if(a.parentAppDEFieldId){const{majorAppDataEntityId:i,parentAppDEFieldId:s}=a,n=ve(i),o=s.toLowerCase(),r=t[n];r&&r!==e.srfkey&&(e[o]=r)}})),e}}),ao=class{create(t,e,a,i){return new eo(t,e,a,i.localMode)}},io=t("FetchMethod",class extends Tn{async exec(t,e,a,s){const n=e&&!_(e)?e:a||{};let o;if(this.isLocalMode){const e=Qs.getCond(this.method),a=new nn(t,n),i=await this.searchLocal(e,a);o=new p(i,200)}else{switch(this.method.dataSetType){case"INDEXDE":case"CODELIST":case"MULTIFORM":o=await this.fetchCodeListSet(t,n);break;case"REMOTE":{const i=this.calcPath(t);o=await this.request(i,t,e,a,s)}break;default:throw new i(this.method,"数据来源类型".concat(this.method.dataSetType,"暂未支持"))}const r=o.data||[];o.data=r.map((t=>this.createEntity(t)))}return o.data&&await to(this.entity,"compute",t,o.data,n),o}async searchLocal(t,e,a=this.entity.quickSearchAppDEFieldIds){let i=this.service.local.getList();t?i.length>0&&(i=i.filter((a=>t.test(a,e)))):i.length>0&&e.query&&""!==e.query&&a&&(i=i.filter((t=>{const i=new RegExp(e.query);for(let e=0;e<a.length;e+=1){const s=t[a[e]];if(i.test(s))return!0}return!1}))),Q(e.sortField)||J(e.sortField)||(i="DESC"===e.sortMode?ft(i,e.sortField):mt(i,e.sortField));const{page:s,size:n}=e,o=s*n,r=(s+1)*n-1;return i.slice(o,r).map((t=>Z(t)))}async fetchCodeListSet(t,e){const{appCodeListId:i}=this.method;if(!i)throw new a(this.method,"没有指定数据来源代码表");const s=await this.app.codeList.get(i,t,e),{keyAppDEFieldId:n,majorAppDEFieldId:o}=this.entity,r=s.map((t=>({[n]:t.value,[o]:t.text})));return new p(r,200)}}),so=t("AcFetchMethod",class extends io{mergeRequestPath(t,e){return"".concat(t,"/ac/").concat(e,"?srfac=ac")}}),no=class{create(t,e,a,i){return i.acMode?new so(t,e,a,i.localMode):new io(t,e,a,i.localMode)}};function oo(){const t=new ao;_s("DEACTION",(()=>t));const e=new no;_s("FETCH",(()=>e)),_s("FETCHTEMP",(()=>e))}var ro=t("InternalMessageService",class{constructor(){this.baseUrl="/extension/internal_messages"}async fetch(t={}){const e={page:0,size:20,sort:"update_time,desc"};Object.assign(e,t);const a=await ibiz.net.post("".concat(this.baseUrl,"/fetch_cur_receiver"),e);return a.headers&&(a.headers["x-page"]&&(a.page=Number(a.headers["x-page"])),a.headers["x-per-page"]&&(a.size=Number(a.headers["x-per-page"])),a.headers["x-total"]&&(a.total=Number(a.headers["x-total"]))),Q(a.data)&&(a.data=[]),a}async get(t){return await ibiz.net.get("".concat(this.baseUrl,"/").concat(t))}async markRead(t){await ibiz.net.post("".concat(this.baseUrl,"/").concat(t,"/mark_read"),{})}async batchMarkRead(){await ibiz.net.post("".concat(this.baseUrl,"/mark_all_read"),{})}async getUnreadNum(){const t=await ibiz.net.post("".concat(this.baseUrl,"/fetch_cur_receiver"),{page:0,size:1,sort:"update_time,desc",searchconds:[{condtype:"GROUP",condop:"AND",bnotmode:!1,searchconds:[{condop:"EQ",condtype:"DEFIELD",fieldname:"status",value:"RECEIVED"}]}]});return t.headers["x-total"]?Number(t.headers["x-total"]):0}}),co=t("MarkOpenDataService",class{constructor(){this.callbackMap=new Map,this.baseUrl="/portal/markopendata",ibiz.mc.command.markOpenData.on((t=>{const e=t.data,{entity:a,key:i}=e,s="".concat(a,"_").concat(i);this.callbackMap.has(s)&&this.callbackMap.get(s).forEach((t=>t(e)))}))}async action(t,e,a){return await ibiz.net.get("".concat(this.baseUrl,"/").concat(t,"/").concat(e,"/").concat(a))}async send(t,e,a,i){return await ibiz.net.post("".concat(this.baseUrl,"/").concat(t,"/").concat(e,"/").concat(a),i)}subscribe(t,e,a){const i="".concat(t,"_").concat(e),s=this.callbackMap.get(i)||[];s.push(a),this.callbackMap.set(i,s)}unsubscribe(t,e,a){const i="".concat(t,"_").concat(e),s=this.callbackMap.get(i)||[],n=s.indexOf(a);n>-1&&(s.splice(n,1),this.callbackMap.set(i,s))}}),lo=t("TreeNodeData",class{constructor(t,e,a){this._uuid=ct(),this._leaf=!1,this._leaf=!0===a.leaf,this._parent=e,this._nodeType=t.treeNodeType,this._disableSelect=!0===t.disableSelect,this._changedOnly=!0===t.enableRowEditChangedOnly,this._parent&&(this._context={...this._parent._context}),a.navContext&&(this._context=Object.assign(this._context||{},a.navContext)),a.navParams&&(this._params={...a.navParams}),this._nodeId=t.id,Object.defineProperty(this,"srfnodeid",{get(){return this._id},enumerable:!0,configurable:!0})}calcIcon(t){const{sysImage:e}=t,a={};return e&&(e.cssClass&&(a.cssClass=e.cssClass),e.imagePath&&(a.imagePath=e.imagePath),e.rawContent&&(a.htmlStr=e.rawContent)),Object.values(a).length>0?a:void 0}getDiffData(){if(this._deData&&this._oldDeData){const t={};return Object.keys(this._deData).forEach((e=>{this._deData[e]===this._oldDeData[e]&&e!==this._deData.srfkeyfield||(t[e]=this._deData[e])})),t.srfkey=this._deData.srfkey,t}return this._deData}}),ho=t("TreeCodeListNodeData",class extends lo{constructor(t,e,a){super(t,e,a);const{data:i}=a;this._text=i.text,this._value=i.value;const s="".concat(t.id,"@").concat(this._value).toLowerCase();if(Object.defineProperty(this,"_id",{get(){return this._parent?"".concat(this._parent._id,":").concat(s):s},enumerable:!0,configurable:!0}),t.appDataEntityId){const e=ve(t.appDataEntityId);this._context=Object.assign(this._context||{},{[e]:this._value})}this.srfkey=this._value,this.srfmajortext=this._text,this._icon=this.calcIcon(t)}}),uo=["_id","srfnodeid","_value","_text","_deData","clone"],po=t("TreeDataSetNodeData",class t extends lo{constructor(e,a,i){var s,n;super(e,a,i);const{data:o}=i;this._deData=o,this._oldDeData=o.clone();const r="".concat(e.id,"@").concat(o.srfkey).toLowerCase();if(Object.defineProperty(this,"_id",{get(){return this._parent?"".concat(this._parent._id,":").concat(r):r},enumerable:!0,configurable:!0}),Object.defineProperty(this,"_text",{get(){return e.textAppDEFieldId?this._deData[e.textAppDEFieldId]:this._deData.srfmajortext},set(t){e.textAppDEFieldId?this._deData[e.textAppDEFieldId]=t:this._deData.srfmajortext=t},enumerable:!0,configurable:!0}),Object.defineProperty(this,"_value",{get(){return e.idAppDEFieldId?this._deData[e.idAppDEFieldId]:this._deData.srfkey},set(t){e.idAppDEFieldId?this._deData[e.idAppDEFieldId]=t:this._deData.srfkey=t},enumerable:!0,configurable:!0}),e.appDataEntityId){const t=ve(e.appDataEntityId);this._context=Object.assign(this._context||{},{[t]:o.srfkey})}this._icon=this.calcIcon(e),this._textHtml=this.calcTextHtml(e),e.leafFlagAppDEFieldId?this._leaf=on(o[e.leafFlagAppDEFieldId]):e.childCntAppDEFieldId&&(this._leaf=!on(o[e.childCntAppDEFieldId]));const c=new Map,d=new Map;null==(s=e.detreeNodeDataItems)||s.forEach((t=>{if(!t.appDEFieldId)return;const e=t.id.toLowerCase(),a=t.appDEFieldId.toLowerCase();c.set(e,a),t.defaultValue&&d.set(e,t.defaultValue)}));const l=new Map;null==(n=e.detreeNodeColumns)||n.forEach((t=>{if("DEFGRIDCOLUMN"!==t.columnType)return;const e=t.detreeColumnId,a=t.dataItemName;e&&a?l.set(e,a):ibiz.log.error("模型异常缺少detreeColumnId或者dataItemName",t)}));const h=new Map;h.set("srfuf","srfuf");const u=t=>l.has(t)?c.get(l.get(t)):c.has(t)?c.get(t):Object.prototype.hasOwnProperty.call(this._deData,t)?t:h.has(t)?h.get(t):void 0;return this.clone=()=>{const a=Z(this._deData),i=new t(e,this._parent,{data:a,leaf:this._leaf,navContext:this._context,navParams:this._params});return Object.keys(this).forEach((t=>{const e=u(t);Q(e)&&!uo.includes(t)&&(i[t]=this[t])})),i},new Proxy(this,{set(t,e,a){const i=u(e);return Q(i)?t[e]=a:t._deData[i]=a,!0},get(t,e,a){const i=u(e);return Q(i)?t[e]:Q(t._deData[i])?(s=e,l.has(s)?d.get(l.get(s)):d.has(s)?d.get(s):void 0):t._deData[i];var s},ownKeys(t){const e=[...new Set([...Object.keys(t),...c.keys(),...Object.keys(t._deData)])];return m(t,e),e}})}calcIcon(t){const e=super.calcIcon(t)||{},{iconAppDEFieldId:a,detreeNodeDataItems:i}=t;a&&this._deData[a]&&(e.imagePath=this._deData[a]),e&&(this._icon=e);const s=null==i?void 0:i.find((t=>"icon"===t.id));return s&&(e.htmlStr=this.calcDataItemScript(s)),Object.values(e).length>0?e:void 0}calcDataItemScript(t){if(t.customCode&&t.scriptCode)return Qe.execScriptFn({data:this._deData},t.scriptCode,{isAsync:!1})}calcTextHtml(t){let e;const{detreeNodeDataItems:a}=t,i=null==a?void 0:a.find((t=>"text"===t.id));return i&&(e=this.calcDataItemScript(i)),e}}),mo=t("TreeStaticNodeData",class extends lo{constructor(t,e,a){var i,s;super(t,e,a);const n="root"===t.nodeValue?void 0:t.nodeValue,o="".concat(t.id).toLowerCase();if(Object.defineProperty(this,"_id",{get(){return this._parent?"".concat(this._parent._id,":").concat(o):o},enumerable:!0,configurable:!0}),this._text=t.text,this._value=n,e&&a.parentValueLevel){let t=e;for(let e=1;e<a.parentValueLevel;e++)t=null==t?void 0:t._parent;(null==t?void 0:t._deData)&&(this._deData=t._deData),this._value=n||(null==t?void 0:t._value)}this.srfkey=(null==(i=this._deData)?void 0:i.srfkey)||this._value,this.srfmajortext=(null==(s=this._deData)?void 0:s.srfmajortext)||this._text,this._icon=this.calcIcon(t)}}),fo=t("UIMapField",class{constructor(t,e,a={}){this.isOriginField=!1,this.isRequestNeed=!0,this.uiKey=t,this.dataKey=e,Q(a.isOriginField)||(this.isOriginField=a.isOriginField),Q(a.dataType)||(this.dataType=a.dataType)}convertVal(t){if(!this.dataType)return t;if(l.isNumber(this.dataType)){const e=Q(t)||""===t?t:Number(t);return Number.isNaN(e)?(ibiz.log.debug("".concat(t,"不能转换成数字")),t):e}return t}}),go=t("CalendarItemData",class{constructor(t,e){this.model=t,this.data=e}get deData(){return this.data}get navId(){return"".concat(this.itemType,"@").concat(this.id)}get itemType(){return this.model.itemType}get bkColor(){const t=this.model.bkcolorAppDEFieldId;return t&&this.data[t]?this.data[t]:this.model.bkcolor}get beginTime(){const t=this.model.beginTimeAppDEFieldId;return t?this.data[t]:void 0}get color(){const t=this.model.colorAppDEFieldId;return t&&this.data[t]?this.data[t]:this.model.color}get content(){const t=this.model.contentAppDEFieldId;return t?this.data[t]:void 0}get endTime(){const t=this.model.endTimeAppDEFieldId;return t?this.data[t]:void 0}get icon(){const t=this.model.iconAppDEFieldId;return t?this.data[t]:void 0}get id(){const t=this.model.idAppDEFieldId;return t&&this.data[t]?this.data[t]:this.data.srfkey}get level(){const t=this.model.levelAppDEFieldId;return t?this.data[t]:void 0}get tag2(){const t=this.model.tag2AppDEFieldId;return t?this.data[t]:void 0}get tag(){const t=this.model.tagAppDEFieldId;return t?this.data[t]:void 0}get text(){const t=this.model.textAppDEFieldId;return t?this.data[t]:void 0}get tips(){const t=this.model.tipsAppDEFieldId;return t?this.data[t]:void 0}});var wo=["REGION","REGION2","REGION3","REGION4"],Eo=t("MapData",class{constructor(t,e){this._longitude=void 0,this._latitude=void 0,this._areaCode=void 0,this._tooltip=void 0,this._value=void 0,this._text=void 0,this._symbol=void 0;const{id:a,itemStyle:i,longitudeAppDEFieldId:s,latitudeAppDEFieldId:n,textAppDEFieldId:o,dataAppDEFieldId:r,tipsAppDEFieldId:c,sysImage:d}=e,l=new Map;return this._id=a+t.srfkey,this._itemStyle=i,this._mapItemId=a,wo.includes(this._itemStyle)?s&&l.set("_areaCode",s):(s&&l.set("_longitude",s),n&&l.set("_latitude",n)),c&&l.set("_tooltip",c),o&&l.set("_text",o),r&&l.set("_value",r),d&&(this._symbol=d.rawContent||d.imagePath),new Proxy(this,{set:(e,a,i)=>(Object.prototype.hasOwnProperty.call(t,a)?t[a]=i:l.has(a)?t[l.get(a)]=i:e[a]=i,!0),get:(e,a,i)=>void 0!==e[a]?e[a]:l.has(a)?t[l.get(a)]:void 0!==t[a]?t[a]:void 0,ownKeys(e){const a=[...new Set([...Object.keys(e),...Object.keys(t)])];return function(t,e){e.forEach((e=>{Object.prototype.hasOwnProperty.call(t,e)||Object.defineProperty(t,e,{enumerable:!0,configurable:!0,writable:!0,value:void 0})}))}(e,a),a}})}});var yo=t("PanelData",class{constructor(t,e){const a=new dt,i={},s={};return t.forEach((t=>{var e;i[t.id]=null==(e=t.viewFieldName)?void 0:e.toLowerCase(),t.viewFieldName&&(s[t.viewFieldName.toLowerCase()]=t.id)})),new Proxy(this,{set:(t,n,o)=>(Object.prototype.hasOwnProperty.call(i,n)?i[n]?e[i[n]]=o:t[n]=o:e[n]=o,a.emit("change",n),i[n]&&i[n]!==n&&a.emit("change",i[n]),s[n]&&s[n]!==n&&a.emit("change",s[n]),!0),get:(t,s,n)=>"_evt"===s?a:i[s]?e[i[s]]:Object.prototype.hasOwnProperty.call(e,s)?e[s]:t[s],ownKeys(t){const a=Object.keys(e);return function(t,e){e.forEach((e=>{Object.prototype.hasOwnProperty.call(t,e)||Object.defineProperty(t,e,{enumerable:!0,configurable:!0,writable:!0,value:void 0})}))}(t,a),a}})}destroy(){this._evt.reset()}});var vo=t("ChartData",class{constructor(t,e,a,i){return this._seriesModelId=null==e?void 0:e.id,this._catalog=a,this._groupName=i,this._uuid=ct(),new Proxy(this,{set:(e,a,i)=>(Object.prototype.hasOwnProperty.call(t,a)?t[a]=i:e[a]=i,!0),get:(e,a,i)=>void 0!==e[a]?e[a]:void 0!==t[a]?t[a]:void 0,ownKeys(e){const a=[...new Set([...Object.keys(e),...Object.keys(t)])];return function(t,e){e.forEach((e=>{Object.prototype.hasOwnProperty.call(t,e)||Object.defineProperty(t,e,{enumerable:!0,configurable:!0,writable:!0,value:void 0})}))}(e,a),a}})}}),Io=(t,e,a={})=>{let i="";if(!t||!e.detreeNodeDataItems)return i;const s=e.detreeNodeDataItems.find((e=>e.detreeColumnId===t));return s&&s.appDEFieldId&&(i=a[s.appDEFieldId.toLowerCase()]),i},Do=t("GanttStaticNodeData",class extends mo{constructor(t,e,a,i){super(e,a,i),this._snDataItemValue=Io(t.sndataItemName,e),this._beginDataItemValue=Io(t.beginDataItemName,e),this._endDataItemValue=Io(t.endDataItemName,e),this._prevDataItemValue=Io(t.prevDataItemName,e),this._finishDataItemValue=Io(t.finishDataItemName,e),this._totalDataItemValue=Io(t.totalDataItemName,e)}}),Co=t("GanttDataSetNodeData",class extends po{constructor(t,e,a,i){super(e,a,i);const{data:s}=i;this._snDataItemValue=Io(t.sndataItemName,e,s),this._beginDataItemValue=Io(t.beginDataItemName,e,s),this._endDataItemValue=Io(t.endDataItemName,e,s),this._prevDataItemValue=Io(t.prevDataItemName,e,s),this._finishDataItemValue=Io(t.finishDataItemName,e,s),this._totalDataItemValue=Io(t.totalDataItemName,e,s)}}),bo=t("GanttCodeListNodeData",class extends ho{constructor(t,e,a,i){super(e,a,i);const{data:s}=i;this._snDataItemValue=Io(t.sndataItemName,e,s),this._beginDataItemValue=Io(t.beginDataItemName,e,s),this._endDataItemValue=Io(t.endDataItemName,e,s),this._prevDataItemValue=Io(t.prevDataItemName,e,s),this._finishDataItemValue=Io(t.finishDataItemName,e,s),this._totalDataItemValue=Io(t.totalDataItemName,e,s)}}),Ao=t("MqttService",class{constructor(t,e,a){this.mqttTopic=t,this.token=e,this.appId=a,this.evt=new dt,this.options={connectTimeout:6e3,clientId:ct(),username:"",password:"",keepalive:60,clean:!0},this.options.username=t,this.options.password=e}async connect(){const t=await e.import("mqtt/dist/mqtt.min"),a=t.default?t.default:t,{location:i}=window;this.client=a.connect("ws://".concat(i.host).concat(ibiz.env.baseUrl,"/").concat(this.appId).concat(ibiz.env.mqttUrl),this.options),this.client.on("connect",(()=>{this.client.subscribe(this.mqttTopic),ibiz.log.debug("mqtt connect")})),this.client.on("error",(t=>{ibiz.log.error("mqtt error",t)})),this.client.on("message",((t,e)=>{this.evt.emit("message",JSON.parse(e.toString())),ibiz.log.debug("mqtt message",t,e.toString())})),this.client.on("reconnect",(()=>{ibiz.log.warn("mqtt reconnect")})),this.client.on("close",(()=>{ibiz.log.warn("mqtt close")}))}close(){var t;null==(t=this.client)||t.end(),this.evt.reset()}}),Po=class t{constructor(t){this.appModel=t,this.cache=new Map}static register(t,e){this.constructorCache.set(t.toUpperCase(),e)}async getService(e,a){const i=e.srfsessionid||"applocation";this.cache.has(i)||this.cache.set(i,new Map);const s=this.cache.get(i);if(!s.has(a)){const e=await ibiz.hub.getAppDataEntity(a,this.appModel.appId);if(!e)throw new o("未找到应用实体[".concat(a,"]"));const n=t.constructorCache.get(a.toUpperCase());let r;r=n?await n(i,e):new gn(i,e),s.set(a,r)}return s.get(a)}reset(t){const e=t.srfsessionid;if(!this.cache.has(e))return;this.cache.get(e).forEach((t=>{t.destroy()})),this.cache.delete(e)}clearTempCache(t){const e=t.srfsessionid;if(!this.cache.has(e))return;this.cache.get(e).forEach((t=>{t.local.clear()}))}clearTempCacheByRs(t,e,a=[]){if(!0===a.includes(e))return;a.push(e);const i=t.srfsessionid;if(!this.cache.has(i))return;const s=this.cache.get(i).get(e);s&&s.local.clear();const n=ibiz.uiDomainManager.get(t.srfsessionid);if(n){n.getDERConfigByMajor(e).forEach((e=>{this.clearTempCacheByRs(t,e.minorAppDataEntityId,a)}))}}async exec(t,e,a,i,s,n){return(await this.getService(a,t)).exec(e,a,i,s,n)}};Po.constructorCache=new Map;var To=t("DEServiceUtil",Po),xo=class t{constructor(){ibiz.commands.register(t.TAG,this.exec.bind(this))}async exec(t,e,a={},s={}){const n=Z(e);n.srfsimple&&delete n.srfsimple;const r=await ibiz.hub.config.view.get(t);if(!r)throw new o("应用视图[".concat(t,"]不存在"));if((n.srfkey||0===a.srfuf)&&r.appDataEntityId){const t=ve(r.appDataEntityId);n.srfkey&&(n[t]=n.srfkey,n.srfkey=void 0),0===a.srfuf&&(n[t]=void 0,delete a.srfuf)}if(r.redirectView){return We(await ibiz.hub.getAppView(t),n,a,s)}const{openMode:c="INDEXVIEWTAB"}=r,d=s.openMode||c;switch(void 0!==d&&"INDEXVIEWTAB"!==d&&n.toRouteDepth&&(n.toRouteDepth=void 0),d){case"INDEXVIEWTAB":case"INDEXVIEWTAB_POPUP":return s.noWaitRoute?(this.openIndexViewTab(r,n,a),{ok:!0}):this.openIndexViewTab(r,n,a,s);case"INDEXVIEWTAB_POPUPMODAL":return this.openIndexViewTabByModal(r,n,a);case"POPUP":throw new i(r,"未支持的视图打开模式: POPUP");case"POPUPMODAL":return this.openModal(r,n,a);case"POPUPAPP":throw new i(r,"未支持的视图打开模式: POPUPAPP");case"POPOVER":return this.openPopover(r,n,a,s);case"DRAWER_LEFT":case"DRAWER_RIGHT":case"DRAWER_TOP":case"DRAWER_BOTTOM":return this.openDrawer(r,n,a);case"USER":return this.openUserCustom(r,n,a);default:return this.openIndexViewTab(r,n,a)}}openIndexViewTab(t,e,a={},i={}){return ibiz.openView.root(t.id,e,a,i)}openIndexViewTabByModal(t,e,a={}){return ibiz.openView.rootByModal(t.id,e,a)}async openModal(t,e,a={}){return ibiz.openView.modal(t.id,e,a)}async openPopover(t,e,a={},i={}){const{event:s,modalOption:n}=i;if(!s)throw new o("气泡打开缺少event");return ibiz.openView.popover(t.id,s,e,a,{...n})}async openDrawer(t,e,a={}){return ibiz.openView.drawer(t.id,e,a)}async openUserCustom(t,e,a={}){return ibiz.openView.custom(t.id,e,a)}};xo.TAG="ibiz.app-view.open";var No=t("OpenAppViewCommand",xo),So=class t{constructor(){ibiz.commands.register(t.TAG,this.exec.bind(this))}async exec(t,e,a={},s={}){const n=(await ibiz.hub.getAppAsync(e.srfappid)).getAppFunc(t);if(!n)throw new o("找不到叫".concat(t,"的应用功能"));const{navigateContexts:r,navigateParams:c,appFuncType:d}=n,l=e.clone();Object.assign(l,oe(r,a,e));const h=oe(c,a,e);switch(Object.assign(h,a),d){case"APPVIEW":return this.openAppView(n,l,h,s);case"OPENHTMLPAGE":return this.openHtmlPage(n);case"PDTAPPFUNC":return this.openPdAppFunc(n,l,h);case"JAVASCRIPT":return this.executeJavaScript(n,l,h);case"CUSTOM":return this.custom(n,l,h);default:throw new i(n,"未支持的应用功能类型: ".concat(d))}}async openAppView(t,e,a,i){if(!t.appViewId)throw new o("应用视图[".concat(t.appViewId,"]不存在"));return ibiz.commands.execute(No.TAG,t.appViewId,e,a,i)}openHtmlPage(t){const e=t.htmlPageUrl;window.open(e,"_blank")}openPdAppFunc(t,e,a){throw ibiz.log.warn("openPdAppFunc",t,e,a),new o("未实现")}executeJavaScript(t,e,a){throw ibiz.log.warn("executeJavaScript",t,e,a),new o("未实现")}custom(t,e,a){throw ibiz.log.warn("custom",t,e,a),new o("未实现")}};So.TAG="ibiz.app-func.exec";var Ro=t("AppFuncCommand",So);function Mo(){new Ro,new No}var Oo=t("Application",class{constructor(t){this.model=t,this.deName2DeCodeName=new Map,this.net=new f({baseURL:"".concat(ibiz.env.baseUrl,"/").concat(this.appId)}),this.configCache=new dn(this.appId,"PSSysApp",t.codeName),this.deService=new To(t),this.codeList=new cn(t),this.authority=new Dn(t)}get appId(){return this.model.appId||ibiz.env.appId}async init(){await this.authority.init(),await this.loadAppModelStyle(),await this.initMqtt()}async loadAppModelStyle(){const t=await ibiz.hub.getAppStyle(this.appId);if(t){const e=document.createElement("style");e.setAttribute("type","text/css"),e.id=this.appId,e.innerHTML=t,document.head.appendChild(e)}}getAppFunc(t){return(this.model.appFuncs||[]).find((e=>e.id===t))||null}async getUIAction(t){const[,e]=t.split("@");if(e){const a=(await ibiz.hub.getAppDataEntity(e,this.appId)).appDEUIActions.find((e=>e.id===t));if(a)return a}return this.model.appDEUIActions.find((e=>e.id===t))}async getOPPriv(t,e){var a,i;let s=null==(a=this.model.deopprivs)?void 0:a.find((e=>e.name===t));if(!s&&e){s=null==(i=(await ibiz.hub.getAppDataEntity(e,this.appId)).deopprivs)?void 0:i.find((e=>e.name===t))}return s}async getDEUILogic(t,e){return(await ibiz.hub.getAppDataEntity(e,this.appId)).appDEUILogics.find((e=>e.id===t))}async initMqtt(){this.mqtt&&this.mqtt.close(),ibiz.env.enableMqtt&&ibiz.appData&&ibiz.appData.mqtttopic&&!0!==ibiz.auth.isAnonymous&&(this.mqtt=new Ao(ibiz.appData.mqtttopic,g(),this.appId),this.mqtt.evt.on("message",(t=>{ibiz.mc.command.next(t)})),await this.mqtt.connect())}destroy(){this.codeList.destroy()}}),Lo=class{parse(t){return t}},_o=class{constructor(){this.appMenu=new Lo}},Fo=class{constructor(){this.viewConfigs=new Map}calcAppViewId(t){let e="";if(-1!==t.indexOf(".")){const a=t.split(".");e=a[a.length-1]}else e=t.toLowerCase();return e}getCustomOption(t){var e;const{appViewParams:a,userParam:i}=t;let s=null==(e=null==a?void 0:a.find((t=>"modaloption"===t.id)))?void 0:e.value;!s&&i&&(s=i.modalOption);let n={};if(s)try{n=JSON.parse(s)}catch(t){ibiz.log.error("视图参数modalOption 解析失败:".concat(t))}return{modalOption:n}}has(t){const e=this.calcAppViewId(t);return this.viewConfigs.has(e)}set(t,e){const a=this.calcAppViewId(t);this.viewConfigs.set(a,e)}async get(t){const e=this.calcAppViewId(t);if(!this.viewConfigs.has(e)){const t=await ibiz.hub.getAppView(e);if(!t)throw new o("视图[".concat(e,"]不存在"));this.set(t.id,{id:t.id,appId:t.appId,codeName:t.codeName,openMode:t.openMode,viewType:t.viewType,width:t.width,height:t.height,appDataEntityId:t.appDataEntityId,redirectView:t.redirectView,...this.getCustomOption(t)})}return this.viewConfigs.get(e)}getSync(t){return this.viewConfigs.has(t)?this.viewConfigs.get(t):null}},Vo=class{constructor(){this.view=new Fo}},ko=t("FormNotifyState",(t=>(t.LOAD="LOAD",t.DRAFT="DRAFT",t.SAVE="SAVE",t))(ko||{})),zo=t("GridNotifyState",(t=>(t.LOAD="LOAD",t.DRAFT="DRAFT",t.SAVE="SAVE",t))(zo||{})),Wo=t("PanelNotifyState",(t=>(t.LOAD="LOAD",t.DRAFT="DRAFT",t.SAVE="SAVE",t))(Wo||{})),Uo=t("TreeGridExNotifyState",(t=>(t.LOAD="LOAD",t.SAVE="SAVE",t.DRAFT="DRAFT",t))(Uo||{})),Bo=t("Counter",class{constructor(t){this.callback=t,this.count=0,this.state="Unused",this.reusable=!0}increment(){return"Used"===this.state||(this.count+=1),this.count}decrement(t){if("Used"!==this.state){if(0===this.count)throw new o("错误的调用!decrement不能对count为0调用");this.count-=1,0===this.count&&(t?t():this.callback&&this.callback(),this.reusable||(this.state="Used"))}}destroy(){this.callback=void 0}}),Go=t("LoadingState",class{constructor(){this.isLoading=!1,this.counter=new Bo(w)}begin(){this.isLoading=!0,this.counter.increment()}end(){this.counter.decrement((()=>{this.isLoading=!1}))}}),jo=t("CTXState",class{}),Ko=t("CTX",class{constructor(t){this.parent=t,this.isDestroyed=!1,this.evt=new dt(3e3),this.controllersMap=new Map,this.state=new jo}async init(t){this.view=t,this.registerController(t.model.name,t)}destroy(){this.controllersMap.clear(),this.view=null,this.state=null,this.isDestroyed=!0}async setState(t){Object.assign(this.state,t)}startLoading(){this.view.startLoading()}endLoading(){this.isDestroyed||this.view.endLoading()}registerController(t,e){this.controllersMap.set(t,e),this.evt.emit("onRegister",t,e)}getController(t,e=!1){return this.controllersMap.has(t)?this.controllersMap.get(t):this.parent&&e?this.parent.getController(t):void 0}getTopView(){return this.parent?2===this.view.modal.routeDepth?this.view:this.parent.getTopView():this.view}}),Xo=t("ActivityCounter",class extends Bo{constructor(){super(...arguments),this.reusable=!1,this.registration=new Map}enroll(t){"Unused"!==this.state||this.registration.has(t)||(this.registration.set(t,!1),this.increment())}attend(t){this.registration.has(t)&&!1===this.registration.get(t)&&(this.registration.set(t,!0),this.decrement())}}),Ho=t("UIActionButtonState",class{constructor(t,e,a){this.disabled=!1,this.visible=!0,this.loading=!1,this.permitted=!0,this.noPermissionHidden=!0,this.noDataDisabled=!1,this.noKeyDisabled=!1,this.isInit=!1,this.name=t,this.uiActionId=a,this.appId=e}async init(){if(!this.uiActionId)return void(this.isInit=!0);const t=await Ae(this.uiActionId,this.appId);if([,this.appDeName]=this.uiActionId.split("@"),!t)return;const{dataAccessAction:e,noPrivDisplayMode:a,actionTarget:i,uiactionMode:s,uiactionTag:n}=t;this.dataAccessAction=e,1===a?this.noPermissionHidden=!1:6===a&&(this.visible=!1),[2,6].includes(a)&&this.dataAccessAction&&(this.visible=!1),(i&&"NONE"!==i||"SYS"===s&&["Save","SaveAndExit","SaveAndNew","Edit","Remove","RemoveAndExit"].includes(n))&&(this.noDataDisabled=!0,"SINGLEKEY"!==i&&"MULTIKEY"!==i||(this.noKeyDisabled=!0)),this.isInit=!0}async calcPermission(t,e,a){if(!this.dataAccessAction)return;const i=await ibiz.hub.getApp(this.appId);this.appDeName&&a&&!a.includes(this.appDeName)&&ibiz.log.warn("".concat(this.uiActionId,"界面行为的实体").concat(this.appDeName,"和数据的实体").concat(a,"不一致")),this.permitted=await i.authority.calcByDataAccessAction(this.dataAccessAction,t,e,a)}async update(t,e,a){this.isInit||await this.init(),await this.calcPermission(t,e,a),this.permitted?(this.visible=!0,this.disabled=this.noDataDisabled&&(!e||this.noKeyDisabled&&!e.srfkey)):(this.disabled=!0,this.visible=!this.noPermissionHidden)}}),qo=t("ButtonContainerState",class{constructor(){Object.defineProperty(this,"children",{enumerable:!1,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"visible",{enumerable:!0,configurable:!0,get:()=>0!==this.children.length&&!!this.children.find((t=>t.visible))})}addState(t,e){Object.defineProperty(this,t,{enumerable:!0,configurable:!0,writable:!0,value:e}),this.children.push(e)}setLoading(t){this.children.forEach((e=>{e.setLoading?e.setLoading(t):e.loading=!!t&&e.name===t}))}async update(t,e,a){await Promise.all(this.children.map((i=>i.update(t,e,a))))}async init(){await Promise.all(this.children.map((t=>t.init())))}}),Yo=t("QXEventEx",class extends dt{constructor(){super(...arguments),this.anyEventFns=[]}onAll(t){this.anyEventFns.includes(t)||this.anyEventFns.push(t)}emit(t,...e){super.emit(t,...e),this.anyEventFns.forEach((a=>{a(t,...e)}))}async asyncEmit(t,...e){const a=super.asyncEmit(t,...e),i=this.anyEventFns.map((a=>a(t,...e))),s=Promise.all(i),n=await a,o=await s;return n.concat(...o)}reset(){super.reset(),gt(this.anyEventFns)}}),Qo=t("ControllerEvent",class{constructor(t){this.getBaseArgs=t,this.isDestroyed=!1,this.evt=new Yo}async emit(t,e){this.isDestroyed||await this.evt.asyncEmit(t,{...this.getBaseArgs(),eventName:t,...e||{}})}on(t,e){this.isDestroyed||this.evt.on(t,e)}off(t,e){this.isDestroyed||this.evt.off(t,e)}onAll(t){this.isDestroyed||this.evt.onAll(t)}destroy(){this.getBaseArgs=void 0,this.evt.reset(),this.isDestroyed=!0}});function $o(t){return window.location.hash.split("/").length>2*t+2}function Jo(t,e){return(!Q(t)&&""!==t||!Q(e)&&""!==e)&&t!==e}function Zo(t){let e=Array.isArray(t)?t[0]:t;return e&&e instanceof En&&(e=e.getOrigin()),e}function tr(t,e,a){const i=[];return t.forEach((t=>{const{valueRuleType:s}=t,n=t.sysValueRule,r=t.defvalueRule;if("SYSVALUERULE"===s&&n)"REG"===n.ruleType||"REGEX"===n.ruleType?i.push({pattern:new RegExp(n.regExCode),message:n.ruleInfo,trigger:"change blur"}):"SCRIPT"===n.ruleType&&i.push({validator:(t,e,a,i)=>{if(!e)return!0;try{Qe.execScriptFn({rule:t,value:e,callback:a,source:i},n.scriptCode,{isAsync:!1})}catch(t){return console.error(t),!1}return!0},trigger:"change blur"});else if("DEFVALUERULE"===s&&r){const t=a||e;i.push({validator:(e,a,i,s)=>{if(ot(s[t]))return!0;const{isPast:n,infoMessage:c}=$e(t,s,r.groupCond);return n||i(new o(c||r.ruleInfo)),!0},trigger:"change blur"})}})),i}function er(t){const e=[],{maxLength:a,minLength:i}=t,{maxValue:s,minValue:n}=t;return a&&e.push({validator:(t,e,i)=>{if(Q(e)||!(e.length>a))return!0;i(new Error("内容长度必须小于等于".concat(a,",当前长度为").concat(e.length)))}}),i&&e.push({validator:(t,e,a)=>{if(Q(e)||!(e.length<i))return!0;a(new Error("内容长度必须大于等于".concat(i,",当前长度为").concat(e.length)))}}),Q(s)||e.push({validator:(t,e,a)=>{if(!(!Q(e)&&wt(e)&&e>s))return!0;a(new Error("值必须小于等于".concat(s)))}}),Q(n)||e.push({validator:(t,e,a)=>{if(!(!Q(e)&&wt(e)&&e<n))return!0;a(new Error("值必须大于等于".concat(n)))}}),e}var ar=t("ValueExUtil",class{static mergeDefault(t){return at(t,{textSeparator:",",valueSeparator:","})}static toText(t,e){if(Q(e)||""===e)return"";const{valueType:a,objectNameField:i,textSeparator:s}=this.mergeDefault(t);if(["OBJECTS","OBJECT"].includes(a)){if(!i)throw new o("缺少objectNameField");const t=i.toLowerCase();return"OBJECTS"===a?e.map((e=>e[t]||"---")).join(s):e[t]}return"SIMPLES"===a?e.join(s):"".concat(e)}});function ir(t,e){var a;const{name:s,valueType:n,defaultValue:r,valueFormat:c}=t,{data:d,context:l,params:h}=e;if(Q(n)&&Q(r))return;if("RESET"===n)return null;const u=d[s];if(!it(u)){if(!n&&r)return r;switch(n){case"APPDATA":if(Object.prototype.hasOwnProperty.call(h,r))return h[r];if(Object.prototype.hasOwnProperty.call(l,r))return l[r];break;case"OPERATORNAME":return l.srfusername;case"OPERATOR":return l.srfuserid;case"CURTIME":return yt().format(c);case"PARAM":return d[r];case"SESSION":case"APPLICATION":if(!(null==(a=ibiz.appData)?void 0:a.context))throw new o("appdata.context不存在");return ibiz.appData.context[r];case"CONTEXT":return h[r];case"UNIQUEID":return ct();default:throw new i({},"默认值类型[".concat(n,"]未支持"))}}}var sr="asyncimportdata2",nr="importdata2";async function or(t,e,a,i){ibiz.notification.info({desc:ibiz.i18n.t("component.dataImport.startImport")});const s=new FormData;s.append("file",t);let n="/".concat(e.deapicodeName2,"/").concat(sr);if((null==a?void 0:a.codeName)&&(n+="?srfimporttag=".concat(a.codeName)),i){n=sn(i,e)+n}const o=await ibiz.net.request(n,{method:"post",data:s,headers:{"Content-Type":"multipart/form-data"}});var r;await(r=o.data.asyncacitonid,new Promise((t=>{const e=a=>{const i=a.messageid||a.data.asyncacitonid;if(r!==i)return;const s=a.data.actionstate;30!==s&&40!==s||(t(),ibiz.mc.command.asyncAction.off(e))};ibiz.mc.command.asyncAction.on(e)}))),ibiz.mc.command.send({srfdecodename:e.codeName},"OBJECTCREATED","DATAIMPORT")}async function rr(t,e,a,i){const s=new FormData;s.append("file",t);let n="/".concat(e.deapicodeName2,"/").concat(nr);if((null==a?void 0:a.codeName)&&(n+="?srfimporttag=".concat(a.codeName)),i){n=sn(i,e)+n}const o={isAsync:!1};try{const t=await ibiz.net.request(n,{method:"post",data:s,headers:{"Content-Type":"multipart/form-data"}});ibiz.mc.command.send({srfdecodename:e.codeName},"OBJECTCREATED","DATAIMPORT"),Object.assign(o,t.data)}catch(t){t instanceof Error&&(o.errorMessage=t.message)}return o}async function cr(t){const e={isAsync:ibiz.env.enableMqtt};if(ibiz.env.enableMqtt)or(t.selectedFile,t.appDataEntity,t.dataImport,t.context);else{const a=await rr(t.selectedFile,t.appDataEntity,t.dataImport,t.context);Object.assign(e,a)}return e}async function dr(t,e,a){if(!ibiz.util.getExcelUtil)throw new o("ibiz.util.getExportExcel不存在");const i=await ibiz.util.getExcelUtil();if(!i)throw new o("导出模块加载错误");try{return i.exportJsonToExcel({header:t,data:e,filename:a,autoWidth:!0}),{ok:!0}}catch(t){return{ok:!1}}}async function lr(t){var e;const a=await ibiz.hub.getAppDataEntity(t.appDataEntityId,t.appId),i=null==(e=a.appDEDataImports)?void 0:e.find((e=>e.id===t.deDataImportId));if(!i)throw new o("没有找到对应的导入数据模型");return{deDataImport:i,appDataEntity:a}}async function hr(t){const{deDataImportId:e,appDataEntityId:a,context:i,params:s}=t,n=t.dataImportViewId||"AppDataUploadView";let o=null;try{o=await ibiz.hub.config.view.get(n)}catch(e){if(t.dataImportViewId)throw e}if(o)return i.srfappdataentityid=a,i.srfdedataimportid=e,ibiz.commands.execute(No.TAG,o.id,i,s,{openMode:"POPUPMODAL"});const{deDataImport:r,appDataEntity:c}=await lr({deDataImportId:e,appDataEntityId:a,appId:i.srfappid}),d=r.enableCustomized?"DataImport2":"DataImport",l=ibiz.overlay.createModal(d,{dismiss:()=>l.dismiss(),dataImport:r,appDataEntity:c,context:i,params:s},{width:"auto",placement:"center"});l.present(),await l.onWillDismiss()}async function ur(t,e){var a;let i="".concat(t.codeName2.toLowerCase(),"/importtemplate");(null==e?void 0:e.codeName)&&(i+="?srfimporttag=".concat(e.codeName));const s=await ibiz.net.request(i,{responseType:"blob"});if(200===s.status){let t=(null==(a=s.headers["content-disposition"].split(";").find((t=>-1!==t.indexOf("filename="))))?void 0:a.slice(9))||"";t=decodeURIComponent(t);const e=new Blob([s.data],{type:"application/vnd.ms-excel"}),i=document.createElement("a");i.download=t,i.style.display="none",i.href=URL.createObjectURL(e),document.body.appendChild(i),i.click(),URL.revokeObjectURL(i.href),document.body.removeChild(i)}}async function pr(t){return new Promise((e=>{E({accept:".xlsx, .xls",multiple:!1,onSelected:async a=>{const i=await cr({selectedFile:a[0],appDataEntity:t.appDataEntity,dataImport:t.dataImport,context:t.context});e(i)},onCancel:()=>{e({cancel:!0})}})}))}async function mr(t,e){const a=ibiz.hub.getApp(e.srfappid),i=await ibiz.hub.getAppDataEntity(t,e.srfappid);let s="/jsonschema/".concat(i.name);0===i.dynaSysMode&&ibiz.appData&&(s+="?dynamodeltag=".concat(ibiz.appData.dynamodeltag));return(await a.net.get(s)).data}var fr="__self",gr=t("BaseController",class{constructor(t,e,a,i){this.model=t,this.params=a,this.ctx=i,this.id=ct(),this.state={},this.name="",this.evt=new Qo(this.getEventArgs.bind(this)),this.mountCounter=new Xo(this.mounted.bind(this)),this.childNames=[],this.name=t.name||t.id,this.state.context=e,this.preprocessModel(t),this.initState(),this.convertMultipleLanguages()}get _evt(){return this.evt}get context(){return this.state.context}preprocessModel(t){}initState(){this.state.isCreated=!1,this.state.isMounted=!1,this.state.isDestroyed=!1}getEventArgs(){return{context:this.context,params:this.params,data:[],targetName:this.model.name,view:this.ctx.view}}async created(){this.mountCounter.enroll(fr),await this.onCreated(),this.state.isCreated=!0,this.force((()=>{this.mountSelf()})),ibiz.log.debug("".concat(this.constructor.name,":").concat(this.name," onCreated")),this._evt.emit("onCreated",void 0)}async onCreated(){this.ctx.evt.on("onForecast",(t=>{this.childNames.includes(t)&&this.mountCounter.enroll(t)})),this.ctx.evt.on("onRegister",((t,e)=>{this.childNames.includes(t)&&e.evt.on("onMounted",(()=>{this.mountCounter.attend(t)}))}))}async mountSelf(){this.mountCounter.registration.get(fr)||this.mountCounter.attend(fr)}async mounted(){await this.onMounted(),this.state.isMounted=!0,ibiz.log.debug("".concat(this.constructor.name,":").concat(this.name," onMounted")),this._evt.emit("onMounted",void 0)}async onMounted(){}async destroyed(){await this.onDestroyed(),this.state.isDestroyed=!0,ibiz.log.debug("".concat(this.constructor.name,":").concat(this.name," onDestroyed")),await this._evt.emit("onDestroyed",void 0),this.evt.destroy()}async onDestroyed(){}force(t){}getController(t,e=!1){return this.ctx.getController(t,e)}getTopView(){return this.ctx.getTopView()}listenNewController(t){this.ctx.evt.on("onRegister",t)}convertMultipleLanguages(){}}),wr=class t{constructor(t){this.msgGroupId=t,this.viewMsgMap=new Map}async init(t){var e,a;const i=ibiz.hub.getApp(t.srfappid).model,s=null==(e=i.appViewMsgGroups)?void 0:e.find((t=>t.id===this.msgGroupId));if(!s)throw new o("找不到视图消息组".concat(this.msgGroupId,"的模型"));this.msgGroup=s;const n=s.appViewMsgGroupDetails.map((t=>t.appViewMsgId));if(null==(a=i.appViewMsgs)||a.forEach((t=>{const e=n.indexOf(t.id);-1!==e&&(this.viewMsgMap.set(t.id,t),n.splice(e,1))})),n.length)throw new o("没有找到".concat(n.join(","),"视图消息模型"))}getDeFieldName(t,e){var a,i;if(e)return null==(i=null==(a=be(t,e))?void 0:a.name)?void 0:i.toLowerCase()}static async fetchDataSet(t,e,i){const{appDataEntityId:s,appDEDataSetId:n}=t;if(!n)throw new a(t,"未配置实体数据集");const o=await ibiz.hub.getApp(e.srfappid).deService.exec(s,n,e,i);return o.data.length?o.data:[]}async calcViewMessages(t,e){const a=this.msgGroup.appViewMsgGroupDetails,i=[];return(null==a?void 0:a.length)&&await Promise.all(a.map((async a=>{if(1===this.viewMsgMap.get(a.appViewMsgId).dynamicMode){const s=await this.calcDynaMsgs(a,t,e);i.push(...s)}else{const t=this.calcStaticMsg(a);i.push(t)}}))),i}calcStaticMsg(t){const{position:e}=t,a=this.viewMsgMap.get(t.appViewMsgId),{title:i,message:s,removeMode:n,position:o,messageType:r}=a,{userTag:c,userTag2:d,userTag3:l,userTag4:h}=a;return{title:i,message:s,position:e||o,messageType:r,removeMode:n,extraParams:{userTag:c,userTag2:d,userTag3:l,userTag4:h}}}async calcDynaMsgs(e,i,s){const n=this.viewMsgMap.get(e.appViewMsgId),{appDataEntityId:o,orderValueAppDEFieldId:r,titleAppDEFieldId:c,removeFlagAppDEFieldId:d,msgTypeAppDEFieldId:l,contentAppDEFieldId:h,msgPosAppDEFieldId:u}=n;if(!o)throw new a(n,"未配置应用实体");const p=await ibiz.hub.getAppDataEntity(o,i.srfappid),m={...s},f=this.getDeFieldName(p,r);f&&(m.sort="".concat(f,",asc"));const g=await t.fetchDataSet(n,i,m);if(!g.length)return[];const w=this.calcStaticMsg(e),E=this.getDeFieldName(p,c),y=this.getDeFieldName(p,u),v=this.getDeFieldName(p,h),I=this.getDeFieldName(p,l),D=this.getDeFieldName(p,d);return g.map((t=>{const e={};return y&&!Q(t[y])&&(e.position=t[y]),E&&!Q(t[E])&&(e.title=t[E]),v&&!Q(t[v])&&(e.message=t[v]),I&&!Q(t[I])&&(e.messageType=t[I]),D&&!Q(t[D])&&(e.removeMode=t[D]),$(w,e)}))}},Er=t("ViewController",class extends gr{constructor(t,e,a,i){super(ibiz.util.layoutPanel.fill(t),d.create({},e),a||{},new Ko(i)),this.session={},this.modal=new fa({}),this.providers={},this.engines=[],this.slotProps={},this.counters={},this.viewLoading=new Go,this.isCloseView=!1,i&&i.registerController(this.model.name,this),this.ctx.init(this),this.initEngines()}get _evt(){return this.evt}get parentView(){var t;return null==(t=this.ctx.parent)?void 0:t.view}get isActive(){return this.state.activated}onActivated(){this.state.activated=!0,ibiz.log.debug("视图[".concat(this.model.name,"](").concat(this.model.id,")激活"))}onDeactivated(){this.state.activated=!1,ibiz.log.debug("视图[".concat(this.model.name,"](").concat(this.model.id,")暂停"))}initEngines(){const t=Le(this.model);if(t.length)t.forEach((t=>{const e=ibiz.engine.getEngine(t,this);e?this.engines.push(e):ibiz.log.warn("未找到视图引擎实现:",t)}));else{const t=ibiz.engine.getEngine({engineCat:"VIEW",engineType:this.model.viewType,appId:this.model.appId},this);t&&this.engines.push(t)}}async initCounters(){const t=this.model.viewLayoutPanel,{appCounterRefs:e}=t;if(e&&e.length>0)try{await Promise.all(e.map((async t=>{const e=await ln.getCounterByRef(t,this.context);this.counters[t.id]=e})))}catch(t){console.error(t)}}initState(){super.initState(),this.state.activated=!0,this.state.isLoading=!1,this.state.caption=this.model.caption,this.state.srfactiveviewdata=null,this.state.viewMessages={},this.state.isClosing=!1}async onCreated(){await super.onCreated(),this.modal.hooks.beforeDismiss.tapPromise((async t=>{it(this.state.closeOK)&&(t.ok=this.state.closeOK),await this._evt.emit("onCloseView",{...t})})),this._evt.emit("onViewInfoChange",{caption:this.model.caption,title:this.model.title}),this.handleContextParams();const t=this.model.viewLayoutPanel;this.childNames.push(t.name);const e=await es(t);this.providers[t.name]=e;const a=Me(this.model);a&&await Promise.all(a.map((async t=>{const e=await es(t);this.providers[t.name||t.id]=e}))),await this.initCounters();const i=Oe(this.model);i.length&&(this.scheduler=ibiz.scheduler.createViewScheduler(i),this.scheduler.defaultParamsCb=()=>this.getEventArgs(),this.scheduler.hasViewEventTrigger&&this.evt.onAll(((t,e)=>{this.scheduler.triggerViewEvent(e)}))),this.initViewMsg(),this.engines.length&&await Promise.all(this.engines.map((t=>t.onCreated())))}async onMounted(){var t;await super.onMounted(),this.engines.length&&await Promise.all(this.engines.map((t=>t.onMounted()))),null==(t=this.scheduler)||t.startTimerTrigger()}async onDestroyed(){const t=this.context.srfsessionid;await super.onDestroyed(),this.engines.length&&await Promise.all(this.engines.map((t=>t.onDestroyed()))),Object.values(this.counters).forEach((t=>t.destroy())),this.ctx.destroy(),this.engines=[],this.scheduler&&this.scheduler.destroy(),this.id===t&&ibiz.uiDomainManager.destroy(t),this.context.destroy(),ibiz.log.debug("视图[".concat(this.model.name,"](").concat(this.model.id,")销毁"))}handleContextParams(){if(this.context.srfappid=this.model.appId||ibiz.env.appId,Q(this.context.srfsessionid)||J(this.context.srfsessionid)){const t=ibiz.uiDomainManager.create(this.id);this.context.srfsessionid=t.id}const t=this.model.appViewNavContexts;let e={};nt(t)&&(e=oe(t,this.params,this.context)),Object.assign(this.context,e),Object.prototype.hasOwnProperty.call(this.context,"srfreadonly")||Object.assign(this.context,{srfreadonly:!1});const a=this.model.appViewNavParams;let i={};nt(a)&&(i=oe(a,this.params,this.context)),Object.assign(this.params,i),this.engines.forEach((t=>{t.handleContextParams()})),this.state.isMounted&&this.callUIAction("Refresh")}async call(t,e){let a;for(const i of this.engines)if(a=await i.call(t,e),void 0!==a)break;return a}async callUIAction(t,e){const a=this.call(t,e);if(void 0===a)throw new o("没有引擎支持预置界面行为".concat(t));return a}async closeView(t={ok:!1,data:[]}){await this.modal.dismiss(t)}startLoading(){this.viewLoading.begin(),this.state.isLoading=this.viewLoading.isLoading}endLoading(){this.viewLoading.end(),this.state.isLoading=this.viewLoading.isLoading}setLayoutPanel(t){var e;this.layoutPanel=t,this.layoutPanel.state.isMounted?this.mountCounter.attend(this.layoutPanel.model.name):this.layoutPanel.evt.on("onMounted",(()=>{this.mountCounter.attend(this.layoutPanel.model.name)})),(null==(e=this.scheduler)?void 0:e.hasControlEventTrigger)&&t.evt.on("onControlEvent",(t=>{this.scheduler.triggerControlEvent(t.triggerControlName,t.triggerEventName,t.triggerEvent)}))}async initViewMsg(){const{appViewMsgGroupId:t}=this.model;if(t){this.state.viewMessages={TOP:[],BOTTOM:[],BODY:[],POPUP:[]},this.viewMsgController=new wr(t),await this.viewMsgController.init(this.context);(await this.viewMsgController.calcViewMessages(this.context,this.params)).forEach((t=>{["TOP","BOTTOM","BODY","POPUP"].includes(t.position)&&this.state.viewMessages[t.position].push(t)})),this.state.viewMessages.POPUP.length&&this.alertViewMessage(this.state.viewMessages.POPUP)}}async alertViewMessage(t){const[e,...a]=t,i={title:e.title,desc:e.message};e.extraParams.userTag&&Object.assign(i,{confirmButtonText:e.extraParams.userTag}),"WARN"===e.messageType?await ibiz.modal.warning(i):"ERROR"===e.messageType?await ibiz.modal.error(i):await ibiz.modal.info(i),a.length&&this.alertViewMessage(a)}convertMultipleLanguages(){this.model.capLanguageRes&&this.model.capLanguageRes.lanResTag&&(this.model.caption=ibiz.i18n.t(this.model.capLanguageRes.lanResTag,this.model.caption))}}),yr=(t("AppDataUploadViewController",class extends Er{initState(){super.initState()}async onCreated(){await super.onCreated();const{srfappdataentityid:t,srfdedataimportid:e,srfappid:a}=this.context,{appDataEntity:i,deDataImport:s}=await lr({appDataEntityId:t,deDataImportId:e,appId:a});this.state.appDataEntity=i,this.state.deDataImport=s}downloadTemplate(){const{appDataEntity:t,deDataImport:e}=this.state;ur(t,e)}async selectAndImport(){const t=await pr({appDataEntity:this.state.appDataEntity,dataImport:this.state.deDataImport,context:this.context});return!0===t.isAsync&&this.closeView(),t}}),t("MobViewController",class extends Er{}),t("WFStepTraceViewController",class extends Er{initState(){super.initState(),this.state.historyData=null}async onCreated(){var t;await super.onCreated();const e=ibiz.hub.getApp(this.context.srfappid),a=null==(t=this.ctx.parent)?void 0:t.view;if(a&&a.model.appDataEntityId){const t=await e.deService.getService(a.context,a.model.appDataEntityId),i=Object.assign(this.context.clone(),this.params),s=await t.wf.getWFHistory(i);s.data&&(this.state.historyData=s.data)}}}),t("EditorController",class{constructor(t,e){this.style={},this.placeHolder="",this.editorParams={},this.model=t,this.parent=e,this.context=e.context,this.params=e.params}get readonly(){return!!this.model.readOnly}get valueFormat(){return this.parent.valueFormat}get dataType(){return this.parent.dataType}async init(){await this.onInit()}async onInit(){if(this.model.placeHolder&&(this.placeHolder=this.model.placeHolder),this.model.editorParams&&Object.keys(this.model.editorParams).forEach((t=>{this.editorParams[t]=this.model.editorParams[t]})),this.model.editorWidth){const t=this.model.editorWidth;this.style.width=t>0&&t<=1?"".concat(100*t,"%"):"".concat(t,"px")}if(this.model.editorHeight){const t=this.model.editorHeight;this.style.height=t>0&&t<=1?"".concat(100*t,"%"):"".concat(t,"px")}if(this.model.cssStyle){const t={};this.model.cssStyle.split(";").filter(Boolean).forEach((e=>{const[a,i]=e.split(":");a&&i&&(t[a.trim()]=i.trim()),Object.assign(this.style,t)}))}this.model.editorItems&&(this.model.editorItems=this.model.editorItems.filter((t=>t.id!==this.model.id)))}handlePublicParams(t,e,a){const{navigateContexts:i,navigateParams:s}=this.model;let n={};i&&t&&(n=oe(i,t,a,e));const o=Object.assign(e.clone(),n);let r={};return s&&t&&(r=oe(s,t,a,e)),{context:o,params:r}}toObj(t){if(!t)return;return new Function("return (".concat(t,");"))()}toBoolean(t){return Object.is("true",t)}formatValue(t=""){if("SIMPLE"!==this.model.valueType)return ar.toText(this.model,t);const e="".concat(t);if(!this.valueFormat)return e;if(l.isDate(this.dataType)){const t=yt(e).format(this.valueFormat);return"Invalid Date"!==t?t:e}return ibiz.util.text.format(e,this.valueFormat)}})),vr=(t("CodeListEditorController",class extends yr{async loadCodeList(t){const{context:e,params:i}=this.handlePublicParams(t,this.context,this.params);if(this.model.appCodeListId){const t=await ibiz.hub.getApp(this.context.srfappid);let a=[];return a=await t.codeList.get(this.model.appCodeListId,e,i),a}throw new a(this.model,"编辑器类型[".concat(this.model.editorType,"],未配置代码表"))}}),t("ControlController",class extends gr{constructor(t,e,a,i){if(super(t,d.create({},e),new y({},a),i),this.controlParams={},this.providers={},this.triggerKey="",this.awaitActiveCbs=new Map,this.delayCbs=new Map,this.registerToCtx(),this.controlPanel=me(t),!this.controlPanel){const e=ibiz.util.layoutPanel.get("".concat(t.controlType,"_DEFAULT"));e&&(this.controlPanel=Z(e))}this.updateContextParams({})}get _evt(){return this.evt}get view(){return this.ctx.view}registerToCtx(){this.ctx.registerController(this.model.name||this.model.id,this)}getEventArgs(){return{...super.getEventArgs(),data:this.getData()||[],ctrl:this}}initState(){super.initState(),this.state.activated=!0,this.state.isLoading=!1}async onCreated(){var t;if(await super.onCreated(),this.controlPanel){this.childNames.push(this.controlPanel.name);const t=await es(this.controlPanel);this.providers[this.controlPanel.name]=t}if(this.handleControlParams(),this.initControlScheduler(this.model.controlLogics),(null==(t=this.scheduler)?void 0:t.hasControlEventTrigger)&&this._evt.onAll(((t,e)=>{this.scheduler.triggerControlEvent(e.targetName,e.eventName,e)})),this.model.appDataEntityId){const t=ve(this.model.appDataEntityId);this.triggerKey="".concat(this.view.name,"@").concat(t,"@").concat(this.model.controlType,"@").concat(this.model.codeName)}this.onDEDataChange=this.onDEDataChange.bind(this),ibiz.mc.command.change.on(this.onDEDataChange)}async onMounted(){var t;await super.onMounted(),null==(t=this.scheduler)||t.startTimerTrigger()}async onDestroyed(){ibiz.mc.command.change.off(this.onDEDataChange),await super.onDestroyed(),this.scheduler&&this.scheduler.destroy(),this.params.destroy()}updateContextParams(t){t.context&&this.context.reset({},t.context),t.params&&this.params.reset({},t.params);const{controlNavContexts:e,controlNavParams:a}=this.model;let i={};nt(e)&&(i=oe(e,this.params,this.context)),Object.assign(this.context,i);let s={};nt(a)&&(s=oe(a,this.params,this.context)),Object.assign(this.params,s)}getControlType(){return this.model.controlType}getData(){return null}async startLoading(){this.state.isLoading=!0,this.ctx.startLoading()}async endLoading(){this.state.isLoading=!1,this.ctx.endLoading()}onActivated(){this.state.activated=!0,this.awaitActiveCbs.size>0&&this.awaitActiveCbs.forEach((t=>{t()})),this.awaitActiveCbs.clear(),ibiz.log.debug("视图[".concat(this.model.name,"](").concat(this.model.id,")激活"))}onDeactivated(){this.state.activated=!1,ibiz.log.debug("视图[".concat(this.model.name,"](").concat(this.model.id,")暂停"))}handlerAbilityParams(t){const e=this.context.clone(),a={...this.params};let i=this.getData()||[];return(null==t?void 0:t.data)&&(i=Array.isArray(t.data)?t.data:[t.data]),(null==t?void 0:t.context)&&Object.assign(e,t.context),(null==t?void 0:t.viewParam)&&Object.assign(a,t.viewParam),{context:e,params:a,data:i}}setLayoutPanel(t){this.layoutPanel=t,this.layoutPanel.state.isMounted?this.mountCounter.attend(this.layoutPanel.model.name):this.layoutPanel.evt.on("onMounted",(()=>{this.mountCounter.attend(this.layoutPanel.model.name)}))}handleControlParams(){if(!this.model.controlParam)return;const{ctrlParams:t}=this.model.controlParam;let e={};nt(t)&&(e=oe(t,this.params,this.context)),Object.assign(this.controlParams,e)}initControlScheduler(t=[]){0!==t.length&&(this.scheduler=ibiz.scheduler.createControlScheduler(t),this.scheduler.defaultParamsCb=()=>this.getEventArgs())}actionNotification(t,e){let a,i="";const{ctrlMsg:o}=this.model;if(o&&o.ctrlMsgItems){if(o.ctrlMsgItems.find((e=>e.name==="".concat(t,"_HIDDEN"))))return;const s=o.ctrlMsgItems.find((e=>e.name===t));if(s&&s.content){a=Q(s.timeout)?void 0:s.timeout/1e3;const t={...this.getEventArgs()};(null==e?void 0:e.data)&&(t.data=e.data),i=Qe.execScriptFn(t,"`".concat(s.content,"`"),{isAsync:!1,singleRowReturn:!0})}}if(!i&&ibiz.i18n){const e="CONTROL.".concat(this.model.controlType,".").concat(t).toUpperCase();i=ibiz.i18n.t(e,""),i===e&&(i="")}if(!i&&(null==e?void 0:e.default)&&(i=e.default),!i&&(null==e?void 0:e.error)&&(i=i||e.error.message),i){if(null==e?void 0:e.error){if(e.error instanceof s&&500!==e.error.status)throw e.error;throw ibiz.log.error(e.error),new n(i,a)}ibiz.message.success(i,a,0===a)}}onDEDataChange(t){ibiz.log.debug("onDEDataChange",t)}emitDEDataChange(t,e){const a=e instanceof En?e.$origin:e,i={triggerKey:this.triggerKey};switch(t){case"create":ibiz.mc.command.create.send(a,i);break;case"update":ibiz.mc.command.update.send(a,i);break;case"remove":ibiz.mc.command.remove.send(a,i);break;default:throw new o("不支持的实体数据变更类型: ".concat(t))}}doNextActive(t,e){if(Q(e.delay)&&(e.delay=300),!1===this.state.activated)this.awaitActiveCbs.set(e.key,t);else if(e.delay){const a=this.delayCbs.get(e.key);clearTimeout(a);const i=setTimeout((()=>{t(),clearTimeout(this.delayCbs.get(e.key))}),e.delay);this.delayCbs.set(e.key,i)}else t()}})),Ir=t("MDControlController",class extends vr{constructor(){super(...arguments),this.isSetSort=!1,this.fieldIdNameMap=new Map}get _evt(){return this.evt}initState(){super.initState(),this.state.items=[],this.state.selectedData=[],this.state.searchParams={},this.state.noSort=!1,this.state.sortQuery="",this.state.curPage=1,this.state.size=20,this.state.total=0,this.state.isLoaded=!1,this.state.singleSelect=!0,this.state.mdctrlActiveMode=0,this.state.groups=[]}get batchToolbarController(){return this.view.getController("".concat(this.model.name,"_batchtoolbar"))}get quickToolbarController(){return this.view.getController("".concat(this.model.name,"_quicktoolbar"))}async onCreated(){var t;await super.onCreated(),this.dataEntity=await ibiz.hub.getAppDataEntity(this.model.appDataEntityId,this.model.appId),null==(t=this.dataEntity.appDEFields)||t.forEach((t=>{this.fieldIdNameMap.set(t.id,t.name)})),this.isSetSort||this.setSort()}async onMounted(){await super.onMounted(),this.state.loadDefault&&this.load({isInitialLoad:!0})}getSortModel(){return{minorSortAppDEFieldId:void 0,minorSortDir:void 0}}setSort(t,e){if(t&&e)this.state.sortQuery="".concat(t,",").concat(e);else if(t||e)this.state.sortQuery="";else{const{minorSortAppDEFieldId:t,minorSortDir:e}=this.getSortModel();if(this.view&&localStorage.getItem("".concat(this.view.model.id,".").concat(this.model.name,".sort")))this.state.sortQuery=localStorage.getItem("".concat(this.view.model.id,".").concat(this.model.name,".sort"));else if(t&&e){const a=this.fieldIdNameMap.get(t);this.state.sortQuery="".concat(a.toLowerCase(),",").concat(e.toLowerCase())}}this.view&&(this.state.sortQuery?localStorage.setItem("".concat(this.view.model.id,".").concat(this.model.name,".sort"),this.state.sortQuery):localStorage.removeItem("".concat(this.view.model.id,".").concat(this.model.name,".sort")))}async getFetchParams(t){const{curPage:e,size:a,sortQuery:i,noSort:s}=this.state,n={...this.params};return a&&(n.page=e-1,n.size=a),!s&&i&&(n.sort=i),await this._evt.emit("onBeforeLoad",void 0),Object.assign(n,{...this.state.searchParams}),t&&Object.assign(n,t),n}async load(t={}){if(this.state.isSimple)return[];const e=!0===t.silent;e||await this.startLoading();try{const e=!0===t.isInitialLoad,a=!0===t.isLoadMore;e?this.state.curPage=1:a&&(this.state.curPage+=1);const{context:i}=this.handlerAbilityParams(t),s=await this.getFetchParams(null==t?void 0:t.viewParam),n=await this.service.fetch(i,s);"number"==typeof n.total&&(this.state.total=n.total),"number"==typeof n.totalPages&&(this.state.totalPages=n.totalPages),a?this.state.items.push(...n.data):this.state.items=n.data,await this.afterLoad(t,n.data),this.state.isLoaded=!0,await this._evt.emit("onLoadSuccess",{isInitialLoad:e})}catch(t){throw await this._evt.emit("onLoadError",void 0),this.actionNotification("FETCHERROR",{error:t}),t}finally{e||await this.endLoading()}return this.state.items.forEach(((t,e)=>{t.srfserialnum=e+1})),this.actionNotification("FETCHSUCCESS"),this.state.items}async afterLoad(t,e){return e}async refresh(){this.doNextActive((()=>this.load({isInitialLoad:!1})),{key:"refresh"})}async remove(t){const{context:e,params:a,data:i}=this.handlerAbilityParams(t);if(!(null==i?void 0:i.length))throw new o("未选中数据");if(!0!==(null==t?void 0:t.silent)){if(!await ibiz.confirm.error({title:"数据删除",desc:"确认删除数据?"}))return}await this._evt.emit("onBeforeRemove",void 0),await this.startLoading();let s=!1;try{await ba(i.map((async t=>{s=await this.handleItemRemove(t,e,a),this.afterRemove(t)}))),!0!==(null==t?void 0:t.silent)&&this.actionNotification("REMOVESUCCESS",{data:i,default:"数据[".concat(i.map((t=>t.srfmajortext)).join("、"),"]删除成功!")}),s&&!(null==t?void 0:t.notRefresh)&&await this.refresh()}catch(t){throw await this._evt.emit("onRemoveError",void 0),this.actionNotification("REMOVEERROR",{error:t,data:i}),t}finally{await this.endLoading()}this.state.selectedData=[],await this._evt.emit("onRemoveSuccess",void 0),i.forEach((t=>{this.emitDEDataChange("remove",t)}))}async handleItemRemove(t,e,a){let i=!1;const s=ve(this.model.appDataEntityId);if(0!==t.srfuf){const n=e.clone();n[s]=t.srfkey,await this.service.remove(n,a),i=!0}return i}afterRemove(t){const e=this.state.items.findIndex((e=>e.srfkey===t.srfkey));-1!==e&&this.state.items.splice(e,1)}getData(){return this.state.selectedData||[]}setActive(t){return this._evt.emit("onActive",{data:[t]})}setSelection(t){var e,a;const{selectedData:i}=this.state;v(i,t)||(this.state.selectedData=t,this._evt.emit("onSelectionChange",{data:t}));const s=null==t?void 0:t[0];null==(e=this.batchToolbarController)||e.calcButtonState(s,this.model.appDataEntityId),null==(a=this.quickToolbarController)||a.calcButtonState(s,this.model.appDataEntityId)}async onRowClick(t){const{selectedData:e}=this.state,a=e.filter((e=>e.srfkey!==t.srfkey));a.length===e.length?this.setSelection(this.state.singleSelect?[t]:e.concat([t])):this.setSelection(a),1===this.state.mdctrlActiveMode&&await this.setActive(t)}async onDbRowClick(t){2===this.state.mdctrlActiveMode&&await this.setActive(t)}async importData(){const{appDataEntityId:t,dedataImportId:e}=this.model;if(!t||!e)throw new a(this.model,"没有配置导入模型!");await hr({appDataEntityId:t,deDataImportId:e,context:this.context,params:this.params})}async exportData(t){}onDEDataChange(t){if(!Q(t.triggerKey)&&t.triggerKey===this.triggerKey)return;if(!t.data||t.data.srfdecodename!==this.dataEntity.codeName)return;let e=!1;const{srfkey:a}=t.data;switch(t.subtype){case"OBJECTCREATED":e=!0;break;case"OBJECTUPDATED":case"OBJECTREMOVED":-1!==this.state.items.findIndex((t=>t.srfkey===a))&&(e=!0)}e&&this.doNextActive((()=>this.load({isInitialLoad:!!ibiz.env.isMob})),{key:"refresh"})}}),Dr=t("AppMenuController",class extends vr{constructor(t,e,a,i){super(t,e,a,i),this.itemProviders={},this.flattenAllItems()}initState(){super.initState(),this.state.menuItemsState={}}get routeDepth(){return this.view.modal.routeDepth}async onCreated(){var t;await super.onCreated(),this.app=await ibiz.hub.getApp(this.context.srfappid),await this.initAppMenuItemProviders(),null==(t=this.model.appMenuItems)||t.forEach((t=>{this.initMenuItemState(t)}))}async initAppMenuItemProviders(){await Promise.all(this.allAppMenuItems.map((async t=>{const e=await Gs(t);e&&(this.itemProviders[t.id]=e)})))}async onClickMenuItem(t,e,i=!0,s={}){const n=I(this.model,t,{compareField:"id",childrenFields:["appMenuItems"]});if(!n)throw new o("找不到名为".concat(t,"的菜单项"));this.evt.emit("onClick",{eventArg:t,event:e});const r=this.itemProviders[t];if(r&&r.onClick)return r.onClick(n,e,this);if(!n.appFuncId)throw new a(n,"没有配置应用功能");const c=this.context.clone();c.srfappid=n.appId||ibiz.env.appId,this.routeDepth&&i&&Object.assign(c,{toRouteDepth:this.routeDepth+1}),await ibiz.commands.execute(Ro.TAG,n.appFuncId,c,this.params,s)}initMenuItemState(t){var e;const a={permitted:!0,visible:!0};if(t.hidden)a.visible=!1;else{let i=!0;t.accessKey&&(i=this.app.authority.calcByResCode(t.accessKey));let s=i;if(null==(e=t.appMenuItems)?void 0:e.length){const e=t.appMenuItems.map((t=>this.initMenuItemState(t).visible));s=s&&e.includes(!0)}a.permitted=i,a.visible=s}return this.state.menuItemsState[t.id]=a,a}flattenAllItems(){const t=[],e=a=>{a.forEach((a=>{t.push(a),a.appMenuItems&&a.appMenuItems.length>0&&e(a.appMenuItems)}))};e(this.model.appMenuItems),this.allAppMenuItems=t}getAllItems(){return this.allAppMenuItems}getCounter(t){const{counters:e}=this.ctx.view;return e[t]?e[t]:null}convertMultipleLanguages(){const t=e=>{e.forEach((e=>{var a;e.capLanguageRes&&e.capLanguageRes.lanResTag&&(e.caption=ibiz.i18n.t(e.capLanguageRes.lanResTag,e.caption)),(null==(a=e.appMenuItems)?void 0:a.length)&&t(e.appMenuItems)}))};this.model.appMenuItems&&this.model.appMenuItems.length>0&&t(this.model.appMenuItems)}}),Cr=(t("AppMenuIconViewController",class extends Dr{async onClickMenuItem(t,e){const i=I(this.model,t,{compareField:"id",childrenFields:["appMenuItems"]});if(!i)throw new o("找不到名为".concat(t,"的菜单项"));if(this.evt.emit("onClick",{eventArg:t,event:e}),!i.appFuncId)throw new a(i,"没有配置应用功能");const s=this.context.clone();1===this.routeDepth&&Object.assign(s,{toRouteDepth:1}),await ibiz.commands.execute(Ro.TAG,i.appFuncId,s,this.params)}}),t("CalendarService",class extends vn{async search(t,e={}){const{sysCalendarItems:a}=this.model;if(!a)return[];const i=a.map((async a=>{const i=a.appDEDataSetId||"fetchdefault",s=t.clone(),n=Z(e);return a.maxSize&&(n.size=a.maxSize),this.exec2(i,s,n,void 0,a.appDataEntityId)}));return(await Promise.all(i)).map(((t,e)=>this.setCalendarConfigData(t.data,e))).flat()}setCalendarConfigData(t,e){const{sysCalendarItems:a}=this.model;if(!a)throw new o("未找到日历项模型");const i=a[e];if(!i)throw new o("未找到日历项模型");return t.map((t=>new go(i,t)))}async exec2(t,e,a={},i={},s=this.model.appDataEntityId){return await this.app.deService.exec(s,t,e,a,i)}}));t("CalendarController",class extends Ir{initState(){super.initState(),this.state.selectedDate=new Date,this.state.size=1e3}async onCreated(){await super.onCreated(),this.service=new Cr(this.model),await this.service.init(this.context),this.initViewScheduler()}initViewScheduler(){const t=this.model.appViewLogics||[];0!==t.length&&(this.viewScheduler=ibiz.scheduler.createViewScheduler(t),this.viewScheduler.defaultParamsCb=()=>this.getEventArgs(),this.viewScheduler.hasViewEventTrigger&&this.evt.onAll(((t,e)=>{this.viewScheduler.triggerViewEvent(e)})))}async setActive(t){return this.openData(t),this._evt.emit("onActive",{data:[t]})}async openData(t){var e,i;const s=this.context.clone();s[((null==(e=t.deData.srfdecodename)?void 0:e.toLowerCase())||ve(this.model.appDataEntityId)).toLowerCase()]=t.deData.srfkey;const n=await(null==(i=this.viewScheduler)?void 0:i.triggerCustom("".concat(t.itemType.toLowerCase(),"_opendata"),{context:s,params:this.params,data:[t.deData],event:void 0,view:this.view,ctrl:this}));if(-1===n)throw new a(this.model,"缺少".concat(t.itemType.toLowerCase(),"_opendata的视图逻辑"));return{cancel:!n||n.ok}}async load(t={}){const e=!0===t.isInitialLoad,{context:a}=this.handlerAbilityParams(t),i=await this.getFetchParams(null==t?void 0:t.viewParam);let s;await this.startLoading();try{s=await this.service.search(a,i)}finally{await this.endLoading()}return await this.afterLoad(t,s),this.state.isLoaded=!0,this.state.items=s,this.sortItems(),await this.evt.emit("onLoadSuccess",{isInitialLoad:e}),s}sortItems(){"TIMELINE"===this.model.calendarStyle&&this.state.items.sort(((t,e)=>{const a=t.beginTime,i=e.beginTime;let s=0;return yt(a).isAfter(i)?s=-1:yt(a).isBefore(i)&&(s=1),s}))}getCurSelectDate(t){const{selectedDate:e}=this.state,{srfstartdate:a,srfenddate:i}=t;if(!a||!i){const t=new Date(e.getFullYear(),e.getMonth(),1),a=new Date(e.getFullYear(),e.getMonth()+1,1);return{srfstartdate:yt(t).format("YYYY-MM-DD HH:mm:ss"),srfenddate:yt(a).format("YYYY-MM-DD HH:mm:ss")}}return{srfstartdate:a,srfenddate:i}}async getFetchParams(t={}){const{curPage:e,size:a,sortQuery:i,noSort:s}=this.state,n={...this.params};if(!s&&i&&(n.sort=i),await this._evt.emit("onBeforeLoad",void 0),Object.assign(n,{...this.state.searchParams}),a&&(n.page=e-1,n.size=a),t&&Object.assign(n,t),"TIMELINE"!==this.model.calendarStyle){const t=this.getCurSelectDate(n);Object.assign(n,t)}return n}async onRowClick(t){const{selectedData:e}=this.state,a=e.filter((e=>e.deData.srfkey!==t.deData.srfkey));a.length===e.length?this.setSelection(this.state.singleSelect?[t]:e.concat([t])):this.setSelection(a),1===this.state.mdctrlActiveMode&&await this.setActive(t)}setSelectDate(t){this.state.selectedDate=t}});yt.extend(bt),yt.extend(Pt),yt.extend(xt),yt.extend(St),yt.extend(Mt);var br="$default_group",Ar=class{constructor(t,e){this.model=t,this.chartGenerator=e,this.chartDataArr=[],this.staticOptions={},this.autoCompleteCategory=!0,this.model=t,this.chartGenerator=e;const{chartSeriesEncode:i,caption:s,id:n,userParam:o}=t;if(!t.catalogField)throw new a(t,"缺少分类属性配置");if(!t.valueField)throw new a(t,"缺少值属性配置");this.catalogField=e.getFieldKey(t.catalogField),this.valueField=e.getFieldKey(t.valueField),this.groupField=t.seriesField?e.getFieldKey(t.seriesField):void 0;const{chartXAxisId:r,chartYAxisId:c}=i||{};this.xAxisIndex=R(r),this.yAxisIndex=R(c),this.seriesName=s||n,this.staticOptions=this.calcStaticOptions(),o&&(this.seriesUserParam=Or(o))}calcStaticOptions(){return{type:this.model.seriesType,name:this.seriesName,emphasis:{label:{fontSize:20,show:!0}},label:{position:"top",show:!0}}}translateVal(t,e,a=!1){if(Q(e))return;if(Q(t))return e;const i=this.chartGenerator.codeListMap.get(t);if(null==i?void 0:i.length){const t=i.find((t=>t.value===e));return t?t.text:"未定义"}return a?void 0:e}prepareChartData(t,e,a,i){var s;this.groupField&&Object.assign(e,{[this.groupField]:i}),this.catalogField&&Object.assign(e,{[this.catalogField]:a});const n=new vo(e,this.model,a,i);t[i].get(a).chartData=n,null==(s=this.chartDataArr)||s.push(n)}calcGroupData(t){this.groupData={},this.chartDataArr=[];const e=this.groupData,{seriesCodeListId:a,catalogCodeListId:i}=this.model;return t.forEach((t=>{let s=br;if(this.groupField){const e=this.translateVal(a,t[this.groupField]);if(Q(e))return;s=e}if(!e[s]&&(e[s]=new Map,i&&this.autoCompleteCategory)){this.chartGenerator.codeListMap.get(i).forEach((t=>{e[s].set(t.text,{value:0})}))}const n=this.translateVal(i,t[this.catalogField],!0);if(n)e[s].get(n)||e[s].set(n,{value:0}),e[s].get(n).value=S(e[s].get(n).value,t[this.valueField]||0),e[s].get(n).chartData?this.prepareChartData(e,{[this.valueField]:e[s].get(n).value},n,s):this.prepareChartData(e,t,n,s);else if(i&&this.autoCompleteCategory){this.chartGenerator.codeListMap.get(i).forEach((t=>{this.prepareChartData(e,{[this.valueField]:0},t.text,s)}))}})),e}calcGroupSeries(t){return Object.keys(t).map((e=>{const a=t[e],i=this.calcSeriesData(a);let s={...this.staticOptions,data:i};return e!==br&&(s.name=e),this.seriesUserParam&&(s=st(s,this.seriesUserParam)),s}))}calcSeriesData(t){const e=[];return t.forEach(((t,a)=>{e.push([a,t.value,t.chartData])})),e}calcByData(t){const e=this.dataPreprocess(t),a=this.calcGroupData(e);return this.addTimeData(a),this.calcGroupSeries(a)}getChartDataByParams(t){var e,a,i;return this.groupData&&1===Object.keys(this.groupData).length?null==(e=this.groupData[br].get(t.name))?void 0:e.chartData:null==(i=null==(a=this.groupData)?void 0:a[t.seriesName].get(t.name))?void 0:i.chartData}dataPreprocess(t){const e=[];t.forEach((t=>{e.push(Z(t))}));const{groupMode:a}=this.model;return a&&e.forEach((t=>{let e="";if("DAY"===a||"YEAR"===a||"MONTH"===a){if("DAY"===a?e="YYYY-MM-DD":"YEAR"===a?e="YYYY":"MONTH"===a&&(e="YYYY-MM"),t[this.catalogField]){const a=yt(t[this.catalogField]).format(e);t[this.catalogField]=a}}else if("QUARTER"===a){if(t[this.catalogField]){const e="".concat(yt(t[this.catalogField]).format("YYYY"),"-").concat(yt(t[this.catalogField]).quarter());t[this.catalogField]=e}}else if("YEARWEEK"===a&&t[this.catalogField]){const e="".concat(yt(t[this.catalogField]).format("YYYY"),"-").concat(yt(t[this.catalogField]).week());t[this.catalogField]=e}})),e}sortTimeData(t){const{groupMode:e}=this.model;Object.keys(t).forEach((a=>{const i=t[a];let s=[];"DAY"===e||"YEAR"===e||"MONTH"===e?s=Array.from(i.keys()).sort(((t,e)=>yt(t).diff(yt(e)))):"QUARTER"!==e&&"YEARWEEK"!==e||(s=Array.from(i.keys()).sort(((t,e)=>{const[a,i]=t.split("-"),[s,n]=e.split("-");return a!==s?parseInt(a,10)-parseInt(s,10):parseInt(i,10)-parseInt(n,10)})));const n=new Map;s.forEach((t=>{n.set(t,i.get(t))})),t[a]=n}))}addTimeData(t){const{groupMode:e}=this.model;if(!e||"CODELIST"===e)return;const a=[];Object.keys(t).forEach((e=>{t[e].forEach(((t,e)=>{a.push(yt(e))}))}));const i=yt.max(a),s=yt.min(a);if("DAY"===e){let e=s;const a=i;for(;null==e?void 0:e.isSameOrBefore(a,"day");){const a=e.format("YYYY-MM-DD");Object.keys(t).forEach((e=>{t[e].get(a)||t[e].set(a,{value:0})})),e=e.add(1,"day")}}else if("YEAR"===e){let e=s.year();const a=i.year();for(;e<=a;){const a=e.toString();Object.keys(t).forEach((e=>{t[e].get(a)||t[e].set(a,{value:0})})),e+=1}}else if("MONTH"===e){let e=s.clone().startOf("month");const a=i.clone().startOf("month");for(;e.isSameOrBefore(a);){const a=e.format("YYYY-MM");Object.keys(t).forEach((e=>{t[e].get(a)||t[e].set(a,{value:0})})),e=e.add(1,"month")}}else if("QUARTER"===e){const e=[];Object.keys(t).forEach((a=>{t[a].forEach(((t,a)=>{e.push(a)}))}));const a=e.reduce(((t,e)=>e<t?e:t),e[0]),i=e.reduce(((t,e)=>e>t?e:t),e[0]),[s]=a.split("-"),[n]=i.split("-");for(let e=parseInt(s,10);e<=parseInt(n,10);e++)for(let a=1;a<=4;a++){const i="".concat(e,"-").concat(a);Object.keys(t).forEach((e=>{t[e].get(i)||t[e].set(i,{value:0})}))}}else if("YEARWEEK"===e){const e=[];Object.keys(t).forEach((a=>{t[a].forEach(((t,a)=>{e.push(a)}))}));const a=e.reduce(((t,e)=>e<t?e:t),e[0]),i=e.reduce(((t,e)=>e>t?e:t),e[0]),[s]=a.split("-"),[n]=i.split("-");for(let e=parseInt(s,10);e<=parseInt(n,10);e++){const a=yt("".concat(e,"-12-31")).isoWeek();for(let i=1;i<=a;i++){const a="".concat(e,"-").concat(i);Object.keys(t).forEach((e=>{t[e].get(a)||t[e].set(a,{value:0})}))}}}this.sortTimeData(t)}},Pr=class extends Ar{calcStaticOptions(){if(void 0===this.xAxisIndex)throw new a(this.model,"序列没有配置X坐标轴");if(void 0===this.yAxisIndex)throw new a(this.model,"序列没有配置Y坐标轴");const t=super.calcStaticOptions();t.xAxisIndex=this.xAxisIndex,t.yAxisIndex=this.yAxisIndex;const{stack:e,step:i}=this.model;return i&&(t.step="middle"),t}},Tr=class extends Ar{calcStaticOptions(){if(void 0===this.xAxisIndex)throw new a(this.model,"序列没有配置X坐标轴");if(void 0===this.yAxisIndex)throw new a(this.model,"序列没有配置Y坐标轴");const t=super.calcStaticOptions();return t.xAxisIndex=this.xAxisIndex,t.yAxisIndex=this.yAxisIndex,this.model,t}},xr=class extends Ar{calcStaticOptions(){const t=super.calcStaticOptions();return t.label.formatter="{b}: {d}%",t.label.position="outer",t}calcSeriesData(t){const e=[];return t.forEach(((t,a)=>{e.push({name:a,value:[t.value,t.chartData]})})),e}},Nr=class extends Ar{calcStaticOptions(){const t=super.calcStaticOptions();return t.label.formatter="{b}: {d}%",t.label.position="outside",t}calcSeriesData(t){const e=[];return t.forEach(((t,a)=>{e.push({name:a,value:[t.value,t.chartData]})})),e}},Sr=class extends Ar{calcStaticOptions(){if(void 0===this.xAxisIndex)throw new a(this.model,"序列没有配置X坐标轴");if(void 0===this.yAxisIndex)throw new a(this.model,"序列没有配置Y坐标轴");const t=super.calcStaticOptions();return t.xAxisIndex=this.xAxisIndex,t.yAxisIndex=this.yAxisIndex,t}},Rr=class{constructor(t){this.indicator={},this.index=t}get indicatorKeys(){return this._indicatorKeys&&this._indicatorKeys.length===Object.keys(this.indicator).length||(this._indicatorKeys=Object.keys(this.indicator).sort()),this._indicatorKeys}updateIndicator(t,e){const a=this.indicator[t];(!a||a.max<e)&&(this.indicator[t]={max:e})}toOptions(){const t=Math.max(...Object.values(this.indicator).map((t=>t.max)));return{indicator:this.indicatorKeys.map((e=>({name:e,max:t})))}}},Mr=class extends Ar{calcStaticOptions(){return super.calcStaticOptions()}calcRadarCoordSystem(t){const e=this.calcGroupData(t);this.chartGenerator.radarMap.has(this.catalogField)||this.chartGenerator.radarMap.set(this.catalogField,new Rr(this.chartGenerator.radarMap.size));const a=this.chartGenerator.radarMap.get(this.catalogField);Object.values(e).forEach((t=>{t.forEach(((t,e)=>{a.updateIndicator(e,t.value)}))}))}calcByData(t){const e=this.groupData,a=this.chartGenerator.radarMap.get(this.catalogField),i=Object.keys(e).map((t=>{const i=e[t],s=a.indicatorKeys.map((t=>i.has(t)?i.get(t).value:0));return{name:t===br?this.seriesName:t,value:s}}));let s={...this.staticOptions,data:i};return this.seriesUserParam&&(s=st(s,this.seriesUserParam)),s}};function Or(t){const e={};return t&&Object.keys(t).forEach((a=>{const i=a.indexOf(".");if(-1===i)return;const s=a.slice(i+1);if(s)try{e[s]=JSON.parse(t[a])}catch(i){e[s]=t[a]}})),e}var Lr=class{constructor(t){this.model=t,this.staticOptions={tooltip:{show:!0}},this.options={},this.seriesGenerators=[],this.radarMap=new Map,this.codeListMap=new Map,this.seriesGeneratorIndexMap=new Map;const{dechartTitle:e,dechartLegend:a,chartXAxises:i,chartYAxises:s,userParam:n}=t;e&&(this.staticOptions.title=this.calcTitleOption(e)),a&&(this.staticOptions.legend=this.calcLegendOption(a)),(null==i?void 0:i.length)&&(this.staticOptions.xAxis=this.calcXYAxisOption(i)),(null==s?void 0:s.length)&&(this.staticOptions.yAxis=this.calcXYAxisOption(s)),n&&(this.chartUserParam=Or(n))}initSeriesGenerators(){var t;null==(t=this.model.dechartSerieses)||t.forEach((t=>{let e;switch(t.seriesType){case"line":e=new Pr(t,this);break;case"bar":e=new Tr(t,this);break;case"scatter":e=new Sr(t,this);break;case"pie":e=new Nr(t,this);break;case"funnel":e=new xr(t,this);break;case"radar":e=new Mr(t,this);break;default:ibiz.log.error("图表暂未支持序列类型".concat(t.seriesType))}e&&this.seriesGenerators.push(e)}))}calcTitleOption(t){const{showTitle:e,title:a,subTitle:i,titlePos:s}=t,n={show:e,text:a,subtext:i,left:"center"},o=null==s?void 0:s.toLowerCase();return"left"===o||"right"===o?n.left=o:"bottom"!==o&&"top"!==o||(n.top=o),n}calcLegendOption(t){const{showLegend:e,legendPos:a}=t,i={};i.show=e;const s=null==a?void 0:a.toLowerCase();return"left"===s||"right"===s?(i.left=s,i.top="middle",i.orient="vertical"):"bottom"===s&&(i.top=s),i}calcXYAxisOption(t){const e=[];return t.forEach((t=>{const{position:a,dataShowMode:i,userParam:s}=t;let n={type:t.echartsType,name:t.caption,max:t.maxValue,min:t.minValue,position:a,axisLabel:{formatter:t=>("number"==typeof t&&(t=t.toString()),1===i?t.length>4?"".concat(t.slice(0,4).split("").join("\n"),"\n..."):t.split("").join("\n"):2===i&&t.length>4?"".concat(t.slice(0,4),"..."):t),rotate:3===i?45:0}};s&&(n=st(n,Or(s))),e.push(n)})),e}async init(t,e){await this.loadCodeList(t,e),this.entity=await ibiz.hub.getAppDataEntity(this.model.appDataEntityId,this.model.appId),this.initSeriesGenerators()}getFieldKey(t){const e=this.entity.appDEFields.find((e=>e.name===t));return e?e.codeName.toLowerCase():t.toLowerCase()}async loadCodeList(t,e){var a;if(this.codeListMap.clear(),!(null==(a=this.model.dechartSerieses)?void 0:a.length))return;const i=ibiz.hub.getApp(t.srfappid),s=async a=>{if(!a||this.codeListMap.has(a))return;const s=await i.codeList.get(a,t,e);this.codeListMap.set(a,s)};await Promise.all(this.model.dechartSerieses.map((async t=>{const{seriesCodeListId:e,catalogCodeListId:a}=t;await s(e),await s(a)})))}calcOptionsByData(t){this.radarMap.clear(),this.options={series:[],radar:[]},this.seriesGenerators.forEach((e=>{"radar"===e.model.seriesType&&e.calcRadarCoordSystem(t)})),this.radarMap.size&&(this.options.radar=[...this.radarMap.values()].map((t=>t.toOptions())));const e=[];return this.seriesGenerators.forEach((a=>{const i=e.length,s=a.calcByData(t);s instanceof Array?e.push(...s):e.push(s);const n=e.length-1;for(let t=i;t<=n;t++)this.seriesGeneratorIndexMap.set(t,a)})),this.options.series=e,1===this.seriesGenerators.length&&this.seriesGenerators[0].groupData&&1===Object.keys(this.seriesGenerators[0].groupData).length&&e[0].type&&["bar","line","scatter"].includes(e[0].type)&&this.staticOptions.legend&&(this.staticOptions.legend.show=!1),this.options=st(this.staticOptions,this.options),this.chartUserParam&&(this.options=st(this.options,this.chartUserParam)),this.options}getChartDataByParams(t){const e=this.seriesGeneratorIndexMap.get(t.seriesIndex);if(!e)throw new o("找不到".concat(t.seriesIndex,"序列的generator!"));return e.getChartDataByParams(t)}},_r=t("ChartService",class extends vn{}),Fr=(t("ChartController",class extends Ir{initState(){super.initState(),this.state.size=1e3,this.state.showGrid=!1,this.state.gridHeaders=[],this.state.gridData=[],this.state.gridPosition="bottom"}async onCreated(){await super.onCreated(),this.service=new _r(this.model),await this.service.init(this.context),this.generator=new Lr(this.model),await this.generator.init(this.context,this.params),this.parseGridParam(),this.resizeChart=this.resizeChart.bind(this),window.addEventListener("resize",this.resizeChart)}async afterLoad(t,e){const a=await super.afterLoad(t,e);return e.forEach((t=>{Object.assign(t,{srfcount:1})})),this.calcOptions(),a}parseGridParam(){this.model.dechartDataGrid&&(this.model.dechartDataGrid.dataGridPos?this.state.gridPosition=this.model.dechartDataGrid.dataGridPos.toLocaleLowerCase():this.state.gridPosition="bottom",!0===this.model.dechartDataGrid.showDataGrid&&(this.state.showGrid=!0))}computeTotal(t){let e=0;return this.state.items.forEach((a=>{const i=Number(a[t]);Number.isNaN(i)||(e+=Number(i))})),e}handleSingleSerieGridData(){const t=this.generator.seriesGenerators[0],{catalogField:e,valueField:a,groupData:i}=t,s=t.chartGenerator.entity.appDEFields,n=s.find((t=>t.id===e)),o=s.find((t=>t.id===a)),r=[{id:e,name:null==n?void 0:n.logicName},{id:a,name:null==o?void 0:o.logicName},{id:"srfpercent",name:"百分比"}];this.state.gridHeaders=r;const c=[],d=this.computeTotal(a);if(i&&i.$default_group){const t=i.$default_group;for(const[i,s]of t){const t=Number.isNaN(Number(s.value))?0:Number(s.value);let n="";n=0===d||Number.isNaN(Number(s.value))?"0%":"".concat(Math.round(t/d*100),"%");const o={[e]:i,[a]:t,srfpercent:n};c.push(o)}}this.state.gridData=c}handleMultipleSerieGridData(){const t=[],e=[];this.generator.seriesGenerators.forEach((a=>{const{catalogField:i,valueField:s,groupData:n}=a,o=a.chartGenerator.entity.appDEFields;if(t.findIndex((t=>t.id===i))<0){const e=o.find((t=>t.id===i.toLowerCase()));t.push({id:i,name:null==e?void 0:e.logicName})}const r=o.find((t=>t.id===s.toLowerCase()));if(t.push({id:s,name:null==r?void 0:r.logicName}),n&&n.$default_group){const t=n.$default_group;for(const[a,n]of t){const t=Number.isNaN(Number(n.value))?0:Number(n.value),o=e.findIndex((t=>t[i]===a));if(o<0){const n={[i]:a,[s]:t};e.push(n)}else Object.assign(e[o],{[s]:t})}}})),this.state.gridHeaders=t,this.state.gridData=e}computeGridData(){this.generator&&this.generator.seriesGenerators&&(1===this.generator.seriesGenerators.length?this.handleSingleSerieGridData():this.handleMultipleSerieGridData())}initChart(t){this.chart=t,this.chart.on("click",(t=>{const e=this.generator.getChartDataByParams(t);e&&this.setActive(e)}))}calcOptions(t=this.state.items){this.options=this.generator.calcOptionsByData(t),this.state.showGrid&&this.computeGridData(),this.updateChart()}updateChart(){if(!this.chart)throw new o("chart对象没有正确初始化");if(!this.options)throw new o("options还没计算");this.chart.setOption(this.options,{notMerge:!0}),this.resizeChart()}resizeChart(){this.chart&&this.chart.resize()}async onDestroyed(){var t;window.removeEventListener("resize",this.resizeChart),await super.onDestroyed(),null==(t=this.chart)||t.dispose()}}),t("CaptionBarController",class extends vr{initState(){super.initState(),this.state.caption=this.view.model.caption}async onCreated(){await super.onCreated(),this.view.evt.on("onViewInfoChange",(({caption:t,dataInfo:e})=>{this.state.caption="".concat(this.view.model.caption).concat(e?"-".concat(e):""),this.setBrowserTabTitle()}))}setBrowserTabTitle(){"ROUTE"!==this.view.modal.mode&&"ROUTE_MODAL"!==this.view.modal.mode||ibiz.util.setBrowserTitle(this.state.caption)}}),class{constructor(t,e){this.deLogicParams=t,this.parameters=e,this.session={},this.params={},this.result=null,this.isEndNode=!1,this.defaultParamName="Default"}get view(){return this.parameters.view}get context(){return Object.prototype.hasOwnProperty.call(this.params,"context")?this.params.context:this.parameters.context}get data(){return this.parameters.data}get viewParam(){return Object.prototype.hasOwnProperty.call(this.params,"viewParam")?this.params.viewParam:this.parameters.params}resetParam(t){var e;null==(e=this.deLogicParams.get(t))||e.calc(this)}renewParam(t){var e;null==(e=this.deLogicParams.get(t))||e.renew(this)}setLastReturn(t){this.lastReturn=t}initLastReturnParam(t){Object.defineProperty(this.params,t,{enumerable:!0,configurable:!0,get:()=>this.lastReturn})}isEntityParam(t){const e=this.deLogicParams.get(t);return!(!e||!e.model.entityParam)}}),Vr=class{};function kr(t,e){const{srcDEUILogicParamId:a,srcFieldName:s,srcValue:n}=e,o=e.srcValueType||"SRCDLPARAM",r=s;let c;switch(o){case"SRCDLPARAM":c=t.params[a];break;case"NULLVALUE":return null;case"NONEVALUE":return;case"SRCVALUE":return ibiz.util.rawValue.format(n);case"WEBCONTEXT":case"VIEWPARAM":c=t.parameters.params;break;case"APPLICATION":case"SESSION":case"APPDATA":case"DATACONTEXT":c=t.parameters.context;break;case"ENVPARAM":c=Z(ibiz.env);break;default:throw new i(e,"暂未支持源值类型".concat(o))}if(c&&r)try{c=Array.isArray(c)?c[Number(r)]:Qe.execScriptFn({srcValue:c},"srcValue.".concat(r),{singleRowReturn:!0,isAsync:!1})}catch(t){throw ibiz.log.error("从源参数取属性".concat(r,"报错,源参数:"),c),t}return c}var zr=class extends Vr{constructor(t){super(),this.model=t,this.srcParam=t.srcLogicParamId,this.dstParam=t.dstLogicParamId}get dstField(){return this.model.dstFieldName}get op(){return this.model.condOP}get type(){return this.model.paramType}get value(){return this.model.paramValue}test(t,e,s){const n=kr(t,{srcDEUILogicParamId:this.dstParam,srcFieldName:this.dstField});let o,r;switch(this.type){case"ENTITYFIELD":{if(!this.value)throw new a(this.model,"当前条件值类型为[数据对象属性],缺少配置条件值");const t=null!=s[this.value]?s[this.value]:e[this.value];r=t,o=Ge(n,this.op,t);break}case"SRCENTITYFIELD":{if(!this.value)throw new a(this.model,"当前条件值类型为[源数据对象属性],缺少配置条件值");const e=kr(t,{srcDEUILogicParamId:this.srcParam,srcFieldName:this.value});r=e,o=Ge(n,this.op,e);break}case"CURTIME":throw new i(this.model,"暂未支持条件值类型为[当前时间]");default:r=this.value,o=Ge(n,this.op,this.value)}return ibiz.log.debug("界面逻辑连接条件项:".concat(this.model.name,"-条件值类型:").concat(this.type,"-源属性名称:").concat(this.dstField,"-源对象值:"),n,"-对比条件:".concat(this.op),"-对比值:",r,"-对比结果:",o),o}},Wr=class t extends Vr{constructor(e){super(),this.model=e;const a=e.deuilogicLinkConds||[];this.conds=a.map((e=>"SINGLE"===e.logicType?new zr(e):new t(e)))}get op(){return this.model.groupOP}get notMode(){return!0===this.model.notMode}test(t,e,i){let s=!0;if(0===this.conds.length)throw new a(this.model,"界面连接条件逻辑组未配置逻辑项");for(let a=0;a<this.conds.length;a++){const n=this.conds[a].test(t,e,i);if("AND"===this.op&&!1===n){s=!1;break}if("OR"===this.op&&!0===n){s=!0;break}}const n=this.notMode?!s:s;return ibiz.log.debug("界面逻辑连接条件组名称:".concat(this.model.name,"-条件组标识:").concat(this.model.id,"-运行结果:"),n),n}},Ur=class{constructor(t){this.model=t,this.srcNode=null,this.dstNode=null,this.groupCond=null;const{linkMode:e,deuilogicLinkGroupCond:a}=this.model;0===(e||0)&&a&&(this.groupCond=new Wr(a))}async exec(t){const{linkMode:e}=this.model,{context:a,data:s}=t;switch(e||0){case 0:return!this.groupCond||this.groupCond.test(t,a,s&&s.length>0?s[0]:{});case 1:return!0;case 2:throw new i(this.model,"未支持的逻辑连接类型: 异步结束");case 3:throw new i(this.model,"未支持的逻辑连接类型: 异步拒绝");case 9:throw new i(this.model,"未支持的逻辑连接类型: 异常处理");default:throw new i(this.model,"未支持的逻辑连接类型:".concat(e))}}},Br=class{constructor(t){this.model=t,this.links=(t.deuilogicLinks||[]).map((t=>new Ur(t)))}},Gr=class extends Br{async exec(t){const{dstAppDataEntityId:e,dstAppDEActionId:i,dstDEUILogicParamId:s,retDEUILogicParamId:n}=this.model;if(!e)throw new a(this.model,"未指定应用实体");if(!i)throw new a(this.model,"未指定实体行为");const o=t.params[s],r=ibiz.hub.getApp(t.context.srfappid),c=await r.deService.exec(e,i,t.context,o,t.viewParam);c.ok&&(t.params[n]=c.data,t.setLastReturn(t.params[n])),ibiz.log.debug("界面逻辑节点(实体行为):".concat(this.model.id,"-界面行为所属实体:").concat(e,"-实体行为标识:").concat(i,"-参数名称:").concat(n,"-值:"),t.params[n])}},jr=class extends Br{async exec(t){const{dstAppDEUIActionId:e,dstDEUILogicParamId:i,dstAppDataEntityId:s}=this.model,{data:n,parameters:o}=t;if(!e)throw new a(this.model,"未配置界面行为");let r=[n];if(i){const e=t.params[i];r=e instanceof Array?e:[e]}ibiz.log.debug("界面逻辑节点(实体界面行为):".concat(this.model.id,"-界面行为标识:").concat(e,"-界面行为所属实体:").concat(s,"-目标逻辑参数对象:").concat(i)),await pc.execAndResolved(e,{...o,context:t.context,params:t.viewParam,data:r},this.model.appId)}},Kr=class extends Br{async exec(t){ibiz.log.debug("界面逻辑节点(启动节点):".concat(this.model.id))}},Xr=class extends Br{async exec(t){t.isEndNode=!0;const{returnType:e,rawValue:a,returnParamId:s}=this.model;if(e){switch(e){case"NONEVALUE":t.result=void 0;break;case"NULLVALUE":t.result=null;break;case"SRCVALUE":t.result=ibiz.util.rawValue.format(a);break;case"LOGICPARAM":t.result=t.params[s];break;default:throw new i(this.model,"暂未支持的结束节点返回值类型: ".concat(e))}ibiz.log.debug("界面逻辑节点(结束节点):".concat(this.model.id,"-返回值类型:").concat(e,"-返回值:"),t.result)}}},Hr=class extends Br{async exec(t){const e=this.model.deuilogicNodeParams;if(null==e?void 0:e.length)for(const a of e){let e;switch(a.dstDEUILogicParamId&&"DEBUG"===ibiz.env.logLevel&&(e=Z(t.params[a.dstDEUILogicParamId])),a.paramAction){case"SETPARAMVALUE":await this.setParamValue(a,t);break;case"RESETPARAM":await this.resetParam(a,t);break;case"COPYPARAM":await this.copyParam(a,t);break;case"BINDPARAM":await this.bindParam(a,t);break;case"RENEWPARAM":await this.renewParam(a,t);break;case"APPENDPARAM":await this.appendParam(a,t);break;case"SORTPARAM":await this.sortParam(a,t);break;default:throw new i(a,"暂未支持逻辑处理参数操作".concat(a.paramAction))}ibiz.log.debug("界面逻辑节点(准备参数):".concat(this.model.id,"-参数处理操作:").concat(a.paramAction,"-目标逻辑参数:").concat(a.dstDEUILogicParamId,"-源参数(值):"),e,"-目标参数(值):",t.params[a.dstDEUILogicParamId])}}setParamValue(t,e){const{dstFieldName:a,dstDEUILogicParamId:i}=t;if(!i)throw new o("没有目标参数对象id");let s=a;e.isEntityParam(i)&&(s=null==s?void 0:s.toLowerCase());const n=kr(e,t);if(s)try{Qe.execScriptFn({srcVal:n,dstParam:e.params[i]},"dstParam.".concat(a," = srcVal"),{singleRowReturn:!1,isAsync:!1})}catch(t){throw ibiz.log.error("给目标参数属性".concat(a,"赋值报错,目标参数:"),e.params[i]),t}else e.params[i]=n}copyParam(t,e){const{dstDEUILogicParamId:a}=t,i=kr(e,t);e.params[a]=Z(i)}bindParam(t,e){const a=kr(e,t);e.params[t.dstDEUILogicParamId]=a}resetParam(t,e){const{dstDEUILogicParamId:a}=t;e.resetParam(a)}renewParam(t,e){const{dstDEUILogicParamId:a}=t;e.renewParam(a)}appendParam(t,e){const{dstDEUILogicParamId:a,dstIndex:i,srcIndex:s,srcSize:n}=t,o=kr(e,t),r=i||0,c=s||0,d=n||o.length;e.params[a].splice(r,0,...o.slice(c,d))}sortParam(t,e){const{dstDEUILogicParamId:a,dstFieldName:i,dstSortDir:s}=t,n=i;e.params[a].sort(((t,e)=>"ASC"===s?t[n]-e[n]:e[n]-t[n]))}},qr=class extends Br{async exec(t){t.isEndNode=!0;const{invokeMethod:e,invokeCtrlId:i,invokeParamId:s}=this.model;if(!i)throw new a(this.model,"没有配置界面对象");if(!s)throw new a(this.model,"没有配置操作参数");if(!e)throw new a(this.model,"没有配置调用方法");const n=t.params[s];if(!n)throw new o("没有找到操作参数".concat(s));const r=t.params[i];if(!r)throw new o("没有找到界面对象".concat(i));if(!r[e]||!q(r[e]))throw new o("没有找到调用方法".concat(e));ibiz.log.debug("界面逻辑节点(视图部件调用):".concat(this.model.id,"-调用视图部件名称:").concat(i,"-调用方法名称:").concat(e,"-触发参数:"),n),await r[e](n)}},Yr=class extends Br{async exec(t){const{dstDEUILogicParamId:e,srcDEUILogicParamId:i}=this.model;if(!e||!i)throw new a(this.model,"缺少目标参数对象或者源参数对象配置");const s=kr(t,this.model);t.params[e]=s,t.setLastReturn(t.params[e]),ibiz.log.debug("界面逻辑节点(绑定参数):".concat(this.model.id,"-参数名称:").concat(e,"-值:"),s)}},Qr=class extends Br{constructor(){super(...arguments),this.typeMap={INFO:"info",QUESTION:"success",WARNING:"warning",ERROR:"error"}}async exec(t){const{msgBoxType:e,buttonsType:s,msgBoxParamId:n}=this.model;if(!e)throw new a(this.model,"缺少消息类型的配置");if(!s)throw new a(this.model,"缺少按钮类型的配置");let{title:o,message:r}=this.model;if(n){const e=t.params[n];e.title&&(o=e.title),e.message&&(r=e.message)}const c=this.typeMap[e],d={type:c,title:o||"消息",desc:r};let l=[];switch(s){case"YESNO":d.confirmButtonText="是",d.cancelButtonText="否",d.showConfirmButton=!0,d.showCancelButton=!0,l=["yes","no"];break;case"OK":d.confirmButtonText="确定",d.showConfirmButton=!0,d.showCancelButton=!1,l=["ok"];break;case"OKCANCEL":d.confirmButtonText="确定",d.cancelButtonText="取消",d.showConfirmButton=!0,d.showCancelButton=!0,l=["ok","cancel"];break;default:throw new i(this.model,"".concat(s,"暂未支持"))}ibiz.log.debug("界面逻辑节点(消息弹窗):".concat(this.model.id,"-消息类型:").concat(c,"-消息:").concat(r));const h=await ibiz.modal.confirm(d);t.setLastReturn(l[h?0:1])}},$r=class extends Br{async exec(t){ibiz.log.debug("界面逻辑节点(前端插件):".concat(this.model.id,"-插件标识:").concat(this.model.sysPFPluginId));const e=await Ds(this.model);e&&await e.exec(this.model,t)}},Jr=class extends Br{async exec(t){const{dstDEUILogicParamId:e,name:i}=this.model;if(!e)throw new a(this.model,"缺少目标参数对象配置");const s=t.params[e];ibiz.log.info("逻辑节点".concat(i,"操作参数值:"),s)}},Zr=class extends Br{async exec(t){const{dstDEUILogicParamId:e}=this.model;if(!e)throw new a(this.model,"缺少目标参数对象配置");t.resetParam(e),t.setLastReturn(t.params[e]),ibiz.log.debug("界面逻辑节点(重置参数):".concat(this.model.id,"-重置参数:").concat(e))}},tc=class extends Br{async exec(t){const{dstDEUILogicParamId:e,srcDEUILogicParamId:i}=this.model;if(!e||!i)throw new a(this.model,"缺少目标参数对象或者源参数对象配置");const s=kr(t,this.model);t.params[e]=Z(s),t.setLastReturn(t.params[e]),ibiz.log.debug("界面逻辑节点(拷贝参数):".concat(this.model.id,"-参数名称:").concat(e,"-值:"),s)}},ec=class extends Br{async exec(t){const{dstDEUILogicParamId:e,srcDEUILogicParamId:i,dstIndex:s,srcIndex:n,srcSize:o}=this.model;if(!e||!i)throw new a(this.model,"缺少目标参数对象或者源参数对象配置");const r=kr(t,this.model),c=s||0,d=n||0,l=o||r.length;t.params[e].splice(c,0,...r.slice(d,l)),t.setLastReturn(t.params[e]),ibiz.log.debug("界面逻辑节点(附加到数组):".concat(this.model.id,"-附加参数:"),t.params,"-附加值:",r.slice(d,l))}},ac=class extends Br{async exec(t){const{dstDEUILogicParamId:e,dstSortDir:i,dstFieldName:s}=this.model;if(!e||!s)throw new a(this.model,"缺少目标参数对象或目标属性配置");const n=s,o=t.params[e];o.sort(((t,e)=>"ASC"===i?t[n]-e[n]:e[n]-t[n])),t.setLastReturn(t.params[e]),ibiz.log.debug("界面逻辑节点(排序数组参数):".concat(this.model.id,"-排序属性:").concat(s,"-排序模式:").concat(i,"-参数名称:").concat(e,"-排序后数组:"),o)}},ic=class extends Br{async exec(t){const{dstDEUILogicParamId:e}=this.model;if(!e)throw new a(this.model,"缺少目标参数对象配置");t.renewParam(e),t.setLastReturn(t.params[e]),ibiz.log.debug("界面逻辑节点(重新建立参数):".concat(this.model.id,"-重建参数:").concat(e))}},sc=class extends Br{async exec(t){const{dstAppDEDataSetId:e,dstAppDataEntityId:i,dstDEUILogicParamId:s,retDEUILogicParamId:n}=this.model;if(!s)throw new a(this.model,"缺少配置过滤参数");const o=t.params[s],r=ibiz.hub.getApp(t.context.srfappid),c=await r.deService.exec(i,e,t.context,o);c.ok&&(t.params[n]=c.data,t.setLastReturn(t.params[s])),ibiz.log.debug("界面逻辑节点(数据集合):".concat(this.model.id,"-数据集实体标识:").concat(i,"-数据集标识:").concat(e,"-参数名称:").concat(n,"-值:"),t.params[n])}},nc=class extends Br{async exec(t){const{errorInfo:e}=this.model;throw ibiz.log.debug("界面逻辑节点(抛出异常):".concat(this.model.id,"-错误信息:").concat(e)),new o(e)}},oc=class extends Br{async exec(t){t.isEndNode=!0;const{eventName:e,eventParamId:i,fireCtrlId:s}=this.model;if(!s)throw new a(this.model,"没有配置触发对象");if(!e)throw new a(this.model,"没有配置事件名称参数");if(!i)throw new a(this.model,"没有配置事件参数");const n=t.params[s];if(!n)throw new o("没有找到触发对象".concat(s));const r=t.params[i];if(!r)throw new o("没有找到事件参数对象".concat(i));ibiz.log.debug("界面逻辑节点(视图部件事件触发逻辑):".concat(this.model.id,"-调用视图部件名称:").concat(s,"-触发事件名称:").concat(e,"-触发参数:"),r),await n.evt.emit(e,r)}},rc=class extends Br{async exec(t){const{dstAppDELogicId:e,dstAppDataEntityId:i,dstDEUILogicParamId:s,retDEUILogicParamId:n}=this.model;if(!i)throw new a(this.model,"没有配置实体");if(!e)throw new a(this.model,"没有配置实体逻辑");if(!s)throw new a(this.model,"没有配置传入逻辑参数");const r=t.params[s];if(!r)throw new o("没有找到传入参数".concat(s));const c=await $n(e,i,t.context,r,t.params);n&&(t.params[n]=c,t.setLastReturn(t.params[n])),ibiz.log.debug("界面逻辑节点(执行实体逻辑):".concat(this.model.id,"-实体逻辑标识:").concat(e,"-实体逻辑所属实体:").concat(i,"-参数名称:").concat(n,"-值:"),c)}},cc=class extends Br{async exec(t){ibiz.log.debug("界面逻辑节点(直接代码):".concat(this.model.id,"-直接代码:"),this.model.code),Qe.execScriptFn({view:t.view,context:t.context,params:t.viewParam,uiLogic:t.params},this.model.code||"",{isAsync:!1})}},dc=class{constructor(t){this.model=t}calc(t){const e=this.model.id,a=this.model,{parameters:i}=t,{context:s,params:n,data:o}=i,r=ibiz.hub.getApp(a.appId);if("layoutPanel"!==a.codeName){if(a.default)a.entityListParam?t.params[e]=o||[]:t.params[e]=o&&o.length>0?o[0]:{};else if(a.activeContainerParam)t.params[e]=i.ctrl||i.view;else if(a.activeCtrlParam)t.params[e]=i.ctrl;else if(a.ctrlParam){const s=i.view.getController(a.codeName.toLowerCase());s?t.params[e]=s:ibiz.log.error("视图逻辑初始化参数,未找到".concat(a.codeName,"指定部件对象"))}else if(a.activeViewParam)t.params[e]=i.view;else if(a.appGlobalParam){let i=ibiz.util.getGlobalParam();a.paramFieldName&&(i=i[a.paramFieldName]),t.params[e]=i}else if(a.applicationParam)t.params[e]=r;else if(a.entityListParam)t.params[e]=[];else if(a.entityPageParam)t.params[e]=[];else if(a.entityParam)t.params[e]={};else if(a.lastReturnParam)t.initLastReturnParam(e);else if(a.navContextParam)t.params[e]=s;else if(a.navViewParamParam)t.params[e]=ibiz.util.getRouterParams();else if(a.routeViewSessionParam){let s=i.view.getTopView().state;a.paramFieldName&&(s=s[a.paramFieldName]),t.params[e]=s}else if(a.simpleListParam)t.params[e]=[];else if(a.simpleParam)t.params[e]={};else if(a.viewNavDataParam)t.params[e]=n;else if(a.viewSessionParam){let s=i.view.state;a.paramFieldName&&(s=s[a.paramFieldName]),t.params[e]=s}else a.filterParam?t.params[e]={}:a.envParam?t.params[e]=ibiz.env:a.sessionParam&&(t.params[e]=t.session);ibiz.log.debug("计算界面逻辑参数,标识:".concat(e),"-值:",t.params[e])}else t.params[e]=i.view.layoutPanel.panelItems}renew(t){const e=this.model.id,a=this.model;if(a.entityListParam||a.simpleListParam||a.entityPageParam)t.params[e]=[];else{if(!a.simpleParam&&!a.entityParam)throw new i(a,"未支持的逻辑参数类型重新建立变量");t.params[e]={}}ibiz.log.debug("重新建立界面逻辑参数,标识:".concat(e),"-值:",t.params[e])}},lc=class{constructor(t){var e;if(this.model=t,this.nodes=new Map,this.params=new Map,!(null==(e=t.deuilogicNodes)?void 0:e.length))throw new a(t,"界面逻辑没有配置逻辑节点");t.deuilogicNodes.forEach((t=>{const{logicNodeType:e}=t;let a;switch(e){case"BEGIN":a=new Kr(t);break;case"END":a=new Xr(t);break;case"DEACTION":a=new Gr(t);break;case"DEUIACTION":a=new jr(t);break;case"PREPAREJSPARAM":a=new Hr(t);break;case"RESETPARAM":a=new Zr(t);break;case"COPYPARAM":a=new tc(t);break;case"BINDPARAM":a=new Yr(t);break;case"VIEWCTRLINVOKE":a=new qr(t);break;case"MSGBOX":a=new Qr(t);break;case"DEBUGPARAM":a=new Jr(t);break;case"APPENDPARAM":a=new ec(t);break;case"SORTPARAM":a=new ac(t);break;case"RENEWPARAM":a=new ic(t);break;case"DEDATASET":a=new sc(t);break;case"THROWEXCEPTION":a=new nc(t);break;case"VIEWCTRLFIREEVENT":a=new oc(t);break;case"DELOGIC":a=new rc(t);break;case"PFPLUGIN":a=new $r(t);break;case"RAWJSCODE":a=new cc(t);break;default:throw new i(t,"未支持的逻辑节点类型: ".concat(e))}this.nodes.set(t.id,a)})),t.deuilogicParams.forEach((t=>{this.params.set(t.id,new dc(t))})),this.nodes.forEach((t=>{t.links.forEach((e=>{e.srcNode=t,this.nodes.has(e.model.dstDEUILogicNodeId)&&(e.dstNode=this.nodes.get(e.model.dstDEUILogicNodeId))}))}))}initLogicParams(t){this.params.forEach((e=>{e.model.default&&(t.defaultParamName=e.model.id),e.calc(t)}))}async exec(t){const e=new Fr(this.params,t);this.initLogicParams(e);const{startDEUILogicNodeId:i}=this.model;if(!i||!this.nodes.has(i))throw new a(this.model,"未设置起始节点");{const t=this.nodes.get(i);await this.deepExec(t,e)}return e.isEndNode?e.result:e.params[e.defaultParamName]?e.params[e.defaultParamName]:null}async deepExec(t,e){await t.exec(e);const{links:a}=t;for(let i=0;i<a.length;i++){const s=a[i];if(await s.exec(e)&&s.dstNode&&(await this.deepExec(s.dstNode,e),!0!==t.model.parallelOutput))break}}},hc=new Map;async function uc(t,e,a){const i=ibiz.hub.getApp(a.context.srfappid),s=await i.getDEUILogic(t,e);if(!s)throw new o("找不到实体".concat(e,"的界面逻辑").concat(t));hc.has(s)||hc.set(s,new lc(s)),ibiz.log.debug("开始执行界面逻辑,实体:".concat(e,"-逻辑名称:").concat(s.name));const n=hc.get(s),r=await n.exec(a);return ibiz.log.debug("结束执行界面逻辑,实体:".concat(e,"-逻辑名称:").concat(s.name)),r}var pc=t("UIActionUtil",class{static async exec(t,e,a){const i=await Ae(t,a);if(!i)throw new o("没找到".concat(t,"的界面行为模型"));if("SINGLEDATA"===i.actionTarget){if(!1===await e.view.call("Validate"))return{cancel:!0}}return(await vs(i)).exec(i,e)}static async execAndResolved(t,e,a){var i,s;const n=await this.exec(t,e,a);if(n.closeView)e.view.modal.ignoreDismissCheck=!0,e.view.closeView({ok:!0});else if(n.refresh)switch(n.refreshMode){case 1:e.view.callUIAction("Refresh");break;case 2:null==(i=e.view.parentView)||i.callUIAction("Refresh");break;case 3:null==(s=e.view.getTopView())||s.callUIAction("Refresh")}(await Ae(t,a)).asyncAction&&!n.cancel&&this.handleAsyncAction(e.event)}static async handleAsyncAction(t){this.handleAsyncActionAnime(t)}static async handleAsyncActionAnime(t){t&&t.target&&await ibiz.util.anime.moveAndResize(t.target,"#".concat("preset-message"))}}),mc=t("UIActionProviderBase",class{async exec(t,e){const i={refresh:t.reloadData,refreshMode:t.refreshMode,closeView:t.closeEditView},{view:s}=e;t.closeEditView&&(s.state.isClosing=!0);const{appDEUILogicId:n,appDataEntityId:o,uilogicAttachMode:r}=t;if("REPLACE"===r){if(!n)throw new a(t,"没有配置实体界面逻辑");return await uc(n,o,e),i}if(!await this.isConfirm(t,e))return this.returnError(i,s);const c=await this.execAction(t,e);if(Object.assign(i,c),!0===i.cancel)return this.returnError(i,s);if("AFTER"===t.uilogicAttachMode){if(!n)throw new a(t,"没有配置实体界面逻辑");await uc(n,o,this.mergeArgsByResult(e,i))}const d=this.mergeArgsByResult(e,i);if(t.closeEditView)this.doNextAction(t,d,t.appId);else{const e=await this.doNextAction(t,d,t.appId);if(e&&(Object.assign(i,e),!0===e.cancel))return this.returnError(i,s)}return i}mergeArgsByResult(t,e){return{...t,context:e.nextContext||t.context,data:e.data||t.data,params:e.nextParams||t.params}}returnError(t,e){return e.state.isClosing=!1,Object.assign(t,{refresh:!1,closeView:!1})}async isConfirm(t,e){const a=this.calcMessage("confirm",t,e);return!t.enableConfirm||!a||ibiz.confirm.warning({title:"操作确认",desc:a})}async doNextAction(t,e,a){const i=t.nextId;if(i)return pc.exec(i,e,a)}async handleParams(t,e,a,i){let s=[];const n=ve(t.appDataEntityId),o=(await ibiz.hub.getAppDataEntity(t.appDataEntityId,e.srfappid)).keyAppDEFieldId;switch(t.actionTarget){case"NONE":s=[];break;case"SINGLEDATA":s=[a[0]];break;case"MULTIDATA":s=a;break;case"MULTIKEY":s=n&&a.length>0?a.map((t=>({[o]:t.srfkey||t[o]}))):[{}];break;case"SINGLEKEY":{const t=a[0]||{};s=n?[{[o]:t.srfkey||t[o]}]:[{}]}}const r=e.clone(),c=[...t.navigateContexts||[]];if(n&&"NONE"!==t.actionTarget){const{valueItem:e,paramItem:a}=t,i=a||n,s=e||"srfkey";c.unshift({key:i,value:s,rawValue:!1})}const d=["MULTIKEY","MULTIDATA"].includes(t.actionTarget)&&a.length>0,l=oe(c,d?de(c,a):a[0]||{},i,e);Object.assign(r,l);const h=t.navigateParams;return{resultContext:r,resultData:s,resultParams:oe(h,d?de(h,a):a[0]||{},i,r)}}calcMessage(t,e,a){let i,s;const{confirmMsg:n,cmlanguageRes:o,successMsg:r,smlanguageRes:c}=e;switch(t){case"confirm":i=n,s=o;break;case"success":i=r,s=c}if(s){const t=ibiz.i18n.t(s.lanResTag,s.defaultContent||i);t!==s.lanResTag&&(i=t)}if(i){const{data:t}=a,e={...a};return 1===t.length?[e.data]=t:0===t.length&&delete e.data,Qe.execScriptFn(e,"`".concat(i,"`"),{isAsync:!1,singleRowReturn:!0})}}handleViewOptionParams(t){if(t.modaloption)try{const e=JSON.parse(t.modaloption);return delete t.modaloption,{modalOption:e}}catch(t){ibiz.log.error("视图参数modalOption 解析失败:".concat(t))}return{}}}),fc=t("BackendUIActionProvider",class extends mc{async execAction(t,e){const{context:i,params:s,data:n,event:o}=e,r={},c=t.appDataEntityId,d=t.appDEMethodId;if(!c||!d)throw new a(t,"未配置实体或实体行为");const{resultContext:l,resultParams:h,resultData:u}=await this.handleParams(t,i,n,s),p={...h},m=t.frontAppViewId;if(m){const t=this.handleViewOptionParams(h),e=await ibiz.commands.execute(No.TAG,m,l,h,{event:o,...t});if(!(null==e?void 0:e.ok))return r.cancel=!0,r;if((null==e?void 0:e.ok)&&e.data){0===u.length&&u.push({});const t=e.data.map((t=>{var e;return(null==(e=t.getOrigin)?void 0:e.call(t))||t||{}}));u.forEach((e=>{e.srfactionparam=t}))}}const f=ibiz.hub.getApp(null==i?void 0:i.srfappid),g=u.map((t=>{var e;return(null==(e=t.getOrigin)?void 0:e.call(t))||t||{}})).map((t=>Object.assign(t,p))),w=["MULTIKEY","MULTIDATA"].includes(t.actionTarget),E=await f.deService.exec(c,d,l,w?g:g[0],p);if(E.ok){const a=this.calcMessage("success",t,e);a&&ibiz.message.success(a)}return Object.assign(r,{data:lt(E.data)?E.data:[E.data],nextContext:l,nextParams:p}),r}}),gc=t("SysUIActionProvider",class extends mc{constructor(){super(...arguments),this.predefinedActionMap=new Map([["EDITVIEW_EXITACTION","Exit"],["EDITVIEW_SAVEANDEXITACTION","SaveAndExit"],["TREEVIEW_REFRESHPARENTACTION","RefreshParent"],["GRIDVIEW_EXPORTXMLACTION","ExportModel"],["GRIDVIEW_EXPORTACTION","ExportExcel"],["EDITVIEW_REMOVEANDEXITACTION","RemoveAndExit"],["GRIDVIEW_PRINTACTION","Print"],["EDITVIEW_NEXTRECORDACTION","NextRecord"],["GRIDVIEW_NEWROWACTION","NewRow"],["EDITVIEW_LASTRECORDACTION","LastRecord"],["EDITVIEW_PREVRECORDACTION","PrevRecord"],["GRIDVIEW_SEARCHBAR","ToggleFilter"],["EDITVIEW_SAVEANDSTARTWFACTION","SaveAndStart"],["EDITVIEW_NEWACTION","New"],["EDITVIEW_PRINTACTION","Print"],["EDITVIEW_COPYACTION","Copy"],["EDITVIEW_HELPACTION","Help"],["EDITVIEW_FIRSTRECORDACTION","FirstRecord"],["GRIDVIEW_REFRESHACTION","Refresh"],["EDITVIEW_SAVEANDNEWACTION","SaveAndNew"],["EDITVIEW_VIEWWFSTEPACTORACTION","ViewWFStep"],["EDITVIEW_SAVEACTION","Save"],["TREEVIEW_REFRESHALLACTION","RefreshAll"],["GRIDVIEW_IMPORTBAR","Import"],["GRIDVIEW_ROWEDITACTION","ToggleRowEdit"],["GRIDVIEW_NEWACTION","New"],["GRIDVIEW_EDITACTION","Edit"],["GRIDVIEW_HELPACTION","Help"],["EDITVIEW_REFRESHACTION","Refresh"],["GRIDVIEW_REMOVEACTION","Remove"],["GRIDVIEW_COPYACTION","Copy"],["GRIDVIEW_VIEWACTION","View"],["GRIDVIEW_SAVEROWACTION","SaveRow"],["APP_LOGIN","Login"],["APP_LOGOUT","logout"],["UTIL_RESET","Reset"],["UTIL_SEARCH","Search"]])}async execAction(t,e){const{view:a}=e,i=this.predefinedActionMap.get(t.predefinedType)||t.uiactionTag;if("Exit"===i)return{closeView:!0};return await a.callUIAction(i,e)||{}}}),wc=t("FrontUIActionProvider",class extends mc{async execAction(t,e){const{context:s,params:n,data:o,event:r,noWaitRoute:c}=e;let d={};switch(t.frontProcessType){case"OPENHTMLPAGE":{const e=D.fill(t.htmlPageUrl,s,null==o?void 0:o[0]);window.open(e,"_blank");break}case"TOP":case"WIZARD":{const e=t.frontAppViewId;if(!e)throw new a(t,"未配置打开视图");const{resultContext:i,resultParams:l}=await this.handleParams(t,s,o,n),h=this.handleViewOptionParams(l),u=await ibiz.commands.execute(No.TAG,e,i,l,{event:r,noWaitRoute:c,...h});(null==u?void 0:u.ok)||(d.cancel=!0),(null==u?void 0:u.ok)&&u.data&&(d.data=u.data,d.nextContext=i,d.nextParams={...n,...l});break}case"PRINT":await this.executePrint(t,e);break;case"DATAIMP":d=await this.executeDataImport(t,e);break;case"DATAEXP":await this.executeDataExport(t,e);break;case"OTHER":d=this.doOther(t,e);break;case"EDITFORM":d=await this.openEditForm(t,e);break;default:throw new i(t,"未支持的前台处理模式[".concat(t.frontProcessType,"]"))}return d}doOther(t,e){const{scriptCode:i}=t,{context:s,params:n,data:o,event:r,view:c}=e;if(i){return Qe.execScriptFn({context:s,params:n,data:o,el:null==r?void 0:r.target,view:c},i)||{}}throw new a(t,"自定义类型缺少配置脚本代码")}async executePrint(t,e){var a,i;const{resultContext:s,resultParams:n}=await this.handleParams(t,e.context,e.data,e.params),r=await ibiz.hub.getAppDataEntity(t.appDataEntityId,t.appId),c=null==(a=r.appDEPrints)?void 0:a.find((e=>e.id===t.appDEPrintId));if(!c)throw new o("没有找到实体打印项");{let t="";if(!s||!s[r.codeName.toLowerCase()])throw new o("没有找到数据主键");t+="/".concat(r.deapicodeName2,"/printdata/").concat(s[r.codeName.toLowerCase()]);const e=await ibiz.net.request(t,{method:"get",responseType:"blob",params:{srfprinttag:c.codeName,...n}});if(!e.ok)throw new o("打印失败");if(n&&n.srfcontenttype){const t=null==(i=e.headers["content-disposition"].split(";").find((t=>-1!==t.indexOf("filename="))))?void 0:i.slice(9),a=URL.createObjectURL(e.data),s=document.createElement("a");s.href=a,s.download=t,document.body.appendChild(s),s.click(),document.body.removeChild(s),URL.revokeObjectURL(a)}else{const t=window.URL.createObjectURL(e.data);window.open(t,"_blank")}}}async executeDataImport(t,e){const{resultContext:i,resultParams:s}=await this.handleParams(t,e.context,e.data,e.params),{appDataEntityId:n,appDEDataImportId:o,frontAppViewId:r}=t;if(!n||!o)throw new a(t,"没有配置导入模型!");return await hr({appDataEntityId:n,deDataImportId:o,dataImportViewId:r,context:i,params:s}),{refresh:!0,refreshMode:1}}async executeDataExport(t,e){var a;const{resultParams:i}=await this.handleParams(t,e.context,e.data,e.params),s=await ibiz.hub.getAppDataEntity(t.appDataEntityId,t.appId),n=null==(a=s.appDEDataExports)?void 0:a.find((e=>e.id===t.appDEDataExportId));if(!n)throw new o("没有找到实体导出项");{const t="/".concat(s.deapicodeName2,"/exportdata/fetchdefault?srfexporttag=").concat(n.codeName),a={page:0,size:n.maxRowCount?n.maxRowCount:1e3,...e.params,...i},r=await ibiz.net.request(t,{method:"post",data:a});if(200!==r.status)throw new o("导出请求失败");{let t="".concat(s.logicName,"表.xlsx");t=decodeURIComponent(t);const e=new Blob([r.data],{type:"application/vnd.ms-excel"}),a=document.createElement("a");a.download=t,a.style.display="none",a.href=URL.createObjectURL(e),document.body.appendChild(a),a.click(),URL.revokeObjectURL(a.href),document.body.removeChild(a)}}}async openEditForm(t,e){const a={},{context:i,params:s,data:n,event:r}=e;if(!r)throw new o("缺少原生JS事件对象");const{resultContext:c,resultParams:d}=await this.handleParams(t,i,n,s),l=this.handleViewOptionParams(d).modalOption||{},h=$({autoClose:!0},l);let u=!1;const p=ibiz.overlay.createPopover("IBizControlShell",{context:c,params:d,modelData:t.deeditForm,onSaveSuccess:t=>{a.data=[t.args],p&&p.dismiss(),u=!0}},h);return p.present(r.target),await p.onWillDismiss(),u||(a.cancel=!0),a}}),Ec=t("WFWithdrawUIActionProvider",class extends mc{async execAction(t,e){const{view:a}=e;let i=!1;return await ibiz.modal.confirm({title:"提示",desc:"是否确认执行撤回操作?"})&&a&&(await a.call("WFWithdraw",e),i=!0),{refresh:!1,closeView:i}}}),yc=class extends mc{async execAction(t,e){if(await ibiz.confirm.info({title:"退出登录",desc:"您确定要退出登录吗?"})){await ibiz.hub.controller.logout()&&window.location.reload()}return{}}};function vc(){const t=new wc;Es("FRONT",(()=>t));const e=new fc;Es("BACKEND",(()=>e));const a=new gc;Es("SYS",(()=>a));const i=new Ec;Es("DEUIACTION_WFWithdraw",(()=>i));const s=new yc;Es("SYS_Logout",(()=>s))}var Ic=t("ToolbarController",class extends vr{get _evt(){return this.evt}initState(){super.initState(),this.state.buttonsState=new qo,this.state.viewMode="EMBED",this.state.extraButtons={}}async doUIAction(t,e,a={}){if("DEUIACTION"===t.itemType){const i=t.uiactionId,s=await Ae(i,t.appId);if(!s)throw new o("没有找到界面行为模型".concat(i));const n=["SYS","BACKEND","WFBACKEND"].includes(s.uiactionMode)&&!1!==s.showBusyIndicator;n&&this.state.buttonsState.setLoading(t.id);try{const s=await this.ctx.view.call("GetData")||[],n=this.getEventArgs();n.params=Object.assign(a,n.params),await pc.execAndResolved(i,{...n,data:s,event:e},t.appId)}finally{n&&this.state.buttonsState.setLoading("")}}}async onCreated(){await super.onCreated(),this.state.viewMode=this.ctx.view.modal.mode,r(this.model,(t=>{if(t.itemType){const e=t,a=new Ho(e.id,this.context.srfappid,e.uiactionId);this.state.buttonsState.addState(e.id,a)}if(t.controlLogics)for(let e=0;e<t.controlLogics.length;e++){const a=t.controlLogics[e],i=this.state.buttonsState[t.id];if(a.itemName===t.id&&"ITEMVISIBLE"===a.triggerType&&i){i.visible=!1;break}}}),{childrenFields:["detoolbarItems"]}),this.state.manualCalcButtonState?await this.state.buttonsState.init():await this.calcButtonState(void 0,this.model.appDataEntityId)}async onItemClick(t,e,a){const i="extra"===t.buttonType;await this._evt.emit("onClick",{event:e,eventArg:t.id,buttonType:i?"extra":"deuiaction"}),i||await this.doUIAction(t,e,a)}async calcButtonState(t,e){let a=t;if(t&&t instanceof En&&(a=t.getOrigin()),await this.state.buttonsState.update(this.context,a,e),this.scheduler){const t={};a&&(t.data=[a]),r(this.model,(e=>{const a=this.state.buttonsState[e.id];if(a){if(a.visible){const i=this.scheduler.triggerItemVisible(e.id,t);void 0!==i&&(a.visible=i)}if(!a.disabled){const i=this.scheduler.triggerItemEnable(e.id,t);void 0!==i&&(a.disabled=!i)}}}),{childrenFields:["detoolbarItems"]})}}setExtraButtons(t,e){this.state.extraButtons[t]||(this.state.extraButtons[t]=[]),this.state.extraButtons[t].push(...e)}clearExtraButtons(t){void 0===t?this.state.extraButtons={}:this.state.extraButtons[t]=[]}initControlScheduler(t=[]){const e=[...t];r(this.model,(t=>{t.controlLogics&&e.push(...t.controlLogics)}),{childrenFields:["detoolbarItems"]}),super.initControlScheduler(e)}convertMultipleLanguages(){const t=e=>{e.forEach((e=>{e.capLanguageRes&&e.capLanguageRes.lanResTag&&(e.caption=ibiz.i18n.t(e.capLanguageRes.lanResTag,e.caption)),"ITEMS"===e.itemType&&e.detoolbarItems&&t(e.detoolbarItems)}))};this.model.detoolbarItems&&this.model.detoolbarItems.length>0&&t(this.model.detoolbarItems)}}),Dc=t("ContextMenuController",class extends Ic{}),Cc=(t("DashboardController",class extends vr{constructor(){super(...arguments),this.providers={},this.portlets={}}initState(){super.initState()}async onCreated(){await super.onCreated(),await this.initPortlets(this.model.controls);const{appDataEntityId:t}=this.view.model;t&&this.view.evt.on("onDataChange",(t=>{const e=Zo(t.data);e&&this.dataChangeNotify(e)}))}async initPortlets(t,e){if(!(null==t?void 0:t.length))return;const a=["CHART","APPMENU","TOOLBAR","LIST"];await Promise.all(t.map((async t=>{var i;if(t.controlType&&a.includes(t.controlType))return;const s=await gs(t);if(s){this.providers[t.id]=s;const a=await s.createController(t,this,e);this.portlets[t.id]=a,(null==(i=t.controls)?void 0:i.length)&&await this.initPortlets(t.controls,a)}})))}async dataChangeNotify(t){await ba(Object.values(this.portlets).map((async e=>e.dataChangeNotify(t))))}}),t("CustomDashboardController",class{constructor(t){var e,a;this.customModelData=[],this.layoutColNum=12,this.layoutRowH=80,this.model=null,this.model=t,this.config=new dn(t.appId,"dynadashboard","dashboard_".concat((null==(e=this.model.appDataEntityId)?void 0:e.toLowerCase())||"app","_").concat(null==(a=this.model.codeName)?void 0:a.toLowerCase()))}async loadCustomModelData(){const t=await this.config.load();return t.model&&(this.customModelData=t.model),t.colNum&&(this.layoutColNum=t.colNum),t.rowH&&(this.layoutRowH=t.rowH),this.customModelData}async saveCustomModelData(t){return await this.config.save({model:t,colNum:this.layoutColNum,rowH:this.layoutRowH})&&(this.customModelData=t),t}}),t("PortletPartState",class{constructor(){this.visible=!0,this.keepAlive=!1,this.layout={width:"",height:"",extraStyle:{},extraClass:[],contentStyle:{}},this.class={container:[],containerDyna:[]},this.actionGroupState=null}})),bc=t("PortletPartController",class{get context(){return this.dashboard.context}get params(){return this.dashboard.params}get containerClass(){return[...this.state.class.container,...this.state.class.containerDyna]}constructor(t,e,a){this.model=t,this.dashboard=e,this.parent=a,this.state=this.createState()}async init(){await this.onInit()}async onInit(){this.onDataChange=this.onDataChange.bind(this);const{layoutPos:t,sysCss:e}=this.model;if(t){const{width:t,height:e}=ge(this.model);this.state.layout.width="".concat(t),this.state.layout.height="".concat(e)}(null==e?void 0:e.cssName)&&this.state.class.container.push(e.cssName),await this.initActionStates()}createState(){return new Cc}onDataChange(t){let e=t.data[0];e&&e instanceof En&&(e=e.getOrigin()),e&&this.state.actionGroupState.update(this.context,e,this.dashboard.view.model.appDataEntityId)}async initActionStates(){var t;const{uiactionGroup:e}=this.model;if(!(null==(t=null==e?void 0:e.uiactionGroupDetails)?void 0:t.length))return;const a=new qo;e.uiactionGroupDetails.forEach((t=>{const e=t.uiactionId;if(e){const i=new Ho(t.id,this.dashboard.context.srfappid,e);a.addState(t.id,i)}})),await a.update(this.dashboard.context),this.state.actionGroupState=a;const{appDataEntityId:i}=this.dashboard.view.model;i&&this.dashboard.view.evt.on("onDataChange",this.onDataChange)}async onActionClick(t,e,a=[]){const i=t.uiactionId;await pc.execAndResolved(i,{context:this.dashboard.context,params:this.dashboard.params,data:a,view:this.dashboard.view,event:e},t.appId)}async dataChangeNotify(t){if(this.state.actionGroupState){const{appDataEntityId:e}=this.dashboard.view.model;this.state.actionGroupState.update(this.context,t,e)}this.calcDynaClass(t)}calcDynaClass(t){if(this.model.dynaClass){const e=we(this.model.dynaClass,t);e.length&&(this.state.class.containerDyna=e)}}async destroyed(){ibiz.log.debug("".concat(this.model.codeName," onDestroyed")),this.dashboard.view.evt.off("onDataChange",this.onDataChange)}}),Ac=(t("ContainerPortletController",class extends bc{}),t("ViewPortletController",class extends bc{}),t("MenuPortletController",class extends bc{}),t("ChartPortletController",class extends bc{}),t("ActionBarPortletController",class extends bc{}),t("HtmlPortletController",class extends bc{}),t("ListPortletController",class extends bc{}),t("RawItemPortletController",class extends bc{}),t("DataViewControlService",class extends vn{initUIDataMap(){var t;super.initUIDataMap(),null==(t=this.model.dedataViewDataItems)||t.forEach((t=>{const e=t.id.toLowerCase(),a=t.appDEFieldId;let i;if(a){const s=a.toLowerCase();i=new fo(e,s,{isOriginField:!0,dataType:t.dataType})}else i=new fo(e,e);this.dataUIMap.set(e,i)}))}})),Pc=t("DataViewControlController",class extends Ir{get enableNew(){return!0===this.model.enableCardNew}initState(){super.initState(),this.state.noSort=!0===this.model.noSort,this.state.size=this.model.pagingSize||20,this.state.singleSelect=!0===this.model.singleSelect,this.state.sortItems=[]}async onCreated(){await super.onCreated(),await this.initControlService(),this.initSortItems()}async initControlService(){this.service=new Ac(this.model),await this.service.init(this.context)}async initGroupActionStates(){var t;const{groupUIActionGroup:e}=this.model;(null==(t=null==e?void 0:e.uiactionGroupDetails)?void 0:t.length)&&this.state.groups.forEach((async t=>{const a=new qo;e.uiactionGroupDetails.forEach((t=>{const e=t.uiactionId;if(e){const i=new Ho(t.id,this.context.srfappid,e);a.addState(t.id,i)}})),await a.update(this.context),t.groupActionGroupState=a}))}async onRowClick(t){var e;super.onRowClick(t);const{groupAppDEFieldId:a}=this.model;if(a)if(this.state.groups.forEach((t=>{t.selectedData=[]})),this.state.selectedData.forEach((t=>{const e=t[a],i=this.state.groups.find((t=>t.key===e));i&&i.selectedData.push(t)})),this.state.singleSelect)this.state.groups.forEach((e=>{var a,i;let s=t;-1!==e.selectedData.indexOf(s)?(s&&s instanceof En&&(s=s.getOrigin()),s&&(null==(a=e.groupActionGroupState)||a.update(this.context,s,this.model.appDataEntityId))):null==(i=e.groupActionGroupState)||i.update(this.context,void 0,this.model.appDataEntityId)}));else{const a=this.state.groups.find((e=>-1!==e.children.indexOf(t)));a&&(null==(e=a.groupActionGroupState)||e.update(this.context,a.selectedData[0],this.model.appDataEntityId))}}async loadMore(){this.state.total>this.state.items.length&&await this.load({isLoadMore:!0})}async afterLoad(t,e){return await this.initGroupCodeListItems(),await this.handleDataGroup(),await this.initGroupActionStates(),e}getOptItemModel(){let t=null;const{dedataViewItems:e}=this.model;if(e)for(let a=0;a<e.length;a++)"ACTIONITEM"===e[a].itemType&&(t=e[a]);return t}getOptItemAction(t){var e;const i=new qo,s=this.getOptItemModel();if(s){if(!s.deuiactionGroup)throw new a(this.model,"操作项没有配置界面行为组");if(!(null==(e=s.deuiactionGroup.uiactionGroupDetails)?void 0:e.length))return ibiz.log.debug("操作项界面行为组没有配置界面行为"),i;s.deuiactionGroup.uiactionGroupDetails.forEach((t=>{const e=t.uiactionId;if(e){const a=new Ho(t.id,this.context.srfappid,e);i.addState(t.id,a)}})),i.update(this.context,t.getOrigin())}return i}async onActionClick(t,e,a){const i=t.uiactionId;await pc.execAndResolved(i,{context:this.context,params:this.params,data:[e],view:this.view,event:a},t.appId)}async handleDataGroup(){const{enableGroup:t,groupMode:e,groupAppDEFieldId:i}=this.model;if(t&&e){if(!i)throw new a(this.model,"分组属性没有配置");"AUTO"===e?this.handleAutoGroup():"CODELIST"===e&&await this.handleCodeListGroup()}}handleAutoGroup(){const{groupAppDEFieldId:t}=this.model;if(t){const{items:e}=this.state,a=new Map;e.forEach((e=>{const i=e[t];Q(i)||(a.has(i)||a.set(i,[]),a.get(i).push(e))}));const i=[];a.forEach(((t,e)=>{i.push({caption:e,key:e,children:[...t]})})),this.state.groups=i}}async initGroupCodeListItems(){const{groupCodeListId:t}=this.model;if(!t)return;const e=ibiz.hub.getApp(this.context.srfappid);this.groupCodeListItems=await e.codeList.get(t,this.context,this.params)}async handleCodeListGroup(){const{groupAppDEFieldId:t,groupCodeListId:e}=this.model;if(!e)throw new a(this.model,"分组代码表没有配置");const{items:i}=this.state,s=new Map;this.groupCodeListItems.forEach((t=>{s.set(t.value,[])})),i.forEach((e=>{const a=e[t],i=s.get(a);i&&i.push(e)}));const n=[];s.forEach(((t,e)=>{const a=this.groupCodeListItems.find((t=>t.value===e));n.push({caption:a.text,key:a.value,children:t})})),this.state.groups=n}getSortModel(){return{minorSortAppDEFieldId:this.model.minorSortAppDEFieldId,minorSortDir:this.model.minorSortDir}}onClickNew(t,e){const a={...this.params,srfgroup:e};pc.execAndResolved("new",{context:this.context,params:a,data:[],view:this.view,event:t},this.view.model.appId)}async onGroupToolbarClick(t,e,a){const i=t.uiactionId,s={...this.params,srfgroup:a.key};await pc.execAndResolved(i,{context:this.context,params:s,data:a.selectedData||[],view:this.view,event:e},t.appId)}initSortItems(){var t;if(!(null==(t=this.model.dedataViewItems)?void 0:t.length))return;const e=[],{minorSortAppDEFieldId:i,minorSortDir:s}=this.model,n=i&&s;this.model.dedataViewItems.forEach((t=>{if(!t.enableSort)return;let{caption:o}=t;if(t.capLanguageRes&&(o=ibiz.i18n.t(t.capLanguageRes.lanResTag,t.caption)),!t.appDEFieldId)throw new a(t,"启用排序的项必须关联实体属性");const r={caption:o,key:t.appDEFieldId};n&&i===t.appDEFieldId&&(r.order=s.toLowerCase()),e.push(r)})),e.length>0&&(this.state.sortItems=e)}}),Tc=t("ExpBarControlController",class extends vr{constructor(){super(...arguments),this.navKeyName="srfkey"}get _evt(){return this.evt}get routeDepth(){return this.view.modal.routeDepth}initState(){super.initState(),this.state.query=""}load(){return this.xDataController.load({isInitialLoad:!0})}get xDataController(){const t=this.view.getController(this.model.xdataControlName);if(!t)throw new a(this.model,"无法获取多数据部件[".concat(this.model.xdataControlName,"]控制器"));return t}get toolbarController(){return this.view.getController("".concat(this.model.xdataControlName.split("_")[0],"_toolbar"))}get XDataModel(){var t;return null==(t=this.model.controls)?void 0:t.find((t=>t.name===this.model.xdataControlName))}get isCache(){return"CACHE"===this.controlParams.expcache||"NO_CACHE"!==this.controlParams.expcache&&ibiz.config.view.expCacheMode.includes(this.model.controlType)}async onCreated(){var t;await super.onCreated(),this.childNames.push(this.model.xdataControlName);const e=await ibiz.hub.getAppDataEntity(this.model.appDataEntityId,this.context.srfappid);if(e){const a=null==(t=e.appDEFields)?void 0:t.filter((t=>t.enableQuickSearch)),i=[];null==a||a.forEach((t=>{(null==t?void 0:t.lnlanguageRes)&&t.lnlanguageRes.lanResTag?i.push(ibiz.i18n.t(t.lnlanguageRes.lanResTag,t.logicName)):(null==t?void 0:t.logicName)&&i.push(t.logicName)})),i.length>0&&(this.state.placeHolder=i.join("、"))}}async onMounted(){super.onMounted(),this.xDataController&&(this.xDataController.evt.on("onActive",(t=>{this.xDataActive(t)})),this.xDataController.evt.on("onLoadSuccess",(t=>{this.xDataLoadSuccess(t)})),this.xDataController.evt.on("onRemoveSuccess",(()=>{this.navByFirstItem()}))),this.toolbarController&&this.xDataController.evt.on("onSelectionChange",(async t=>{this.toolbarController.calcButtonState(t.data[0],this.model.appDataEntityId)})),this.state.loadDefault&&this.load()}xDataLoadSuccess(t){if(t.isInitialLoad)this.state.srfnav&&this.routeDepth?this.navBySrfnav():this.navByFirstItem();else{const t=this.xDataController.state.selectedData;t[0]&&this.xDataController.setActive(t[0])}}navBySrfnav(){var t;const e=null==(t=this.xDataController)?void 0:t.state.items.find((t=>t[this.navKeyName]===this.state.srfnav));if(this.routeDepth&&$o(this.routeDepth))return e&&this.xDataController.setSelection([e]),void this._evt.emit("onNavViewChange",{navViewMsg:{key:this.state.srfnav,isRoutePushed:!0,isCache:this.isCache},context:this.context});e?(this.xDataController.setActive(e),this.xDataController.setSelection([e])):this._evt.emit("onNavViewChange",{navViewMsg:{key:this.state.srfnav,is404:!0,isCache:this.isCache},context:this.context})}navByFirstItem(){const t=this.xDataController.state.items[0];if(!t)return this.state.srfnav="",void this._evt.emit("onNavViewChange",{navViewMsg:{key:"",isCache:this.isCache}});this.xDataController.setActive(t),this.xDataController.setSelection([t])}xDataActive(t){const{data:e,context:a,params:i}=t,s=this.getNavViewMsg(e[0],a,i);this._evt.emit("onNavViewChange",{navViewMsg:s})}prepareParams(t,e,a,i){const{navDER:s,navFilter:n,navigateContexts:o,navigateParams:r,appDataEntityId:c}=t,d={deName:c?ve(c):void 0,navFilter:n,pickupDEFName:null==s?void 0:s.pickupDEFName,navContexts:o,navParams:r},l={context:a,params:i,data:e},{resultContext:h,resultParams:u}=le(d,l),p=Object.assign(a.clone(),h,{currentSrfNav:e[this.navKeyName]});this.state.srfnav=e[this.navKeyName];return{context:p,params:{...u}}}calcViewModelId(){var t;if(["GRID","DATAVIEW","LIST"].includes((null==(t=this.XDataModel)?void 0:t.controlType)||""))return this.XDataModel.navAppViewId;throw new o("多节点视图由子类实现")}getNavViewMsg(t,e,a){const i=this.calcViewModelId(),s=this.prepareParams(this.XDataModel,t,e,a);return{key:t[this.navKeyName],context:s.context,params:s.params,viewId:i,isCache:this.isCache}}calcControlHeaderVisible(){const t=!!this.toolbarController;if(!t&&this.layoutPanel){const t=this.layoutPanel.panelItems.control_toolbar;t&&(t.state.visible=!1)}return t||!(!this.model.showTitleBar||!this.model.title)||!!this.model.enableSearch}setLayoutPanel(t){super.setLayoutPanel(t),t.evt.on("onMounted",(()=>{if(!this.calcControlHeaderVisible()){const t=this.layoutPanel.panelItems.control_header;t&&(t.state.visible=!1)}}))}async onRouterChange(t){this.state.srfnav!==t.srfnav&&(this.state.srfnav=t.srfnav,this.navBySrfnav())}}),xc=(t("CalendarExpBarController",class extends Tc{constructor(){super(...arguments),this.navKeyName="navId"}getCalendarItemModel(t){const{sysCalendarItems:e}=this.XDataModel;if(e)return e.find((e=>e.itemType===t))}get xDataController(){const t=this.view.getController(this.model.xdataControlName);if(!t)throw new a(this.model,"无法获取多数据部件[".concat(this.model.xdataControlName,"]控制器"));return t}navBySrfnav(){var t;const e=null==(t=this.xDataController)?void 0:t.state.items.find((t=>t.navId===this.state.srfnav));if(super.navBySrfnav(),!e)return;const a=new Date(e.beginTime);this.xDataController.setSelectDate(a)}getNavViewMsg(t){const e=this.getCalendarItemModel(t.itemType);if(e){const{context:a,params:i}=this.prepareParams(e,t.deData?t.deData:t,this.context,this.params);return a.currentSrfNav=t.navId,this.state.srfnav=t.navId,{key:t.navId,context:a,params:i,viewId:e.navAppViewId}}return{key:t.navId,context:this.context,params:this.params}}}),t("TreeExpBarController",class extends Tc{constructor(){super(...arguments),this.navKeyName="_id",this.navNodeModelIds=[]}get xDataController(){const t=this.view.getController(this.model.xdataControlName);if(!t)throw new a(this.model,"无法获取多数据部件[".concat(this.model.xdataControlName,"]控制器"));return t}async onMounted(){super.onMounted(),this.xDataController&&this.xDataController.evt.on("onAfterRefreshParent",(t=>{const e=this.xDataController.state.selectedData;e[0]&&this.xDataController.setActive(e[0])}))}getNodeModel(t){const{detreeNodes:e}=this.XDataModel;let a;return e&&e.forEach((e=>{e.id===t&&(a=e)})),a}xDataActive(t){const{nodeData:e}=t;super.xDataActive({...t,data:[e]})}getNavViewMsg(t,e,a){const i=t._id,s=t._deData||t,n=this.getNodeModel(t._nodeId);if(!n)throw new o("找不到".concat(t._nodeId,"的节点模型"));const r=this.prepareParams(n,s,e,a);return r.context.currentSrfNav=i,this.state.srfnav=i,{key:i,viewId:n.navAppViewId,isCache:this.isCache,...r}}navByFirstItem(){const t=this.xDataController.state.items.find((t=>!(!this.xDataController.model.rootVisible&&this.xDataController.state.rootNodes.includes(t))&&(!!this.state.noNeedNavView||this.navNodeModelIds.includes(t._nodeId))));t&&(this.xDataController.setActive(t),this.xDataController.setSelection([t]))}async onCreated(){await super.onCreated();const{detreeNodes:t}=this.XDataModel;null==t||t.forEach((t=>{t.navAppViewId&&this.navNodeModelIds.push(t.id)})),this.state.srfnav&&(this.defaultExpandedKeys=this.calcExpandKeys(this.state.srfnav))}calcExpandKeys(t){const e=[];return t.split(":").forEach(((t,a)=>{0===a?e.push(t):e.push("".concat(e[a-1],":").concat(t))})),e.pop(),e}async onRouterChange(t){if(this.state.srfnav!==t.srfnav){const e=this.calcExpandKeys(t.srfnav);await this.xDataController.expandNodeByKey(e)}await super.onRouterChange(t)}calcControlHeaderVisible(){const t=!!this.toolbarController;if(!t&&this.layoutPanel){const t=this.layoutPanel.panelItems.control_toolbar;t&&(t.state.visible=!1)}return t||!(!this.model.showTitleBar||!this.model.title)}}),t("ChartExpBarController",class extends Tc{navByFirstItem(){if(!this.xDataController.state.items[0])return this.state.srfnav="",void this._evt.emit("onNavViewChange",{navViewMsg:{key:"",isCache:this.isCache}});const t=this.xDataController.generator.seriesGenerators.find((t=>t.chartDataArr.length>0&&t.model.navAppViewId));t&&this.xDataController.setActive(t.chartDataArr[0])}prepareParams(t,e,a,i){var s;const{context:n,params:o}=super.prepareParams(t,e,a,i);if(e._seriesModelId){const a=null==(s=t.dechartSerieses)?void 0:s.find((t=>t.id===e._seriesModelId));if(a){const{navigateContexts:t,navigateParams:s}=a,r=oe(t,e,i,n),c=oe(s,e,i,o);return{context:Object.assign(n.clone(),r),params:c}}}return{context:n,params:o}}getNavViewMsg(t,e,a){var i;let s;if(t._seriesModelId){const e=null==(i=this.XDataModel.dechartSerieses)?void 0:i.find((e=>e.id===t._seriesModelId));s=null==e?void 0:e.navAppViewId}const n=this.prepareParams(this.XDataModel,t,e,a);return{key:t._uuid,context:n.context,params:n.params,viewId:s,isCache:this.isCache}}}),t("FormController",class extends vr{constructor(){super(...arguments),this.details={},this.providers={},this.formItems=[],this.formMDCtrls=[],this.counters={}}get _evt(){return this.evt}get data(){return this.state.data}initState(){super.initState(),this.state.data=new En,this.state.isLoaded=!1,this.state.processing=!1,this.state.modified=!1}async dataChangeNotify(t){await ba(Object.values(this.details).map((async e=>e.dataChangeNotify(t))))}formStateNotify(t){Object.values(this.details).forEach((e=>{e.formStateNotify(t)}))}async onCreated(){await super.onCreated(),await this.initDetailControllers(),await this.initCounter(),this.dataChangeNotify=C(this.dataChangeNotify.bind(this),((t,e)=>[Array.from(new Set([...t[0],...e[0]]))]),200),this._evt.on("onFormDetailEvent",(t=>{var e;null==(e=this.scheduler)||e.triggerControlEvent(t.formDetailName,t.formDetailEventName,t)}))}async initDetailControllers(t=this.model.deformPages,e=this,i=void 0){await Promise.all(t.map((async t=>{const s=await rs(t,this.model);if(!s)return;if(e.details[t.id])throw new a(t,"初始化异常: 表单成员[".concat(t.id,"](").concat(t.detailType,")已存在,表单项标识重复请检查配置"));e.providers[t.id]=s;const n=await s.createController(t,e,i);if(e.details[t.id]=n,"FORMITEM"===t.detailType&&e.formItems.push(n),"MDCTRL"===t.detailType&&e.formMDCtrls.push(n),Re(t))return;const o=Se(t);o.length&&await this.initDetailControllers(o,e,n)})))}getData(){return[this.state.data]}async setDataValue(t,e){if(!Object.prototype.hasOwnProperty.call(this.state.data,t)||Jo(this.state.data[t],e)){this.state.data[t]=e,this.state.processing=!0,this.state.modified=!0,await this._evt.emit("onFormDataChange",void 0);try{await this.dataChangeNotify([t])}finally{this.state.processing=!1}}}async updateFormItem(t){}async validate(){return-1===(await Promise.all([...this.formItems,...this.formMDCtrls].map((t=>t.validate())))).findIndex((t=>!t))}actionNotification(t,e){if((null==e?void 0:e.error)&&e.error instanceof b){const{details:t}=e.error;t.forEach((t=>{this.setDetailError(t.name,t.errorInfo)}))}super.actionNotification(t,{data:this.data,...e||{}})}initControlScheduler(t=[]){const e=[...t];r(this.model,(t=>{t.controlLogics&&e.push(...t.controlLogics)}),{childrenFields:["deformPages","deformTabPages","deformDetails"]}),super.initControlScheduler(e)}async onDestroyed(){await super.onDestroyed(),Object.values(this.counters).forEach((t=>t.destroy()))}async initCounter(){this.counters={};const{appCounterRefs:t}=this.model;if(t&&t.length>0){const e=this.context[ve(this.model.appDataEntityId)];try{await Promise.all(t.map((async t=>{const a=await ln.getCounterByRef(t,this.context,e?{customId:e}:void 0);this.counters[t.id]=a})))}catch(t){console.error(t)}}}setDetailError(t,e){const a=this.details[t],i=null==a?void 0:a.state;i&&(i.error=e)}})),Nc=class extends yn{setDefault(t,e,a,i){r(this.model,(s=>{if("FORMITEM"===s.detailType){const{createDVT:n,createDV:o,updateDVT:r,updateDV:c,valueFormat:d}=s,l="create"===i?n:r,h="create"===i?o:c,u=s.id.toLowerCase(),p=ir({name:u,valueType:l,defaultValue:h,valueFormat:d},{data:t,context:e,params:a});void 0!==p&&(t[u]=p)}}),{childrenFields:["deformPages","deformTabPages","deformDetails"]})}},Sc=t("SearchFormService",class extends Nc{async getDraft(t,e={}){let a={ok:!0,status:200,data:this.getFilteredData({...e})};return a=this.handleResponse(a),a.ok&&a.data&&this.setDefault(a.data,t,e,"create"),a}initUIDataMap(){r(this.model,(t=>{if("FORMITEM"===t.detailType){const e=t.id.toLowerCase();this.dataUIMap.set(e,new fo(e,e))}}),{childrenFields:["deformPages","deformTabPages","deformDetails"]})}handleResponse(t){const e=super.handleResponse(t);return e.ok&&e.data&&(e.data=this.toUIData(e.data)),e}getFilteredData(t){const e={};return this.dataUIMap.forEach((a=>{void 0!==t[a.dataKey]&&(e[a.dataKey]=t[a.dataKey])})),e}}),Rc=(t("SearchFormController",class extends xc{initState(){super.initState(),this.state.storedFilters=[]}async onCreated(){var t,e;await super.onCreated(),this.config=new dn(this.model.appId,"dynafilter","searchform_".concat((null==(t=this.model.appDataEntityId)?void 0:t.toLowerCase())||"app","_").concat(null==(e=this.model.codeName)?void 0:e.toLowerCase())),this.preprocessLayoutPanel(),this.service=new Sc(this.model),await this.service.init(this.context),await this.load(),await this.loadConfig()}async load(){const t={...this.params};let e;await this.evt.emit("onBeforeLoadDraft",{params:t});try{e=await this.service.getDraft(this.context,t)}catch(t){throw this.actionNotification("GETDRAFTERROR",{error:t}),t}return this.state.data=e.data,this.state.isLoaded=!0,this.formStateNotify("DRAFT"),this.actionNotification("GETDRAFTSUCCESS"),this.data}getFilterParams(){const t={};return Object.keys(this.state.data).forEach((e=>{const a=this.state.data[e];null!=a&&""!==a&&(t[e]=a)})),t}async search(){await this.evt.emit("onSearch",void 0)}async onSearchButtonClick(){await this.search()}async reset(){await this.load(),await this.search()}async dataChangeNotify(t){await super.dataChangeNotify(t),this.model.enableAutoSearch&&this.search()}async onKeyUp(t){const e=t||window.event;e&&"Enter"===e.code&&await this.onSearchButtonClick()}preprocessLayoutPanel(){if(!this.controlPanel)return;const{searchButtonStyle:t}=this.model;let e=!1,a=!1;const i=this.model.searchButtonPos||"RIGHT";e="BOTTOM"===i,a="BOTTOM"!==i,"NONE"===t&&(e=!0,a=!0);const s=t=>{let i,n="";if(["rootPanelItems","panelItems"].find((e=>!!t[e]&&(i=t[e],n=e,!0))),i&&i.length>0){const o=[];i.forEach((t=>{e&&"control_buttons_right"===t.id||a&&"control_buttons_bottom"===t.id||(o.push(t),s(t))})),o.length<i.length&&(t[n]=o)}};(a||e)&&s(this.controlPanel)}async loadConfig(){const t=await this.config.load();t.model&&(this.state.storedFilters=t.model)}async saveConfig(){await this.config.save({model:this.state.storedFilters})}async storeFilter(t){this.state.storedFilters.push({name:t,data:{...this.data}}),await this.saveConfig()}applyStoredFilter(t){const e=this.state.storedFilters[t];if(!e)throw new o("没有找到可以应用的搜索条件");e.data&&Object.assign(this.data,e.data),this.search()}async removeStoredFilter(t){if(!this.state.storedFilters[t])throw new o("没有找到保存的搜索条件");this.state.storedFilters.splice(t,1),await this.saveConfig()}}),t("FormDetailState",class{constructor(t){this.parent=t,this.disabled=!1,this.layout={width:"",height:"",extraStyle:{},extraClass:[],contentStyle:{}},this.class={container:[],containerDyna:[],label:[],labelDyna:[]},this.required=!1,this.showMoreMode=0,this.readonly=!1;let e,a,i=!0;Object.defineProperty(this,"visible",{enumerable:!0,configurable:!0,get(){if(this.parent){if(!1===this.parent.visible)return!1;if(1===this.showMoreMode&&!1===this.parent.isShowMore)return!1}return i},set:t=>(i=t,!0)}),Object.defineProperty(this,"keepAlive",{enumerable:!0,configurable:!0,get(){return void 0!==e?e:!!this.parent&&this.parent.keepAlive},set:t=>(e=t,!0)}),Object.defineProperty(this,"readonly",{enumerable:!0,configurable:!0,get(){return void 0!==a?a:!!this.context&&!(!0!==this.context.srfreadonly&&"true"!==this.context.srfreadonly)},set:t=>(a=t,!0)})}})),Mc=t("FormDetailEventName",(t=>(t.CLICK="onClick",t.FOCUS="onFocus",t.BLUR="onBlur",t.CHANGE="onChange",t.ENTER="onEnter",t))(Mc||{})),Oc=t("PanelItemEventName",(t=>(t.CLICK="onClick",t.FOCUS="onFocus",t.BLUR="onBlur",t.CHANGE="onChange",t.ENTER="onEnter",t))(Oc||{})),Lc=t("FormDetailController",class{constructor(t,e,a){this.dynaLogicResult={visible:void 0,disabled:void 0,required:void 0},this.model=t,this.form=e,this.parent=a,this.state=this.createState(),this.state.context=this.context}get data(){return this.form.data}get context(){return this.form.context}get params(){return this.form.params}get containerClass(){return[...this.state.class.container,...this.state.class.containerDyna]}get labelClass(){return[...this.state.class.label,...this.state.class.labelDyna]}async init(){await this.onInit()}async onInit(){this.state.showMoreMode=this.model.showMoreMode;const{layoutPos:t,sysCss:e,labelSysCss:a,capLanguageRes:i}=this.model;if(t){const{width:e,height:a}=ge(t);this.state.layout.width="".concat(e),this.state.layout.height="".concat(a)}(null==e?void 0:e.cssName)&&this.state.class.container.push(e.cssName),(null==a?void 0:a.cssName)&&this.state.class.label.push(a.cssName),i&&i.lanResTag&&(this.model.caption=ibiz.i18n.t(i.lanResTag,this.model.caption))}createState(){var t;return new Rc(null==(t=this.parent)?void 0:t.state)}async dataChangeNotify(t){this.calcDynamicLogic(t),this.calcDetailDisabled(this.data),this.calcDetailVisible(this.data),this.calcDetailRequired(this.data),this.calcDynaClass(this.data)}async formStateNotify(t){this.calcDynamicLogic([],!0),this.calcDetailDisabled(this.data),this.calcDetailVisible(this.data),this.calcDetailRequired(this.data),this.calcDynaClass(this.data)}calcDynamicLogic(t,e=!1){var a;this.parent&&!this.parent.state.visible||null==(a=this.model.defdgroupLogics)||a.forEach((a=>{const i=a.relatedDetailNames||[];if(e||A(i,t))try{const t=Ze(this.data,a);switch(a.logicCat){case"ITEMBLANK":this.dynaLogicResult.required=!t;break;case"ITEMENABLE":this.dynaLogicResult.disabled=!t;break;case"PANELVISIBLE":this.dynaLogicResult.visible=t}}catch(t){ibiz.log.error(t)}}))}force(t){}calcDynaClass(t){if(this.model.dynaClass){const e=we(this.model.dynaClass,t);this.state.class.containerDyna=e}if(this.model.labelDynaClass){const e=we(this.model.labelDynaClass,t);this.state.class.labelDyna=e}}calcDetailDisabled(t){let{disabled:e}=this.dynaLogicResult;if(!0!==e&&this.form.scheduler){const a=this.form.scheduler.triggerItemEnable(this.model.id,{data:[t]});void 0!==a&&(e=!a)}void 0!==e&&(this.state.disabled=e)}calcDetailVisible(t){let{visible:e}=this.dynaLogicResult;if(!1!==e&&this.form.scheduler){const a=this.form.scheduler.triggerItemVisible(this.model.id,{data:[t]});void 0!==a&&(e=a)}void 0!==e&&(this.state.visible=e)}calcDetailRequired(t){let{required:e}=this.dynaLogicResult;if(!0!==e&&this.form.scheduler){const a=this.form.scheduler.triggerItemBlank(this.model.id,{data:[t]});void 0!==a&&(e=!a)}void 0!==e&&(this.state.required=e)}async onClick(t){t&&t.stopPropagation(),this.form.evt.emit("onFormDetailEvent",{formDetailName:this.model.id,formDetailEventName:"onClick",event:t})}}),_c=t("FormButtonState",class extends Rc{constructor(){super(...arguments),this.loading=!1}}),Fc=(t("FormButtonController",class extends Lc{constructor(){super(...arguments),this.actionState=null}createState(){var t;return new _c(null==(t=this.parent)?void 0:t.state)}async onInit(){super.onInit(),await this.initActionStates()}async initActionStates(){const t=this.model.uiactionId;t&&(this.actionState=new Ho(this.model.id,this.form.context.srfappid,t))}async formStateNotify(t){if(this.actionState){const t=ve(this.form.model.appDataEntityId);await this.actionState.update(this.context,this.data,t)}await super.formStateNotify(t)}calcDetailDisabled(t){super.calcDetailDisabled(t),this.actionState&&(this.state.disabled=!(!this.state.disabled&&!this.actionState.disabled))}calcDetailVisible(t){super.calcDetailVisible(t),this.actionState&&(this.state.visible=!(!this.state.visible||!this.actionState.visible))}async onClick(t){this.state.loading=!0;try{"UIACTION"===this.model.actionType&&await this.doUIAction(t),await this.doFormItemUpdate()}finally{this.state.loading=!1}super.onClick(t)}async doUIAction(t){const e=this.model.uiactionId;await pc.execAndResolved(e,{context:this.form.context,params:this.form.params,data:[this.data],view:this.form.view,event:t,noWaitRoute:!0},this.model.appId)}async doFormItemUpdate(){this.model.deformItemUpdateId&&await this.form.updateFormItem(this.model.deformItemUpdateId)}}),t("FormDruipartState",class extends Rc{constructor(){super(...arguments),this.showMask=!1}})),Vc=(t("FormDRUIPartController",class extends Lc{constructor(){super(...arguments),this.refreshItems=["srfkey"],this.paramItem="srfkey",this.isNewData=!1}createState(){var t;return new Fc(null==(t=this.parent)?void 0:t.state)}async onInit(){if(await super.onInit(),Object.assign(this.state.layout.extraStyle,{overflow:"auto"}),this.model.refreshItems){let t=this.model.refreshItems.split(";");t=t.filter((t=>!!t)),this.refreshItems.push(...t)}this.model.paramItem&&(this.paramItem=this.model.paramItem)}async dataChangeNotify(t){await super.dataChangeNotify(t),A(this.refreshItems,t)&&this.calcViewParams()}async formStateNotify(t){await super.formStateNotify(t),this.isNewData="DRAFT"===t,0!==this.model.maskMode&&(this.state.showMask=this.isNewData),"LOAD"!==t&&"DRAFT"!==t&&"SAVE"!==t||this.calcViewParams()}calcViewParams(){let t=this.form.context.clone();const e=this.model.navigateContexts;nt(e)&&(t=Object.assign(t,oe(e,this.data,this.form.params,this.form.context)));const a=oe(this.model.navigateParams,this.data,this.form.params,this.form.context);if(this.state.viewComponentKey){if(JSON.stringify(this.navContext)!==JSON.stringify(t)||JSON.stringify(this.navParams)!==JSON.stringify(a))this.navContext=t,this.navParams=a,this.force();else if(this.embedView){if(this.isNewData)return;this.embedView.callUIAction("Refresh")}}else this.state.viewComponentKey=ct(),this.navContext=t,this.navParams=a}setEmbedView(t){this.embedView=t,this.embedView.evt.on("onMounted",(()=>{this.isNewData||this.embedView.call("Load")})),this.embedView.evt.on("onDataChange",(t=>{["LOAD","LOADDRAFT"].includes(t.actionType)||(ibiz.log.debug("接收到关系界面的数据变更事件",t),this.model.deformItemUpdateId&&this.form.updateFormItem(this.model.deformItemUpdateId))}))}}),t("FormGroupPanelState",class extends Rc{constructor(){super(...arguments),this.isShowMore=!1,this.actionGroupState=null}})),kc=t("FormGroupPanelController",class extends Lc{get disableClose(){const{titleBarCloseMode:t}=this.model;return 0===t||void 0===t}get defaultExpansion(){const{titleBarCloseMode:t}=this.model;return this.disableClose||1===t}createState(){var t;return new Vc(null==(t=this.parent)?void 0:t.state)}async onInit(){super.onInit(),await this.initActionStates()}async formStateNotify(t){if(super.formStateNotify(t),this.state.actionGroupState){const t=this.data.getOrigin?this.data.getOrigin():this.data;this.state.actionGroupState.update(this.form.context,t)}}async initActionStates(){var t;const{uiactionGroup:e}=this.model;if(!(null==(t=null==e?void 0:e.uiactionGroupDetails)?void 0:t.length))return;const a=new qo;e.uiactionGroupDetails.forEach((t=>{const e=t.uiactionId;if(e){const i=new Ho(t.id,this.form.context.srfappid,e);a.addState(t.id,i)}})),await a.update(this.form.context),this.state.actionGroupState=a}async onActionClick(t,e){const a=t.uiactionId;await pc.execAndResolved(a,{context:this.form.context,params:this.form.params,data:[this.data],view:this.form.view,event:e},t.appId)}}),zc=t("FormItemState",class extends Rc{constructor(t){super(t),this.parent=t,this.error=null,this.enableCondDisabled=!1;let e=!1;Object.defineProperty(this,"disabled",{enumerable:!0,configurable:!0,get(){return!!this.enableCondDisabled||e},set:t=>(e=t,!0)})}}),Wc=(t("FormItemController",class extends Lc{constructor(t,e,a){super(t,e,a),this.rules=[]}createState(){var t;return new zc(null==(t=this.parent)?void 0:t.state)}get name(){return this.model.id}get value(){return this.data[this.name]}get valueItemName(){if(this.model.editor)return this.model.editor.valueItemName}get labelCaption(){const{captionItemName:t}=this.model;return t?this.data[t]:this.model.caption}get unitName(){return this.model.unitName}get valueFormat(){return this.model.valueFormat}get dataType(){return this.model.dataType}async onInit(){var t,e;await super.onInit(),this.state.required=!this.model.allowEmpty;const{enableCond:a}=this.model;a||(this.state.enableCondDisabled=!0),!0!==this.context.srfreadonly&&"true"!==this.context.srfreadonly&&(null==(t=this.model.editor)?void 0:t.readOnly)&&(this.state.readonly=(null==(e=this.model.editor)?void 0:e.readOnly)||!1),this.model.editor&&"HIDDEN"!==this.model.editor.editorType&&(this.editorProvider=await ss(this.model.editor),this.editorProvider&&(this.editor=await this.editorProvider.createController(this.model.editor,this),await this.initRules()))}async initRules(){this.rules=[];const t=ga(this.form.model.deformItemVRs||[],this.name);t&&this.rules.push(...tr(t,this.name,this.valueItemName)),this.model.editor&&this.rules.push(...er(this.model.editor)),this.rules.length>0&&(this.validator=new vt({[this.name]:this.rules}))}calcEnableCond(){const{enableCond:t}=this.model,e=0===this.data.srfuf;(e&&2===t||!e&&1===t)&&(this.state.enableCondDisabled=!0)}async dataChangeNotify(t){await super.dataChangeNotify(t);const{resetItemNames:e}=this.model;let a=!1;e&&e.length>0&&e.forEach((e=>{t.includes(e)&&(a=!0)})),a&&this.setDataValue(null,this.name),(t.includes(this.name)||t.includes(this.valueItemName))&&this.validate(),t.includes(this.name)&&this.model.deformItemUpdateId&&await this.form.updateFormItem(this.model.deformItemUpdateId)}async formStateNotify(t){super.formStateNotify(t),this.calcEnableCond()}calcDynamicLogic(t,e=!1){this.model.hidden||super.calcDynamicLogic(t,e)}async validate(){if(!this.state.visible)return this.state.error=null,!0;if(this.state.required&&("string"==typeof this.data[this.name]?ot(this.data[this.name].trimEnd()):ot(this.data[this.name])))return this.state.error="请填写".concat(this.model.caption||""),!1;if(this.validator)try{await this.validator.validate(this.data)}catch({errors:t,_fields:e}){return this.state.error=t[0].message,!1}return this.state.error=null,!0}async setDataValue(t,e){e=e||this.name,await this.form.setDataValue(e,t),this.form.evt.emit("onFormDetailEvent",{formDetailName:this.model.id,formDetailEventName:"onChange"})}onFocus(t){this.form.evt.emit("onFormDetailEvent",{formDetailName:this.model.id,formDetailEventName:"onFocus",event:t})}onBlur(t){this.form.evt.emit("onFormDetailEvent",{formDetailName:this.model.id,formDetailEventName:"onBlur",event:t})}onEnter(t){this.form.evt.emit("onFormDetailEvent",{formDetailName:this.model.id,formDetailEventName:"onEnter",event:t})}}),class extends Rc{constructor(){super(...arguments),this.actionGroupState=null}}),Uc=t("FormMDCtrlController",class extends Lc{createState(){var t;return new Wc(null==(t=this.parent)?void 0:t.state)}get name(){return this.model.id}get context(){return this.form.context}get params(){return this.form.params}get enableCreate(){return!this.state.readonly&&P.checkPermission(this.model.buildInActions,1)}get enableUpdate(){return!this.state.readonly&&P.checkPermission(this.model.buildInActions,2)}get enableDelete(){return!this.state.readonly&&P.checkPermission(this.model.buildInActions,4)}async updateFormItem(){this.model.deformItemUpdateId&&await this.form.updateFormItem(this.model.deformItemUpdateId)}async formStateNotify(t){if(super.formStateNotify(t),this.state.actionGroupState){const t=this.data.getOrigin?this.data.getOrigin():this.data;this.state.actionGroupState.update(this.form.context,t)}}async onInit(){super.onInit(),await this.initActionStates()}async initActionStates(){var t;const{uiactionGroup:e}=this.model;if(!(null==(t=null==e?void 0:e.uiactionGroupDetails)?void 0:t.length))return;const a=new qo;e.uiactionGroupDetails.forEach((t=>{const e=t.uiactionId;if(e){const i=new Ho(t.id,this.form.context.srfappid,e);a.addState(t.id,i)}})),await a.update(this.form.context),this.state.actionGroupState=a}async onActionClick(t,e){const a=t.uiactionId;await pc.execAndResolved(a,{context:this.context,params:this.params,data:[this.data],view:this.form.view,event:e},t.appId)}refresh(){}async validate(){return!0}}),Bc=(t("FormMDCtrlMDController",class extends Uc{constructor(){super(...arguments),this.ignoreNextSelfChange=!1}get name(){return this.model.id}async onInit(){await super.onInit();const{contentControl:t}=this.model;if(!t)throw new a(this.model,"多数据部件未配置内容部件");"GRID"===t.controlType&&T(t,{enableRowEdit:this.enableCreate||this.enableUpdate,enableRowNew:this.enableCreate});const e=await es(t);e&&(this.mdProvider=e)}setMDControl(t){this.mdController=t,t.evt.on("onSaveSuccess",(()=>{this.notifyFormDataChange()})),t.evt.on("onRemoveSuccess",(()=>{this.notifyFormDataChange()}))}updateFormItem(){const t=this.mdController.state.items||[];return this.data[this.name]=t,super.updateFormItem()}remove(){this.mdController.remove()}create(){if("GRID"!==this.model.contentType)throw new i(this.model,"多数据部件类型".concat(this.model.contentType,"暂不支持添加数据"));this.mdController.newRow()}refresh(){this.mdController?this.mdController.refresh():ibiz.log.debug("mdController不存在")}async formStateNotify(t){await super.formStateNotify(t),this.refresh()}async dataChangeNotify(t){t.includes(this.model.id)&&this.ignoreNextSelfChange?this.ignoreNextSelfChange=!1:(await super.dataChangeNotify(t),t.includes(this.model.id)&&this.refresh())}notifyFormDataChange(){this.updateFormItem(),this.ignoreNextSelfChange=!0,this.form.dataChangeNotify([this.name])}}),class extends Wc{}),Gc=(t("FormMDCtrlFormController",class extends Uc{constructor(){super(...arguments),this.ignoreNextSelfChange=!1,this.formMap=new Map}createState(){var t;return new Bc(null==(t=this.parent)?void 0:t.state)}async onInit(){super.onInit();const{contentControl:t}=this.model;if(!t)throw new a(this.model,"多数据部件未配置内容部件");t.enableAutoSave=this.enableCreate||this.enableUpdate;const e=await es(t);e&&(this.formProvider=e);const{appDataEntityId:i}=this.model.contentControl;this.deName=ve(i)}async fetchData(){const{appDataEntityId:t}=this.model.contentControl,e=await ibiz.hub.getApp(this.model.appId).deService.exec(t,"fetchdefault",this.context,this.params);e.ok&&(this.state.items=e.data.map((t=>{const e=this.context.clone();e[this.deName]=t.srfkey;const a={...this.params};return{id:t.srfkey,context:e,params:a}})))}async formStateNotify(t){await super.formStateNotify(t),await this.refresh()}setFormController(t,e){this.formMap.set(t,e),e.evt.on("onSaveSuccess",(e=>{const a=e.data[0],i=this.state.items.find((e=>e.id===t));i&&i.context[this.deName]!==a.srfkey&&(i.context[this.deName]=a.srfkey),this.notifyFormDataChange()})),e.evt.on("onRemoveSuccess",(()=>{this.notifyFormDataChange()}))}async remove(t){const e=this.formMap.get(t);if(!e)throw new o("没有找到对应".concat(t,"的表单控制器"));await e.remove();const a=this.state.items.findIndex((e=>e.id===t));-1!==a&&this.state.items.splice(a,1)}create(t){const e=this.context.clone(),a={...this.params};this.state.items||(this.state.items=[]);const i={id:ct(),context:e,params:a};void 0!==t?this.state.items.splice(t,0,i):this.state.items.push(i)}refresh(){this.fetchData()}async dataChangeNotify(t){t.includes(this.model.id)&&this.ignoreNextSelfChange?this.ignoreNextSelfChange=!1:(await super.dataChangeNotify(t),t.includes(this.model.id)&&this.refresh())}notifyFormDataChange(){this.updateFormItem(),this.ignoreNextSelfChange=!0,this.form.dataChangeNotify([this.name])}}),t("FormMDCtrlRepeaterController",class extends Uc{constructor(){super(...arguments),this.repeaterStyle="MultiForm",this.isSingleData=!1}get value(){return this.data[this.model.id]}async onInit(){switch(await super.onInit(),this.model.detailStyle){case"DEFAULT":this.repeaterStyle="MultiForm",this.isSingleData=!1;break;case"STYLE2":this.repeaterStyle="Grid",this.isSingleData=!1;break;case"STYLE3":this.repeaterStyle="SingleForm",this.isSingleData=!0;break;default:throw new i(this.model,"暂不支持重复器样式".concat(this.model.detailStyle))}this.prepareRepeatedForm()}prepareRepeatedForm(){const t="".concat(this.model.id,"repeatedform"),e={appId:this.model.appId,id:t,codeName:t,name:t,deformPages:[{appId:this.model.appId,id:"formpage1",deformDetails:this.model.deformDetails,detailType:"FORMPAGE",detailStyle:"DEFAULT",layout:this.model.layout}]};["appId","controlType","deformItemVRs"].forEach((t=>{e[t]=this.form.model[t]})),this.repeatedForm=Z(e)}setValue(t){this.form.setDataValue(this.name,t)}create(t){if(this.isSingleData)this.setValue({});else{let e=this.value;e=e?[...e]:[],void 0!==t?e.splice(t,0,{}):e.push({}),this.setValue(e)}}remove(t){if(this.isSingleData)return void this.setValue(null);const e=this.value.filter(((e,a)=>t!==a));this.setValue(e)}async dataChangeNotify(t){await super.dataChangeNotify(t);const{resetItemNames:e}=this.model;let a=!1;e&&e.length>0&&e.forEach((e=>{t.includes(e)&&(a=!0)})),a&&this.setValue(null),t.includes(this.name)&&await this.updateFormItem()}}),t("FormPageState",class extends Vc{})),jc=(t("FormPageController",class extends kc{createState(){var t;return new Gc(null==(t=this.parent)?void 0:t.state)}}),t("FormRawItemState",class extends Rc{})),Kc=(t("FormRawItemController",class extends Lc{createState(){var t;return new jc(null==(t=this.parent)?void 0:t.state)}}),t("FormTabPageState",class extends Rc{})),Xc=(t("FormTabPageController",class extends Lc{createState(){var t;return new Kc(null==(t=this.parent)?void 0:t.state)}get isActive(){return this.parent.state.activeTab===this.model.id}}),t("FormTabPanelState",class extends Rc{constructor(){super(...arguments),this.activeTab=""}})),Hc=(t("FormTabPanelController",class extends Lc{createState(){var t;return new Xc(null==(t=this.parent)?void 0:t.state)}async onInit(){var t;await super.onInit(),this.state.activeTab=(null==(t=this.model.deformTabPages)?void 0:t[0].id)||""}onTabChange(t){this.state.activeTab=t}getCounter(t){const{counters:e}=this.form;return e&&e[t]?e[t]:null}}),t("EditFormService",class extends Nc{async get(t,e={}){var a;let i=await this.exec((null==(a=this.model.getControlAction)?void 0:a.appDEMethodId)||"get",t,void 0,e);return i=this.handleResponse(i),i.ok&&i.data&&this.setDefault(i.data,t,e,"update"),i}async getDraft(t,e={}){var a;let i=await this.exec((null==(a=this.model.getDraftControlAction)?void 0:a.appDEMethodId)||"getdraft",t,void 0,e);return i=this.handleResponse(i),i.ok&&i.data&&this.setDefault(i.data,t,e,"create"),i}async remove(t,e={}){var a;return await this.exec((null==(a=this.model.removeControlAction)?void 0:a.appDEMethodId)||"remove",t,void 0,e)}async create(t,e){var a;const i=e instanceof En?e.getOrigin():e,s=this.getFilteredData(i);let n=await this.exec((null==(a=this.model.createControlAction)?void 0:a.appDEMethodId)||"create",t,s);return n=this.handleResponse(n),n}async update(t,e){var a;const i=e instanceof En?e.getOrigin():e,s=this.getFilteredData(i);let n=await this.exec((null==(a=this.model.updateControlAction)?void 0:a.appDEMethodId)||"update",t,s);return n=this.handleResponse(n),n}async goBack(t,e){var i;const s=null==(i=this.model.goBackControlAction)?void 0:i.appDEMethodId;if(!s)throw new a(this.model,"缺少返回操作实体行为");let n=await this.exec(s,t,e instanceof En?e.getOrigin():e);return n=this.handleResponse(n),n}async updateFormItem(t,e,a={}){let i=await this.exec(t,e,a);return i=this.handleResponse(i),i}async wfStart(t,e,a){var i;const s=(null==(i=this.model.wfstartControlAction)?void 0:i.appDEMethodId)||"wfstart";return(await this.app.deService.getService(t,this.model.appDataEntityId)).wf.exec(s,t,e,a instanceof En?a.getOrigin():a)}async wfSubmit(t,e,a){var i;const s=this.model;let n="";n=e.type?e.type:(null==(i=s.wfsubmitControlAction)?void 0:i.appDEMethodId)||"wfsubmit";return(await this.app.deService.getService(t,this.model.appDataEntityId)).wf.exec(n,t,e,a instanceof En?a.getOrigin():a)}initUIDataMap(){super.initUIDataMap();const t=["srfwfmemo","srfwftransferor","srfactionparam","srffrontuf","srfnextform"];r(this.model,(e=>{if("FORMITEM"===e.detailType||"MDCTRL"===e.detailType){const a=e,i=a.id.toLowerCase(),s=a.fieldName||e.appDEFieldId;let n;n=s?new fo(i,s,{isOriginField:!0,dataType:a.dataType}):new fo(i,i,{isOriginField:t.includes(i)}),this.dataUIMap.set(i,n)}}),{childrenFields:["deformPages","deformTabPages","deformDetails"]})}handleResponse(t){const e=super.handleResponse(t);return e.ok&&e.data&&(e.data=this.toUIData(e.data)),e}getFilteredData(t){const e={};return this.dataUIMap.forEach((a=>{void 0!==t[a.dataKey]&&(e[a.dataKey]=t[a.dataKey])})),e}})),qc=(t("EditFormController",class extends xc{constructor(){super(...arguments),this.oldData=new En}get view(){return this.ctx.view}async onCreated(){await super.onCreated(),this.service=new Hc(this.model),await this.service.init(this.context),this.autoSave=V(this.autoSave.bind(this),500,{trailing:!0})}async onMounted(){await super.onMounted(),!this.state.isSimple&&this.state.loadDefault&&this.load()}async loadDraft(t){const{context:e,params:a}=this.handlerAbilityParams(t);let i;try{await this.startLoading(),await this.evt.emit("onBeforeLoadDraft",{params:a}),i=await this.service.getDraft(e,a)}catch(t){throw await this.evt.emit("onLoadDraftError",void 0),this.actionNotification("GETDRAFTERROR",{error:t}),t}finally{await this.endLoading()}return this.state.data=i.data,this.formStateNotify("DRAFT"),await this.evt.emit("onLoadDraftSuccess",void 0),this.actionNotification("GETDRAFTSUCCESS"),this.state.isLoaded=!0,this.data}async copy(){const t=Z(this.context),e=Z(this.params),a=(await ibiz.hub.getAppDataEntity(this.model.appDataEntityId,this.model.appId)).keyAppDEFieldId;if(a&&this.params[a]){t[ve(this.model.appDataEntityId)]=this.params[a],delete e[a],delete this.params[a],delete e.srfcopymode,delete this.params.srfcopymode}let i;try{await this.startLoading(),await this.evt.emit("onBeforeLoad",{args:e}),i=await this.service.get(t,e)}catch(t){throw await this.evt.emit("onLoadError",{args:t}),this.actionNotification("GETERROR",{error:t}),t}finally{await this.endLoading()}return i.data.srfkey=void 0,i.data.tempsrfkey=ct(),this.state.modified=!1,this.state.data=i.data,this.formStateNotify("LOAD"),await this.evt.emit("onLoadSuccess",{args:i.data}),this.actionNotification("GETSUCCESS"),this.state.isLoaded=!0,this.data}async load(t){if(this.params.srfcopymode)return this.copy();if(!Ie(this.context,ve(this.model.appDataEntityId)))return this.loadDraft();const{context:e,params:a}=this.handlerAbilityParams(t),i=Z(a);let s;try{await this.startLoading(),await this.evt.emit("onBeforeLoad",{args:i}),s=await this.service.get(e,i)}catch(t){throw await this.evt.emit("onLoadError",{args:t}),this.actionNotification("GETERROR",{error:t}),t}finally{await this.endLoading()}return this.state.modified=!1,this.state.data=s.data,this.oldData=this.data.clone(),this.formStateNotify("LOAD"),await this.evt.emit("onLoadSuccess",{args:s.data}),this.actionNotification("GETSUCCESS"),this.state.isLoaded=!0,this.data}async save(t){const e=!0===(null==t?void 0:t.silent);if(this.state.processing){return await x(500,this.save.bind(this),[t])}if(!await this.validate())throw new o("请检查表单填写!");e||await this.startLoading();const{context:a,data:i}=this.handlerAbilityParams(t),s=i[0],n=0===s.srfuf;let r;try{await this.evt.emit("onBeforeSave",{args:s}),r=n?await this.service.create(a,s):await this.service.update(a,s)}catch(t){throw await this.evt.emit("onSaveError",{args:t}),this.actionNotification("".concat(n?"CREATE":"UPDATE","ERROR"),{error:t}),t}finally{e||await this.endLoading()}const c=!0===(null==t?void 0:t.noFillBack);return r.data&&(c?(this.data.updatedate=r.data.updatedate,this.data.srfkey=r.data.srfkey):T(this.data,r.data),this.oldData=this.data.clone(),this.data.tempsrfkey=this.data.srfkey),this.state.modified=!1,await this.evt.emit("onSaveSuccess",{args:r.data}),this.view.state.isClosing||this.formStateNotify("SAVE"),e||this.actionNotification("".concat(n?"CREATE":"UPDATE","SUCCESS"),{default:"".concat(this.data.srfmajortext||"","保存成功")}),this.emitDEDataChange(n?"create":"update",r.data),this.data}async remove(t){const{context:e,params:a}=this.handlerAbilityParams(t);let i,s=!1;if(await this.evt.emit("onBeforeRemove",{args:this.data}),1===this.data.srfuf){if(s=await ibiz.modal.confirm({title:"提示",desc:"确认删除吗?"}),!s)return!1;await this.startLoading();try{i=await this.service.remove(e,a)}catch(t){throw await this.evt.emit("onRemoveError",{args:t}),this.actionNotification("REMOVEERROR",{error:t}),t}finally{await this.endLoading()}s=i.ok}return this.emitDEDataChange("remove",this.data),this.state.data=new En,this.state.modified=!1,await this.evt.emit("onRemoveSuccess",{args:this.data}),this.actionNotification("REMOVESUCCESS"),s}async goBack(){let t;await this.startLoading();try{t=await this.service.goBack(this.context,this.data)}finally{await this.endLoading()}return t.data&&T(this.data,t.data),this.data}async updateFormItem(t){var e;const a=null==(e=this.model.deformItemUpdates)?void 0:e.find((e=>e.id===t));if(!a)throw new o("没找到".concat(t,"表单项更新"));const{appDEMethodId:i,defiupdateDetails:s,customCode:n,scriptCode:r,showBusyIndicator:c}=a,d=null==s?void 0:s.map((t=>t.id));try{let t;if(c&&this.startLoading(),n&&r)t=Qe.execScriptFn({...this.getEventArgs(),data:this.data},r,{isAsync:!1});else{const e={...this.params,...this.data.getOrigin()},a=await this.service.updateFormItem(i,this.context,e);t=a.data}t&&(null==d?void 0:d.length)&&await Promise.all(d.map((e=>this.setDataValue(e,t[e]))))}finally{c&&this.endLoading()}}async wfStart(t){if(!await this.validate())throw new o("请检查表单填写!");await this.startLoading();const{context:e,params:a}=this.handlerAbilityParams(t);try{await this.service.wfStart(e,a,this.data),this.emitDEDataChange("update",this.data),this.emitDEDataChange("update",{srfdecodename:"SysTodo"})}catch(t){throw this.actionNotification("WFSTARTERROR",{error:t}),t}finally{await this.endLoading()}this.actionNotification("WFSTARTSUCCESS",{default:"流程启动成功"})}async wfSubmit(t){if(!await this.validate())throw new o("请检查表单填写!");await this.startLoading();const{context:e,params:a}=this.handlerAbilityParams(t);try{await this.service.wfSubmit(e,a,this.data),this.emitDEDataChange("update",this.data),this.emitDEDataChange("update",{srfdecodename:"SysTodo"})}catch(t){throw this.actionNotification("WFSUBMITERROR",{error:t}),t}finally{await this.endLoading()}this.actionNotification("WFSUBMITSUCCESS",{default:"流程提交成功"})}async dataChangeNotify(t){await super.dataChangeNotify(t),this.autoSave()}async autoSave(){if(!this.model.enableAutoSave)return;const{autoSaveMode:t}=this.model,e={silent:!0,noFillBack:!0};if(3===t)e.data=this.getDiffData(),e.context=d.create({srfsimple:!0});try{await this.save(e)}catch(t){ibiz.log.error(t)}}getDiffData(){const{data:t}=this.state,e={};return Object.keys(t).forEach((a=>{Array.isArray(t[a])?v(t[a],this.oldData[a])||(e[a]=t[a]):t[a]===this.oldData[a]&&a!==t.srfkeyfield||(e[a]=t[a])})),e.srfuf=t.srfuf,new En(e,this.oldData.$dataUIMap)}setSimpleData(t){const e=this.service.toUIData(t).clone();this.formItems.forEach((t=>{Object.prototype.hasOwnProperty.call(e,t.name)||(e[t.name]=null)})),this.state.modified=!1,this.state.data=e,this.state.isLoaded?this.dataChangeNotify(Object.keys(this.state.data)):(this.formStateNotify("LOAD"),this.state.isLoaded=!0)}onDEDataChange(t){var e;if("OBJECTUPDATED"===t.subtype&&(Q(t.triggerKey)||t.triggerKey!==this.triggerKey)&&this.model.appDataEntityId){const a=ve(this.model.appDataEntityId);if(!t.data||(null==(e=t.data.srfdecodename)?void 0:e.toLowerCase())!==a||t.data.srfkey!==this.data.srfkey)return;this.doNextActive((()=>this.load()),{key:"load"})}}}),t("GridColumnController",class{constructor(t,e){var a;this.isAdaptiveColumn=!1,this.isCustomCode=!1,this.model=t,this.grid=e,this.isAdaptiveColumn="STAR"===t.widthUnit,this.isAdaptiveColumn&&(this.grid.hasAdaptiveColumn=!0),(null==(a=this.deGridDataItem)?void 0:a.customCode)&&(this.isCustomCode=!0)}get context(){return this.grid.context}get params(){return this.grid.params}get enableRowEdit(){return!(!this.grid.model.enableRowEdit||!this.model.enableRowEdit)}get deGridDataItem(){var t;return null==(t=this.grid.model.degridDataItems)?void 0:t.find((t=>t.id===this.model.id))}get valueFormat(){var t;return null==(t=this.deGridDataItem)?void 0:t.format}get dataType(){var t;return null==(t=this.deGridDataItem)?void 0:t.dataType}async init(){await this.onInit()}async onInit(){}getCustomHtml(t){var e;if(null==(e=this.deGridDataItem)?void 0:e.scriptCode)return Qe.execScriptFn({data:t.data},this.deGridDataItem.scriptCode,{singleRowReturn:!0,isAsync:!1})}})),Yc=t("GridRowState",class{constructor(t,e){this.errors={},this.uaColStates={},this.editColStates={},this.uiActionGroupStates={},this.showRowEdit=!1,this.modified=!1,this.processing=!1,this.data=t,this.oldData=t.clone(),Object.keys(this.data).forEach((t=>{void 0===this.errors[t]&&(this.errors[t]=null)})),Object.values(e.uaColumns).forEach((t=>{t.initActionStates(this)})),Object.values(e.fieldColumns).forEach((t=>{t.initActionStates(this)})),Object.values(e.editColumns).forEach((t=>{let a;this.editColStates[t.fieldName]={disabled:!1,readonly:!1,editable:"all"===ibiz.config.grid.editShowMode,required:!1},Object.defineProperty(this.editColStates[t.fieldName],"readonly",{enumerable:!0,configurable:!0,get:()=>void 0!==a?a:!!e.context&&!(!0!==e.context.srfreadonly&&"true"!==e.context.srfreadonly),set:t=>(a=t,!0)})}))}getDiffData(){const t={};return Object.keys(this.data).forEach((e=>{this.data[e]===this.oldData[e]&&e!==this.data.srfkeyfield||(t[e]=this.data[e])})),t.srfuf=this.data.srfuf,t.srfkey=this.data.srfkey,new En(t,this.oldData.$dataUIMap)}}),Qc=t("GridService",class extends vn{initUIDataMap(){var t;if(super.initUIDataMap(),this.model.degridColumns){const e=this.model.degridDataItems||[];null==(t=this.model.degridColumns)||t.forEach((t=>{const i=t.id.toLowerCase(),s=t.appDEFieldId;let n;if(s){const o=s.toLowerCase(),r=e.find((e=>e.id===t.dataItemName));if(!r)throw new a(t,"未找到对应的表格数据项[".concat(s,"]"));n=new fo(i,o,{isOriginField:!0,dataType:r.dataType})}else n=new fo(i,i);this.dataUIMap.set(i,n)}))}}async updateGridEditItem(t,e,a={}){const i=await this.app.deService.getService(e,this.model.appDataEntityId);let s=await i.exec(t,e,a);return s=this.handleResponse(s),s}}),$c={string:25,number:6,integer:9,date:5};var Jc=t("GridController",class extends Ir{constructor(){super(...arguments),this.hasAdaptiveColumn=!1,this.isMultistageHeader=!1,this.addSchemaColumn=!1,this.columns={},this.fieldColumns={},this.uaColumns={},this.editColumns={},this.providers={},this.aggTitle="合计",this.dataExportParam={},this.allExportColumns=[],this.allExportCodelistMap=new Map,this.formatValue=(t,e="")=>{const a="".concat(e);if(!t)return a;if(yt(a,t,!0).isValid()){return yt(a).format(t)}return ibiz.util.text.format(a,t)}}get _evt(){return this.evt}get groupCodeListItems(){var t;return null==(t=this.groupFieldColumn)?void 0:t.codeListItems}get enableAgg(){return"NONE"!==this.model.aggMode}get allowRowEdit(){return!!this.model.enableRowEdit&&this.state.rowEditOpen}get overflowMode(){return ibiz.config.grid.overflowMode}initState(){super.initState(),this.state.rows=[],this.state.noSort=!0===this.model.noSort,this.state.size=this.model.pagingSize||20,this.state.singleSelect=!0===this.model.singleSelect,this.state.columnStates=[],this.state.aggResult={},this.state.rowEditOpen=!1}async onCreated(){await this.initByEntitySchema(),await super.onCreated(),this.service=new Qc(this.model),await this.service.init(this.context),this.initColumnStates(),await this.initGridColumns(),this.dataChangeNotify=C(this.dataChangeNotify.bind(this),((t,e)=>[t[0],Array.from(new Set([...t[1],...e[1]]))]),200),await this.initGroup(),await this.initExportData()}async initByEntitySchema(){if(!this.addSchemaColumn)return;const t=await mr(this.model.appDataEntityId,this.context);if(!t)return;const e=await async function(t,e){var a;if(!t.properties)return;const{properties:i}=t;if(!(Object.keys(i).length>0))return;const s=[];Object.keys(i).forEach((t=>{let e;switch(i[t].type){case"string":e="string","date-time"===i[t].format&&(e="date");break;case"integer":e="integer";break;case"number":e="number";break;default:return void ibiz.log.error("未支持的类型".concat(i[t].type))}s.push({key:t,description:i[t].description,type:e})}));const n={};null==(a=(await ibiz.hub.getAppDataEntity(e.model.appDataEntityId,e.model.appId)).appDEFields)||a.forEach((t=>{n[t.codeName.toLowerCase()]=t.id}));const o=[],r=[];return s.forEach((t=>{o.push({appId:e.model.appId,appDEFieldId:n[t.key],id:t.key,codeName:t.key,columnType:"DEFGRIDCOLUMN",width:150,widthUnit:"PX",valueType:"SIMPLE",caption:t.description,dataItemName:t.key}),r.push({appId:e.model.appId,appDEFieldId:n[t.key],id:t.key,valueType:"SIMPLE",dataType:$c[t.type]})})),{degridColumns:o,degridDataItems:r}}(t,this);if(e&&e.degridColumns.length>0){const{degridColumns:t,degridDataItems:a}=e;this.model=Z(this.model),this.model.degridColumns=[...(this.model.degridColumns||[]).filter((e=>-1===t.findIndex((t=>t.id===e.id)))),...t],this.model.degridDataItems=[...(this.model.degridDataItems||[]).filter((t=>-1===a.findIndex((e=>e.id===t.id)))),...a]}}async initExportData(){var t;if(this.model.dedataExportId&&(this.dataExport=null==(t=this.dataEntity.appDEDataExports)?void 0:t.find((t=>t.id===this.model.dedataExportId)),this.dataExport&&(this.allExportColumns=await this.findAllExportColumns(this.dataExport))),this.allExportColumns.length>0)this.allExportColumns.forEach((t=>{t.codeListItems&&this.allExportCodelistMap.set(t.appDEFieldId,t.codeListItems)})),this.dataExportParam.fields=this.allExportColumns.map((t=>t.appDEFieldId)),this.dataExportParam.header=this.allExportColumns.map((t=>t.caption));else{Object.keys(this.fieldColumns).forEach((t=>{this.fieldColumns[t].codeList&&this.allExportCodelistMap.set(t,this.fieldColumns[t].codeListItems)}));const{degridColumns:t=[]}=this.model;this.dataExportParam.fields=t.map((t=>t.id)),this.dataExportParam.header=t.map((t=>t.caption))}}async initGroup(){if(!this.model.enableGroup)return;const{groupAppDEFieldId:t,groupCodeListId:e,groupMode:i}=this.model;if(this.groupFieldColumn=Object.values(this.fieldColumns).find((e=>e.model.appDEFieldId===t)),!this.groupFieldColumn)throw new a(this.model,"没有配置分组属性的属性列");const s=this.groupFieldColumn.model.id;if(!this.groupFieldColumn.model.appCodeListId)throw new a(this.groupFieldColumn.model,"分组属性的属性列".concat(s,"没有配置代码表"));const n=this.state.columnStates.findIndex((t=>t.key===this.groupFieldColumn.model.codeName));if(-1!==n&&0!==n){if(this.isMultistageHeader)throw new a(this.model,"请将分组属性列".concat(s,"配置为第一列"));const t=this.state.columnStates.splice(n,1);this.state.columnStates.unshift(...t)}if("CODELIST"===i){if(!e)throw new a(this.model,"代码表分组模式需要配置代码表");if(this.groupFieldColumn.model.appCodeListId!==e)throw new a(this.model,"分组代码表与属性列".concat(s,"的代码表不一致"))}this.calcColumnFixed()}async afterLoad(t,e){return await super.afterLoad(t,e),await ba(Object.values(this.fieldColumns).map((async t=>{await t.loadCodeList()})),!1),this.state.rows=e.map((t=>{const e=new Yc(t,this);return this.gridStateNotify(e,"LOAD"),e})),await this.updateRows(this.state.rows),this.calcGroupData(e),this.calcAggResult(e),e}async updateRows(t){for(const e of t)await Promise.all([...Object.values(e.uaColStates).map((t=>t.update(this.context,e.data.getOrigin(),this.model.appDataEntityId))),...Object.values(e.uiActionGroupStates).map((t=>t.update(this.context,e.data.getOrigin(),this.model.appDataEntityId)))])}calcGroupData(t){const{enableGroup:e,groupMode:a}=this.model;if(e){const e=new Map,i="CODELIST"===a,s=this.groupFieldColumn.model.id;i&&this.groupCodeListItems.forEach((t=>{e.set(t.value,[])})),t.forEach((t=>{const a=t[s];i||e.has(a)||e.set(a,[]),e.has(a)&&e.get(a).push(t)})),this.state.groups=[],e.forEach(((t,e)=>{const a=this.groupCodeListItems.find((t=>t.value===e));this.state.groups.push({caption:(null==a?void 0:a.text)||"".concat(e),key:e,children:t})}))}}async loadRemoteAgg(){const{aggMode:t,aggAppDataEntityId:e,aggAppDEDataSetId:i}=this.model;if("ALL"!==t)return;if(!i||!e)throw new a(this.model,"缺少配置聚合实体或聚合数据集");const s=await this.getFetchParams(),n=ibiz.hub.getApp(this.context.srfappid),o=await n.deService.exec(e,i,this.context,void 0,s);o.data.length&&([this.state.remoteAggResult]=o.data)}async getFetchParams(t={}){return!0===this.model.enableItemPrivilege&&(t.srfdataaccessaction=!0),super.getFetchParams(t)}calcAggResult(t){Object.values(this.fieldColumns).forEach((e=>{const a=e.calcFieldAgg(t);a&&(this.state.aggResult[e.model.id]=a)}))}afterRemove(t){super.afterRemove(t);const e=this.findRowStateIndex(t);this.state.rows.splice(e,1),this.state.groups.forEach((e=>{if(e.children.length){const a=e.children.findIndex((e=>e.srfkey===t.srfkey));-1!==a&&e.children.splice(a,1)}}))}async newRow(){const{enableRowEdit:t,enableRowNew:e}=this.model,{editShowMode:a}=ibiz.config.grid;if(!t||!e||!["row","all"].includes(a))return void ibiz.log.error("不支持新建行");if("row"===a){if(this.state.rows.find((t=>t.showRowEdit)))throw new o("请先完成当前行编辑中的行的操作")}const i={...this.params},s=this.calcDefaultValue({},!0);let n;Object.assign(i,s);try{n=await this.service.getDraft(this.context,i)}catch(t){throw this.actionNotification("GETDRAFTERROR",{error:t}),t}const r=n.data;N(r,s),this.state.items.unshift(r);const c=new Yc(r,this);this.state.rows.unshift(c),this.gridStateNotify(c,"DRAFT"),"row"===a&&this.switchRowEdit(this.state.rows[0],!0),this.actionNotification("GETDRAFTSUCCESS",{data:r})}async save(t){if(this.state.isSimple)return;const e=0===t.srfuf,a=this.findRowState(t);if(!a)throw new o("行数据不存在");if(!a.modified)return void ibiz.log.debug("值没有发生改变");if(a.processing)return void await x(500,this.save.bind(this),[t]);if(!await this.validate(a))throw new o("行数据校验不通过,保存取消");let i;this.model.enableRowEditChangedOnly&&(t=a.getDiffData());const s=ve(this.model.appDataEntityId),n=this.context.clone();n[s]=t.srfkey;try{i=e?await this.service.create(n,t):await this.service.update(n,t)}catch(t){throw await this._evt.emit("onSaveError",void 0),this.actionNotification("".concat(e?"CREATE":"UPDATE","ERROR"),{error:t,data:a.data,rowState:a}),t}const r=this.findRowStateIndex(t);this.state.items.splice(r,1,i.data),a.data=i.data,a.oldData=i.data.clone(),a.modified=!1,this.gridStateNotify(a,"SAVE"),await this._evt.emit("onSaveSuccess",void 0),this.emitDEDataChange(e?"create":"update",i.data)}async saveAll(){const t=this.state.rows.filter((t=>t.modified)).map((t=>t.data));t.length&&await ba(t.map((t=>this.save(t))))}async initColumnsController(t){var e;const a=await ls(t,this.model);if(!a)return;this.providers[t.codeName]=a;const i=await a.createController(t,this);this.columns[t.codeName]=i,"DEFGRIDCOLUMN"===t.columnType||"DEFTREEGRIDCOLUMN"===t.columnType?(this.fieldColumns[t.codeName]=i,t.enableRowEdit&&(this.editColumns[t.codeName]=i)):"UAGRIDCOLUMN"===t.columnType?this.uaColumns[t.codeName]=i:"GROUPGRIDCOLUMN"===t.columnType&&(this.isMultistageHeader=!0,await Promise.all((null==(e=t.degridColumns)?void 0:e.map((async t=>{await this.initColumnsController(t)})))||[]))}initColumnStates(){this.state.columnStates=[];const t=localStorage.getItem("".concat(this.view.model.id,".").concat(this.model.name,".columnStates"));if(t){const e=JSON.parse(t);this.addSchemaColumn&&e.schemaColumnStates?this.state.columnStates=e.schemaColumnStates:!this.addSchemaColumn&&e.defaultColumnStates&&(this.state.columnStates=e.defaultColumnStates)}0===this.state.columnStates.length&&r(this.model,(t=>{"GROUPGRIDCOLUMN"!==t.columnType&&this.state.columnStates.push({key:t.codeName,caption:t.caption,hidden:!!t.hideDefault||!!t.hiddenDataItem,uaColumn:"UAGRIDCOLUMN"===t.columnType,adaptive:"STAR"===t.widthUnit})}),{childrenFields:["degridColumns"]}),this.calcColumnFixed()}calcColumnFixed(){const t=this.state.columnStates.filter((t=>!t.hidden)),e=t.length,{frozenFirstColumn:a,frozenLastColumn:i}=this.model;this.hasAdaptiveColumn=!1,t.forEach(((t,s)=>{t.adaptive&&(this.hasAdaptiveColumn=!0),t.uaColumn?t.fixed=s+1<=Math.floor(e/2)?"left":"right":a&&s<a?t.fixed="left":i&&s>=e-i&&(t.fixed="right")}))}async initGridColumns(){this.model.degridColumns&&await Promise.all(this.model.degridColumns.map((async t=>this.initColumnsController(t))))}async setRowValue(t,e,a){if(!Object.prototype.hasOwnProperty.call(t.data,e)||Jo(t.data[e],a)){t.data[e]=a,t.modified=!0,t.processing=!0;try{await this.dataChangeNotify(t,[e]),await this._evt.emit("onGridDataChange",{data:this.state.rows.map((t=>t.data))})}finally{t.processing=!1}}}async dataChangeNotify(t,e){await ba(Object.values(this.editColumns).map((async a=>a.dataChangeNotify(t,e))))}gridStateNotify(t,e){Object.values(this.editColumns).forEach((a=>{a.gridStateNotify(t,e)}))}async validate(t){return-1===(await Promise.all(Object.values(this.editColumns).map((e=>e.validate(t))))).findIndex((t=>!t))}async toggleRowEdit(){if(!this.model.enableRowNew)throw new o("当前表格不支持行编辑,无法切换开启行编辑");this.state.rowEditOpen=!this.state.rowEditOpen}async switchRowEdit(t,e,a=!0){if(!this.allowRowEdit)return;const i=void 0===e?!t.showRowEdit:e;if(t.showRowEdit!==i){if(!1===i)if(a)await this.save(t.data);else{if(0===t.data.srfuf)return t.showRowEdit=!1,this._evt.emit("onRowEditChange",{row:t}),this.remove({data:[t.data],silent:!0});t.cacheData&&(t.data=t.cacheData,delete t.cacheData)}else{if(this.state.rows.find((t=>t.showRowEdit)))throw new o("同时只能有一行开启行编辑");if(1===t.data.srfuf){t.cacheData=Z(t.data);const e=this.calcDefaultValue(t.data,!1);Object.assign(t.data,e)}}t.showRowEdit=i,Object.values(this.editColumns).forEach((e=>{t.editColStates[e.fieldName].editable=i})),this._evt.emit("onRowEditChange",{row:t})}}getSortModel(){return{minorSortAppDEFieldId:this.model.minorSortAppDEFieldId,minorSortDir:this.model.minorSortDir}}setSort(t,e){let a;t&&(a=this.fieldIdNameMap.get(t).toLowerCase()),super.setSort(a,e)}async updateGridEditItem(t,e){var a;const i=null==(a=this.model.degridEditItemUpdates)?void 0:a.find((t=>t.id===e));if(!i)throw new o("没找到".concat(e,"编辑列更新"));const{appDEMethodId:s,degeiupdateDetails:n,customCode:r,scriptCode:c}=i,d=n.map((t=>t.id));let l;if(r&&c)l=Qe.execScriptFn({...this.getEventArgs(),data:t.data},c,{isAsync:!1});else{const e={...this.params,...t.data.getOrigin()},a=await this.service.updateGridEditItem(s,this.context,e);l=a.data}l&&(null==d?void 0:d.length)&&await Promise.all(d.map((e=>this.setRowValue(t,e,l[e]))))}async loadData(t){const{context:e}=this.handlerAbilityParams(t),a=await this.getFetchParams(null==t?void 0:t.viewParam);let i;await this.startLoading();try{i=await this.service.fetch(e,a)}finally{await this.endLoading()}return i.data}async findAllExportColumns(t){var e;const a=ibiz.hub.getApp(this.context.srfappid),i=null==(e=t.dedataExportItems)?void 0:e.map((async t=>{const e={...t};return t.codeListId&&(e.codeList=a.codeList.getCodeList(t.codeListId),e.codeListItems=await a.codeList.get(t.codeListId,this.context)),e}));return i?Promise.all(i):[]}formatExcelData(t){const{fields:e=[]}=this.dataExportParam,a=Z(t.map((t=>e.reduce(((e,a)=>(e[a]=t[a],e)),{}))));return a.forEach((t=>{Object.keys(t).forEach((e=>{var a;let i=t[e];const s=this.allExportColumns.find((t=>t.appDEFieldId===e)),n=this.fieldColumns[e],o=(null==s?void 0:s.format)||(null==n?void 0:n.valueFormat),r=(null==n?void 0:n.model.unitName)||"";i=this.allExportCodelistMap.get(e)?(null==(a=this.allExportCodelistMap.get(e).find((a=>a.value===t[e])))?void 0:a.text)||i:this.formatValue(o,i)+r,t[e]=i}))})),a}async getExportData(t){var e;const{type:a}=t;let i=[];if(a&&"activatedPage"!==a)if("maxRowCount"===a||"customPage"===a){const{size:s}=this.state,{startPage:n,endPage:o}=t,r="customPage"===a?{page:0,offset:(n-1)*s,size:(o-n+1)*s}:{size:(null==(e=this.dataExport)?void 0:e.maxRowCount)||1e3,page:0};i=await this.loadData({viewParam:r})}else"selectedRows"===a&&(i=this.getData());else i=this.state.rows.map((t=>t.data));if(0===i.length)throw new o("无导出数据");return i}async exportData(t){const{header:e}=this.dataExportParam;if(!e)throw new o("无表格列");const a=await this.getExportData(t.params),i=this.formatExcelData(a).map((t=>Object.values(t)));await dr(e,i,this.model.logicName)}calcDefaultValue(t,e){const a={};return Object.values(this.editColumns).forEach((i=>{const{createDV:s,createDVT:n,updateDV:o,updateDVT:r}=i.editItem,c=e?n:r,d=e?s:o,l=ir({name:i.fieldName,valueType:c,defaultValue:d,valueFormat:i.valueFormat},{data:t,context:this.context,params:this.params});void 0!==l&&(a[i.fieldName]=l)})),a}findRowStateIndex(t){const e=0===t.srfuf?"tempsrfkey":"srfkey";return this.state.rows.findIndex((a=>a.data[e]===t[e]))}findRowState(t){const e=this.findRowStateIndex(t);return-1!==e?this.state.rows[e]:void 0}async onRowClick(t){this.setSelection([t]),1===this.state.mdctrlActiveMode&&await this.setActive(t)}convertMultipleLanguages(){const t=e=>{e.forEach((e=>{e.capLanguageRes&&e.capLanguageRes.lanResTag&&(e.caption=ibiz.i18n.t(e.capLanguageRes.lanResTag,e.caption)),"GROUPGRIDCOLUMN"===e.columnType&&e.degridColumns&&t(e.degridColumns)}))};this.model.degridColumns&&this.model.degridColumns.length>0&&t(this.model.degridColumns)}setColumnVisible(t){t.hidden=!t.hidden,this.calcColumnFixed(),this.saveColumnStates()}setGroupParams(t){t.sort?(this.state.sortQuery=t.sort,this.isSetSort=!0):this.state.sortQuery="",t.columnstates?(this.state.columnStates=t.columnstates,this.calcColumnFixed()):this.initColumnStates()}changeColumnStateSort(t,e,a){const i=this.state.columnStates.find((e=>e.key===t));i&&(this.state.columnStates.splice(a,1),this.state.columnStates.splice(e,0,i),this.calcColumnFixed(),this.saveColumnStates())}saveColumnStates(){let t={};const e=localStorage.getItem("".concat(this.view.model.id,".").concat(this.model.name,".columnStates"));e&&(t=JSON.parse(e)),this.addSchemaColumn?t.schemaColumnStates=this.state.columnStates:t.defaultColumnStates=this.state.columnStates,localStorage.setItem("".concat(this.view.model.id,".").concat(this.model.name,".columnStates"),JSON.stringify(t))}actionNotification(t,e){if((null==e?void 0:e.error)&&(null==e?void 0:e.rowState)&&e.error instanceof b){const{details:t}=e.error,{errors:a}=e.rowState;t.forEach((t=>{a[t.name]=t.errorInfo}))}super.actionNotification(t,{...e||{}})}}),Zc=t("GridFieldColumnController",class extends qc{constructor(){super(...arguments),this.codeList=void 0}get isLinkColumn(){return!!this.model.enableLinkView&&!!this.model.linkAppViewId}get hasAction(){return!!this.model.deuiactionId}get fieldName(){return this.model.id.toLowerCase()}async onInit(){await super.onInit(),this.loadCodeList=V(this.loadCodeList,300,{leading:!0,trailing:!1}),this.loadCodeList()}initActionStates(t){const{deuiactionGroup:e}=this.model;if(e&&e.uiactionGroupDetails){const a=new qo;e.uiactionGroupDetails.forEach((t=>{const e=t.uiactionId;if(e){const i=new Ho(t.id,this.grid.context.srfappid,e);a.addState(t.id,i)}})),t.uiActionGroupStates[this.model.codeName]=a}}clickable(t){const e=t.data[this.fieldName];return(this.isLinkColumn||this.hasAction)&&e}handlePublicParams(t,e,a){const{userParam:i}=this.model;if(!i)return{context:e,params:a};const{navigateContexts:s,navigateParams:n}=pe(i);let o={};s&&t&&(o=oe(s,t,a,e));const r=Object.assign(e.clone(),o);let c={};n&&t&&(c=oe(n,t,a,e));return{context:r,params:{...a,...c}}}async openLinkView(t,e){if(!t.data[this.fieldName])return;const a=this.model.linkValueItem||"srfkey",s=t.data[a];if(null==s)throw new i(this.model,"未在行数据中取到 ".concat(a," 的值"));const{linkAppViewId:n}=this.model;if(!n)return;const o=aa(t.data),r=Object.assign(this.context.clone(),{srfkey:s,...o}),c=Z(this.params),{context:d,params:l}=this.handlePublicParams(t.data,r,c),h=await ibiz.commands.execute(No.TAG,n,d,l,{event:e});(null==h?void 0:h.ok)&&this.grid.load()}async triggerAction(t,e){const a=this.model.deuiactionId;await pc.execAndResolved(a,{context:this.context,params:this.params,data:[t.data],view:this.grid.view,event:e},this.model.appId)}async loadCodeList(){const t=this.model.appCodeListId;if(!t)return;const e=ibiz.hub.getApp(this.context.srfappid);this.codeList||(this.codeList=e.codeList.getCodeList(t));const a=await e.codeList.get(t,this.context,this.params);return this.codeListItems=a,a}calcFieldAgg(t){const{aggField:e,aggMode:a,aggValueFormat:s,unitName:n}=this.model;if(Q(a)||"NONE"===a)return;const o=e||this.model.id;let r;if(t=t.filter((t=>!Q(t[o]))),"PAGE"!==this.grid.model.aggMode)throw"ALL"===this.grid.model.aggMode?new i(this.model,"远程聚合暂未支持"):new i(this.grid.model,"暂未支持聚合模式".concat(this.grid.model.aggMode));switch(a){case"SUM":r=t.map((t=>t[o])).reduce(((t,e)=>S(t,e)),0);break;case"AVG":r=t.map((t=>t[o])).reduce(((t,e)=>S(t,e)),0)/t.length;break;case"MAX":r=Math.max(...t.map((t=>t[o])));break;case"MIN":r=Math.min(...t.map((t=>t[o])));break;default:throw new i(this.model,"暂未支持属性列聚合模式".concat(a))}let c="".concat(r);if(s)try{c=ibiz.util.text.format("".concat(r),s)}catch(t){ibiz.log.error("".concat(r," 值格式化错误"))}return c&&n&&(c+=n),c}formatValue(t=""){if("SIMPLE"!==this.model.valueType)return ar.toText(this.model,t);const e="".concat(t);if(!this.valueFormat)return e;if(l.isDate(this.dataType)){const t=yt(e).format(this.valueFormat);return"Invalid Date"!==t?t:e}return ibiz.util.text.format(e,this.valueFormat)}async onActionClick(t,e,a){const i=t.uiactionId;await pc.execAndResolved(i,{context:this.context,params:this.params,data:[e.data],view:this.grid.view,event:a},t.appId)}}),td=(t("GridUAColumnController",class extends qc{initActionStates(t){var e;const{deuiactionGroup:i}=this.model;if(!i)throw new a(this.model,"操作列没有配置界面行为组");if(!(null==(e=i.uiactionGroupDetails)?void 0:e.length))return void ibiz.log.debug("操作列界面行为组没有配置界面行为");const s=new qo;i.uiactionGroupDetails.forEach((t=>{const e=t.uiactionId;if(e){const a=new Ho(t.id,this.grid.context.srfappid,e);s.addState(t.id,a)}})),t.uaColStates[this.model.codeName]=s}async onActionClick(t,e,a){const i=t.uiactionId;await pc.execAndResolved(i,{context:this.context,params:this.params,data:[e.data],view:this.grid.view,event:a},t.appId)}}),t("GridFieldEditColumnController",class extends Zc{constructor(){super(...arguments),this.rules=[]}get unitName(){return this.editItem.unitName}get valueFormat(){return this.model.valueFormat}get valueItemName(){if(this.editItem.editor)return this.editItem.editor.valueItemName}async onInit(){await super.onInit();const t=Ne(this.grid.model,this.model.codeName);t&&(this.editItem=t,this.editItem.editor&&"HIDDEN"!==this.editItem.editor.editorType&&(this.editorProvider=await ss(this.editItem.editor),this.editorProvider&&(this.editor=await this.editorProvider.createController(this.editItem.editor,this),await this.initRules())))}async initRules(){this.rules=[];const t=ga(this.grid.model.degridEditItemVRs||[],this.fieldName);t&&this.rules.push(...tr(t,this.fieldName,this.valueItemName)),this.editItem.editor&&this.rules.push(...er(this.editItem.editor)),this.rules.length>0&&(this.validator=new vt({[this.fieldName]:this.rules}))}async setRowValue(t,e,a){a=a||this.fieldName,await this.grid.setRowValue(t,a,e)}async dataChangeNotify(t,e){const{resetItemNames:a}=this.editItem;let i=!1;a&&a.length>0&&a.forEach((t=>{e.includes(t)&&(i=!0)})),i&&this.setRowValue(t,null),this.calcColumnDisabled(t);const s=t.editColStates[this.fieldName].required;this.calcColumnRequired(t);if(s!==t.editColStates[this.fieldName].required||e.includes(this.fieldName)||e.includes(this.valueItemName)){if(!await this.validate(t))throw new o("".concat(this.editItem.codeName,"校验报错,").concat(t.errors[this.fieldName]))}e.includes(this.fieldName)&&this.editItem.degridEditItemUpdateId&&await this.grid.updateGridEditItem(t,this.editItem.degridEditItemUpdateId)}gridStateNotify(t,e){this.calcColumnDisabled(t),this.calcColumnReadonly(t),this.calcColumnRequired(t)}calcColumnDisabled(t){let e=this.calcEnableCond(t);if(e&&this.grid.scheduler){const a=this.grid.scheduler.triggerItemEnable(this.fieldName,{data:[t.data]});void 0!==a&&(e=a)}t.editColStates[this.fieldName].disabled=!e}calcColumnRequired(t){let e=!1!==this.editItem.allowEmpty;if(e&&this.grid.scheduler){const a=this.grid.scheduler.triggerItemBlank(this.fieldName,{data:[t.data]});void 0!==a&&(e=a)}t.editColStates[this.fieldName].required=!e}calcColumnReadonly(t){var e;const a=!!(null==(e=this.editItem.editor)?void 0:e.readOnly);a&&(t.editColStates[this.fieldName].readonly=a)}calcEnableCond(t){const{enableCond:e}=this.editItem,a=0===t.data.srfuf;switch(e){case 0:return!1;case 1:return a;case 2:return!a;default:return!0}}async validate(t){const e=this.fieldName;if("cell"!==ibiz.config.grid.editShowMode&&!0===t.editColStates[e].required&&("string"==typeof t.data[e]?ot(t.data[e].trimEnd()):ot(t.data[e])))return t.errors[e]="请填写".concat(this.model.caption||""),!1;if(this.rules.length&&this.validator)try{await this.validator.validate(t.data)}catch(a){const{errors:i}=a;return t.errors[e]=i[0].message,!1}return t.errors[e]=null,!0}}),t("GridGroupColumnController",class extends qc{}),t("ListService",class extends vn{initUIDataMap(){var t;super.initUIDataMap(),null==(t=this.model.delistDataItems)||t.forEach((t=>{const e=t.id.toLowerCase(),a=t.appDEFieldId;let i;if(a){const s=a.toLowerCase();i=new fo(e,s,{isOriginField:!0,dataType:t.dataType})}else i=new fo(e,e);this.dataUIMap.set(e,i)}))}})),ed=(t("ListController",class extends Ir{initState(){super.initState(),this.state.noSort=!0===this.model.noSort}async onCreated(){await super.onCreated(),this.state.size=this.model.pagingSize||20,this.service=new td(this.model),await this.service.init(this.context)}getSortModel(){return{minorSortAppDEFieldId:this.model.minorSortAppDEFieldId,minorSortDir:this.model.minorSortDir}}async loadMore(){this.state.total>this.state.items.length&&await this.load({isLoadMore:!0})}async afterLoad(t,e){return await this.handleDataGroup(),e}setData(t){this.state.items=t}getAllData(){return this.state.items}async handleDataGroup(){const{enableGroup:t,groupMode:e}=this.model;t&&e&&("AUTO"===e?this.handleAutoGroup():"CODELIST"===e&&await this.handleCodeListGroup())}handleAutoGroup(){const{groupAppDEFieldId:t}=this.model;if(t){const{items:e}=this.state,a=new Map;e.forEach((e=>{const i=a.get(e[t])||[];i.push(e),a.set(e[t],i)}));const i=[];a.forEach(((t,e)=>{i.push({caption:e,key:e,children:[...t]})})),this.state.groups=i}}async handleCodeListGroup(){const{groupAppDEFieldId:t,groupCodeListId:e}=this.model;if(t&&e){const{items:a}=this.state,i=[],s=ibiz.hub.getApp(this.context.srfappid),n=await s.codeList.get(e,this.context,this.params),o=[];n.forEach((e=>{const s=a.filter((a=>a[t]===e.value));i.push({caption:e.text,key:e.value,children:[...s]}),o.push(e.value)}));const r=a.filter((e=>-1===o.indexOf(e[t])));r.length>0&&i.push({caption:"其他",key:"其他",children:[...r]}),this.state.groups=i}}}),t("PanelController",class extends vr{constructor(t,e,a,i,s){super(t,e,a,i),this.panelItems={},this.providers={},this.container=s}get _evt(){return this.evt}get data(){return this.state.data}initState(){super.initState(),this.state.data={}}setInputData(t){this.inputData=t}getData(){return[this.data]}async onCreated(){var t;await super.onCreated(),await this.initPanelItemControllers(),(null==(t=this.scheduler)?void 0:t.hasControlEventTrigger)&&this._evt.on("onPanelItemEvent",(t=>{this.scheduler.triggerControlEvent(t.panelItemName,t.panelItemEventName,t)}))}async onMounted(){this.load()}async onDestroyed(){var t,e;await super.onDestroyed(),null==(e=(t=this.data).destroy)||e.call(t),Object.values(this.panelItems).forEach((t=>{t.destroy()}))}async initPanelItemControllers(t=this.model.rootPanelItems,e=this,a=void 0){t&&await Promise.all(t.map((async t=>{var i,s;const n=await ps(t,e.model,e.view.model);if(!n)return;e.providers[t.id]=n;const o=await n.createController(t,e,a);e.panelItems[t.id]=o,(null==(i=t.panelItems)?void 0:i.length)&&!o.isDataContainer&&await this.initPanelItemControllers(t.panelItems,e,o),(null==(s=t.panelTabPages)?void 0:s.length)&&await this.initPanelItemControllers(t.panelTabPages,e,o)})))}async load(){var t,e;const a=await this.prepareData();if(!a)throw new o("未获取到面板数据");const i=this.convertData(a);null==(e=(t=this.data).destroy)||e.call(t),this.state.data=i,this.panelStateNotify("LOAD")}async prepareData(){let t;if(1===this.model.dataMode)this.inputData&&(t=this.inputData);else t=this.inputData||{};return t}convertData(t){const e=ke(this.model),a=e.map((t=>t.id)),i=new yo(e,t);return i._evt.on("change",(t=>{a.includes(t)&&this.dataChangeNotify([t])})),i}dataChangeNotify(t){Object.values(this.panelItems).forEach((e=>{e.dataChangeNotify(t)}))}panelStateNotify(t){Object.values(this.panelItems).forEach((e=>{e.panelStateNotify(t)}))}async setDataValue(t,e){Object.prototype.hasOwnProperty.call(this.state.data,t)&&this.state.data[t]===e||(this.state.data[t]=e)}initControlScheduler(t=[]){const e=[...t];r(this.model,(t=>{t.controlLogics&&e.push(...t.controlLogics)}),{childrenFields:["rootPanelItems","panelItems","panelTabPages"]}),super.initControlScheduler(e)}})),ad=(t("ViewLayoutPanelController",class extends ed{async onCreated(){var t;this.preprocessModel(),await super.onCreated(),(null==(t=this.scheduler)?void 0:t.hasControlEventTrigger)&&this.evt.on("onControlEvent",(t=>{this.scheduler.triggerControlEvent(t.triggerControlName,t.triggerEventName,t.triggerEvent)}))}registerToCtx(){}preprocessModel(t){var e;const a=t=>{const e=[];return t.forEach((t=>{"CONTAINER"===t.itemType&&"PANELPART"===t.predefinedType?e.push(...t.panelItems||[]):e.push(t)})),e.forEach((t=>{"CONTAINER"===t.itemType&&this.preprocessModel(t)})),e};t?t.panelItems=a(t.panelItems||[]):(null==(e=this.model.rootPanelItems)?void 0:e.length)&&(this.model.rootPanelItems=a(this.model.rootPanelItems||[]))}}),t("PanelItemState",class{constructor(t){this.parent=t,this.disabled=!1,this.layout={width:"",height:"",extraStyle:{},extraClass:[],contentStyle:{}},this.class={container:[],containerDyna:[],label:[],labelDyna:[]},this.required=!1,this.readonly=!1;let e,a,i=!0;Object.defineProperty(this,"visible",{enumerable:!0,configurable:!0,get(){var t;return!1!==(null==(t=this.parent)?void 0:t.visible)&&i},set:t=>(i=t,!0)}),Object.defineProperty(this,"keepAlive",{enumerable:!0,configurable:!0,get(){return void 0!==e?e:!!this.parent&&this.parent.keepAlive},set:t=>(e=t,!0)}),Object.defineProperty(this,"readonly",{enumerable:!0,configurable:!0,get(){return void 0!==a?a:!!this.context&&!(!0!==this.context.srfreadonly&&"true"!==this.context.srfreadonly)},set:t=>(a=t,!0)})}})),id=(t("PanelItemController",class{constructor(t,e,a){this.model=t,this.panel=e,this.parent=a,this.dynaLogicResult={visible:void 0,disabled:void 0,required:void 0},this.state=this.createState(),this.state.context=this.panel.context}get dataParent(){return this.findDataParent(this)}get data(){return this.dataParent.data}get containerClass(){return[...this.state.class.container,...this.state.class.containerDyna]}get labelClass(){return[...this.state.class.label,...this.state.class.labelDyna]}async init(){var t;!!(null==(t=this.model.panelItemGroupLogics)?void 0:t.find((t=>"PANELVISIBLE"===t.logicCat)))&&(this.state.visible=!1),await this.onInit()}async onInit(){const{layoutPos:t,sysCss:e,labelSysCss:a}=this.model;if(t){const{width:e,height:a}=ge(t);this.state.layout.width="".concat(e),this.state.layout.height="".concat(a)}(null==e?void 0:e.cssName)&&this.state.class.container.push(e.cssName),(null==a?void 0:a.cssName)&&this.state.class.label.push(a.cssName)}destroy(){}createState(){var t;return new ad(null==(t=this.parent)?void 0:t.state)}async dataChangeNotify(t){this.calcDynamicLogic(t),this.calcItemDisabled(this.data),this.calcItemVisible(this.data),this.calcItemRequired(this.data),this.calcDynaClass(this.data)}async panelStateNotify(t){this.calcDynamicLogic([],!0),this.calcItemDisabled(this.data),this.calcItemVisible(this.data),this.calcItemRequired(this.data),this.calcDynaClass(this.data)}calcItemDisabled(t){let{disabled:e}=this.dynaLogicResult;if(!0!==e&&this.panel.scheduler){const a=this.panel.scheduler.triggerItemEnable(this.model.id,{data:[t]});void 0!==a&&(e=!a)}void 0!==e&&(this.state.disabled=e)}calcItemVisible(t){let{visible:e}=this.dynaLogicResult;if(!1!==e&&this.panel.scheduler){const a=this.panel.scheduler.triggerItemVisible(this.model.id,{data:[t]});void 0!==a&&(e=a)}void 0!==e&&(this.state.visible=e)}calcItemRequired(t){let{required:e}=this.dynaLogicResult;if(!0!==e&&this.panel.scheduler){const a=this.panel.scheduler.triggerItemBlank(this.model.id,{data:[t]});void 0!==a&&(e=!a)}void 0!==e&&(this.state.required=e)}calcDynamicLogic(t,e=!1){var a;this.parent&&!this.parent.state.visible||null==(a=this.model.panelItemGroupLogics)||a.forEach((a=>{const i=a.relatedItemNames||[];if(e||A(i,t))try{const t=ta(this.data,a);switch(a.logicCat){case"ITEMBLANK":this.dynaLogicResult.required=!t;break;case"ITEMENABLE":this.dynaLogicResult.disabled=!t;break;case"PANELVISIBLE":this.dynaLogicResult.visible=t}}catch(t){ibiz.log.error(t)}}))}findDataParent(t){const{parent:e}=t;return e?e.isDataContainer?e:this.findDataParent(e):t.panel}calcDynaClass(t){if(this.model.dynaClass){const e=we(this.model.dynaClass,t);e.length&&(this.state.class.containerDyna=e)}if(this.model.labelDynaClass){const e=we(this.model.labelDynaClass,t);e.length&&(this.state.class.labelDyna=e)}}onClick(){this.panel.evt.emit("onPanelItemEvent",{panelItemName:this.model.id,panelItemEventName:"onClick"})}}),t("PickupViewPanelController",class extends vr{async onCreated(){await super.onCreated(),this.mountCounter.enroll(this.model.embeddedAppDEViewId)}updateContextParams(t){super.updateContextParams(t),this.initNavParam()}initNavParam(){const{navigateContexts:t,navigateParams:e}=this.model,a=this.context.clone(),i={...this.params};t&&Object.assign(a,oe(t,this.params,this.context)),e&&Object.assign(i,oe(e,this.params,this.context)),this.state.context=a,this.state.params=i}setEmbedView(t){this.embedView=t,this.embedView.state.isMounted?this.mountCounter.attend(this.model.embeddedAppDEViewId):this.embedView.evt.on("onMounted",(()=>{this.mountCounter.attend(this.model.embeddedAppDEViewId)})),this.embedView.evt.on("onSelectionChange",(t=>{this.evt.emit("onSelectionChange",t)})),this.embedView.evt.on("onDataActive",(t=>{this.evt.emit("onDataActive",{data:t.data})}))}async getSelectedData(){return await this.embedView.call("GetData")}async getAllData(){return await this.embedView.call("GetAllData")}}),t("ItemsValueOPs",["EXISTS","NOTEXISTS"])),sd=/^N_(.\w+)_(.\w+)$/;function nd(t){var e;return"SIMPLE"===(null==(e=t.userParam)?void 0:e.ITEMTYPE)}function od(t){var e;return"HIDDEN"===(null==(e=t.userParam)?void 0:e.ITEMTYPE)}function rd(t){const e=t.split("__")[1].match(sd);return{field:e[1],op:e[2]}}var cd=["ISNULL","ISNOTNULL","EXISTS","NOTEXISTS"],dd=/\$\{[^}]*\}/,ld=t("SearchBarFilterController",class{constructor(t,e,a,i){var s;let n;this.model=t,this.appDataEntity=e,this.context=a,this.params=i,this.noEditor=!1,this.type="FIELD",this.hidden=od(t),t.appDEFieldId&&(n=be(this.appDataEntity,t.appDEFieldId)),this.fieldName=n?n.codeName.toLowerCase():t.id,this.key=this.fieldName,this.label=t.caption||(null==n?void 0:n.logicName)||t.id,this.valueOP=null==(s=t.defsearchMode)?void 0:s.valueOP,this.noEditor=this.valueOP?cd.includes(this.valueOP):!this.model.editor}get valueItem(){return this.editor?this.editor.valueItem:void 0}async init(){if(!this.noEditor){if(!this.model.editor)throw new a(this.model,"缺少编辑器模型");this.editorProvider=await ss(this.model.editor),this.editorProvider&&(this.editor=await this.editorProvider.createController(this.model.editor,this))}}calcEditorProps(t){const e={};let a=t.value;return t.disabled&&dd.test(a)&&(a=a.replace("${context.srfpersonid}","当前用户"),a=a.replace("${context.srforgid}","当前组织")),this.valueItem&&(e[this.valueItem]=t.valueItem),{value:a,data:e}}onEditorChange(t,e,a){this.valueItem&&a===this.valueItem?t.valueItem=e:t.value=e}}),hd=class{constructor(t,e){this.themeUrl="/extension/app_view_themes",this.model=t,this.viewTag=e}async init(t){this.app=ibiz.hub.getApp(this.model.appId)}async fetch(){const t=[{condop:"EQ",condtype:"DEFIELD",fieldname:"app_view_tag",value:this.viewTag}],e=await this.app.net.post("".concat(this.themeUrl,"/fetch_cur_user_all"),{searchconds:t,sort:"create_time,asc"});return e.ok&&(e.data=this.convertBackDataToFront(e.data)),e}async get(t){const e=await this.app.net.get("".concat(this.themeUrl,"/").concat(t));return e.ok&&([e.data]=this.convertBackDataToFront([e.data])),e}async remove(t){return await this.app.net.delete("".concat(this.themeUrl,"/").concat(t))}async create(t){return await this.app.net.post("".concat(this.themeUrl),{name:"".concat(this.viewTag,"___").concat(t),caption:t,app_tag:this.model.appId,app_view_tag:this.viewTag})}async createWithParams(t,e){return await this.app.net.post("".concat(this.themeUrl),{name:t.name,caption:t.caption,app_tag:this.model.appId,app_view_tag:this.viewTag,theme_model:JSON.stringify(e),valid_flag:t.show?1:0})}async createBatch(t){const e=this.convertFrontDataToBack(t);return await this.app.net.post("".concat(this.themeUrl),e)}async update(t,e){const[a]=this.convertFrontDataToBack([e]);return await this.app.net.put("".concat(this.themeUrl,"/").concat(t),a)}async updateBatch(t){const e=this.convertFrontDataToBack(t),a=e.map((t=>t.id)).join(";");return await this.app.net.put("".concat(this.themeUrl,"/").concat(a),e)}convertBackDataToFront(t){return t.map((t=>{const e={...t};return t.id&&(e.id=t.id),t.name&&(e.name=t.name),t.caption&&(e.caption=t.caption),t.theme_model&&(e.searchGroupData=JSON.parse(t.theme_model)),"number"==typeof t.valid_flag&&(e.show=1===t.valid_flag),t.order_value&&(e.order=t.order_value),e}))}convertFrontDataToBack(t){return t.map((t=>{const e={app_tag:this.model.appId,app_view_tag:this.viewTag};return t.id&&(e.id=t.id),t.name&&(e.name=t.name),t.caption&&(e.caption=t.caption),t.searchGroupData&&Object.keys(t.searchGroupData).length>0&&(e.theme_model=JSON.stringify(t.searchGroupData)),"boolean"==typeof t.show&&(e.valid_flag=t.show?1:0),t.order&&(e.order_value=t.order),e}))}},ud="",pd={string:["EQ","NOTEQ","ISNULL","ISNOTNULL","USERLIKE","LIKE","LIFTLIKE","RIGHT_LIKE"],number:["EQ","GT","GTANDEQ","LT","LTANDEQ","NOTEQ","ISNULL","ISNOTNULL","IN","NOTIN"],date:["EQ","GT","GTANDEQ","LT","LTANDEQ","NOTEQ","ISNULL","ISNOTNULL","IN","NOTIN"]},md={};function fd(t,e){if(t.enumSource)return{appId:ud,editorType:"DROPDOWNLIST",singleSelect:!0,valueType:"SIMPLE",appCodeListId:t.enumSource,id:"".concat(t.key,"_").concat(e)};return md["".concat(t.type,"_").concat(e)]}async function gd(t,e,a){var i;if(!t.properties)return[];const{properties:s}=t;if(!(Object.keys(s).length>0))return[];const n=[];Object.keys(s).forEach((t=>{let e;switch(s[t].type){case"string":e="string","date-time"===s[t].format&&(e="date");break;case"integer":case"number":e="number";break;default:return void ibiz.log.error("未支持的类型".concat(s[t].type))}n.push({key:t,description:s[t].description,type:e,enumSource:s[t].enumSource})}));const o={};null==(i=(await ibiz.hub.getAppDataEntity(e,a)).appDEFields)||i.forEach((t=>{o[t.codeName.toLowerCase()]=t.id}));const r=[];return n.forEach((t=>{const e=pd[t.type];e?e.forEach((e=>{t&&r.push({appId:ud,appDEFieldId:o[t.key],id:t.key,caption:t.description,defsearchMode:{appId:ud,valueOP:e},editor:fd(t,e)})})):ibiz.log.error("未支持的类型",t.type)})),r}Object.keys(pd).forEach((t=>{pd[t].forEach((e=>{if(cd.includes(e))return;const a="".concat(t,"_").concat(e);md[a]||("date"!==t||["IN","NOTIN"].includes(e)?md[a]={appId:ud,editorType:"TEXTBOX",id:a}:md[a]={appId:ud,editorType:"DATEPICKER",id:a})}))}));var wd=/^N_(.\w+)_(.\w+)$/,Ed=t("SearchBarFilterItemsController",class extends ld{constructor(t,e,a,i){super(t[0],e,a,i),this.filterModels=t,this.allFields=[],this.subFilterCMap=new Map,this.type="ITEMS"}calcKey(t,e){return"".concat(t.toUpperCase(),"_").concat(e.toUpperCase())}async initMinorAppDE(){var t;const e=this.filterModels[0].appDEFieldId;let a="";if(null==(t=this.appDataEntity.appDEMethodDTOs)||t.find((t=>{var i;const s=null==(i=t.appDEMethodDTOFields)?void 0:i.find((t=>t.appDEFieldId===e));return!!s&&(a=s.refAppDataEntityId,!0)})),!a)throw new o("找不到属性".concat(e,"对应的关联实体"));this.minorAppDE=await ibiz.hub.getAppDataEntity(a,this.context.srfappid)}async initAllFields(){var t;const e=new Map;this.filterModels.forEach((t=>{var a;const i=(null==(a=t.defsearchMode.codeName)?void 0:a.split("__")[1]).match(wd),s=i[1],n=i[2],o=Z(t);o.defsearchMode.valueOP=n,o.id=s;const r=new ld(o,this.appDataEntity,this.context,this.params);this.subFilterCMap.set(this.calcKey(s,n),r),r.hidden||(e.has(s)||e.set(s,{name:s,label:"",valueOPs:[],fieldName:s}),e.get(s).valueOPs.push(n))})),null==(t=this.minorAppDE.appDEFields)||t.forEach((t=>{const a=t.codeName.toUpperCase();e.has(a)&&(e.get(a).label=t.logicName)})),this.allFields=Array.from(e.values()),await Promise.all(Array.from(this.subFilterCMap.values()).map((t=>t.init())))}async init(){await this.initMinorAppDE(),await this.initAllFields(),this.hidden=Array.from(this.subFilterCMap.values()).every((t=>t.hidden))}getSubFilterController(t,e){return this.subFilterCMap.get(this.calcKey(t,e))}});function yd(){return[{nodeType:"GROUP",logicType:"AND",children:[{nodeType:"FIELD",field:null,valueOP:null,value:null}]}]}function vd(t){const e={pass:!1};let a=!1,i=!1;return r(t[0],(t=>{i||("FIELD"===t.nodeType?(a=!0,i=!t.field||!t.valueOP||Q(t.value)):i="ITEMS"===t.nodeType?!t.field||!t.valueOP:!t.logicType)})),a&&!i&&(e.pass=!0),e}function Id(t,e){let a;if("GROUP"===t.nodeType){const i={condop:t.logicType,condtype:"GROUP"};t.children.length>0&&(i.searchconds=t.children.map((t=>Id(t,e)))),a=i,t.notMode&&(i.notmode=t.notMode)}else if("FIELD"===t.nodeType){const e={condtype:"DEFIELD",fieldname:t.field,value:t.value,condop:t.valueOP};t.valueItem&&(e.value=t.valueItem),a=e}else{const i={condop:t.valueOP,fieldname:t.field,condtype:"ITEMS"};t.children.length>0&&(i.searchconds=t.children.map((t=>Id(t,e)))),a=i}return(null==e?void 0:e.after)&&e.after(t,a),a}function Dd(t,e){const{pass:a}=vd(t);if(!a)return;return t.map((t=>Id(t,e)))}function Cd(t){var e,a;let i;if("GROUP"===t.condtype){const a={logicType:t.condop,nodeType:"GROUP",children:[]};(null==(e=t.searchconds)?void 0:e.length)&&(a.children=t.searchconds.map((t=>Cd(t)))),i=a,t.notmode&&(a.notMode=t.notmode)}else if("DEFIELD"===t.condtype){const e={nodeType:"FIELD",field:t.fieldname,value:t.value,valueOP:t.condop};t.valueItem&&(e.valueItem=t.valueItem),i=e}else{const e={nodeType:"ITEMS",field:t.fieldname,valueOP:t.condop,children:[]};(null==(a=t.searchconds)?void 0:a.length)&&(e.children=t.searchconds.map((t=>Cd(t)))),t.simple&&(e.simple=t.simple),i=e}return!0===t.hidden&&(i.hidden=!0),i}function bd(t){let e;if("GROUP"===t.nodeType){const a={condop:t.logicType,condtype:"GROUP"};t.children.length>0&&(a.searchconds=t.children.map((t=>bd(t)))),e=a,t.notMode&&(a.notmode=t.notMode)}else if("FIELD"===t.nodeType){const a={condtype:"DEFIELD",fieldname:t.field,value:t.value,condop:t.valueOP};t.valueItem&&(a.valueItem=t.valueItem),e=a}else{const a={condop:t.valueOP,fieldname:t.field,condtype:"ITEMS"};t.children.length>0&&(a.searchconds=t.children.map((t=>bd(t)))),t.simple&&(a.simple=t.simple),e=a}return!0===t.hidden&&(e.hidden=!0),e}function Ad(t){const{pass:e}=vd(t);if(!e)return;return t.map(bd)}var Pd=t("SearchBarFilterSimpleItemsController",class extends ld{constructor(t,e,a,i){super(t,e,a,i),this.noEditor=!1,this.key=this.model.id,this.type="SIMPLE_ITEMS";const s=rd(t.defsearchMode.codeName);this.subFieldName=s.field,this.subValueOP=s.op}addSimpleFilterNode(t){Object.assign(t,{simple:!0,field:this.fieldName,nodeType:"ITEMS",valueOP:this.valueOP,children:[{nodeType:"FIELD",field:this.subFieldName,valueOP:this.subValueOP,value:null}]})}}),Td=/\$\{[^}]*\}/,xd=(t("SearchBarController",class extends vr{constructor(){super(...arguments),this.placeHolder="",this.filterControllers=[],this.currentEditGroup=null,this.isBackendSearchGroup="SEARCHBAR2"===this.model.searchBarStyle,this.hasDefaultSelect=!1,this.addSchemaFilters=!1}get enableFilter(){return!0===this.model.enableFilter}get searchBarFilters(){return this.model.searchBarFilters||[]}get grid(){return this.ctx.getController("grid")||this.ctx.getController("treegrid")}initState(){super.initState(),this.state.query="",this.state.selectedGroupItem=null,this.state.searchBarGroups=[],this.state.selectedSearchGroupItem=null,this.state.advancedQuickSearch=!1,this.state.quickSearchItems=[],this.state.quickSearchFieldNames=[],this.state.quickSearchPlaceHolder="",this.resetFilter(),this.state.visible=!!(this.model.enableQuickSearch||this.model.enableGroup||this.enableFilter)}async onCreated(){await this.initByEntitySchema(),await super.onCreated();const t=await ibiz.hub.getAppDataEntity(this.model.appDataEntityId,this.context.srfappid);t&&(this.appDataEntity=t,this.calcQuickSearchPlaceholder(),this.initAdvancedQuickSearch()),this.isBackendSearchGroup&&this.view.model.codeName&&(this.service=new hd(this.model,this.view.model.codeName.toLowerCase()),await this.service.init(this.context)),await this.initSearchBarFilters(),await this.initSearBarGroups(!0)}async initByEntitySchema(){var t;if(!this.addSchemaFilters)return;const e=await mr(this.model.appDataEntityId,this.context);if(!e)return;const a=await gd(e,this.model.appDataEntityId,this.model.appId),i=[];null==(t=this.model.searchBarFilters)||t.forEach((t=>{-1===a.findIndex((e=>{var a;return e.appDEFieldId===t.appDEFieldId&&(!(null==(a=t.defsearchMode)?void 0:a.valueOP)||e.defsearchMode.valueOP===t.defsearchMode.valueOP)}))&&i.push(t)})),a.length>0&&(this.model=Z(this.model),this.model.searchBarFilters=a.concat(...i),this.model.enableFilter=!0)}calcQuickSearchPlaceholder(){if(!this.appDataEntity)return;const t=this.appDataEntity.appDEFields.filter((t=>t.enableQuickSearch));if(t.length){const e=[];t.forEach((t=>{t.lnlanguageRes&&t.lnlanguageRes.lanResTag?e.push(ibiz.i18n.t(t.lnlanguageRes.lanResTag,t.logicName)):t.logicName&&e.push(t.logicName)})),e.length>0&&(this.placeHolder=e.join("、"),this.state.quickSearchPlaceHolder=this.placeHolder)}}handleInput(t){this.state.query=t}onSearch(){this.evt.emit("onSearch",void 0)}findFilterController(t,e){return this.filterControllers.find((a=>a.fieldName===t&&(!a.valueOP||a.valueOP===e)))}getFilterParams(){var t;const e={};if(this.state.query&&(e.query=this.state.query,this.state.advancedQuickSearch&&this.state.quickSearchFieldNames.length&&(e.queryconds=this.state.quickSearchFieldNames.map((t=>"n_".concat(t,"_like"))))),(null==(t=this.state.selectedGroupItem)?void 0:t.data)&&"string"==typeof this.state.selectedGroupItem.data&&!this.isBackendSearchGroup){const t=oe(Qe.execSingleLine(this.state.selectedGroupItem.data),this.params,this.context);Object.assign(e,t)}const a=this.calcFilters();return a&&(e.searchconds=a),e}resetFilter(){this.state.filterNodes=[{nodeType:"GROUP",logicType:"AND",children:[{nodeType:"FIELD",field:null,valueOP:null,value:null}]}],this.evt.emit("onSearch",void 0)}async initSearchBarFilters(){var t;if(null==(t=this.searchBarFilters)?void 0:t.length){const t=new Map;this.searchBarFilters.forEach((e=>{var a;if((null==(a=e.defsearchMode)?void 0:a.valueOP)&&id.includes(e.defsearchMode.valueOP)){if(nd(e))return void this.filterControllers.push(new Pd(e,this.appDataEntity,this.context,this.params));const a="".concat(e.appDEFieldId,"_").concat(e.defsearchMode.valueOP);return t.has(a)||t.set(a,[]),void t.get(a).push(e)}const i=new ld(e,this.appDataEntity,this.context,this.params);this.filterControllers.push(i)})),t.size>0&&t.forEach((t=>{const e=new Ed(t,this.appDataEntity,this.context,this.params);this.filterControllers.push(e)})),await Promise.all(this.filterControllers.map((t=>t.init())))}}calcFilters(){if(!this.enableFilter)return;return Dd(this.state.filterNodes,{after:(t,e)=>{"FIELD"===t.nodeType&&L(t.value)&&Td.test(t.value)&&(e.value=Qe.execSingleLine("`".concat(t.value,"`"),{...this.getEventArgs()}))}})}async initSearBarGroups(t=!1){if(this.state.searchBarGroups=[],this.isBackendSearchGroup){this.model.searchBarGroups&&this.model.searchBarGroups.length>0&&(this.state.searchBarGroups=this.model.searchBarGroups.map(((t,e)=>{const a={name:t.id,caption:t.caption,saved:!1,show:!0,searchGroupData:{},order:100*(e+1),defaultSelect:!1,noEdit:!0};if(t.data)try{const e=JSON.parse(t.data);e.theme_model&&(e.theme_model.sort&&(a.searchGroupData.sort=e.theme_model.sort),e.theme_model.columnstates&&(a.searchGroupData.columnstates=e.theme_model.columnstates),e.theme_model.searchconds&&(a.searchGroupData.searchconds=e.theme_model.searchconds)),e.valid_flag&&(a.show="1"===e.valid_flag)}catch(e){ibiz.log.error("".concat(t.data,"非标准JSON格式:"),e)}return t.defaultGroup&&(a.defaultSelect=!0),a})));const e=await this.service.fetch();if(e.ok&&e.data.forEach((t=>{const e=this.state.searchBarGroups.find((e=>e.name===t.name));if(e)T(e,t),e.saved=!0;else{const e=this.state.searchBarGroups.reduce(((t,e,a)=>e.order>this.state.searchBarGroups[t].order?a:t),0);this.state.searchBarGroups.push({saved:!0,show:!0,searchGroupData:{},order:100*(e+2),...t})}})),this.state.searchBarGroups.sort(((t,e)=>t.order-e.order)),this.state.searchBarGroups.forEach(((t,e)=>{t.order=100*(e+1)})),t&&this.state.searchBarGroups&&this.state.searchBarGroups.length>0){this.state.searchBarGroups.find((t=>t.defaultSelect))&&(this.hasDefaultSelect=!0)}}}setDefaultSelect(){if(this.state.searchBarGroups&&this.state.searchBarGroups.length>0){const t=this.state.searchBarGroups.find((t=>t.defaultSelect));t&&this.handleGroupClick(t)}}async handleSave(){if(this.grid&&this.state.selectedSearchGroupItem){const t={searchconds:Ad(this.state.filterNodes),sort:this.grid.state.sortQuery,columnstates:this.grid.state.columnStates};if(this.state.selectedSearchGroupItem.saved)await this.service.update(this.state.selectedSearchGroupItem.id,{searchGroupData:t,show:this.state.selectedSearchGroupItem.show,order:this.state.selectedSearchGroupItem.order}),ibiz.message.success("保存成功");else{const e=await this.service.createWithParams(this.state.selectedSearchGroupItem,t);if(e.ok){const t=this.state.searchBarGroups.find((t=>t.name===e.data.name));t&&(T(t,e.data),t.saved=!0),ibiz.message.success("保存成功")}}}}async handleGroupClick(t){if(this.state.selectedSearchGroupItem=t,t.saved){const e=await this.service.get(t.id);e.ok&&(T(t,e.data),t.show=!0)}if(t.searchGroupData&&t.searchGroupData.searchconds&&t.searchGroupData.searchconds.length>0){const e=t.searchGroupData.searchconds.map((t=>Cd(t)));this.state.filterNodes=e}else this.state.filterNodes=[{nodeType:"GROUP",logicType:"AND",children:[{nodeType:"FIELD",field:null,valueOP:null,value:null}]}];r(this.state.filterNodes[0],(t=>{"FIELD"===t.nodeType&&t.field&&t.valueOP&&L(t.value)&&Td.test(t.value)&&(t.disabled=!0)})),this.grid&&t&&t.searchGroupData&&(this.grid.setGroupParams(t.searchGroupData),await this.grid.load({isInitialLoad:!0}))}initAdvancedQuickSearch(){var t;2===this.model.quickSearchMode&&(null==(t=this.model.searchBarQuickSearchs)?void 0:t.length)&&(this.state.advancedQuickSearch=!0,this.state.quickSearchItems=[],this.state.quickSearchFieldNames=[],this.model.searchBarQuickSearchs.forEach((t=>{const e=be(this.appDataEntity,t.appDEFieldId),a=e.codeName.toLowerCase();this.state.quickSearchItems.push({fieldName:a,label:e.logicName}),this.state.quickSearchFieldNames.push(a)})),this.calcQuickSearchPlaceHolder())}calcQuickSearchPlaceHolder(){if(this.state.advancedQuickSearch)if(this.state.quickSearchFieldNames.length){const t=[];this.state.quickSearchItems.forEach((e=>{this.state.quickSearchFieldNames.includes(e.fieldName)&&t.push(e.label)})),this.state.quickSearchPlaceHolder=t.join("、")}else this.state.quickSearchPlaceHolder=this.placeHolder}}),t("TabExpPanelController",class extends vr{constructor(){super(...arguments),this.isShowCaption=!0,this.isShowIcon=!1}get isCache(){return"CACHE"===this.controlParams.expcache||"NO_CACHE"!==this.controlParams.expcache&&ibiz.config.view.expCacheMode.includes(this.model.controlType)}get routeDepth(){return this.view.modal.routeDepth}initState(){super.initState(),this.state.tabPages=[],this.state.activeName="",this.state.expViewParams={}}async onCreated(){await super.onCreated(),this.layoutPanel=this.view.layoutPanel,this.initTabPages(),this.initIconCaption()}initTabPages(){const t=this.model.controls,e=[];t.forEach((t=>{e.push({caption:t.caption,tabTag:t.id,class:t.sysCss?[t.sysCss.cssName]:[],sysImage:t.sysImage})})),this.state.tabPages=e,e.length>0&&this.initDefaultPage()}initIconCaption(){if(this.params.showmode)switch(this.params.showmode){case"ICONANDSHORTWORD":this.isShowIcon=!0,this.isShowCaption=!0;break;case"ICON":this.isShowIcon=!0,this.isShowCaption=!1;break;case"SHORTWORD":this.isShowIcon=!1,this.isShowCaption=!0}}initDefaultPage(){if(this.state.defaultTabName){const t=this.state.tabPages.find((t=>t.tabTag===this.state.defaultTabName));if(t)return this.state.activeName=t.tabTag,void this.changeToTab(this.activeTabViewPanelModel,void 0!==this.routeDepth&&$o(this.routeDepth))}this.state.activeName=this.state.tabPages[0].tabTag,this.handleTabChange()}changeToTab(t=this.activeTabViewPanelModel,e=!1){const a=this.getNavViewMsg(t);!0===e&&(a.isRoutePushed=!0),this.evt.emit("onNavViewChange",{navViewMsg:a}),this.evt.emit("onTabChange",{tab:t})}get activeTabViewPanelModel(){const{activeName:t}=this.state;return this.model.controls.find((e=>e.id===t))}async handleTabChange(){this.activeTabViewPanelModel&&this.changeToTab()}prepareParams(t){const{navDER:e,navFilter:a,navigateContexts:i,navigateParams:s,appDataEntityId:n}=t,o={deName:ve(n),navFilter:a,pickupDEFName:null==e?void 0:e.pickupDEFName,navContexts:i,navParams:s},r={context:this.context,params:this.params,data:{}},{resultContext:c,resultParams:d}=le(o,r);return{context:Object.assign(this.context.clone(),c,{currentSrfNav:this.state.activeName}),params:{...d,...this.state.expViewParams}}}getNavViewMsg(t){const{context:e,params:a}=this.prepareParams(t);return{key:t.codeName.toLowerCase(),context:e,params:a,viewId:t.embeddedAppDEViewId,isCache:this.isCache,modalOptions:{replace:!0}}}refresh(){const t=this.getNavViewMsg(this.activeTabViewPanelModel);t.key+=ct(),this.evt.emit("onNavViewChange",{navViewMsg:t})}}),t("TreeService",class extends vn{async fetchChildNodes(t,e){const{hasQuery:a}=e;let i=[];if(t){const s=xe(this.model,{parentId:null==t?void 0:t._nodeId,hasQuery:a});if(0===s.length)return;(await ba(s.map((async a=>{const i=Te(this.model,a.childDETreeNodeId);return this.fetchNodeDatasByType(i,a,t,e)})),!1)).forEach((t=>{i.push(...t)}))}else{const t=Pe(this.model);i=await this.fetchNodeDatasByType(t,void 0,void 0,e)}return i}async fetchNodeDatasByType(t,e,a,s){const n=0===xe(this.model,{parentId:t.id,hasQuery:s.hasQuery}).length,o={...s,leaf:n};let r=[];if(t.accessKey){if(!this.app.authority.calcByResCode(t.accessKey))return r}switch(t.treeNodeType){case"STATIC":r=[await this.getStaticNodeData(t,e,a,o)];break;case"DE":r=await this.getDENodeDatas(t,e,a,o);break;case"CODELIST":r=await this.getCodeListNodeDatas(t,e,a,o);break;default:throw new i(t,"".concat(t.treeNodeType,"节点类型未支持"))}const{expandFirstOnly:c,expanded:d,rootNode:l}=t,h=l&&!this.model.rootVisible;return n||await Promise.all(r.map((async(t,e)=>{var a;if(d&&(!c||c&&0===e)||(null==(a=s.defaultExpandedKeys)?void 0:a.length)&&s.defaultExpandedKeys.includes(t._id)||h){const e=await this.fetchChildNodes(t,s);t._children=e}}))),r}async getStaticNodeData(t,e,a,i){return new mo(t,a,{parentValueLevel:null==e?void 0:e.parentValueLevel,leaf:!!i.leaf})}getNodeRSFilterParams(t,e,a){const{parentValueLevel:i,navigateContexts:s,navigateParams:n,parentFilter:o,parentDER1N:r}=t,c=null==r?void 0:r.pickupDEFName,d={...a.params},l={...a.context,...(null==e?void 0:e._context)||{}};let h,u,p,m={};if(e){h=e;for(let t=1;t<i;t++)h=null==h?void 0:h._parent}if(h){m=h._deData||{};const t=Te(this.model,h._nodeId);t.appDataEntityId&&(p=ve(t.appDataEntityId)),u=h._value}const{resultContext:f,resultParams:g}=le({deName:p,navFilter:o?"n_".concat(o.toLowerCase(),"_eq"):void 0,pickupDEFName:c,navParams:n,navContexts:s},{derValue:u,context:l,params:d,data:m});return Object.assign(l,f),Object.assign(d,g),{context:l,params:d,navContext:f,navParams:g}}async getDENodeDatas(t,e,a,i){const{appDEDataSetId:s,appDataEntityId:n}=t,{context:o,params:r,navContext:c,navParams:d}=e?this.getNodeRSFilterParams(e,a,i):{context:i.context,params:i.params,navContext:{},navParams:{}};r.size=t.maxSize||1e3,t.sortAppDEFieldId&&Object.assign(r,{sort:"".concat(t.sortAppDEFieldId.toLowerCase(),",").concat(t.sortDir?t.sortDir.toLowerCase():"asc")});const l=await this.app.deService.exec(n,s,o,r);if(l.data.length){return l.data.map((e=>new po(t,a,{data:e,leaf:!!i.leaf,navContext:c,navParams:d})))}return[]}async getCodeListNodeDatas(t,e,a,i){const{context:s,params:n,navContext:o,navParams:r}=e?this.getNodeRSFilterParams(e,a,i):{context:i.context,params:i.params,navContext:{},navParams:{}},c=await this.app.codeList.get(t.codeListId,s,n);if(c.length){return c.map((e=>new ho(t,a,{data:e,leaf:!!i.leaf,navContext:o,navParams:r})))}return[]}async removeItem(t,e,a={}){var i;const s=(null==(i=this.model.removeControlAction)?void 0:i.appDEMethodId)||"remove";return await this.execWithEntityId(t,s,e,void 0,a)}async execWithEntityId(t,e,a,i,s){const n=this.handleCustomRequestHeader();return await this.app.deService.exec(t,e,a,i,s,n)}})),Nd=t("TreeController",class extends Ir{constructor(){super(...arguments),this.contextMenus={},this.enableQuickSearch=!1,this.dropNodeRss=new Map,this.contextMenuInfos={}}get _evt(){return this.evt}initState(){super.initState(),this.state.defaultExpandedKeys=[],this.state.expandedKeys=[],this.state.navigational=!1,this.state.size=0,this.state.query=""}async onCreated(){var t,e;if(await super.onCreated(),this.state.expandedKeys=[...this.state.defaultExpandedKeys],(null==(t=this.model.detreeNodes)?void 0:t[0].enableQuickSearch)&&(this.enableQuickSearch=!0),this.dataEntity){const t=null==(e=this.dataEntity.appDEFields)?void 0:e.filter((t=>t.enableQuickSearch)),a=[];null==t||t.forEach((t=>{(null==t?void 0:t.lnlanguageRes)&&t.lnlanguageRes.lanResTag?a.push(ibiz.i18n.t(t.lnlanguageRes.lanResTag,t.logicName)):(null==t?void 0:t.logicName)&&a.push(t.logicName)})),a.length>0&&(this.state.placeHolder=a.join("、"))}this.initDropNodeRss(),this.initNodeClickTBUIActionItem(),await this.initService(),await this.initCounter(),this.model.detreeNodes.forEach((t=>{var e,a;(null==(a=null==(e=t.decontextMenu)?void 0:e.detoolbarItems)?void 0:a.length)&&(this.contextMenus[t.decontextMenu.id]=new Dc(t.decontextMenu,this.context,this.params,this.ctx))})),await Promise.all(Object.values(this.contextMenus).map((t=>t.created())))}async onDestroyed(){await super.onDestroyed(),this.counter&&this.counter.destroy()}async initService(){this.service=new xd(this.model),await this.service.init(this.context)}async initCounter(){const{appCounterRefs:t}=this.model,e=null==t?void 0:t[0];e&&(this.counter=await ln.getCounterByRef(e,this.context))}initDropNodeRss(){var t;null==(t=this.model.detreeNodes)||t.forEach((t=>{if(!t.allowDrop)return;const e=[];xe(this.model,{parentId:t.id,hasQuery:!1}).forEach((t=>{var a;if(null==(a=t.parentDER1N)?void 0:a.pickupDEFName){const a=this.getNodeModel(t.childDETreeNodeId);"DE"===(null==a?void 0:a.treeNodeType)&&a.appDataEntityId&&e.push({minorEntityId:a.appDataEntityId,pickupDEFName:t.parentDER1N.pickupDEFName.toLowerCase(),childDETreeNodeId:t.childDETreeNodeId})}})),e.length>0&&this.dropNodeRss.set(t.id,e)}))}initNodeClickTBUIActionItem(){var t;null==(t=this.model.detreeNodes)||t.forEach((t=>{var e;const a=t.decontextMenu;if(null==(e=null==a?void 0:a.detoolbarItems)?void 0:e.length){let e=0;const i=[];r(a,(t=>{if("DEUIACTION"===t.itemType){e+=1;const a=t;200===a.actionLevel&&i.push(a)}}),{childrenFields:["detoolbarItems"]}),this.contextMenuInfos[t.id]={onlyOneActionItem:1===e,clickTBUIActionItem:i[0]}}}))}async load(t={}){const e=!0===t.isInitialLoad;let a;e&&await this.startLoading();try{a=await this.loadNodes()}finally{e&&await this.endLoading()}return await this.afterLoad(t,a),this.state.isLoaded=!0,await this._evt.emit("onLoadSuccess",{isInitialLoad:e}),a}async getFetchParams(t){const e=await super.getFetchParams(t);return this.state.query&&(e.query=this.state.query),e}async loadNodes(t){const e=await this.getFetchParams(),a=!!e.query;let i;this.state.isLoading=!0;try{i=await this.service.fetchChildNodes(t,{context:this.context.clone(),params:e,hasQuery:a,defaultExpandedKeys:this.state.expandedKeys})||[]}finally{this.state.isLoading=!1}return t?t._children=i:this.state.rootNodes=i,await this.afterLoadNodes(i),i}async afterLoadNodes(t){this.state.items=[],r({_children:this.state.rootNodes},(t=>{this.state.items.push(t)}),{childrenFields:["_children"]}),this.state.expandedKeys=this.calcExpandedKeys(t)}async onTreeNodeClick(t,e){var a;const i=null==(a=this.contextMenuInfos[t._nodeId])?void 0:a.clickTBUIActionItem;if(i)return this.doUIAction(i.uiactionId,t,e,i.appId);if(this.state.navigational){const e=this.getNodeModel(t._nodeId);if(!(null==e?void 0:e.navAppViewId))return}if(this.state.singleSelect&&!t._disableSelect){const{selectedData:e}=this.state,a=e.filter((e=>e._id!==t._id));a.length===e.length?this.setSelection(this.state.singleSelect?[t]:e.concat([t])):this.setSelection(a)}1===this.state.mdctrlActiveMode&&await this.setActive(t)}onExpandChange(t,e){const a=this.state.expandedKeys.includes(t._id);if(e&&!a)this.state.expandedKeys.push(t._id);else if(!e&&a){const e=this.state.expandedKeys.indexOf(t._id);-1!==e&&this.state.expandedKeys.splice(e,1)}}async onDbTreeNodeClick(t){2===this.state.mdctrlActiveMode&&await this.setActive(t)}setActive(t){const e=this.parseTreeNodeData(t);return this._evt.emit("onActive",{...e,nodeData:t})}setSelection(t){const e=t.map((t=>t._id)),a=this.state.items.filter((t=>e.includes(t._id)));super.setSelection(a)}getNodeModel(t){var e;return null==(e=this.model.detreeNodes)?void 0:e.find((e=>e.id===t))}getNodeData(t){const e=this.state.items.find((e=>e._id===t));return e||this.state.items.find((e=>e._uuid===t))}async doUIAction(t,e,a,i){const s=this.getEventArgs(),n=this.parseTreeNodeData(e),o=await pc.exec(t,{...s,...n,event:a},i);if(o.closeView)this.view.closeView();else if(o.refresh)switch(o.refreshMode){case 1:this.refreshNodeChildren(e);break;case 2:this.refreshNodeChildren(e,!0);break;case 3:this.refresh()}}parseTreeNodeData(t){let e=null;return e="DE"===t._nodeType?t:{...t,...t._deData||{}},{data:[e],context:Object.assign(this.context.clone(),t._context||{}),params:{...this.params,...t._params||{}}}}calcExpandedKeys(t){let e=[...this.state.expandedKeys];return r({_children:t},(t=>{var a;(null==(a=t._children)?void 0:a.length)&&e.push(t._id)}),{childrenFields:["_children"]}),e=Array.from(new Set(e)),e}async refreshNodeChildren(t,e=!1){const a=t.srfkey?"srfkey":"_id",i=this.state.items.find((e=>e[a]===t[a]));if(!i)return void ibiz.log.error("找不到对应的树节点数据",t);if(e){const{_parent:t}=i;if(!t||!this.model.rootVisible&&this.state.rootNodes.includes(t))return void await this.refresh()}const s=e?i._parent:i,n=await this.loadNodes(s);this._evt.emit("onAfterRefreshParent",{parentNode:s,children:n})}async expandNodeByKey(t){const e=t.filter((t=>!this.state.expandedKeys.includes(t)));if(0===e.length)return;const a=this.state.items.filter((t=>e.includes(t._id)));this.state.expandedKeys.push(...e),0!==a.length&&await Promise.all(a.map((t=>this.loadNodes(t))))}calcAllowDrag(t){const e=this.getNodeModel(t._nodeId);return!0===(null==e?void 0:e.allowDrag)}calcAllowDrop(t,e,a){var i,s;const n=this.getNodeModel(t._nodeId);if("inner"===a)return!!this.findDropNodeRS(e._nodeId,n.appDataEntityId);if((null==(i=t._parent)?void 0:i._id)===(null==(s=e._parent)?void 0:s._id)){const t=this.getNodeModel(e._nodeId);return!0===(null==t?void 0:t.allowOrder)}return!!e._parent&&!!this.findDropNodeRS(e._parent._nodeId,n.appDataEntityId)}findDropNodeRS(t,e){const a=this.dropNodeRss.get(t);return null==a?void 0:a.find((t=>t.minorEntityId===e))}async onNodeDrop(t,e,i){var s,n,o;"inner"!==i||e._leaf||void 0!==e._children||await this.expandNodeByKey([e._id]);const r=[],c=this.getNodeModel(t._nodeId),d="inner"===i?e:e._parent,l=(null==e?void 0:e._id)!==(null==(s=t._parent)?void 0:s._id);let h=this.getNodeModel(e._nodeId);if("inner"===i||(null==(n=e._parent)?void 0:n._id)!==(null==(o=t._parent)?void 0:o._id)){const e=this.findDropNodeRS(d._nodeId,c.appDataEntityId);e&&(t._deData[e.pickupDEFName]=d._value,r.push(t),h=this.getNodeModel(e.childDETreeNodeId))}const u=t._parent._children;if(u.splice(u.indexOf(t),1),"inner"===i)e._children||(e._children=[],e._leaf=!0,this.state.expandedKeys.push(e._id)),e._children.push(t);else{let a=d._children.indexOf(e);"next"===i&&(a+=1),d._children.splice(a,0,t)}("inner"===i||l)&&(t._parent=d,t._nodeId=h.id,this.state.expandedKeys=this.calcExpandedKeys([d]));const{sortAppDEFieldId:p,sortDir:m,allowOrder:f}=h;if(!0===f){if(!p)throw new a(h,"缺少配置排序属性");const e=p.toLowerCase(),i="ASC"===m,s=[...d._children];i||s.reverse();const n=t=>t+(100-t%100),o=t=>t[e]||0;let c;s.forEach(((a,i)=>{const d=a._deData;void 0===c?a===t&&(c=0===i?100:n(o(s[i-1]._deData)),d[e]=c,-1===r.indexOf(a)&&r.push(a)):(c>=o(d)&&(d[e]=n(c),r.push(a)),c=o(d))}))}await this.updateDeNodeData(r),this._evt.emit("onAfterNodeDrop",{isChangedParent:l})}async updateDeNodeData(t){const e=ibiz.hub.getApp(this.context.srfappid);await Promise.all(t.map((async t=>{const a=this.getNodeModel(t._nodeId);let i=t._deData;t._changedOnly&&(i=t.getDiffData());const s=ve(a.appDataEntityId),n=this.context.clone();n[s]=i.srfkey;const o=await e.deService.exec(a.appDataEntityId,"update",n,i);o.data&&(t._deData=o.data,t._oldDeData=o.data.clone())})))}async modifyNodeText(t,e){const i=this.getNodeModel(t._nodeId);if(!i.allowEditText)throw new a(i,"树节点没有配置编辑模式:名称");if("DE"!==t._nodeType)throw new o("不是实体树节点数据");t._text=e,await this.updateDeNodeData([t]),this.emitDEDataChange("update",t._deData)}async handleItemRemove(t,e,a){let i=!1;const s=this.getNodeModel(t._nodeId);if(!s)throw new o("未找到树节点");const n=s.appDataEntityId;if(n){const s=ve(n);if(0!==t.srfuf){const o=e.clone();o[s]=t.srfkey,await this.service.removeItem(n,o,a),i=!0}}return i}onDEDataChange(t){if(!Q(t.triggerKey)&&t.triggerKey===this.triggerKey)return;if("OBJECTCREATED"===t.subtype)return;const e=t.data,a=this.state.items.find((t=>"DE"===t._nodeType&&t._deData&&t._deData.srfdecodename===e.srfdecodename&&t._deData.srfkey===e.srfkey));a&&this.doNextActive((()=>this.refreshNodeChildren(a,!0)),{key:"refresh".concat(a._id)})}}),Sd=t("WizardPanelService",class extends yn{async initialize(t,e={},a={}){var i;const s=null==(i=this.model.initControlAction)?void 0:i.appDEMethodId;let n=await this.exec(s,t,e,a);return n=this.handleResponse(n),n}async finish(t,e={},a={}){var i;const s=null==(i=this.model.finishControlAction)?void 0:i.appDEMethodId;let n=await this.exec(s,t,e,a);return n=this.handleResponse(n),n}}),Rd=(t("WizardPanelController",class extends vr{constructor(){super(...arguments),this.tagHistory=[],this.providers={},this.firstForm=void 0,this.formControllers=new Map,this.steps=[],this.stepTags={},this.formData={}}initState(){super.initState()}async onCreated(){var t,e;await super.onCreated(),this.model.dewizard.dewizardForms.forEach((t=>{var e,a,i;t.firstForm&&(this.firstForm=t);const s="".concat(this.model.name,"_form_").concat(null==(e=t.formTag)?void 0:e.toLowerCase()),n=null==(i=null==(a=this.model.dewizard)?void 0:a.dewizardSteps)?void 0:i.find((e=>e.id===t.dewizardStepId)),o=null==n?void 0:n.stepTag;this.stepTags[s]=o})),null==(e=null==(t=this.model.dewizard)?void 0:t.dewizardSteps)||e.forEach((t=>{this.steps.push(t.stepTag)})),this.service=new Sd(this.model),await this.service.init(this.context);const{deeditForms:a}=this.model;a&&a.length>0&&await Promise.all(a.map((async t=>{const{formTag:e}=t.dewizardForm;if(e){const a=await es(t);a&&(this.providers[e]=a)}})))}get activeWizardForm(){const{activeFormTag:t}=this.state,e=this.model.dewizard.dewizardForms.find((e=>e.formTag===t));return e||ibiz.log.debug("找不到".concat(t,"的向导表单")),e}get activeFormController(){const{activeFormTag:t}=this.state,e=this.formControllers.get(t);if(!e)throw new o("找不到".concat(t,"的表单控制器"));return e}async onFormMounted(t,e){const a=e.ctrl;this.formControllers.set(t,a);const i=await a.load();Object.assign(this.formData,i)}onFormSaved(t){const e=t.data[0];Object.assign(this.formData,e);const a=ve(this.model.appDataEntityId);!this.context[a]&&e&&e.srfkey&&(this.context[a]=e.srfkey)}getWizardFormByTag(t){var e;if(!(null==(e=this.model.dewizard)?void 0:e.dewizardForms))throw new o("没有配置向导表单集合");const a=this.model.dewizard.dewizardForms.find((e=>e.formTag===t));if(!a)throw new o("找不到标识为".concat(t,"的向导表单"));return a}async initialize(){var t;if(null==(t=this.model.initControlAction)?void 0:t.appDEMethodId){const t=await this.service.initialize(this.context,{},this.params),e=ve(this.model.appDataEntityId);if(t.data&&t.data.srfkey&&(this.formData=t.data,this.context[e]=t.data.srfkey),t.data&&this.model.stateAppDEFieldId&&t.data[this.model.stateAppDEFieldId]){const e=this.getWizardFormByTag(t.data[this.model.stateAppDEFieldId]);e&&(this.state.activeFormTag=e.formTag)}}!this.state.activeFormTag&&this.firstForm&&(this.state.activeFormTag=this.firstForm.formTag,this.tagHistory.push(this.firstForm.formTag))}async finish(){await this.service.finish(this.context,this.formData,this.params),this.evt.emit("onFinishSuccess",void 0)}async onPrevClick(){let t,e;if(this.activeFormController.model.goBackControlAction&&(t=await this.activeFormController.goBack()),this.model.stateAppDEFieldId&&t&&t[this.model.stateAppDEFieldId]){this.getWizardFormByTag(t[this.model.stateAppDEFieldId])&&(e=t[this.model.stateAppDEFieldId])}else this.tagHistory.pop(),e=this.tagHistory[this.tagHistory.length-1];if(!e)throw new o("没有上一个表单");this.state.activeFormTag=e}async onNextClick(){const t=await this.activeFormController.save({silent:!0});let e;if(t.srfnextform){this.getWizardFormByTag(t.srfnextform)&&(e=t.srfnextform,this.tagHistory.push(e))}else if(this.model.stateAppDEFieldId&&t[this.model.stateAppDEFieldId]){this.getWizardFormByTag(t[this.model.stateAppDEFieldId])&&(e=t[this.model.stateAppDEFieldId])}else{const t=this.model.dewizard.dewizardSteps,a=this.model.dewizard.dewizardForms;if(t&&a){const a=t.findIndex((t=>t.id===this.activeWizardForm.dewizardStepId)),i=t[a+1];if(!i)throw new o("找不到下一个向导步骤");const s=this.getWizardFormByTag(i.stepTag);s&&s.formTag&&(e=s.formTag)}}if(!e)throw new o("找不到下一个向导表单");this.state.activeFormTag=e,this.tagHistory.push(e)}async onFinishClick(){await this.activeFormController.save(),await this.finish()}}),t("MDCtrlService",class extends vn{initUIDataMap(){var t;super.initUIDataMap(),null==(t=this.model.delistDataItems)||t.forEach((t=>{const e=t.id.toLowerCase(),a=t.appDEFieldId;let i;if(a){const s=a.toLowerCase();i=new fo(e,s,{isOriginField:!0,dataType:t.dataType})}else i=new fo(e,e);this.dataUIMap.set(e,i)}))}})),Md=t("MobMDCtrlRowState",class{constructor(t,e){this.data=t,this.controller=e,this.uaColStates={},this.data=t}}),Od=(t("MDCtrlController",class extends Ir{initState(){super.initState(),this.state.rows=[],this.state.noSort=!0===this.model.noSort,this.state.mdctrlActiveMode=1}async onCreated(){await super.onCreated(),this.service=new Rd(this.model),await this.service.init(this.context),this.setSort()}async loadMore(){this.state.total>this.state.items.length&&!this.state.isLoading&&await this.load({isLoadMore:!0,silent:!0})}async refresh(){this.doNextActive((()=>this.load({isInitialLoad:!0})),{key:"refresh"})}async afterLoad(t,e){return t.isInitialLoad&&(this.state.rows=[]),e&&e.length>0&&this.state.rows.push(...e.map((t=>{const e=new Md(t,this);return this.initActionStates(e),e}))),await this.initGroupCodeListItems(),await this.handleDataGroup(),super.afterLoad(t,e)}setData(t){const e=t.map((t=>new Md(t,this)));this.state.rows=e}getAllData(){return this.state.rows.map((t=>t.data))}async onActionClick(t,e,a){const i=t.uiactionId;await pc.execAndResolved(i,{context:this.context,params:this.params,data:[e.data],view:this.view,event:a},t.appId)}initActionStates(t){const{deuiactionGroup:e,deuiactionGroup2:a}=this.model;e&&this.initUIActionGroup(t,e),a&&this.initUIActionGroup(t,a)}initUIActionGroup(t,e){var a;(null==(a=e.uiactionGroupDetails)?void 0:a.length)||ibiz.log.debug("操作列界面行为组没有配置界面行为");const i=new qo;(e.uiactionGroupDetails||[]).forEach((t=>{const e=t.uiactionId;if(e){const a=new Ho(t.id,this.context.srfappid,e);i.addState(t.id,a)}})),i.update(this.context,t.data.getOrigin()),t.uaColStates[e.id]=i}async handleDataGroup(){const{enableGroup:t,groupMode:e,groupAppDEFieldId:i}=this.model;if(t&&e){if(!i)throw new a(this.model,"分组属性没有配置");"AUTO"===e?this.handleAutoGroup():"CODELIST"===e&&await this.handleCodeListGroup()}}handleAutoGroup(){const{groupAppDEFieldId:t}=this.model;if(t){const{items:e}=this.state,a=new Map;e.forEach((e=>{const i=e[t];Q(i)||(a.has(i)||a.set(i,[]),a.get(i).push(new Md(e,this)))}));const i=[];a.forEach(((t,e)=>{i.push({caption:e,key:e,children:[...t]})})),this.state.groups=i}}async initGroupCodeListItems(){const{groupCodeListId:t}=this.model;if(!t)return;const e=ibiz.hub.getApp(this.context.srfappid);this.groupCodeListItems=await e.codeList.get(t,this.context,this.params)}async handleCodeListGroup(){const{groupAppDEFieldId:t,groupCodeListId:e}=this.model;if(!e)throw new a(this.model,"分组代码表没有配置");const{items:i}=this.state,s=new Map;this.groupCodeListItems.forEach((t=>{s.set(t.value,[])})),i.forEach((e=>{const a=e[t],i=s.get(a);i&&i.push(new Md(e,this))}));const n=[];s.forEach(((t,e)=>{const a=this.groupCodeListItems.find((t=>t.value===e));n.push({caption:a.text,key:a.value,children:t})})),this.state.groups=n}}),t("KanbanService",class extends Ac{async updateGroup(t,e){var a;const i=(null==(a=this.model.updateGroupControlAction)?void 0:a.appDEMethodId)||"update";let s=await this.exec(i,t,e.getOrigin());return s=this.handleResponse(s),s}})),Ld=(t("KanbanController",class extends Pc{get enableEditOrder(){return!0===this.model.enableCardEditOrder}get enableEditGroup(){return!0===this.model.enableCardEditGroup}async initControlService(){this.service=new Od(this.model),await this.service.init(this.context)}initState(){super.initState(),this.state.size=this.model.pagingSize||1e3,this.state.updating=!1,this.state.batching=!1,this.state.selectGroupKey="",this.state.draggable=this.enableEditOrder||this.enableEditGroup,this.state.uaState={}}async onCreated(){await super.onCreated(),this.setToolbarHooks()}sortItems(t){const e=this.model.minorSortAppDEFieldId,{minorSortDir:i}=this.model;if(!e)throw new a(this.model,"排序属性没配置");if(!i)throw new a(this.model,"排序方向没配置");const s="ASC"===i;t.forEach((t=>{const a=t[e];if(Q(a))t[e]=0;else{const e=Number(a);if(Number.isNaN(e))throw new o("".concat(t.srfmajortext,"的排序属性无法转换成数值"))}})),t.sort(((t,a)=>s?t[e]-a[e]:a[e]-t[e]))}async afterLoad(t,e){var a;this.sortItems(this.state.items),super.afterLoad(t,e);const i=[];return null==(a=this.model.dedataViewItems)||a.forEach((t=>{"ACTIONITEM"===t.itemType&&t.deuiactionGroup&&t.deuiactionGroup.uiactionGroupDetails&&i.push(...t.deuiactionGroup.uiactionGroupDetails)})),i&&i.length>0&&e.forEach((t=>{const e=new qo;i.forEach((t=>{const a=t.uiactionId;if(a){const i=new Ho(t.id,this.context.srfappid,a);e.addState(t.id,i)}})),this.state.uaState[t.srfkey]=e})),e.forEach((t=>{this.state.uaState[t.srfkey]&&Object.keys(this.state.uaState[t.srfkey]).length>0&&this.state.uaState[t.srfkey].update(this.context,t.getOrigin(),this.model.appDataEntityId)})),e}async onRowClick(t){const{groupAppDEFieldId:e}=this.model;if(this.state.batching&&e){if(t[e]!==this.state.selectGroupKey)return void(1===this.state.mdctrlActiveMode&&await this.setActive(t))}super.onRowClick(t)}onClickNew(t,e){this.setSelectGroup(e),super.onClickNew(t,e)}async onGroupToolbarClick(t,e,a){this.setSelectGroup(a.key),super.onGroupToolbarClick(t,e,a)}async onGroupActionClick(t,e,a,i){this.setSelectGroup(i.key);const s={...this.params,srfgroup:i},n=t.uiactionId;await pc.execAndResolved(n,{context:this.context,params:s,data:[e],view:this.view,event:a},t.appId)}handleDataGroup(){if(!this.model.enableGroup||"NONE"===this.model.groupMode)throw new o("看板部件必须开启分组");return super.handleDataGroup()}handleAutoGroup(){const{groupAppDEFieldId:t}=this.model;if(t){const{items:e}=this.state,a=new Map;e.forEach((e=>{const i=e[t];Q(i)||(a.has(i)||a.set(i,[]),a.get(i).push(e))}));const i=[];a.forEach(((t,e)=>{const a=this.groupCodeListItems.find((t=>t.value===e));i.push({caption:a.text,color:a.color,key:a.value,children:[...t]})})),this.state.groups=i}}async handleCodeListGroup(){const{groupAppDEFieldId:t,groupCodeListId:e}=this.model;if(!e)throw new a(this.model,"分组代码表没有配置");const{items:i}=this.state,s=new Map;this.groupCodeListItems.forEach((t=>{s.set(t.value,[])})),i.forEach((e=>{const a=e[t],i=s.get(a);i&&i.push(e)}));const n=[];s.forEach(((t,e)=>{const a=this.groupCodeListItems.find((t=>t.value===e));n.push({caption:a.text,color:a.color,key:a.value,children:t})})),this.state.groups=n}async onDragChange(t){if(!this.enableEditGroup&&t.from!==t.to)return void ibiz.message.warning("当前看板不允许调整分组!");const e="ASC"===this.model.minorSortDir,{from:a,to:i,fromIndex:s,toIndex:n}=t,o=this.model.groupAppDEFieldId,r=this.model.minorSortAppDEFieldId,c=[],d=this.state.groups.find((t=>t.key===a)),l=this.state.groups.find((t=>t.key===i));if(!this.enableEditOrder){if(t.from===t.to)return void ibiz.message.warning("当前看板不允许调整次序");const e=d.children[s];return e[o]=t.to,this.updateChangedItems([e])}const h=t=>t+(100-t%100),u=[...l.children],p=[...l.children],m=d.children[s];t.from!==t.to?(m[o]=t.to,p.splice(n,0,m)):(p.splice(s,1),p.splice(n,0,m));const f=d.children.splice(s,1);let g;l.children.splice(n,0,...f),e||(u.reverse(),p.reverse());let w,E=[];p.forEach(((t,e)=>{void 0===g?t!==u[e]&&(g=u[e]?u[e][r]||100:0===e?100:h(u[e-1][r]),t[r]=g,c.push(t)):(g>=t[r]?(E.length>0&&(E.forEach((t=>{t[r]=h(w),c.push(t),w=t[r]})),g=w,w=0,E=[]),t[r]=h(g),c.push(t)):(0===E.length&&(w=g),E.push(t)),g=t[r])})),this.updateChangedItems(c)}async updateChangedItems(t){try{this.state.updating=!0,await Promise.all(t.map((async t=>{const e=ve(this.model.appDataEntityId),a=this.context.clone();a[e]=t.srfkey;const i=await this.service.updateGroup(a,t);if(i.data){const e=this.state.items.findIndex((e=>e.srfkey===t.srfkey));this.state.items.splice(e,1,i.data)}})))}finally{this.state.updating=!1,await this.afterLoad({},this.state.items)}}getFullscreen(){return document.isFullScreen||document.mozIsFullScreen||document.webkitIsFullScreen}onFullScreen(t){const e=this.getFullscreen();return e?document.documentElement.requestFullScreen?document.exitFullScreen():document.documentElement.webkitRequestFullScreen?document.webkitCancelFullScreen():document.documentElement.mozRequestFullScreen&&document.mozCancelFullScreen():t&&(t.webkitRequestFullscreen?t.webkitRequestFullscreen():t.mozRequestFullScreen?t.mozRequestFullScreen():t.msRequestFullscreen?t.msRequestFullscreen():t.requestFullscreen&&t.requestFullscreen()),!e}setSelectGroup(t){this.state.batching||(this.state.selectGroupKey=t)}setGroupController(t,e,a){const i=this.state.groups.find((e=>e.key===t));i&&(i[e]=a)}setToolbarHooks(){this.listenNewController(((t,e)=>{(t.startsWith("".concat(this.model.name,"_quicktoolbar"))||t.startsWith("".concat(this.model.name,"_groupquicktoolbar")))&&this.setQuickToolbarClickHook(t,e),t.startsWith("".concat(this.model.name,"_batchtoolbar"))&&this.setBatchToolbarClickHook(t,e)}))}setQuickToolbarClickHook(t,e){const a=t.split("quicktoolbar_")[1];this.setGroupController(a,"quickToolbarController",e),e.evt.on("onClick",(t=>{const e=t.targetName.split("quicktoolbar_")[1];this.setSelectGroup(e),Object.assign(t.params,{srfgroup:e})}))}setBatchToolbarClickHook(t,e){const a=t.split("batchtoolbar_")[1];this.setGroupController(a,"batchToolbarController",e),e.evt.on("onClick",(t=>{const e=t.targetName.split("batchtoolbar_")[1];this.setSelectGroup(e),Object.assign(t.params,{srfgroup:e})}))}openBatch(t){this.state.selectGroupKey=t,this.state.batching=!0,this.state.selectedData=[],this.state.groups.forEach((t=>{t.selectedData=[]}))}closeBatch(){this.state.selectGroupKey="",this.state.batching=!1,this.state.selectedData=[],this.state.groups.forEach((t=>{t.selectedData=[]}))}}),t("TreeGridExService",class extends xd{})),_d=t("TreeGridExRowState",class{constructor(t,e){this.errors={},this.columnActionsStates={},this.editColStates={},this.modified=!1,this.showRowEdit=!1,this.processing=!1,this.data=t,"DE"===t._nodeType&&(Object.values(e.uaColumns).forEach((t=>{t.initActionStates(this)})),Object.values(e.fieldColumns).forEach((t=>{t.initActionStates(this)})),Object.values(e.fieldColumns).forEach((t=>{this.editColStates[t.name]={disabled:!1,readonly:!1,editable:"all"===ibiz.config.grid.editShowMode,required:!1}})))}}),Fd=t("TreeGridExController",class extends Nd{constructor(){super(...arguments),this.providers={},this.columns={},this.fieldColumns={},this.uaColumns={}}get _evt(){return this.evt}get hasAdaptiveColumn(){return!!Object.values(this.columns).find((t=>t.isAdaptiveColumn))}get overflowMode(){return ibiz.config.grid.overflowMode}get allowRowEdit(){return this.state.rowEditOpen}initState(){super.initState(),this.state.columnStates=[],this.state.rootNodes=[],this.state.rows={},this.state.rowEditOpen=!0}async onCreated(){await super.onCreated(),await this.initGridColumns(),this.initColumnStates()}async initService(){this.service=new Ld(this.model),await this.service.init(this.context)}async initGridColumns(){this.model.detreeColumns&&await Promise.all(this.model.detreeColumns.map((async t=>this.initColumnsController(t))))}async initColumnsController(t){const e=await Ws(t);if(!e)return;this.providers[t.codeName]=e;const a=await e.createController(t,this);this.columns[t.codeName]=a,"DEFGRIDCOLUMN"===t.columnType?this.fieldColumns[t.codeName]=a:"UAGRIDCOLUMN"===t.columnType&&(this.uaColumns[t.codeName]=a)}initColumnStates(){var t;null==(t=this.model.detreeColumns)||t.forEach((t=>{this.state.columnStates.push({key:t.codeName,caption:t.caption,hidden:!!t.hideDefault,uaColumn:"UAGRIDCOLUMN"===t.columnType})})),this.calcColumnFixed()}calcColumnFixed(){const t=this.state.columnStates.filter((t=>!t.hidden)),e=t.length;t.forEach(((t,a)=>{t.uaColumn&&(t.fixed=a+1<=Math.floor(e/2)?"left":"right")}))}getRowState(t){const e=this.getNodeData(t);if(e)return this.state.rows[e._uuid]}async afterLoadNodes(t){await super.afterLoadNodes(t),r({_children:t},(t=>{this.state.rows[t._uuid]=new _d(t,this)}),{childrenFields:["_children"]})}convertMultipleLanguages(){this.model.detreeColumns&&this.model.detreeColumns.length>0&&this.model.detreeColumns.forEach((t=>{t.capLanguageRes&&t.capLanguageRes.lanResTag&&(t.caption=ibiz.i18n.t(t.capLanguageRes.lanResTag,t.caption))}))}async save(t){if(this.state.isSimple)return void ibiz.log.debug("简单模式,不保存");if("DE"!==t._nodeType)throw new o("非实体节点数据不能保存");const e=this.state.rows[t._uuid];if(!e)throw new o("行数据不存在");if(!e.modified)return void ibiz.log.debug("值没有发生改变");if(e.processing)return void await x(500,this.save.bind(this),[t]);const i=this.getNodeModel(t._nodeId),{appDataEntityId:s,updateAppDEActionId:n}=i,r=0===t._deData.srfuf;if(r)throw new o("暂不支持新建");if(!n)throw new a(i,"树节点没有配置更新实体行为");const c=ve(s),d=this.context.clone();d[c]=t._deData.srfkey;const l=ibiz.hub.getApp(this.context.srfappid);let h;try{h=await l.deService.exec(s,n,d,t._deData)}catch(t){throw await this._evt.emit("onSaveError",void 0),this.actionNotification("".concat(r?"CREATE":"UPDATE","ERROR"),{error:t,data:e.data}),t}e.data._deData=h.data,e.modified=!1,this.gridStateNotify(e,"SAVE"),await this._evt.emit("onSaveSuccess",void 0)}async saveAll(){const t=Object.values(this.state.rows).filter((t=>t.modified)).map((t=>t.data));t.length&&await ba(t.map((t=>this.save(t))))}gridStateNotify(t,e){Object.values(this.columns).forEach((a=>{a.gridStateNotify(t,e)}))}async setRowValue(t,e,a){if(!Object.prototype.hasOwnProperty.call(t.data,e)||Jo(t.data[e],a)){t.data[e]=a,t.modified=!0,t.processing=!0;try{await this.dataChangeNotify(t,[e])}finally{t.processing=!1}}}async dataChangeNotify(t,e){await ba(Object.values(this.columns).map((async a=>a.dataChangeNotify(t,e))))}async toggleRowEdit(){this.state.rowEditOpen=!this.state.rowEditOpen}calcDefaultValue(t,e){const a={};return Object.values(this.fieldColumns).forEach((i=>{const s=i.nodeColumnControllerMap.get(t._nodeId);if(!s||!s.nodeEditItem)return;const{createDV:n,createDVT:o,updateDV:r,updateDVT:c}=s.nodeEditItem,d=e?o:c,l=e?n:r,h=ir({name:i.name,valueType:d,defaultValue:l,valueFormat:s.valueFormat},{data:t,context:this.context,params:this.params});void 0!==h&&(a[i.name]=h)})),a}async switchRowEdit(t,e,a=!0){if(!this.allowRowEdit)return;if("DE"!==t.data._nodeType)return;const i=void 0===e?!t.showRowEdit:e;if(t.showRowEdit!==i){if(!1===i)if(a)await this.save(t.data);else{if(0===t.data._deData.srfuf)return t.showRowEdit=!1,this._evt.emit("onRowEditChange",{row:t}),this.remove({data:[t.data],silent:!0});t.cacheData&&(t.data=t.cacheData,delete t.cacheData)}else{if(Object.values(this.state.rows).find((t=>t.showRowEdit)))throw new o("同时只能有一行开启行编辑");if(1===t.data._deData.srfuf){t.cacheData=Z(t.data);const e=this.calcDefaultValue(t.data,!1);Object.assign(t.data,e)}}t.showRowEdit=i,Object.values(this.fieldColumns).forEach((e=>{t.editColStates[e.name].editable=i})),this._evt.emit("onRowEditChange",{row:t})}}}),Vd=t("TreeGridExColumnController",class{constructor(t,e){this.isAdaptiveColumn=!1,this.isCustomCode=!1,this.model=t,this.treeGrid=e,this.isAdaptiveColumn="STAR"===t.widthUnit}get context(){return this.treeGrid.context}get params(){return this.treeGrid.params}get isFirstShowColumn(){const t=this.treeGrid.state.columnStates.find((t=>!t.hidden));return(null==t?void 0:t.key)===this.model.codeName}async init(){await this.onInit()}async onInit(){}gridStateNotify(t,e){}async dataChangeNotify(t,e){}}),kd=t("TreeGridExNodeColumnController",class{constructor(t,e){this.fieldColumn=t,this.nodeModel=e,this.codeList=void 0;const{detreeNodeColumns:i,detreeNodeDataItems:s,detreeNodeEditItems:n}=e,o=null==i?void 0:i.find((t=>t.detreeColumnId===this.fieldColumn.model.id)),r=null==s?void 0:s.find((t=>t.id===o.dataItemName));if(!o||!r)throw new a(e,"节点没有配置对应表格列".concat(this.fieldColumn.name,"的数据项"));if(this.nodeColumn=o,this.nodeDataItem=r,o.enableRowEdit){const t=null==n?void 0:n.find((t=>t.id===o.id));if(!t)throw new a(e,"没有找到对应表格列".concat(this.fieldColumn.name,"的编辑项模型"));this.nodeEditItem=t}}get unitName(){var t;return null==(t=this.nodeEditItem)?void 0:t.unitName}get valueFormat(){return this.nodeColumn.valueFormat}get context(){return this.fieldColumn.context}get params(){return this.fieldColumn.params}get dataType(){var t;return null==(t=this.nodeDataItem)?void 0:t.dataType}get name(){return this.fieldColumn.name}get treeGrid(){return this.fieldColumn.treeGrid}get isLinkColumn(){return!!this.nodeColumn.enableLinkView&&!!this.nodeColumn.linkAppViewId}get hasClickAction(){return!!this.nodeColumn.deuiactionId}get overflowMode(){return this.fieldColumn.treeGrid.overflowMode}async init(){var t;(null==(t=this.nodeEditItem)?void 0:t.editor)&&"HIDDEN"!==this.nodeEditItem.editor.editorType&&(this.editorProvider=await ss(this.nodeEditItem.editor),this.editorProvider&&(this.editor=await this.editorProvider.createController(this.nodeEditItem.editor,this))),this.nodeEditItem||await this.loadCodeList()}initActionStates(t){const{deuiactionGroup:e}=this.nodeColumn;if(e&&e.uiactionGroupDetails){const a=new qo;e.uiactionGroupDetails.forEach((t=>{const e=t.uiactionId;if(e){const i=new Ho(t.id,this.context.srfappid,e);a.addState(t.id,i)}})),t.columnActionsStates[this.name]=a}}onTextClick(t,e){this.isLinkColumn?(e.stopPropagation(),this.openLinkView(t,e)):this.hasClickAction&&(e.stopPropagation(),this.triggerAction(t,e))}async openLinkView(t,e){if(!t.data[this.fieldColumn.name])return;const a=this.nodeColumn.linkValueItem||"srfkey",i=t.data[a];if(null==i)throw new o("未在行数据中取到 ".concat(a," 的值"));const{linkAppViewId:s}=this.nodeColumn;if(!s)return;const n=aa(t.data),r=Object.assign(this.context.clone(),{srfkey:i,...n}),c=Z(this.params),{userParam:d}=this.nodeColumn;if(d){const{navigateContexts:e,navigateParams:a}=pe(d);let i={};e&&t.data&&(i=oe(e,t.data,c,r)),Object.assign(r,i);let s={};a&&t.data&&(s=oe(a,t.data,c,r)),Object.assign(c,s)}const l=await ibiz.commands.execute(No.TAG,s,r,c,{event:e});(null==l?void 0:l.ok)&&this.fieldColumn.treeGrid.refresh()}async triggerAction(t,e){const a=this.nodeColumn.deuiactionId;await pc.execAndResolved(a,{context:this.context,params:this.params,data:[t.data],view:this.treeGrid.view,event:e},this.nodeColumn.appId)}async onActionClick(t,e,a){const i=t.uiactionId;await this.treeGrid.doUIAction(i,e.data,a,t.appId)}formatValue(t=""){if("SIMPLE"!==this.nodeColumn.valueType)return ar.toText(this.nodeColumn,t);const e="".concat(t);if(!this.valueFormat)return e;if(l.isDate(this.dataType)||"createdate"===this.fieldColumn.name){const t=yt(e).format(this.valueFormat);return"Invalid Date"!==t?t:e}return ibiz.util.text.format(e,this.valueFormat)}async loadCodeList(){const t=this.nodeColumn.appCodeListId;if(!t)return;const e=ibiz.hub.getApp(this.context.srfappid);this.codeList||(this.codeList=e.codeList.getCodeList(t));const a=await e.codeList.get(t,this.context,this.params);return this.codeListItems=a,a}gridStateNotify(t,e){if("LOAD"===e||"SAVE"===e){const e=t.columnActionsStates[this.name];e&&"DE"===t.data._nodeType&&e.update(this.context,t.data._deData)}}async setRowValue(t,e,a){a=a||this.name,await this.treeGrid.setRowValue(t,a,e)}}),zd=(t("TreeGridExFieldColumnController",class extends Vd{constructor(){super(...arguments),this.nodeColumnControllerMap=new Map}get name(){return this.model.id}async init(){await this.onInit(),await this.initNodeColumnController()}async initNodeColumnController(){var t;null==(t=this.treeGrid.model.detreeNodes)||t.forEach((t=>{var e;if("DE"!==t.treeNodeType)return;(null==(e=t.detreeNodeColumns)?void 0:e.find((t=>t.detreeColumnId===this.model.id)))&&this.nodeColumnControllerMap.set(t.id,new kd(this,t))})),await Promise.all(Array.from(this.nodeColumnControllerMap.values()).map((t=>t.init())))}initActionStates(t){const e=this.nodeColumnControllerMap.get(t.data._nodeId);e&&e.initActionStates(t)}gridStateNotify(t,e){super.gridStateNotify(t,e);const a=this.nodeColumnControllerMap.get(t.data._nodeId);a&&a.gridStateNotify(t,e)}}),t("TreeGridExUAColumnController",class extends Vd{constructor(){super(...arguments),this.nodeColumnMap=new Map}async init(){await this.onInit(),await this.initNodeColumnMap()}initNodeColumnMap(){var t;null==(t=this.treeGrid.model.detreeNodes)||t.forEach((t=>{var e;if("DE"!==t.treeNodeType)return;const a=null==(e=t.detreeNodeColumns)?void 0:e.find((t=>t.detreeColumnId===this.model.id));a&&this.nodeColumnMap.set(t.id,a)}))}getUIActionGroup(t){let{deuiactionGroup:e}=this.model;if("DE"===t.data._nodeType&&this.nodeColumnMap.get(t.data._nodeId)){const a=this.nodeColumnMap.get(t.data._nodeId);a.deuiactionGroup&&(e=a.deuiactionGroup)}return e}initActionStates(t){var e;const a=this.getUIActionGroup(t);if(!a)return void ibiz.log.warn("".concat(this.model.id,"操作列没有配置界面行为组"));if(!(null==(e=a.uiactionGroupDetails)?void 0:e.length))return void ibiz.log.debug("操作列界面行为组没有配置界面行为");const i=new qo;a.uiactionGroupDetails.forEach((t=>{const e=t.uiactionId;if(e){const a=new Ho(t.id,this.treeGrid.context.srfappid,e);i.addState(t.id,a)}})),t.columnActionsStates[this.model.id]=i}async onActionClick(t,e,a){const i=t.uiactionId;await this.treeGrid.doUIAction(i,e.data,a,t.appId)}gridStateNotify(t,e){if(super.gridStateNotify(t,e),"LOAD"===e||"SAVE"===e){const e=t.columnActionsStates[this.model.id];e&&"DE"===t.data._nodeType&&e.update(this.context,t.data._deData)}}}),t("TreeGridController",class extends Jc{constructor(){super(...arguments),this.treeGridValueField="",this.treeGridParentField=""}initState(){super.initState(),this.state.showTreeGrid=!0}async onCreated(){await super.onCreated(),this.initTreeGridField()}initTreeGridField(){var t,e;const i=null==(t=this.model.degridColumns)?void 0:t.find((t=>4===t.treeColumnMode||12===t.treeColumnMode)),s=null==(e=this.model.degridColumns)?void 0:e.find((t=>2===t.treeColumnMode||3===t.treeColumnMode));if(!i)throw new a(this.model,"树表格无值列模式");if(!s)throw new a(this.model,"树表格无父值列模式");this.treeGridValueField=s.appDEFieldId.toLowerCase(),this.treeGridParentField=i.appDEFieldId.toLowerCase()}switchTreeGridShow(){this.state.showTreeGrid=!this.state.showTreeGrid}}),t("TreeGridService",class extends Qc{}),t("MEditViewPanelService",class extends vn{})),Wd=(t("MEditViewPanelController",class extends Ir{constructor(){super(...arguments),this.parameters=[]}async onCreated(){await super.onCreated(),this.service=new zd(this.model),await this.service.init(this.context),await this.initParameters()}initState(){super.initState(),this.state.panelUiItems=[],this.state.activeTab="",this.state.size=1e3,this.state.isNeedScroll=!1}async initParameters(){var t,e;if(this.model.embeddedAppViewId){const a=await ibiz.hub.getAppView(this.model.embeddedAppViewId);if(a.appDataEntityId){const i=await ibiz.hub.getAppDataEntity(a.appDataEntityId,a.appId);this.parameters=a&&i?[{parameterName:null==(t=i.keyAppDEFieldId)?void 0:t.toLowerCase(),pathName:null==(e=i.codeName)?void 0:e.toLowerCase()}]:[]}}}async afterLoad(t,e){await super.afterLoad(t,e);const a=this.state.panelUiItems.filter((t=>t.id.startsWith("mockId:")));return this.state.panelUiItems=[],this.doItems(e,a),"TAB_TOP"===this.model.panelStyle&&this.state.panelUiItems.length>0&&0===a.length&&(this.state.activeTab=this.state.panelUiItems[0].id),e}handlePanelItemParams(t){const[{parameterName:e}]=this.parameters,a={id:t[e]?t[e]:"mockId:".concat(ct()),context:this.context.clone(),params:{},data:t,srfmajortext:""};return this.parameters.forEach((e=>{const{parameterName:i,pathName:s}=e;t[i]&&!Object.is(t[i],"")&&Object.assign(a.context,{[s]:t[i]}),t.srfmajortext&&!Object.is(t.srfmajortext,"")?Object.assign(a,{srfmajortext:t.srfmajortext}):0===t.srfuf&&Object.assign(a,{srfmajortext:"草稿--新建"})})),a}doItems(t,e){t.forEach((t=>{const e=this.handlePanelItemParams(t);this.state.panelUiItems.push(e)})),e&&this.state.panelUiItems.push(...e)}async handleAdd(){this.state.isNeedScroll=!0,this.doItems([{srfuf:0}]),"TAB_TOP"===this.model.panelStyle&&(this.state.activeTab=this.state.panelUiItems[this.state.panelUiItems.length-1].id)}async handleDelete(t){if(this.state.isNeedScroll=!1,0===t.data.srfuf){const e=this.state.panelUiItems.findIndex((e=>e===t));this.state.panelUiItems.splice(e,1)}else await this.remove({data:[t.data],notRefresh:!0})}async handleTabDelete(t,e){let a=!1;t.id===this.state.activeTab&&e===this.state.panelUiItems.length-1&&e>0&&(a=!0),await this.handleDelete(t),a&&(this.state.activeTab=this.state.panelUiItems[this.state.panelUiItems.length-1].id)}afterRemove(t){super.afterRemove(t);const e=this.state.panelUiItems.findIndex((e=>e.data.srfkey===t.srfkey));-1!==e&&this.state.panelUiItems.splice(e,1)}onViewDataChange(t,e){"onSaveSuccess"===t.eventName&&this.handleDataChange(t.data[0],e)}async handleDataChange(t,e){const a=this.state.panelUiItems.findIndex((t=>t.id===e));if(a<0)throw new o("编辑视图面板部件UI数据不存在");const i=this.state.panelUiItems[a];i.id.startsWith("mockId:")?this.state.panelUiItems[a]=this.handlePanelItemParams(t):i.srfmajortext=t.srfmajortext,"TAB_TOP"===this.model.panelStyle&&(this.state.activeTab=this.state.panelUiItems[a].id)}}),t("MapService",class extends vn{async init(t){await super.init(t)}async fetchAll(t,e={}){var a;const i=[];if(null==(a=this.model.sysMapItems)?void 0:a.length){const a=ibiz.hub.getApp(t.srfappid);await Promise.all(this.model.sysMapItems.map((async s=>{const{appDataEntityId:n,appDEDataSetId:o,customCond:r}=s,c=t.clone(),d={...e};if(r){const a=Qe.execSingleLine(r);if(a){const{navigateContexts:i,navigateParams:s}=pe(a);i&&Object.assign(c,oe(i,e,t)),s&&Object.assign(d,oe(i,e,t))}}const l=await a.deService.exec(n,o,c,d);l.data&&i.push(...l.data.map((t=>new Eo(t,s))))})))}return new p(i,200)}})),Ud=(t("MapController",class extends Ir{initState(){super.initState(),this.state.size=1e3,this.state.pointData=[],this.state.areaData=[],this.calcDefaultOptions()}async onCreated(){await super.onCreated(),this.service=new Wd(this.model),await this.service.init(this.context)}async load(t={}){if(this.state.isSimple)return[];await this.startLoading();try{const e=!0===t.isInitialLoad,{context:a}=this.handlerAbilityParams(t),i=await this.getFetchParams(null==t?void 0:t.viewParam);a.srfareacode=this.state.areaCode;const s=await this.service.fetchAll(a,i);this.state.items=s.data,await this.afterLoad(t,s.data),this.state.isLoaded=!0,await this._evt.emit("onLoadSuccess",{isInitialLoad:e})}catch(t){throw await this._evt.emit("onLoadError",void 0),this.actionNotification("FETCHERROR",{error:t}),t}finally{await this.endLoading()}return this.actionNotification("FETCHSUCCESS"),this.state.items}async afterLoad(t,e){const a=await super.afterLoad(t,e),i=[],s=[];return a.forEach((t=>{"REGION"===t._itemStyle?i.push(t):"POINT"===t._itemStyle&&s.push(t)})),this.state.pointData=s,this.state.areaData=i,a}calcDefaultOptions(){var t;if(this.state.strAreaCode=!1,this.state.defaultAreaCode=1e5,null==(t=this.model.controlParam)?void 0:t.ctrlParams){const{ctrlParams:t}=this.model.controlParam;Object.keys(t).forEach((e=>{const a=t[e];switch(e.toLowerCase()){case"defaultareacode":this.state.defaultAreaCode=a;break;case"strareacode":this.state.strAreaCode="true"===a;break;case"jsonbaseurl":this.state.jsonBaseUrl=a}}))}this.state.defaultAreaCode=this.state.strAreaCode?"".concat(this.state.defaultAreaCode):Number(this.state.defaultAreaCode),this.state.areaCode=this.state.defaultAreaCode}onMapChange(t){this.state.areaCode=t,this.load({}),this.evt.emit("onMapChange",{areaCode:t})}onAreaClick(t){this.evt.emit("onAreaClick",{data:[t]})}onPointClick(t){this.evt.emit("onPointClick",{data:[t]})}}),t("ReportPanelService",class extends yn{async fetch(t,e={}){this.dataEntity=await ibiz.hub.getAppDataEntity(this.model.appDataEntityId,this.model.appId);const a="".concat(this.dataEntity.deapicodeName2,"/report?srfreporttag=").concat(this.model.codeName);let i=await ibiz.net.request(a,{method:"post",data:e});return i=this.handleResponse(i),i}})),Bd=class{constructor(t){this.config={},this.model=t,this.setConfig()}setConfig(){}init(t){this.protoRef=t}load(t){return Promise.resolve(t)}},Gd=class extends Bd{setConfig(){this.config={CONFIG:{fitView:!0,minZoom:.002,layout:{type:"force",preventOverlap:!0,linkDistance:200,nodeSize:80,nodeSpacing:30}},NODELEGENDCONFIG:{valueField:"source_lables||target_lables",selected:"{{return Object.is(data.source_lables, 'NEO4J_ZT') || Object.is(data.target_lables, 'NEO4J_ZT')}}",codeListTag:"web.nodetype"},EDGELEGENDCONFIG:{valueField:"relationship_type",codeListTag:"web.relationshiptype"},PLUGINCONFIG:{gridConfig:{},miniMapConfig:{}},HOOKS:{g6Hooks:[{name:"afterrender",callBack:"{{ const nodes = data.controller.graph.getNodes(); if (nodes.length < 25) { data.controller.graph.zoomTo(1); data.controller.graph.fitCenter() } }}"}],nodeDataHook:"{{ data.forEach(node => { const type = node.data.source_lables || node.data.target_lables; Object.assign(node, { label: node.data.name, size: 66, style: { fill: node.color },donutAttrs: { prop1: 10000, prop2: 10 },donutColorMap: { prop1: node.color, prop2: node.color },icon: {show: true,img: type === 'NEO4J_ZT' ? resource.dir('assets/images/user-avatar.png') : resource.dir('assets/images/phone.png'),width: 40,height: 40}})})}}",edgeDataHook:"{{ data.forEach(edge => {Object.assign(edge, { label: edge.name })}) }}"}}}load(t){return this.protoRef&&this.protoRef.setData(t),Promise.resolve(t)}},jd=class extends Bd{},Kd=class{static getInstance(t){if(!t||!t.appDEReport||!t.appDEReport.reportType)throw new Error("报表面板生成器工厂参数错误,报表面板未指定报表类型");switch(t.appDEReport.reportType){case"USER":return new Gd(t);case"USER2":return new jd(t);default:throw new Error("指定报表".concat(t.appDEReport.reportType,"类型报表面板生成器暂未实现"))}}},Xd=(t("ReportPanelController",class extends vr{get _evt(){return this.evt}initState(){super.initState(),this.state.data={},this.state.searchParams={},this.state.reportType=this.model.appDEReport&&this.model.appDEReport.reportType||""}async onCreated(){await super.onCreated(),this.generator=Kd.getInstance(this.model),this.dataEntity=await ibiz.hub.getAppDataEntity(this.model.appDataEntityId,this.model.appId),this.service=new Ud(this.model),await this.service.init(this.context)}async onMounted(){await super.onMounted(),this.state.loadDefault&&this.load({isInitialLoad:!0})}onDestroyed(){return super.onDestroyed()}async load(t={}){await this.startLoading();try{const{context:e}=this.handlerAbilityParams(t),a=await this.getFetchParams(null==t?void 0:t.viewParam),i=await this.service.fetch(e,a);this.state.data=i.data,await this.afterLoad(t,i.data),this.state.isLoaded=!0,await this._evt.emit("onLoadSuccess",void 0)}catch(t){throw await this._evt.emit("onLoadError",void 0),this.actionNotification("FETCHERROR",{error:t}),t}finally{await this.endLoading()}return this.actionNotification("FETCHSUCCESS"),this.state.data}async afterLoad(t,e){return e}async getFetchParams(t){const e={...this.params};return await this._evt.emit("onBeforeLoad",void 0),Object.assign(e,{...this.state.searchParams}),t&&Object.assign(e,t),e}getData(){return[this.state.data]}async refresh(){this.doNextActive((()=>this.load({isInitialLoad:!1})),{key:"refresh"})}}),t("GanttService",class extends xd{async getNodeDraft(t,e,a,i){var s;const{appDataEntityId:n}=t,{context:o,params:r,navContext:c,navParams:d}=e?this.getNodeRSFilterParams(e,a,i):{context:i.context,params:i.params,navContext:{},navParams:{}},l=await this.app.deService.exec(n,"getdraft",o,r),{data:h}=l;return(null==(s=null==e?void 0:e.parentDER1N)?void 0:s.pickupDEFName)&&a&&(h[e.parentDER1N.pickupDEFName]=a._value),new Co(this.model,t,a,{data:l.data,leaf:!0,navContext:c,navParams:d})}async fetchChildNodes(t,e){const{hasQuery:a}=e;let i=[];if(t){const s=xe(this.model,{parentId:t._nodeId,hasQuery:a});if(0===s.length)return;(await ba(s.map((async a=>{const i=Te(this.model,a.childDETreeNodeId);return this.fetchNodeDatasByType(i,a,t,e)})),!1)).forEach((t=>{i.push(...t)}))}else{const t=Pe(this.model);i=await this.fetchNodeDatasByType(t,void 0,void 0,e)}return i}async fetchNodeDatasByType(t,e,a,s){const n=0===xe(this.model,{parentId:t.id,hasQuery:s.hasQuery}).length,o={...s,leaf:n};let r=[];switch(t.treeNodeType){case"STATIC":r=[await this.getStaticGanttNodeData(t,e,a,o)];break;case"DE":r=await this.getDEGanttNodeDatas(t,e,a,o);break;case"CODELIST":r=await this.getCodeListGanttNodeDatas(t,e,a,o);break;default:throw new i(t,"".concat(t.treeNodeType,"节点类型未支持"))}const{expandFirstOnly:c,expanded:d,rootNode:l}=t,h=l&&!this.model.rootVisible;return n||await Promise.all(r.map((async(t,e)=>{if(d&&(!c||c&&0===e)||h){const e=await this.fetchChildNodes(t,s);t._children=e}}))),r}async getStaticGanttNodeData(t,e,a,i){return new Do(this.model,t,a,{parentValueLevel:null==e?void 0:e.parentValueLevel,leaf:!!i.leaf})}async getDEGanttNodeDatas(t,e,a,i){const{appDEDataSetId:s,appDataEntityId:n}=t,{context:o,params:r,navContext:c,navParams:d}=e?this.getNodeRSFilterParams(e,a,i):{context:i.context,params:i.params,navContext:{},navParams:{}};r.size=t.maxSize||1e3,t.sortAppDEFieldId&&Object.assign(r,{sort:"".concat(t.sortAppDEFieldId.toLowerCase(),",").concat(t.sortDir?t.sortDir.toLowerCase():"asc")});const l=await this.app.deService.exec(n,s,o,r);if(l.data.length){return l.data.map((e=>new Co(this.model,t,a,{data:e,leaf:!!i.leaf,navContext:c,navParams:d})))}return[]}async getCodeListGanttNodeDatas(t,e,a,i){const{context:s,params:n,navContext:o,navParams:r}=e?this.getNodeRSFilterParams(e,a,i):{context:i.context,params:i.params,navContext:{},navParams:{}},c=await this.app.codeList.get(t.codeListId,s,n);if(c.length){return c.map((e=>new bo(this.model,t,a,{data:e,leaf:!!i.leaf,navContext:o,navParams:r})))}return[]}})),Hd=(t("GanttController",class extends Fd{get _evt(){return this.evt}initState(){super.initState(),this.state.ganttStyle={}}onDataChange(t){}async initService(){this.service=new Xd(this.model),await this.service.init(this.context)}setGanttStyle(t){this.state.ganttStyle=t}async onCreated(){await super.onCreated(),this.initViewScheduler()}initViewScheduler(){const t=this.model.appViewLogics||[];0!==t.length&&(this.viewScheduler=ibiz.scheduler.createViewScheduler(t),this.viewScheduler.defaultParamsCb=()=>this.getEventArgs(),this.viewScheduler.hasViewEventTrigger&&this.evt.onAll(((t,e)=>{this.viewScheduler.triggerViewEvent(e)})))}async setActive(t){const e=this.parseTreeNodeData(t);return"DE"===t._nodeType&&await this.onNodeDataActive(e),this._evt.emit("onActive",{...e,nodeData:t})}async onNodeDataActive(t){(await this.openData(t)).cancel||this.refreshNodeChildren(t.data[0],!0)}async openData({data:t,context:e,params:i}){var s,n;const o=t[0],r=this.getNodeModel(o._nodeId),{appDataEntityId:c}=r;e[ve(c).toLowerCase()]=null==(s=o._deData)?void 0:s.srfkey;const d=await(null==(n=this.viewScheduler)?void 0:n.triggerCustom("".concat(r.id.toLowerCase(),"_opendata"),{context:e,params:i,data:t,event:void 0,view:this.view,ctrl:this}));if(-1===d)throw new a(r,"缺少".concat(r.id.toLowerCase(),"_opendata的视图逻辑"));return{cancel:!d||d.ok}}async setRowValue(t,e,a){const{beginDataItemName:i,endDataItemName:s}=this.model;if(!Object.prototype.hasOwnProperty.call(t.data,e)||Jo(t.data[e],a)){t.data[e]=a,e===i?t.data._beginDataItemValue=a:e===s&&(t.data._endDataItemValue=a),t.modified=!0,t.processing=!0;try{await this.dataChangeNotify(t,[e])}finally{t.processing=!1}}}async modifyNodeTime(t,{begin:e,end:a}){if("DE"!==t._nodeType)throw new o("不是实体甘特节点数据");const i=this.getRowState(t._id);if(!i)throw new o("行数据不存在");const{beginDataItemName:s,endDataItemName:n}=this.model;this.setRowValue(i,s,e),this.setRowValue(i,n,a),await this.save(i.data)}async save(t){if(this.state.isSimple)return void ibiz.log.debug("简单模式,不保存");if("DE"!==t._nodeType)throw new o("非实体节点数据不能保存");const e=this.state.rows[t._uuid];if(!e)throw new o("行数据不存在");if(!e.modified)return void ibiz.log.debug("值没有发生改变");if(e.processing)return void await x(500,this.save.bind(this),[t]);const a=this.getNodeModel(t._nodeId),{appDataEntityId:i}=a,s=0===t._deData.srfuf,n=ve(i),r=this.context.clone();r[n]=t._deData.srfkey;const c=ibiz.hub.getApp(this.context.srfappid);let d;try{d=await c.deService.exec(i,s?"create":"update",r,t._deData)}catch(t){throw await this._evt.emit("onSaveError",void 0),this.actionNotification("".concat(s?"CREATE":"UPDATE","ERROR"),{error:t,data:e.data}),t}e.data._deData=d.data,e.modified=!1,this.gridStateNotify(e,"SAVE"),await this._evt.emit("onSaveSuccess",void 0)}async remove(t){const{context:e,params:a,data:i}=this.handlerAbilityParams(t);if(!(null==i?void 0:i.length))throw new o("未选中数据");if(!0!==(null==t?void 0:t.silent)){if(!await ibiz.confirm.error({title:"数据删除",desc:"确认删除数据?"}))return}await this._evt.emit("onBeforeRemove",void 0),await this.startLoading();let s,n=!1;try{const o=ibiz.hub.getApp(this.context.srfappid);await ba(i.map((async t=>{if("DE"===t._nodeType){const i=e.clone(),r=this.getNodeModel(t._nodeId);if(r&&0!==t._deData.srfuf){const{appDataEntityId:e}=r;if(i[ve(e)]=t.srfkey,await o.deService.exec(e,"remove",i,a),!s&&t._parent){const e=this.getNodeData(t._parent._id);s=e}n=!0}this.afterRemove(t)}}))),!0!==(null==t?void 0:t.silent)&&this.actionNotification("REMOVESUCCESS",{data:i,default:"数据[".concat(i.map((t=>t.srfmajortext)).join("、"),"]删除成功!")}),n&&s&&!(null==t?void 0:t.notRefresh)&&await this.refreshNodeChildren(s)}catch(t){throw await this._evt.emit("onRemoveError",void 0),this.actionNotification("REMOVEERROR",{error:t,data:i}),t}finally{await this.endLoading()}this.state.selectedData=[],await this._evt.emit("onRemoveSuccess",void 0)}afterRemove(t){var e;const a=this.state.items.findIndex((e=>e._uuid===t._uuid));if(-1!==a&&this.state.items.splice(a,1),this.state.rows[t._uuid]&&delete this.state.rows[t._uuid],t._parent){const a=this.getNodeData(t._parent._id),i=a._children.findIndex((e=>e._uuid===t._uuid));-1!==i&&(null==(e=a._children)||e.splice(i,1))}}async newRow(t={}){var e;const{data:a}=t,{editShowMode:i}=ibiz.config.grid;if("row"===i){if(Object.values(this.state.rows).find((t=>t.showRowEdit)))throw new o("请先完成当前行编辑中的行的操作")}let s,n;if(a){const t=Array.isArray(a)?a[0]:a;n=this.getNodeData(t._id),s=this.getNodeModel(n._nodeId)}else n=this.state.rootNodes[0],s=Pe(this.model);if(s){let t,a;if(xe(this.model,{parentId:s.id,hasQuery:!1}).forEach((e=>{const i=this.getNodeModel(e.childDETreeNodeId);"DE"===(null==i?void 0:i.treeNodeType)&&i.appDataEntityId&&(t=e,a=i)})),a){let s;try{s=await this.service.getNodeDraft(a,t,n,{hasQuery:!1,context:this.context.clone(),params:this.params})}catch(t){throw this.actionNotification("GETDRAFTERROR",{error:t}),t}const o=this.calcDefaultValue(s,!0);Object.assign(s,o);const r=this.getRowState(n._id);(null==(e=n._children)?void 0:e.length)?n._children.push(s):n._children=[s],this.state.items.push(s);const c=new _d(s,this);this.state.rows[s._uuid]=c,this.gridStateNotify(c,"DRAFT"),"row"===i&&this.switchRowEdit(c,!0),this._evt.emit("onNewRow",{row:r}),this.actionNotification("GETDRAFTSUCCESS",{data:s})}}}}),t("HubController",class{constructor(){this.session={}}login(t,e){return ibiz.auth.login(t,e)}async logout(){const t=await ibiz.auth.logout();if(t){const t=window.location;if(-1!==t.search.indexOf("isAnonymous=true")){const e="".concat(t.origin).concat(t.pathname).concat(t.hash);window.history.replaceState({},"",e)}}return t}})),qd=class{constructor(){this.evt=new dt,this.total=0,this.actions=[],this.doingNum=0,this.finishedStates=[30,40],this.service=new bn}async init(){this.listenMessage()}listenMessage(){ibiz.mc.command.asyncAction.on((async t=>{if(!t.data||"ASYNCACTION"!==t.subtype)return;const e=this.formatAsyncAction(t.data);-1===this.actions.findIndex((t=>t.asyncacitonid===e.asyncacitonid))?this.add(e):this.update(e)}))}formatAsyncAction(t){if(["begintime","endtime","createdate","updatedate"].forEach((e=>{Y(t[e])&&(t[e]=yt(t[e]).format("YYYY-MM-DD HH:mm:ss"))})),!O(t.actionresult))try{const e=JSON.parse(t.actionresult);t.actionresult=e}catch(t){}if(!O(t.completionrate)){const e=Number(t.completionrate);Number.isNaN(e)?t.completionrate=void 0:t.completionrate=e}return t}add(t){this.actions.unshift(t),this.finishedStates.includes(t.actionstate)?this.noticeResult(t):(this.doingNum+=1,ibiz.notice.showDoingNotice({num:this.doingNum})),this.evt.emit("add",Z(t)),this.evt.emit("dataChange")}update(t){const e=this.actions.findIndex((e=>e.asyncacitonid===t.asyncacitonid));this.actions.splice(e,1,t),this.finishedStates.includes(t.actionstate)&&(this.doingNum-=1,this.doingNum<=0&&ibiz.notice.closeDoingNotice(),this.noticeResult(t)),this.evt.emit("change",Z(t)),this.evt.emit("dataChange")}noticeResult(t){ibiz.notice.showAsyncAction(t)}};function Yd(t){if(""===t)return!1;const e=(new DOMParser).parseFromString(t,"text/html");return Array.from(e.body.childNodes).some((t=>1===t.nodeType))}var Qd=class{constructor(){this.evt=new dt,this.total=0,this.unreadCount=0,this.page=0,this.size=20,this.messages=[],this.unreadOnly=!1,this.service=new ro,this.ns=null,this.provider=null}async init(){this.listenMqtt(),await this.refreshUnreadCount()}async load(){try{await this.fetch(!1)}catch(t){ibiz.log.error(t)}}async loadMore(){await this.fetch(!0)}async refreshUnreadCount(){try{this.unreadCount=await this.service.getUnreadNum(),this.evt.emit("unreadCountChange",this.unreadCount)}catch(t){ibiz.log.error(t)}}toggleUnReadOnly(t){const e=void 0===t?!this.unreadOnly:t;this.unreadOnly!==e&&(this.unreadOnly=e,this.evt.emit("unreadOnlyChange",this.unreadOnly),this.load())}async fetch(t=!1){!1===t?this.page=0:this.page+=1;const e={page:this.page,size:this.size,sort:"update_time,desc"};this.unreadOnly&&(e.searchconds=[{condtype:"GROUP",condop:"AND",bnotmode:!1,searchconds:[{condop:"EQ",condtype:"DEFIELD",fieldname:"status",value:"RECEIVED"}]}]);const a=await this.service.fetch(e);this.total=a.total,t?this.messages.push(...a.data):this.messages=a.data,this.evt.emit("dataChange")}listenMqtt(){ibiz.mc.command.internalMessage.on((async t=>{var e;ibiz.log.debug("mqtt internalMessage: ",t),"INTERNALMESSAGE"===t.subtype&&(t.content&&ibiz.notification.default({isHtmlDesc:Yd(t.content),desc:t.content,position:"bottom-right",class:null==(e=this.ns)?void 0:e.b("notice"),onClick:()=>{const e=ibiz.env.isMob?t.mobileurl:t.url;this.provider&&this.provider.openViewByUrl(e)}}),this.refreshUnreadCount())}))}async markRead(t){const e=this.messages.find((e=>e.id===t.id));e&&"RECEIVED"===e.status&&(await this.service.markRead(t.id),e.status="READ",this.unreadCount-=1,this.evt.emit("unreadCountChange",this.unreadCount),this.evt.emit("dataChange"))}async batchMarkRead(){await this.service.batchMarkRead(),await this.fetch(),this.unreadCount=0,this.evt.emit("unreadCountChange",this.unreadCount)}async get(t){return(await this.service.get(t)).data}},$d=class{constructor(){this.evt=new dt,this.total=0,this.asyncAction=new qd,this.internalMessage=new Qd}async init(){this.internalMessage.evt.on("unreadCountChange",(()=>{this.total=this.internalMessage.unreadCount,this.evt.emit("totalChange",this.total)})),await this.internalMessage.init(),await this.asyncAction.init()}},Jd=class{constructor(){this.convert=new _o,this.controller=new Hd,this.appMap=new Map,this.view2appMap=new Map,this.view2appPriorityMap=new Map,this.views=new Map,this.dataEntities=new Map,this.config=new Vo,this.notice=new $d,this.defaultAppIndexViewName="Index"}calcAppViewId(t){let e="";if(-1!==t.indexOf(".")){const a=t.split(".");e=a[a.length-1]}else e=t.toLowerCase();return e}registerModelLoaderProvider(t){this.modelLoaderProvider=t}registerAppView(t){this.views.set(t.codeName.toLowerCase(),t)}registerAppDataEntity(t,e=ibiz.env.appId){this.dataEntities.has(e)||this.dataEntities.set(e,new Map);this.dataEntities.get(e).set(t.id,t)}setAppView(t,e=ibiz.env.appId,a=-1){const i=this.calcAppViewId(t);if(this.view2appMap.has(i)){const t=this.view2appPriorityMap.get(i);if(t&&t<a)return}this.view2appMap.set(i,e),-1!==a&&this.view2appPriorityMap.set(i,a)}hasAppView(t){const e=this.calcAppViewId(t);return this.view2appMap.has(e)}async getAppStyle(t){return this.modelLoaderProvider?this.modelLoaderProvider.getAppStyle(t):null}async getAppView(t){const e=this.calcAppViewId(t),a=this.view2appMap.get(e)||ibiz.env.appId;if(this.appMap.has(a)||await this.createApp(a),this.views.has(e))return this.views.get(e);if(this.modelLoaderProvider){const t=await this.modelLoaderProvider.getAppView(a,e);return this.registerAppView(t),t}throw new o("视图[".concat(e,"]不存在"))}async loadAppView(t,e,a){if(this.modelLoaderProvider){return await this.modelLoaderProvider.loadAppView(t,e,a)}throw new o("视图[".concat(e,"]不存在"))}async getAppDataEntity(t,e=ibiz.env.appId){if(this.dataEntities.has(e)){const a=this.dataEntities.get(e);if(a.has(t))return a.get(t)}if(this.modelLoaderProvider){let a;return a=-1!==t.indexOf(".")?await this.modelLoaderProvider.getAppDataEntity(e,t):await this.modelLoaderProvider.getAppDataEntityByCodeName(e,t),this.registerAppDataEntity(a,e),a}throw new o("未找到应用实体[".concat(t,"]"))}async createApp(t){if(this.appMap.has(t))return this.appMap.get(t);if(!this.modelLoaderProvider)throw new o("请先注册模型加载适配器");const e=await this.modelLoaderProvider.getApp(t),a=new Oo(e);return this.appMap.set(t,a),await this.modelLoaderProvider.initApp(t),await a.init(),this.configCache||(this.configCache=new dn(ibiz.env.appId,"PSSysHub","Global")),a}async getAppAsync(t=ibiz.env.appId){return this.createApp(t)}getApp(t){let e=null;return e=t?t instanceof Object?t.id:t:ibiz.env.appId,this.appMap.get(e)}getAllApps(){return this.appMap.size>0?Array.from(this.appMap.values()):[]}async getAppDEService(t,e,a){return(await this.getAppAsync(t)).deService.getService(a,e)}reset(){this.appMap.clear(),this.configCache=void 0}destroy(){ibiz.hub.getAllApps().forEach((t=>{t.destroy()}))}},Zd=t("EngineFactory",class{constructor(){this.viewEngines=new Map}register(t,e){this.viewEngines.set(t,e)}unRegister(t){this.viewEngines.delete(t)}getEngine(t,...e){const{engineType:a,engineCat:i}=t,s="".concat(i,"_").concat(a),n=this.viewEngines.get(s);if(n)return n(...e);ibiz.log.error("没有".concat(s,"对应的引擎"),t)}}),tl=t("ViewEngineBase",class{constructor(t){this.view=t,this.init(),this.initViewState()}get toolbar(){return this.view.getController("toolbar")}get leftToolbar(){return this.view.getController("lefttoolbar")}get rightToolbar(){return this.view.getController("righttoolbar")}get footerToolbar(){return this.view.getController("footertoolbar")}get viewLayoutPanel(){return this.view.layoutPanel}init(){}handleContextParams(){}async onCreated(){const{childNames:t,modal:e}=this.view;e.hooks.shouldDismiss.tapPromise((async t=>{this.view.state.isLoading&&(t.allowClose=!1)})),t.push("captionbar","toolbar"),this.calcDynamicLayout()}calcDynamicLayout(){const t=this.calcRemoveLayoutModel();ibiz.log.debug("".concat(this.view.model.codeName,"删除模型:").concat(t.join(";"))),this.removeLayoutModel(t)}calcRemoveLayoutModel(){const{model:t}=this.view,e=[];!1===t.showCaptionBar&&e.push("view_captionbar");return["lefttoolbar","righttoolbar","footertoolbar"].forEach((a=>{ue(t,a)||e.push(a)})),this.calcViewHeaderVisible()||e.push("view_header"),ibiz.env.isMob?(this.calcViewFooterVisible()||e.push("view_footer"),this.isExistAndInLayout("lefttoolbar")||this.isExistAndInLayout("righttoolbar")||!1!==t.showCaptionBar||e.push("view_toolbar")):ue(t,"toolbar")||e.push("view_toolbar","toolbar"),e}removeLayoutModel(t,e=this.view.model.viewLayoutPanel){if(!e)return;const a=e.rootPanelItems||e.panelItems||[],i=a.findIndex((e=>t.includes(e.id)));-1!==i&&a.splice(i,1),a.forEach((e=>{"CONTAINER"===e.itemType&&this.removeLayoutModel(t,e)}))}async onMounted(){const{model:t,childNames:e}=this.view;ibiz.log.debug("".concat(t.id,"的子组件:").concat(e.join(";"),"都已mounted"))}async onDestroyed(){}async call(t,e){if("GetData"===t)return this.getData()}initViewState(){}getData(){return[]}calcViewHeaderVisible(){let t=!1;const{model:e}=this.view;return e.showCaptionBar&&(t=!0),ibiz.env.isMob?(this.isExistAndInLayout("lefttoolbar")&&(t=!0),this.isExistAndInLayout("righttoolbar")&&(t=!0)):this.isExistAndInLayout("toolbar")&&(t=!0),t}isExistAndInLayout(t){const e=this.view.model.viewLayoutPanel;if(!e)return!1;const a=I(e,t,{compareField:"id",childrenFields:["panelItems","rootPanelItems"]}),{model:i}=this.view,s=ue(i,t);let n=!(!a||!s);if("TOOLBAR"===(null==s?void 0:s.controlType)){const t=s.detoolbarItems;n=!!(n&&t&&t.length>0)}return n}calcViewFooterVisible(){let t=!1;return this.isExistAndInLayout("footertoolbar")&&(t=!0),t}async loadEntityData(){const{appDataEntityId:t}=this.view.model,{evt:e,context:a,params:i}=this.view;if(!t)throw new o("该视图没有实体,无法加载实体数据");const s=ibiz.hub.getApp(a.srfappid),n=await s.deService.exec(t,"get",a,i),{data:r}=n;r&&(this.view.state.srfactiveviewdata=r,e.emit("onDataChange",{actionType:"LOAD",data:[r]}),r.srfkey&&e.emit("onViewInfoChange",{dataInfo:r.srfmajortext||""}))}}),el=(t("MDViewEngine",class extends tl{get xdataControlName(){return this.view.model.xdataControlName}get searchForm(){return this.view.getController("searchform")}get searchBar(){return this.view.getController("searchbar")}get tabToolbar(){return this.view.getController("tabtoolbar")}get tabSearchForm(){return this.view.getController("tabsearchform")}get tabSearchBar(){return this.view.getController("tabsearchbar")}get xdataControl(){return this.view.getController(this.xdataControlName)}async onCreated(){await super.onCreated();const{childNames:t}=this.view;t.push(this.xdataControlName,"searchform","searchbar","tabtoolbar","tabsearchform","tabsearchbar"),this.xdataControlName&&(this.view.slotProps[this.xdataControlName]||(this.view.slotProps[this.xdataControlName]={}),this.view.slotProps[this.xdataControlName].loadDefault=!1)}async onMounted(){await super.onMounted();const{model:t}=this.view;this.xdataControl.evt.on("onActive",this.onXDataActive.bind(this)),this.xdataControl.evt.on("onSelectionChange",(async t=>{var e,a;null==(e=this.toolbar)||e.calcButtonState(t.data[0],this.xdataControl.model.appDataEntityId),null==(a=this.tabToolbar)||a.calcButtonState(t.data[0],this.xdataControl.model.appDataEntityId)})),this.xdataControl.evt.on("onBeforeLoad",(()=>{this.xdataControl.state.searchParams=this.getSearchParams()})),this.xdataControl.evt.on("onLoadSuccess",(t=>{this.view.evt.emit("onDataChange",{...t,actionType:"LOAD"})})),this.xdataControl.evt.on("onRemoveSuccess",(t=>{this.view.evt.emit("onDataChange",{...t,actionType:"REMOVE"})})),this.xdataControl.evt.on("onSaveSuccess",(t=>{this.view.evt.emit("onDataChange",{...t,actionType:"SAVE"})}));const e=this.viewLayoutPanel.panelItems.view_searchform;if(e){const a=!!this.searchForm;e.state.keepAlive=a,e.state.visible=a&&!!t.expandSearchForm}if(this.searchForm&&this.searchForm.evt.on("onSearch",(()=>{this.reLoad()})),this.searchBar&&this.searchBar.evt.on("onSearch",(()=>{this.reLoad()})),this.tabSearchForm&&this.tabSearchForm.evt.on("onSearch",(()=>{this.reLoad()})),this.tabSearchBar&&this.tabSearchBar.evt.on("onSearch",(()=>{this.reLoad()})),!this.view.state.noLoadDefault&&t.loadDefault){const t=this.searchBar||this.tabSearchBar;t&&t.hasDefaultSelect&&("grid"===this.xdataControlName||"treegrid"===this.xdataControlName)?t.setDefaultSelect():this.load()}}handleContextParams(){super.handleContextParams(),this.view.context.srfsimple||(this.view.context.srfsimple=!0)}async onXDataActive(t){(await this.openData(t)).cancel||this.refresh()}async call(t,e){if("ToggleFilter"===t)return this.toggleFilter(),null;if("Edit"===t||"View"===t)return this.openData(e);if("New"===t)return this.newData(e);if("Remove"===t)return await this.remove(e),null;if("Import"===t)return await this.importData(),null;if("Refresh"===t)return await this.refresh(),null;if("ExportExcel"===t)return await this.exportData(e),null;if("Search"===t){const t=this.searchForm||this.tabSearchForm;return await t.search(),null}if("Reset"===t){const t=this.searchForm||this.tabSearchForm;return await t.reset(),null}return"Copy"===t?(this.copy(e),null):"Load"===t?(this.load(e),null):"GetAllData"===t?this.xdataControl.state.items:super.call(t,e)}getData(){return this.xdataControl.getData()}async openData(t){var e,i;const{data:s,event:n}=t,o=(t.context||this.view.context).clone();o.srfpaginationviewid=this.view.id;const r=t.params||this.view.params;o[((null==(e=s[0].srfdecodename)?void 0:e.toLowerCase())||ve(this.xdataControl.model.appDataEntityId)).toLowerCase()]=s[0].srfkey;const c=await(null==(i=this.view.scheduler)?void 0:i.triggerCustom("opendata",{context:o,params:r,data:s,event:n,view:this.view}));if(-1===c)throw new a(this.view.model,"缺少opendata的视图逻辑");return{cancel:!c.ok}}async newData(t){var e,i,s;const{data:n,event:o,copyMode:r}=t;if(!(null==(i=null==(e=this.view.model.viewLayoutPanel)?void 0:e.appViewLogics)?void 0:i.find((t=>"newdata"===t.id))))throw new a(this.view.model,"缺少newdata的视图逻辑");const c=Z(this.view.params);r&&(c.srfcopymode=r);const d=await(null==(s=this.view.scheduler)?void 0:s.triggerCustom("newdata",{context:this.view.context,params:c,data:n,event:o,view:this.view}));if(-1===d)throw new a(this.view.model,"缺少newdata的视图逻辑");return{cancel:!d.ok}}async remove(t){await this.xdataControl.remove(t)}async load(t={}){await this.xdataControl.load({isInitialLoad:!0,...t})}async refresh(){await this.xdataControl.refresh()}async reLoad(){await this.xdataControl.load({isInitialLoad:!0})}getSearchParams(){const t={};return this.searchForm&&Object.assign(t,this.searchForm.getFilterParams()),this.searchBar&&Object.assign(t,this.searchBar.getFilterParams()),this.tabSearchForm&&Object.assign(t,this.tabSearchForm.getFilterParams()),this.tabSearchBar&&Object.assign(t,this.tabSearchBar.getFilterParams()),t}async importData(){await this.xdataControl.importData()}async exportData(t){await this.xdataControl.exportData(t)}async copy(t){this.newData(Object.assign(t,{copyMode:!0}))}calcViewHeaderVisible(){const t=super.calcViewHeaderVisible();return this.calcViewSearchBarVisible()||t}calcViewSearchBarVisible(){const{model:t}=this.view,e=this.isExistAndInLayout("searchbar");if(!e)return e;const a=ue(t,"searchbar");return!(!a.enableQuickSearch&&!a.enableGroup&&!0!==a.enableFilter)}toggleFilter(){if(this.searchForm){const t=this.viewLayoutPanel.panelItems.view_searchform;t&&(t.state.visible=!t.state.visible)}}calcRemoveLayoutModel(){const{model:t}=this.view,e=super.calcRemoveLayoutModel();return ue(t,"searchform")||e.push("searchform"),this.calcViewSearchBarVisible()||e.push("view_searchbar"),e}}),document.title),al=class{constructor(){this.layoutPanel=new ea,this.theme=new Ea,this.text=new wa,this.hbs=new se,this.rawValue=new Da,this.action=pc,this.error=new Ft,this.viewStack=new Ca,this.anime=new Vi,this.file=new ki,this.error.register(new _t)}showAppLoading(){const t=document.getElementById("app-loading-x");t&&(t.style.display="none")}hiddenAppLoading(){setTimeout((()=>{const t=document.getElementById("app-loading-x");t&&(t.style.display="none")}),300)}setBrowserTitle(t){const e=ibiz.hub.getApp();let a="";a=ibiz.env.AppTitle?ibiz.env.AppTitle:e.model.title?e.model.title:el,document.title=t?"".concat(a," - ").concat(t):a}getGlobalParam(){throw new o("获取应用全局变量没有实现")}getRouterParams(){throw new o("获取视图路由参数变量没有实现")}},il=class{constructor(t,e){this.logic=t,this.scheduler=e,this.type=t.logicType}execute(t){throw new o("Method not implemented.")}destroy(){}},sl=class{constructor(){this.constructorMap=new Map}register(t,e){this.constructorMap.set(t,e)}createExecutor(t,e){const a=this.constructorMap.get(t.logicType);if(!a)throw new i(t,"逻辑类型 ".concat(t.logicType," 暂未支持!"));return a(t,e)}},nl=class extends il{constructor(){super(...arguments),this.initialized=!1}convertScriptArgs(t){return t}init(t,e,a){this.convertScriptArgs=e;const i=this.logic.scriptCode;this.scriptFn=Qe.createScriptFn(t,i,a),this.initialized=!0}execute(t){const e=this.convertScriptArgs(t);return this.scriptFn.exec(e)}},ol=class extends il{execute(t){const{appDEUILogicId:e,appDataEntityId:i}=this.logic;if(!e)throw new a(this.logic,"没有配置实体界面逻辑");return uc(e,i,t)}},rl=class{constructor(t){this.triggers=new Map,this.executors=new Map,this.hasViewEventTrigger=!1,this.hasControlEventTrigger=!1,this.logics=t,t.forEach((t=>{try{const e=this.createExecutor(t);this.executors.set(t.id,e);const a=this.createTrigger(t);this.triggers.set(t.id,a),a.bindExecutor(e)}catch(t){ibiz.log.error(t.message)}}))}destroy(){this.triggers.forEach((t=>t.destroy())),this.executors.forEach((t=>t.destroy()))}getExecuteParams(t){let e={};return this.defaultParamsCb&&(e=this.defaultParamsCb()),at(t,e)}createTrigger(t){switch(t.triggerType){case"VIEWEVENT":this.hasViewEventTrigger=!0;break;case"CTRLEVENT":this.hasControlEventTrigger=!0}return ibiz.scheduler.triggerFactory.createTrigger(t,this)}createExecutor(t){return ibiz.scheduler.executorFactory.createExecutor(t,this)}getMatchTriggers(t){const e=[];return this.triggers.forEach((a=>{a.match(t)&&e.push(a)})),e}triggerAndExecute(t,e={}){const a=this.getMatchTriggers(t);if(a.length>0){const t=this.getExecuteParams(e);return a.map((e=>e.execute(t)))}}triggerItemDynaLogic(t,e,a){const i={itemName:t,triggerType:e},s=this.triggerAndExecute(i,a);if(null==s?void 0:s.length)return s.pop()}triggerItemVisible(t,e){return this.triggerItemDynaLogic(t,"ITEMVISIBLE",e)}triggerItemEnable(t,e){return this.triggerItemDynaLogic(t,"ITEMENABLE",e)}triggerItemBlank(t,e){return this.triggerItemDynaLogic(t,"ITEMBLANK",e)}startTimerTrigger(){this.getMatchTriggers({triggerType:"TIMER"}).forEach((t=>t.start()))}triggerCustom(t,e){const a=this.triggers.get(t);if(!a)return-1;const i=this.getExecuteParams(e);return a.execute(i)}triggerControlEvent(t,e,a){const i={ctrlName:t,eventName:e,triggerType:"CTRLEVENT"};this.triggerAndExecute(i,a)}},cl=class extends rl{constructor(t){const e=t.filter((t=>"APPVIEWENGINE"!==t.triggerType));e.forEach((t=>{"CTRLEVENT"===t.triggerType&&(t.ctrlName=t.itemName||t.logicTag)})),super(e)}},dl=class extends rl{constructor(t){t.forEach((t=>{t.triggerType=t.logicTrigger})),super(t)}triggerViewEvent(t){const e={eventName:t.eventName,triggerType:"VIEWEVENT"};this.triggerAndExecute(e,t)}},ll=class{constructor(){this.constructorMap=new Map}register(t,e){this.constructorMap.set(t,e)}createTrigger(t,e){const a=this.constructorMap.get(t.triggerType);if(!a)throw new i(t,"触发器类型 ".concat(t.triggerType," 暂未支持!"));return a(t,e)}},hl=class{constructor(){this.executorFactory=new sl,this.triggerFactory=new ll}createViewScheduler(t){return new dl(t)}createControlScheduler(t){return new cl(t)}},ul=class{constructor(t,e){this.logic=t,this.scheduler=e,this.type=t.triggerType}bindExecutor(t){this.executor=t,"SCRIPT"===this.executor.type&&this.bindScriptExecutor(t)}bindScriptExecutor(t){t.initialized||t.init([],(t=>t),{isAsync:!0,singleRowReturn:!1})}match(t){return t.triggerType===this.type}execute(t){if(this.executor)return this.executor.execute(t);throw new o("".concat(this.logic.id,"没有绑定executor"))}destroy(){this.executor=void 0}},pl=class extends ul{},ml=class extends ul{bindExecutor(t){if(super.bindExecutor(t),"SCRIPT"!==this.executor.type)throw new o("预定义逻辑类型".concat(this.type,"的触发器类型只能是脚本"))}bindScriptExecutor(t){t.init(["context","viewparams","data","env","view"],(t=>{const{context:e,params:a,data:i,view:s}=t;return{context:e,params:a,data:(null==i?void 0:i[0])||{},env:ibiz.env,view:s}}),{singleRowReturn:!0,isAsync:!1})}match(t){var e,a;return super.match(t)&&(null==(e=t.itemName)?void 0:e.toLowerCase())===(null==(a=this.logic.itemName)?void 0:a.toLowerCase())}execute(t){return!!this.executor.execute(t)}},fl=class extends ul{constructor(){super(...arguments),this.timer=null}start(){if(!this.logic.timer)throw new a(this.logic,"定时器缺少定时间隔");this.timer=setInterval((()=>{if(!this.scheduler.defaultParamsCb)throw new o("定时器缺少默认参数回调");const t=this.scheduler.defaultParamsCb();this.executor.execute(t)}),this.logic.timer)}destroy(){super.destroy(),this.timer&&clearInterval(this.timer)}},gl=class extends il{async execute(t){let e;try{this.logic.builtinAppUILogic&&"APP_OPENDATA"===this.logic.builtinAppUILogic.viewLogicType?e=await this.executeOpenDataAppUILogic(this.logic.builtinAppUILogic,t):this.logic.builtinAppUILogic&&"APP_NEWDATA"===this.logic.builtinAppUILogic.viewLogicType&&(e=await this.executeNewDataAppUILogic(this.logic.builtinAppUILogic,t))}catch(t){ibiz.log.error(t)}return e}async executeOpenDataAppUILogic(t,e){const{context:i,params:s,...n}=e,{data:r}=e;if(!(null==r?void 0:r[0]))throw new o("opendata没有可操作数据!");let c;if(t.openDataAppViews)c=await this.calcOpenViewRef(t,e);else if(c=t.openDataAppView,!c)throw new a(t,"opendata视图逻辑没有配置默认打开视图");const d=c.refAppViewId;if(!d)throw new a(t,"opendata视图逻辑的默认打开视图没有实际引用视图");const l=c.navigateContexts||[],h=Object.assign(i,oe(l,r[0],s,i));let u={};const p=c.navigateParams;return nt(p)&&(u=oe(p,r[0],s,i)),ibiz.commands.execute(No.TAG,d,h,u,{...n,openMode:c.openMode})}async calcOpenViewRef(t,e){const i=await ibiz.hub.getAppDataEntity(e.view.model.appDataEntityId,e.view.model.appId),s=i.formTypeAppDEFieldId||i.dataTypeAppDEFieldId;if(!s)throw new a(t,"".concat(i.codeName,"[多表单实体] or [索引实体]缺少类型属性配置"));const{data:n}=e,r=n[0][s];if(!r)throw new a(t,"数据源无表单类型应用实体属性值");const c=t.openDataAppViews,d=null==c?void 0:c.find((t=>t.refMode===r));if(!d)throw new o("没有找到与表单类型".concat(r,"相关的实体的编辑视图"));return d}async executeNewDataAppUILogic(t,e){const{context:s,params:n,...o}=e,{data:r,view:c}=e,{enableWizardAdd:d,enableBatchAdd:l,batchAddOnly:h,newDataAppView:u}=t;let p;if(d){if(p=await this.getWizardNewViewRef(t,e),!p)return{ok:!1}}else if(l){const e=ve(c.parentView.model.appDataEntityId),i=t.batchAddAppViews;if(p=null==i?void 0:i.find((t=>t.refMode.toLowerCase()!==e)),!p)throw new a(t,"没有找到批添加需要打开的选择视图")}else{if(h)throw new i(t,"batchAddOnly暂未支持");if(p=u,!p||!p.refAppViewId)throw new a(t,"newdata视图逻辑没有配置默认新建数据视图")}let m={},f={};const g=(null==r?void 0:r[0])||{},w=p.navigateContexts;nt(w)&&(m=oe(w,g,n,s)),m=Object.assign(s,m);const E=p.navigateParams;if(nt(E)&&(f=oe(E,g,n,s)),n.srfcopymode){const t=(await ibiz.hub.getAppDataEntity(c.model.appDataEntityId,c.model.appId)).keyAppDEFieldId;t&&g&&(f[t]=g.srfkey,f.srfcopymode=!0)}f.srfuf=0;const y=await ibiz.commands.execute(No.TAG,p.refAppViewId,m,f,{...o,openMode:p.openMode});return l&&y.data&&await this.doBatchAdd(t,y.data,s,p,e.view),y}async getWizardNewViewRef(t,e){var i;const{wizardAppView:s,newDataAppViews:n}=t,{context:r,params:c,...d}=e;if(!s||!s.refAppViewId)throw new a(t,"缺少默认索引实体选择视图");const l=await ibiz.commands.execute(No.TAG,s.refAppViewId,r,c,{...d,openMode:"POPUPMODAL"});if(!l.ok)return;const h=null==(i=l.data)?void 0:i[0];if(!h)throw new o("请选中一条数据");const u=h.srfkey,p=null==n?void 0:n.find((t=>{var e;return(null==(e=t.refMode)?void 0:e.toUpperCase())===u.toUpperCase()}));if(!p)throw new o("没有找到与索引类型".concat(u,"相关的实体的编辑视图"));return p}async doBatchAdd(t,e,i,s,n){var r;if(null==e?void 0:e.length){const c=await ibiz.hub.getAppDataEntity(t.appDataEntityId,i.srfappid),d=c.minorAppDERSs,l=s.refMode.toLowerCase();if(!d)throw new a(c,"实体没有从关系集合!");let h="";if(null==d||d.forEach((t=>{const e=ve(t.majorAppDataEntityId);l===e&&(h=t.parentAppDEFieldId)})),void 0===h)throw new o("没有找到".concat(l,"在当前实体的外键属性"));const u={srfkey:h},p=null==(r=n.model.appViewParams)?void 0:r.find((t=>t.key.toLowerCase()==="PROPERTYMAP".toLowerCase()));if(p){const t=p.value.split(",");for(const e of t){const[t,a]=e.split(":");t&&a&&(u[t]=a)}}ibiz.log.debug("批量新建转换映射属性",u);const m=e.map((t=>{const e={};return Object.keys(u).forEach((a=>{const i=u[a];e[i]=t[a]})),e}));ibiz.log.debug("批量新建创建数据",m);const f=ibiz.hub.getApp(i.srfappid).deService;await f.exec(c.id,"Create",i,m)}}},wl=class extends ul{constructor(t,e){super(t,e),this.logic=t,this.scheduler=e,this.listenEventNames=[];const a=t.eventNames.split(";");this.listenEventNames=a.map((t=>oa[t]||t))}match(t){return super.match(t)&&this.listenEventNames.includes(t.eventName)}},El=class extends ul{constructor(t,e){super(t,e),this.logic=t,this.scheduler=e,this.listenEventNames=[];const a=t.eventNames.split(";");this.listenEventNames=a.map((t=>ca[t]||t))}match(t){return super.match(t)&&t.ctrlName.toLowerCase()===this.logic.ctrlName.toLowerCase()&&this.listenEventNames.includes(t.eventName)}},yl=class extends il{execute(t){if(!this.logic.appDEUIActionId)throw new a(this.logic,"逻辑中缺少触发应用实体界面行为id");pc.execAndResolved(this.logic.appDEUIActionId,t,this.logic.appId)}};t("PluginStaticResource",class{constructor(t){this.urlReg=/^http[s]?:\/\/[^\s]*/,this.styleElementMap=new Map,this.url=new URL(t),this.baseDir=It.dirname(this.url.pathname)}dir(t){return this.urlReg.test(t)?t:this.url.origin+It.resolve(this.baseDir,t)}async loadStyle(t){const e=t.map((t=>{const e=this.urlReg.test(t)?t:this.dir(t);return!this.styleElementMap.has(e)&&(this.styleElementMap.set(e,null),new Promise(((t,a)=>{const i=document.createElement("link");i.setAttribute("type","text/css"),i.setAttribute("rel","stylesheet"),i.setAttribute("href",e),i.onload=t,i.onerror=a,document.head.appendChild(i)})))}));try{await Promise.all(e)}catch(t){ibiz.log.error(t)}}}),t("RemotePluginItem",class{constructor(t,e,a){this.tag=t,this.repo=e,this.config=a}})}}}));
1
+ System.register(["@ibiz-template/core","lodash-es","ramda","qx-util","qs","dayjs","async-validator","path-browserify"],(function(t,e){"use strict";var a,i,s,n,o,r,c,d,l,h,u,p,m,f,g,w,E,y,v,I,D,C,b,A,P,T,x,S,N,R,M,O,L,_,F,V,k,z,W,U,B,G,j,K,X,H,q,Y,Q,$,J,Z,tt,et,at,it,st,nt,ot,rt,ct,dt,lt,ht,ut,pt,mt,ft,gt,wt,Et,yt,vt,It;return{setters:[function(t){a=t.RuntimeModelError,i=t.ModelError,s=t.HttpError,n=t.NoticeError,o=t.RuntimeError,r=t.recursiveIterate,c=t.downloadFileFromBlob,d=t.IBizContext,l=t.DataTypes,h=t.clone,u=t.CoreConst,p=t.HttpResponse,m=t.updateKeyDefine,f=t.Net,g=t.getToken,w=t.NOOP,E=t.selectFile,y=t.IBizParams,v=t.isElementSame,I=t.findRecursiveChild,D=t.StringUtil,C=t.debounceAndAsyncMerge,b=t.EntityError,A=t.isOverlap,P=t.BitMask,T=t.mergeInLeft,x=t.awaitTimeout,S=t.mergeDefaultInLeft,N=t.plus,R=t.toNumberOrNil},function(t){M=t.isEmpty,O=t.isNil,L=t.isString,_=t.isArray,F=t.isObject,V=t.debounce,k=t.camelCase,z=t.eq,W=t.gt,U=t.gte,B=t.findIndex,G=t.lt,j=t.lte,K=t.upperFirst,X=t.snakeCase,H=t.kebabCase,q=t.isFunction,Y=t.isNumber},function(t){Q=t.isNil,$=t.mergeRight,J=t.isEmpty,Z=t.clone,tt=t.equals,et=t.where,at=t.mergeLeft,it=t.isNotNil,st=t.mergeDeepRight},function(t){nt=t.notNilEmpty,ot=t.isNilOrEmpty,rt=t.AsyncSeriesHook,ct=t.createUUID,dt=t.QXEvent,lt=t.isArray,ht=t.getCookie,ut=t.setCookie,pt=t.clearCookie,mt=t.ascSort,ft=t.descSort,gt=t.clearAll,wt=t.isNumber},function(t){Et=t.default},function(t){yt=t.default},function(t){vt=t.default},function(t){It=t.default}],execute:function(){t({SearchCondEx2filterNode:Ad,asyncImportData:or,asyncImportData2:mr,calcContentAlignStyle:function(t){const{valignSelf:e,halignSelf:a}=t;let i;if(e||a){switch(i={display:"flex"},e){case"TOP":Object.assign(i,{"align-items":"flex-start"});break;case"MIDDLE":Object.assign(i,{"align-items":"center"});break;case"BOTTOM":Object.assign(i,{"align-items":"flex-end"})}switch(a){case"LEFT":Object.assign(i,{"justify-content":"flex-start"});break;case"CENTER":Object.assign(i,{"justify-content":"center"});break;case"RIGHT":Object.assign(i,{"justify-content":"flex-end"});break;case"JUSTIFY":Object.assign(i,{"justify-content":"space-between"})}}return i},calcDeCodeNameById:ve,calcDynaClass:we,calcDynaSysParams:async function(t,e,a={}){const i=a.appId||e.srfappid,s=a.viewParams||{},n={},o=await ibiz.hub.getAppDataEntity(t,i);if(s.srfkey)n.srfkey=s.srfkey;else{const t=e[o.codeName.toLowerCase()];t&&(n.srfkey=t)}if(s.srfparentkey&&s.srfparentdename)n.srfparentkey=s.srfparentkey,n.srfparentdename=s.srfparentdename;else{const t=an(e,o);if(t&&t.keys.length>1){const a=t.keys[t.keys.length-2];n.srfparentkey=s.srfparentkey||e[a],n.srfparentdename=s.srfparentdename||a}}return n},calcFilterModelBySchema:Ed,calcGridLayoutPos:function(t){const{layout:e,colXS:a,colXSOffset:i,colSM:s,colSMOffset:n,colMD:o,colMDOffset:r,colLG:c,colLGOffset:d}=t,l=(t,a)=>({span:(t&&-1!==t?t:"TABLE_24COL"===e?24:12)*("TABLE_24COL"===e?1:2),offset:a&&-1!==a?a:void 0});return{xs:l(a,i),sm:l(s,n),md:l(o,r),lg:l(c,d)}},calcImportSchemaData:fr,calcLayoutHeightWidth:ge,calcMainStateOPPrivsStrs:ye,calcNavParams:le,calcResPath:sn,calcSearchCondExs:Td,calcSearchConds:bd,compare:je,compareNumber:Ke,contains:Xe,convertNavData:oe,convertNavDataByArray:ce,convertObjectToNavParams:ne,createImportSchema:async function(t){const e=fr(t);return await ibiz.net.request("extension/import_schemas",{method:"post",data:e})},deleteImportSchema:async function(t){const e="extension/import_schemas/".concat(t);return await ibiz.net.request(e,{method:"delete"})},downloadImportTemplate:ur,execDELogic:Qn,execDELogicAction:Jn,execDELogicById:$n,execFieldLogics:to,execUILogic:mc,exportData:dr,fetchImportSchemas:async function(t){var e;const a={n_import_tag_eq:t.appDataEntity.defaultAppDEDataImportId,n_system_tag_eq:null==(e=ibiz.appData)?void 0:e.context.srfsystemid,n_data_entity_tag_eq:t.appDataEntity.codeName};return await ibiz.net.request("extension/import_schemas/fetch_cur_user",{method:"post",data:a})},fieldValueToBoolean:on,filterFieldLogics:Ce,filterNode2SearchCond:Cd,filterNode2SearchCondEx:Pd,filterValueRules:ga,findAppDEMethod:fe,findChildFormDetails:Ne,findDELogic:De,findEditItem:Se,findFieldById:be,findModelChild:he,formatMultiData:de,generateEditorRules:er,generateRules:tr,getAllPanelField:ke,getAppCounterProvider:$i,getAppMenuItemProvider:Gs,getAppViewRef:function(t,e){var a,i;let s=t.appViewRefs||[];(null==(i=null==(a=t.viewLayoutPanel)?void 0:a.appViewRefs)?void 0:i.length)&&(s=s.concat(t.viewLayoutPanel.appViewRefs));return s.find((t=>t.name===e||t.id===e))},getAsyncActionProvider:function(t){const e=(a=t.actiontype||"DEFAULT",ibiz.register.get("".concat(As,"_").concat(a)));var a;if(e)return e;throw new o("找不异步操作类型".concat(t.actiontype,"对应的适配器"))},getChildNodeRSs:xe,getControl:ue,getControlPanel:me,getControlProvider:es,getControlsByView:Me,getCtrlTeleportParams:function(t){var e,a,i,s;const n=null==(a=null==(e=t.controlParam)?void 0:e.ctrlParams)?void 0:a.TELEPORTTAG,o="true"===(null==(s=null==(i=t.controlParam)?void 0:i.ctrlParams)?void 0:s.TELEPORTFLAG);return{teleportTag:n,teleportFlag:o}},getDEMethodProvider:Vs,getDERedirectToView:Be,getDataImportModels:lr,getDeACMode:async function(t,e,a){var i;const s=await ibiz.hub.getAppDataEntity(e,a);return null==(i=s.appDEACModes)?void 0:i.find((e=>e.id===t))},getDefaultDataImport:function(t){var e;if(t.defaultAppDEDataImportId)return null==(e=t.appDEDataImports)?void 0:e.find((e=>e.id===t.defaultAppDEDataImportId))},getDefaultValue:ir,getEditorProvider:ss,getEntitySchema:gr,getErrorViewProvider:function(t){let e;e||(a=t,e=ibiz.register.get("".concat(Ks,"_").concat(a)));var a;return e},getFormDetailProvider:rs,getGridColumnProvider:ls,getImportSchema:async function(t){const e="extension/import_schemas/".concat(t);return await ibiz.net.request(e,{method:"get"})},getInternalMessageProvider:function(t){const e=(a=t.content_type||"DEFAULT",ibiz.register.get("".concat(js,"_").concat(a)));var a;if(e)return e;throw new o("找不站内信类型".concat(t.content_type,"对应的适配器"))},getMatchResPath:an,getOriginData:Zo,getOriginFilterNodes:Id,getPFPlugin:function(t,e){const i=ibiz.hub.getApp(e);if(!i)throw new a(i,"未找到应用");const{model:s}=i;if(!s.appPFPluginRefs)throw new a(s,"应用未配置插件");const n=s.appPFPluginRefs.find((e=>e.pluginCode.toLowerCase()===t.toLowerCase()));if(!n)throw new Error("未找到插件".concat(t));return n},getPanelItemProvider:ps,getPlatformProvider:Os,getPlatformType:Ss,getPortletProvider:gs,getRootNode:Pe,getTreeGridExColumnProvider:Ws,getTreeNode:Te,getUIActionById:Ae,getUIActionItemsByActionLevel:function(t,e){const a=[];return r(t,(t=>{if("DEUIACTION"===t.itemType){const i=t;i.actionLevel===e&&a.push(i)}}),{childrenFields:["detoolbarItems"]}),a},getUIActionProvider:vs,getUILogicNodeProvider:Ds,getViewEngines:Le,getViewLogics:Oe,getViewProvider:async function(t){let e;const{viewType:a,viewStyle:i,sysPFPluginId:s,appId:n}=t;if(s){const t=await Hi(s,n);if(t&&(e=bs(t)),e)return e;ibiz.log.error("找不到视图插件".concat(t,"对应的适配器"))}if(i&&"DEFAULT"!==i){if(e=bs("".concat(a,"_").concat(i)),e)return e;ibiz.log.error("找不到视图类型:[".concat(a,"]的视图样式:[").concat(i,"]对应的适配器"),t)}e||(e=bs(a));e||(e=bs("DEFAULT"));return e},getWFContext:aa,getWFSubmitViewId:function(t,e){var a;const{type:i,sequenceflowview:s,sequenceflowmobview:n}=e,o=(null==(a=t.viewLayoutPanel)?void 0:a.appViewRefs)||t.appViewRefs,r=i?"WFUTILACTION@".concat(i.toUpperCase()):"WFACTION@".concat(ibiz.env.isMob?n:s),c=null==o?void 0:o.find((t=>-1!==t.name.indexOf(r)));return null==c?void 0:c.refAppViewId},handleAllSettled:ba,hasDeCodeName:Ie,hasSubRoute:$o,importData:rr,importData2:cr,install:function(){const{ibiz:t}=window;t.util=new sl,t.hub=new tl,t.register=new Lt,t.config=new Ot,t.auth=new Cn,t.engine=new el,t.uiDomainManager=new Ia,t.markOpenData=new co,Mo(),Dc(),oo(),Ys(),ibiz.scheduler=new pl,ibiz.scheduler.triggerFactory.register("ITEMVISIBLE",((t,e)=>new gl(t,e))),ibiz.scheduler.triggerFactory.register("ITEMENABLE",((t,e)=>new gl(t,e))),ibiz.scheduler.triggerFactory.register("ITEMBLANK",((t,e)=>new gl(t,e))),ibiz.scheduler.triggerFactory.register("TIMER",((t,e)=>new wl(t,e))),ibiz.scheduler.triggerFactory.register("CUSTOM",((t,e)=>new fl(t,e))),ibiz.scheduler.triggerFactory.register("VIEWEVENT",((t,e)=>new yl(t,e))),ibiz.scheduler.triggerFactory.register("CTRLEVENT",((t,e)=>new vl(t,e))),ibiz.scheduler.executorFactory.register("SCRIPT",((t,e)=>new rl(t,e))),ibiz.scheduler.executorFactory.register("APPDEUILOGIC",((t,e)=>new cl(t,e))),ibiz.scheduler.executorFactory.register("DEUILOGIC",((t,e)=>new cl(t,e))),ibiz.scheduler.executorFactory.register("APPUILOGIC",((t,e)=>new El(t,e))),ibiz.scheduler.executorFactory.register("APPDEUIACTION",((t,e)=>new Il(t,e))),function(){const t=new Ts;Rs("Browser",(()=>t))}(),t.platform=Os()},installCommand:Mo,isDataContainer:_e,isFormDataContainer:Re,isHiddenFilter:cd,isSimpleItems:rd,isValueChange:Jo,matchMainState:Ee,openDataImport:hr,openRedirectView:We,parseSubFieldInfo:dd,parseUserParams:pe,parseViewProtocol:ze,presetAppCounterProvider:Ys,presetDEMethodProvider:oo,presetUIActionProvider:Dc,registerAppCounterProvider:Yi,registerAppMenuItemProvider:function(t,e){ibiz.register.register("".concat(Us,"_").concat(t),e)},registerAsyncActionProvider:function(t,e){ibiz.register.register("".concat(As,"_").concat(t),e)},registerControlProvider:function(t,e){ibiz.register.register("".concat(Zi,"_").concat(t),e)},registerDEMethodProvider:_s,registerEditorProvider:function(t,e){ibiz.register.register("".concat(as,"_").concat(t),e)},registerErrorViewProvider:function(t,e){ibiz.register.register("".concat(Ks,"_").concat(t),e)},registerFormDetailProvider:function(t,e){ibiz.register.register("".concat(ns,"_").concat(t),e)},registerGridColumnProvider:function(t,e){ibiz.register.register("".concat(cs,"_").concat(t),e)},registerInternalMessageProvider:function(t,e){ibiz.register.register("".concat(js,"_").concat(t),e)},registerPanelItemProvider:function(t,e){ibiz.register.register("".concat(hs,"_").concat(t.toUpperCase()),e)},registerPlatformProvider:Rs,registerPortletProvider:function(t,e){ibiz.register.register("".concat(ms,"_").concat(t),e)},registerTreeGridExColumnProvider:function(t,e){ibiz.register.register("".concat(ks,"_").concat(t),e)},registerUIActionProvider:Es,registerUILogicNodeProvider:function(t,e){ibiz.register.register("".concat(Is,"_").concat(t),e)},registerViewProvider:function(t,e){ibiz.register.register("".concat(Cs,"_").concat(t),e)},selectAndImport:pr,strContain:He,testCond:Ge,toLocalOpenWFRedirectView:async function(t,e,a={}){const i=await Ue(t,e,a);await ibiz.commands.execute(So.TAG,i.viewId,i.context,i.params,i.opts)},updateImportSchema:async function(t){const e=fr(t),a="extension/import_schemas/".concat(e.id);return await ibiz.net.request(a,{method:"put",data:e})},validateFilterNodes:Dd,verifyDeRules:$e,verifyFormGroupLogic:Ze,verifyPanelGroupLogic:ta});"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;function Dt(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Ct={exports:{}};!function(t,e){t.exports=function(t,e,a){var i=function(t,e){if(!e||!e.length||1===e.length&&!e[0]||1===e.length&&Array.isArray(e[0])&&!e[0].length)return null;var a;1===e.length&&e[0].length>0&&(e=e[0]),a=(e=e.filter((function(t){return t})))[0];for(var i=1;i<e.length;i+=1)e[i].isValid()&&!e[i][t](a)||(a=e[i]);return a};a.max=function(){var t=[].slice.call(arguments,0);return i("isAfter",t)},a.min=function(){var t=[].slice.call(arguments,0);return i("isBefore",t)}}}(Ct);var bt=Dt(Ct.exports),At={exports:{}};!function(t,e){t.exports=function(t,e){e.prototype.isSameOrBefore=function(t,e){return this.isSame(t,e)||this.isBefore(t,e)}}}(At);var Pt=Dt(At.exports),Tt={exports:{}};!function(t,e){var a,i;t.exports=(a="month",i="quarter",function(t,e){var s=e.prototype;s.quarter=function(t){return this.$utils().u(t)?Math.ceil((this.month()+1)/3):this.month(this.month()%3+3*(t-1))};var n=s.add;s.add=function(t,e){return t=Number(t),this.$utils().p(e)===i?this.add(3*t,a):n.bind(this)(t,e)};var o=s.startOf;s.startOf=function(t,e){var s=this.$utils(),n=!!s.u(e)||e;if(s.p(t)===i){var r=this.quarter()-1;return n?this.month(3*r).startOf(a).startOf("day"):this.month(3*r+2).endOf(a).endOf("day")}return o.bind(this)(t,e)}})}(Tt);var xt=Dt(Tt.exports),St={exports:{}};!function(t,e){var a,i;t.exports=(a="week",i="year",function(t,e,s){var n=e.prototype;n.week=function(t){if(void 0===t&&(t=null),null!==t)return this.add(7*(t-this.week()),"day");var e=this.$locale().yearStart||1;if(11===this.month()&&this.date()>25){var n=s(this).startOf(i).add(1,i).date(e),o=s(this).endOf(a);if(n.isBefore(o))return 1}var r=s(this).startOf(i).date(e).startOf(a).subtract(1,"millisecond"),c=this.diff(r,a,!0);return c<0?s(this).startOf("week").week():Math.ceil(c)},n.weeks=function(t){return void 0===t&&(t=null),this.week(t)}})}(St);var Nt=Dt(St.exports),Rt={exports:{}};!function(t,e){var a;t.exports=(a="day",function(t,e,i){var s=function(t){return t.add(4-t.isoWeekday(),a)},n=e.prototype;n.isoWeekYear=function(){return s(this).year()},n.isoWeek=function(t){if(!this.$utils().u(t))return this.add(7*(t-this.isoWeek()),a);var e,n,o,r=s(this),c=(e=this.isoWeekYear(),o=4-(n=(this.$u?i.utc:i)().year(e).startOf("year")).isoWeekday(),n.isoWeekday()>4&&(o+=7),n.add(o,a));return r.diff(c,"week")+1},n.isoWeekday=function(t){return this.$utils().u(t)?this.day()||7:this.day(this.day()%7?t:t-7)};var o=n.startOf;n.startOf=function(t,e){var a=this.$utils(),i=!!a.u(e)||e;return"isoweek"===a.p(t)?i?this.date(this.date()-(this.isoWeekday()-1)).startOf("day"):this.date(this.date()-1-(this.isoWeekday()-1)+7).endOf("day"):o.bind(this)(t,e)}})}(Rt);var Mt=Dt(Rt.exports),Ot=class{constructor(){this.view={enableDataInfoBar:!0,expCacheMode:"TABEXPPANEL:",disableHomeTabs:!1},this.grid={editShowMode:"row",editSaveMode:"cell-blur",overflowMode:"wrap"},this.appMenu={enableEcho:!0},this.codeList={timeout:36e5},this.form={mdCtrlConfirmBeforeRemove:!0},this.pickerEditor={overflowMode:"auto"}}},Lt=t("RegisterCenter",class{constructor(){this.providers=new Map}register(t,e){this.providers.set(t,e)}unRegister(t){this.providers.delete(t)}get(t,...e){const a=this.providers.get(t);if(a)return a(...e)}}),_t=t("DefaultErrorHandler",class{handle(t){return t instanceof a||t instanceof i?ibiz.message.error(t.message,10,!0):t instanceof s?401===t.status?ibiz.message.error("没有注册无权限错误处理器"):ibiz.notification.error({title:"",desc:t.message,duration:10}):t instanceof n?ibiz.message.error(t.message,t.duration,0===t.duration):t instanceof o&&ibiz.message.error(t.message,10,!0),ibiz.log.error(t),!0}}),Ft=t("ErrorHandlerCenter",class{constructor(){this.handlers=[]}register(t){this.handlers.unshift(t)}handleSingle(t){this.handlers.find((e=>!!e.handle(t)))||ibiz.log.error("没有找到能处理该错误的处理器",t)}handle(t){t instanceof Array?t.forEach((t=>{this.handleSingle(t)})):this.handleSingle(t)}}),Vt=class{static isHelperName(t){return this.helperNames.includes(t)}static handleJudgmentExecute(t,e,a){return a.fn?e?a.fn(t):a.inverse(t):e?a.hash.yes=!0:a.hash.no=!1}};Vt.helperNames=["lookup","log","and","camelCase","concat","eq","gt","get","lowerCase","lt","lte","neq","not","or","pascalCase","pluralize","snakeCase","spinalCase","upperCase"];var kt=class{constructor(t,e){t.registerHelper(e,this.onExecute)}},zt=class extends kt{constructor(t){super(t,"and")}onExecute(...t){const e=t[t.length-1];t.pop();const a=t.filter((t=>!!t)).length===t.length;return Vt.handleJudgmentExecute(this,a,e)}},Wt=class extends kt{constructor(t){super(t,"camelCase")}onExecute(t){return t?k(t):""}},Ut=class extends kt{constructor(t){super(t,"concat")}onExecute(...t){return t.pop(),t.join("")}},Bt=class extends kt{constructor(t){super(t,"eq")}onExecute(t,e,a){const i=z(t,e);return Vt.handleJudgmentExecute(this,i,a)}},Gt=class extends kt{constructor(t){super(t,"gt")}onExecute(t,e,a){const i=W(t,e);return Vt.handleJudgmentExecute(this,i,a)}},jt=class extends kt{constructor(t){super(t,"gte")}onExecute(t,e,a){const i=U(t,e);return Vt.handleJudgmentExecute(this,i,a)}},Kt=class extends kt{constructor(t){super(t,"eqPropertyValue")}onExecute(t,e,a,i){let s=!1;return s=_(t)?!z(B(t,(t=>z(t[e],a))),-1):t.hasOwnProperty(e)&&(s=z(t[e],a)),Vt.handleJudgmentExecute(this,s,i)}},Xt=class extends kt{constructor(t){super(t,"jsonParse")}onExecute(t){return JSON.parse(t)}},Ht=class extends kt{constructor(t){super(t,"jsonStringify")}onExecute(t,e){return JSON.stringify(t,null,"number"==typeof e?e:void 0)}},qt=class extends kt{constructor(t){super(t,"lowerCase")}onExecute(t){return t?t.toLowerCase():""}},Yt=class extends kt{constructor(t){super(t,"lt")}onExecute(t,e,a){const i=G(t,e);return Vt.handleJudgmentExecute(this,i,a)}},Qt=class extends kt{constructor(t){super(t,"lte")}onExecute(t,e,a){const i=j(t,e);return Vt.handleJudgmentExecute(this,i,a)}},$t=class extends kt{constructor(t){super(t,"neq")}onExecute(t,e,a){const i=!z(t,e);return Vt.handleJudgmentExecute(this,i,a)}},Jt=class extends kt{constructor(t){super(t,"not")}onExecute(t,e){const a=J(t)||Q(t);return Vt.handleJudgmentExecute(this,a,e)}},Zt=class extends kt{constructor(t){super(t,"or")}onExecute(...t){var e;const a=t[t.length-1];t.pop();const i=t.find((t=>!!t));if(a.fn){const t=(null==(e=a.data)?void 0:e.root)||{};return i?a.fn(t):a.inverse(t)}return i||""}},te=class extends kt{constructor(t){super(t,"pascalCase")}onExecute(t){return t?K(t):""}},ee=class extends kt{constructor(t){super(t,"snakeCase")}onExecute(t){return t?X(t):""}},ae=class extends kt{constructor(t){super(t,"spinalCase")}onExecute(t){return t?H(t):""}},ie=class extends kt{constructor(t){super(t,"upperCase")}onExecute(t){return t?t.toUpperCase():""}};var se=t("HandlebarsUtil",class{constructor(){this.p=null}get isInit(){return!!this.hsb}async init(){if(this.isInit)return;if(this.p)return this.p;this.p=e.import("handlebars");const t=await this.p;var a;return this.hsb=t.default||t,this.p=null,a=this.hsb,new zt(a),new Wt(a),new Ut(a),new Bt(a),new Gt(a),new jt(a),new Xt(a),new Ht(a),new qt(a),new Yt(a),new Qt(a),new $t(a),new Jt(a),new Zt(a),new te(a),new ee(a),new ae(a),new ie(a),new Kt(a),this.hsb}async render(t,e){this.hsb||await this.init();return this.hsb.compile(t)(e)}syncRender(t,e){if(!this.hsb)throw new Error("handlebars not init");return this.hsb.compile(t)(e)}});function ne(t){const e=[],a=/^%(.+)%$/;for(const i in t){let s=!0,n=t[i];nt(t[i])&&a.test(t[i])&&(s=!1,n=t[i].substring(1,t[i].length-1)),e.push({key:i.toLowerCase(),rawValue:s,value:n})}return e}function oe(t,...e){if(!t||M(t))return{};return ce(Array.isArray(t)?t:ne(t),...e)}function re(t,e){const a=t.find((t=>!ot(t)&&(t[e]||Object.prototype.hasOwnProperty.call(t,e))));return{find:!!a,value:null==a?void 0:a[e]}}function ce(t,...e){const a=/\$\{[^}]*\}/g,i={};for(const s of t)if(s.rawValue)i[s.key.toLowerCase()]=s.value||null;else{const t=s.value.match(a);if(null!==t){let a=s.value;t.forEach((t=>{const{find:i,value:s}=re(e,t.slice(2,-1).toLowerCase());i&&(a=a.replace(t,"".concat(O(s)?"":s)))})),i[s.key.toLowerCase()]=a}else{const{find:t,value:a}=re(e,s.value.toLowerCase());t&&(i[s.key.toLowerCase()]=a)}}return i}function de(t,e){const a={};if(!t)return a;const i=Array.isArray(t)?t:ne(t),s=e[0];return i.forEach((t=>{const{rawValue:i,value:n}=t;!i&&n&&Object.prototype.hasOwnProperty.call(s,n)&&(a[n]=e.map((t=>t[n])).join(";"))})),a}function le(t,e){const{deName:a,navFilter:i,pickupDEFName:s,navContexts:n,navParams:o}=t,{context:r,params:c,data:d,derValue:l}=e,h={},u={},p=l||d.srfkey;p&&(a&&(h[a]=p),i&&(u[i]=p),s&&(u["n_".concat(s.toLowerCase(),"_eq")]=p));const m=oe(n,d,c,r),f=oe(o,d,c,r);return Object.assign(h,m),Object.assign(u,f),{resultContext:h,resultParams:u}}function he(t,e){if(t&&e){const a=t.find((t=>!!t.id&&t.id.toLowerCase()===e.toLowerCase()));if(a)return a}return null}function ue(t,e){var a,i;let s=t.controls||[];return(null==(i=null==(a=t.viewLayoutPanel)?void 0:a.controls)?void 0:i.length)&&(s=s.concat(t.viewLayoutPanel.controls)),s.find((t=>t.name===e||t.codeName===e||t.id===e))}function pe(t){const e={},a={},i={};for(const s in t)if(Object.prototype.hasOwnProperty.call(t,s)){const n=t[s];if(-1!==s.indexOf(".")){const t=s.split(".");switch(t[0]){case"SRFNAVPARAM":Object.assign(a,{[t[1]]:n});break;case"SRFNAVCTX":Object.assign(e,{[t[1]]:n});break;default:Object.assign(i,{key:n})}}}return{navigateContexts:e,navigateParams:a,other:i}}function me(t){let e;if(t.controlRenders){const a=t.controlRenders.find((t=>"LAYOUTPANEL"===t.renderType&&!!t.layoutPanel));e=null==a?void 0:a.layoutPanel}return e}function fe(t,e){const a=t.appDEMethods;if(a&&e){const t=he(a,e);if(t)return t;const i=a.find((t=>{switch(t.methodType){case"DEACTION":{const{actionTag:a}=t;return(null==a?void 0:a.toLowerCase())===e.toLowerCase()}case"FETCH":{const{dataSetTag:a}=t;return"fetch".concat(null==a?void 0:a.toLowerCase())===e.toLowerCase()}default:return!1}}));if(i)return i}return null}function ge(t){const{width:e,height:a,widthMode:i,heightMode:s}=t,n={width:"",height:""};return"FULL"===i?n.width="100%":e&&e>0&&(n.width=e>0&&e<=1?"".concat(100*e,"%"):"".concat(e,"PERCENTAGE"===i?"%":"px")),"FULL"===s?n.height="100%":a&&a>0&&(n.height=a>0&&a<=1?"".concat(100*a,"%"):"".concat(a,"PERCENTAGE"===s?"%":"px")),n}function we(t,e){const a=[],i=Qe.execScriptFn({data:e},t,{singleRowReturn:!0,isAsync:!1});return L(i)?a.push(i):_(i)?a.push(...i):F(i)&&Object.keys(i).forEach((t=>{i[t]&&a.push(t)})),a}function Ee(t,e){const{mainStateAppDEFieldIds:a,demainStates:i}=t;if(a&&i){const t=[];return a.forEach((a=>{t.push(e[a])})),i.find((e=>{const{stateValue:a,state2Value:i,state3Value:s}=e;let n=!0;const o=[a,i,s];for(let e=0;e<t.length;e++)if("".concat(t[e])!=="".concat(o[e])){n=!1;break}return n}))}}function ye(t,e){const a=ibiz.hub.getApp(e.appId).model,{demainStateOPPrivs:i,opprivAllowMode:s}=t,n=(null==i?void 0:i.map((t=>t.name)))||[];let o=[];if(s)o=n;else{o=[...a.deopprivs,...e.deopprivs].filter((t=>!n.includes(t.name))).map((t=>t.name))}return o}function ve(t){return t.split(".").pop()}function Ie(t,e){const a=ve(e);return nt(t[a])}function De(t,e){var a;return null==(a=e.appDELogics)?void 0:a.find((e=>e.id===t))}function Ce(t,e){var a,i;const s=[];return null==(a=t.appDEFields)||a.forEach((t=>{"compute"===e&&t.computeAppDEFLogicId?s.push(t.computeAppDEFLogicId):"change"===e&&t.onChangeAppDEFLogicId?s.push(t.onChangeAppDEFLogicId):"default"===e&&t.defaultValueAppDEFLogicId&&s.push(t.defaultValueAppDEFLogicId)})),(null==(i=t.appDELogics)?void 0:i.filter((t=>s.includes(t.id))))||[]}function be(t,e){var a;return null==(a=t.appDEFields)?void 0:a.find((t=>t.id===e))}async function Ae(t,e){return ibiz.hub.getApp(e).getUIAction(t)}function Pe(t){return t.detreeNodes.find((t=>t.rootNode))}function Te(t,e){return t.detreeNodes.find((t=>t.id===e))}function xe(t,e){const a=e.parentId||Pe(t).id;return t.detreeNodeRSs.filter((t=>{return t.parentDETreeNodeId===a&&(i=t.searchMode,s=e.hasQuery,3===i||(s?1===i:2===i));var i,s}))}function Se(t,e){var a;return null==(a=t.degridEditItems)?void 0:a.find((t=>t.codeName===e))}function Ne(t){let e;switch(t.detailType){case"TABPANEL":e=t.deformTabPages;break;case"FORMPAGE":case"TABPAGE":case"GROUPPANEL":e=t.deformDetails}return e||[]}function Re(t){return"MDCTRL"===t.detailType}function Me(t){const{viewLayoutPanel:e}=t,a=t.controls||[];return e&&a.push(...e.controls||[]),a}function Oe(t){const{viewLayoutPanel:e}=t,a=t.appViewLogics||[];return e&&a.push(...e.appViewLogics||[]),a}function Le(t){const{viewLayoutPanel:e}=t,a=t.appViewEngines||[];return e&&a.push(...e.appViewEngines||[]),a.filter((t=>"CTRL"!==t.engineCat||(ibiz.log.warn("未支持的引擎分类:".concat(t.engineType)),!1)))}function _e(t){return"CONTAINER"===t.itemType&&["CONTAINER_MULTIDATA","CONTAINER_SINGLEDATA"].includes(t.predefinedType)}var Fe=["panelItems","panelTabPages","rootPanelItems"];function Ve(t){let e=[];for(const a of Fe)if(t[a]&&t[a].length&&t[a].length>0){e=t[a];break}const a=[];return e.length&&(a.push(...e.filter((t=>"FIELD"===t.itemType))),e.forEach((t=>{_e(t)||a.push(...Ve(t))}))),a}function ke(t){return Ve(t)}function ze(t){const e=new URL(t),a={},i={};let s="";if(e.searchParams.size>0){const s=e.searchParams.get("srfnavctx");if(s){try{Object.assign(a,JSON.parse(s))}catch(e){ibiz.log.error("重定向[".concat(t,"] 中 srfnavctx 参数解析失败"),e)}e.searchParams.delete("srfnavctx")}e.searchParams.forEach(((t,e)=>{i[e]=t}))}const n=e.pathname.replace("//","").split("/"),[o,r]=n;return s=r||o,{context:a,params:i,viewId:s}}async function We(t,e,a={},i={}){return async function(t,e,a={},i={}){let s;try{s=await Be(t,e,a,i)}catch(t){return ibiz.log.error(t),{ok:!1,data:[]}}if("url"===s.type){const t=s.url;return new Promise((e=>{const a=window.open(t,"_blank");a&&(a.callback=()=>{e({ok:!0,data:[]})})}))}return await ibiz.commands.execute(So.TAG,s.viewId,s.context,s.params,s.opts)||{ok:!0,data:[]}}(t,e,a,i)}async function Ue(t,e,a={}){const i=e.lastIndexOf("?"),s=decodeURIComponent(e.substring(i+1,e.length)),n=Et.parse(s,{delimiter:";"}),r=n.srfdename||"";if(!r)throw new o("重定向参数缺少实体名称");const c=ibiz.hub.getApp(t.srfappid).deName2DeCodeName.get(r.toUpperCase());if(!c)throw new o("未找到指定实体的codeName: ".concat(r));n[c.toLowerCase()]=n[r.toLowerCase()];const d="".concat(c).concat(ibiz.env.isMob?"Mob":"","RedirectView"),l=await ibiz.hub.getAppView(d);if(delete n.srfdename,"undo"!==n.srfwf){const t=n.processDefinitionKey.split("-")[3],e=t.substring(0,t.lastIndexOf("v")),a=t.substring(t.lastIndexOf("v"));n.wf=e,n.wfVersion=a}return n.srfprocessinstanceid&&(t.srfprocessinstanceid=n.srfprocessinstanceid,delete n.srfprocessinstanceid),{context:t,params:n,opts:a,viewId:l.id}}async function Be(t,e,i={},s={}){var n;const r=oe(t.appViewNavContexts||[],i,e);e=Object.assign(e.clone(),r);const c=oe(t.appViewNavParams||[],i,e);Object.assign(i,c);const d=t.appDataEntityId,l=ve(d);let h=(null==(n=s.data)?void 0:n[0])||{};e[l]=h[l]||e[l]||i[l];const u=t.getDataAppDEActionId,p=ibiz.hub.getApp(t.appId),m=await p.deService.getService(e,d);ibiz.loading.showRedirect();try{const t=await m.exec(u||"get",e,i);if(t.ok){h=t.data;let a=h.linkurl;if(a){if(e.srfprocessinstanceid&&(a+=";srfprocessinstanceid=".concat(e.srfprocessinstanceid)),ibiz.env.dev&&-1!==a.indexOf("appredirectview?")&&(a=a.slice(a.indexOf("appredirectview?"))),a.startsWith("http://")||a.startsWith("https://"))return{type:"url",url:a};if(a.startsWith("appredirectview?")){return{type:"view",...await Ue(e,a,s)}}throw new o("未支持的linkUrl格式:".concat(a))}}}finally{ibiz.loading.hideRedirect()}const f=await ibiz.hub.getAppDataEntity(d,t.appId),g=await async function(t,e,a,i){let s="";const n=e.typeAppDEFieldId;if(n){const{codeName:a}=be(t,n),s=i[a.toLowerCase()];if(nt(s))return s.startsWith("view://")?s:"".concat(s.toUpperCase());ibiz.log.warn("重定向视图[".concat(e.name,"]自定义类别属性[").concat(n,"]值为空"),i)}const o="".concat(ibiz.env.isMob?"MOB":"","EDITVIEW"),r=a.srfwf;if(nt(r))return nt(a.wf)?"".concat(o,":").concat(r.toUpperCase(),":").concat(a.wf.toUpperCase()):"".concat(o,":").concat(r.toUpperCase());let c="";if(t.indexTypeAppDEFieldId){const{codeName:e}=be(t,t.indexTypeAppDEFieldId);c=i[e.toLowerCase()]}if(ot(c)&&t.formTypeAppDEFieldId){const{codeName:e}=be(t,t.formTypeAppDEFieldId);c=i[e.toLowerCase()]}s=nt(c)?"".concat(o,":").concat(c.toString().toUpperCase()):"".concat(o);return s}(f,t,i,h);let w="";if(!g.startsWith("view://")){const n=g.split(":"),o=2===n.length?g:n.slice(0,2).join(":"),r="".concat(f.name.toUpperCase(),":").concat(g),c=[];t.redirectAppViewRefs&&c.push(...t.redirectAppViewRefs),t.appViewRefs&&c.push(...t.appViewRefs);const d=c.find((t=>{const e=t.name||t.id;return e===r||e===g||e===o}));if(d){if(w=d.refAppViewId,d.openMode&&(s.openMode=d.openMode),w)return{type:"view",viewId:w,context:e,params:i,opts:{...s,data:[h]}};throw new a(d,"未配置实际引用视图")}throw ibiz.log.error("重定向视图引用有:",null==c?void 0:c.map((({refAppViewId:t,name:e,realTitle:a})=>({viewId:t,tag:e,title:a})))),new a(t,"未找到重定向标识[".concat(g,"]或[").concat(r,"]或工作流[").concat(o,"]对应视图"))}{const t=ze(g);Object.assign(e,t.context),Object.assign(i,t.params),w=t.viewId}if(w)return{type:"view",viewId:w,context:e,params:i,opts:{...s,data:[h]}};throw new a(t,"标识[".concat(g,"]未匹配到实际引用视图"))}function Ge(t,e,a){if(Object.is(e,"IN"))return Xe(t,a);if(Object.is(e,"NOTIN"))return!Xe(t,a);switch(e){case"EQ":return"".concat(t)==="".concat(a);case"NOTEQ":return"".concat(t)!=="".concat(a);case"LT":return je(t,a)<0;case"LTANDEQ":return je(t,a)<=0;case"GT":return je(t,a)>0;case"GTANDEQ":return je(t,a)>=0;case"ISNULL":return ot(t);case"ISNOTNULL":return nt(t);case"TESTNULL":return Q(t);case"IN":return Xe(t,a);case"NOTIN":return!Xe(t,a);case"LIKE":return He(t,a);case"LEFTLIKE":return He(t,a,"start");case"RIGHTLIKE":return He(t,a,"end");default:throw new o("值操作:".concat(e,",暂未支持"))}}function je(t,e){const a=Number(t),i=Number(e);if(!Number.isNaN(a)&&!Number.isNaN(i))return Ke(a,i);const s=new Date(t).getTime(),n=new Date(e).getTime();if(!Number.isNaN(s)&&!Number.isNaN(n))return Ke(s,n);throw new o("".concat(t," 和 ").concat(e," 无法比较大小"))}function Ke(t,e){return Number.isNaN(t)&&(t=0),Number.isNaN(e)&&(e=0),t>e?1:t<e?-1:0}function Xe(t,e){if(!e||"string"!=typeof e)throw new o("范围比较的条件值不存或者不是字符串");if(t){return e.split(",").includes("".concat(t))}return!1}function He(t,e,a){if(!t||!e)return!1;const i="".concat(t).toUpperCase(),s="".concat(e).toUpperCase(),n=i.indexOf(s);switch(a){case"start":return 0===n;case"end":return n+s.length===i.length;default:return-1!==n}}var qe={singleRowReturn:!1,isAsync:!0},Ye=t("ScriptFunction",class{constructor(t,e,a=qe){this.argKeys=[],this.options=a;const i=this.formatCode(e,a);this.calcArgKeys(t,a);const s=new Function(...this.argKeys,i);this.scriptFn=function(...t){try{return s.apply({},t)}catch(t){throw ibiz.log.error("报错脚本",i),t}}}formatCode(t,e){let a=t;return e.singleRowReturn&&(a="return (".concat(a,")")),e.isAsync&&(a="return (async function() { ".concat(a,"} )();")),a}calcArgKeys(t,e){const a=e.presetParams?Object.keys(e.presetParams):[];a.push(...t);a.push("document","el","selector","env","appSession","topViewSession","viewSession","context","viewParam","activeData","data","app","topView","parentView","view","parent","util","ctrl"),this.argKeys=Array.from(new Set(a))}convertArgs(t){const{presetParams:e}=this.options,a=e?$(e,t):t;a.document=document,a.selector=t=>document.getElementsByClassName(t);const i=[];return this.argKeys.forEach((t=>{void 0===a[t]&&this.fillDefaultParams(t,a),i.push(a[t])})),i}fillDefaultParams(t,e){switch(t){case"util":e.util={message:ibiz.message,notification:ibiz.notification,modal:ibiz.modal,confirm:ibiz.confirm,openView:ibiz.openView};break;case"viewParam":e.viewParam=e.params;break;case"env":e.env=ibiz.env;break;case"app":e.app=ibiz.hub.controller;break;case"appSession":e.appSession=ibiz.hub.controller.session}const a=e.view;if(a)switch(t){case"parent":e.parent=a.parentView;break;case"topView":e.topView=a.getTopView();break;case"parentView":e.parentView=a.parentView;break;case"topViewSession":e.topViewSession=a.getTopView().session;break;case"viewSession":e.viewSession=a.session}}exec(t){const e=this.convertArgs(t);return this.scriptFn(...e)}}),Qe=t("ScriptFactory",class{static createScriptFn(t,e,a){return new Ye(t,e,a)}static execScriptFn(t,e,a){return this.createScriptFn(Object.keys(t),e,a).exec(t)}static execSingleLine(t,e={}){return this.execScriptFn(e,t,{singleRowReturn:!0,isAsync:!1})}});function $e(t,e,a){const i={isPast:!0,infoMessage:a.ruleInfo};if(function(t){return"GROUP"===t.condType}(a)){const s=a.conds;s&&s.length>0&&(i.isPast=function(t,e,a="AND",i=!1){if(!((null==t?void 0:t.length)>0))return!1;let s="AND"===a;for(let i=0,n=t.length;i<n;i++){const n=e(t[i],i);if("AND"===a){if(!n){s=!1;break}}else if("OR"===a&&n){s=!0;break}}return i?!s:s}(s,(a=>{const{isPast:s,infoMessage:n}=$e(t,e,a);return i.infoMessage=n,s}),a.condOp,!!a.notMode),!i.isPast&&("AND"===a.condOp&&a.notMode||"OR"===a.condOp&&!a.notMode)&&(i.infoMessage=a.ruleInfo))}else{t=(null==a?void 0:a.defname.toLowerCase())||t;try{if(function(t){return"SIMPLE"===t.condType}(a))i.isPast=!function(t,e,a,i,s,n,r){Object.is(s,"CURTIME")&&(a="".concat(new Date));if(Object.is(s,"ENTITYFIELD")){a=n[a=a?a.toLowerCase():""]?n[a]:a}(Q(i)||J(i))&&(i="内容必须符合值规则");const c=Ge(t,e,a);if(!c&&r)throw new o(i);return!c}(e[t],a.condOp,a.paramValue,a.ruleInfo,a.paramType,e,a.keyCond);else if(function(t){return"VALUERANGE2"===t.condType}(a))i.isPast=!function(t,e,a,i,s,n,r){ot(n)&&(n="值必须符合值范围规则");if(ot(t)){if(r)throw new o("值为空");return n="值为空",!0}if(Je(t,/^-?\d*\.?\d+$/,"",r))return!0;const c=Number.parseFloat(t);if(null!==e)if(a){if(c<e){if(r)throw new o(n);return!0}}else if(c<=e){if(r)throw new o(n);return!0}if(null!=i)if(s){if(c>i){if(r)throw new o(n);return!0}}else if(c>=i){if(r)throw new o(n);return!0}return n="",!1}(e[t],a.minValue,a.includeMinValue,a.maxValue,a.includeMaxValue,a.ruleInfo,a.keyCond);else if(function(t){return"REGEX"===t.condType}(a))i.isPast=!Je(e[t],a.regExCode,a.ruleInfo,a.keyCond);else if(function(t){return"STRINGLENGTH"===t.condType}(a))i.isPast=!function(t,e,a,i,s,n,r){ot(n)&&(n="内容长度必须符合范围规则");if(ot(t)){if(r)throw new o("值为空");return n="值为空",!0}const c=t.length;if(null!==e)if(a){if(c<e){if(r)throw new o(n);return!0}}else if(c<=e){if(r)throw new o(n);return!0}if(null!==i)if(s){if(c>i){if(r)throw new o(n);return!0}}else if(c>=i){if(r)throw new o(n);return!0}return n="",!1}(e[t],a.minValue,a.includeMinValue,a.maxValue,a.includeMaxValue,a.ruleInfo,a.keyCond);else if(function(t){return"SYSVALUERULE"===t.condType}(a)&&(null==a?void 0:a.sysValueRule)){const{ruleType:s,regExCode:n,scriptCode:r,ruleInfo:c}=a.sysValueRule;if(i.infoMessage=a.ruleInfo||c,"REG"===s)i.isPast=!Je(e[t],n,i.infoMessage,a.keyCond);else if("SCRIPT"===s){const{isPast:s,infoMessage:n}=function(t,e,a,i,s){ot(i)&&(i="值必须符合脚本规则");const n=e;let r="",c=!0;const d=t=>{c=!1,(null==t?void 0:t.length)>0?t.forEach((t=>{(null==t?void 0:t.message)&&(r+=t.message)})):(null==t?void 0:t.message)&&(r=t.message)};try{const e=Qe.execScriptFn({value:t,data:n},a,{isAsync:!1});"boolean"==typeof e&&(c=e)}catch(t){ibiz.log.error(t),d(t)}if(i="",!c&&s)throw new o(i);return{isPast:c,infoMessage:r||i}}(e[t],e,r,i.infoMessage,a.keyCond);i.isPast=s,i.infoMessage=n||i.infoMessage}}}catch(t){i.isPast=!1}i.isPast=a.notMode?!i.isPast:i.isPast}return i}function Je(t,e,a,i){ot(a)&&(a="值必须符合正则规则");if(ot(t)){if(i)throw new o("值为空");return a="值为空",!0}if(!new RegExp(e).test(t)){if(i)throw new o(a);return!0}return a="",!1}function Ze(t,e){if(function(t){return"GROUP"===t.logicType}(e)){const i=e.defdlogics;if(!i||0===i.length)throw new a(e,"发现空逻辑组,逻辑无法正常执行!");let s=!0;if("AND"===e.groupOP){s=void 0===i.find((e=>!Ze(t,e)))}else if("OR"===e.groupOP){s=void 0!==e.defdlogics.find((e=>Ze(t,e)))}return e.notMode?!s:s}if(function(t){return"SINGLE"===t.logicType}(e))return Ge(t[e.defdname.toLowerCase()],e.condOP,e.value);throw new i(e,"未支持的逻辑类型".concat(e.logicType))}function ta(t,e){if(function(t){return"GROUP"===t.logicType}(e)){const i=e.panelItemLogics;if(!i||0===i.length)throw new a(e,"发现空逻辑组,逻辑无法正常执行!");let s=!0;if("AND"===e.groupOP){s=void 0===i.find((e=>!ta(t,e)))}else if("OR"===e.groupOP){s=void 0!==e.panelItemLogics.find((e=>ta(t,e)))}return e.notMode?!s:s}if(function(t){return"SINGLE"===t.logicType}(e))return Ge(t[e.dstModelField.toLowerCase()],e.condOp,e.value);throw new i(e,"未支持的逻辑类型".concat(e.logicType))}var ea=t("LayoutPanelUtil",class{constructor(){this.cache=new Map}register(t,e){this.cache.set(t,e)}get(t){return this.cache.get(t)}fill(t){const{viewLayoutPanel:e}=t;if(!e||!0===e.useDefaultLayout){const e=this.calcLayoutTag(t);if(this.cache.has(e)){const a=Z(this.cache.get(e));t.viewLayoutPanel=a,t.appCounterRefs&&(a.appCounterRefs=t.appCounterRefs,delete t.appCounterRefs),t.appViewEngines&&(a.appViewEngines=t.appViewEngines,delete t.appViewEngines),t.appViewLogics&&(a.appViewLogics=t.appViewLogics,delete t.appViewLogics),t.appViewRefs&&(a.appViewRefs=t.appViewRefs,delete t.appViewRefs),t.controls&&(a.controls=t.controls,delete t.controls)}}return t}calcLayoutTag(t){const{viewType:e,viewStyle:a}=t;return"APPINDEXVIEW"===e?this.calcIndexViewLayoutTag(t):"".concat(e,"_").concat(a)}calcIndexViewLayoutTag(t){const{viewType:e,viewStyle:a,blankMode:i,mainMenuAlign:s}=t;let n="";i?n="BLANK_MODE":s&&(n=s.toUpperCase());let o="";return o=""!==n?"".concat(e,"_").concat(a,"_").concat(n):"".concat(e,"_").concat(a),ibiz.config.view.disableHomeTabs&&["APPINDEXVIEW_DEFAULT","APPINDEXVIEW_DEFAULT_LEFT","APPINDEXVIEW_DEFAULT_TOP"].includes(o)&&(o+="_NO_NAV"),o}});function aa(t){const e={};return t.param09&&(e.srfprocessinstanceid=t.param09),e}var ia=t("ControlType",(t=>(t.APP_MENU="APPMENU",t.GRID="GRID",t.FORM="FORM",t.SEARCHFORM="SEARCHFORM",t.TOOLBAR="TOOLBAR",t.DRBAR="DRBAR",t.VIEWPANEL="VIEWPANEL",t.PICKUP_VIEW_PANEL="PICKUPVIEWPANEL",t.DATAVIEW="DATAVIEW",t.TREEGRID="TREEGRID",t.WF_EXPBAR="WFEXPBAR",t.TREEVIEW="TREEVIEW",t.TREE_EXP_BAR="TREEEXPBAR",t.TAB_VIEWPANEL="TABVIEWPANEL",t.DRTAB="DRTAB",t.CHART="CHART",t.REPORT_PANEL="REPORTPANEL",t.LIST="LIST",t.MOB_MDCTRL="MOBMDCTRL",t.MULTI_EDIT_VIEWPANEL="MULTIEDITVIEWPANEL",t.WIZARD_PANEL="WIZARDPANEL",t.UPDATE_PANEL="UPDATEPANEL",t.SEARCHBAR="SEARCHBAR",t.DASHBOARD="DASHBOARD",t.CALENDAR="CALENDAR",t.PANEL="PANEL",t.VIEW_LAYOUT_PANEL="VIEWLAYOUTPANEL",t.MAP="MAP",t.GANTT="GANTT",t.TREE_GRIDEX="TREEGRIDEX",t.KANBAN="KANBAN",t.CALENDAR_EXPBAR="CALENDAREXPBAR",t.CHART_EXPBAR="CHARTEXPBAR",t.DATA_VIEW_EXPBAR="DATAVIEWEXPBAR",t.GANTT_EXPBAR="GANTTEXPBAR",t.GRID_EXPBAR="GRIDEXPBAR",t.LIST_EXPBAR="LISTEXPBAR",t.MAP_EXPBAR="MAPEXPBAR",t.STATE_WIZARD_PANEL="STATEWIZARDPANEL",t.TAB_EXP_PANEL="TABEXPPANEL",t.CUSTOM="CUSTOM",t.CAPTIONBAR="CAPTIONBAR",t.CONTEXT_MENU="CONTEXTMENU",t))(ia||{})),sa=t("PlatformType",(t=>(t.IOS="IOS",t.ANDROID="Android",t.WECHAT="WeChat",t.QQ="QQ",t.DINGTALK="DingTalk",t.BROWSER="Browser",t.WCMP="WeChatMiniProgram",t.DESKTOP="Desktop",t))(sa||{})),na=t("RouteConst",(t=>(t.ROUTE_MODAL_TAG="route-modal",t))(na||{})),oa=t("StudioViewEvents",class{});oa.onViewMounted="onMounted",oa.onViewDestroyed="onDestroyed";var ra=t("StudioPanelEvents",class{});ra.onClick="onClick",ra.onChange="onChange",ra.onEnter="onEnter",ra.onLeave="onLeave";var ca=t("StudioControlEvents",class{});ca.onBeforeLoad="onBeforeLoad",ca.onLoadSuccess="onLoadSuccess",ca.onLoadError="onLoadError",ca.onBeforeLoadDraft="onBeforeLoadDraft",ca.onLoadDraftSuccess="onLoadDraftSuccess",ca.onLoadDraftError="onLoadDraftError",ca.onBeforeSave="onBeforeSave",ca.onSaveSuccess="onSaveSuccess",ca.onSaveError="onSaveError",ca.onBeforeRemove="onBeforeRemove",ca.onRemoveSuccess="onRemoveSuccess",ca.onRemoveError="onRemoveError",ca.CLICK="onClick";var da=t("SysUIActionTag",(t=>(t.NEW="New",t.EDIT="Edit",t.REFRESH="Refresh",t.EXIT="Exit",t.SAVE_AND_EXIT="SaveAndExit",t.SAVE_AND_NEW="SaveAndNew",t.SAVE="Save",t.SAVE_ROW="SaveRow",t.REMOVE="Remove",t.REMOVE_AND_EXIT="RemoveAndExit",t.NEW_ROW="NewRow",t.TOGGLE_FILTER="ToggleFilter",t.IMPORT="Import",t.EXPORT_EXCEL="ExportExcel",t.SAVE_AND_START="SaveAndStart",t.VIEW_WF_STEP="ViewWFStep",t.NO="No",t.YES="Yes",t.CANCEL="Cancel",t.OK="Ok",t.SEARCH="Search",t.RESET="Reset",t.FINISH="Finish",t.NEXT_STEP="NextStep",t.PREV_STEP="PrevStep",t.ADD_SELECTION="AddSelection",t.REMOVE_SELECTION="RemoveSelection",t.REMOVE_ALL="RemoveAll",t.ADD_ALL="AddAll",t.LOGOUT="Logout",t.LOGIN="Login",t.CANCEL_CHANGES="CancelChanges",t.COPY="Copy",t.VIEW="View",t.TOGGLE_ROW_EDIT="ToggleRowEdit",t.REFRESH_ALL="RefreshAll",t.REFRESH_PARENT="RefreshParent",t.FIRST_RECORD="FirstRecord",t.LAST_RECORD="LastRecord",t.PREV_RECORD="PrevRecord",t.NEXT_RECORD="NextRecord",t.LOAD_MORE="LoadMore",t))(da||{})),la=t("ValueOP",(t=>(t.EQ="EQ",t.NOT_EQ="NOTEQ",t.GT="GT",t.GT_AND_EQ="GTANDEQ",t.LT="LT",t.LT_AND_EQ="LTANDEQ",t.IS_NULL="ISNULL",t.IS_NOT_NULL="ISNOTNULL",t.IN="IN",t.NOT_IN="NOTIN",t.LIKE="LIKE",t.LIFT_LIKE="LIFTLIKE",t.RIGHT_LIKE="RIGHT_LIKE",t.CHILD_OF="CHILDOF",t.USER_LIKE="USERLIKE",t.BIT_AND="BITAND",t.EXISTS="EXISTS",t.NOT_EXISTS="NOTEXISTS",t))(la||{})),ha=t("ViewCallTag",(t=>(t.LOAD="Load",t.GET_DATA="GetData",t.GET_ALL_DATA="GetAllData",t.VALIDATE="Validate",t.TOGGLE_COLLAPSE="ToggleCollapse",t.WF_WITHDRAW="WFWithdraw",t))(ha||{})),ua=t("ViewMode",(t=>(t.ROUTE="ROUTE",t.ROUTE_MODAL="ROUTE_MODAL",t.MODAL="MODAL",t.DRAWER="DRAWER",t.EMBED="EMBED",t.POPOVER="POPOVER",t))(ua||{})),pa=t("ViewType",(t=>(t.APP_INDEX_VIEW="APPINDEXVIEW",t.DE_GRID_VIEW="DEGRIDVIEW",t.DE_EDIT_VIEW="DEEDITVIEW",t.APP_DATA_UPLOAD_VIEW="APPDATAUPLOADVIEW",t.APP_ERROR_VIEW="APPERRORVIEW",t.APP_FILE_UPLOAD_VIEW="APPFILEUPLOADVIEW",t.APP_FUN_PICKUP_VIEW="APPFUNCPICKUPVIEW",t.APP_LOGIN_VIEW="APPLOGINVIEW",t.APP_LOGOUT_VIEW="APPLOGOUTVIEW",t.APP_PANEL_VIEW="APPPANELVIEW",t.APP_PIC_UPLOAD_VIEW="APPPICUPLOADVIEW",t.APP_PORTAL_VIEW="APPPORTALVIEW",t.APP_REDIRECT_VIEW="APPREDIRECTVIEW",t.APP_START_VIEW="APPSTARTVIEW",t.APP_WELCOME_VIEW="APPWELCOMEVIEW",t.APP_WF_ADD_STEP_AFTER_VIEW="APPWFADDSTEPAFTERVIEW",t.APP_WF_ADD_STEP_BEFORE_VIEW="APPWFADDSTEPBEFOREVIEW",t.APP_WF_REDIRECT_VIEW="APPWFREDIRECTVIEW",t.APP_WF_SENDBAC_VIEW="APPWFSENDBACKVIEW",t.APP_WF_STEP_ACTOR_VIEW="APPWFSTEPACTORVIEW",t.APP_WF_STEP_DATA_VIEW="APPWFSTEPDATAVIEW",t.APP_WF_STEP_TRACE_VIEW="APPWFSTEPTRACEVIEW",t.APP_WF_SUPPLY_INFO_VIEW="APPWFSUPPLYINFOVIEW",t.APP_WF_TAKE_ADVICE_VIEW="APPWFTAKEADVICEVIEW",t.DE_CALENDAR_EXP_VIEW="DECALENDAREXPVIEW",t.DE_CALENDAR_VIEW="DECALENDARVIEW",t.DE_CHART_EXP_VIEW="DECHARTEXPVIEW",t.DE_CHART_VIEW="DECHARTVIEW",t.DE_CHART_VIEW9="DECHARTVIEW9",t.DE_CUSTOM_VIEW="DECUSTOMVIEW",t.DE_DATA_VIEW="DEDATAVIEW",t.DE_DATA_VIEW9="DEDATAVIEW9",t.DE_DATAVIEW_EXP_VIEW="DEDATAVIEWEXPVIEW",t.DE_EDIT_VIEW2="DEEDITVIEW2",t.DE_EDIT_VIEW3="DEEDITVIEW3",t.DE_EDIT_VIEW4="DEEDITVIEW4",t.DE_EDIT_VIEW9="DEEDITVIEW9",t.DE_FORM_PICKUP_DATA_VIEW="DEFORMPICKUPDATAVIEW",t.DE_GANTT_EXP_VIEW="DEGANTTEXPVIEW",t.DE_GANTT_VIEW="DEGANTTVIEW",t.DE_GANTT_VIEW9="DEGANTTVIEW9",t.DE_GRID_EXP_VIEW="DEGRIDEXPVIEW",t.DE_GRID_VIEW2="DEGRIDVIEW2",t.DE_GRID_VIEW4="DEGRIDVIEW4",t.DE_GRID_VIEW8="DEGRIDVIEW8",t.DE_GRID_VIEW9="DEGRIDVIEW9",t.DE_HTML_VIEW="DEHTMLVIEW",t.DE_INDEX_PICKUP_DATA_VIEW="DEINDEXPICKUPDATAVIEW",t.DE_INDEX_VIEW="DEINDEXVIEW",t.DE_KANBAN_VIEW="DEKANBANVIEW",t.DE_KANBAN_VIEW9="DEKANBANVIEW9",t.DE_LIST_EXP_VIEW="DELISTEXPVIEW",t.DE_LIST_VIEW="DELISTVIEW",t.DE_LIST_VIEW9="DELISTVIEW9",t.DE_MAP_EXP_VIEW="DEMAPEXPVIEW",t.DE_MAP_VIEW="DEMAPVIEW",t.DE_MAP_VIEW9="DEMAPVIEW9",t.DE_MD_CUSTOM_VIEW="DEMDCUSTOMVIEW",t.DE_MEDITVIEW9="DEMEDITVIEW9",t.DE_MOB_CALENDAR_EXP_VIEW="DEMOBCALENDAREXPVIEW",t.DE_MOB_CALENDAR_VIEW="DEMOBCALENDARVIEW",t.DE_MOB_CALENDAR_VIEW9="DEMOBCALENDARVIEW9",t.DE_MOB_CHART_EXP_VIEW="DEMOBCHARTEXPVIEW",t.DE_MO_BCHART_VIEW="DEMOBCHARTVIEW",t.D_EMOB_CHART_VIEW9="DEMOBCHARTVIEW9",t.DE_MOB_CUSTOM_VIEW="DEMOBCUSTOMVIEW",t.DE_MOB_DATA_VIEW="DEMOBDATAVIEW",t.DE_MOB_DATA_VIEW_EXP_VIEW="DEMOBDATAVIEWEXPVIEW",t.DE_MOB_EDIT_VIEW="DEMOBEDITVIEW",t.DE_MOB_EDIT_VIEW3="DEMOBEDITVIEW3",t.DE_MOB_EDITVIEW9="DEMOBEDITVIEW9",t.DE_MOB_FORM_PICKUP_MDVIEW="DEMOBFORMPICKUPMDVIEW",t.DE_MOB_GANTT_EXP_VIEW="DEMOBGANTTEXPVIEW",t.DE_MOB_GANTT_VIEW="DEMOBGANTTVIEW",t.DE_MOB_GANTT_VIEW9="DEMOBGANTTVIEW9",t.DE_MOB_HTML_VIEW="DEMOBHTMLVIEW",t.DE_MOB_INDEX_PICKUP_MDVIEW="DEMOBINDEXPICKUPMDVIEW",t.DE_MOB_LIST_EXP_VIEW="DEMOBLISTEXPVIEW",t.DE_MOB_LIST_VIEW="DEMOBLISTVIEW",t.DE_MOB_MAP_VIEW="DEMOBMAPVIEW",t.DE_MOB_MAP_VIEW9="DEMOBMAPVIEW9",t.DE_MOB_MDVIEW="DEMOBMDVIEW",t.DE_MOB_MDVIEW9="DEMOBMDVIEW9",t.DE_MOB_MEDIT_VIEW9="DEMOBMEDITVIEW9",t.DE_MOB_MPICKUP_VIEW="DEMOBMPICKUPVIEW",t.DE_MOB_OPT_VIEW="DEMOBOPTVIEW",t.DE_MOB_PANEL_VIEW="DEMOBPANELVIEW",t.DE_MOB_PANEL_VIEW9="DEMOBPANELVIEW9",t.DE_MOB_PICKUP_LIST_VIEW="DEMOBPICKUPLISTVIEW",t.DE_MOB_PICKUP_MDVIEW="DEMOBPICKUPMDVIEW",t.DE_MOB_PICKUP_TREE_VIEW="DEMOBPICKUPTREEVIEW",t.DE_MOB_PICKUP_VIEW="DEMOBPICKUPVIEW",t.DE_MOB_PORTAL_VIEW="DEMOBPORTALVIEW",t.DE_MOB_PORTAL_VIEW9="DEMOBPORTALVIEW9",t.DE_MOB_REDIRECT_VIEW="DEMOBREDIRECTVIEW",t.DE_MOB_REPORT_VIEW="DEMOBREPORTVIEW",t.DE_MOB_TAB_EXP_VIEW="DEMOBTABEXPVIEW",t.DE_MOB_TAB_EXP_VIEW9="DEMOBTABEXPVIEW9",t.DE_MOB_TAB_SEARCH_VIEW="DEMOBTABSEARCHVIEW",t.DE_MOB_TAB_SEARCH_VIEW9="DEMOBTABSEARCHVIEW9",t.DE_MOB_TREE_EXP_VIEW="DEMOBTREEEXPVIEW",t.DEMOBTREEEXPVIEW9="DEMOBTREEEXPVIEW9",t.DE_MOB_TREE_VIEW="DEMOBTREEVIEW",t.DE_MOB_WFACTION_VIEW="DEMOBWFACTIONVIEW",t.DE_MOB_WF_DATA_REDIRECT_VIEW="DEMOBWFDATAREDIRECTVIEW",t.DE_MOB_WF_DYNAACTIO_NVIEW="DEMOBWFDYNAACTIONVIEW",t.DE_MOB_WFDYNA_EDIT_VIEW="DEMOBWFDYNAEDITVIEW",t.DE_MOB_WF_DYNA_EDIT_VIEW3="DEMOBWFDYNAEDITVIEW3",t.DE_MOB_WF_DYNA_EXP_MDVIEW="DEMOBWFDYNAEXPMDVIEW",t.DE_MO_BWF_DYNA_START_VIEW="DEMOBWFDYNASTARTVIEW",t.DE_MOB_WF_EDIT_VIEW="DEMOBWFEDITVIEW",t.DE_MOB_WF_EDIT_VIEW3="DEMOBWFEDITVIEW3",t.DE_MOB_WF_MDVIEW="DEMOBWFMDVIEW",t.DE_MOB_WF_PROXY_RESULT_VIEW="DEMOBWFPROXYRESULTVIEW",t.DE_MOB_WF_PROXY_START_VIEW="DEMOBWFPROXYSTARTVIEW",t.DE_MOB_WF_START_VIEW="DEMOBWFSTARTVIEW",t.DE_MOB_WIZARD_VIEW="DEMOBWIZARDVIEW",t.DE_MPICKUP_VIEW="DEMPICKUPVIEW",t.DE_MPICKUP_VIEW2="DEMPICKUPVIEW2",t.DE_OPT_VIEW="DEOPTVIEW",t.DE_PANEL_VIEW="DEPANELVIEW",t.DE_PANEL_VIEW9="DEPANELVIEW9",t.DE_PICKUP_DATA_VIEW="DEPICKUPDATAVIEW",t.DE_PICKUP_GRID_VIEW="DEPICKUPGRIDVIEW",t.DE_PICKUP_TREE_VIEW="DEPICKUPTREEVIEW",t.DE_PICKUP_VIEW="DEPICKUPVIEW",t.DE_PICKUP_VIEW2="DEPICKUPVIEW2",t.DE_PICK_UP_VIEW3="DEPICKUPVIEW3",t.DE_PORTAL_VIEW="DEPORTALVIEW",t.DE_PORTAL_VIEW9="DEPORTALVIEW9",t.DE_REDIRECT_VIEW="DEREDIRECTVIEW",t.DE_REPORT_VIEW="DEREPORTVIEW",t.DE_TAB_EXP_VIEW="DETABEXPVIEW",t.DE_TAB_EXP_VIEW9="DETABEXPVIEW9",t.DE_TAB_SEARCH_VIEW="DETABSEARCHVIEW",t.DE_TAB_SEARCH_VIEW9="DETABSEARCHVIEW9",t.DE_TREE_EXP_VIEW="DETREEEXPVIEW",t.DE_TREE_EXP_VIEW2="DETREEEXPVIEW2",t.DE_TREE_EXP_VIEW3="DETREEEXPVIEW3",t.DE_TREE_GRID_EXVIEW="DETREEGRIDEXVIEW",t.DE_TREE_GRID_EXVIEW9="DETREEGRIDEXVIEW9",t.DE_TREE_GRID_VIEW="DETREEGRIDVIEW",t.DE_TREE_GRID_VIEW9="DETREEGRIDVIEW9",t.DE_TREE_VIEW="DETREEVIEW",t.DE_TREE_VIEW9="DETREEVIEW9",t.DE_WF_ACTION_VIEW="DEWFACTIONVIEW",t.DE_WF_DATA_REDIRECT_VIEW="DEWFDATAREDIRECTVIEW",t.DE_WF_DYNA_ACTION_VIEW="DEWFDYNAACTIONVIEW",t.DE_WF_DYNA_EDIT_VIEW="DEWFDYNAEDITVIEW",t.DE_WF_DYNA_EDIT_VIEW3="DEWFDYNAEDITVIEW3",t.DE_WF_DYNA_EXP_GRID_VIEW="DEWFDYNAEXPGRIDVIEW",t.DE_WF_DYNA_START_VIEW="DEWFDYNASTARTVIEW",t.DE_WF_EDIT_PROXY_DATA_VIEW="DEWFEDITPROXYDATAVIEW",t.DE_WF_EDIT_VIEW="DEWFEDITVIEW",t.DE_WF_EDIT_VIEW2="DEWFEDITVIEW2",t.DE_WF_EDIT_VIEW3="DEWFEDITVIEW3",t.DE_WF_EDIT_VIEW9="DEWFEDITVIEW9",t.DE_WF_EXP_VIEW="DEWFEXPVIEW",t.DE_WF_GRID_VIEW="DEWFGRIDVIEW",t.DE_WF_PROXY_DATA_VIEW="DEWFPROXYDATAVIEW",t.DE_WF_PROXY_RESULT_VIEW="DEWFPROXYRESULTVIEW",t.DE_WF_PROXY_START_VIEW="DEWFPROXYSTARTVIEW",t.DE_WF_START_VIEW="DEWFSTARTVIEW",t.DE_WIZARD_VIEW="DEWIZARDVIEW",t.DE_SUB_APP_REF_VIEW="DESUBAPPREFVIEW",t))(pa||{})),ma=t("PresetIdentifier",(t=>(t.MESSAGE="preset-message",t))(ma||{})),fa=t("Modal",class{constructor(t){this.mode="EMBED",this.viewUsage=4,this.ignoreDismissCheck=!1,this.hooks={shouldDismiss:new rt,beforeDismiss:new rt},this._dismiss=t=>{ibiz.log.error("外部关闭能力未注册",t)},t.mode&&(this.mode=t.mode),t.routeDepth&&(this.routeDepth=t.routeDepth),t.viewUsage&&(this.viewUsage=t.viewUsage),t.dismiss&&(this._dismiss=t.dismiss)}injectDismiss(t){this._dismiss=t}async dismiss(t={ok:!1,data:[]}){const e={};return!0!==this.ignoreDismissCheck&&await this.hooks.shouldDismiss.call(e),!1===e.allowClose?(ibiz.log.debug("shouldDismiss结果为false,关闭中断。"),!1):(await this.hooks.beforeDismiss.call(t),this._dismiss(t),this.destroy(),!0)}destroy(){this.hooks.shouldDismiss.clear(),this.hooks.beforeDismiss.clear()}});function ga(t,e){return t.filter((t=>{const{checkMode:a}=t,i=t.deformItemName||t.degridEditItemName;return 2!==a&&i===e}))}var wa=t("TextUtil",class{constructor(){this.inputElement=null}format(t,e){return t}copy(t){return this.inputElement||(this.inputElement=document.createElement("input"),this.inputElement.style.position="absolute",this.inputElement.style.left="-9999px",document.body.appendChild(this.inputElement)),this.inputElement.value=t,this.inputElement.select(),document.execCommand("copy")}}),Ea=t("ThemeUtil",class{constructor(){this.html=document.getElementsByTagName("html")[0]}async loadTheme(t){const e=Z(t.themeParams||{}),a=e["theme-package-path"];delete e.appId,delete e["theme-package-path"],await ibiz.plugin.loadPlugin({runtimeObject:!0,rtobjectName:t.name,rtobjectRepo:a}),this.setThemeParams(t,e),this.setTheme(t.themeTag)}setThemeParams(t,e){if(document.getElementById(t.themeTag))return;let a=":root.".concat(t.themeTag,"{");for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t)){const i=e[t];a+="".concat(t,": ").concat(i).concat(i.endsWith(";")?"":";")}a+="}";const i=document.createElement("style");i.id=t.themeTag,i.type="text/css",i.innerHTML=a,document.head.appendChild(i)}setTheme(t){const e=this.getTheme();this.html.classList.remove(e),this.html.setAttribute("theme",t),this.html.classList.add(t)}getTheme(){return this.html.getAttribute("theme")}}),ya=class{constructor(){this.commitQueue=new Map,this.state={isOpen:!1,isChange:!1}}open(){this.state.isOpen?ibiz.log.warn("事务已经开启, 单个界面域只能开启一个事务"):this.state.isOpen=!0}change(t,e){this.state.isChange=!0,this.commitQueue.set(t,e)}commit(){const t=Array.from(this.commitQueue.values()).reverse();for(const e of t)e();this.commitQueue.clear(),this.state.isChange=!1}rollback(){this.commitQueue.clear(),this.state.isChange=!1}close(){if(this.state.isChange)throw new Error("当前事务未提交,不可以直接关闭事务");this.state.isOpen=!1}},va=t("UIDomain",class{constructor(t){this.state={rsInit:!1},this.rsMap=new Map,this.rs2Map=new Map,this.transaction=new ya,this.dataModification=!1,this.id=t||ct()}dataChange(){this.dataModification=!0}dataChangeCompleted(){this.dataModification=!1}setDERConfig(t,e){this.rsMap.set(t,e)}getDERConfig(t){return this.rsMap.has(t)?this.rsMap.get(t):[]}getDERConfigByMajor(t){return this.rs2Map.has(t)?this.rs2Map.get(t):[]}calcParentRs(){this.rs2Map.clear(),this.rsMap.forEach(((t,e)=>{t.forEach((t=>{t.minorAppDataEntityId=e;const a=t.majorAppDataEntityId;this.rs2Map.has(a)||this.rs2Map.set(a,[]),this.rs2Map.get(a).push(t)}))}))}destroy(){this.rsMap.clear();ibiz.hub.getAllApps().forEach((t=>{t.deService.reset({srfappid:t.appId,srfsessionid:this.id})}))}}),Ia=t("UIDomainManager",class{constructor(){this.domainMap=new Map}create(t){const e=new va(t);return this.domainMap.set(e.id,e),e}get(t){if(this.domainMap.has(t))return this.domainMap.get(t);throw new Error("无效的界面域标识[".concat(t,"]"))}destroy(t){this.domainMap.has(t)&&(this.domainMap.get(t).destroy(),this.domainMap.delete(t))}}),Da=t("RawValueUtil",class{isNumber(t){return/^-?\d+(\.\d+)?$/.test(t)}format(t){let e=t;return void 0!==t&&("true"===t||"false"===t?e="true"===t:this.isNumber(t)&&(e=parseFloat(t))),e}}),Ca=t("ViewStack",class{constructor(){this.stackMap=new Map,this.stack=[],this.activeStack=[],this.evt=new dt}add(t,e){this.stack.push(e),this.stackMap.set(t,e),this.recalculateActiveStack(),this.evt.emit("add",e),this.evt.emit("change",{type:"add",view:e})}remove(t){const e=this.stackMap.get(t);e&&(this.stack.splice(this.stack.indexOf(e),1),this.stackMap.delete(t),this.recalculateActiveStack(),this.evt.emit("remove",e),this.evt.emit("change",{type:"remove",view:e}))}getActives(){return this.activeStack}active(t){const e=this.stackMap.get(t);e&&(this.recalculateActiveStack(),this.evt.emit("active",e),this.evt.emit("change",{type:"active",view:e}))}deactivate(t){const e=this.stackMap.get(t);e&&(this.recalculateActiveStack(),this.evt.emit("deactivate",e),this.evt.emit("change",{type:"deactivate",view:e}))}getView(t){return this.stackMap.get(t)}recalculateActiveStack(){this.activeStack=this.stack.filter((t=>!0===t.isActive))}});async function ba(t,e=!0){const a=await Promise.allSettled(t),i=[],s=[];if(a.forEach((t=>{"fulfilled"===t.status?i.push(t.value):s.push(t.reason)})),s.length>0){const t=1===s.length?s[0]:s;if(e)throw t;ibiz.util.error.handle(t)}return i}var Aa={position:"fixed",zIndex:"10000"};function Pa(t,e=document.body,a=!0){const i=xa(t);if(null==i)throw new Error("Cannot clone a null or undefined element.");const s=i.cloneNode(!0);if(a)for(;s.firstChild;)s.removeChild(s.firstChild);return function(t,{width:e,height:a,boundingLeft:i,boundingTop:s}){t.style.left="".concat(i,"px"),t.style.top="".concat(s,"px"),t.style.width="".concat(e,"px"),t.style.height="".concat(a,"px"),Object.assign(t.style,Aa)}(s,Ta(i)),e.appendChild(s),s}function Ta(t){const e=t.offsetWidth,a=t.offsetHeight,i=window.getComputedStyle(t),s=parseFloat(i.padding),{left:n,top:o}=t.getBoundingClientRect();return{width:e,height:a,padding:s,boundingLeft:n,boundingTop:o}}function xa(t){return"string"==typeof t?document.querySelector(t):t}var Sa={update:null,begin:null,loopBegin:null,changeBegin:null,change:null,changeComplete:null,loopComplete:null,complete:null,loop:1,direction:"normal",autoplay:!0,timelineOffset:0},Na={duration:1e3,delay:0,endDelay:0,easing:"easeOutElastic(1, .5)",round:0},Ra=["translateX","translateY","translateZ","rotate","rotateX","rotateY","rotateZ","scale","scaleX","scaleY","scaleZ","skew","skewX","skewY","perspective","matrix","matrix3d"],Ma={CSS:{},springs:{}};function Oa(t,e,a){return Math.min(Math.max(t,e),a)}function La(t,e){return t.indexOf(e)>-1}function _a(t,e){return t.apply(null,e)}var Fa={arr:function(t){return Array.isArray(t)},obj:function(t){return La(Object.prototype.toString.call(t),"Object")},pth:function(t){return Fa.obj(t)&&t.hasOwnProperty("totalLength")},svg:function(t){return t instanceof SVGElement},inp:function(t){return t instanceof HTMLInputElement},dom:function(t){return t.nodeType||Fa.svg(t)},str:function(t){return"string"==typeof t},fnc:function(t){return"function"==typeof t},und:function(t){return void 0===t},nil:function(t){return Fa.und(t)||null===t},hex:function(t){return/(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(t)},rgb:function(t){return/^rgb/.test(t)},hsl:function(t){return/^hsl/.test(t)},col:function(t){return Fa.hex(t)||Fa.rgb(t)||Fa.hsl(t)},key:function(t){return!Sa.hasOwnProperty(t)&&!Na.hasOwnProperty(t)&&"targets"!==t&&"keyframes"!==t}};function Va(t){var e=/\(([^)]+)\)/.exec(t);return e?e[1].split(",").map((function(t){return parseFloat(t)})):[]}function ka(t,e){var a=Va(t),i=Oa(Fa.und(a[0])?1:a[0],.1,100),s=Oa(Fa.und(a[1])?100:a[1],.1,100),n=Oa(Fa.und(a[2])?10:a[2],.1,100),o=Oa(Fa.und(a[3])?0:a[3],.1,100),r=Math.sqrt(s/i),c=n/(2*Math.sqrt(s*i)),d=c<1?r*Math.sqrt(1-c*c):0,l=1,h=c<1?(c*r-o)/d:-o+r;function u(t){var a=e?e*t/1e3:t;return a=c<1?Math.exp(-a*c*r)*(l*Math.cos(d*a)+h*Math.sin(d*a)):(l+h*a)*Math.exp(-a*r),0===t||1===t?t:1-a}return e?u:function(){var e=Ma.springs[t];if(e)return e;for(var a=1/6,i=0,s=0;;)if(1===u(i+=a)){if(++s>=16)break}else s=0;var n=i*a*1e3;return Ma.springs[t]=n,n}}function za(t){return void 0===t&&(t=10),function(e){return Math.ceil(Oa(e,1e-6,1)*t)*(1/t)}}var Wa,Ua,Ba=function(){var t=.1;function e(t,e){return 1-3*e+3*t}function a(t,e){return 3*e-6*t}function i(t){return 3*t}function s(t,s,n){return((e(s,n)*t+a(s,n))*t+i(s))*t}function n(t,s,n){return 3*e(s,n)*t*t+2*a(s,n)*t+i(s)}return function(e,a,i,o){if(0<=e&&e<=1&&0<=i&&i<=1){var r=new Float32Array(11);if(e!==a||i!==o)for(var c=0;c<11;++c)r[c]=s(c*t,e,i);return function(t){return e===a&&i===o||0===t||1===t?t:s(d(t),a,o)}}function d(a){for(var o=0,c=1;10!==c&&r[c]<=a;++c)o+=t;--c;var d=o+(a-r[c])/(r[c+1]-r[c])*t,l=n(d,e,i);return l>=.001?function(t,e,a,i){for(var o=0;o<4;++o){var r=n(e,a,i);if(0===r)return e;e-=(s(e,a,i)-t)/r}return e}(a,d,e,i):0===l?d:function(t,e,a,i,n){var o,r,c=0;do{(o=s(r=e+(a-e)/2,i,n)-t)>0?a=r:e=r}while(Math.abs(o)>1e-7&&++c<10);return r}(a,o,o+t,e,i)}}}(),Ga=(Wa={linear:function(){return function(t){return t}}},Ua={Sine:function(){return function(t){return 1-Math.cos(t*Math.PI/2)}},Expo:function(){return function(t){return t?Math.pow(2,10*t-10):0}},Circ:function(){return function(t){return 1-Math.sqrt(1-t*t)}},Back:function(){return function(t){return t*t*(3*t-2)}},Bounce:function(){return function(t){for(var e,a=4;t<((e=Math.pow(2,--a))-1)/11;);return 1/Math.pow(4,3-a)-7.5625*Math.pow((3*e-2)/22-t,2)}},Elastic:function(t,e){void 0===t&&(t=1),void 0===e&&(e=.5);var a=Oa(t,1,10),i=Oa(e,.1,2);return function(t){return 0===t||1===t?t:-a*Math.pow(2,10*(t-1))*Math.sin((t-1-i/(2*Math.PI)*Math.asin(1/a))*(2*Math.PI)/i)}}},["Quad","Cubic","Quart","Quint"].forEach((function(t,e){Ua[t]=function(){return function(t){return Math.pow(t,e+2)}}})),Object.keys(Ua).forEach((function(t){var e=Ua[t];Wa["easeIn"+t]=e,Wa["easeOut"+t]=function(t,a){return function(i){return 1-e(t,a)(1-i)}},Wa["easeInOut"+t]=function(t,a){return function(i){return i<.5?e(t,a)(2*i)/2:1-e(t,a)(-2*i+2)/2}},Wa["easeOutIn"+t]=function(t,a){return function(i){return i<.5?(1-e(t,a)(1-2*i))/2:(e(t,a)(2*i-1)+1)/2}}})),Wa);function ja(t,e){if(Fa.fnc(t))return t;var a=t.split("(")[0],i=Ga[a],s=Va(t);switch(a){case"spring":return ka(t,e);case"cubicBezier":return _a(Ba,s);case"steps":return _a(za,s);default:return _a(i,s)}}function Ka(t){try{return document.querySelectorAll(t)}catch(t){return}}function Xa(t,e){for(var a=t.length,i=arguments.length>=2?arguments[1]:void 0,s=[],n=0;n<a;n++)if(n in t){var o=t[n];e.call(i,o,n,t)&&s.push(o)}return s}function Ha(t){return t.reduce((function(t,e){return t.concat(Fa.arr(e)?Ha(e):e)}),[])}function qa(t){return Fa.arr(t)?t:(Fa.str(t)&&(t=Ka(t)||t),t instanceof NodeList||t instanceof HTMLCollection?[].slice.call(t):[t])}function Ya(t,e){return t.some((function(t){return t===e}))}function Qa(t){var e={};for(var a in t)e[a]=t[a];return e}function $a(t,e){var a=Qa(t);for(var i in t)a[i]=e.hasOwnProperty(i)?e[i]:t[i];return a}function Ja(t,e){var a=Qa(t);for(var i in e)a[i]=Fa.und(t[i])?e[i]:t[i];return a}function Za(t){return Fa.rgb(t)?(a=/rgb\((\d+,\s*[\d]+,\s*[\d]+)\)/g.exec(e=t))?"rgba("+a[1]+",1)":e:Fa.hex(t)?function(t){var e=t.replace(/^#?([a-f\d])([a-f\d])([a-f\d])$/i,(function(t,e,a,i){return e+e+a+a+i+i})),a=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);return"rgba("+parseInt(a[1],16)+","+parseInt(a[2],16)+","+parseInt(a[3],16)+",1)"}(t):Fa.hsl(t)?function(t){var e,a,i,s=/hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.exec(t)||/hsla\((\d+),\s*([\d.]+)%,\s*([\d.]+)%,\s*([\d.]+)\)/g.exec(t),n=parseInt(s[1],10)/360,o=parseInt(s[2],10)/100,r=parseInt(s[3],10)/100,c=s[4]||1;function d(t,e,a){return a<0&&(a+=1),a>1&&(a-=1),a<1/6?t+6*(e-t)*a:a<.5?e:a<2/3?t+(e-t)*(2/3-a)*6:t}if(0==o)e=a=i=r;else{var l=r<.5?r*(1+o):r+o-r*o,h=2*r-l;e=d(h,l,n+1/3),a=d(h,l,n),i=d(h,l,n-1/3)}return"rgba("+255*e+","+255*a+","+255*i+","+c+")"}(t):void 0;var e,a}function ti(t){var e=/[+-]?\d*\.?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?(%|px|pt|em|rem|in|cm|mm|ex|ch|pc|vw|vh|vmin|vmax|deg|rad|turn)?$/.exec(t);if(e)return e[1]}function ei(t,e){return Fa.fnc(t)?t(e.target,e.id,e.total):t}function ai(t,e){return t.getAttribute(e)}function ii(t,e,a){if(Ya([a,"deg","rad","turn"],ti(e)))return e;var i=Ma.CSS[e+a];if(!Fa.und(i))return i;var s=document.createElement(t.tagName),n=t.parentNode&&t.parentNode!==document?t.parentNode:document.body;n.appendChild(s),s.style.position="absolute",s.style.width=100+a;var o=100/s.offsetWidth;n.removeChild(s);var r=o*parseFloat(e);return Ma.CSS[e+a]=r,r}function si(t,e,a){if(e in t.style){var i=e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase(),s=t.style[e]||getComputedStyle(t).getPropertyValue(i)||"0";return a?ii(t,s,a):s}}function ni(t,e){return Fa.dom(t)&&!Fa.inp(t)&&(!Fa.nil(ai(t,e))||Fa.svg(t)&&t[e])?"attribute":Fa.dom(t)&&Ya(Ra,e)?"transform":Fa.dom(t)&&"transform"!==e&&si(t,e)?"css":null!=t[e]?"object":void 0}function oi(t){if(Fa.dom(t)){for(var e,a=t.style.transform||"",i=/(\w+)\(([^)]*)\)/g,s=new Map;e=i.exec(a);)s.set(e[1],e[2]);return s}}function ri(t,e,a,i){var s=La(e,"scale")?1:0+function(t){return La(t,"translate")||"perspective"===t?"px":La(t,"rotate")||La(t,"skew")?"deg":void 0}(e),n=oi(t).get(e)||s;return a&&(a.transforms.list.set(e,n),a.transforms.last=e),i?ii(t,n,i):n}function ci(t,e,a,i){switch(ni(t,e)){case"transform":return ri(t,e,i,a);case"css":return si(t,e,a);case"attribute":return ai(t,e);default:return t[e]||0}}function di(t,e){var a=/^(\*=|\+=|-=)/.exec(t);if(!a)return t;var i=ti(t)||0,s=parseFloat(e),n=parseFloat(t.replace(a[0],""));switch(a[0][0]){case"+":return s+n+i;case"-":return s-n+i;case"*":return s*n+i}}function li(t,e){if(Fa.col(t))return Za(t);if(/\s/g.test(t))return t;var a=ti(t),i=a?t.substr(0,t.length-a.length):t;return e?i+e:i}function hi(t,e){return Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2))}function ui(t){for(var e,a=t.points,i=0,s=0;s<a.numberOfItems;s++){var n=a.getItem(s);s>0&&(i+=hi(e,n)),e=n}return i}function pi(t){if(t.getTotalLength)return t.getTotalLength();switch(t.tagName.toLowerCase()){case"circle":return function(t){return 2*Math.PI*ai(t,"r")}(t);case"rect":return function(t){return 2*ai(t,"width")+2*ai(t,"height")}(t);case"line":return function(t){return hi({x:ai(t,"x1"),y:ai(t,"y1")},{x:ai(t,"x2"),y:ai(t,"y2")})}(t);case"polyline":return ui(t);case"polygon":return function(t){var e=t.points;return ui(t)+hi(e.getItem(e.numberOfItems-1),e.getItem(0))}(t)}}function mi(t,e){var a=e||{},i=a.el||function(t){for(var e=t.parentNode;Fa.svg(e)&&Fa.svg(e.parentNode);)e=e.parentNode;return e}(t),s=i.getBoundingClientRect(),n=ai(i,"viewBox"),o=s.width,r=s.height,c=a.viewBox||(n?n.split(" "):[0,0,o,r]);return{el:i,viewBox:c,x:c[0]/1,y:c[1]/1,w:o,h:r,vW:c[2],vH:c[3]}}function fi(t,e,a){function i(a){void 0===a&&(a=0);var i=e+a>=1?e+a:0;return t.el.getPointAtLength(i)}var s=mi(t.el,t.svg),n=i(),o=i(-1),r=i(1),c=a?1:s.w/s.vW,d=a?1:s.h/s.vH;switch(t.property){case"x":return(n.x-s.x)*c;case"y":return(n.y-s.y)*d;case"angle":return 180*Math.atan2(r.y-o.y,r.x-o.x)/Math.PI}}function gi(t,e){var a=/[+-]?\d*\.?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?/g,i=li(Fa.pth(t)?t.totalLength:t,e)+"";return{original:i,numbers:i.match(a)?i.match(a).map(Number):[0],strings:Fa.str(t)||e?i.split(a):[]}}function wi(t){return Xa(t?Ha(Fa.arr(t)?t.map(qa):qa(t)):[],(function(t,e,a){return a.indexOf(t)===e}))}function Ei(t){var e=wi(t);return e.map((function(t,a){return{target:t,id:a,total:e.length,transforms:{list:oi(t)}}}))}function yi(t,e){var a=Qa(e);if(/^spring/.test(a.easing)&&(a.duration=ka(a.easing)),Fa.arr(t)){var i=t.length;2===i&&!Fa.obj(t[0])?t={value:t}:Fa.fnc(e.duration)||(a.duration=e.duration/i)}var s=Fa.arr(t)?t:[t];return s.map((function(t,a){var i=Fa.obj(t)&&!Fa.pth(t)?t:{value:t};return Fa.und(i.delay)&&(i.delay=a?0:e.delay),Fa.und(i.endDelay)&&(i.endDelay=a===s.length-1?e.endDelay:0),i})).map((function(t){return Ja(t,a)}))}function vi(t,e){var a=[],i=e.keyframes;for(var s in i&&(e=Ja(function(t){for(var e=Xa(Ha(t.map((function(t){return Object.keys(t)}))),(function(t){return Fa.key(t)})).reduce((function(t,e){return t.indexOf(e)<0&&t.push(e),t}),[]),a={},i=function(i){var s=e[i];a[s]=t.map((function(t){var e={};for(var a in t)Fa.key(a)?a==s&&(e.value=t[a]):e[a]=t[a];return e}))},s=0;s<e.length;s++)i(s);return a}(i),e)),e)Fa.key(s)&&a.push({name:s,tweens:yi(e[s],t)});return a}function Ii(t,e){var a;return t.tweens.map((function(i){var s=function(t,e){var a={};for(var i in t){var s=ei(t[i],e);Fa.arr(s)&&1===(s=s.map((function(t){return ei(t,e)}))).length&&(s=s[0]),a[i]=s}return a.duration=parseFloat(a.duration),a.delay=parseFloat(a.delay),a}(i,e),n=s.value,o=Fa.arr(n)?n[1]:n,r=ti(o),c=ci(e.target,t.name,r,e),d=a?a.to.original:c,l=Fa.arr(n)?n[0]:d,h=ti(l)||ti(c),u=r||h;return Fa.und(o)&&(o=d),s.from=gi(l,u),s.to=gi(di(o,l),u),s.start=a?a.end:0,s.end=s.start+s.delay+s.duration+s.endDelay,s.easing=ja(s.easing,s.duration),s.isPath=Fa.pth(n),s.isPathTargetInsideSVG=s.isPath&&Fa.svg(e.target),s.isColor=Fa.col(s.from.original),s.isColor&&(s.round=1),a=s,s}))}var Di={css:function(t,e,a){return t.style[e]=a},attribute:function(t,e,a){return t.setAttribute(e,a)},object:function(t,e,a){return t[e]=a},transform:function(t,e,a,i,s){if(i.list.set(e,a),e===i.last||s){var n="";i.list.forEach((function(t,e){n+=e+"("+t+") "})),t.style.transform=n}}};function Ci(t,e){Ei(t).forEach((function(t){for(var a in e){var i=ei(e[a],t),s=t.target,n=ti(i),o=ci(s,a,n,t),r=di(li(i,n||ti(o)),o),c=ni(s,a);Di[c](s,a,r,t.transforms,!0)}}))}function bi(t,e){return Xa(Ha(t.map((function(t){return e.map((function(e){return function(t,e){var a=ni(t.target,e.name);if(a){var i=Ii(e,t),s=i[i.length-1];return{type:a,property:e.name,animatable:t,tweens:i,duration:s.end,delay:i[0].delay,endDelay:s.endDelay}}}(t,e)}))}))),(function(t){return!Fa.und(t)}))}function Ai(t,e){var a=t.length,i=function(t){return t.timelineOffset?t.timelineOffset:0},s={};return s.duration=a?Math.max.apply(Math,t.map((function(t){return i(t)+t.duration}))):e.duration,s.delay=a?Math.min.apply(Math,t.map((function(t){return i(t)+t.delay}))):e.delay,s.endDelay=a?s.duration-Math.max.apply(Math,t.map((function(t){return i(t)+t.duration-t.endDelay}))):e.endDelay,s}var Pi=0;var Ti=[],xi=function(){var t;function e(a){for(var i=Ti.length,s=0;s<i;){var n=Ti[s];n.paused?(Ti.splice(s,1),i--):(n.tick(a),s++)}t=s>0?requestAnimationFrame(e):void 0}return"undefined"!=typeof document&&document.addEventListener("visibilitychange",(function(){Ni.suspendWhenDocumentHidden&&(Si()?t=cancelAnimationFrame(t):(Ti.forEach((function(t){return t._onDocumentVisibility()})),xi()))})),function(){t||Si()&&Ni.suspendWhenDocumentHidden||!(Ti.length>0)||(t=requestAnimationFrame(e))}}();function Si(){return!!document&&document.hidden}function Ni(t){void 0===t&&(t={});var e,a=0,i=0,s=0,n=0,o=null;function r(t){var e=window.Promise&&new Promise((function(t){return o=t}));return t.finished=e,e}var c=function(t){var e=$a(Sa,t),a=$a(Na,t),i=vi(a,t),s=Ei(t.targets),n=bi(s,i),o=Ai(n,a),r=Pi;return Pi++,Ja(e,{id:r,children:[],animatables:s,animations:n,duration:o.duration,delay:o.delay,endDelay:o.endDelay})}(t);function d(){var t=c.direction;"alternate"!==t&&(c.direction="normal"!==t?"normal":"reverse"),c.reversed=!c.reversed,e.forEach((function(t){return t.reversed=c.reversed}))}function l(t){return c.reversed?c.duration-t:t}function h(){a=0,i=l(c.currentTime)*(1/Ni.speed)}function u(t,e){e&&e.seek(t-e.timelineOffset)}function p(t){for(var e=0,a=c.animations,i=a.length;e<i;){var s=a[e],n=s.animatable,o=s.tweens,r=o.length-1,d=o[r];r&&(d=Xa(o,(function(e){return t<e.end}))[0]||d);for(var l=Oa(t-d.start-d.delay,0,d.duration)/d.duration,h=isNaN(l)?1:d.easing(l),u=d.to.strings,p=d.round,m=[],f=d.to.numbers.length,g=void 0,w=0;w<f;w++){var E=void 0,y=d.to.numbers[w],v=d.from.numbers[w]||0;E=d.isPath?fi(d.value,h*y,d.isPathTargetInsideSVG):v+h*(y-v),p&&(d.isColor&&w>2||(E=Math.round(E*p)/p)),m.push(E)}var I=u.length;if(I){g=u[0];for(var D=0;D<I;D++){u[D];var C=u[D+1],b=m[D];isNaN(b)||(g+=C?b+C:b+" ")}}else g=m[0];Di[s.type](n.target,s.property,g,n.transforms),s.currentValue=g,e++}}function m(t){c[t]&&!c.passThrough&&c[t](c)}function f(t){var h=c.duration,f=c.delay,g=h-c.endDelay,w=l(t);c.progress=Oa(w/h*100,0,100),c.reversePlayback=w<c.currentTime,e&&function(t){if(c.reversePlayback)for(var a=n;a--;)u(t,e[a]);else for(var i=0;i<n;i++)u(t,e[i])}(w),!c.began&&c.currentTime>0&&(c.began=!0,m("begin")),!c.loopBegan&&c.currentTime>0&&(c.loopBegan=!0,m("loopBegin")),w<=f&&0!==c.currentTime&&p(0),(w>=g&&c.currentTime!==h||!h)&&p(h),w>f&&w<g?(c.changeBegan||(c.changeBegan=!0,c.changeCompleted=!1,m("changeBegin")),m("change"),p(w)):c.changeBegan&&(c.changeCompleted=!0,c.changeBegan=!1,m("changeComplete")),c.currentTime=Oa(w,0,h),c.began&&m("update"),t>=h&&(i=0,c.remaining&&!0!==c.remaining&&c.remaining--,c.remaining?(a=s,m("loopComplete"),c.loopBegan=!1,"alternate"===c.direction&&d()):(c.paused=!0,c.completed||(c.completed=!0,m("loopComplete"),m("complete"),!c.passThrough&&"Promise"in window&&(o(),r(c)))))}return r(c),c.reset=function(){var t=c.direction;c.passThrough=!1,c.currentTime=0,c.progress=0,c.paused=!0,c.began=!1,c.loopBegan=!1,c.changeBegan=!1,c.completed=!1,c.changeCompleted=!1,c.reversePlayback=!1,c.reversed="reverse"===t,c.remaining=c.loop,e=c.children;for(var a=n=e.length;a--;)c.children[a].reset();(c.reversed&&!0!==c.loop||"alternate"===t&&1===c.loop)&&c.remaining++,p(c.reversed?c.duration:0)},c._onDocumentVisibility=h,c.set=function(t,e){return Ci(t,e),c},c.tick=function(t){s=t,a||(a=s),f((s+(i-a))*Ni.speed)},c.seek=function(t){f(l(t))},c.pause=function(){c.paused=!0,h()},c.play=function(){c.paused&&(c.completed&&c.reset(),c.paused=!1,Ti.push(c),h(),xi())},c.reverse=function(){d(),c.completed=!c.reversed,h()},c.restart=function(){c.reset(),c.play()},c.remove=function(t){Mi(wi(t),c)},c.reset(),c.autoplay&&c.play(),c}function Ri(t,e){for(var a=e.length;a--;)Ya(t,e[a].animatable.target)&&e.splice(a,1)}function Mi(t,e){var a=e.animations,i=e.children;Ri(t,a);for(var s=i.length;s--;){var n=i[s],o=n.animations;Ri(t,o),o.length||n.children.length||i.splice(s,1)}a.length||i.length||e.pause()}Ni.version="3.2.1",Ni.speed=1,Ni.suspendWhenDocumentHidden=!0,Ni.running=Ti,Ni.remove=function(t){for(var e=wi(t),a=Ti.length;a--;){Mi(e,Ti[a])}},Ni.get=ci,Ni.set=Ci,Ni.convertPx=ii,Ni.path=function(t,e){var a=Fa.str(t)?Ka(t)[0]:t,i=e||100;return function(t){return{property:t,el:a,svg:mi(a),totalLength:pi(a)*(i/100)}}},Ni.setDashoffset=function(t){var e=pi(t);return t.setAttribute("stroke-dasharray",e),e},Ni.stagger=function(t,e){void 0===e&&(e={});var a=e.direction||"normal",i=e.easing?ja(e.easing):null,s=e.grid,n=e.axis,o=e.from||0,r="first"===o,c="center"===o,d="last"===o,l=Fa.arr(t),h=l?parseFloat(t[0]):parseFloat(t),u=l?parseFloat(t[1]):0,p=ti(l?t[1]:t)||0,m=e.start||0+(l?h:0),f=[],g=0;return function(t,e,w){if(r&&(o=0),c&&(o=(w-1)/2),d&&(o=w-1),!f.length){for(var E=0;E<w;E++){if(s){var y=c?(s[0]-1)/2:o%s[0],v=c?(s[1]-1)/2:Math.floor(o/s[0]),I=y-E%s[0],D=v-Math.floor(E/s[0]),C=Math.sqrt(I*I+D*D);"x"===n&&(C=-I),"y"===n&&(C=-D),f.push(C)}else f.push(Math.abs(o-E));g=Math.max.apply(Math,f)}i&&(f=f.map((function(t){return i(t/g)*g}))),"reverse"===a&&(f=f.map((function(t){return n?t<0?-1*t:-t:Math.abs(g-t)})))}return m+(l?(u-h)/g:h)*(Math.round(100*f[e])/100)+p}},Ni.timeline=function(t){void 0===t&&(t={});var e=Ni(t);return e.duration=0,e.add=function(a,i){var s=Ti.indexOf(e),n=e.children;function o(t){t.passThrough=!0}s>-1&&Ti.splice(s,1);for(var r=0;r<n.length;r++)o(n[r]);var c=Ja(a,$a(Na,t));c.targets=c.targets||t.targets;var d=e.duration;c.autoplay=!1,c.direction=e.direction,c.timelineOffset=Fa.und(i)?d:di(i,d),o(e),e.seek(c.timelineOffset);var l=Ni(c);o(l),n.push(l);var h=Ai(n,t);return e.delay=h.delay,e.endDelay=h.endDelay,e.duration=h.duration,e.seek(0),e.reset(),e.autoplay&&e.play(),e},e},Ni.easing=ja,Ni.penner=Ga,Ni.random=function(t,e){return Math.floor(Math.random()*(e-t+1))+t};var Oi=Ni,Li={duration:1e3,loop:!1,easing:"easeInOutSine"};function _i(t,e){const a={};if(e.complete&&t.complete){const i=e.complete,s=t.complete;a.complete=t=>{i(t),s(t)}}return{...t,...e,...a}}function Fi(t,e,a={}){const{left:i,top:s}=t.getBoundingClientRect(),{left:n,top:o}=e.getBoundingClientRect(),r=n-i,c=o-s;return new Promise((e=>{const i=_i({targets:t,translateX:r,translateY:c,...Li,complete:()=>{e(!0)}},a);Oi(i)}))}var Vi=t("AnimeUtil",class{async movePoint(t,e,a={}){const i=xa(e);if(!i)return ibiz.log.debug("终点元素不存在"),!1;const s=Pa(t,document.body);if(!s)return ibiz.log.debug("动画元素不存在"),!1;const{padding:n,width:o,height:r}=Ta(s),c={borderRadius:["0%","50%"],maxWidth:[o,"6px"],maxHeight:[r,"6px"],minWidth:[o,"6px"],minHeight:[r,"6px"],padding:[n,"6px"],duration:700};Object.assign(c,a);const d=await Fi(s,i,c);var l;return(l=s)&&l.remove(),d}moveToTarget(t,e,a={}){return Fi(t,e,a)}resize(t,e={}){return function(t,e={}){return new Promise((a=>{const i=_i({scale:[1,.8,1],targets:t,...Li,complete:()=>{a(!0)}},e);Oi(i)}))}(t,e)}async moveAndResize(t,e,a={}){const i=await this.movePoint(t,e,a);return i&&await this.resize(e,{duration:500}),i}}),ki=t("FileUtil",class{calcOSSCatUrl(t,e,a){var i;let s="".concat(ibiz.env.baseUrl,"/").concat(ibiz.env.appId).concat(t);const n=ibiz.hub.getApp(e.srfappid),o=a||n.model.defaultOSSCat||(null==(i=n.model.userParam)?void 0:i.DefaultOSSCat);return s=s.replace("/{cat}",o?"/".concat(o):""),s}calcFileUpDownUrl(t,e,a={},i={}){const{uploadParams:s,exportParams:n,osscat:o}=i;let r=this.calcOSSCatUrl(ibiz.env.uploadFileUrl,t,o),c=this.calcOSSCatUrl("".concat(ibiz.env.downloadFileUrl,"/%fileId%"),t,o),d={},l={};return s&&(d=oe(s,a,e,t)),n&&(l=oe(n,a,e,t)),r+=Et.stringify(d,{addQueryPrefix:!0}),c+=Et.stringify(l,{addQueryPrefix:!0}),{uploadUrl:r,downloadUrl:c}}async fileDownload(t,e){const a=await ibiz.net.request(t,{method:"get",responseType:"blob",baseURL:""});if(200!==a.status)throw new o("下载文件失败");if(!a.data)throw new o("文件流数据不存在");{const t=e;c(a.data,t)}}async fileUpload(t,e,a){const i=new FormData;i.append("file",e);const s=await ibiz.net.axios({url:t,method:"post",headers:a,data:i});if(200!==s.status)throw new o("文件上传失败");return s.data}}),zi=class{constructor(){this.psModelGroupCondBase=null}parse(t){if(t instanceof Array){const e=this.createPSModelGroupCond();e.parse(t),this.psModelGroupCondBase=e}}testSingleCond(t,e,a){try{if("ISNULL"===t)return null==e;if("ISNOTNULL"===t)return null!=e;if("EQ"===t||"ABSEQ"===t||"GT"===t||"GTANDEQ"===t||"LT"===t||"LTANDEQ"===t||"NOTEQ"===t){if(null==e||null==a)return!1;let i=-1;if(e==a?i=0:e>a&&(i=1),"EQ"===t||"ABSEQ"===t)return 0===i;if("GT"===t)return i>0;if("GTANDEQ"===t)return i>=0;if("LT"===t)return i<0;if("LTANDEQ"===t)return i<=0;if("NOTEQ"===t)return 0!==i}if("LIKE"===t)return null!=e&&null!=a&&-1!==e.toString().toUpperCase().indexOf(a.toString().toUpperCase());if("LEFTLIKE"===t)return null!=e&&null!=a&&0===e.toString().toUpperCase().indexOf(a.toString().toUpperCase())}catch(t){ibiz.log.error(t)}return!1}getPSModelGroupCondBase(){return this.psModelGroupCondBase}},Wi=class{constructor(){this.strCondOp=null}getCondOp(){return this.strCondOp}setCondOp(t){this.strCondOp=t}},Ui=class extends Wi{parse(t){const e=t.length;let a=!0,i=!1,s=!1;for(let n=0;n<e;n++)if(a){const e=t[n];this.setCondOp(e),a=!1,i=!0}else if(i){const e=t[n];this.setParam(e),i=!1,s=!0}else if(s){const e=t[n];if(e instanceof Object&&!(e instanceof Array)){const t=e;null!=t.type&&this.setValueType(t.type.toString()),null!=t.value&&this.setValue(t.value.toString())}else this.setValue(e);break}}getValueType(){return this.strValueType}setValueType(t){this.strValueType=t}getValue(){return this.strValue}setValue(t){this.strValue=t}getParamType(){return this.strParamType}setParamType(t){this.strParamType=t}getParam(){return this.strParam}setParam(t){this.strParam=t}},Bi=class t extends Wi{constructor(){super(...arguments),this.childCondList=[],this.bNotMode=!1}parse(e){const a=e.length;let i=!0,s=!0,n=!1;for(let r=0;r<a;r++){if(i&&s){if("!"===e[r]){this.setNotMode(!0),i=!1;continue}}if(s){const t=e[r];this.setCondOp(t),s=!1,i=!1,n=!0}else if(n){const a=e[r];if(!(a instanceof Array))throw new o("值必须为数组");a.forEach((e=>{if(e.length>0){const a=e[0].toString();if("!"===a||"OR"===a||"AND"===a){const a=new t;a.parse(e),this.childCondList.push(a)}else{const t=new Ui;t.parse(e),this.childCondList.push(t)}}}))}}}setNotMode(t){this.bNotMode=t}isNotMode(){return this.bNotMode}getChildPSModelCondBases(){return this.childCondList}},Gi=class extends Bi{},ji=class extends Ui{},Ki=class t extends zi{test(t,e){return this.testCond(this.getPSModelGroupCondBase(),t,e)}testCond(e,a,i){if(e instanceof Bi){const t=e.getChildPSModelCondBases();if(null==t||J(t))return!e.isNotMode();const s="AND"===e.getCondOp();let n=s;for(let e=0;e<t.length;e++){const o=t[e];if(this.testCond(o,a,i)){if(!s){n=!0;break}}else if(s){n=!1;break}}return e.isNotMode()?!n:n}if(e instanceof Ui){J(e.getParam())&&ibiz.log.warn("没有指定属性名称",e);const s=a[e.getParam().toLowerCase()];let n=null;const o=e.getValueType(),r=e.getValue();return null==o||J(o)?n=e.getValue():(J(r)&&ibiz.log.warn("没有指定上下文参数名称"),t.PARAMTYPE_WEBCONTEXT===o?n=i.data[r.toLowerCase()]:t.PARAMTYPE_DATACONTEXT===o&&(n=i.getValue(r.toLowerCase()))),this.testSingleCond(e.getCondOp(),s,n)}return ibiz.log.warn("无法识别的条件对象",e),!1}createPSModelSingleCond(){return new ji}createPSModelGroupCond(){return new Gi}};Ki.PARAMTYPE_DATACONTEXT="DATACONTEXT",Ki.PARAMTYPE_WEBCONTEXT="WEBCONTEXT";var Xi=t("PSDEDQCondEngine",Ki);async function Hi(t,e){var a;const i=null==(a=ibiz.hub.getApp(e).model.appPFPluginRefs)?void 0:a.find((e=>e.pluginCode.toLowerCase()===t));if(i)return await ibiz.plugin.loadPlugin(i),"".concat(i.pluginType,"_").concat(i.pluginCode);ibiz.log.error("未匹配到插件[".concat(t,"]模型"))}var qi=t("APP_COUNTER_PROVIDER_PREFIX","APPCOUNTER");function Yi(t,e){ibiz.register.register("".concat(qi,"_").concat(t),e)}function Qi(t){return ibiz.register.get("".concat(qi,"_").concat(t))}async function $i(t){let e;const{codeName:a,counterType:i,sysPFPluginId:s,appId:n}=t;if(s){const t=await Hi(s,n);if(t&&(e=Qi(t)),e)return e;ibiz.log.error("找不到系统计数器插件".concat(t,"对应的适配器"))}if("CUSTOM"===i){if(e=Qi(a),e)return e;throw new o("找不到自定义系统计数器".concat(a,"对应的适配器"))}if(e=Qi(i),e)return e;throw new o("找不系统计数器类型".concat(i,"对应的适配器"))}var Ji=class{static getRegisterKey(t,e){switch(t){case hs:return this.calcKeyByView(e);case ns:case cs:case Zi:return this.calcKeyByCtrl(e);default:return""}}static calcKeyByView(t){const{controlItemModel:e,controlModel:a,viewModel:i}=t;let s="";return(null==i?void 0:i.codeName)&&(s+="".concat(i.codeName.toUpperCase())),(null==a?void 0:a.codeName)&&(s+="@".concat(a.codeName.toUpperCase())),(null==e?void 0:e.id)&&(s+="@".concat(e.id.toUpperCase())),s}static calcKeyByCtrl(t){const{controlModel:e,controlItemModel:a}=t;let i="",s="APP";if(e){const{appDataEntityId:t,controlType:a,codeName:n}=e;t&&(s=ve(t).toUpperCase()),a&&(i+="@".concat(a.toUpperCase())),n&&(i+="@".concat(n.toUpperCase()))}return(null==a?void 0:a.codeName)&&(i+="@".concat(a.codeName.toUpperCase())),i=s+i,i}},Zi=t("CONTROL_PROVIDER_PREFIX","CONTROL");function ts(t){return ibiz.register.get("".concat(Zi,"_").concat(t))}async function es(t){let e;const{controlType:a,controlStyle:i,sysPFPluginId:s,appId:n}=t,o=Ji.getRegisterKey(Zi,{controlModel:t});if(e=ts(o),e)return e;if(ibiz.log.debug("找不到自定义注册标识为[".concat(o,"]对应的适配器")),s){const t=await Hi(s,n);if(t&&(e=ts(t)),e)return e;ibiz.log.error("找不到部件插件".concat(t,"对应的适配器"))}if(i&&"DEFAULT"!==i){if(e=ts("".concat(a,"_").concat(i)),e)return e;ibiz.log.error("找不到部件类型:[".concat(a,"]的部件样式:[").concat(i,"]对应的适配器"),t)}if(e=ts(a),e)return e;"DATAINFOBAR"!==a&&ibiz.log.error("找不到部件类型".concat(a,"对应的适配器"))}var as=t("EDITOR_PROVIDER_PREFIX","EDITOR");function is(t){return ibiz.register.get("".concat(as,"_").concat(t))}async function ss(t){let e;const{editorType:a,editorStyle:i,predefinedType:s,sysPFPluginId:n,appId:o}=t;if(n){const t=await Hi(n,o);if(t&&(e=is(t)),e)return e;ibiz.log.error("找不到编辑器插件".concat(t,"对应的适配器"))}if(i&&"DEFAULT"!==i){if(e=is("".concat(a,"_").concat(i)),e)return e;ibiz.log.error("找不到编辑器类型:[".concat(a,"]的编辑器样式:[").concat(i,"]对应的适配器"),t)}if(s){let n="".concat(s,"_").concat(a);if(i&&"DEFAULT"!==i&&(n+="_".concat(i)),e=is(n),e)return e;ibiz.log.error("找不到编辑器类型:[".concat(a,"]的预置类型:[").concat(s,"]对应的适配器"),t)}if(e=is(a),e)return e;ibiz.log.error("找不到编辑器类型".concat(a,"对应的适配器"))}var ns=t("FORMDETAIL_PROVIDER_PREFIX","FORMDETAIL");function os(t){return ibiz.register.get("".concat(ns,"_").concat(t))}async function rs(t,e){let a;const{detailType:i,sysPFPluginId:s,appId:n}=t,o=Ji.getRegisterKey(ns,{controlItemModel:t,controlModel:e});if(a=os(o),a)return a;if(ibiz.log.debug("找不到自定义注册标识为[".concat(o,"]对应的适配器")),s){const t=await Hi(s,n);if(t&&(a=os(t)),a)return a;ibiz.log.error("找不到表单成员插件".concat(t,"对应的适配器"))}if(a=os(i),a)return a;ibiz.log.error("找不到表单成员类型".concat(i,"对应的适配器"))}var cs=t("GRIDCOLUMN_PROVIDER_PREFIX","GRIDCOLUMN");function ds(t){return ibiz.register.get("".concat(cs,"_").concat(t))}async function ls(t,e){let a;const{columnType:i,enableRowEdit:s,sysPFPluginId:n,appId:o}=t,r=Ji.getRegisterKey(cs,{controlItemModel:t,controlModel:e});if(a=ds(r),a)return a;if(ibiz.log.debug("找不到自定义注册标识为[".concat(r,"]对应的适配器")),n){const t=await Hi(n,o);if(t&&(a=ds(t)),a)return a;ibiz.log.error("找不到表格列插件".concat(t,"对应的适配器"))}const c=s?"".concat(i,"_EDIT"):i;if(a=ds(c),a)return a;ibiz.log.error("找不到表格列类型".concat(c,"对应的适配器"))}var hs=t("PANELITEM_PROVIDER_PREFIX","PANELITEM");function us(t){return ibiz.register.get("".concat(hs,"_").concat(t.toUpperCase()))}async function ps(t,e,a){var i;let s;const{itemType:n,sysPFPluginId:o,appId:r,controlRenders:c}=t,d=Ji.getRegisterKey(hs,{controlItemModel:t,controlModel:e,viewModel:a});if(s=us(d),s)return s;if(ibiz.log.debug("找不到自定义注册标识为[".concat(d,"]对应的适配器")),o){const t=await Hi(o,r);if(t&&(s=us(t)),s)return s;ibiz.log.error("找不到面板成员插件".concat(t,"对应的适配器"))}if(c&&c.length>0)s=us("PREDEFINE_RENDER");else{if("CONTAINER"===n){const e=t.predefinedType||"DEFAULT",a="CONTAINER_".concat(e);if(s=us(a),s)return s;ibiz.log.error("找不到面板容器预置类型为".concat(e,"的适配器,注册key为").concat(a))}if("RAWITEM"===n){const e=(null==(i=t.rawItem)?void 0:i.predefinedType)||"DEFAULT",a="RAWITEM_".concat(e);if(s=us(a),s)return s;ibiz.log.error("找不到面板成员直接内容预置类型为".concat(e,"的适配器,注册key为").concat(a))}if("FIELD"===n){const{editor:e}=t;if(e&&e.predefinedType){if(s=us("FIELD_".concat(e.predefinedType.toUpperCase())),s)return s}}s=us(n)}if(s)return s;ibiz.log.error("找不到面板成员类型".concat(n,"对应的适配器"))}var ms=t("PORTLET_PROVIDER_PREFIX","PORTLET");function fs(t){return ibiz.register.get("".concat(ms,"_").concat(t))}async function gs(t){let e;const{portletType:a,sysPFPluginId:i,appId:s}=t;if(i){const t=await Hi(i,s);if(t&&(e=fs(t)),e)return e;ibiz.log.error("找不到门户部件插件".concat(t,"对应的适配器"))}if(e=fs(a),e)return e;ibiz.log.error("找不到门户部件成员类型".concat(a,"对应的适配器"))}var ws=t("UIACTION_PROVIDER_PREFIX","UIACTION");function Es(t,e){ibiz.register.register("".concat(ws,"_").concat(t),e)}function ys(t){return ibiz.register.get("".concat(ws,"_").concat(t))}async function vs(t){let e;const{uiactionMode:a,sysPFPluginId:i,appId:s,uiactionTag:n}=t;if(i){const t=await Hi(i,s);if(t&&(e=ys(t)),e)return e;ibiz.log.error("找不到界面行为插件".concat(t,"对应的适配器"))}if(e=ys("".concat(a,"_").concat(n)),e)return e;if(e=ys(a),e)return e;throw new o("找不界面行为模式".concat(a,"对应的适配器"))}var Is=t("UILOGINNODE_PROVIDER_PREFIX","UI_LOGIN_NODE");async function Ds(t){let e;const{sysPFPluginId:a,appId:i}=t,s=await Hi(a,i);if(s){if(e=ibiz.register.get("".concat(Is,"_").concat(s)),e)return e;throw new o("找不到界面逻辑前端插件节点,插件".concat(s,"对应的适配器"))}}var Cs=t("VIEW_PROVIDER_PREFIX","VIEW");function bs(t){return ibiz.register.get("".concat(Cs,"_").concat(t))}var As=t("ASYNC_ACTION_PROVIDER_PREFIX","ASYNC_ACTION");var Ps=t("PlatformProviderBase",class{back(){throw new Error("Method not implemented.")}init(){throw new Error("Method not implemented.")}async login(t,e,a){return ibiz.auth.login(t,e)}async download(t,e){const a=await ibiz.net.request(t,{method:"get",responseType:"blob",baseURL:""});if(200!==a.status)throw new o("下载文件失败");if(a.data){const t=e;return c(a.data,t),Promise.resolve(!0)}throw new o("文件流数据不存在")}}),Ts=t("BrowserPlatformProvider",class extends Ps{});var xs=window.navigator.userAgent.toLowerCase();function Ss(){return/Android|Adr/i.test(xs)?"Android":/iPhone|iPod|iPad/i.test(xs)?"IOS":/MicroMessenger/i.test(xs)?"WeChat":/DingTalk/i.test(xs)?"DingTalk":/miniProgram/i.test(xs)||"miniprogram"===window.__wxjs_environment?"WeChatMiniProgram":"Browser"}var Ns=t("PLATFORM_PROVIDER_PREFIX","PLATFORM");function Rs(t,e){ibiz.register.register("".concat(Ns,"_").concat(t),e)}function Ms(t){return ibiz.register.get("".concat(Ns,"_").concat(t))}function Os(){const t=Ms(Ss());return t||Ms("Browser")}var Ls=t("DEMETHOD_PROVIDER_PREFIX","DEMETHOD");function _s(t,e){ibiz.register.register("".concat(Ls,"_").concat(t),e)}function Fs(t){return ibiz.register.get("".concat(Ls,"_").concat(t))}async function Vs(t){let e;const{methodType:a,sysPFPluginId:i,appId:s}=t;if(i){const t=await Hi(i,s);if(t&&(e=Fs(t)),e)return e;ibiz.log.error("找不到实体行为插件".concat(t,"对应的适配器"))}if(e=Fs(a),e)return e;throw new o("找不实体行为方法类型为".concat(a,"的适配器"))}var ks=t("TREEGRIDEX_COLUMN_PROVIDER_PREFIX","TREEGRIDEX_COLUMN");function zs(t){return ibiz.register.get("".concat(ks,"_").concat(t))}async function Ws(t){let e;const{columnType:a,appId:i,renderSysPFPluginId:s}=t;if(s){const t=await Hi(s,i);if(t&&(e=zs(t)),e)return e;ibiz.log.error("找不到树表格列插件".concat(t,"对应的适配器"))}if(e=zs(a),e)return e;ibiz.log.error("找不到表格列类型".concat(a,"对应的适配器"))}var Us=t("APPMENUITEM_PROVIDER_PREFIX","APPMENUITEM");function Bs(t){return ibiz.register.get("".concat(Us,"_").concat(t))}async function Gs(t){let e;const{sysPFPluginId:a,appId:i,itemType:s}=t;if(a){const t=await Hi(a,i);if(t&&(e=Bs(t)),e)return e;ibiz.log.error("找不到应用菜单项插件".concat(t,"对应的适配器"))}return e=Bs(s),e}var js=t("INTERNAL_MESSAGE_PROVIDER_PREFIX","INTERNAL_MESSAGE");var Ks=t("ERROR_VIEW_PROVIDER_PREFIX","ERROR_VIEW");var Xs=t("AppCounter",class{constructor(t){this.model=t,this.destroyed=!1,this.context=d.create(),this.params={},this.evt=new dt,this.data={},this.countChange=this.countChange.bind(this)}get isDestroyed(){return this.destroyed}async init(t,e){this.setParams(t,e),this.interval(),await this.load(),this.model.appDataEntityId&&ibiz.mc.command.change.on(this.countChange)}countChange(t){const e=t.data;if(this.model.appDataEntityId){const t=ve(this.model.appDataEntityId);e&&e.srfdecodename&&e.srfdecodename.toLowerCase()===t&&this.refresh()}}setParams(t,e){t&&(this.context=Z(t)),e&&(this.params=Z(e))}interval(){this.destroyInterval(),this.intervalTimer=setInterval((()=>{this.evt.getSize("change")>0&&this.load()}),this.model.timer||6e3)}destroyInterval(){this.intervalTimer&&(clearInterval(this.intervalTimer),this.intervalTimer=null)}async load(){throw new o("未实现计数器加载方法")}refresh(t,e){return this.setParams(t,e),this.load()}onChange(t,e=!0){this.evt.on("change",t),e&&nt(this.data)&&t(this.data)}offChange(t){this.evt.off("change",t)}getCounter(t){return this.data[t.toLowerCase()]||0}destroy(){this.destroyed=!0,this.context.destroy(),this.destroyInterval(),this.evt.reset(),ibiz.mc.command.change.off(this.countChange)}}),Hs=t("AppDECounter",class extends Xs{async init(t,e){this.appDataEntityId=this.model.appDataEntityId;const i=this.model.getAppDEActionId;if(!i)throw new a(this.model,"未找到获取计数器行为!");this.action=i,await super.init(t,e)}async load(){const t=ibiz.hub.getApp(this.context.srfappid),e=await t.deService.exec(this.appDataEntityId,this.action,this.context,this.params);return e.ok&&(this.data=e.data,this.evt.emit("change",this.data)),this.data}}),qs=t("AppDECounterProvider",class{createCounter(t){return new Hs(t)}});function Ys(){Yi("DEDR",(()=>new qs))}var Qs=t("DEDQCondUtil",class{static getCond(t){if(this.map.has(t))return this.map.get(t);const e=t.dedqgroupConditions;if(e){const a=new Xi;return 1===e.length?a.parse(this.calcCond(e)[0]):e.length>1&&a.parse(["AND",this.calcCond(e)][0]),this.map.set(t,a),a}return null}static calcCond(t){const e=[];return t.forEach((t=>{const a=[];if("GROUP"===t.condType){const e=t;e.notMode&&a.push("!"),a.push(t.condOp);const i=e.dedqconditions;if(i){const t=this.calcCond(i);a.push(t)}}else{if("SINGLE"!==t.condType)throw new i(t,"暂未支持的查询条件类型: ".concat(t.condType));{const e=t;a.push(e.condOp),a.push(e.fieldName),e.condValue?e.vartypeId?a.push({type:e.vartypeId,value:e.condValue}):a.push(e.condValue):a.push("")}}e.push(a)})),e}});Qs.map=new WeakMap;var $s=t("DynamicCodeListCache",class{constructor(t){this.cache=new Map,this.isPredefined=!1,this.context=d.create(),this.params={},this.evt=new dt,this.commonKeys=["query","queryconds"],this.codeList=t,this.codelistChange=this.codelistChange.bind(this);const{appDataEntityId:e,appDEDataSetId:a}=this.codeList;e&&a&&ibiz.mc.command.change.on(this.codelistChange)}setParams(t,e){t&&(this.context=Z(t)),e&&(this.params=Z(e))}async init(){return this.initPromise=(async()=>{const{predefinedType:t}=this.codeList;if(t){if(this.isPredefined=!0,!["OPERATOR","RUNTIME","DEMAINSTATE"].includes(t))throw new i(this.codeList,"预定义类型".concat(t,"暂不支持"))}else this.initPromise=void 0})(),this.initPromise}convertData(t){const e={},{valueAppDEFieldId:a,textAppDEFieldId:i,iconClsAppDEFieldId:s,iconClsXAppDEFieldId:n,iconPathAppDEFieldId:o,iconPathXAppDEFieldId:r,disableAppDEFieldId:c,dataAppDEFieldId:d,clsAppDEFieldId:l,colorAppDEFieldId:h}=this.codeList,u=a?t[a]:t.srfkey;if(e.id=u,e.value=u,e.text=i?t[i]:t.srfmajortext,(s||n||o||r)&&(e.sysImage={appId:this.codeList.appId},s&&(e.sysImage.cssClass=t[s]),n&&(e.sysImage.cssClassX=t[n]),o&&(e.sysImage.imagePath=t[o]),r&&(e.sysImage.imagePathX=t[r])),c&&(e.disableSelect=on(t[c])),l&&(e.textCls=t[l]),h&&(e.color=t[h]),d&&t[d])try{e.data=Qe.execSingleLine(t[d])}catch(t){ibiz.log.error("动态代码表数据属性返回值不为对象格式的字符串,无法转换!")}return e}presetconvertData(t){const e={},{color:a,bkcolor:i,disabled:s,id:n,text:o,value:r,cls:c}=t;return e.value=r,e.color=a,e.bkcolor=i,e.text=o,e.id=n,e.disableSelect=s,e.cls=c,e.data=t,e}sortShoworder(t){return t.forEach((t=>{"showorder"in t||Object.assign(t,{showorder:1e3})})),t.sort(((t,e)=>t.showorder-e.showorder))}async load(t,e={}){const i={...e};this.commonKeys.forEach((t=>{delete i[t]})),this.setParams(t,i);const s=ibiz.hub.getApp(t.srfappid),{appDataEntityId:n,appDEDataSetId:o,minorSortAppDEFieldId:r,minorSortDir:c,pvalueAppDEFieldId:d,customCond:l}=this.codeList;if(r&&c&&Object.assign(i,{sort:"".concat(r.toLowerCase(),",").concat(c.toLowerCase())}),l){const e=oe(Qe.execSingleLine(l),i,t);Object.assign(i,e)}if(i.size||(i.size=1e4),this.isPredefined&&this.codeList.codeName){let t=this.codeList.codeName;if("OPERATOR"===this.codeList.predefinedType){const e=this.codeList.codeName.indexOf("__");t=-1!==e?this.codeList.codeName.substring(e+2):this.codeList.codeName}const e=await s.net.get("/dictionaries/codelist/".concat(t),i),a=[],{items:n}=e.data;return this.sortShoworder(n).length&&n.forEach((t=>{a.push(this.presetconvertData(t))})),Object.freeze(a)}if(!n)throw new a(this.codeList,"未配置应用实体");if(!o)throw new a(this.codeList,"未配置数据集");const h=await s.deService.exec(n,o,t,void 0,i);let u=[];if(h.data.length)if(d){const t=this.prepareTreeData(h.data);t&&(u=t)}else h.data.forEach((t=>{u.push(this.convertData(t))}));return Object.freeze(u)}prepareTreeData(t){const{valueAppDEFieldId:e,pvalueAppDEFieldId:a}=this.codeList,i={},s=[];return t.forEach((t=>{i[t[e]]=this.convertData(t)})),t.forEach((t=>{const n=i[t[a]];n?(n.children=n.children||[],n.children.push(i[t[e]])):s.push(i[t[e]])})),s}async get(t,e={}){if(this.initPromise&&await this.initPromise,!this.codeList.enableCache)return this.load(t,e);const a=JSON.stringify(t)+JSON.stringify(e);if(this.cache.has(a)){const t=this.cache.get(a);if(t.expirationTime>(new Date).getTime())return t.promise?t.promise:t.items;this.cache.delete(a)}const i=this.load(t,e),{cacheTimeout:s}=this.codeList,n=-1===s||Q(s)?ibiz.config.codeList.timeout:this.codeList.cacheTimeout,o={expirationTime:(new Date).getTime()+n,promise:i};this.cache.set(a,o);const r=await i;return o.items=r,delete o.promise,r}codelistChange(t){const e=t.data,{appDataEntityId:a}=this.codeList;if(a){const t=ve(a);e&&e.srfdecodename&&e.srfdecodename.toLowerCase()===t&&this.refresh()}}async refresh(){const t=JSON.stringify(this.context)+JSON.stringify(this.params);this.cache.delete(t);const e=await this.get(this.context,this.params);this.evt.emit("change",e)}onChange(t,e=!0){this.evt.on("change",t);const a=JSON.stringify(this.context)+JSON.stringify(this.params),i=this.cache.get(a);e&&nt(i)&&t(i.items)}offChange(t){this.evt.off("change",t)}destroy(){const{appDataEntityId:t,appDEDataSetId:e}=this.codeList;t&&e&&ibiz.mc.command.change.off(this.codelistChange)}});function Js(t,e){if(null!=e){const{srfkey:t}=e;if(!Q(t)&&!J(t))return!0}throw new o("执行「".concat(t,"」不存在「srfkey」无法处理"))}function Zs(t,e){const{srfsessionid:a}=e;if(!Q(a)&&!J(a))return!0;throw new o("执行「".concat(t,"」不存在「srfsessionid」无法处理"))}var tn=t("DECache",class{constructor(t){this.entity=t,this.cacheMap=new Map}get isUnionKey(){var t;return!!(null==(t=this.entity.unionKeyValueAppDEFieldIds)?void 0:t.length)}forceAdd(t,e){const a=this.cacheMap.get(e.srfkey);a&&(a.assign(e),ibiz.log.warn("forceAdd",e.srfkey,e))}forceUpdate(t,e){this.cacheMap.set(e.srfkey,Z(e)),ibiz.log.warn("forceUpdate",e.srfkey,e)}forceDelete(t,e){this.cacheMap.delete(e),ibiz.log.warn("forceDelete",e)}add(t,e){if(this.isUnionKey&&(this.calcUnionKey(e),this.checkData(t,e.srfkey)))throw new o("新建联合主键数据失败,已有主键为".concat(e.srfkey,"的数据"));try{Zs("add",t),(Q(e.srfkey)||J(e.srfkey))&&(e.srfkey=ct()),e.srftempdate=(new Date).getTime();const a=()=>{this.cacheMap.set(e.srfkey,Z(e)),ibiz.log.warn("add",e.srfkey,e)},i=this.getTransaction(t);return i?i.change(e.srfkey,(()=>{a()})):a(),e}catch(t){return ibiz.log.error(t),null}}get(t,e){try{Zs("get",t);const a=this.cacheMap.get(e);return ibiz.log.warn("get",e,a),Z(a)}catch(t){return ibiz.log.error(t),null}}update(t,e){const a=e.srfkey;if(this.isUnionKey&&(this.calcUnionKey(e),a!==e.srfkey&&this.checkData(t,e.srfkey)))throw new o("更新联合主键数据失败,已有主键为".concat(e.srfkey,"的数据"));try{Zs("update",t),Js("update",e),e.srftempdate=(new Date).getTime();const i=this.cacheMap.get(a);if(i){const s=Z(i);s.assign(e);const n=()=>{i.assign(e),a!==e.srfkey&&this.cacheMap.delete(a),this.cacheMap.set(e.srfkey,i),ibiz.log.warn("update",e.srfkey,e)},o=this.getTransaction(t);return o?o.change(e.srfkey,(()=>{n()})):n(),s}throw new Error("数据不存在,无法更新!")}catch(t){return ibiz.log.error(t),null}}delete(t,e){try{Zs("delete",t);const a=e;if(this.cacheMap.has(a)){const e=this.cacheMap.get(a),i=()=>{this.cacheMap.delete(a),ibiz.log.warn("delete",a)},s=this.getTransaction(t);return s?s.change(a,(()=>{i()})):i(),e}return null}catch(t){return ibiz.log.error(t),null}}createBatch(t,e){try{Zs("add",t);const a=t=>{this.cacheMap.set(t.srfkey,t),ibiz.log.warn("add",t.srfkey,t)},i=this.getTransaction(t);for(let t=0;t<e.length;t++){const s=e[t];(Q(s.srfkey)||J(s.srfkey))&&(s.srfkey=ct()),s.srftempdate=(new Date).getTime();const n=Z(s);i?i.change(n.srfkey,(()=>{a(n)})):a(n)}return e}catch(t){ibiz.log.error(t)}return[]}updateBatch(t,e){try{Zs("update",t);const a=(t,e)=>{e!==t.srfkey&&this.cacheMap.delete(e),this.cacheMap.set(t.srfkey,t),ibiz.log.warn("update",t.srfkey,t)},i=this.getTransaction(t);for(let s=0;s<e.length;s++){const n=e[s];Js("update",n);const r=n.srfkey;if(this.isUnionKey&&(this.calcUnionKey(n),r!==n.srfkey&&this.checkData(t,n.srfkey)))throw new o("更新联合主键数据失败,已有主键为".concat(n.srfkey,"的数据"));n.srftempdate=(new Date).getTime();const c=this.cacheMap.get(n.srfkey);if(!c)throw new Error("数据[".concat(n.srfdename,"-").concat(n.srfmajortext,"(").concat(n.srfkey,")]不存在,无法更新!"));{const t=Z(c);t.assign(n),e[s]=t,i?i.change(n.srfkey,(()=>{c.assign(n),a(c,r)})):(c.assign(n),a(c,r))}}return e}catch(t){return ibiz.log.error(t),null}}deleteBatch(t,e){try{Zs("delete",t)}catch(t){return ibiz.log.error(t),e}const a=[];for(let t=0;t<e.length;t++){const i=e[t];this.cacheMap.has(i)||a.push(i)}if(a.length>0)throw new Error("未找到以下数据「".concat(a.join("、"),"」,无法删除!"));const i=t=>{this.cacheMap.delete(t),ibiz.log.warn("delete",t)},s=this.getTransaction(t);for(let t=0;t<e.length;t++){const a=e[t];s?s.change(a,(()=>{i(a)})):i(a)}return[]}checkData(t,e){return!!this.cacheMap.get(e)}getList(){const t=this.cacheMap.values();return Array.from(t)}generatePred(t={}){const e={};t.srfkey&&(e.srfkey=tt(t.srfkey)),delete t.srfkey;for(const a in t)if(Object.prototype.hasOwnProperty.call(t,a)){const i=t[a];e[a]=tt(i)}return et(e)}clear(){this.cacheMap.clear()}calcUnionKey(t){const e=this.entity.unionKeyValueAppDEFieldIds.map((t=>he(this.entity.appDEFields||[],t).codeName.toLowerCase())).map((e=>Q(t[e])?"__empty__":t[e]));t.srfkey=e.join("||")}getTransaction(t){const e=ibiz.uiDomainManager.get(t.srfsessionid);return e&&!0===e.transaction.state.isOpen?e.transaction:null}}),en=/\$\{(.*?)\}/g;function an(t,e){const a=(e.requestPaths||[]).map((t=>{const e=t.match(en);return{path:t,keys:(null==e?void 0:e.map((t=>t.substring(2,t.length-1))))||[]}})).filter((e=>{const{keys:a}=e;return 0===a.length||a.every(((e,i)=>i===a.length-1||null!=t[e]))})).sort(((t,e)=>e.keys.length-t.keys.length));if(a.length>0)return a[0]}function sn(t,e){const a=an(t,e);if(a){if(a.keys.length>0){let{path:e}=a;return a.keys.forEach(((i,s)=>{e=s===a.keys.length-1?e.replace(new RegExp("/[^/]+/\\$\\{".concat(i,"\\}")),""):e.replace("${".concat(i,"}"),t[i])})),e}return a.path}return""}var nn=t("SearchFilter",class{constructor(t,e){if(this.page=0,this.size=1e3,this.data={},this.sortField="srfordervalue",this.sortMode="ASC",this.context=t,e){if(Q(e.page)||J(e.page)||(this.page=e.page),Q(e.size)||J(e.size)||(this.size=e.size),Q(e.query)||J(e.query)||(this.query=e.query),!Q(e.sort)&&!J(e.sort)){const t=e.sort.split(",");t.length>=1&&([this.sortField]=t),t.length>=2&&(this.sortMode=t[1].toUpperCase())}this.data={...e},delete this.data.page,delete this.data.size,delete this.data.query,delete this.data.sort}}getValue(t){return this.data[t]?this.data[t]:this.context[t]}});function on(t){if("boolean"==typeof t)return t;if("number"==typeof t)return t>0;if("string"!=typeof t)return!!t;switch(t){case"true":return!0;case"false":return!1;default:{const e=Number(t);return!Number.isNaN(e)&&e>0}}}function rn(t){const e={};if(!t)return e;const a=t.split(",");return a&&a.length>0&&a.forEach((t=>{const[a,i]=t.split(":");e[a]=parseInt(i,10)})),e}var cn=t("CodeListService",class{constructor(t){this.appModel=t,this.allCodeLists=new Map,this.cache=new Map}getStatic(t){const e=t.codeName;if(this.cache.has(e))return this.cache.get(e);const a=t.codeItems;let i=[];return(null==a?void 0:a.length)&&(i=this.formatStaticItems(a,t.codeItemValueNumber)),this.cache.set(e,Object.freeze(i)),i}setCodeList(t){const{id:e,codeName:a}=t;this.allCodeLists.set(e,t),this.allCodeLists.set(a,t)}getCodeList(t){return this.allCodeLists.get(t)}formatStaticItems(t,e){return t.map((t=>{var a;let i=t.text;t.textLanguageRes&&(i=ibiz.i18n.t(t.textLanguageRes.lanResTag,t.text));let{tooltip:s}=t;t.tooltipLanguageRes&&(s=ibiz.i18n.t(t.tooltipLanguageRes.lanResTag,t.tooltip));const n={text:i,value:e?Number(t.value):t.value,color:t.color,id:t.codeName,textCls:t.textCls,disableSelect:t.disableSelect,tooltip:s,data:t.data?Qe.execSingleLine(t.data):void 0,sysImage:t.sysImage,userData:t.userData};return(null==(a=t.codeItems)?void 0:a.length)&&(n.children=this.formatStaticItems(t.codeItems,e)),Object.freeze(n)}))}async getDynamicCodeList(t,e,a={}){let i;const s=t.codeName;return this.cache.has(s)?i=this.cache.get(s):(i=new $s(t),this.cache.set(s,i),await i.init()),i.get(e,a)}async get(t,e,a){const i=this.allCodeLists.get(t);if(!i)throw new o("找不到".concat(t,"代码表"));return"STATIC"===i.codeListType?this.getStatic(i):"DYNAMIC"===i.codeListType?this.getDynamicCodeList(i,e,a):[]}async getCodeListInstance(t){let e;const a=this.allCodeLists.get(t);if(!a)throw new o("找不到".concat(t,"代码表"));if("DYNAMIC"===a.codeListType){const t=a.codeName;this.cache.has(t)?e=this.cache.get(t):(e=new $s(a),this.cache.set(t,e),await e.init())}return e}destroy(){Array.from(this.cache.values()).forEach((t=>{t instanceof $s&&t.destroy()}))}}),dn=t("ConfigService",class{constructor(t,e,a){this.appId=t,this.folder=e,this.tag=a,this.app=ibiz.hub.getApp(t)}async save(t){const e=await this.app.net.put("/configs/".concat(this.folder,"/").concat(this.tag),t);return!!e.ok&&e.data}async load(){const t=await this.app.net.get("/configs/".concat(this.folder,"/").concat(this.tag));return t.ok&&t.data||{}}}),ln=t("CounterService",class{static async getCounter(t,e,a){let i=t.id;if(a&&a.customId&&(i=a.customId),this.counterMap.has(i)){const t=this.counterMap.get(i);if(!1===t.isDestroyed)return t;this.counterMap.delete(i)}const s=(await $i(t)).createCounter(t);return await s.init(e,a),this.counterMap.set(i,s),s}static async getCounterByRef(t,e,i){const{appCounter:s}=t;if(!s)throw new a(t,"未配置应用计数器!");return this.getCounter(s,e,i)}});ln.counterMap=new Map;var hn=t("WorkFlowService",class{constructor(t){this.model=t,this.commonBaseUrl="",this.app=ibiz.hub.getApp(t.appId);const e=ibiz.appData.context;this.commonBaseUrl="/wfcore/".concat(e.srfsystemid,"-app-").concat(this.app.model.codeName.toLowerCase(),"/").concat(this.model.name.toLowerCase())}getBaseUrl(){return this.commonBaseUrl}getActiveData(t,e){return e.srfprocessinstanceid&&(t.srfprocessinstanceid=e.srfprocessinstanceid),t}getWFInstanceTag(t){return t.srfprocessinstanceid||"alls"}async getWFStep(t){const{processDefinitionKey:e,taskDefinitionKey:a}=t;return this.app.net.get("".concat(this.getBaseUrl(),"/process-definitions/").concat(e,"/usertasks/").concat(a))}async getWFLink(t,e){const a=t[this.model.codeName.toLowerCase()],{taskDefinitionKey:i}=t;return this.app.net.post("".concat(this.getBaseUrl(),"/").concat(a,"/usertasks/").concat(i,"/ways"),{activedata:this.getActiveData(e,t)})}async getWFHistory(t){const e=t[this.model.codeName.toLowerCase()];return this.app.net.get("".concat(this.getBaseUrl(),"/").concat(e,"/process-instances/").concat(this.getWFInstanceTag(t),"/history"))}async getWFProcessDiagram(t){const e=t[this.model.codeName.toLowerCase()];return this.app.net.request("".concat(this.getBaseUrl(),"/").concat(e,"/process-instances/").concat(this.getWFInstanceTag(t),"/processdiagram"),{method:"post",data:{},responseType:"blob"})}async getWFVersion(t){return this.app.net.get("/wfcore/".concat(ibiz.appData.context.srfsystemid,"-app-").concat(this.app.model.codeName.toLowerCase(),"/").concat(this.model.name.toLowerCase()).concat(t?"-".concat(t):"","/process-definitions2"))}async wfStart(t,e,a){return this.app.net.post("".concat(this.getBaseUrl(),"/").concat(t[this.model.codeName.toLowerCase()],"/process-instances"),{...e,activedata:this.getActiveData(a,t)})}async wfSubmit(t,e,a){return this.app.net.post("".concat(this.getBaseUrl(),"/").concat(t[this.model.codeName.toLowerCase()],"/tasks/").concat(e.taskId),{...e,activedata:this.getActiveData(a,t)})}async wfWithdraw(t,e,a){return this.app.net.post("".concat(this.getBaseUrl(),"/").concat(t[this.model.codeName.toLowerCase()],"/tasks/").concat(e.taskId,"/withdraw"),{...e,activedata:this.getActiveData(a,t)})}async wfReassign(t,e,a){return ibiz.net.post("".concat(this.getBaseUrl(),"/").concat(t[this.model.codeName.toLowerCase()],"/tasks/").concat(e.taskId,"/transfer"),{...e,activedata:this.getActiveData(a,t)})}async wfAddStepBefore(t,e,a){return ibiz.net.post("".concat(this.getBaseUrl(),"/").concat(t[this.model.codeName.toLowerCase()],"/tasks/").concat(e.taskId,"/beforesign"),{...e,activedata:this.getActiveData(a,t)})}async wfAddStepAfter(t,e,a){return ibiz.net.post("".concat(this.getBaseUrl(),"/").concat(t[this.model.codeName.toLowerCase()],"/tasks/").concat(e.taskId,"/aftersign"),{...e,activedata:this.getActiveData(a,t)})}async wfSendBack(t,e,a){return ibiz.net.post("".concat(this.getBaseUrl(),"/").concat(t[this.model.codeName.toLowerCase()],"/tasks/").concat(e.taskId,"/sendback"),{...e,activedata:this.getActiveData(a,t)})}async wfSendCopy(t,e,a){return ibiz.net.post("".concat(this.getBaseUrl(),"/").concat(t[this.model.codeName.toLowerCase()],"/tasks/").concat(e.taskId,"/sendcopy"),{...e,activedata:this.getActiveData(a,t)})}async exec(t,e,a={},i={}){switch(t){case"wfstart":return this.wfStart(e,a,i);case"wfsubmit":return this.wfSubmit(e,a,i);case"reassign":return this.wfReassign(e,a,i);case"addstepbefore":return this.wfAddStepBefore(e,a,i);case"addstepafter":return this.wfAddStepAfter(e,a,i);case"sendback":return this.wfSendBack(e,a,i);case"sendcopy":return this.wfSendCopy(e,a,i);default:throw new o("「".concat(t,"」未实现"))}}}),un=class{constructor(t){this.model=t}exportData(t,e,a,i){const s=sn(a,this.model),n="".concat(s,"/").concat(this.model.deapicodeName2,"/exportdata/").concat(e.toLowerCase(),"/?srfexporttag=").concat(t.codeName);return ibiz.net.request(n,{method:"post",data:i,responseType:"blob"})}},pn=t("Srfuf",(t=>(t[t.CREATE=0]="CREATE",t[t.UPDATE=1]="UPDATE",t))(pn||{})),mn=t("AppDataEntity",class t{get srfuf(){return this.srfkey===this.tempsrfkey?1:0}constructor(e,a={}){Object.defineProperty(this,"_entity",{enumerable:!1,configurable:!0,value:e}),Object.defineProperty(this,"_data",{enumerable:!1,configurable:!0,value:Z(a instanceof t?a._data:a)}),Object.defineProperty(this,"srfdeid",{get:()=>e.id}),Object.defineProperty(this,"srfdecodename",{get:()=>e.codeName});const i=he(e.appDEFields||[],e.keyAppDEFieldId);if(i){const t=i.codeName.toLowerCase();Object.defineProperty(this,"srfkeyfield",{get:()=>t}),Object.defineProperty(this,"srfkey",{set(e){this._data[t]=e},get(){return this._data[t]}})}else ibiz.log.warn("实体[".concat(e.codeName,"]未配置主键字段"));const s=he(e.appDEFields||[],e.majorAppDEFieldId);if(s){const t=s.codeName.toLowerCase();Object.defineProperty(this,"srfmajorfield",{get:()=>t}),Object.defineProperty(this,"srfmajortext",{set(e){this._data[t]=e},get(){return this._data[t]}})}else ibiz.log.warn("实体[".concat(e.codeName,"]未配置主文本字段"));Object.defineProperty(this,"tempsrfkey",{enumerable:!1,configurable:!0,writable:!0,value:Q(this.srfkey)?ct():this.srfkey}),this.defineProperties()}defineProperties(){var t;const{_data:e,convertVal:a}=this,i={};Object.keys(e).forEach((t=>{i[t]={enumerable:!0,set(a){e[t]=a},get:()=>e[t]}})),null==(t=this._entity.appDEFields)||t.forEach((t=>{const s=t.codeName.toLowerCase();i[s]={enumerable:!0,set(i){e[s]=a(i,t.stdDataType)},get:()=>e[s]},e[s]=a(e[s],t.stdDataType)})),Object.defineProperties(this,i)}clone(){const e=new t(this._entity,this._data);return e.srfkey=this.srfkey,e}assign(e){let a={};return a=e instanceof t?e._data:e,Object.keys(a).forEach((t=>{void 0===a[t]&&delete a[t]})),Object.assign(this._data,a),this}convertVal(t,e){if(null==t)return t;if(Q(e))return t;if(l.isNumber(e)){const e=Q(t)||""===t?t:Number(t);return Number.isNaN(e)?(ibiz.log.debug("".concat(t,"不能转换成数字")),t):e}return t}}),fn=t("MethodDto",class{constructor(t,e,a,i){this.service=t,this.entity=e,this.isLocalMode=a,this.dto=i,this.dtoMap=new Map,i?(this.app=ibiz.hub.getApp(e.appId),this.fields=i.appDEMethodDTOFields||[]):this.fields=[]}convertArrayToListMap(t){const e={};return t.forEach(((t,a)=>{e[a+1]=t})),e}convertListMapToArray(t){const e=[];return Object.keys(t).forEach((a=>{const i=parseInt(a,10);e[i-1]=t[i]})),e}async get(t,e,s=!1){if(!0===t.srfsimple&&!1===this.isLocalMode)return e;const n={},o=ibiz.uiDomainManager.get(t.srfsessionid);for(let r=0;r<this.fields.length;r++){const c=this.fields[r],d=c.codeName.toLowerCase();switch(c.type){case"SIMPLE":case"SIMPLES":case"DTO":break;case"DTOS":if(c.listMap)e[d]&&(n[d]=0===e[d].length?null:this.convertArrayToListMap(e[d]));else{if(void 0!==e[d]&&!1===s)break;if(!c.refAppDataEntityId)break;const i=o.getDERConfig(c.refAppDataEntityId),r=await this.getFieldDto(t,c),l=await ibiz.hub.getAppDEService(r.entity.appId,c.refAppDataEntityId,t),h=i.find((t=>t.majorAppDataEntityId===this.entity.id));let u;if(h&&h.nestedAppDEDataSetId){const a=Z(t);a[this.entity.codeName.toLowerCase()]=e.srfkey;const i={};h.parentAppDEFieldId&&(i[h.parentAppDEFieldId]=e.srfkey),u=await l.exec(h.nestedAppDEDataSetId,a,i)}else{if(r.entity.id===this.entity.id)throw new a(c,"子关系未配置嵌套关系数据集, 会导致递归查询死循环,请配置!");u=await l.exec("FetchDefault",t)}if(u.ok){const e=u.data,a=[];for(let i=0;i<e.length;i++)a.push(await r.get(t,e[i],!0));n[d]=a}}break;default:throw new i(c,"未支持的应用实体方法输入属性类型: ".concat(c.type))}}return{...e,...n}}async sets(t,e){if(!0===t.srfsimple&&!1===this.isLocalMode)return e&&e.length>0?e.map((t=>this.service.createEntity(t))):[];const a=ibiz.uiDomainManager.get(t.srfsessionid);return Promise.all(e.map((async e=>{const i=this.fields.filter((t=>"DTOS"===t.type)).map((async i=>{const s=i.codeName.toLowerCase();if(i.listMap&&"object"==typeof e[s])e[s]=this.convertListMapToArray(e[s]);else{if(!i.refAppDataEntityId)return;const n=a.getDERConfig(i.refAppDataEntityId).find((t=>t.majorAppDataEntityId===this.entity.id)),o=await this.getFieldDto(t,i);n||o.service.local.clear();const r=e[s];if(r&&r.length>0){const a=e[this.entity.keyAppDEFieldId];i.refPickupAppDEFieldId&&r.forEach((t=>{t[i.refPickupAppDEFieldId]=a})),await o.sets(t,r)}else await o.sets(t,[])}}));for(let t=0;t<i.length;t++)await i[t];const s=this.service.createEntity(e);return this.isLocalMode&&await this.service.local.add(t,s),s})))}async calcRs(t,e=0){if(e>10)return;e+=1;const a=ibiz.uiDomainManager.get(t.srfsessionid),i=this.fields.filter((t=>"DTOS"===t.type));for(let s=0;s<i.length;s++){const n=i[s];if(!n.refAppDataEntityId)continue;if(0===a.getDERConfig(n.refAppDataEntityId).length){const i=await this.getFieldDto(t,n);i.entity.minorAppDERSs&&a.setDERConfig(n.refAppDataEntityId,i.entity.minorAppDERSs.filter((t=>1===t.rsmode))),await i.calcRs(t,e)}}}async getFieldDto(t,e){if(this.dtoMap.has(e.codeName))return this.dtoMap.get(e.codeName);const a=await ibiz.hub.getAppDataEntity(e.refAppDataEntityId,this.entity.appId),i=he(a.appDEMethodDTOs||[],e.refAppDEMethodDTOId),s=await this.app.deService.getService(t,a.id);s.isLocalMode=!0;const n=s.createMethodDto(i,{isLocalMode:!0});return this.dtoMap.set(e.codeName,n),n}}),gn=t("DEService",class{constructor(t,e){this.srfSessionId=t,this.model=e,this.methodMap=new Map,this.isLocalMode=!1,this.local=new tn(e),this.configCache=new dn(e.appId,"PSAppDataEntity",e.codeName),this.wf=new hn(e),this.file=new un(e)}async getMethod(t,e=!1){const s=e?"ac-".concat(t):t;if(this.methodMap.has(s))return this.methodMap.get(s);const n=fe(this.model,t);if(!n)throw new a(this.model,"未找到服务方法: ".concat(t));const o=await Vs(n);if(!o)throw new i(n,"未支持的服务方法类型: ".concat(n.methodType));const r=o.create(this,this.model,n,{acMode:e,localMode:this.isLocalMode});return this.methodMap.set(s,r),r}async exec(t,e,a,i,s){const n=await this.getMethod(t);if(n)return n.exec(e,a,i,s);throw new o("".concat(this.model.codeName,"未支持「").concat(t,"」方法"))}getDraft(t,e,a){return this.exec("GetDraft",t,e,a)}create(t,e,a){return this.exec("Create",t,e,a)}get(t,e,a){return this.exec("Get",t,e,a)}update(t,e,a){return this.exec("Update",t,e,a)}remove(t,e,a){return this.exec("Remove",t,e,a)}fetchDefault(t,e,a){return this.exec("FetchDefault",t,e,a)}getDraftTemp(t,e,a){return this.exec("GetDraftTemp",t,e,a)}createTemp(t,e,a){return this.exec("CreateTemp",t,e,a)}getTemp(t,e,a){return this.exec("GetTemp",t,e,a)}updateTemp(t,e,a){return this.exec("UpdateTemp",t,e,a)}removeTemp(t,e,a){return this.exec("RemoveTemp",t,e,a)}fetchTempDefault(t,e,a){return this.exec("FetchTempDefault",t,e,a)}async execAc(t,e,a,i={}){const s=await this.getMethod(t,!0);if(s)return s.exec(e,a,i);throw new o("".concat(this.model.codeName,"未支持「").concat(t,"」方法"))}aiChatSse(t,e,a={},i={}){const s=ibiz.hub.getApp(this.model.appId),n=this.calcSsePath(e);return new Promise(((e,o)=>{s.net.sse("/".concat(n),{srfactag:"AIChat",...a},{headers:{"Content-Type":"application/json"},body:JSON.stringify(i),onmessage:e=>{if(e.data){const a=JSON.parse(e.data);t(a)}},onclose:()=>{e()},onerror:t=>{o(t)}})}))}aiChatHistory(t,e={},a={}){const i=ibiz.hub.getApp(this.model.appId),s=this.calcSsePath(t,!0);return i.net.post(s,a,{srfactag:"AIChat",...e})}calcSsePath(t,e=!1){const a=t[this.model.codeName.toLowerCase()],i="/".concat(this.model.deapicodeName2,"/ssechatcompletion").concat(e?"/histories":"").concat(a?"/".concat(a):"");return sn(t,this.model)+i}newEntity(t){return t instanceof mn?t.clone():new mn(this.model,t)}createEntity(t){return Array.isArray(t)?t.map((t=>this.newEntity(t))):this.newEntity(t)}async destroy(){this.local.clear()}createMethodDto(t,e){return new fn(this,this.model,null==e?void 0:e.isLocalMode,t)}}),wn=["srfkey","srfmajortext","srfmajorfield","srfkeyfield","tempsrfkey","srfuf","srfdeid","srfdecodename"],En=t("ControlVO",class t{constructor(t={},e=new Map){Object.defineProperty(this,"$origin",{enumerable:!1,configurable:!0,value:t||{}}),Object.defineProperty(this,"$dataUIMap",{enumerable:!1,configurable:!0,value:e||new Map}),Object.defineProperty(this,"srfactionparam",{get(){return this.$origin.srfactionparam},set(t){this.$origin.srfactionparam=t},enumerable:!0,configurable:!0}),["srfkey","srfmajortext"].forEach((t=>{if(Object.prototype.hasOwnProperty.call(this.$origin,t))Object.defineProperty(this,t,{get(){return this.$origin[t]},set(e){this.$origin[t]=e},enumerable:!1,configurable:!0});else if(this.$dataUIMap.has(t)){const{dataKey:e}=this.$dataUIMap.get(t);Object.defineProperty(this,t,{get(){return this.$origin[e]},set(t){this.$origin[e]=t},enumerable:!1,configurable:!0})}else Object.defineProperty(this,t,{enumerable:!1,configurable:!0,writable:!0,value:null})})),Object.prototype.hasOwnProperty.call(this.$origin,"tempsrfkey")?Object.defineProperty(this,"tempsrfkey",{get(){return this.$origin.tempsrfkey},set(t){this.$origin.tempsrfkey=t},enumerable:!1,configurable:!0}):Object.defineProperty(this,"tempsrfkey",{enumerable:!1,configurable:!0,writable:!0,value:Q(this.srfkey)?ct():this.srfkey}),Object.defineProperty(this,"srfuf",{get(){return Object.prototype.hasOwnProperty.call(this.$origin,"srfuf")?this.$origin.srfuf:this.srfkey===this.tempsrfkey?1:0},enumerable:!1,configurable:!0}),["srfdeid","srfdecodename","srfkeyfield","srfmajorfield"].forEach((t=>{Object.defineProperty(this,t,{get(){return this.$origin[t]},enumerable:!1,configurable:!0})})),this.$dataUIMap.forEach(((t,e)=>{const a=t.dataKey;this.linkProperty(e,a,t)})),Object.keys(t).forEach((t=>{Object.prototype.hasOwnProperty.call(this,t)||this.linkProperty(t,t)}))}linkProperty(t,e,a){const i=!a||a.isOriginField;wn.includes(t)||(i||Object.prototype.hasOwnProperty.call(this.$origin,t)?Object.defineProperty(this,t,{enumerable:!0,configurable:!0,get(){return this.$origin[e]},set(t){this.$origin[e]=t}}):Object.defineProperty(this,t,{enumerable:!0,configurable:!0,writable:!0,value:null}))}getOrigin(){return this.$origin}setOrigin(e){this.$origin=e instanceof t?e.getOrigin():e}clone(){const e=Z(this.$origin),a=new t(e,this.$dataUIMap);return Object.keys(this).forEach((t=>{a[t]=this[t]})),a}}),yn=t("ControlService",class{constructor(t){this.dataUIMap=new Map,this.model=t}async init(t){this.app=ibiz.hub.getApp(this.model.appId),this.initUIDataMap()}initUIDataMap(){}async exec(t,e,a,i){const s=this.handleCustomRequestHeader(),n=await this.app.deService.exec(this.model.appDataEntityId,t,e,a,i,s);return await this.handleItemPrivilege(n.data,e),n}async handleItemPrivilege(t,e){const{enableItemPrivilege:a,appDataEntityId:i}=this.model;if(a&&i){const a=await this.app.authority.getService(i);(Array.isArray(t)?t:[t]).forEach((t=>{a.setDataAccAction({srfkey:t.srfkey,srfsessionid:e.srfsessionid},t.srfdataaccaction)}))}}handleCustomRequestHeader(){const t={},{enableItemPrivilege:e}=this.model;return e&&Object.assign(t,{srfdataaccaction:!0}),t}handleResponse(t){return h(t)}toUIData(t){return new En(t,this.dataUIMap)}}),vn=t("MDControlService",class extends yn{async fetch(t,e={}){var a;const i=(null==(a=this.model.fetchControlAction)?void 0:a.appDEMethodId)||"fetchdefault";let s=await this.exec(i,t,e);return s=this.handleResponse(s),s}async get(t,e={}){var a;const i=(null==(a=this.model.getControlAction)?void 0:a.appDEMethodId)||"get";let s=await this.exec(i,t,void 0,e);return s=this.handleResponse(s),s}async getDraft(t,e={}){var a;const i=(null==(a=this.model.getDraftControlAction)?void 0:a.appDEMethodId)||"getdraft";let s=await this.exec(i,t,void 0,e);return s=this.handleResponse(s),s}async remove(t,e={}){var a;const i=(null==(a=this.model.removeControlAction)?void 0:a.appDEMethodId)||"remove";return await this.exec(i,t,void 0,e)}async create(t,e){var a;const i=(null==(a=this.model.createControlAction)?void 0:a.appDEMethodId)||"create";let s=await this.exec(i,t,e.getOrigin());return s=this.handleResponse(s),s}async update(t,e){var a;const i=(null==(a=this.model.updateControlAction)?void 0:a.appDEMethodId)||"update";let s=await this.exec(i,t,e.getOrigin());return s=this.handleResponse(s),s}async updateBatch(t,e){var a;const i=(null==(a=this.model.updateControlAction)?void 0:a.appDEMethodId)||"update";let s=await this.exec(i,t,e.map((t=>t.getOrigin())));return s=this.handleResponse(s),s}async exportData(t,e,a={}){throw new o("未实现")}handleResponse(t){const e=super.handleResponse(t);return e.headers&&(e.headers["x-page"]&&(e.page=Number(e.headers["x-page"])),e.headers["x-per-page"]&&(e.size=Number(e.headers["x-per-page"])),e.headers["x-total"]&&(e.total=Number(e.headers["x-total"])),e.headers["x-total-pages"]&&(e.totalPages=Number(e.headers["x-total-pages"]))),e.ok&&(lt(e.data)?e.data=e.data.map((t=>this.toUIData(t))):e.data=this.toUIData(e.data)),e}}),In=t("DeAuthorityService",class{constructor(t){this.entityModel=t,this.dataAccActionMap=new Map}setDataAccAction(t,e){t.srfsessionid&&this.dataAccActionMap.set("".concat(t.srfsessionid,"-").concat(t.srfkey),e),this.dataAccActionMap.set(t.srfkey,e)}getDataAccAction(t){return this.dataAccActionMap.get(t)}async calcByDataAccessAction(t,e,a,i){if(i){if(!await this.calcDeDataAccAction(t,e,a))return!1}return!!await this.calcByDeMainState(t,e)}async calcMajorDataAccAction(t){const{minorAppDERSs:e}=this.entityModel;if(!e)return;const a=null==e?void 0:e.find((e=>{const a=ve(e.majorAppDataEntityId);return Object.prototype.hasOwnProperty.call(t,a)&&t[a]}));if(!a)return;const i=await ibiz.hub.getApp(t.srfappid),s=await i.authority.getService(a.majorAppDataEntityId);if(!s)return;const n=ve(a.majorAppDataEntityId);return s.getDataAccAction("".concat(t.srfsessionid,"-").concat(t[n]))||s.getDataAccAction("".concat(t[n]))}async calcDeDataAccAction(t,e,a){let i,s=!0;const{dataAccCtrlMode:n}=this.entityModel;switch(n){case 1:i=(null==e?void 0:e.srfdataaccaction)?rn(e.srfdataaccaction):void 0;break;case 2:i=rn(await this.calcMajorDataAccAction(a));break;case 3:i=rn(await this.calcMajorDataAccAction(a)),!Object.prototype.hasOwnProperty.call(i,t)&&e&&e.srfdataaccaction&&(i=rn(e.srfdataaccaction))}return i&&t&&!i[t]&&(s=!1),s}async calcByDeMainState(t,e={}){let a=!0;if(0===Object.keys(e).length)return a;const i=this.entityModel;if(!i.enableDEMainState)return ibiz.log.debug("".concat(i.codeName,"实体不存在或者为启用主状态,返回true")),a;ibiz.log.debug("操作标识".concat(t,"主状态计算开始"),e,i);const s=Ee(i,e);if(s){ibiz.log.debug("匹配主状态",s);const e=ye(s,i);ibiz.log.debug("允许的主状态权限集合",e),a=e.includes(t)}else ibiz.log.debug("没匹配主状态,返回false"),a=!1;return ibiz.log.debug("操作标识".concat(t,"权限计算结束:").concat(a)),a}}),Dn=t("AuthorityService",class{constructor(t){this.appModel=t,this.cache=new Map,this.constructorCache=new Map,this.resCodes=[],this.enablePermission=!1}register(t,e){this.constructorCache.set(t,e)}async getService(t){if(!this.cache.has(t)){const e=await ibiz.hub.getAppDataEntity(t,this.appModel.appId);if(!e)throw new o("未找到应用实体[".concat(t,"]"));const a=this.constructorCache.get(t);let i;i=a?await a(e):new In(e),this.cache.set(t,i)}return this.cache.get(t)}async init(t=ibiz.appData){t&&(t.unires&&(this.resCodes=t.unires),!0===t.enablepermissionvalid&&ibiz.env.enablePermission&&(this.enablePermission=!0))}calcByResCode(t){return!this.enablePermission||this.resCodes.includes(t)}async calcByDataAccessAction(t,e,a,i){if(this.enablePermission){const e=await ibiz.hub.getApp(this.appModel.appId),a=await e.getOPPriv(t,i);if(a&&a.mapSysUniResMode&&a.mapSysUniResCode)return!!this.calcByResCode(a.mapSysUniResCode)}if(i){return(await this.getService(i)).calcByDataAccessAction(t,a,e,this.enablePermission)}return!0}}),Cn=t("V7AuthService",class{get isAnonymous(){return"1"===ht(u.IS_ANONYMOUS)}async anonymousLogin(){const{anonymousUser:t,anonymousPwd:e}=ibiz.env;if(!t||!e)return ibiz.log.error("未找到匿名登录配置用户名或密码"),!1;const a=await this.login(t,e);if(a){ut(u.IS_ANONYMOUS,"1",0,!0);const t=ht(u.TOKEN),e=ht(u.TOKEN_EXPIRES),a=ht(u.TOKEN_REMEMBER),i=ht(u.REFRESH_TOKEN);ut(u.TOKEN,t,0,!0),ut(u.TOKEN_EXPIRES,e,0,!0),ut(u.TOKEN_REMEMBER,a,0,!0),i&&ut(u.REFRESH_TOKEN,i,0,!0)}return a}async login(t,e,a){try{const i=await ibiz.net.post("/v7/login",{loginname:t,password:e,rememberme:a}),{data:s}=i;if(s&&s.token){const t=a?30:0;a&&ut(u.TOKEN_REMEMBER,"1",t,!0),ut(u.TOKEN,s.token,t,!0);const e=(new Date).getTime()+1e3*(s.expirein||7199);ut(u.TOKEN_EXPIRES,"".concat(e),t,!0),s.refresh_token&&ut(u.REFRESH_TOKEN,s.refresh_token,t,!0),pt(u.IS_ANONYMOUS)}return!0}catch(t){ibiz.notification.error({title:"登录失败",desc:t.message||""})}return!1}async logout(){try{return await ibiz.net.get("/v7/logout"),pt(u.TOKEN),pt(u.TOKEN_EXPIRES),pt(u.TOKEN_REMEMBER),pt(u.REFRESH_TOKEN),pt(u.IS_ANONYMOUS),ibiz.appData=void 0,ibiz.orgData=void 0,!0}catch(t){ibiz.notification.error({title:"登出失败",desc:t.message||""})}return!1}async extendLogin(){if(this.isAnonymous)return;const t=ht(u.TOKEN),e=ht(u.TOKEN_EXPIRES);if(t&&e){let t=Number(e)-(new Date).getTime();const a=3e5;t=t>a?t-a:0,setTimeout((async()=>{const t=ht(u.TOKEN_REMEMBER),e=ht(u.REFRESH_TOKEN),a=t?30:0;let i;if(i=null!=e&&""!==e?await ibiz.net.get("/uaa/refresh_token/".concat(e)):await ibiz.net.get("/uaa/refreshtoken2"),i.ok){t&&ut(u.TOKEN_REMEMBER,"1",a,!0),ut(u.TOKEN,i.data.token,a,!0);const e=(new Date).getTime()+1e3*(i.data.expirein||7199);ut(u.TOKEN_EXPIRES,"".concat(e),a,!0),i.data.refresh_token&&ut(u.REFRESH_TOKEN,i.data.refresh_token,a,!0),await this.loadAppData(),ibiz.hub.getAllApps().forEach((t=>{t.initMqtt()}))}this.extendLogin()}),t)}}async refreshToken(){const t=ht(u.TOKEN_REMEMBER),e=ht(u.REFRESH_TOKEN);if(null!=e&&""!==e){const a=await ibiz.net.get("/uaa/refresh_token/".concat(e));if(a.ok){const e=t?30:0;t&&ut(u.TOKEN_REMEMBER,"1",e,!0),ut(u.TOKEN,a.data.token,e,!0);const i=(new Date).getTime()+1e3*(a.data.expirein||7199);ut(u.TOKEN_EXPIRES,"".concat(i),e,!0),a.data.refresh_token&&ut(u.REFRESH_TOKEN,a.data.refresh_token,e,!0),pt(u.IS_ANONYMOUS)}}}getAuthInfo(){const t=ht(u.TOKEN),e=!!ht(u.IS_ANONYMOUS);return t?{token:t,isAnonymous:e}:void 0}async loadAppData(){const t=await ibiz.net.get("/appdata");t.ok&&(ibiz.appData=t.data)}}),bn=t("AsyncActionService",class{async fetch(t={}){const e=await ibiz.net.post("/portal/asyncaction/all",t);return Q(e.data)&&(e.data=[]),e}async get(t){return await ibiz.net.get("/portal/asyncaction/".concat(t))}}),An=t("MethodInput",class{constructor(t,e,a,i=!1){this.service=t,this.entity=e,this.method=a,this.isLocalMode=i;const s=a.appDEMethodInput;if(s){const a=he(e.appDEMethodDTOs||[],s.appDEMethodDTOId);a&&(this.dto=t.createMethodDto(a,{isLocalMode:this.isLocalMode}))}}async handle(t,e){return this.dto?this.dto.get(t,e):e}}),Pn=t("MethodReturn",class{constructor(t,e,a,i=!1){this.service=t,this.entity=e,this.method=a,this.isLocalMode=i;const s=a.appDEMethodReturn;if(s){const a=he(e.appDEMethodDTOs||[],s.appDEMethodDTOId);a&&(this.dto=t.createMethodDto(a,{isLocalMode:this.isLocalMode}))}}async handle(t,e){if(this.dto){const a=ibiz.hub.getApp(this.entity.appId),i=ibiz.uiDomainManager.get(t.srfsessionid);i&&!0!==i.state.rsInit&&(await this.dto.calcRs(t),i.calcParentRs(),i.state.rsInit=!0),i.dataChangeCompleted(),a.deService.clearTempCacheByRs({srfappid:a.appId,srfsessionid:t.srfsessionid},this.entity.id);return(await this.dto.sets(t,[e]))[0]}return ot(e)&&(e={}),new mn(this.entity,e)}}),Tn=t("Method",class{constructor(t,e,a,i=!1){this.service=t,this.entity=e,this.method=a,this.isLocalMode=i,this.app=ibiz.hub.getApp(e.appId),this.input=new An(t,e,a),this.result=new Pn(t,e,a)}async request(t,e,i,s,n){const{actionType:o,requestMethod:r}=this.method;if("REMOTE"===o){const e=this.method.requestPath;let o=null;switch(r){case"POST":o=await this.app.net.post(this.mergeRequestPath(t,e),i||s||{},{},n);break;case"GET":o=await this.app.net.get(this.mergeRequestPath(t,e),i||s,n);break;case"PUT":o=await this.app.net.put(this.mergeRequestPath(t,e),i||s||{},n);break;case"DELETE":o=await this.app.net.delete(this.mergeRequestPath(t,e),i||s);break;default:throw new a(this.method,r?"未支持的请求方式: ".concat(r):"未配置请求方式")}return o}throw new a(this.method,"未支持的行为类型[".concat(o,"]"))}mergeRequestPath(t,e){return e?"".concat(t).concat(e):"".concat(t)}calcPath(t){const e="/".concat(this.entity.deapicodeName2);return sn(t,this.entity)+e}createEntity(t){return this.service.createEntity(t)}}),xn=class{constructor(t,e,a,i){this.deLogicParams=t,this.params={},this.result=null,this.isEndNode=!1,this.defaultParamName="Default",this.parameters={context:e,data:_(a)?a:[a],params:i}}get context(){return Object.prototype.hasOwnProperty.call(this.params,"context")?this.params.context:this.parameters.context}get data(){return this.parameters.data}get viewParam(){return Object.prototype.hasOwnProperty.call(this.params,"viewParam")?this.params.viewParam:this.parameters.params}resetParam(t){var e;null==(e=this.deLogicParams.get(t))||e.calc(this)}renewParam(t){var e;null==(e=this.deLogicParams.get(t))||e.renew(this)}setLastReturn(t){this.lastReturn=t}initLastReturnParam(t){Object.defineProperty(this.params,t,{enumerable:!0,configurable:!0,get:()=>this.lastReturn})}isEntityParam(t){const e=this.deLogicParams.get(t);return!(!e||!e.model.entityParam)}},Sn=class{},Nn=class extends Sn{constructor(t){super(),this.model=t,this.srcParam=t.srcLogicParamId,this.dstParam=t.dstLogicParamId}get dstField(){return this.model.dstFieldName.toLowerCase()}get op(){return this.model.condOP}get type(){return this.model.paramType}get value(){return this.model.paramValue}test(t,e,s){const n=t.params[this.dstParam];let o,r;switch(this.type){case"ENTITYFIELD":{if(!this.value)throw new a(this.model,"当前条件值类型为[数据对象属性],缺少配置条件值");const t=null!=s[this.value]?s[this.value]:e[this.value];r=t,o=Ge(n[this.dstField],this.op,t);break}case"SRCENTITYFIELD":{if(!this.value)throw new a(this.model,"当前条件值类型为[源数据对象属性],缺少配置条件值");const e=t.params[this.srcParam];r=e[this.value],o=Ge(n[this.dstField],this.op,e[this.value]);break}case"CURTIME":throw new i(this.model,"暂未支持条件值类型为[当前时间]");default:r=this.value,o=Ge(n[this.dstField],this.op,this.value)}return ibiz.log.debug("实体逻辑连接条件项:".concat(this.model.name,"-条件值类型:").concat(this.type,"-源属性名称:").concat(this.dstField,"-源对象值:"),n[this.dstField],"-对比条件:".concat(this.op),"-对比值",r,"-对比结果:",o),o}},Rn=class t extends Sn{constructor(e){super(),this.model=e;const a=e.conds||[];this.conds=a.map((e=>"SINGLE"===e.logicType?new Nn(e):new t(e)))}get op(){return this.model.groupOP}get notMode(){return!0===this.model.notMode}test(t,e,i){let s=!0;if(0===this.conds.length)throw new a(this.model,"界面连接条件逻辑组未配置逻辑项");for(let a=0;a<this.conds.length;a++){const n=this.conds[a].test(t,e,i);if("AND"===this.op&&!1===n){s=!1;break}if("OR"===this.op&&!0===n){s=!0;break}}const n=this.notMode?!s:s;return ibiz.log.debug("实体逻辑连接条件组名称:".concat(this.model.name,"-条件组标识:").concat(this.model.id,"-运行结果:"),n),n}},Mn=class{constructor(t){this.model=t,this.srcNode=null,this.dstNode=null,this.groupCond=null;const e=this.model.delogicLinkGroupCond;e&&(this.groupCond=new Rn(e))}async exec(t){const{defaultLink:e}=this.model;return!(!e&&this.groupCond)||this.groupCond.test(t,t.context,t.data[0]||{})}},On=class{constructor(t){var e;this.model=t,this.links=null==(e=t.links||[])?void 0:e.map((t=>new Mn(t)))}},Ln=class extends On{async exec(t){const{dstAppDataEntityId:e,dstAppDEActionId:i,dstDELogicParamId:s,retDELogicParamId:n}=this.model;if(!e)throw new a(this.model,"未指定应用实体");if(!i)throw new a(this.model,"未指定实体行为");const o=t.params[s],r=ibiz.hub.getApp(t.context.srfappid),c=await r.deService.exec(e,i,t.context,o,t.viewParam);c.ok&&(t.params[n]=c.data),ibiz.log.debug("实体逻辑节点(实体行为):".concat(this.model.id,"-界面行为所属实体:").concat(e,"-实体行为标识:").concat(i,"-参数名称:").concat(n,"-值:"),t.params[n])}},_n=class extends On{async exec(t){ibiz.log.debug("实体逻辑节点(启动节点):".concat(this.model.id))}},Fn=class extends On{async exec(t){t.isEndNode=!0;const{returnParamId:e,returnType:a,rawValue:s}=this.model;if(a){switch(a){case"NONEVALUE":t.result=void 0;break;case"NULLVALUE":t.result=null;break;case"SRCVALUE":t.result=ibiz.util.rawValue.format(s);break;case"LOGICPARAM":t.result=t.params[e];break;default:throw new i(this.model,"暂未支持的结束节点返回值类型: ".concat(a))}ibiz.log.debug("实体逻辑节点(结束节点):".concat(this.model.id,"-返回值类型:").concat(a,"-返回值:"),t.result)}}};function Vn(t,e){const{srcDELogicParamId:a,srcFieldName:s,srcValue:n,expression:o}=e,r=e.srcValueType||"SRCDLPARAM";let c,d=s;switch(r){case"SRCDLPARAM":c=t.params[a],t.isEntityParam(a)&&(d=null==d?void 0:d.toLowerCase());break;case"NULLVALUE":return null;case"NONEVALUE":return;case"SRCVALUE":return ibiz.util.rawValue.format(n);case"WEBCONTEXT":case"VIEWPARAM":c=t.parameters.params;break;case"APPLICATION":case"SESSION":case"APPDATA":case"DATACONTEXT":c=t.parameters.context;break;case"ENVPARAM":c=Z(ibiz.env);break;case"EXPRESSION":if(!o)throw new i(e,"表达式为空");c=Qe.execScriptFn(t,o,{singleRowReturn:!0,isAsync:!1});break;default:throw new i(e,"暂未支持源值类型".concat(r))}if(c&&d)try{c=Array.isArray(c)?c[Number(d)]:Qe.execScriptFn({srcValue:c},"srcValue.".concat(d),{singleRowReturn:!0,isAsync:!1})}catch(t){throw ibiz.log.error("从源参数取属性".concat(d,"报错,源参数:"),c),t}return c}var kn=class extends On{async exec(t){const e=this.model.delogicNodeParams;(null==e?void 0:e.length)&&await Promise.all(e.map((e=>{let a,s;switch(e.dstDELogicParamId&&"DEBUG"===ibiz.env.logLevel&&(s=Z(t.params[e.dstDELogicParamId])),e.paramAction){case"SETPARAMVALUE":a=this.setParamValue(e,t);break;case"RESETPARAM":a=this.resetParam(e,t);break;case"COPYPARAM":a=this.copyParam(e,t);break;case"BINDPARAM":a=this.bindParam(e,t);break;case"RENEWPARAM":a=this.renewParam(e,t);break;case"APPENDPARAM":a=this.appendParam(e,t);break;case"SORTPARAM":a=this.sortParam(e,t);break;default:throw new i(e,"暂未支持逻辑处理参数操作".concat(e.paramAction))}return ibiz.log.debug("实体逻辑节点(准备参数):".concat(this.model.id,"-参数处理操作:").concat(e.paramAction,"-目标逻辑参数:").concat(e.dstDELogicParamId,"-源参数(值):"),s,"-目标参数(值):",t.params[e.dstDELogicParamId]),a})))}copyParam(t,e){const{dstDELogicParamId:a}=t,i=Vn(e,t);e.params[a]=Z(i)}bindParam(t,e){const a=Vn(e,t);e.params[t.dstDELogicParamId]=a}setParamValue(t,e){const{dstFieldName:a,dstDELogicParamId:i}=t;let s=a;e.isEntityParam(i)&&(s=null==s?void 0:s.toLowerCase());const n=Vn(e,t);s?e.params[i][s]=n:e.params[i]=n}resetParam(t,e){const{dstDELogicParamId:a}=t;e.resetParam(a)}renewParam(t,e){const{dstDELogicParamId:a}=t;e.renewParam(a)}appendParam(t,e){const{dstDELogicParamId:a,dstIndex:i,srcIndex:s,srcSize:n}=t,o=Vn(e,t),r=i||0,c=s||0,d=n||o.length;e.params[a].splice(r,0,...o.slice(c,d))}sortParam(t,e){const{dstDELogicParamId:a,dstFieldName:i,dstSortDir:s}=t,n=i.toLowerCase();e.params[a].sort(((t,e)=>"ASC"===s?t[n]-e[n]:e[n]-t[n]))}},zn=class extends On{async exec(t){const{dstAppDEDataSetId:e,dstAppDataEntityId:a,dstDELogicParamId:i,retDELogicParamId:s}=this.model,n=t.params[i],o=ibiz.hub.getApp(t.context.srfappid),r=await o.deService.exec(a,e,t.context,n);r.ok&&(t.params[s]=r.data),ibiz.log.debug("实体逻辑节点(数据集合):".concat(this.model.id,"-数据集实体标识:").concat(a,"-数据集标识:").concat(e,"-参数名称:").concat(s,"-值:"),t.params[s])}},Wn=class extends On{async exec(t){const{dstDELogicParamId:e,srcDELogicParamId:i}=this.model;if(!e||!i)throw new a(this.model,"缺少目标参数对象或者源参数对象配置");const s=Vn(t,this.model);t.params[e]=s,ibiz.log.debug("实体逻辑节点(绑定参数):".concat(this.model.id,"-参数名称:").concat(e,"-值:"),s)}},Un=class extends On{async exec(t){const{dstDELogicParamId:e}=this.model;if(!e)throw new a(this.model,"缺少目标参数对象配置");t.resetParam(e),ibiz.log.debug("实体逻辑节点(重置参数):".concat(this.model.id,"-重置参数:").concat(e))}},Bn=class extends On{async exec(t){const{dstDELogicParamId:e}=this.model;if(!e)throw new a(this.model,"缺少目标参数对象配置");t.renewParam(e),ibiz.log.debug("实体逻辑节点(重新建立参数):".concat(this.model.id,"-重建参数:").concat(e))}},Gn=class extends On{async exec(t){const{dstDELogicParamId:e,srcDELogicParamId:i}=this.model;if(!e||!i)throw new a(this.model,"缺少目标参数对象或者源参数对象配置");const s=Vn(t,this.model);t.params[e]=Z(s),ibiz.log.debug("实体逻辑节点(拷贝参数):".concat(this.model.id,"-参数名称:").concat(e,"-值:"),s)}},jn=class extends On{async exec(t){const{dstDELogicParamId:e,dstSortDir:i,dstFieldName:s}=this.model;if(!e||!s)throw new a(this.model,"缺少目标参数对象或目标属性配置");const n=s.toLowerCase(),o=t.params[e];o.sort(((t,e)=>"ASC"===i?t[n]-e[n]:e[n]-t[n])),ibiz.log.debug("实体逻辑节点(排序数组参数):".concat(this.model.id,"-排序属性:").concat(s,"-排序模式:").concat(i,"-参数名称:").concat(e,"-排序后数组:"),o)}},Kn=class extends On{async exec(t){const{dstDELogicParamId:e,srcDELogicParamId:i,dstIndex:s,srcIndex:n,srcSize:o}=this.model;if(!e||!i)throw new a(this.model,"缺少目标参数对象或者源参数对象配置");const r=Vn(t,this.model),c=s||0,d=n||0,l=o||r.length;t.params[e].splice(c,0,...r.slice(d,l)),ibiz.log.debug("实体逻辑节点(附加到数组):".concat(this.model.id,"-附加参数:"),t.params,"-附加值:",r.slice(d,l))}},Xn=class extends On{async exec(t){const{errorCode:e,errorInfo:a}=this.model;throw ibiz.log.debug("实体逻辑节点(抛出异常):".concat(this.model.id,"-错误代码:").concat(e,"-错误信息:").concat(a)),new s({response:{status:e,statusText:a}})}},Hn=class{constructor(t){this.model=t}calc(t){const e=this.model.id,a=this.model;if(a.default)a.entityListParam?t.params[e]=t.data||[]:t.params[e]=t.data[0]||{};else if(a.appGlobalParam)t.params[e]=Z(ibiz.env);else if(a.entityListParam)t.params[e]=[];else if(a.entityPageParam)t.params[e]={};else if(a.entityParam)t.params[e]={};else if(a.lastReturnParam)t.initLastReturnParam(e);else if(a.appContextParam)t.params[e]=t.parameters.context;else if(a.simpleListParam)t.params[e]=[];else if(a.simpleParam)t.params[e]={};else if(a.cloneParam)t.params[e]=Z(t.data||{});else{if(a.envParam)throw new i(a,"未支持的逻辑参数类型: 系统环境变量");if(a.fileListParam)throw new i(a,"未支持的逻辑参数类型: 文件对象列表变量");if(a.fileParam)throw new i(a,"未支持的逻辑参数类型: 文件对象变量");if(a.filterParam)throw new i(a,"未支持的逻辑参数类型: 过滤器对象变量");if(a.lastParam)throw new i(a,"未支持的逻辑参数类型: 最后数据变量");if(a.originEntity)throw new i(a,"未支持的逻辑参数类型: 原始数据对象");if(a.sessionParam)throw new i(a,"未支持的逻辑参数类型: 操作会话变量")}ibiz.log.debug("计算实体逻辑参数,标识:".concat(e),"-值:",t.params[e])}renew(t){const e=this.model.id,a=this.model;if(a.entityListParam||a.simpleListParam||a.entityPageParam)t.params[e]=[];else{if(!a.simpleParam&&!a.entityParam)throw new i(a,"未支持的逻辑参数类型重新建立变量");t.params[e]={}}ibiz.log.debug("重新建立实体逻辑参数,标识:".concat(e),"-值:",t.params[e])}},qn=class{constructor(t){var e,s;if(this.model=t,this.nodes=new Map,this.params=new Map,t.customCode){if(!t.scriptCode)throw new a(t,"脚本代码模式没有配置脚本代码");this.scriptFn=Qe.createScriptFn([],t.scriptCode,{isAsync:!0})}else{if(!(null==(e=t.delogicNodes)?void 0:e.length))throw new a(t,"实体逻辑没有配置逻辑节点");t.delogicNodes.forEach((t=>{const{logicNodeType:e}=t;let a;switch(e){case"BEGIN":a=new _n(t);break;case"END":a=new Fn(t);break;case"DEACTION":a=new Ln(t);break;case"PREPAREPARAM":a=new kn(t);break;case"DEDATASET":a=new zn(t);break;case"THROWEXCEPTION":a=new Xn(t);break;case"BINDPARAM":a=new Wn(t);break;case"RESETPARAM":a=new Un(t);break;case"COPYPARAM":a=new Gn(t);break;case"RENEWPARAM":a=new Bn(t);break;case"APPENDPARAM":a=new Kn(t);break;case"SORTPARAM":a=new jn(t);break;default:throw new i(t,"未支持的逻辑节点类型: ".concat(e))}this.nodes.set(t.id,a)})),null==(s=t.delogicParams)||s.forEach((t=>{this.params.set(t.id,new Hn(t))})),this.nodes.forEach((t=>{t.links.forEach((e=>{e.srcNode=t,this.nodes.has(e.model.thenId)&&(e.dstNode=this.nodes.get(e.model.thenId))}))}))}}initLogicParams(t){this.params.forEach((e=>{e.model.default&&(t.defaultParamName=e.model.id),e.calc(t)}))}async exec(t,e,i){if(this.scriptFn)return this.scriptFn.exec({context:t,data:e,params:i});const s=new xn(this.params,t,e,i);this.initLogicParams(s);const{startDELogicNodeId:n}=this.model;if(!n||!this.nodes.has(n))throw new a(this.model,"未设置起始节点");{const t=this.nodes.get(n);await this.deepExec(t,s)}return s.isEndNode?s.result:s.params[s.defaultParamName]?s.params[s.defaultParamName]:null}async deepExec(t,e){await t.exec(e);const{links:a}=t;for(let i=0;i<a.length;i++){const s=a[i];if(await s.exec(e)&&s.dstNode&&(await this.deepExec(s.dstNode,e),!0!==t.model.parallelOutput))break}}},Yn=new Map;async function Qn(t,e,a={},i={}){Yn.has(t)||Yn.set(t,new qn(t)),ibiz.log.debug("开始执行实体逻辑,逻辑标识:".concat(t.id,"-逻辑名称:").concat(t.name));const s=Yn.get(t),n=await s.exec(e,a,i);return ibiz.log.debug("结束执行实体逻辑,逻辑标识:".concat(t.id,"-逻辑名称:").concat(t.name)),n}async function $n(t,e,a,i,s){const n=await async function(t,e,a){return De(t,await ibiz.hub.getAppDataEntity(e,a))}(t,e,a.srfappid);if(!n)throw new o("".concat(e,"找不到实体逻辑").concat(t));return Qn(n,a,i,s)}async function Jn(t,e,a,i){const n=Z(e),o=a?Z(a):a,r=i?Z(i):i;try{const e=await Qn(t,n,o,r);return new p(e)}catch(t){if(t instanceof s)return new p(t,500);throw t}}async function Zn(t,e,a,i,s){const n=Ce(t,e);if(n.length){(await Promise.all(n.map((t=>Qn(t,a,i,s))))).forEach((t=>{Object.assign(i,t)}))}}async function to(t,e,a,i,s={}){if(i){if(!_(i))return Zn(t,e,a,i,s);await Promise.all(i.map((i=>Zn(t,e,a,i,s))))}}var eo=t("DEActionMethod",class extends Tn{async inputHandle(t,e){return _(e)?e:this.input.handle(t,e)}async exec(t,e,i,s){let n;if(e&&!["READ","GETDRAFT"].includes(this.method.actionMode)&&await to(this.entity,"change",t,e,i),"DELOGIC"===this.method.actionType){const s=De(this.method.appDELogicId,this.entity);if(!s)throw new a(this.method,"缺少实体处理逻辑");n=await Jn(s,t,e,i)}else{e&&!this.isLocalMode&&(e=await this.inputHandle(t,e));switch(this.method.actionTag?this.method.actionTag.toUpperCase():this.method.codeName.toUpperCase()){case"CREATE":n=await this.create(t,e,i||{},s);break;case"GET":n=await this.get(t,i,s);break;case"GETDRAFT":n=await this.getDraft(t,i,s);break;case"REMOVE":n=await this.remove(t,i);break;case"UPDATE":n=await this.update(t,e,i,s);break;case"CREATETEMP":n=await this.createTemp(t,e);break;case"GETTEMP":n=await this.getTemp(t,e);break;case"GETDRAFTTEMP":n=await this.getDraftTemp(t,i);break;case"REMOVETEMP":n=await this.removeTemp(t,e);break;case"UPDATETEMP":n=await this.updateTemp(t,e);break;default:{let a=this.calcPath(t);if(this.method.needResourceKey){let i=t[this.entity.codeName.toLowerCase()];O(i)&&(i=_(e)?null:null==e?void 0:e[this.entity.keyAppDEFieldId]),a="".concat(a,"/").concat(i)}const o=await this.request(a,t,e,i,s);o.data=await this.result.handle(t,o.data),n=o}}}return n.data&&await to(this.entity,"compute",t,n.data,i),n}async create(t,e,a,i){if(!e)throw new o("create行为没有传data");if(this.isLocalMode)return this.createTemp(t,this.createEntity(e));const s=this.calcPath(t),n=await this.app.net.post(s,e,a,i);return n.data=await this.result.handle(t,n.data),n}async remove(t,e,a){if(this.isLocalMode)return this.removeTemp(t,e);const i=this.calcPath(t);return await this.app.net.delete("".concat(i,"/").concat(t[this.entity.codeName.toLowerCase()]),e,a)}async update(t,e,a,i){if(!e)throw new o("update行为没有传data");if(this.isLocalMode)return this.updateTemp(t,this.createEntity(e));const s=this.calcPath(t),n=await this.app.net.put("".concat(s,"/").concat(t[this.entity.codeName.toLowerCase()]),e,a,i);return n.data=await this.result.handle(t,n.data),n}async get(t,e={},a={}){if(this.isLocalMode)return this.getTemp(t,e);const i=this.calcPath(t),s=await this.app.net.get("".concat(i,"/").concat(t[this.entity.codeName.toLowerCase()]),e,a);return s.data=await this.result.handle(t,s.data),s}async getDraft(t,e,a){if(this.isLocalMode)return this.getDraftTemp(t,e);const i=this.calcPath(t),s=await this.app.net.get(this.mergeRequestPath(i,this.method.requestPath),e,a);return s.data=await this.result.handle(t,s.data),s}async createTemp(t,e){try{const a=this.createEntity(e);let i;i=_(a)?await Promise.all(a.map((e=>this.service.local.add(t,this.attach(t,e))))):await this.service.local.add(t,this.attach(t,a));const s=ibiz.uiDomainManager.get(t.srfsessionid);return s&&s.dataChange(),new p(i)}catch(t){throw new s(t)}}async getDraftTemp(t,e){try{const t=this.createEntity({});return t?new p(t):new p(t,500)}catch(t){return new p(t,500)}}async removeTemp(t,e){try{let a=null;e&&(a=e[this.entity.keyAppDEFieldId.toLowerCase()]),!a&&t&&(a=t[this.entity.codeName.toLowerCase()]);try{await this.associationDeletion(a,t,e)}catch(t){throw new s({response:new p(null,500,t.message)})}const i=this.service.local.delete(t,a);if(i){const e=ibiz.uiDomainManager.get(t.srfsessionid);return e&&e.dataChange(),new p(i)}return new p(i,500)}catch(t){throw new s(t)}}async associationDeletion(t,e,i){const s=ibiz.uiDomainManager.get(e.srfsessionid),n=s.transaction;let o=!1;!1===n.state.isOpen&&(n.open(),o=!0);try{let i=s.getDERConfigByMajor(this.entity.id);if(i.length>0){const s=this.service.local.get(e,t);i=mt(i,"removeOrder");for(const n of i){if("DER1N"!==n.rstype)throw new a(n,"目前只支持[DER1N]关系类型关联删除删除");const{removeActionType:i,removeRejectMsg:o,minorAppDataEntityId:r,nestedAppDEDataSetId:c="FetchDefault"}=n,d=ibiz.hub.getApp(this.entity.appId),l=await d.deService.getService(e,r),h=Z(e);h[this.entity.codeName.toLowerCase()]=t;const u=(await l.exec(c,h)).data||[];switch(i){case 1:for(let t=0;t<u.length;t++){const e=u[t];h[l.model.codeName.toLowerCase()]=e.srfkey;const a=await l.remove(h,e);if(!1===a.ok)throw new Error(a.statusText)}break;case 2:for(let t=0;t<u.length;t++){const e=u[t];h[l.model.codeName.toLowerCase()]=e.srfkey,e[n.parentAppDEFieldId.toLowerCase()]=void 0;const a=await l.updateTemp(h,e);if(!1===a.ok)throw new Error(a.statusText)}break;case 3:if(u.length>0){const t=u.map((t=>t.srfmajortext)).join("、"),e="无法删除[".concat(this.entity.logicName,"-").concat(s.srfmajortext,"], 数据被[").concat(l.model.logicName,"-").concat(t,"]引用");throw new Error(o||e)}}}}o&&n.state.isOpen&&n.commit()}catch(t){throw o&&n.state.isOpen&&n.rollback(),t}finally{o&&n.state.isOpen&&n.close()}}async updateTemp(t,e){try{const a=this.createEntity(e);let i;if(i=_(a)?await Promise.all(a.map((e=>this.service.local.update(t,this.attach(t,e))))):await this.service.local.update(t,this.attach(t,a)),i){const e=ibiz.uiDomainManager.get(t.srfsessionid);return e&&e.dataChange(),new p(i)}return new p(i,500)}catch(t){throw new s(t)}}async getTemp(t,e){try{let a=null;e&&(a=e[this.entity.keyAppDEFieldId.toLowerCase()]),!a&&t&&(a=t[this.entity.codeName.toLowerCase()]);const i=this.service.local.get(t,a);return i?new p(i):new p(i,500)}catch(t){throw new s(t)}}async removeBatchTemp(t,e){return new p(!0)}attach(t,e){const a=t.srfsessionid,i=ibiz.uiDomainManager.get(a).getDERConfig(this.entity.id);return i.length>0&&i.forEach((a=>{if(a.parentAppDEFieldId){const{majorAppDataEntityId:i,parentAppDEFieldId:s}=a,n=ve(i),o=s.toLowerCase(),r=t[n];r&&r!==e.srfkey&&(e[o]=r)}})),e}}),ao=class{create(t,e,a,i){return new eo(t,e,a,i.localMode)}},io=t("FetchMethod",class extends Tn{async exec(t,e,a,s){const n=e&&!_(e)?e:a||{};let o;if(this.isLocalMode){const e=Qs.getCond(this.method),a=new nn(t,n),i=await this.searchLocal(e,a);o=new p(i,200)}else{switch(this.method.dataSetType){case"INDEXDE":case"CODELIST":case"MULTIFORM":o=await this.fetchCodeListSet(t,n);break;case"REMOTE":{const i=this.calcPath(t);o=await this.request(i,t,e,a,s)}break;default:throw new i(this.method,"数据来源类型".concat(this.method.dataSetType,"暂未支持"))}const r=o.data||[];o.data=r.map((t=>this.createEntity(t)))}return o.data&&await to(this.entity,"compute",t,o.data,n),o}async searchLocal(t,e,a=this.entity.quickSearchAppDEFieldIds){let i=this.service.local.getList();t?i.length>0&&(i=i.filter((a=>t.test(a,e)))):i.length>0&&e.query&&""!==e.query&&a&&(i=i.filter((t=>{const i=new RegExp(e.query);for(let e=0;e<a.length;e+=1){const s=t[a[e]];if(i.test(s))return!0}return!1}))),Q(e.sortField)||J(e.sortField)||(i="DESC"===e.sortMode?ft(i,e.sortField):mt(i,e.sortField));const{page:s,size:n}=e,o=s*n,r=(s+1)*n-1;return i.slice(o,r).map((t=>Z(t)))}async fetchCodeListSet(t,e){const{appCodeListId:i}=this.method;if(!i)throw new a(this.method,"没有指定数据来源代码表");const s=await this.app.codeList.get(i,t,e),{keyAppDEFieldId:n,majorAppDEFieldId:o}=this.entity,r=s.map((t=>({[n]:t.value,[o]:t.text})));return new p(r,200)}}),so=t("AcFetchMethod",class extends io{mergeRequestPath(t,e){return"".concat(t,"/ac/").concat(e,"?srfac=ac")}}),no=class{create(t,e,a,i){return i.acMode?new so(t,e,a,i.localMode):new io(t,e,a,i.localMode)}};function oo(){const t=new ao;_s("DEACTION",(()=>t));const e=new no;_s("FETCH",(()=>e)),_s("FETCHTEMP",(()=>e))}var ro=t("InternalMessageService",class{constructor(){this.baseUrl="/extension/internal_messages"}async fetch(t={}){const e={page:0,size:20,sort:"update_time,desc"};Object.assign(e,t);const a=await ibiz.net.post("".concat(this.baseUrl,"/fetch_cur_receiver"),e);return a.headers&&(a.headers["x-page"]&&(a.page=Number(a.headers["x-page"])),a.headers["x-per-page"]&&(a.size=Number(a.headers["x-per-page"])),a.headers["x-total"]&&(a.total=Number(a.headers["x-total"]))),Q(a.data)&&(a.data=[]),a}async get(t){return await ibiz.net.get("".concat(this.baseUrl,"/").concat(t))}async markRead(t){await ibiz.net.post("".concat(this.baseUrl,"/").concat(t,"/mark_read"),{})}async batchMarkRead(){await ibiz.net.post("".concat(this.baseUrl,"/mark_all_read"),{})}async getUnreadNum(){const t=await ibiz.net.post("".concat(this.baseUrl,"/fetch_cur_receiver"),{page:0,size:1,sort:"update_time,desc",searchconds:[{condtype:"GROUP",condop:"AND",bnotmode:!1,searchconds:[{condop:"EQ",condtype:"DEFIELD",fieldname:"status",value:"RECEIVED"}]}]});return t.headers["x-total"]?Number(t.headers["x-total"]):0}}),co=t("MarkOpenDataService",class{constructor(){this.callbackMap=new Map,this.baseUrl="/portal/markopendata",ibiz.mc.command.markOpenData.on((t=>{const e=t.data,{entity:a,key:i}=e,s="".concat(a,"_").concat(i);this.callbackMap.has(s)&&this.callbackMap.get(s).forEach((t=>t(e)))}))}async action(t,e,a){return await ibiz.net.get("".concat(this.baseUrl,"/").concat(t,"/").concat(e,"/").concat(a))}async send(t,e,a,i){return await ibiz.net.post("".concat(this.baseUrl,"/").concat(t,"/").concat(e,"/").concat(a),i)}subscribe(t,e,a){const i="".concat(t,"_").concat(e),s=this.callbackMap.get(i)||[];s.push(a),this.callbackMap.set(i,s)}unsubscribe(t,e,a){const i="".concat(t,"_").concat(e),s=this.callbackMap.get(i)||[],n=s.indexOf(a);n>-1&&(s.splice(n,1),this.callbackMap.set(i,s))}}),lo=t("TreeNodeData",class{constructor(t,e,a){this._uuid=ct(),this._leaf=!1,this._leaf=!0===a.leaf,this._parent=e,this._nodeType=t.treeNodeType,this._disableSelect=!0===t.disableSelect,this._changedOnly=!0===t.enableRowEditChangedOnly,this._parent&&(this._context={...this._parent._context}),a.navContext&&(this._context=Object.assign(this._context||{},a.navContext)),a.navParams&&(this._params={...a.navParams}),this._nodeId=t.id,Object.defineProperty(this,"srfnodeid",{get(){return this._id},enumerable:!0,configurable:!0})}calcIcon(t){const{sysImage:e}=t,a={};return e&&(e.cssClass&&(a.cssClass=e.cssClass),e.imagePath&&(a.imagePath=e.imagePath),e.rawContent&&(a.htmlStr=e.rawContent)),Object.values(a).length>0?a:void 0}getDiffData(){if(this._deData&&this._oldDeData){const t={};return Object.keys(this._deData).forEach((e=>{this._deData[e]===this._oldDeData[e]&&e!==this._deData.srfkeyfield||(t[e]=this._deData[e])})),t.srfkey=this._deData.srfkey,t}return this._deData}}),ho=t("TreeCodeListNodeData",class extends lo{constructor(t,e,a){super(t,e,a);const{data:i}=a;this._text=i.text,this._value=i.value;const s="".concat(t.id,"@").concat(this._value).toLowerCase();if(Object.defineProperty(this,"_id",{get(){return this._parent?"".concat(this._parent._id,":").concat(s):s},enumerable:!0,configurable:!0}),t.appDataEntityId){const e=ve(t.appDataEntityId);this._context=Object.assign(this._context||{},{[e]:this._value})}this.srfkey=this._value,this.srfmajortext=this._text,this._icon=this.calcIcon(t)}}),uo=["_id","srfnodeid","_value","_text","_deData","clone"],po=t("TreeDataSetNodeData",class t extends lo{constructor(e,a,i){var s,n;super(e,a,i);const{data:o}=i;this._deData=o,this._oldDeData=o.clone();const r="".concat(e.id,"@").concat(o.srfkey).toLowerCase();if(Object.defineProperty(this,"_id",{get(){return this._parent?"".concat(this._parent._id,":").concat(r):r},enumerable:!0,configurable:!0}),Object.defineProperty(this,"_text",{get(){return e.textAppDEFieldId?this._deData[e.textAppDEFieldId]:this._deData.srfmajortext},set(t){e.textAppDEFieldId?this._deData[e.textAppDEFieldId]=t:this._deData.srfmajortext=t},enumerable:!0,configurable:!0}),Object.defineProperty(this,"_value",{get(){return e.idAppDEFieldId?this._deData[e.idAppDEFieldId]:this._deData.srfkey},set(t){e.idAppDEFieldId?this._deData[e.idAppDEFieldId]=t:this._deData.srfkey=t},enumerable:!0,configurable:!0}),e.appDataEntityId){const t=ve(e.appDataEntityId);this._context=Object.assign(this._context||{},{[t]:o.srfkey})}this._icon=this.calcIcon(e),this._textHtml=this.calcTextHtml(e),e.leafFlagAppDEFieldId?this._leaf=on(o[e.leafFlagAppDEFieldId]):e.childCntAppDEFieldId&&(this._leaf=!on(o[e.childCntAppDEFieldId]));const c=new Map,d=new Map;null==(s=e.detreeNodeDataItems)||s.forEach((t=>{if(!t.appDEFieldId)return;const e=t.id.toLowerCase(),a=t.appDEFieldId.toLowerCase();c.set(e,a),t.defaultValue&&d.set(e,t.defaultValue)}));const l=new Map;null==(n=e.detreeNodeColumns)||n.forEach((t=>{if("DEFGRIDCOLUMN"!==t.columnType)return;const e=t.detreeColumnId,a=t.dataItemName;e&&a?l.set(e,a):ibiz.log.error("模型异常缺少detreeColumnId或者dataItemName",t)}));const h=new Map;h.set("srfuf","srfuf");const u=t=>l.has(t)?c.get(l.get(t)):c.has(t)?c.get(t):Object.prototype.hasOwnProperty.call(this._deData,t)?t:h.has(t)?h.get(t):void 0;return this.clone=()=>{const a=Z(this._deData),i=new t(e,this._parent,{data:a,leaf:this._leaf,navContext:this._context,navParams:this._params});return Object.keys(this).forEach((t=>{const e=u(t);Q(e)&&!uo.includes(t)&&(i[t]=this[t])})),i},new Proxy(this,{set(t,e,a){const i=u(e);return Q(i)?t[e]=a:t._deData[i]=a,!0},get(t,e,a){const i=u(e);return Q(i)?t[e]:Q(t._deData[i])?(s=e,l.has(s)?d.get(l.get(s)):d.has(s)?d.get(s):void 0):t._deData[i];var s},ownKeys(t){const e=[...new Set([...Object.keys(t),...c.keys(),...Object.keys(t._deData)])];return m(t,e),e}})}calcIcon(t){const e=super.calcIcon(t)||{},{iconAppDEFieldId:a,detreeNodeDataItems:i}=t;if(a&&this._deData[a]){const t=this._deData[a];-1!==t.indexOf("fa-")?e.cssClass=t:e.imagePath=t}e&&(this._icon=e);const s=null==i?void 0:i.find((t=>"icon"===t.id));return s&&(e.htmlStr=this.calcDataItemScript(s)),Object.values(e).length>0?e:void 0}calcDataItemScript(t){if(t.customCode&&t.scriptCode)return Qe.execScriptFn({data:this._deData},t.scriptCode,{isAsync:!1})}calcTextHtml(t){let e;const{detreeNodeDataItems:a}=t,i=null==a?void 0:a.find((t=>"text"===t.id));return i&&(e=this.calcDataItemScript(i)),e}}),mo=t("TreeStaticNodeData",class extends lo{constructor(t,e,a){var i,s;super(t,e,a);const n="root"===t.nodeValue?void 0:t.nodeValue,o="".concat(t.id).toLowerCase();if(Object.defineProperty(this,"_id",{get(){return this._parent?"".concat(this._parent._id,":").concat(o):o},enumerable:!0,configurable:!0}),this._text=t.text,this._value=n,e&&a.parentValueLevel){let t=e;for(let e=1;e<a.parentValueLevel;e++)t=null==t?void 0:t._parent;(null==t?void 0:t._deData)&&(this._deData=t._deData),this._value=n||(null==t?void 0:t._value)}this.srfkey=(null==(i=this._deData)?void 0:i.srfkey)||this._value,this.srfmajortext=(null==(s=this._deData)?void 0:s.srfmajortext)||this._text,this._icon=this.calcIcon(t)}}),fo=t("UIMapField",class{constructor(t,e,a={}){this.isOriginField=!1,this.isRequestNeed=!0,this.uiKey=t,this.dataKey=e,Q(a.isOriginField)||(this.isOriginField=a.isOriginField),Q(a.dataType)||(this.dataType=a.dataType)}convertVal(t){if(!this.dataType)return t;if(l.isNumber(this.dataType)){const e=Q(t)||""===t?t:Number(t);return Number.isNaN(e)?(ibiz.log.debug("".concat(t,"不能转换成数字")),t):e}return t}}),go=t("CalendarItemData",class{constructor(t,e){this.model=t,this.data=e}get deData(){return this.data}get navId(){return"".concat(this.itemType,"@").concat(this.id)}get itemType(){return this.model.itemType}get bkColor(){const t=this.model.bkcolorAppDEFieldId;return t&&this.data[t]?this.data[t]:this.model.bkcolor}get beginTime(){const t=this.model.beginTimeAppDEFieldId;return t?this.data[t]:void 0}get color(){const t=this.model.colorAppDEFieldId;return t&&this.data[t]?this.data[t]:this.model.color}get content(){const t=this.model.contentAppDEFieldId;return t?this.data[t]:void 0}get endTime(){const t=this.model.endTimeAppDEFieldId;return t?this.data[t]:void 0}get icon(){const t=this.model.iconAppDEFieldId;return t?this.data[t]:void 0}get id(){const t=this.model.idAppDEFieldId;return t&&this.data[t]?this.data[t]:this.data.srfkey}get level(){const t=this.model.levelAppDEFieldId;return t?this.data[t]:void 0}get tag2(){const t=this.model.tag2AppDEFieldId;return t?this.data[t]:void 0}get tag(){const t=this.model.tagAppDEFieldId;return t?this.data[t]:void 0}get text(){const t=this.model.textAppDEFieldId;return t?this.data[t]:void 0}get tips(){const t=this.model.tipsAppDEFieldId;return t?this.data[t]:void 0}});var wo=["REGION","REGION2","REGION3","REGION4"],Eo=t("MapData",class{constructor(t,e){this._longitude=void 0,this._latitude=void 0,this._areaCode=void 0,this._tooltip=void 0,this._value=void 0,this._text=void 0,this._symbol=void 0;const{id:a,itemStyle:i,longitudeAppDEFieldId:s,latitudeAppDEFieldId:n,textAppDEFieldId:o,dataAppDEFieldId:r,tipsAppDEFieldId:c,sysImage:d}=e,l=new Map;return this._id=a+t.srfkey,this._itemStyle=i,this._mapItemId=a,wo.includes(this._itemStyle)?s&&l.set("_areaCode",s):(s&&l.set("_longitude",s),n&&l.set("_latitude",n)),c&&l.set("_tooltip",c),o&&l.set("_text",o),r&&l.set("_value",r),d&&(this._symbol=d.rawContent||d.imagePath),new Proxy(this,{set:(e,a,i)=>(Object.prototype.hasOwnProperty.call(t,a)?t[a]=i:l.has(a)?t[l.get(a)]=i:e[a]=i,!0),get:(e,a,i)=>void 0!==e[a]?e[a]:l.has(a)?t[l.get(a)]:void 0!==t[a]?t[a]:void 0,ownKeys(e){const a=[...new Set([...Object.keys(e),...Object.keys(t)])];return function(t,e){e.forEach((e=>{Object.prototype.hasOwnProperty.call(t,e)||Object.defineProperty(t,e,{enumerable:!0,configurable:!0,writable:!0,value:void 0})}))}(e,a),a}})}});var yo=t("PanelData",class{constructor(t,e){const a=new dt,i={},s={};return t.forEach((t=>{var e;i[t.id]=null==(e=t.viewFieldName)?void 0:e.toLowerCase(),t.viewFieldName&&(s[t.viewFieldName.toLowerCase()]=t.id)})),new Proxy(this,{set:(t,n,o)=>(Object.prototype.hasOwnProperty.call(i,n)?i[n]?e[i[n]]=o:t[n]=o:e[n]=o,a.emit("change",n),i[n]&&i[n]!==n&&a.emit("change",i[n]),s[n]&&s[n]!==n&&a.emit("change",s[n]),!0),get:(t,s,n)=>"_evt"===s?a:i[s]?e[i[s]]:Object.prototype.hasOwnProperty.call(e,s)?e[s]:t[s],ownKeys(t){const a=Object.keys(e);return function(t,e){e.forEach((e=>{Object.prototype.hasOwnProperty.call(t,e)||Object.defineProperty(t,e,{enumerable:!0,configurable:!0,writable:!0,value:void 0})}))}(t,a),a}})}destroy(){this._evt.reset()}});var vo=t("ChartData",class{constructor(t,e,a,i){return this._seriesModelId=null==e?void 0:e.id,this._catalog=a,this._groupName=i,this._uuid=ct(),new Proxy(this,{set:(e,a,i)=>(Object.prototype.hasOwnProperty.call(t,a)?t[a]=i:e[a]=i,!0),get:(e,a,i)=>void 0!==e[a]?e[a]:void 0!==t[a]?t[a]:void 0,ownKeys(e){const a=[...new Set([...Object.keys(e),...Object.keys(t)])];return function(t,e){e.forEach((e=>{Object.prototype.hasOwnProperty.call(t,e)||Object.defineProperty(t,e,{enumerable:!0,configurable:!0,writable:!0,value:void 0})}))}(e,a),a}})}}),Io=(t,e,a={})=>{let i="";if(!t||!e.detreeNodeDataItems)return i;const s=e.detreeNodeDataItems.find((e=>e.detreeColumnId===t));return s&&s.appDEFieldId&&(i=a[s.appDEFieldId.toLowerCase()]),i},Do=t("GanttStaticNodeData",class extends mo{constructor(t,e,a,i){super(e,a,i),this._snDataItemValue=Io(t.sndataItemName,e),this._beginDataItemValue=Io(t.beginDataItemName,e),this._endDataItemValue=Io(t.endDataItemName,e),this._prevDataItemValue=Io(t.prevDataItemName,e),this._finishDataItemValue=Io(t.finishDataItemName,e),this._totalDataItemValue=Io(t.totalDataItemName,e)}}),Co=t("GanttDataSetNodeData",class extends po{constructor(t,e,a,i){super(e,a,i);const{data:s}=i;this._snDataItemValue=Io(t.sndataItemName,e,s),this._beginDataItemValue=Io(t.beginDataItemName,e,s),this._endDataItemValue=Io(t.endDataItemName,e,s),this._prevDataItemValue=Io(t.prevDataItemName,e,s),this._finishDataItemValue=Io(t.finishDataItemName,e,s),this._totalDataItemValue=Io(t.totalDataItemName,e,s)}}),bo=t("GanttCodeListNodeData",class extends ho{constructor(t,e,a,i){super(e,a,i);const{data:s}=i;this._snDataItemValue=Io(t.sndataItemName,e,s),this._beginDataItemValue=Io(t.beginDataItemName,e,s),this._endDataItemValue=Io(t.endDataItemName,e,s),this._prevDataItemValue=Io(t.prevDataItemName,e,s),this._finishDataItemValue=Io(t.finishDataItemName,e,s),this._totalDataItemValue=Io(t.totalDataItemName,e,s)}}),Ao=t("MqttService",class{constructor(t,e,a){this.mqttTopic=t,this.token=e,this.appId=a,this.evt=new dt,this.options={connectTimeout:6e3,clientId:ct(),username:"",password:"",keepalive:60,clean:!0},this.options.username=t,this.options.password=e}async connect(){const t=await e.import("mqtt/dist/mqtt.min"),a=t.default?t.default:t,{location:i}=window;this.client=a.connect("ws://".concat(i.host).concat(ibiz.env.baseUrl,"/").concat(this.appId).concat(ibiz.env.mqttUrl),this.options),this.client.on("connect",(()=>{this.client.subscribe(this.mqttTopic),ibiz.log.debug("mqtt connect")})),this.client.on("error",(t=>{ibiz.log.error("mqtt error",t)})),this.client.on("message",((t,e)=>{this.evt.emit("message",JSON.parse(e.toString())),ibiz.log.debug("mqtt message",t,e.toString())})),this.client.on("reconnect",(()=>{ibiz.log.warn("mqtt reconnect")})),this.client.on("close",(()=>{ibiz.log.warn("mqtt close")}))}close(){var t;null==(t=this.client)||t.end(),this.evt.reset()}}),Po=class t{constructor(t){this.appModel=t,this.cache=new Map}static register(t,e){this.constructorCache.set(t.toUpperCase(),e)}async getService(e,a){const i=e.srfsessionid||"applocation";this.cache.has(i)||this.cache.set(i,new Map);const s=this.cache.get(i);if(!s.has(a)){const e=await ibiz.hub.getAppDataEntity(a,this.appModel.appId);if(!e)throw new o("未找到应用实体[".concat(a,"]"));const n=t.constructorCache.get(a.toUpperCase());let r;r=n?await n(i,e):new gn(i,e),s.set(a,r)}return s.get(a)}reset(t){const e=t.srfsessionid;if(!this.cache.has(e))return;this.cache.get(e).forEach((t=>{t.destroy()})),this.cache.delete(e)}clearTempCache(t){const e=t.srfsessionid;if(!this.cache.has(e))return;this.cache.get(e).forEach((t=>{t.local.clear()}))}clearTempCacheByRs(t,e,a=[]){if(!0===a.includes(e))return;a.push(e);const i=t.srfsessionid;if(!this.cache.has(i))return;const s=this.cache.get(i).get(e);s&&s.local.clear();const n=ibiz.uiDomainManager.get(t.srfsessionid);if(n){n.getDERConfigByMajor(e).forEach((e=>{this.clearTempCacheByRs(t,e.minorAppDataEntityId,a)}))}}async exec(t,e,a,i,s,n){return(await this.getService(a,t)).exec(e,a,i,s,n)}};Po.constructorCache=new Map;var To=t("DEServiceUtil",Po),xo=class t{constructor(){ibiz.commands.register(t.TAG,this.exec.bind(this))}async exec(t,e,a={},s={}){const n=Z(e);n.srfsimple&&delete n.srfsimple;const r=await ibiz.hub.config.view.get(t);if(!r)throw new o("应用视图[".concat(t,"]不存在"));if((n.srfkey||0===a.srfuf)&&r.appDataEntityId){const t=ve(r.appDataEntityId);n.srfkey&&(n[t]=n.srfkey,n.srfkey=void 0),0===a.srfuf&&(n[t]=void 0,delete a.srfuf)}if(r.redirectView){return We(await ibiz.hub.getAppView(t),n,a,s)}const{openMode:c="INDEXVIEWTAB"}=r,d=s.openMode||c;switch(void 0!==d&&"INDEXVIEWTAB"!==d&&n.toRouteDepth&&(n.toRouteDepth=void 0),d){case"INDEXVIEWTAB":case"INDEXVIEWTAB_POPUP":return s.noWaitRoute?(this.openIndexViewTab(r,n,a),{ok:!0}):this.openIndexViewTab(r,n,a,s);case"INDEXVIEWTAB_POPUPMODAL":return this.openIndexViewTabByModal(r,n,a);case"POPUP":throw new i(r,"未支持的视图打开模式: POPUP");case"POPUPMODAL":return this.openModal(r,n,a);case"POPUPAPP":throw new i(r,"未支持的视图打开模式: POPUPAPP");case"POPOVER":return this.openPopover(r,n,a,s);case"DRAWER_LEFT":case"DRAWER_RIGHT":case"DRAWER_TOP":case"DRAWER_BOTTOM":return this.openDrawer(r,n,a);case"USER":return this.openUserCustom(r,n,a);default:return this.openIndexViewTab(r,n,a)}}openIndexViewTab(t,e,a={},i={}){return ibiz.openView.root(t.id,e,a,i)}openIndexViewTabByModal(t,e,a={}){return ibiz.openView.rootByModal(t.id,e,a)}async openModal(t,e,a={}){return ibiz.openView.modal(t.id,e,a)}async openPopover(t,e,a={},i={}){const{event:s,modalOption:n}=i;if(!s)throw new o("气泡打开缺少event");return ibiz.openView.popover(t.id,s,e,a,{...n})}async openDrawer(t,e,a={}){return ibiz.openView.drawer(t.id,e,a)}async openUserCustom(t,e,a={}){return ibiz.openView.custom(t.id,e,a)}};xo.TAG="ibiz.app-view.open";var So=t("OpenAppViewCommand",xo),No=class t{constructor(){ibiz.commands.register(t.TAG,this.exec.bind(this))}async exec(t,e,a={},s={}){const n=(await ibiz.hub.getAppAsync(e.srfappid)).getAppFunc(t);if(!n)throw new o("找不到叫".concat(t,"的应用功能"));const{navigateContexts:r,navigateParams:c,appFuncType:d}=n,l=e.clone();Object.assign(l,oe(r,a,e));const h=oe(c,a,e);switch(Object.assign(h,a),d){case"APPVIEW":return this.openAppView(n,l,h,s);case"OPENHTMLPAGE":return this.openHtmlPage(n);case"PDTAPPFUNC":return this.openPdAppFunc(n,l,h);case"JAVASCRIPT":return this.executeJavaScript(n,l,h);case"CUSTOM":return this.custom(n,l,h);default:throw new i(n,"未支持的应用功能类型: ".concat(d))}}async openAppView(t,e,a,i){if(!t.appViewId)throw new o("应用视图[".concat(t.appViewId,"]不存在"));return ibiz.commands.execute(So.TAG,t.appViewId,e,a,i)}openHtmlPage(t){const e=t.htmlPageUrl;window.open(e,"_blank")}openPdAppFunc(t,e,a){throw ibiz.log.warn("openPdAppFunc",t,e,a),new o("未实现")}executeJavaScript(t,e,a){throw ibiz.log.warn("executeJavaScript",t,e,a),new o("未实现")}custom(t,e,a){throw ibiz.log.warn("custom",t,e,a),new o("未实现")}};No.TAG="ibiz.app-func.exec";var Ro=t("AppFuncCommand",No);function Mo(){new Ro,new So}var Oo=t("Application",class{constructor(t){this.model=t,this.deName2DeCodeName=new Map,this.net=new f({baseURL:"".concat(ibiz.env.baseUrl,"/").concat(this.appId)}),this.configCache=new dn(this.appId,"PSSysApp",t.codeName),this.deService=new To(t),this.codeList=new cn(t),this.authority=new Dn(t)}get appId(){return this.model.appId||ibiz.env.appId}async init(){await this.authority.init(),await this.loadAppModelStyle(),await this.initMqtt()}async loadAppModelStyle(){const t=await ibiz.hub.getAppStyle(this.appId);if(t){const e=document.createElement("style");e.setAttribute("type","text/css"),e.id=this.appId,e.innerHTML=t,document.head.appendChild(e)}}getAppFunc(t){return(this.model.appFuncs||[]).find((e=>e.id===t))||null}async getUIAction(t){const[,e]=t.split("@");if(e){const a=(await ibiz.hub.getAppDataEntity(e,this.appId)).appDEUIActions.find((e=>e.id===t));if(a)return a}return this.model.appDEUIActions.find((e=>e.id===t))}async getOPPriv(t,e){var a,i;let s=null==(a=this.model.deopprivs)?void 0:a.find((e=>e.name===t));if(!s&&e){s=null==(i=(await ibiz.hub.getAppDataEntity(e,this.appId)).deopprivs)?void 0:i.find((e=>e.name===t))}return s}async getDEUILogic(t,e){return(await ibiz.hub.getAppDataEntity(e,this.appId)).appDEUILogics.find((e=>e.id===t))}async initMqtt(){this.mqtt&&this.mqtt.close(),ibiz.env.enableMqtt&&ibiz.appData&&ibiz.appData.mqtttopic&&!0!==ibiz.auth.isAnonymous&&(this.mqtt=new Ao(ibiz.appData.mqtttopic,g(),this.appId),this.mqtt.evt.on("message",(t=>{ibiz.mc.command.next(t)})),await this.mqtt.connect())}destroy(){this.codeList.destroy()}}),Lo=class{parse(t){return t}},_o=class{constructor(){this.appMenu=new Lo}},Fo=class{constructor(){this.viewConfigs=new Map}calcAppViewId(t){let e="";if(-1!==t.indexOf(".")){const a=t.split(".");e=a[a.length-1]}else e=t.toLowerCase();return e}getCustomOption(t){var e;const{appViewParams:a,userParam:i}=t;let s=null==(e=null==a?void 0:a.find((t=>"modaloption"===t.id)))?void 0:e.value;!s&&i&&(s=i.modalOption);let n={};if(s)try{n=JSON.parse(s)}catch(t){ibiz.log.error("视图参数modalOption 解析失败:".concat(t))}return{modalOption:n}}has(t){const e=this.calcAppViewId(t);return this.viewConfigs.has(e)}set(t,e){const a=this.calcAppViewId(t);this.viewConfigs.set(a,e)}async get(t){const e=this.calcAppViewId(t);if(!this.viewConfigs.has(e)){const t=await ibiz.hub.getAppView(e);if(!t)throw new o("视图[".concat(e,"]不存在"));this.set(t.id,{id:t.id,appId:t.appId,codeName:t.codeName,openMode:t.openMode,viewType:t.viewType,width:t.width,height:t.height,appDataEntityId:t.appDataEntityId,redirectView:t.redirectView,...this.getCustomOption(t)})}return this.viewConfigs.get(e)}getSync(t){return this.viewConfigs.has(t)?this.viewConfigs.get(t):null}},Vo=class{constructor(){this.view=new Fo}},ko=t("FormNotifyState",(t=>(t.LOAD="LOAD",t.DRAFT="DRAFT",t.SAVE="SAVE",t))(ko||{})),zo=t("GridNotifyState",(t=>(t.LOAD="LOAD",t.DRAFT="DRAFT",t.SAVE="SAVE",t))(zo||{})),Wo=t("PanelNotifyState",(t=>(t.LOAD="LOAD",t.DRAFT="DRAFT",t.SAVE="SAVE",t))(Wo||{})),Uo=t("TreeGridExNotifyState",(t=>(t.LOAD="LOAD",t.SAVE="SAVE",t.DRAFT="DRAFT",t))(Uo||{})),Bo=t("Counter",class{constructor(t){this.callback=t,this.count=0,this.state="Unused",this.reusable=!0}increment(){return"Used"===this.state||(this.count+=1),this.count}decrement(t){if("Used"!==this.state){if(0===this.count)throw new o("错误的调用!decrement不能对count为0调用");this.count-=1,0===this.count&&(t?t():this.callback&&this.callback(),this.reusable||(this.state="Used"))}}destroy(){this.callback=void 0}}),Go=t("LoadingState",class{constructor(){this.isLoading=!1,this.counter=new Bo(w)}begin(){this.isLoading=!0,this.counter.increment()}end(){this.counter.decrement((()=>{this.isLoading=!1}))}}),jo=t("CTXState",class{}),Ko=t("CTX",class{constructor(t){this.parent=t,this.isDestroyed=!1,this.evt=new dt(3e3),this.controllersMap=new Map,this.state=new jo}async init(t){this.view=t,this.registerController(t.model.name,t)}destroy(){this.controllersMap.clear(),this.view=null,this.state=null,this.isDestroyed=!0}async setState(t){Object.assign(this.state,t)}startLoading(){this.view.startLoading()}endLoading(){this.isDestroyed||this.view.endLoading()}registerController(t,e){this.controllersMap.set(t,e),this.evt.emit("onRegister",t,e)}getController(t,e=!1){return this.controllersMap.has(t)?this.controllersMap.get(t):this.parent&&e?this.parent.getController(t):void 0}getTopView(){return this.parent?2===this.view.modal.routeDepth?this.view:this.parent.getTopView():this.view}}),Xo=t("ActivityCounter",class extends Bo{constructor(){super(...arguments),this.reusable=!1,this.registration=new Map}enroll(t){"Unused"!==this.state||this.registration.has(t)||(this.registration.set(t,!1),this.increment())}attend(t){this.registration.has(t)&&!1===this.registration.get(t)&&(this.registration.set(t,!0),this.decrement())}}),Ho=t("UIActionButtonState",class{constructor(t,e,a){this.disabled=!1,this.visible=!0,this.loading=!1,this.permitted=!0,this.noPermissionHidden=!0,this.noDataDisabled=!1,this.noKeyDisabled=!1,this.isInit=!1,this.name=t,this.uiActionId=a,this.appId=e}async init(){if(!this.uiActionId)return void(this.isInit=!0);const t=await Ae(this.uiActionId,this.appId);if([,this.appDeName]=this.uiActionId.split("@"),!t)return;const{dataAccessAction:e,noPrivDisplayMode:a,actionTarget:i,uiactionMode:s,uiactionTag:n}=t;this.dataAccessAction=e,1===a?this.noPermissionHidden=!1:6===a&&(this.visible=!1),[2,6].includes(a)&&this.dataAccessAction&&(this.visible=!1),(i&&"NONE"!==i||"SYS"===s&&["Save","SaveAndExit","SaveAndNew","Edit","Remove","RemoveAndExit"].includes(n))&&(this.noDataDisabled=!0,"SINGLEKEY"!==i&&"MULTIKEY"!==i||(this.noKeyDisabled=!0)),this.isInit=!0}async calcPermission(t,e,a){if(!this.dataAccessAction)return;const i=await ibiz.hub.getApp(this.appId);this.appDeName&&a&&!a.includes(this.appDeName)&&ibiz.log.warn("".concat(this.uiActionId,"界面行为的实体").concat(this.appDeName,"和数据的实体").concat(a,"不一致")),this.permitted=await i.authority.calcByDataAccessAction(this.dataAccessAction,t,e,a)}async update(t,e,a){this.isInit||await this.init(),await this.calcPermission(t,e,a),this.permitted?(this.visible=!0,this.disabled=this.noDataDisabled&&(!e||this.noKeyDisabled&&!e.srfkey)):(this.disabled=!0,this.visible=!this.noPermissionHidden)}}),qo=t("ButtonContainerState",class{constructor(){Object.defineProperty(this,"children",{enumerable:!1,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"visible",{enumerable:!0,configurable:!0,get:()=>0!==this.children.length&&!!this.children.find((t=>t.visible))})}addState(t,e){Object.defineProperty(this,t,{enumerable:!0,configurable:!0,writable:!0,value:e}),this.children.push(e)}setLoading(t){this.children.forEach((e=>{e.setLoading?e.setLoading(t):e.loading=!!t&&e.name===t}))}async update(t,e,a){await Promise.all(this.children.map((i=>i.update(t,e,a))))}async init(){await Promise.all(this.children.map((t=>t.init())))}}),Yo=t("QXEventEx",class extends dt{constructor(){super(...arguments),this.anyEventFns=[]}onAll(t){this.anyEventFns.includes(t)||this.anyEventFns.push(t)}emit(t,...e){super.emit(t,...e),this.anyEventFns.forEach((a=>{a(t,...e)}))}async asyncEmit(t,...e){const a=super.asyncEmit(t,...e),i=this.anyEventFns.map((a=>a(t,...e))),s=Promise.all(i),n=await a,o=await s;return n.concat(...o)}reset(){super.reset(),gt(this.anyEventFns)}}),Qo=t("ControllerEvent",class{constructor(t){this.getBaseArgs=t,this.isDestroyed=!1,this.evt=new Yo}async emit(t,e){this.isDestroyed||await this.evt.asyncEmit(t,{...this.getBaseArgs(),eventName:t,...e||{}})}on(t,e){this.isDestroyed||this.evt.on(t,e)}off(t,e){this.isDestroyed||this.evt.off(t,e)}onAll(t){this.isDestroyed||this.evt.onAll(t)}destroy(){this.getBaseArgs=void 0,this.evt.reset(),this.isDestroyed=!0}});function $o(t){return window.location.hash.split("/").length>2*t+2}function Jo(t,e){return(!Q(t)&&""!==t||!Q(e)&&""!==e)&&t!==e}function Zo(t){let e=Array.isArray(t)?t[0]:t;return e&&e instanceof En&&(e=e.getOrigin()),e}function tr(t,e,a){const i=[];return t.forEach((t=>{const{valueRuleType:s}=t,n=t.sysValueRule,r=t.defvalueRule;if("SYSVALUERULE"===s&&n)"REG"===n.ruleType||"REGEX"===n.ruleType?i.push({pattern:new RegExp(n.regExCode),message:n.ruleInfo,trigger:"change blur"}):"SCRIPT"===n.ruleType&&i.push({validator:(t,e,a,i)=>{if(!e)return!0;try{Qe.execScriptFn({rule:t,value:e,callback:a,source:i},n.scriptCode,{isAsync:!1})}catch(t){return console.error(t),!1}return!0},trigger:"change blur"});else if("DEFVALUERULE"===s&&r){const t=a||e;i.push({validator:(e,a,i,s)=>{if(ot(s[t]))return!0;const{isPast:n,infoMessage:c}=$e(t,s,r.groupCond);return n||i(new o(c||r.ruleInfo)),!0},trigger:"change blur"})}})),i}function er(t){const e=[],{maxLength:a,minLength:i}=t,{maxValue:s,minValue:n}=t;return a&&e.push({validator:(t,e,i)=>{if(Q(e)||!(e.length>a))return!0;i(new Error("内容长度必须小于等于".concat(a,",当前长度为").concat(e.length)))}}),i&&e.push({validator:(t,e,a)=>{if(Q(e)||!(e.length<i))return!0;a(new Error("内容长度必须大于等于".concat(i,",当前长度为").concat(e.length)))}}),Q(s)||e.push({validator:(t,e,a)=>{if(!(!Q(e)&&wt(e)&&e>s))return!0;a(new Error("值必须小于等于".concat(s)))}}),Q(n)||e.push({validator:(t,e,a)=>{if(!(!Q(e)&&wt(e)&&e<n))return!0;a(new Error("值必须大于等于".concat(n)))}}),e}var ar=t("ValueExUtil",class{static mergeDefault(t){return at(t,{textSeparator:",",valueSeparator:","})}static toText(t,e){if(Q(e)||""===e)return"";const{valueType:a,objectNameField:i,textSeparator:s}=this.mergeDefault(t);if(["OBJECTS","OBJECT"].includes(a)){if(!i)throw new o("缺少objectNameField");const t=i.toLowerCase();return"OBJECTS"===a?e.map((e=>e[t]||"---")).join(s):e[t]}return"SIMPLES"===a?e.join(s):"".concat(e)}});function ir(t,e){var a;const{name:s,valueType:n,defaultValue:r,valueFormat:c}=t,{data:d,context:l,params:h}=e;if(Q(n)&&Q(r))return;if("RESET"===n)return null;const u=d[s];if(!it(u)){if(!n&&r)return r;switch(n){case"APPDATA":if(Object.prototype.hasOwnProperty.call(h,r))return h[r];if(Object.prototype.hasOwnProperty.call(l,r))return l[r];break;case"OPERATORNAME":return l.srfusername;case"OPERATOR":return l.srfuserid;case"CURTIME":return yt().format(c);case"PARAM":return d[r];case"SESSION":case"APPLICATION":if(!(null==(a=ibiz.appData)?void 0:a.context))throw new o("appdata.context不存在");return ibiz.appData.context[r];case"CONTEXT":return h[r];case"UNIQUEID":return ct();default:throw new i({},"默认值类型[".concat(n,"]未支持"))}}}var sr="asyncimportdata2",nr="importdata2";async function or(t,e,a,i){ibiz.notification.info({desc:ibiz.i18n.t("component.dataImport.startImport")});const s=new FormData;s.append("file",t);let n="/".concat(e.deapicodeName2,"/").concat(sr);if((null==a?void 0:a.codeName)&&(n+="?srfimporttag=".concat(a.codeName)),i){n=sn(i,e)+n}const o=await ibiz.net.request(n,{method:"post",data:s,headers:{"Content-Type":"multipart/form-data"}});var r;await(r=o.data.asyncacitonid,new Promise((t=>{const e=a=>{const i=a.messageid||a.data.asyncacitonid;if(r!==i)return;const s=a.data.actionstate;30!==s&&40!==s||(t(),ibiz.mc.command.asyncAction.off(e))};ibiz.mc.command.asyncAction.on(e)}))),ibiz.mc.command.send({srfdecodename:e.codeName},"OBJECTCREATED","DATAIMPORT")}async function rr(t,e,a,i){const s=new FormData;s.append("file",t);let n="/".concat(e.deapicodeName2,"/").concat(nr);if((null==a?void 0:a.codeName)&&(n+="?srfimporttag=".concat(a.codeName)),i){n=sn(i,e)+n}const o={isAsync:!1};try{const t=await ibiz.net.request(n,{method:"post",data:s,headers:{"Content-Type":"multipart/form-data"}});ibiz.mc.command.send({srfdecodename:e.codeName},"OBJECTCREATED","DATAIMPORT"),Object.assign(o,t.data)}catch(t){t instanceof Error&&(o.errorMessage=t.message)}return o}async function cr(t){const e={isAsync:ibiz.env.enableMqtt};if(ibiz.env.enableMqtt)or(t.selectedFile,t.appDataEntity,t.dataImport,t.context);else{const a=await rr(t.selectedFile,t.appDataEntity,t.dataImport,t.context);Object.assign(e,a)}return e}async function dr(t,e,a){if(!ibiz.util.getExcelUtil)throw new o("ibiz.util.getExportExcel不存在");const i=await ibiz.util.getExcelUtil();if(!i)throw new o("导出模块加载错误");try{return i.exportJsonToExcel({header:t,data:e,filename:a,autoWidth:!0}),{ok:!0}}catch(t){return{ok:!1}}}async function lr(t){var e;const a=await ibiz.hub.getAppDataEntity(t.appDataEntityId,t.appId),i=null==(e=a.appDEDataImports)?void 0:e.find((e=>e.id===t.deDataImportId));if(!i)throw new o("没有找到对应的导入数据模型");return{deDataImport:i,appDataEntity:a}}async function hr(t){const{deDataImportId:e,appDataEntityId:a,context:i,params:s}=t,n=t.dataImportViewId||"AppDataUploadView";let o=null;try{o=await ibiz.hub.config.view.get(n)}catch(e){if(t.dataImportViewId)throw e}if(o)return i.srfappdataentityid=a,i.srfdedataimportid=e,ibiz.commands.execute(So.TAG,o.id,i,s,{openMode:"POPUPMODAL"});const{deDataImport:r,appDataEntity:c}=await lr({deDataImportId:e,appDataEntityId:a,appId:i.srfappid}),d=r.enableCustomized?"DataImport2":"DataImport",l=ibiz.overlay.createModal(d,{dismiss:()=>l.dismiss(),dataImport:r,appDataEntity:c,context:i,params:s},{width:"auto",placement:"center"});l.present(),await l.onWillDismiss()}async function ur(t,e){var a;let i="".concat(t.codeName2.toLowerCase(),"/importtemplate");(null==e?void 0:e.codeName)&&(i+="?srfimporttag=".concat(e.codeName));const s=await ibiz.net.request(i,{responseType:"blob"});if(200===s.status){let t=(null==(a=s.headers["content-disposition"].split(";").find((t=>-1!==t.indexOf("filename="))))?void 0:a.slice(9))||"";t=decodeURIComponent(t);const e=new Blob([s.data],{type:"application/vnd.ms-excel"}),i=document.createElement("a");i.download=t,i.style.display="none",i.href=URL.createObjectURL(e),document.body.appendChild(i),i.click(),URL.revokeObjectURL(i.href),document.body.removeChild(i)}}async function pr(t){return new Promise((e=>{E({accept:".xlsx, .xls",multiple:!1,onSelected:async a=>{const i=await cr({selectedFile:a[0],appDataEntity:t.appDataEntity,dataImport:t.dataImport,context:t.context});e(i)},onCancel:()=>{e({cancel:!0})}})}))}async function mr(t){var e;let a="/".concat(t.appDataEntity.codeName2.toLowerCase());if(t.context){a=sn(t.context,t.appDataEntity)+a}const i="".concat(a,"/asyncimportdata2"),s={srfossfileid:t.fileId,srfimportschemaid:t.schemaId},n=(null==(e=t.dataImport)?void 0:e.id)||t.appDataEntity.defaultAppDEDataImportId;n&&Object.assign(s,{srfimporttag:n}),await ibiz.net.request(i,{method:"get",params:s}),ibiz.notification.info({desc:ibiz.i18n.t("component.dataImport.startImport")})}function fr(t){var e,a,i,s;let n={system_tag:null==(e=ibiz.appData)?void 0:e.context.srfsystemid,data_entity_tag:null==(a=t.appDataEntity)?void 0:a.codeName,import_tag:(null==(i=t.dataImport)?void 0:i.id)||(null==(s=t.appDataEntity)?void 0:s.defaultAppDEDataImportId),owner_type:"PERSONAL"};return n=$(n,t.data),n}async function gr(t,e){const a=ibiz.hub.getApp(e.srfappid),i=await ibiz.hub.getAppDataEntity(t,e.srfappid);let s="/jsonschema/".concat(i.name);0===i.dynaSysMode&&ibiz.appData&&(s+="?dynamodeltag=".concat(ibiz.appData.dynamodeltag));return(await a.net.get(s)).data}var wr="__self",Er=t("BaseController",class{constructor(t,e,a,i){this.model=t,this.params=a,this.ctx=i,this.id=ct(),this.state={},this.name="",this.evt=new Qo(this.getEventArgs.bind(this)),this.mountCounter=new Xo(this.mounted.bind(this)),this.childNames=[],this.name=t.name||t.id,this.state.context=e,this.preprocessModel(t),this.initState(),this.convertMultipleLanguages()}get _evt(){return this.evt}get context(){return this.state.context}preprocessModel(t){}initState(){this.state.isCreated=!1,this.state.isMounted=!1,this.state.isDestroyed=!1}getEventArgs(){return{context:this.context,params:this.params,data:[],targetName:this.model.name,view:this.ctx.view}}async created(){this.mountCounter.enroll(wr),await this.onCreated(),this.state.isCreated=!0,this.force((()=>{this.mountSelf()})),ibiz.log.debug("".concat(this.constructor.name,":").concat(this.name," onCreated")),this._evt.emit("onCreated",void 0)}async onCreated(){this.ctx.evt.on("onForecast",(t=>{this.childNames.includes(t)&&this.mountCounter.enroll(t)})),this.ctx.evt.on("onRegister",((t,e)=>{this.childNames.includes(t)&&e.evt.on("onMounted",(()=>{this.mountCounter.attend(t)}))}))}async mountSelf(){this.mountCounter.registration.get(wr)||this.mountCounter.attend(wr)}async mounted(){await this.onMounted(),this.state.isMounted=!0,ibiz.log.debug("".concat(this.constructor.name,":").concat(this.name," onMounted")),this._evt.emit("onMounted",void 0)}async onMounted(){}async destroyed(){await this.onDestroyed(),this.state.isDestroyed=!0,ibiz.log.debug("".concat(this.constructor.name,":").concat(this.name," onDestroyed")),await this._evt.emit("onDestroyed",void 0),this.evt.destroy()}async onDestroyed(){}force(t){}getController(t,e=!1){return this.ctx.getController(t,e)}getTopView(){return this.ctx.getTopView()}listenNewController(t){this.ctx.evt.on("onRegister",t)}convertMultipleLanguages(){}}),yr=class t{constructor(t){this.msgGroupId=t,this.viewMsgMap=new Map}async init(t){var e,a;const i=ibiz.hub.getApp(t.srfappid).model,s=null==(e=i.appViewMsgGroups)?void 0:e.find((t=>t.id===this.msgGroupId));if(!s)throw new o("找不到视图消息组".concat(this.msgGroupId,"的模型"));this.msgGroup=s;const n=s.appViewMsgGroupDetails.map((t=>t.appViewMsgId));if(null==(a=i.appViewMsgs)||a.forEach((t=>{const e=n.indexOf(t.id);-1!==e&&(this.viewMsgMap.set(t.id,t),n.splice(e,1))})),n.length)throw new o("没有找到".concat(n.join(","),"视图消息模型"))}getDeFieldName(t,e){var a,i;if(e)return null==(i=null==(a=be(t,e))?void 0:a.name)?void 0:i.toLowerCase()}static async fetchDataSet(t,e,i){const{appDataEntityId:s,appDEDataSetId:n}=t;if(!n)throw new a(t,"未配置实体数据集");const o=await ibiz.hub.getApp(e.srfappid).deService.exec(s,n,e,i);return o.data.length?o.data:[]}async calcViewMessages(t,e){const a=this.msgGroup.appViewMsgGroupDetails,i=[];return(null==a?void 0:a.length)&&await Promise.all(a.map((async a=>{if(1===this.viewMsgMap.get(a.appViewMsgId).dynamicMode){const s=await this.calcDynaMsgs(a,t,e);i.push(...s)}else{const t=this.calcStaticMsg(a);i.push(t)}}))),i}calcStaticMsg(t){const{position:e}=t,a=this.viewMsgMap.get(t.appViewMsgId),{title:i,message:s,removeMode:n,position:o,messageType:r}=a,{userTag:c,userTag2:d,userTag3:l,userTag4:h}=a;return{title:i,message:s,position:e||o,messageType:r,removeMode:n,extraParams:{userTag:c,userTag2:d,userTag3:l,userTag4:h}}}async calcDynaMsgs(e,i,s){const n=this.viewMsgMap.get(e.appViewMsgId),{appDataEntityId:o,orderValueAppDEFieldId:r,titleAppDEFieldId:c,removeFlagAppDEFieldId:d,msgTypeAppDEFieldId:l,contentAppDEFieldId:h,msgPosAppDEFieldId:u}=n;if(!o)throw new a(n,"未配置应用实体");const p=await ibiz.hub.getAppDataEntity(o,i.srfappid),m={...s},f=this.getDeFieldName(p,r);f&&(m.sort="".concat(f,",asc"));const g=await t.fetchDataSet(n,i,m);if(!g.length)return[];const w=this.calcStaticMsg(e),E=this.getDeFieldName(p,c),y=this.getDeFieldName(p,u),v=this.getDeFieldName(p,h),I=this.getDeFieldName(p,l),D=this.getDeFieldName(p,d);return g.map((t=>{const e={};return y&&!Q(t[y])&&(e.position=t[y]),E&&!Q(t[E])&&(e.title=t[E]),v&&!Q(t[v])&&(e.message=t[v]),I&&!Q(t[I])&&(e.messageType=t[I]),D&&!Q(t[D])&&(e.removeMode=t[D]),$(w,e)}))}},vr=t("ViewController",class extends Er{constructor(t,e,a,i){super(ibiz.util.layoutPanel.fill(t),d.create({},e),a||{},new Ko(i)),this.session={},this.modal=new fa({}),this.providers={},this.engines=[],this.slotProps={},this.counters={},this.viewLoading=new Go,this.isCloseView=!1,i&&i.registerController(this.model.name,this),this.ctx.init(this),this.initEngines()}get _evt(){return this.evt}get parentView(){var t;return null==(t=this.ctx.parent)?void 0:t.view}get isActive(){return this.state.activated}onActivated(){this.state.activated=!0,ibiz.log.debug("视图[".concat(this.model.name,"](").concat(this.model.id,")激活"))}onDeactivated(){this.state.activated=!1,ibiz.log.debug("视图[".concat(this.model.name,"](").concat(this.model.id,")暂停"))}initEngines(){const t=Le(this.model);if(t.length)t.forEach((t=>{const e=ibiz.engine.getEngine(t,this);e?this.engines.push(e):ibiz.log.warn("未找到视图引擎实现:",t)}));else{const t=ibiz.engine.getEngine({engineCat:"VIEW",engineType:this.model.viewType,appId:this.model.appId},this);t&&this.engines.push(t)}}async initCounters(){const t=this.model.viewLayoutPanel,{appCounterRefs:e}=t;if(e&&e.length>0)try{await Promise.all(e.map((async t=>{const e=await ln.getCounterByRef(t,this.context);this.counters[t.id]=e})))}catch(t){console.error(t)}}initState(){super.initState(),this.state.activated=!0,this.state.isLoading=!1,this.state.caption=this.model.caption,this.state.srfactiveviewdata=null,this.state.viewMessages={},this.state.isClosing=!1}async onCreated(){await super.onCreated(),this.modal.hooks.beforeDismiss.tapPromise((async t=>{it(this.state.closeOK)&&(t.ok=this.state.closeOK),await this._evt.emit("onCloseView",{...t})})),this._evt.emit("onViewInfoChange",{caption:this.model.caption,title:this.model.title}),this.handleContextParams();const t=this.model.viewLayoutPanel;this.childNames.push(t.name);const e=await es(t);this.providers[t.name]=e;const a=Me(this.model);a&&await Promise.all(a.map((async t=>{const e=await es(t);this.providers[t.name||t.id]=e}))),await this.initCounters();const i=Oe(this.model);i.length&&(this.scheduler=ibiz.scheduler.createViewScheduler(i),this.scheduler.defaultParamsCb=()=>this.getEventArgs(),this.scheduler.hasViewEventTrigger&&this.evt.onAll(((t,e)=>{this.scheduler.triggerViewEvent(e)}))),this.initViewMsg(),this.engines.length&&await Promise.all(this.engines.map((t=>t.onCreated())))}async onMounted(){var t;await super.onMounted(),this.engines.length&&await Promise.all(this.engines.map((t=>t.onMounted()))),null==(t=this.scheduler)||t.startTimerTrigger()}async onDestroyed(){const t=this.context.srfsessionid;await super.onDestroyed(),this.engines.length&&await Promise.all(this.engines.map((t=>t.onDestroyed()))),Object.values(this.counters).forEach((t=>t.destroy())),this.ctx.destroy(),this.engines=[],this.scheduler&&this.scheduler.destroy(),this.id===t&&ibiz.uiDomainManager.destroy(t),this.context.destroy(),ibiz.log.debug("视图[".concat(this.model.name,"](").concat(this.model.id,")销毁"))}handleContextParams(){if(this.context.srfappid=this.model.appId||ibiz.env.appId,Q(this.context.srfsessionid)||J(this.context.srfsessionid)){const t=ibiz.uiDomainManager.create(this.id);this.context.srfsessionid=t.id}const t=this.model.appViewNavContexts;let e={};nt(t)&&(e=oe(t,this.params,this.context)),Object.assign(this.context,e),Object.prototype.hasOwnProperty.call(this.context,"srfreadonly")||Object.assign(this.context,{srfreadonly:!1});const a=this.model.appViewNavParams;let i={};nt(a)&&(i=oe(a,this.params,this.context)),Object.assign(this.params,i),this.engines.forEach((t=>{t.handleContextParams()})),this.state.isMounted&&this.callUIAction("Refresh")}async call(t,e){let a;for(const i of this.engines)if(a=await i.call(t,e),void 0!==a)break;return a}async callUIAction(t,e){const a=this.call(t,e);if(void 0===a)throw new o("没有引擎支持预置界面行为".concat(t));return a}async closeView(t={ok:!1,data:[]}){await this.modal.dismiss(t)}startLoading(){this.viewLoading.begin(),this.state.isLoading=this.viewLoading.isLoading}endLoading(){this.viewLoading.end(),this.state.isLoading=this.viewLoading.isLoading}setLayoutPanel(t){var e;this.layoutPanel=t,this.layoutPanel.state.isMounted?this.mountCounter.attend(this.layoutPanel.model.name):this.layoutPanel.evt.on("onMounted",(()=>{this.mountCounter.attend(this.layoutPanel.model.name)})),(null==(e=this.scheduler)?void 0:e.hasControlEventTrigger)&&t.evt.on("onControlEvent",(t=>{this.scheduler.triggerControlEvent(t.triggerControlName,t.triggerEventName,t.triggerEvent)}))}async initViewMsg(){const{appViewMsgGroupId:t}=this.model;if(t){this.state.viewMessages={TOP:[],BOTTOM:[],BODY:[],POPUP:[]},this.viewMsgController=new yr(t),await this.viewMsgController.init(this.context);(await this.viewMsgController.calcViewMessages(this.context,this.params)).forEach((t=>{["TOP","BOTTOM","BODY","POPUP"].includes(t.position)&&this.state.viewMessages[t.position].push(t)})),this.state.viewMessages.POPUP.length&&this.alertViewMessage(this.state.viewMessages.POPUP)}}async alertViewMessage(t){const[e,...a]=t,i={title:e.title,desc:e.message};e.extraParams.userTag&&Object.assign(i,{confirmButtonText:e.extraParams.userTag}),"WARN"===e.messageType?await ibiz.modal.warning(i):"ERROR"===e.messageType?await ibiz.modal.error(i):await ibiz.modal.info(i),a.length&&this.alertViewMessage(a)}convertMultipleLanguages(){this.model.capLanguageRes&&this.model.capLanguageRes.lanResTag&&(this.model.caption=ibiz.i18n.t(this.model.capLanguageRes.lanResTag,this.model.caption))}}),Ir=(t("AppDataUploadViewController",class extends vr{initState(){super.initState()}async onCreated(){await super.onCreated();const{srfappdataentityid:t,srfdedataimportid:e,srfappid:a}=this.context,{appDataEntity:i,deDataImport:s}=await lr({appDataEntityId:t,deDataImportId:e,appId:a});this.state.appDataEntity=i,this.state.deDataImport=s}downloadTemplate(){const{appDataEntity:t,deDataImport:e}=this.state;ur(t,e)}async selectAndImport(){const t=await pr({appDataEntity:this.state.appDataEntity,dataImport:this.state.deDataImport,context:this.context});return!0===t.isAsync&&this.closeView(),t}async asyncImportData2(t){return mr({appDataEntity:this.state.appDataEntity,dataImport:this.state.deDataImport,context:this.context,...t})}}),t("MobViewController",class extends vr{}),t("WFStepTraceViewController",class extends vr{initState(){super.initState(),this.state.historyData=null}async onCreated(){var t;await super.onCreated();const e=ibiz.hub.getApp(this.context.srfappid),a=null==(t=this.ctx.parent)?void 0:t.view;if(a&&a.model.appDataEntityId){const t=await e.deService.getService(a.context,a.model.appDataEntityId),i=Object.assign(this.context.clone(),this.params),s=await t.wf.getWFHistory(i);s.data&&(this.state.historyData=s.data)}}}),t("EditorController",class{constructor(t,e){this.style={},this.placeHolder="",this.editorParams={},this.model=t,this.parent=e,this.context=e.context,this.params=e.params}get readonly(){return!!this.model.readOnly}get valueFormat(){return this.parent.valueFormat}get dataType(){return this.parent.dataType}async init(){await this.onInit()}async onInit(){if(this.model.placeHolder&&(this.placeHolder=this.model.placeHolder),this.model.editorParams&&Object.keys(this.model.editorParams).forEach((t=>{this.editorParams[t]=this.model.editorParams[t]})),this.model.editorWidth){const t=this.model.editorWidth;this.style.width=t>0&&t<=1?"".concat(100*t,"%"):"".concat(t,"px")}if(this.model.editorHeight){const t=this.model.editorHeight;this.style.height=t>0&&t<=1?"".concat(100*t,"%"):"".concat(t,"px")}if(this.model.cssStyle){const t={};this.model.cssStyle.split(";").filter(Boolean).forEach((e=>{const[a,i]=e.split(":");a&&i&&(t[a.trim()]=i.trim()),Object.assign(this.style,t)}))}this.model.editorItems&&(this.model.editorItems=this.model.editorItems.filter((t=>t.id!==this.model.id)))}handlePublicParams(t,e,a){const{navigateContexts:i,navigateParams:s}=this.model;let n={};i&&t&&(n=oe(i,t,a,e));const o=Object.assign(e.clone(),n);let r={};return s&&t&&(r=oe(s,t,a,e)),{context:o,params:r}}toObj(t){if(!t)return;return new Function("return (".concat(t,");"))()}toBoolean(t){return Object.is("true",t)}formatValue(t=""){if("SIMPLE"!==this.model.valueType)return ar.toText(this.model,t);const e="".concat(t);if(!this.valueFormat)return e;if(l.isDate(this.dataType)){const t=yt(e).format(this.valueFormat);return"Invalid Date"!==t?t:e}return ibiz.util.text.format(e,this.valueFormat)}})),Dr=(t("CodeListEditorController",class extends Ir{async loadCodeList(t){const{context:e,params:i}=this.handlePublicParams(t,this.context,this.params);if(this.model.appCodeListId){const t=await ibiz.hub.getApp(this.context.srfappid);let a=[];return a=await t.codeList.get(this.model.appCodeListId,e,i),a}throw new a(this.model,"编辑器类型[".concat(this.model.editorType,"],未配置代码表"))}}),t("ControlController",class extends Er{constructor(t,e,a,i){if(super(t,d.create({},e),new y({},a),i),this.controlParams={},this.providers={},this.triggerKey="",this.awaitActiveCbs=new Map,this.delayCbs=new Map,this.registerToCtx(),this.controlPanel=me(t),!this.controlPanel){const e=ibiz.util.layoutPanel.get("".concat(t.controlType,"_DEFAULT"));e&&(this.controlPanel=Z(e))}this.updateContextParams({})}get _evt(){return this.evt}get view(){return this.ctx.view}registerToCtx(){this.ctx.registerController(this.model.name||this.model.id,this)}getEventArgs(){return{...super.getEventArgs(),data:this.getData()||[],ctrl:this}}initState(){super.initState(),this.state.activated=!0,this.state.isLoading=!1}async onCreated(){var t;if(await super.onCreated(),this.controlPanel){this.childNames.push(this.controlPanel.name);const t=await es(this.controlPanel);this.providers[this.controlPanel.name]=t}if(this.handleControlParams(),this.initControlScheduler(this.model.controlLogics),(null==(t=this.scheduler)?void 0:t.hasControlEventTrigger)&&this._evt.onAll(((t,e)=>{this.scheduler.triggerControlEvent(e.targetName,e.eventName,e)})),this.model.appDataEntityId){const t=ve(this.model.appDataEntityId);this.triggerKey="".concat(this.view.name,"@").concat(t,"@").concat(this.model.controlType,"@").concat(this.model.codeName)}this.onDEDataChange=this.onDEDataChange.bind(this),ibiz.mc.command.change.on(this.onDEDataChange)}async onMounted(){var t;await super.onMounted(),null==(t=this.scheduler)||t.startTimerTrigger()}async onDestroyed(){ibiz.mc.command.change.off(this.onDEDataChange),await super.onDestroyed(),this.scheduler&&this.scheduler.destroy(),this.params.destroy()}updateContextParams(t){t.context&&this.context.reset({},t.context),t.params&&this.params.reset({},t.params);const{controlNavContexts:e,controlNavParams:a}=this.model;let i={};nt(e)&&(i=oe(e,this.params,this.context)),Object.assign(this.context,i);let s={};nt(a)&&(s=oe(a,this.params,this.context)),Object.assign(this.params,s)}getControlType(){return this.model.controlType}getData(){return null}async startLoading(){this.state.isLoading=!0,this.ctx.startLoading()}async endLoading(){this.state.isLoading=!1,this.ctx.endLoading()}onActivated(){this.state.activated=!0,this.awaitActiveCbs.size>0&&this.awaitActiveCbs.forEach((t=>{t()})),this.awaitActiveCbs.clear(),ibiz.log.debug("视图[".concat(this.model.name,"](").concat(this.model.id,")激活"))}onDeactivated(){this.state.activated=!1,ibiz.log.debug("视图[".concat(this.model.name,"](").concat(this.model.id,")暂停"))}handlerAbilityParams(t){const e=this.context.clone(),a={...this.params};let i=this.getData()||[];return(null==t?void 0:t.data)&&(i=Array.isArray(t.data)?t.data:[t.data]),(null==t?void 0:t.context)&&Object.assign(e,t.context),(null==t?void 0:t.viewParam)&&Object.assign(a,t.viewParam),{context:e,params:a,data:i}}setLayoutPanel(t){this.layoutPanel=t,this.layoutPanel.state.isMounted?this.mountCounter.attend(this.layoutPanel.model.name):this.layoutPanel.evt.on("onMounted",(()=>{this.mountCounter.attend(this.layoutPanel.model.name)}))}handleControlParams(){if(!this.model.controlParam)return;const{ctrlParams:t}=this.model.controlParam;let e={};nt(t)&&(e=oe(t,this.params,this.context)),Object.assign(this.controlParams,e)}initControlScheduler(t=[]){0!==t.length&&(this.scheduler=ibiz.scheduler.createControlScheduler(t),this.scheduler.defaultParamsCb=()=>this.getEventArgs())}actionNotification(t,e){let a,i="";const{ctrlMsg:o}=this.model;if(o&&o.ctrlMsgItems){if(o.ctrlMsgItems.find((e=>e.name==="".concat(t,"_HIDDEN"))))return;const s=o.ctrlMsgItems.find((e=>e.name===t));if(s&&s.content){a=Q(s.timeout)?void 0:s.timeout/1e3;const t={...this.getEventArgs()};(null==e?void 0:e.data)&&(t.data=e.data),i=Qe.execScriptFn(t,"`".concat(s.content,"`"),{isAsync:!1,singleRowReturn:!0})}}if(!i&&ibiz.i18n){const e="CONTROL.".concat(this.model.controlType,".").concat(t).toUpperCase();i=ibiz.i18n.t(e,""),i===e&&(i="")}if(!i&&(null==e?void 0:e.default)&&(i=e.default),!i&&(null==e?void 0:e.error)&&(i=i||e.error.message),i){if(null==e?void 0:e.error){if(e.error instanceof s&&500!==e.error.status)throw e.error;throw ibiz.log.error(e.error),new n(i,a)}ibiz.message.success(i,a,0===a)}}onDEDataChange(t){ibiz.log.debug("onDEDataChange",t)}emitDEDataChange(t,e){const a=e instanceof En?e.$origin:e,i={triggerKey:this.triggerKey};switch(t){case"create":ibiz.mc.command.create.send(a,i);break;case"update":ibiz.mc.command.update.send(a,i);break;case"remove":ibiz.mc.command.remove.send(a,i);break;default:throw new o("不支持的实体数据变更类型: ".concat(t))}}doNextActive(t,e){if(Q(e.delay)&&(e.delay=300),!1===this.state.activated)this.awaitActiveCbs.set(e.key,t);else if(e.delay){const a=this.delayCbs.get(e.key);clearTimeout(a);const i=setTimeout((()=>{t(),clearTimeout(this.delayCbs.get(e.key))}),e.delay);this.delayCbs.set(e.key,i)}else t()}})),Cr=t("MDControlController",class extends Dr{constructor(){super(...arguments),this.isSetSort=!1,this.fieldIdNameMap=new Map}get _evt(){return this.evt}initState(){super.initState(),this.state.items=[],this.state.selectedData=[],this.state.searchParams={},this.state.noSort=!1,this.state.sortQuery="",this.state.curPage=1,this.state.size=20,this.state.total=0,this.state.isLoaded=!1,this.state.singleSelect=!0,this.state.mdctrlActiveMode=0,this.state.groups=[]}get batchToolbarController(){return this.view.getController("".concat(this.model.name,"_batchtoolbar"))}get quickToolbarController(){return this.view.getController("".concat(this.model.name,"_quicktoolbar"))}async onCreated(){var t;await super.onCreated(),this.dataEntity=await ibiz.hub.getAppDataEntity(this.model.appDataEntityId,this.model.appId),null==(t=this.dataEntity.appDEFields)||t.forEach((t=>{this.fieldIdNameMap.set(t.id,t.name)})),this.isSetSort||this.setSort()}async onMounted(){await super.onMounted(),this.state.loadDefault&&this.load({isInitialLoad:!0})}getSortModel(){return{minorSortAppDEFieldId:void 0,minorSortDir:void 0}}setSort(t,e){if(t&&e)this.state.sortQuery="".concat(t,",").concat(e);else if(t||e)this.state.sortQuery="";else{const{minorSortAppDEFieldId:t,minorSortDir:e}=this.getSortModel();if(this.view&&localStorage.getItem("".concat(this.view.model.id,".").concat(this.model.name,".sort")))this.state.sortQuery=localStorage.getItem("".concat(this.view.model.id,".").concat(this.model.name,".sort"));else if(t&&e){const a=this.fieldIdNameMap.get(t);this.state.sortQuery="".concat(a.toLowerCase(),",").concat(e.toLowerCase())}}this.view&&(this.state.sortQuery?localStorage.setItem("".concat(this.view.model.id,".").concat(this.model.name,".sort"),this.state.sortQuery):localStorage.removeItem("".concat(this.view.model.id,".").concat(this.model.name,".sort")))}async getFetchParams(t){const{curPage:e,size:a,sortQuery:i,noSort:s}=this.state,n={...this.params};return a&&(n.page=e-1,n.size=a),!s&&i&&(n.sort=i),await this._evt.emit("onBeforeLoad",void 0),Object.assign(n,{...this.state.searchParams}),t&&Object.assign(n,t),n}async load(t={}){if(this.state.isSimple)return[];const e=!0===t.silent;e||await this.startLoading();try{const e=!0===t.isInitialLoad,a=!0===t.isLoadMore;e?this.state.curPage=1:a&&(this.state.curPage+=1);const{context:i}=this.handlerAbilityParams(t),s=await this.getFetchParams(null==t?void 0:t.viewParam),n=await this.service.fetch(i,s);"number"==typeof n.total&&(this.state.total=n.total),"number"==typeof n.totalPages&&(this.state.totalPages=n.totalPages),a?this.state.items.push(...n.data):this.state.items=n.data,await this.afterLoad(t,n.data),this.state.isLoaded=!0,await this._evt.emit("onLoadSuccess",{isInitialLoad:e})}catch(t){throw await this._evt.emit("onLoadError",void 0),this.actionNotification("FETCHERROR",{error:t}),t}finally{e||await this.endLoading()}return this.state.items.forEach(((t,e)=>{t.srfserialnum=e+1})),this.actionNotification("FETCHSUCCESS"),this.state.items}async afterLoad(t,e){return e}async refresh(){this.doNextActive((()=>this.load({isInitialLoad:!1})),{key:"refresh"})}async remove(t){const{context:e,params:a,data:i}=this.handlerAbilityParams(t);if(!(null==i?void 0:i.length))throw new o("未选中数据");if(!0!==(null==t?void 0:t.silent)){if(!await ibiz.confirm.error({title:"数据删除",desc:"确认删除数据?"}))return}await this._evt.emit("onBeforeRemove",void 0),await this.startLoading();let s=!1;try{await ba(i.map((async t=>{s=await this.handleItemRemove(t,e,a),this.afterRemove(t)}))),!0!==(null==t?void 0:t.silent)&&this.actionNotification("REMOVESUCCESS",{data:i,default:"数据[".concat(i.map((t=>t.srfmajortext)).join("、"),"]删除成功!")}),s&&!(null==t?void 0:t.notRefresh)&&await this.refresh()}catch(t){throw await this._evt.emit("onRemoveError",void 0),this.actionNotification("REMOVEERROR",{error:t,data:i}),t}finally{await this.endLoading()}this.state.selectedData=[],await this._evt.emit("onRemoveSuccess",void 0),i.forEach((t=>{this.emitDEDataChange("remove",t)}))}async handleItemRemove(t,e,a){let i=!1;const s=ve(this.model.appDataEntityId);if(0!==t.srfuf){const n=e.clone();n[s]=t.srfkey,await this.service.remove(n,a),i=!0}return i}afterRemove(t){const e=this.state.items.findIndex((e=>e.srfkey===t.srfkey));-1!==e&&this.state.items.splice(e,1)}getData(){return this.state.selectedData||[]}setActive(t){return this._evt.emit("onActive",{data:[t]})}setSelection(t){var e,a;const{selectedData:i}=this.state;v(i,t)||(this.state.selectedData=t,this._evt.emit("onSelectionChange",{data:t}));const s=null==t?void 0:t[0];null==(e=this.batchToolbarController)||e.calcButtonState(s,this.model.appDataEntityId),null==(a=this.quickToolbarController)||a.calcButtonState(s,this.model.appDataEntityId)}async onRowClick(t){const{selectedData:e}=this.state,a=e.filter((e=>e.srfkey!==t.srfkey));a.length===e.length?this.setSelection(this.state.singleSelect?[t]:e.concat([t])):this.setSelection(a),1===this.state.mdctrlActiveMode&&await this.setActive(t)}async onDbRowClick(t){2===this.state.mdctrlActiveMode&&await this.setActive(t)}async importData(){const{appDataEntityId:t,dedataImportId:e}=this.model;if(!t||!e)throw new a(this.model,"没有配置导入模型!");await hr({appDataEntityId:t,deDataImportId:e,context:this.context,params:this.params})}async exportData(t){}onDEDataChange(t){if(!Q(t.triggerKey)&&t.triggerKey===this.triggerKey)return;if(!t.data||t.data.srfdecodename!==this.dataEntity.codeName)return;let e=!1;const{srfkey:a}=t.data;switch(t.subtype){case"OBJECTCREATED":e=!0;break;case"OBJECTUPDATED":case"OBJECTREMOVED":-1!==this.state.items.findIndex((t=>t.srfkey===a))&&(e=!0)}e&&this.doNextActive((()=>this.load({isInitialLoad:!!ibiz.env.isMob})),{key:"refresh"})}}),br=t("AppMenuController",class extends Dr{constructor(t,e,a,i){super(t,e,a,i),this.itemProviders={},this.flattenAllItems()}initState(){super.initState(),this.state.menuItemsState={}}get routeDepth(){return this.view.modal.routeDepth}async onCreated(){var t;await super.onCreated(),this.app=await ibiz.hub.getApp(this.context.srfappid),await this.initAppMenuItemProviders(),null==(t=this.model.appMenuItems)||t.forEach((t=>{this.initMenuItemState(t)}))}async initAppMenuItemProviders(){await Promise.all(this.allAppMenuItems.map((async t=>{const e=await Gs(t);e&&(this.itemProviders[t.id]=e)})))}async onClickMenuItem(t,e,i=!0,s={}){const n=I(this.model,t,{compareField:"id",childrenFields:["appMenuItems"]});if(!n)throw new o("找不到名为".concat(t,"的菜单项"));this.evt.emit("onClick",{eventArg:t,event:e});const r=this.itemProviders[t];if(r&&r.onClick)return r.onClick(n,e,this);if(!n.appFuncId)throw new a(n,"没有配置应用功能");const c=this.context.clone();c.srfappid=n.appId||ibiz.env.appId,this.routeDepth&&i&&Object.assign(c,{toRouteDepth:this.routeDepth+1}),await ibiz.commands.execute(Ro.TAG,n.appFuncId,c,this.params,s)}initMenuItemState(t){var e;const a={permitted:!0,visible:!0};if(t.hidden)a.visible=!1;else{let i=!0;t.accessKey&&(i=this.app.authority.calcByResCode(t.accessKey));let s=i;if(null==(e=t.appMenuItems)?void 0:e.length){const e=t.appMenuItems.map((t=>this.initMenuItemState(t).visible));s=s&&e.includes(!0)}a.permitted=i,a.visible=s}return this.state.menuItemsState[t.id]=a,a}flattenAllItems(){const t=[],e=a=>{a.forEach((a=>{t.push(a),a.appMenuItems&&a.appMenuItems.length>0&&e(a.appMenuItems)}))};e(this.model.appMenuItems),this.allAppMenuItems=t}getAllItems(){return this.allAppMenuItems}getCounter(t){const{counters:e}=this.ctx.view;return e[t]?e[t]:null}convertMultipleLanguages(){const t=e=>{e.forEach((e=>{var a;e.capLanguageRes&&e.capLanguageRes.lanResTag&&(e.caption=ibiz.i18n.t(e.capLanguageRes.lanResTag,e.caption)),(null==(a=e.appMenuItems)?void 0:a.length)&&t(e.appMenuItems)}))};this.model.appMenuItems&&this.model.appMenuItems.length>0&&t(this.model.appMenuItems)}}),Ar=(t("AppMenuIconViewController",class extends br{async onClickMenuItem(t,e){const i=I(this.model,t,{compareField:"id",childrenFields:["appMenuItems"]});if(!i)throw new o("找不到名为".concat(t,"的菜单项"));if(this.evt.emit("onClick",{eventArg:t,event:e}),!i.appFuncId)throw new a(i,"没有配置应用功能");const s=this.context.clone();1===this.routeDepth&&Object.assign(s,{toRouteDepth:1}),await ibiz.commands.execute(Ro.TAG,i.appFuncId,s,this.params)}}),t("CalendarService",class extends vn{async search(t,e={}){const{sysCalendarItems:a}=this.model;if(!a)return[];const i=a.map((async a=>{const i=a.appDEDataSetId||"fetchdefault",s=t.clone(),n=Z(e);return a.maxSize&&(n.size=a.maxSize),this.exec2(i,s,n,void 0,a.appDataEntityId)}));return(await Promise.all(i)).map(((t,e)=>this.setCalendarConfigData(t.data,e))).flat()}setCalendarConfigData(t,e){const{sysCalendarItems:a}=this.model;if(!a)throw new o("未找到日历项模型");const i=a[e];if(!i)throw new o("未找到日历项模型");return t.map((t=>new go(i,t)))}async exec2(t,e,a={},i={},s=this.model.appDataEntityId){return await this.app.deService.exec(s,t,e,a,i)}}));t("CalendarController",class extends Cr{initState(){super.initState(),this.state.selectedDate=new Date,this.state.size=1e3}async onCreated(){await super.onCreated(),this.service=new Ar(this.model),await this.service.init(this.context),this.initViewScheduler()}initViewScheduler(){const t=this.model.appViewLogics||[];0!==t.length&&(this.viewScheduler=ibiz.scheduler.createViewScheduler(t),this.viewScheduler.defaultParamsCb=()=>this.getEventArgs(),this.viewScheduler.hasViewEventTrigger&&this.evt.onAll(((t,e)=>{this.viewScheduler.triggerViewEvent(e)})))}async setActive(t){return this.openData(t),this._evt.emit("onActive",{data:[t]})}async openData(t){var e,i;const s=this.context.clone();s[((null==(e=t.deData.srfdecodename)?void 0:e.toLowerCase())||ve(this.model.appDataEntityId)).toLowerCase()]=t.deData.srfkey;const n=await(null==(i=this.viewScheduler)?void 0:i.triggerCustom("".concat(t.itemType.toLowerCase(),"_opendata"),{context:s,params:this.params,data:[t.deData],event:void 0,view:this.view,ctrl:this}));if(-1===n)throw new a(this.model,"缺少".concat(t.itemType.toLowerCase(),"_opendata的视图逻辑"));return{cancel:!n||n.ok}}async load(t={}){const e=!0===t.isInitialLoad,{context:a}=this.handlerAbilityParams(t),i=await this.getFetchParams(null==t?void 0:t.viewParam);let s;await this.startLoading();try{s=await this.service.search(a,i)}finally{await this.endLoading()}return await this.afterLoad(t,s),this.state.isLoaded=!0,this.state.items=s,this.sortItems(),await this.evt.emit("onLoadSuccess",{isInitialLoad:e}),s}sortItems(){"TIMELINE"===this.model.calendarStyle&&this.state.items.sort(((t,e)=>{const a=t.beginTime,i=e.beginTime;let s=0;return yt(a).isAfter(i)?s=-1:yt(a).isBefore(i)&&(s=1),s}))}getCurSelectDate(t){const{selectedDate:e}=this.state,{srfstartdate:a,srfenddate:i}=t;if(!a||!i){const t=new Date(e.getFullYear(),e.getMonth(),1),a=new Date(e.getFullYear(),e.getMonth()+1,1);return{srfstartdate:yt(t).format("YYYY-MM-DD HH:mm:ss"),srfenddate:yt(a).format("YYYY-MM-DD HH:mm:ss")}}return{srfstartdate:a,srfenddate:i}}async getFetchParams(t={}){const{curPage:e,size:a,sortQuery:i,noSort:s}=this.state,n={...this.params};if(!s&&i&&(n.sort=i),await this._evt.emit("onBeforeLoad",void 0),Object.assign(n,{...this.state.searchParams}),a&&(n.page=e-1,n.size=a),t&&Object.assign(n,t),"TIMELINE"!==this.model.calendarStyle){const t=this.getCurSelectDate(n);Object.assign(n,t)}return n}async onRowClick(t){const{selectedData:e}=this.state,a=e.filter((e=>e.deData.srfkey!==t.deData.srfkey));a.length===e.length?this.setSelection(this.state.singleSelect?[t]:e.concat([t])):this.setSelection(a),1===this.state.mdctrlActiveMode&&await this.setActive(t)}setSelectDate(t){this.state.selectedDate=t}});yt.extend(bt),yt.extend(Pt),yt.extend(xt),yt.extend(Nt),yt.extend(Mt);var Pr="$default_group",Tr=class{constructor(t,e){this.model=t,this.chartGenerator=e,this.chartDataArr=[],this.staticOptions={},this.autoCompleteCategory=!0,this.model=t,this.chartGenerator=e;const{chartSeriesEncode:i,caption:s,id:n,userParam:o}=t;if(!t.catalogField)throw new a(t,"缺少分类属性配置");if(!t.valueField)throw new a(t,"缺少值属性配置");this.catalogField=e.getFieldKey(t.catalogField),this.valueField=e.getFieldKey(t.valueField),this.groupField=t.seriesField?e.getFieldKey(t.seriesField):void 0;const{chartXAxisId:r,chartYAxisId:c}=i||{};this.xAxisIndex=R(r),this.yAxisIndex=R(c),this.seriesName=s||n,this.staticOptions=this.calcStaticOptions(),o&&(this.seriesUserParam=_r(o))}calcStaticOptions(){return{type:this.model.seriesType,name:this.seriesName,emphasis:{label:{fontSize:20,show:!0}},label:{position:"top",show:!0}}}translateVal(t,e,a=!1){if(Q(e))return;if(Q(t))return e;const i=this.chartGenerator.codeListMap.get(t);if(null==i?void 0:i.length){const t=i.find((t=>t.value===e));return t?t.text:"未定义"}return a?void 0:e}prepareChartData(t,e,a,i){var s;this.groupField&&Object.assign(e,{[this.groupField]:i}),this.catalogField&&Object.assign(e,{[this.catalogField]:a});const n=new vo(e,this.model,a,i);t[i].get(a).chartData=n,null==(s=this.chartDataArr)||s.push(n)}calcGroupData(t){this.groupData={},this.chartDataArr=[];const e=this.groupData,{seriesCodeListId:a,catalogCodeListId:i}=this.model;return t.forEach((t=>{let s=Pr;if(this.groupField){const e=this.translateVal(a,t[this.groupField]);if(Q(e))return;s=e}if(!e[s]&&(e[s]=new Map,i&&this.autoCompleteCategory)){this.chartGenerator.codeListMap.get(i).forEach((t=>{e[s].set(t.text,{value:0})}))}const n=this.translateVal(i,t[this.catalogField],!0);if(n)e[s].get(n)||e[s].set(n,{value:0}),e[s].get(n).value=N(e[s].get(n).value,t[this.valueField]||0),e[s].get(n).chartData?this.prepareChartData(e,{[this.valueField]:e[s].get(n).value},n,s):this.prepareChartData(e,t,n,s);else if(i&&this.autoCompleteCategory){this.chartGenerator.codeListMap.get(i).forEach((t=>{this.prepareChartData(e,{[this.valueField]:0},t.text,s)}))}})),e}calcGroupSeries(t){return Object.keys(t).map((e=>{const a=t[e],i=this.calcSeriesData(a);let s={...this.staticOptions,data:i};return e!==Pr&&(s.name=e),this.seriesUserParam&&(s=st(s,this.seriesUserParam)),s}))}calcSeriesData(t){const e=[];return t.forEach(((t,a)=>{e.push([a,t.value,t.chartData])})),e}calcByData(t){const e=this.dataPreprocess(t),a=this.calcGroupData(e);return this.addTimeData(a),this.calcGroupSeries(a)}getChartDataByParams(t){var e,a,i;return this.groupData&&1===Object.keys(this.groupData).length?null==(e=this.groupData[Pr].get(t.name))?void 0:e.chartData:null==(i=null==(a=this.groupData)?void 0:a[t.seriesName].get(t.name))?void 0:i.chartData}dataPreprocess(t){const e=[];t.forEach((t=>{e.push(Z(t))}));const{groupMode:a}=this.model;return a&&e.forEach((t=>{let e="";if("DAY"===a||"YEAR"===a||"MONTH"===a){if("DAY"===a?e="YYYY-MM-DD":"YEAR"===a?e="YYYY":"MONTH"===a&&(e="YYYY-MM"),t[this.catalogField]){const a=yt(t[this.catalogField]).format(e);t[this.catalogField]=a}}else if("QUARTER"===a){if(t[this.catalogField]){const e="".concat(yt(t[this.catalogField]).format("YYYY"),"-").concat(yt(t[this.catalogField]).quarter());t[this.catalogField]=e}}else if("YEARWEEK"===a&&t[this.catalogField]){const e="".concat(yt(t[this.catalogField]).format("YYYY"),"-").concat(yt(t[this.catalogField]).week());t[this.catalogField]=e}})),e}sortTimeData(t){const{groupMode:e}=this.model;Object.keys(t).forEach((a=>{const i=t[a];let s=[];"DAY"===e||"YEAR"===e||"MONTH"===e?s=Array.from(i.keys()).sort(((t,e)=>yt(t).diff(yt(e)))):"QUARTER"!==e&&"YEARWEEK"!==e||(s=Array.from(i.keys()).sort(((t,e)=>{const[a,i]=t.split("-"),[s,n]=e.split("-");return a!==s?parseInt(a,10)-parseInt(s,10):parseInt(i,10)-parseInt(n,10)})));const n=new Map;s.forEach((t=>{n.set(t,i.get(t))})),t[a]=n}))}addTimeData(t){const{groupMode:e}=this.model;if(!e||"CODELIST"===e)return;const a=[];Object.keys(t).forEach((e=>{t[e].forEach(((t,e)=>{a.push(yt(e))}))}));const i=yt.max(a),s=yt.min(a);if("DAY"===e){let e=s;const a=i;for(;null==e?void 0:e.isSameOrBefore(a,"day");){const a=e.format("YYYY-MM-DD");Object.keys(t).forEach((e=>{t[e].get(a)||t[e].set(a,{value:0})})),e=e.add(1,"day")}}else if("YEAR"===e){let e=s.year();const a=i.year();for(;e<=a;){const a=e.toString();Object.keys(t).forEach((e=>{t[e].get(a)||t[e].set(a,{value:0})})),e+=1}}else if("MONTH"===e){let e=s.clone().startOf("month");const a=i.clone().startOf("month");for(;e.isSameOrBefore(a);){const a=e.format("YYYY-MM");Object.keys(t).forEach((e=>{t[e].get(a)||t[e].set(a,{value:0})})),e=e.add(1,"month")}}else if("QUARTER"===e){const e=[];Object.keys(t).forEach((a=>{t[a].forEach(((t,a)=>{e.push(a)}))}));const a=e.reduce(((t,e)=>e<t?e:t),e[0]),i=e.reduce(((t,e)=>e>t?e:t),e[0]),[s]=a.split("-"),[n]=i.split("-");for(let e=parseInt(s,10);e<=parseInt(n,10);e++)for(let a=1;a<=4;a++){const i="".concat(e,"-").concat(a);Object.keys(t).forEach((e=>{t[e].get(i)||t[e].set(i,{value:0})}))}}else if("YEARWEEK"===e){const e=[];Object.keys(t).forEach((a=>{t[a].forEach(((t,a)=>{e.push(a)}))}));const a=e.reduce(((t,e)=>e<t?e:t),e[0]),i=e.reduce(((t,e)=>e>t?e:t),e[0]),[s]=a.split("-"),[n]=i.split("-");for(let e=parseInt(s,10);e<=parseInt(n,10);e++){const a=yt("".concat(e,"-12-31")).isoWeek();for(let i=1;i<=a;i++){const a="".concat(e,"-").concat(i);Object.keys(t).forEach((e=>{t[e].get(a)||t[e].set(a,{value:0})}))}}}this.sortTimeData(t)}},xr=class extends Tr{calcStaticOptions(){if(void 0===this.xAxisIndex)throw new a(this.model,"序列没有配置X坐标轴");if(void 0===this.yAxisIndex)throw new a(this.model,"序列没有配置Y坐标轴");const t=super.calcStaticOptions();t.xAxisIndex=this.xAxisIndex,t.yAxisIndex=this.yAxisIndex;const{stack:e,step:i}=this.model;return i&&(t.step="middle"),t}},Sr=class extends Tr{calcStaticOptions(){if(void 0===this.xAxisIndex)throw new a(this.model,"序列没有配置X坐标轴");if(void 0===this.yAxisIndex)throw new a(this.model,"序列没有配置Y坐标轴");const t=super.calcStaticOptions();return t.xAxisIndex=this.xAxisIndex,t.yAxisIndex=this.yAxisIndex,this.model,t}},Nr=class extends Tr{calcStaticOptions(){const t=super.calcStaticOptions();return t.label.formatter="{b}: {d}%",t.label.position="outer",t}calcSeriesData(t){const e=[];return t.forEach(((t,a)=>{e.push({name:a,value:[t.value,t.chartData]})})),e}},Rr=class extends Tr{calcStaticOptions(){const t=super.calcStaticOptions();return t.label.formatter="{b}: {d}%",t.label.position="outside",t}calcSeriesData(t){const e=[];return t.forEach(((t,a)=>{e.push({name:a,value:[t.value,t.chartData]})})),e}},Mr=class extends Tr{calcStaticOptions(){if(void 0===this.xAxisIndex)throw new a(this.model,"序列没有配置X坐标轴");if(void 0===this.yAxisIndex)throw new a(this.model,"序列没有配置Y坐标轴");const t=super.calcStaticOptions();return t.xAxisIndex=this.xAxisIndex,t.yAxisIndex=this.yAxisIndex,t}},Or=class{constructor(t){this.indicator={},this.index=t}get indicatorKeys(){return this._indicatorKeys&&this._indicatorKeys.length===Object.keys(this.indicator).length||(this._indicatorKeys=Object.keys(this.indicator).sort()),this._indicatorKeys}updateIndicator(t,e){const a=this.indicator[t];(!a||a.max<e)&&(this.indicator[t]={max:e})}toOptions(){const t=Math.max(...Object.values(this.indicator).map((t=>t.max)));return{indicator:this.indicatorKeys.map((e=>({name:e,max:t})))}}},Lr=class extends Tr{calcStaticOptions(){return super.calcStaticOptions()}calcRadarCoordSystem(t){const e=this.calcGroupData(t);this.chartGenerator.radarMap.has(this.catalogField)||this.chartGenerator.radarMap.set(this.catalogField,new Or(this.chartGenerator.radarMap.size));const a=this.chartGenerator.radarMap.get(this.catalogField);Object.values(e).forEach((t=>{t.forEach(((t,e)=>{a.updateIndicator(e,t.value)}))}))}calcByData(t){const e=this.groupData,a=this.chartGenerator.radarMap.get(this.catalogField),i=Object.keys(e).map((t=>{const i=e[t],s=a.indicatorKeys.map((t=>i.has(t)?i.get(t).value:0));return{name:t===Pr?this.seriesName:t,value:s}}));let s={...this.staticOptions,data:i};return this.seriesUserParam&&(s=st(s,this.seriesUserParam)),s}};function _r(t){const e={};return t&&Object.keys(t).forEach((a=>{const i=a.indexOf(".");if(-1===i)return;const s=a.slice(i+1);if(s)try{e[s]=JSON.parse(t[a])}catch(i){e[s]=t[a]}})),e}var Fr=class{constructor(t){this.model=t,this.staticOptions={tooltip:{show:!0}},this.options={},this.seriesGenerators=[],this.radarMap=new Map,this.codeListMap=new Map,this.seriesGeneratorIndexMap=new Map;const{dechartTitle:e,dechartLegend:a,chartXAxises:i,chartYAxises:s,userParam:n}=t;e&&(this.staticOptions.title=this.calcTitleOption(e)),a&&(this.staticOptions.legend=this.calcLegendOption(a)),(null==i?void 0:i.length)&&(this.staticOptions.xAxis=this.calcXYAxisOption(i)),(null==s?void 0:s.length)&&(this.staticOptions.yAxis=this.calcXYAxisOption(s)),n&&(this.chartUserParam=_r(n))}initSeriesGenerators(){var t;null==(t=this.model.dechartSerieses)||t.forEach((t=>{let e;switch(t.seriesType){case"line":e=new xr(t,this);break;case"bar":e=new Sr(t,this);break;case"scatter":e=new Mr(t,this);break;case"pie":e=new Rr(t,this);break;case"funnel":e=new Nr(t,this);break;case"radar":e=new Lr(t,this);break;default:ibiz.log.error("图表暂未支持序列类型".concat(t.seriesType))}e&&this.seriesGenerators.push(e)}))}calcTitleOption(t){const{showTitle:e,title:a,subTitle:i,titlePos:s}=t,n={show:e,text:a,subtext:i,left:"center"},o=null==s?void 0:s.toLowerCase();return"left"===o||"right"===o?n.left=o:"bottom"!==o&&"top"!==o||(n.top=o),n}calcLegendOption(t){const{showLegend:e,legendPos:a}=t,i={};i.show=e;const s=null==a?void 0:a.toLowerCase();return"left"===s||"right"===s?(i.left=s,i.top="middle",i.orient="vertical"):"bottom"===s&&(i.top=s),i}calcXYAxisOption(t){const e=[];return t.forEach((t=>{const{position:a,dataShowMode:i,userParam:s}=t;let n={type:t.echartsType,name:t.caption,max:t.maxValue,min:t.minValue,position:a,axisLabel:{formatter:t=>("number"==typeof t&&(t=t.toString()),1===i?t.length>4?"".concat(t.slice(0,4).split("").join("\n"),"\n..."):t.split("").join("\n"):2===i&&t.length>4?"".concat(t.slice(0,4),"..."):t),rotate:3===i?45:0}};s&&(n=st(n,_r(s))),e.push(n)})),e}async init(t,e){await this.loadCodeList(t,e),this.entity=await ibiz.hub.getAppDataEntity(this.model.appDataEntityId,this.model.appId),this.initSeriesGenerators()}getFieldKey(t){const e=this.entity.appDEFields.find((e=>e.name===t));return e?e.codeName.toLowerCase():t.toLowerCase()}async loadCodeList(t,e){var a;if(this.codeListMap.clear(),!(null==(a=this.model.dechartSerieses)?void 0:a.length))return;const i=ibiz.hub.getApp(t.srfappid),s=async a=>{if(!a||this.codeListMap.has(a))return;const s=await i.codeList.get(a,t,e);this.codeListMap.set(a,s)};await Promise.all(this.model.dechartSerieses.map((async t=>{const{seriesCodeListId:e,catalogCodeListId:a}=t;await s(e),await s(a)})))}calcOptionsByData(t){this.radarMap.clear(),this.options={series:[],radar:[]},this.seriesGenerators.forEach((e=>{"radar"===e.model.seriesType&&e.calcRadarCoordSystem(t)})),this.radarMap.size&&(this.options.radar=[...this.radarMap.values()].map((t=>t.toOptions())));const e=[];return this.seriesGenerators.forEach((a=>{const i=e.length,s=a.calcByData(t);s instanceof Array?e.push(...s):e.push(s);const n=e.length-1;for(let t=i;t<=n;t++)this.seriesGeneratorIndexMap.set(t,a)})),this.options.series=e,1===this.seriesGenerators.length&&this.seriesGenerators[0].groupData&&1===Object.keys(this.seriesGenerators[0].groupData).length&&e[0].type&&["bar","line","scatter"].includes(e[0].type)&&this.staticOptions.legend&&(this.staticOptions.legend.show=!1),this.options=st(this.staticOptions,this.options),this.chartUserParam&&(this.options=st(this.options,this.chartUserParam)),this.options}getChartDataByParams(t){const e=this.seriesGeneratorIndexMap.get(t.seriesIndex);if(!e)throw new o("找不到".concat(t.seriesIndex,"序列的generator!"));return e.getChartDataByParams(t)}},Vr=t("ChartService",class extends vn{}),kr=(t("ChartController",class extends Cr{initState(){super.initState(),this.state.size=1e3,this.state.showGrid=!1,this.state.gridHeaders=[],this.state.gridData=[],this.state.gridPosition="bottom"}async onCreated(){await super.onCreated(),this.service=new Vr(this.model),await this.service.init(this.context),this.generator=new Fr(this.model),await this.generator.init(this.context,this.params),this.parseGridParam(),this.resizeChart=this.resizeChart.bind(this),window.addEventListener("resize",this.resizeChart)}async afterLoad(t,e){const a=await super.afterLoad(t,e);return e.forEach((t=>{Object.assign(t,{srfcount:1})})),this.calcOptions(),a}parseGridParam(){this.model.dechartDataGrid&&(this.model.dechartDataGrid.dataGridPos?this.state.gridPosition=this.model.dechartDataGrid.dataGridPos.toLocaleLowerCase():this.state.gridPosition="bottom",!0===this.model.dechartDataGrid.showDataGrid&&(this.state.showGrid=!0))}computeTotal(t){let e=0;return this.state.items.forEach((a=>{const i=Number(a[t]);Number.isNaN(i)||(e+=Number(i))})),e}handleSingleSerieGridData(){const t=this.generator.seriesGenerators[0],{catalogField:e,valueField:a,groupData:i}=t,s=t.chartGenerator.entity.appDEFields,n=s.find((t=>t.id===e)),o=s.find((t=>t.id===a)),r=[{id:e,name:null==n?void 0:n.logicName},{id:a,name:null==o?void 0:o.logicName},{id:"srfpercent",name:"百分比"}];this.state.gridHeaders=r;const c=[],d=this.computeTotal(a);if(i&&i.$default_group){const t=i.$default_group;for(const[i,s]of t){const t=Number.isNaN(Number(s.value))?0:Number(s.value);let n="";n=0===d||Number.isNaN(Number(s.value))?"0%":"".concat(Math.round(t/d*100),"%");const o={[e]:i,[a]:t,srfpercent:n};c.push(o)}}this.state.gridData=c}handleMultipleSerieGridData(){const t=[],e=[];this.generator.seriesGenerators.forEach((a=>{const{catalogField:i,valueField:s,groupData:n}=a,o=a.chartGenerator.entity.appDEFields;if(t.findIndex((t=>t.id===i))<0){const e=o.find((t=>t.id===i.toLowerCase()));t.push({id:i,name:null==e?void 0:e.logicName})}const r=o.find((t=>t.id===s.toLowerCase()));if(t.push({id:s,name:null==r?void 0:r.logicName}),n&&n.$default_group){const t=n.$default_group;for(const[a,n]of t){const t=Number.isNaN(Number(n.value))?0:Number(n.value),o=e.findIndex((t=>t[i]===a));if(o<0){const n={[i]:a,[s]:t};e.push(n)}else Object.assign(e[o],{[s]:t})}}})),this.state.gridHeaders=t,this.state.gridData=e}computeGridData(){this.generator&&this.generator.seriesGenerators&&(1===this.generator.seriesGenerators.length?this.handleSingleSerieGridData():this.handleMultipleSerieGridData())}initChart(t){this.chart=t,this.chart.on("click",(t=>{const e=this.generator.getChartDataByParams(t);e&&this.setActive(e)}))}calcOptions(t=this.state.items){this.options=this.generator.calcOptionsByData(t),this.state.showGrid&&this.computeGridData(),this.updateChart()}updateChart(){if(!this.chart)throw new o("chart对象没有正确初始化");if(!this.options)throw new o("options还没计算");this.chart.setOption(this.options,{notMerge:!0}),this.resizeChart()}resizeChart(){this.chart&&this.chart.resize()}async onDestroyed(){var t;window.removeEventListener("resize",this.resizeChart),await super.onDestroyed(),null==(t=this.chart)||t.dispose()}}),t("CaptionBarController",class extends Dr{initState(){super.initState(),this.state.caption=this.view.model.caption}async onCreated(){await super.onCreated(),this.view.evt.on("onViewInfoChange",(({caption:t,dataInfo:e})=>{this.state.caption="".concat(this.view.model.caption).concat(e?"-".concat(e):""),this.setBrowserTabTitle()}))}setBrowserTabTitle(){"ROUTE"!==this.view.modal.mode&&"ROUTE_MODAL"!==this.view.modal.mode||ibiz.util.setBrowserTitle(this.state.caption)}}),class{constructor(t,e){this.deLogicParams=t,this.parameters=e,this.session={},this.params={},this.result=null,this.isEndNode=!1,this.defaultParamName="Default"}get view(){return this.parameters.view}get context(){return Object.prototype.hasOwnProperty.call(this.params,"context")?this.params.context:this.parameters.context}get data(){return this.parameters.data}get viewParam(){return Object.prototype.hasOwnProperty.call(this.params,"viewParam")?this.params.viewParam:this.parameters.params}resetParam(t){var e;null==(e=this.deLogicParams.get(t))||e.calc(this)}renewParam(t){var e;null==(e=this.deLogicParams.get(t))||e.renew(this)}setLastReturn(t){this.lastReturn=t}initLastReturnParam(t){Object.defineProperty(this.params,t,{enumerable:!0,configurable:!0,get:()=>this.lastReturn})}isEntityParam(t){const e=this.deLogicParams.get(t);return!(!e||!e.model.entityParam)}}),zr=class{};function Wr(t,e){const{srcDEUILogicParamId:a,srcFieldName:s,srcValue:n}=e,o=e.srcValueType||"SRCDLPARAM",r=s;let c;switch(o){case"SRCDLPARAM":c=t.params[a];break;case"NULLVALUE":return null;case"NONEVALUE":return;case"SRCVALUE":return ibiz.util.rawValue.format(n);case"WEBCONTEXT":case"VIEWPARAM":c=t.parameters.params;break;case"APPLICATION":case"SESSION":case"APPDATA":case"DATACONTEXT":c=t.parameters.context;break;case"ENVPARAM":c=Z(ibiz.env);break;default:throw new i(e,"暂未支持源值类型".concat(o))}if(c&&r)try{c=Array.isArray(c)?c[Number(r)]:Qe.execScriptFn({srcValue:c},"srcValue.".concat(r),{singleRowReturn:!0,isAsync:!1})}catch(t){throw ibiz.log.error("从源参数取属性".concat(r,"报错,源参数:"),c),t}return c}var Ur=class extends zr{constructor(t){super(),this.model=t,this.srcParam=t.srcLogicParamId,this.dstParam=t.dstLogicParamId}get dstField(){return this.model.dstFieldName}get op(){return this.model.condOP}get type(){return this.model.paramType}get value(){return this.model.paramValue}test(t,e,s){const n=Wr(t,{srcDEUILogicParamId:this.dstParam,srcFieldName:this.dstField});let o,r;switch(this.type){case"ENTITYFIELD":{if(!this.value)throw new a(this.model,"当前条件值类型为[数据对象属性],缺少配置条件值");const t=null!=s[this.value]?s[this.value]:e[this.value];r=t,o=Ge(n,this.op,t);break}case"SRCENTITYFIELD":{if(!this.value)throw new a(this.model,"当前条件值类型为[源数据对象属性],缺少配置条件值");const e=Wr(t,{srcDEUILogicParamId:this.srcParam,srcFieldName:this.value});r=e,o=Ge(n,this.op,e);break}case"CURTIME":throw new i(this.model,"暂未支持条件值类型为[当前时间]");default:r=this.value,o=Ge(n,this.op,this.value)}return ibiz.log.debug("界面逻辑连接条件项:".concat(this.model.name,"-条件值类型:").concat(this.type,"-源属性名称:").concat(this.dstField,"-源对象值:"),n,"-对比条件:".concat(this.op),"-对比值:",r,"-对比结果:",o),o}},Br=class t extends zr{constructor(e){super(),this.model=e;const a=e.deuilogicLinkConds||[];this.conds=a.map((e=>"SINGLE"===e.logicType?new Ur(e):new t(e)))}get op(){return this.model.groupOP}get notMode(){return!0===this.model.notMode}test(t,e,i){let s=!0;if(0===this.conds.length)throw new a(this.model,"界面连接条件逻辑组未配置逻辑项");for(let a=0;a<this.conds.length;a++){const n=this.conds[a].test(t,e,i);if("AND"===this.op&&!1===n){s=!1;break}if("OR"===this.op&&!0===n){s=!0;break}}const n=this.notMode?!s:s;return ibiz.log.debug("界面逻辑连接条件组名称:".concat(this.model.name,"-条件组标识:").concat(this.model.id,"-运行结果:"),n),n}},Gr=class{constructor(t){this.model=t,this.srcNode=null,this.dstNode=null,this.groupCond=null;const{linkMode:e,deuilogicLinkGroupCond:a}=this.model;0===(e||0)&&a&&(this.groupCond=new Br(a))}async exec(t){const{linkMode:e}=this.model,{context:a,data:s}=t;switch(e||0){case 0:return!this.groupCond||this.groupCond.test(t,a,s&&s.length>0?s[0]:{});case 1:return!0;case 2:throw new i(this.model,"未支持的逻辑连接类型: 异步结束");case 3:throw new i(this.model,"未支持的逻辑连接类型: 异步拒绝");case 9:throw new i(this.model,"未支持的逻辑连接类型: 异常处理");default:throw new i(this.model,"未支持的逻辑连接类型:".concat(e))}}},jr=class{constructor(t){this.model=t,this.links=(t.deuilogicLinks||[]).map((t=>new Gr(t)))}},Kr=class extends jr{async exec(t){const{dstAppDataEntityId:e,dstAppDEActionId:i,dstDEUILogicParamId:s,retDEUILogicParamId:n}=this.model;if(!e)throw new a(this.model,"未指定应用实体");if(!i)throw new a(this.model,"未指定实体行为");const o=t.params[s],r=ibiz.hub.getApp(t.context.srfappid),c=await r.deService.exec(e,i,t.context,o,t.viewParam);c.ok&&(t.params[n]=c.data,t.setLastReturn(t.params[n])),ibiz.log.debug("界面逻辑节点(实体行为):".concat(this.model.id,"-界面行为所属实体:").concat(e,"-实体行为标识:").concat(i,"-参数名称:").concat(n,"-值:"),t.params[n])}},Xr=class extends jr{async exec(t){const{dstAppDEUIActionId:e,dstDEUILogicParamId:i,dstAppDataEntityId:s}=this.model,{data:n,parameters:o}=t;if(!e)throw new a(this.model,"未配置界面行为");let r=[n];if(i){const e=t.params[i];r=e instanceof Array?e:[e]}ibiz.log.debug("界面逻辑节点(实体界面行为):".concat(this.model.id,"-界面行为标识:").concat(e,"-界面行为所属实体:").concat(s,"-目标逻辑参数对象:").concat(i)),await fc.execAndResolved(e,{...o,context:t.context,params:t.viewParam,data:r},this.model.appId)}},Hr=class extends jr{async exec(t){ibiz.log.debug("界面逻辑节点(启动节点):".concat(this.model.id))}},qr=class extends jr{async exec(t){t.isEndNode=!0;const{returnType:e,rawValue:a,returnParamId:s}=this.model;if(e){switch(e){case"NONEVALUE":t.result=void 0;break;case"NULLVALUE":t.result=null;break;case"SRCVALUE":t.result=ibiz.util.rawValue.format(a);break;case"LOGICPARAM":t.result=t.params[s];break;default:throw new i(this.model,"暂未支持的结束节点返回值类型: ".concat(e))}ibiz.log.debug("界面逻辑节点(结束节点):".concat(this.model.id,"-返回值类型:").concat(e,"-返回值:"),t.result)}}},Yr=class extends jr{async exec(t){const e=this.model.deuilogicNodeParams;if(null==e?void 0:e.length)for(const a of e){let e;switch(a.dstDEUILogicParamId&&"DEBUG"===ibiz.env.logLevel&&(e=Z(t.params[a.dstDEUILogicParamId])),a.paramAction){case"SETPARAMVALUE":await this.setParamValue(a,t);break;case"RESETPARAM":await this.resetParam(a,t);break;case"COPYPARAM":await this.copyParam(a,t);break;case"BINDPARAM":await this.bindParam(a,t);break;case"RENEWPARAM":await this.renewParam(a,t);break;case"APPENDPARAM":await this.appendParam(a,t);break;case"SORTPARAM":await this.sortParam(a,t);break;default:throw new i(a,"暂未支持逻辑处理参数操作".concat(a.paramAction))}ibiz.log.debug("界面逻辑节点(准备参数):".concat(this.model.id,"-参数处理操作:").concat(a.paramAction,"-目标逻辑参数:").concat(a.dstDEUILogicParamId,"-源参数(值):"),e,"-目标参数(值):",t.params[a.dstDEUILogicParamId])}}setParamValue(t,e){const{dstFieldName:a,dstDEUILogicParamId:i}=t;if(!i)throw new o("没有目标参数对象id");let s=a;e.isEntityParam(i)&&(s=null==s?void 0:s.toLowerCase());const n=Wr(e,t);if(s)try{Qe.execScriptFn({srcVal:n,dstParam:e.params[i]},"dstParam.".concat(a," = srcVal"),{singleRowReturn:!1,isAsync:!1})}catch(t){throw ibiz.log.error("给目标参数属性".concat(a,"赋值报错,目标参数:"),e.params[i]),t}else e.params[i]=n}copyParam(t,e){const{dstDEUILogicParamId:a}=t,i=Wr(e,t);e.params[a]=Z(i)}bindParam(t,e){const a=Wr(e,t);e.params[t.dstDEUILogicParamId]=a}resetParam(t,e){const{dstDEUILogicParamId:a}=t;e.resetParam(a)}renewParam(t,e){const{dstDEUILogicParamId:a}=t;e.renewParam(a)}appendParam(t,e){const{dstDEUILogicParamId:a,dstIndex:i,srcIndex:s,srcSize:n}=t,o=Wr(e,t),r=i||0,c=s||0,d=n||o.length;e.params[a].splice(r,0,...o.slice(c,d))}sortParam(t,e){const{dstDEUILogicParamId:a,dstFieldName:i,dstSortDir:s}=t,n=i;e.params[a].sort(((t,e)=>"ASC"===s?t[n]-e[n]:e[n]-t[n]))}},Qr=class extends jr{async exec(t){t.isEndNode=!0;const{invokeMethod:e,invokeCtrlId:i,invokeParamId:s}=this.model;if(!i)throw new a(this.model,"没有配置界面对象");if(!s)throw new a(this.model,"没有配置操作参数");if(!e)throw new a(this.model,"没有配置调用方法");const n=t.params[s];if(!n)throw new o("没有找到操作参数".concat(s));const r=t.params[i];if(!r)throw new o("没有找到界面对象".concat(i));if(!r[e]||!q(r[e]))throw new o("没有找到调用方法".concat(e));ibiz.log.debug("界面逻辑节点(视图部件调用):".concat(this.model.id,"-调用视图部件名称:").concat(i,"-调用方法名称:").concat(e,"-触发参数:"),n),await r[e](n)}},$r=class extends jr{async exec(t){const{dstDEUILogicParamId:e,srcDEUILogicParamId:i}=this.model;if(!e||!i)throw new a(this.model,"缺少目标参数对象或者源参数对象配置");const s=Wr(t,this.model);t.params[e]=s,t.setLastReturn(t.params[e]),ibiz.log.debug("界面逻辑节点(绑定参数):".concat(this.model.id,"-参数名称:").concat(e,"-值:"),s)}},Jr=class extends jr{constructor(){super(...arguments),this.typeMap={INFO:"info",QUESTION:"success",WARNING:"warning",ERROR:"error"}}async exec(t){const{msgBoxType:e,buttonsType:s,msgBoxParamId:n}=this.model;if(!e)throw new a(this.model,"缺少消息类型的配置");if(!s)throw new a(this.model,"缺少按钮类型的配置");let{title:o,message:r}=this.model;if(n){const e=t.params[n];e.title&&(o=e.title),e.message&&(r=e.message)}const c=this.typeMap[e],d={type:c,title:o||"消息",desc:r};let l=[];switch(s){case"YESNO":d.confirmButtonText="是",d.cancelButtonText="否",d.showConfirmButton=!0,d.showCancelButton=!0,l=["yes","no"];break;case"OK":d.confirmButtonText="确定",d.showConfirmButton=!0,d.showCancelButton=!1,l=["ok"];break;case"OKCANCEL":d.confirmButtonText="确定",d.cancelButtonText="取消",d.showConfirmButton=!0,d.showCancelButton=!0,l=["ok","cancel"];break;default:throw new i(this.model,"".concat(s,"暂未支持"))}ibiz.log.debug("界面逻辑节点(消息弹窗):".concat(this.model.id,"-消息类型:").concat(c,"-消息:").concat(r));const h=await ibiz.modal.confirm(d);t.setLastReturn(l[h?0:1])}},Zr=class extends jr{async exec(t){ibiz.log.debug("界面逻辑节点(前端插件):".concat(this.model.id,"-插件标识:").concat(this.model.sysPFPluginId));const e=await Ds(this.model);e&&await e.exec(this.model,t)}},tc=class extends jr{async exec(t){const{dstDEUILogicParamId:e,name:i}=this.model;if(!e)throw new a(this.model,"缺少目标参数对象配置");const s=t.params[e];ibiz.log.info("逻辑节点".concat(i,"操作参数值:"),s)}},ec=class extends jr{async exec(t){const{dstDEUILogicParamId:e}=this.model;if(!e)throw new a(this.model,"缺少目标参数对象配置");t.resetParam(e),t.setLastReturn(t.params[e]),ibiz.log.debug("界面逻辑节点(重置参数):".concat(this.model.id,"-重置参数:").concat(e))}},ac=class extends jr{async exec(t){const{dstDEUILogicParamId:e,srcDEUILogicParamId:i}=this.model;if(!e||!i)throw new a(this.model,"缺少目标参数对象或者源参数对象配置");const s=Wr(t,this.model);t.params[e]=Z(s),t.setLastReturn(t.params[e]),ibiz.log.debug("界面逻辑节点(拷贝参数):".concat(this.model.id,"-参数名称:").concat(e,"-值:"),s)}},ic=class extends jr{async exec(t){const{dstDEUILogicParamId:e,srcDEUILogicParamId:i,dstIndex:s,srcIndex:n,srcSize:o}=this.model;if(!e||!i)throw new a(this.model,"缺少目标参数对象或者源参数对象配置");const r=Wr(t,this.model),c=s||0,d=n||0,l=o||r.length;t.params[e].splice(c,0,...r.slice(d,l)),t.setLastReturn(t.params[e]),ibiz.log.debug("界面逻辑节点(附加到数组):".concat(this.model.id,"-附加参数:"),t.params,"-附加值:",r.slice(d,l))}},sc=class extends jr{async exec(t){const{dstDEUILogicParamId:e,dstSortDir:i,dstFieldName:s}=this.model;if(!e||!s)throw new a(this.model,"缺少目标参数对象或目标属性配置");const n=s,o=t.params[e];o.sort(((t,e)=>"ASC"===i?t[n]-e[n]:e[n]-t[n])),t.setLastReturn(t.params[e]),ibiz.log.debug("界面逻辑节点(排序数组参数):".concat(this.model.id,"-排序属性:").concat(s,"-排序模式:").concat(i,"-参数名称:").concat(e,"-排序后数组:"),o)}},nc=class extends jr{async exec(t){const{dstDEUILogicParamId:e}=this.model;if(!e)throw new a(this.model,"缺少目标参数对象配置");t.renewParam(e),t.setLastReturn(t.params[e]),ibiz.log.debug("界面逻辑节点(重新建立参数):".concat(this.model.id,"-重建参数:").concat(e))}},oc=class extends jr{async exec(t){const{dstAppDEDataSetId:e,dstAppDataEntityId:i,dstDEUILogicParamId:s,retDEUILogicParamId:n}=this.model;if(!s)throw new a(this.model,"缺少配置过滤参数");const o=t.params[s],r=ibiz.hub.getApp(t.context.srfappid),c=await r.deService.exec(i,e,t.context,o);c.ok&&(t.params[n]=c.data,t.setLastReturn(t.params[s])),ibiz.log.debug("界面逻辑节点(数据集合):".concat(this.model.id,"-数据集实体标识:").concat(i,"-数据集标识:").concat(e,"-参数名称:").concat(n,"-值:"),t.params[n])}},rc=class extends jr{async exec(t){const{errorInfo:e}=this.model;throw ibiz.log.debug("界面逻辑节点(抛出异常):".concat(this.model.id,"-错误信息:").concat(e)),new o(e)}},cc=class extends jr{async exec(t){t.isEndNode=!0;const{eventName:e,eventParamId:i,fireCtrlId:s}=this.model;if(!s)throw new a(this.model,"没有配置触发对象");if(!e)throw new a(this.model,"没有配置事件名称参数");if(!i)throw new a(this.model,"没有配置事件参数");const n=t.params[s];if(!n)throw new o("没有找到触发对象".concat(s));const r=t.params[i];if(!r)throw new o("没有找到事件参数对象".concat(i));ibiz.log.debug("界面逻辑节点(视图部件事件触发逻辑):".concat(this.model.id,"-调用视图部件名称:").concat(s,"-触发事件名称:").concat(e,"-触发参数:"),r),await n.evt.emit(e,r)}},dc=class extends jr{async exec(t){const{dstAppDELogicId:e,dstAppDataEntityId:i,dstDEUILogicParamId:s,retDEUILogicParamId:n}=this.model;if(!i)throw new a(this.model,"没有配置实体");if(!e)throw new a(this.model,"没有配置实体逻辑");if(!s)throw new a(this.model,"没有配置传入逻辑参数");const r=t.params[s];if(!r)throw new o("没有找到传入参数".concat(s));const c=await $n(e,i,t.context,r,t.params);n&&(t.params[n]=c,t.setLastReturn(t.params[n])),ibiz.log.debug("界面逻辑节点(执行实体逻辑):".concat(this.model.id,"-实体逻辑标识:").concat(e,"-实体逻辑所属实体:").concat(i,"-参数名称:").concat(n,"-值:"),c)}},lc=class extends jr{async exec(t){ibiz.log.debug("界面逻辑节点(直接代码):".concat(this.model.id,"-直接代码:"),this.model.code),Qe.execScriptFn({view:t.view,context:t.context,params:t.viewParam,uiLogic:t.params},this.model.code||"",{isAsync:!1})}},hc=class{constructor(t){this.model=t}calc(t){const e=this.model.id,a=this.model,{parameters:i}=t,{context:s,params:n,data:o}=i,r=ibiz.hub.getApp(a.appId);if("layoutPanel"!==a.codeName){if(a.default)a.entityListParam?t.params[e]=o||[]:t.params[e]=o&&o.length>0?o[0]:{};else if(a.activeContainerParam)t.params[e]=i.ctrl||i.view;else if(a.activeCtrlParam)t.params[e]=i.ctrl;else if(a.ctrlParam){const s=i.view.getController(a.codeName.toLowerCase());s?t.params[e]=s:ibiz.log.error("视图逻辑初始化参数,未找到".concat(a.codeName,"指定部件对象"))}else if(a.activeViewParam)t.params[e]=i.view;else if(a.appGlobalParam){let i=ibiz.util.getGlobalParam();a.paramFieldName&&(i=i[a.paramFieldName]),t.params[e]=i}else if(a.applicationParam)t.params[e]=r;else if(a.entityListParam)t.params[e]=[];else if(a.entityPageParam)t.params[e]=[];else if(a.entityParam)t.params[e]={};else if(a.lastReturnParam)t.initLastReturnParam(e);else if(a.navContextParam)t.params[e]=s;else if(a.navViewParamParam)t.params[e]=ibiz.util.getRouterParams();else if(a.routeViewSessionParam){let s=i.view.getTopView().state;a.paramFieldName&&(s=s[a.paramFieldName]),t.params[e]=s}else if(a.simpleListParam)t.params[e]=[];else if(a.simpleParam)t.params[e]={};else if(a.viewNavDataParam)t.params[e]=n;else if(a.viewSessionParam){let s=i.view.state;a.paramFieldName&&(s=s[a.paramFieldName]),t.params[e]=s}else a.filterParam?t.params[e]={}:a.envParam?t.params[e]=ibiz.env:a.sessionParam&&(t.params[e]=t.session);ibiz.log.debug("计算界面逻辑参数,标识:".concat(e),"-值:",t.params[e])}else t.params[e]=i.view.layoutPanel.panelItems}renew(t){const e=this.model.id,a=this.model;if(a.entityListParam||a.simpleListParam||a.entityPageParam)t.params[e]=[];else{if(!a.simpleParam&&!a.entityParam)throw new i(a,"未支持的逻辑参数类型重新建立变量");t.params[e]={}}ibiz.log.debug("重新建立界面逻辑参数,标识:".concat(e),"-值:",t.params[e])}},uc=class{constructor(t){var e;if(this.model=t,this.nodes=new Map,this.params=new Map,!(null==(e=t.deuilogicNodes)?void 0:e.length))throw new a(t,"界面逻辑没有配置逻辑节点");t.deuilogicNodes.forEach((t=>{const{logicNodeType:e}=t;let a;switch(e){case"BEGIN":a=new Hr(t);break;case"END":a=new qr(t);break;case"DEACTION":a=new Kr(t);break;case"DEUIACTION":a=new Xr(t);break;case"PREPAREJSPARAM":a=new Yr(t);break;case"RESETPARAM":a=new ec(t);break;case"COPYPARAM":a=new ac(t);break;case"BINDPARAM":a=new $r(t);break;case"VIEWCTRLINVOKE":a=new Qr(t);break;case"MSGBOX":a=new Jr(t);break;case"DEBUGPARAM":a=new tc(t);break;case"APPENDPARAM":a=new ic(t);break;case"SORTPARAM":a=new sc(t);break;case"RENEWPARAM":a=new nc(t);break;case"DEDATASET":a=new oc(t);break;case"THROWEXCEPTION":a=new rc(t);break;case"VIEWCTRLFIREEVENT":a=new cc(t);break;case"DELOGIC":a=new dc(t);break;case"PFPLUGIN":a=new Zr(t);break;case"RAWJSCODE":a=new lc(t);break;default:throw new i(t,"未支持的逻辑节点类型: ".concat(e))}this.nodes.set(t.id,a)})),t.deuilogicParams.forEach((t=>{this.params.set(t.id,new hc(t))})),this.nodes.forEach((t=>{t.links.forEach((e=>{e.srcNode=t,this.nodes.has(e.model.dstDEUILogicNodeId)&&(e.dstNode=this.nodes.get(e.model.dstDEUILogicNodeId))}))}))}initLogicParams(t){this.params.forEach((e=>{e.model.default&&(t.defaultParamName=e.model.id),e.calc(t)}))}async exec(t){const e=new kr(this.params,t);this.initLogicParams(e);const{startDEUILogicNodeId:i}=this.model;if(!i||!this.nodes.has(i))throw new a(this.model,"未设置起始节点");{const t=this.nodes.get(i);await this.deepExec(t,e)}return e.isEndNode?e.result:e.params[e.defaultParamName]?e.params[e.defaultParamName]:null}async deepExec(t,e){await t.exec(e);const{links:a}=t;for(let i=0;i<a.length;i++){const s=a[i];if(await s.exec(e)&&s.dstNode&&(await this.deepExec(s.dstNode,e),!0!==t.model.parallelOutput))break}}},pc=new Map;async function mc(t,e,a){const i=ibiz.hub.getApp(a.context.srfappid),s=await i.getDEUILogic(t,e);if(!s)throw new o("找不到实体".concat(e,"的界面逻辑").concat(t));pc.has(s)||pc.set(s,new uc(s)),ibiz.log.debug("开始执行界面逻辑,实体:".concat(e,"-逻辑名称:").concat(s.name));const n=pc.get(s),r=await n.exec(a);return ibiz.log.debug("结束执行界面逻辑,实体:".concat(e,"-逻辑名称:").concat(s.name)),r}var fc=t("UIActionUtil",class{static async exec(t,e,a){const i=await Ae(t,a);if(!i)throw new o("没找到".concat(t,"的界面行为模型"));if("SINGLEDATA"===i.actionTarget){if(!1===await e.view.call("Validate"))return{cancel:!0}}return(await vs(i)).exec(i,e)}static async execAndResolved(t,e,a){var i,s;const n=await this.exec(t,e,a);if(n.closeView)e.view.modal.ignoreDismissCheck=!0,e.view.closeView({ok:!0});else if(n.refresh)switch(n.refreshMode){case 1:e.view.callUIAction("Refresh");break;case 2:null==(i=e.view.parentView)||i.callUIAction("Refresh");break;case 3:null==(s=e.view.getTopView())||s.callUIAction("Refresh")}(await Ae(t,a)).asyncAction&&!n.cancel&&this.handleAsyncAction(e.event)}static async handleAsyncAction(t){this.handleAsyncActionAnime(t)}static async handleAsyncActionAnime(t){t&&t.target&&await ibiz.util.anime.moveAndResize(t.target,"#".concat("preset-message"))}}),gc=t("UIActionProviderBase",class{async exec(t,e){const i={refresh:t.reloadData,refreshMode:t.refreshMode,closeView:t.closeEditView},{view:s}=e;t.closeEditView&&(s.state.isClosing=!0);const{appDEUILogicId:n,appDataEntityId:o,uilogicAttachMode:r}=t;if("REPLACE"===r){if(!n)throw new a(t,"没有配置实体界面逻辑");return await mc(n,o,e),i}if(!await this.isConfirm(t,e))return this.returnError(i,s);const c=await this.execAction(t,e);if(Object.assign(i,c),!0===i.cancel)return this.returnError(i,s);if("AFTER"===t.uilogicAttachMode){if(!n)throw new a(t,"没有配置实体界面逻辑");await mc(n,o,this.mergeArgsByResult(e,i))}const d=this.mergeArgsByResult(e,i);if(t.closeEditView)this.doNextAction(t,d,t.appId);else{const e=await this.doNextAction(t,d,t.appId);if(e&&(Object.assign(i,e),!0===e.cancel))return this.returnError(i,s)}return i}mergeArgsByResult(t,e){return{...t,context:e.nextContext||t.context,data:e.data||t.data,params:e.nextParams||t.params}}returnError(t,e){return e.state.isClosing=!1,Object.assign(t,{refresh:!1,closeView:!1})}async isConfirm(t,e){const a=this.calcMessage("confirm",t,e);return!t.enableConfirm||!a||ibiz.confirm.warning({title:"操作确认",desc:a})}async doNextAction(t,e,a){const i=t.nextId;if(i)return fc.exec(i,e,a)}async handleParams(t,e,a,i){let s=[];const n=ve(t.appDataEntityId),o=(await ibiz.hub.getAppDataEntity(t.appDataEntityId,e.srfappid)).keyAppDEFieldId;switch(t.actionTarget){case"NONE":s=[];break;case"SINGLEDATA":s=[a[0]];break;case"MULTIDATA":s=a;break;case"MULTIKEY":s=n&&a.length>0?a.map((t=>({[o]:t.srfkey||t[o]}))):[{}];break;case"SINGLEKEY":{const t=a[0]||{};s=n?[{[o]:t.srfkey||t[o]}]:[{}]}}const r=e.clone(),c=[...t.navigateContexts||[]];if(n&&"NONE"!==t.actionTarget){const{valueItem:e,paramItem:a}=t,i=a||n,s=e||"srfkey";c.unshift({key:i,value:s,rawValue:!1})}const d=["MULTIKEY","MULTIDATA"].includes(t.actionTarget)&&a.length>0,l=oe(c,d?de(c,a):a[0]||{},i,e);Object.assign(r,l);const h=t.navigateParams;return{resultContext:r,resultData:s,resultParams:oe(h,d?de(h,a):a[0]||{},i,r)}}calcMessage(t,e,a){let i,s;const{confirmMsg:n,cmlanguageRes:o,successMsg:r,smlanguageRes:c}=e;switch(t){case"confirm":i=n,s=o;break;case"success":i=r,s=c}if(s){const t=ibiz.i18n.t(s.lanResTag,s.defaultContent||i);t!==s.lanResTag&&(i=t)}if(i){const{data:t}=a,e={...a};return 1===t.length?[e.data]=t:0===t.length&&delete e.data,Qe.execScriptFn(e,"`".concat(i,"`"),{isAsync:!1,singleRowReturn:!0})}}handleViewOptionParams(t){if(t.modaloption)try{const e=JSON.parse(t.modaloption);return delete t.modaloption,{modalOption:e}}catch(t){ibiz.log.error("视图参数modalOption 解析失败:".concat(t))}return{}}}),wc=t("BackendUIActionProvider",class extends gc{async execAction(t,e){const{context:i,params:s,data:n,event:o}=e,r={},c=t.appDataEntityId,d=t.appDEMethodId;if(!c||!d)throw new a(t,"未配置实体或实体行为");const{resultContext:l,resultParams:h,resultData:u}=await this.handleParams(t,i,n,s),p={...h},m=t.frontAppViewId;if(m){const t=this.handleViewOptionParams(h),e=await ibiz.commands.execute(So.TAG,m,l,h,{event:o,...t});if(!(null==e?void 0:e.ok))return r.cancel=!0,r;if((null==e?void 0:e.ok)&&e.data){0===u.length&&u.push({});const t=e.data.map((t=>{var e;return(null==(e=t.getOrigin)?void 0:e.call(t))||t||{}}));u.forEach((e=>{e.srfactionparam=t}))}}const f=ibiz.hub.getApp(null==i?void 0:i.srfappid),g=u.map((t=>{var e;return(null==(e=t.getOrigin)?void 0:e.call(t))||t||{}})).map((t=>Object.assign(t,p))),w=["MULTIKEY","MULTIDATA"].includes(t.actionTarget),E=await f.deService.exec(c,d,l,w?g:g[0],p);if(E.ok){const a=this.calcMessage("success",t,e);a&&ibiz.message.success(a)}return Object.assign(r,{data:lt(E.data)?E.data:[E.data],nextContext:l,nextParams:p}),r}}),Ec=t("SysUIActionProvider",class extends gc{constructor(){super(...arguments),this.predefinedActionMap=new Map([["EDITVIEW_EXITACTION","Exit"],["EDITVIEW_SAVEANDEXITACTION","SaveAndExit"],["TREEVIEW_REFRESHPARENTACTION","RefreshParent"],["GRIDVIEW_EXPORTXMLACTION","ExportModel"],["GRIDVIEW_EXPORTACTION","ExportExcel"],["EDITVIEW_REMOVEANDEXITACTION","RemoveAndExit"],["GRIDVIEW_PRINTACTION","Print"],["EDITVIEW_NEXTRECORDACTION","NextRecord"],["GRIDVIEW_NEWROWACTION","NewRow"],["EDITVIEW_LASTRECORDACTION","LastRecord"],["EDITVIEW_PREVRECORDACTION","PrevRecord"],["GRIDVIEW_SEARCHBAR","ToggleFilter"],["EDITVIEW_SAVEANDSTARTWFACTION","SaveAndStart"],["EDITVIEW_NEWACTION","New"],["EDITVIEW_PRINTACTION","Print"],["EDITVIEW_COPYACTION","Copy"],["EDITVIEW_HELPACTION","Help"],["EDITVIEW_FIRSTRECORDACTION","FirstRecord"],["GRIDVIEW_REFRESHACTION","Refresh"],["EDITVIEW_SAVEANDNEWACTION","SaveAndNew"],["EDITVIEW_VIEWWFSTEPACTORACTION","ViewWFStep"],["EDITVIEW_SAVEACTION","Save"],["TREEVIEW_REFRESHALLACTION","RefreshAll"],["GRIDVIEW_IMPORTBAR","Import"],["GRIDVIEW_ROWEDITACTION","ToggleRowEdit"],["GRIDVIEW_NEWACTION","New"],["GRIDVIEW_EDITACTION","Edit"],["GRIDVIEW_HELPACTION","Help"],["EDITVIEW_REFRESHACTION","Refresh"],["GRIDVIEW_REMOVEACTION","Remove"],["GRIDVIEW_COPYACTION","Copy"],["GRIDVIEW_VIEWACTION","View"],["GRIDVIEW_SAVEROWACTION","SaveRow"],["APP_LOGIN","Login"],["APP_LOGOUT","logout"],["UTIL_RESET","Reset"],["UTIL_SEARCH","Search"]])}async execAction(t,e){const{view:a}=e,i=this.predefinedActionMap.get(t.predefinedType)||t.uiactionTag;if("Exit"===i)return{closeView:!0};return await a.callUIAction(i,e)||{}}}),yc=t("FrontUIActionProvider",class extends gc{async execAction(t,e){const{context:s,params:n,data:o,event:r,noWaitRoute:c}=e;let d={};switch(t.frontProcessType){case"OPENHTMLPAGE":{const e=D.fill(t.htmlPageUrl,s,null==o?void 0:o[0]);window.open(e,"_blank");break}case"TOP":case"WIZARD":{const e=t.frontAppViewId;if(!e)throw new a(t,"未配置打开视图");const{resultContext:i,resultParams:l}=await this.handleParams(t,s,o,n),h=this.handleViewOptionParams(l),u=await ibiz.commands.execute(So.TAG,e,i,l,{event:r,noWaitRoute:c,...h});(null==u?void 0:u.ok)||(d.cancel=!0),(null==u?void 0:u.ok)&&u.data&&(d.data=u.data,d.nextContext=i,d.nextParams={...n,...l});break}case"PRINT":await this.executePrint(t,e);break;case"DATAIMP":d=await this.executeDataImport(t,e);break;case"DATAEXP":await this.executeDataExport(t,e);break;case"OTHER":d=this.doOther(t,e);break;case"EDITFORM":d=await this.openEditForm(t,e);break;default:throw new i(t,"未支持的前台处理模式[".concat(t.frontProcessType,"]"))}return d}doOther(t,e){const{scriptCode:i}=t,{context:s,params:n,data:o,event:r,view:c}=e;if(i){return Qe.execScriptFn({context:s,params:n,data:o,el:null==r?void 0:r.target,view:c},i)||{}}throw new a(t,"自定义类型缺少配置脚本代码")}async executePrint(t,e){var a,i;const{resultContext:s,resultParams:n}=await this.handleParams(t,e.context,e.data,e.params),r=await ibiz.hub.getAppDataEntity(t.appDataEntityId,t.appId),c=null==(a=r.appDEPrints)?void 0:a.find((e=>e.id===t.appDEPrintId));if(!c)throw new o("没有找到实体打印项");{let t="";if(!s||!s[r.codeName.toLowerCase()])throw new o("没有找到数据主键");t+="/".concat(r.deapicodeName2,"/printdata/").concat(s[r.codeName.toLowerCase()]);const e=await ibiz.net.request(t,{method:"get",responseType:"blob",params:{srfprinttag:c.codeName,...n}});if(!e.ok)throw new o("打印失败");if(n&&n.srfcontenttype){const t=null==(i=e.headers["content-disposition"].split(";").find((t=>-1!==t.indexOf("filename="))))?void 0:i.slice(9),a=URL.createObjectURL(e.data),s=document.createElement("a");s.href=a,s.download=t,document.body.appendChild(s),s.click(),document.body.removeChild(s),URL.revokeObjectURL(a)}else{const t=window.URL.createObjectURL(e.data);window.open(t,"_blank")}}}async executeDataImport(t,e){const{resultContext:i,resultParams:s}=await this.handleParams(t,e.context,e.data,e.params),{appDataEntityId:n,appDEDataImportId:o,frontAppViewId:r}=t;if(!n||!o)throw new a(t,"没有配置导入模型!");return await hr({appDataEntityId:n,deDataImportId:o,dataImportViewId:r,context:i,params:s}),{refresh:!0,refreshMode:1}}async executeDataExport(t,e){var a;const{resultParams:i}=await this.handleParams(t,e.context,e.data,e.params),s=await ibiz.hub.getAppDataEntity(t.appDataEntityId,t.appId),n=null==(a=s.appDEDataExports)?void 0:a.find((e=>e.id===t.appDEDataExportId));if(!n)throw new o("没有找到实体导出项");{const t="/".concat(s.deapicodeName2,"/exportdata/fetchdefault?srfexporttag=").concat(n.codeName),a={page:0,size:n.maxRowCount?n.maxRowCount:1e3,...e.params,...i},r=await ibiz.net.request(t,{method:"post",data:a});if(200!==r.status)throw new o("导出请求失败");{let t="".concat(s.logicName,"表.xlsx");t=decodeURIComponent(t);const e=new Blob([r.data],{type:"application/vnd.ms-excel"}),a=document.createElement("a");a.download=t,a.style.display="none",a.href=URL.createObjectURL(e),document.body.appendChild(a),a.click(),URL.revokeObjectURL(a.href),document.body.removeChild(a)}}}async openEditForm(t,e){const a={},{context:i,params:s,data:n,event:r}=e;if(!r)throw new o("缺少原生JS事件对象");const{resultContext:c,resultParams:d}=await this.handleParams(t,i,n,s),l=this.handleViewOptionParams(d).modalOption||{},h=$({autoClose:!0},l);let u=!1;const p=ibiz.overlay.createPopover("IBizControlShell",{context:c,params:d,modelData:t.deeditForm,onSaveSuccess:t=>{a.data=[t.args],p&&p.dismiss(),u=!0}},h);return p.present(r.target),await p.onWillDismiss(),u||(a.cancel=!0),a}}),vc=t("WFWithdrawUIActionProvider",class extends gc{async execAction(t,e){const{view:a}=e;let i=!1;return await ibiz.modal.confirm({title:"提示",desc:"是否确认执行撤回操作?"})&&a&&(await a.call("WFWithdraw",e),i=!0),{refresh:!1,closeView:i}}}),Ic=class extends gc{async execAction(t,e){if(await ibiz.confirm.info({title:"退出登录",desc:"您确定要退出登录吗?"})){await ibiz.hub.controller.logout()&&window.location.reload()}return{}}};function Dc(){const t=new yc;Es("FRONT",(()=>t));const e=new wc;Es("BACKEND",(()=>e));const a=new Ec;Es("SYS",(()=>a));const i=new vc;Es("DEUIACTION_WFWithdraw",(()=>i));const s=new Ic;Es("SYS_Logout",(()=>s))}var Cc=t("ToolbarController",class extends Dr{get _evt(){return this.evt}initState(){super.initState(),this.state.buttonsState=new qo,this.state.viewMode="EMBED",this.state.extraButtons={}}async doUIAction(t,e,a={}){if("DEUIACTION"===t.itemType){const i=t.uiactionId,s=await Ae(i,t.appId);if(!s)throw new o("没有找到界面行为模型".concat(i));const n=["SYS","BACKEND","WFBACKEND"].includes(s.uiactionMode)&&!1!==s.showBusyIndicator;n&&this.state.buttonsState.setLoading(t.id);try{const s=await this.ctx.view.call("GetData")||[],n=this.getEventArgs();n.params=Object.assign(a,n.params),await fc.execAndResolved(i,{...n,data:s,event:e},t.appId)}finally{n&&this.state.buttonsState.setLoading("")}}}async onCreated(){await super.onCreated(),this.state.viewMode=this.ctx.view.modal.mode,r(this.model,(t=>{if(t.itemType){const e=t,a=new Ho(e.id,this.context.srfappid,e.uiactionId);this.state.buttonsState.addState(e.id,a)}if(t.controlLogics)for(let e=0;e<t.controlLogics.length;e++){const a=t.controlLogics[e],i=this.state.buttonsState[t.id];if(a.itemName===t.id&&"ITEMVISIBLE"===a.triggerType&&i){i.visible=!1;break}}}),{childrenFields:["detoolbarItems"]}),this.state.manualCalcButtonState?await this.state.buttonsState.init():await this.calcButtonState(void 0,this.model.appDataEntityId)}async onItemClick(t,e,a){const i="extra"===t.buttonType;await this._evt.emit("onClick",{event:e,eventArg:t.id,buttonType:i?"extra":"deuiaction"}),i||await this.doUIAction(t,e,a)}async calcButtonState(t,e){let a=t;if(t&&t instanceof En&&(a=t.getOrigin()),await this.state.buttonsState.update(this.context,a,e),this.scheduler){const t={};a&&(t.data=[a]),r(this.model,(e=>{const a=this.state.buttonsState[e.id];if(a){if(a.visible){const i=this.scheduler.triggerItemVisible(e.id,t);void 0!==i&&(a.visible=i)}if(!a.disabled){const i=this.scheduler.triggerItemEnable(e.id,t);void 0!==i&&(a.disabled=!i)}}}),{childrenFields:["detoolbarItems"]})}}setExtraButtons(t,e){this.state.extraButtons[t]||(this.state.extraButtons[t]=[]),this.state.extraButtons[t].push(...e)}clearExtraButtons(t){void 0===t?this.state.extraButtons={}:this.state.extraButtons[t]=[]}initControlScheduler(t=[]){const e=[...t];r(this.model,(t=>{t.controlLogics&&e.push(...t.controlLogics)}),{childrenFields:["detoolbarItems"]}),super.initControlScheduler(e)}convertMultipleLanguages(){const t=e=>{e.forEach((e=>{e.capLanguageRes&&e.capLanguageRes.lanResTag&&(e.caption=ibiz.i18n.t(e.capLanguageRes.lanResTag,e.caption)),"ITEMS"===e.itemType&&e.detoolbarItems&&t(e.detoolbarItems)}))};this.model.detoolbarItems&&this.model.detoolbarItems.length>0&&t(this.model.detoolbarItems)}}),bc=t("ContextMenuController",class extends Cc{}),Ac=(t("DashboardController",class extends Dr{constructor(){super(...arguments),this.providers={},this.portlets={}}initState(){super.initState()}async onCreated(){await super.onCreated(),await this.initPortlets(this.model.controls);const{appDataEntityId:t}=this.view.model;t&&this.view.evt.on("onDataChange",(t=>{const e=Zo(t.data);e&&this.dataChangeNotify(e)}))}async initPortlets(t,e){if(!(null==t?void 0:t.length))return;const a=["CHART","APPMENU","TOOLBAR","LIST"];await Promise.all(t.map((async t=>{var i;if(t.controlType&&a.includes(t.controlType))return;const s=await gs(t);if(s){this.providers[t.id]=s;const a=await s.createController(t,this,e);this.portlets[t.id]=a,(null==(i=t.controls)?void 0:i.length)&&await this.initPortlets(t.controls,a)}})))}async dataChangeNotify(t){await ba(Object.values(this.portlets).map((async e=>e.dataChangeNotify(t))))}}),t("CustomDashboardController",class{constructor(t){var e,a;this.customModelData=[],this.layoutColNum=12,this.layoutRowH=80,this.model=null,this.model=t,this.config=new dn(t.appId,"dynadashboard","dashboard_".concat((null==(e=this.model.appDataEntityId)?void 0:e.toLowerCase())||"app","_").concat(null==(a=this.model.codeName)?void 0:a.toLowerCase()))}async loadCustomModelData(){const t=await this.config.load();return t.model&&(this.customModelData=t.model),t.colNum&&(this.layoutColNum=t.colNum),t.rowH&&(this.layoutRowH=t.rowH),this.customModelData}async saveCustomModelData(t){return await this.config.save({model:t,colNum:this.layoutColNum,rowH:this.layoutRowH})&&(this.customModelData=t),t}}),t("PortletPartState",class{constructor(){this.visible=!0,this.keepAlive=!1,this.layout={width:"",height:"",extraStyle:{},extraClass:[],contentStyle:{}},this.class={container:[],containerDyna:[]},this.actionGroupState=null}})),Pc=t("PortletPartController",class{get context(){return this.dashboard.context}get params(){return this.dashboard.params}get containerClass(){return[...this.state.class.container,...this.state.class.containerDyna]}constructor(t,e,a){this.model=t,this.dashboard=e,this.parent=a,this.state=this.createState()}async init(){await this.onInit()}async onInit(){this.onDataChange=this.onDataChange.bind(this);const{layoutPos:t,sysCss:e}=this.model;if(t){const{width:t,height:e}=ge(this.model);this.state.layout.width="".concat(t),this.state.layout.height="".concat(e)}(null==e?void 0:e.cssName)&&this.state.class.container.push(e.cssName),await this.initActionStates()}createState(){return new Ac}onDataChange(t){let e=t.data[0];e&&e instanceof En&&(e=e.getOrigin()),e&&this.state.actionGroupState.update(this.context,e,this.dashboard.view.model.appDataEntityId)}async initActionStates(){var t;const{uiactionGroup:e}=this.model;if(!(null==(t=null==e?void 0:e.uiactionGroupDetails)?void 0:t.length))return;const a=new qo;e.uiactionGroupDetails.forEach((t=>{const e=t.uiactionId;if(e){const i=new Ho(t.id,this.dashboard.context.srfappid,e);a.addState(t.id,i)}})),await a.update(this.dashboard.context),this.state.actionGroupState=a;const{appDataEntityId:i}=this.dashboard.view.model;i&&this.dashboard.view.evt.on("onDataChange",this.onDataChange)}async onActionClick(t,e,a=[]){const i=t.uiactionId;await fc.execAndResolved(i,{context:this.dashboard.context,params:this.dashboard.params,data:a,view:this.dashboard.view,event:e},t.appId)}async dataChangeNotify(t){if(this.state.actionGroupState){const{appDataEntityId:e}=this.dashboard.view.model;this.state.actionGroupState.update(this.context,t,e)}this.calcDynaClass(t)}calcDynaClass(t){if(this.model.dynaClass){const e=we(this.model.dynaClass,t);e.length&&(this.state.class.containerDyna=e)}}async destroyed(){ibiz.log.debug("".concat(this.model.codeName," onDestroyed")),this.dashboard.view.evt.off("onDataChange",this.onDataChange)}}),Tc=(t("ContainerPortletController",class extends Pc{}),t("ViewPortletController",class extends Pc{}),t("MenuPortletController",class extends Pc{}),t("ChartPortletController",class extends Pc{}),t("ActionBarPortletController",class extends Pc{}),t("HtmlPortletController",class extends Pc{}),t("ListPortletController",class extends Pc{}),t("RawItemPortletController",class extends Pc{}),t("DataViewControlService",class extends vn{initUIDataMap(){var t;super.initUIDataMap(),null==(t=this.model.dedataViewDataItems)||t.forEach((t=>{const e=t.id.toLowerCase(),a=t.appDEFieldId;let i;if(a){const s=a.toLowerCase();i=new fo(e,s,{isOriginField:!0,dataType:t.dataType})}else i=new fo(e,e);this.dataUIMap.set(e,i)}))}})),xc=t("DataViewControlController",class extends Cr{get enableNew(){return!0===this.model.enableCardNew}initState(){super.initState(),this.state.noSort=!0===this.model.noSort,this.state.size=this.model.pagingSize||20,this.state.singleSelect=!0===this.model.singleSelect,this.state.sortItems=[]}async onCreated(){await super.onCreated(),await this.initControlService(),this.initSortItems()}async initControlService(){this.service=new Tc(this.model),await this.service.init(this.context)}async initGroupActionStates(){var t;const{groupUIActionGroup:e}=this.model;(null==(t=null==e?void 0:e.uiactionGroupDetails)?void 0:t.length)&&this.state.groups.forEach((async t=>{const a=new qo;e.uiactionGroupDetails.forEach((t=>{const e=t.uiactionId;if(e){const i=new Ho(t.id,this.context.srfappid,e);a.addState(t.id,i)}})),await a.update(this.context),t.groupActionGroupState=a}))}async onRowClick(t){var e;super.onRowClick(t);const{groupAppDEFieldId:a}=this.model;if(a)if(this.state.groups.forEach((t=>{t.selectedData=[]})),this.state.selectedData.forEach((t=>{const e=t[a],i=this.state.groups.find((t=>t.key===e));i&&i.selectedData.push(t)})),this.state.singleSelect)this.state.groups.forEach((e=>{var a,i;let s=t;-1!==e.selectedData.indexOf(s)?(s&&s instanceof En&&(s=s.getOrigin()),s&&(null==(a=e.groupActionGroupState)||a.update(this.context,s,this.model.appDataEntityId))):null==(i=e.groupActionGroupState)||i.update(this.context,void 0,this.model.appDataEntityId)}));else{const a=this.state.groups.find((e=>-1!==e.children.indexOf(t)));a&&(null==(e=a.groupActionGroupState)||e.update(this.context,a.selectedData[0],this.model.appDataEntityId))}}async loadMore(){this.state.total>this.state.items.length&&await this.load({isLoadMore:!0})}async afterLoad(t,e){return await this.initGroupCodeListItems(),await this.handleDataGroup(),await this.initGroupActionStates(),e}getOptItemModel(){let t=null;const{dedataViewItems:e}=this.model;if(e)for(let a=0;a<e.length;a++)"ACTIONITEM"===e[a].itemType&&(t=e[a]);return t}getOptItemAction(t){var e;const i=new qo,s=this.getOptItemModel();if(s){if(!s.deuiactionGroup)throw new a(this.model,"操作项没有配置界面行为组");if(!(null==(e=s.deuiactionGroup.uiactionGroupDetails)?void 0:e.length))return ibiz.log.debug("操作项界面行为组没有配置界面行为"),i;s.deuiactionGroup.uiactionGroupDetails.forEach((t=>{const e=t.uiactionId;if(e){const a=new Ho(t.id,this.context.srfappid,e);i.addState(t.id,a)}})),i.update(this.context,t.getOrigin())}return i}async onActionClick(t,e,a){const i=t.uiactionId;await fc.execAndResolved(i,{context:this.context,params:this.params,data:[e],view:this.view,event:a},t.appId)}async handleDataGroup(){const{enableGroup:t,groupMode:e,groupAppDEFieldId:i}=this.model;if(t&&e){if(!i)throw new a(this.model,"分组属性没有配置");"AUTO"===e?this.handleAutoGroup():"CODELIST"===e&&await this.handleCodeListGroup()}}handleAutoGroup(){const{groupAppDEFieldId:t}=this.model;if(t){const{items:e}=this.state,a=new Map;e.forEach((e=>{const i=e[t];Q(i)||(a.has(i)||a.set(i,[]),a.get(i).push(e))}));const i=[];a.forEach(((t,e)=>{i.push({caption:e,key:e,children:[...t]})})),this.state.groups=i}}async initGroupCodeListItems(){const{groupCodeListId:t}=this.model;if(!t)return;const e=ibiz.hub.getApp(this.context.srfappid);this.groupCodeListItems=await e.codeList.get(t,this.context,this.params)}async handleCodeListGroup(){const{groupAppDEFieldId:t,groupCodeListId:e}=this.model;if(!e)throw new a(this.model,"分组代码表没有配置");const{items:i}=this.state,s=new Map;this.groupCodeListItems.forEach((t=>{s.set(t.value,[])})),i.forEach((e=>{const a=e[t],i=s.get(a);i&&i.push(e)}));const n=[];s.forEach(((t,e)=>{const a=this.groupCodeListItems.find((t=>t.value===e));n.push({caption:a.text,key:a.value,children:t})})),this.state.groups=n}getSortModel(){return{minorSortAppDEFieldId:this.model.minorSortAppDEFieldId,minorSortDir:this.model.minorSortDir}}onClickNew(t,e){const a={...this.params,srfgroup:e};fc.execAndResolved("new",{context:this.context,params:a,data:[],view:this.view,event:t},this.view.model.appId)}async onGroupToolbarClick(t,e,a){const i=t.uiactionId,s={...this.params,srfgroup:a.key};await fc.execAndResolved(i,{context:this.context,params:s,data:a.selectedData||[],view:this.view,event:e},t.appId)}initSortItems(){var t;if(!(null==(t=this.model.dedataViewItems)?void 0:t.length))return;const e=[],{minorSortAppDEFieldId:i,minorSortDir:s}=this.model,n=i&&s;this.model.dedataViewItems.forEach((t=>{if(!t.enableSort)return;let{caption:o}=t;if(t.capLanguageRes&&(o=ibiz.i18n.t(t.capLanguageRes.lanResTag,t.caption)),!t.appDEFieldId)throw new a(t,"启用排序的项必须关联实体属性");const r={caption:o,key:t.appDEFieldId};n&&i===t.appDEFieldId&&(r.order=s.toLowerCase()),e.push(r)})),e.length>0&&(this.state.sortItems=e)}}),Sc=t("ExpBarControlController",class extends Dr{constructor(){super(...arguments),this.navKeyName="srfkey"}get _evt(){return this.evt}get routeDepth(){return this.view.modal.routeDepth}initState(){super.initState(),this.state.query=""}load(){return this.xDataController.load({isInitialLoad:!0})}get xDataController(){const t=this.view.getController(this.model.xdataControlName);if(!t)throw new a(this.model,"无法获取多数据部件[".concat(this.model.xdataControlName,"]控制器"));return t}get toolbarController(){return this.view.getController("".concat(this.model.xdataControlName.split("_")[0],"_toolbar"))}get XDataModel(){var t;return null==(t=this.model.controls)?void 0:t.find((t=>t.name===this.model.xdataControlName))}get isCache(){return"CACHE"===this.controlParams.expcache||"NO_CACHE"!==this.controlParams.expcache&&ibiz.config.view.expCacheMode.includes(this.model.controlType)}async onCreated(){var t;await super.onCreated(),this.childNames.push(this.model.xdataControlName);const e=await ibiz.hub.getAppDataEntity(this.model.appDataEntityId,this.context.srfappid);if(e){const a=null==(t=e.appDEFields)?void 0:t.filter((t=>t.enableQuickSearch)),i=[];null==a||a.forEach((t=>{(null==t?void 0:t.lnlanguageRes)&&t.lnlanguageRes.lanResTag?i.push(ibiz.i18n.t(t.lnlanguageRes.lanResTag,t.logicName)):(null==t?void 0:t.logicName)&&i.push(t.logicName)})),i.length>0&&(this.state.placeHolder=i.join("、"))}}async onMounted(){super.onMounted(),this.xDataController&&(this.xDataController.evt.on("onActive",(t=>{this.xDataActive(t)})),this.xDataController.evt.on("onLoadSuccess",(t=>{this.xDataLoadSuccess(t)})),this.xDataController.evt.on("onRemoveSuccess",(()=>{this.navByFirstItem()}))),this.toolbarController&&this.xDataController.evt.on("onSelectionChange",(async t=>{this.toolbarController.calcButtonState(t.data[0],this.model.appDataEntityId)})),this.state.loadDefault&&this.load()}xDataLoadSuccess(t){if(t.isInitialLoad)this.state.srfnav&&this.routeDepth?this.navBySrfnav():this.navByFirstItem();else{const t=this.xDataController.state.selectedData;t[0]&&this.xDataController.setActive(t[0])}}navBySrfnav(){var t;const e=null==(t=this.xDataController)?void 0:t.state.items.find((t=>t[this.navKeyName]===this.state.srfnav));if(this.routeDepth&&$o(this.routeDepth))return e&&this.xDataController.setSelection([e]),void this._evt.emit("onNavViewChange",{navViewMsg:{key:this.state.srfnav,isRoutePushed:!0,isCache:this.isCache},context:this.context});e?(this.xDataController.setActive(e),this.xDataController.setSelection([e])):this._evt.emit("onNavViewChange",{navViewMsg:{key:this.state.srfnav,is404:!0,isCache:this.isCache},context:this.context})}navByFirstItem(){const t=this.xDataController.state.items[0];if(!t)return this.state.srfnav="",void this._evt.emit("onNavViewChange",{navViewMsg:{key:"",isCache:this.isCache}});this.xDataController.setActive(t),this.xDataController.setSelection([t])}xDataActive(t){const{data:e,context:a,params:i}=t,s=this.getNavViewMsg(e[0],a,i);this._evt.emit("onNavViewChange",{navViewMsg:s})}prepareParams(t,e,a,i){const{navDER:s,navFilter:n,navigateContexts:o,navigateParams:r,appDataEntityId:c}=t,d={deName:c?ve(c):void 0,navFilter:n,pickupDEFName:null==s?void 0:s.pickupDEFName,navContexts:o,navParams:r},l={context:a,params:i,data:e},{resultContext:h,resultParams:u}=le(d,l),p=Object.assign(a.clone(),h,{currentSrfNav:e[this.navKeyName]});this.state.srfnav=e[this.navKeyName];return{context:p,params:{...u}}}calcViewModelId(){var t;if(["GRID","DATAVIEW","LIST"].includes((null==(t=this.XDataModel)?void 0:t.controlType)||""))return this.XDataModel.navAppViewId;throw new o("多节点视图由子类实现")}getNavViewMsg(t,e,a){const i=this.calcViewModelId(),s=this.prepareParams(this.XDataModel,t,e,a);return{key:t[this.navKeyName],context:s.context,params:s.params,viewId:i,isCache:this.isCache}}calcControlHeaderVisible(){const t=!!this.toolbarController;if(!t&&this.layoutPanel){const t=this.layoutPanel.panelItems.control_toolbar;t&&(t.state.visible=!1)}return t||!(!this.model.showTitleBar||!this.model.title)||!!this.model.enableSearch}setLayoutPanel(t){super.setLayoutPanel(t),t.evt.on("onMounted",(()=>{if(!this.calcControlHeaderVisible()){const t=this.layoutPanel.panelItems.control_header;t&&(t.state.visible=!1)}}))}async onRouterChange(t){this.state.srfnav!==t.srfnav&&(this.state.srfnav=t.srfnav,this.navBySrfnav())}}),Nc=(t("CalendarExpBarController",class extends Sc{constructor(){super(...arguments),this.navKeyName="navId"}getCalendarItemModel(t){const{sysCalendarItems:e}=this.XDataModel;if(e)return e.find((e=>e.itemType===t))}get xDataController(){const t=this.view.getController(this.model.xdataControlName);if(!t)throw new a(this.model,"无法获取多数据部件[".concat(this.model.xdataControlName,"]控制器"));return t}navBySrfnav(){var t;const e=null==(t=this.xDataController)?void 0:t.state.items.find((t=>t.navId===this.state.srfnav));if(super.navBySrfnav(),!e)return;const a=new Date(e.beginTime);this.xDataController.setSelectDate(a)}getNavViewMsg(t){const e=this.getCalendarItemModel(t.itemType);if(e){const{context:a,params:i}=this.prepareParams(e,t.deData?t.deData:t,this.context,this.params);return a.currentSrfNav=t.navId,this.state.srfnav=t.navId,{key:t.navId,context:a,params:i,viewId:e.navAppViewId}}return{key:t.navId,context:this.context,params:this.params}}}),t("TreeExpBarController",class extends Sc{constructor(){super(...arguments),this.navKeyName="_id",this.navNodeModelIds=[]}get xDataController(){const t=this.view.getController(this.model.xdataControlName);if(!t)throw new a(this.model,"无法获取多数据部件[".concat(this.model.xdataControlName,"]控制器"));return t}async onMounted(){super.onMounted(),this.xDataController&&this.xDataController.evt.on("onAfterRefreshParent",(t=>{const e=this.xDataController.state.selectedData;e[0]&&this.xDataController.setActive(e[0])}))}getNodeModel(t){const{detreeNodes:e}=this.XDataModel;let a;return e&&e.forEach((e=>{e.id===t&&(a=e)})),a}xDataActive(t){const{nodeData:e}=t;super.xDataActive({...t,data:[e]})}getNavViewMsg(t,e,a){const i=t._id,s=t._deData||t,n=this.getNodeModel(t._nodeId);if(!n)throw new o("找不到".concat(t._nodeId,"的节点模型"));const r=this.prepareParams(n,s,e,a);return r.context.currentSrfNav=i,this.state.srfnav=i,{key:i,viewId:n.navAppViewId,isCache:this.isCache,...r}}navByFirstItem(){const t=this.xDataController.state.items.find((t=>!(!this.xDataController.model.rootVisible&&this.xDataController.state.rootNodes.includes(t))&&(!!this.state.noNeedNavView||this.navNodeModelIds.includes(t._nodeId))));t&&(this.xDataController.setActive(t),this.xDataController.setSelection([t]))}async onCreated(){await super.onCreated();const{detreeNodes:t}=this.XDataModel;null==t||t.forEach((t=>{t.navAppViewId&&this.navNodeModelIds.push(t.id)})),this.state.srfnav&&(this.defaultExpandedKeys=this.calcExpandKeys(this.state.srfnav))}calcExpandKeys(t){const e=[];return t.split(":").forEach(((t,a)=>{0===a?e.push(t):e.push("".concat(e[a-1],":").concat(t))})),e.pop(),e}async onRouterChange(t){if(this.state.srfnav!==t.srfnav){const e=this.calcExpandKeys(t.srfnav);await this.xDataController.expandNodeByKey(e)}await super.onRouterChange(t)}calcControlHeaderVisible(){const t=!!this.toolbarController;if(!t&&this.layoutPanel){const t=this.layoutPanel.panelItems.control_toolbar;t&&(t.state.visible=!1)}return t||!(!this.model.showTitleBar||!this.model.title)}}),t("ChartExpBarController",class extends Sc{navByFirstItem(){if(!this.xDataController.state.items[0])return this.state.srfnav="",void this._evt.emit("onNavViewChange",{navViewMsg:{key:"",isCache:this.isCache}});const t=this.xDataController.generator.seriesGenerators.find((t=>t.chartDataArr.length>0&&t.model.navAppViewId));t&&this.xDataController.setActive(t.chartDataArr[0])}prepareParams(t,e,a,i){var s;const{context:n,params:o}=super.prepareParams(t,e,a,i);if(e._seriesModelId){const a=null==(s=t.dechartSerieses)?void 0:s.find((t=>t.id===e._seriesModelId));if(a){const{navigateContexts:t,navigateParams:s}=a,r=oe(t,e,i,n),c=oe(s,e,i,o);return{context:Object.assign(n.clone(),r),params:c}}}return{context:n,params:o}}getNavViewMsg(t,e,a){var i;let s;if(t._seriesModelId){const e=null==(i=this.XDataModel.dechartSerieses)?void 0:i.find((e=>e.id===t._seriesModelId));s=null==e?void 0:e.navAppViewId}const n=this.prepareParams(this.XDataModel,t,e,a);return{key:t._uuid,context:n.context,params:n.params,viewId:s,isCache:this.isCache}}}),t("FormController",class extends Dr{constructor(){super(...arguments),this.details={},this.providers={},this.formItems=[],this.formMDCtrls=[],this.counters={}}get _evt(){return this.evt}get data(){return this.state.data}initState(){super.initState(),this.state.data=new En,this.state.isLoaded=!1,this.state.processing=!1,this.state.modified=!1}async dataChangeNotify(t){await ba(Object.values(this.details).map((async e=>e.dataChangeNotify(t))))}formStateNotify(t){Object.values(this.details).forEach((e=>{e.formStateNotify(t)}))}async onCreated(){await super.onCreated(),await this.initDetailControllers(),await this.initCounter(),this.dataChangeNotify=C(this.dataChangeNotify.bind(this),((t,e)=>[Array.from(new Set([...t[0],...e[0]]))]),200),this._evt.on("onFormDetailEvent",(t=>{var e;null==(e=this.scheduler)||e.triggerControlEvent(t.formDetailName,t.formDetailEventName,t)}))}async initDetailControllers(t=this.model.deformPages,e=this,i=void 0){await Promise.all(t.map((async t=>{const s=await rs(t,this.model);if(!s)return;if(e.details[t.id])throw new a(t,"初始化异常: 表单成员[".concat(t.id,"](").concat(t.detailType,")已存在,表单项标识重复请检查配置"));e.providers[t.id]=s;const n=await s.createController(t,e,i);if(e.details[t.id]=n,"FORMITEM"===t.detailType&&e.formItems.push(n),"MDCTRL"===t.detailType&&e.formMDCtrls.push(n),Re(t))return;const o=Ne(t);o.length&&await this.initDetailControllers(o,e,n)})))}getData(){return[this.state.data]}async setDataValue(t,e){if(!Object.prototype.hasOwnProperty.call(this.state.data,t)||Jo(this.state.data[t],e)){this.state.data[t]=e,this.state.processing=!0,this.state.modified=!0,await this._evt.emit("onFormDataChange",void 0);try{await this.dataChangeNotify([t])}finally{this.state.processing=!1}}}async updateFormItem(t){}async validate(){return-1===(await Promise.all([...this.formItems,...this.formMDCtrls].map((t=>t.validate())))).findIndex((t=>!t))}actionNotification(t,e){if((null==e?void 0:e.error)&&e.error instanceof b){const{details:t}=e.error;t.forEach((t=>{this.setDetailError(t.name,t.errorInfo)}))}super.actionNotification(t,{data:this.data,...e||{}})}initControlScheduler(t=[]){const e=[...t];r(this.model,(t=>{t.controlLogics&&e.push(...t.controlLogics)}),{childrenFields:["deformPages","deformTabPages","deformDetails"]}),super.initControlScheduler(e)}async onDestroyed(){await super.onDestroyed(),Object.values(this.counters).forEach((t=>t.destroy()))}async initCounter(){this.counters={};const{appCounterRefs:t}=this.model;if(t&&t.length>0){const e=this.context[ve(this.model.appDataEntityId)];try{await Promise.all(t.map((async t=>{const a=await ln.getCounterByRef(t,this.context,e?{customId:e}:void 0);this.counters[t.id]=a})))}catch(t){console.error(t)}}}setDetailError(t,e){const a=this.details[t],i=null==a?void 0:a.state;i&&(i.error=e)}})),Rc=class extends yn{setDefault(t,e,a,i){r(this.model,(s=>{if("FORMITEM"===s.detailType){const{createDVT:n,createDV:o,updateDVT:r,updateDV:c,valueFormat:d}=s,l="create"===i?n:r,h="create"===i?o:c,u=s.id.toLowerCase(),p=ir({name:u,valueType:l,defaultValue:h,valueFormat:d},{data:t,context:e,params:a});void 0!==p&&(t[u]=p)}}),{childrenFields:["deformPages","deformTabPages","deformDetails"]})}},Mc=t("SearchFormService",class extends Rc{async getDraft(t,e={}){let a={ok:!0,status:200,data:this.getFilteredData({...e})};return a=this.handleResponse(a),a.ok&&a.data&&this.setDefault(a.data,t,e,"create"),a}initUIDataMap(){r(this.model,(t=>{if("FORMITEM"===t.detailType){const e=t.id.toLowerCase();this.dataUIMap.set(e,new fo(e,e))}}),{childrenFields:["deformPages","deformTabPages","deformDetails"]})}handleResponse(t){const e=super.handleResponse(t);return e.ok&&e.data&&(e.data=this.toUIData(e.data)),e}getFilteredData(t){const e={};return this.dataUIMap.forEach((a=>{void 0!==t[a.dataKey]&&(e[a.dataKey]=t[a.dataKey])})),e}}),Oc=(t("SearchFormController",class extends Nc{initState(){super.initState(),this.state.storedFilters=[]}async onCreated(){var t,e;await super.onCreated(),this.config=new dn(this.model.appId,"dynafilter","searchform_".concat((null==(t=this.model.appDataEntityId)?void 0:t.toLowerCase())||"app","_").concat(null==(e=this.model.codeName)?void 0:e.toLowerCase())),this.preprocessLayoutPanel(),this.service=new Mc(this.model),await this.service.init(this.context),await this.load(),await this.loadConfig()}async load(){const t={...this.params};let e;await this.evt.emit("onBeforeLoadDraft",{params:t});try{e=await this.service.getDraft(this.context,t)}catch(t){throw this.actionNotification("GETDRAFTERROR",{error:t}),t}return this.state.data=e.data,this.state.isLoaded=!0,this.formStateNotify("DRAFT"),this.actionNotification("GETDRAFTSUCCESS"),this.data}getFilterParams(){const t={};return Object.keys(this.state.data).forEach((e=>{const a=this.state.data[e];null!=a&&""!==a&&(t[e]=a)})),t}async search(){await this.evt.emit("onSearch",void 0)}async onSearchButtonClick(){await this.search()}async reset(){await this.load(),await this.search()}async dataChangeNotify(t){await super.dataChangeNotify(t),this.model.enableAutoSearch&&this.search()}async onKeyUp(t){const e=t||window.event;e&&"Enter"===e.code&&await this.onSearchButtonClick()}preprocessLayoutPanel(){if(!this.controlPanel)return;const{searchButtonStyle:t}=this.model;let e=!1,a=!1;const i=this.model.searchButtonPos||"RIGHT";e="BOTTOM"===i,a="BOTTOM"!==i,"NONE"===t&&(e=!0,a=!0);const s=t=>{let i,n="";if(["rootPanelItems","panelItems"].find((e=>!!t[e]&&(i=t[e],n=e,!0))),i&&i.length>0){const o=[];i.forEach((t=>{e&&"control_buttons_right"===t.id||a&&"control_buttons_bottom"===t.id||(o.push(t),s(t))})),o.length<i.length&&(t[n]=o)}};(a||e)&&s(this.controlPanel)}async loadConfig(){const t=await this.config.load();t.model&&(this.state.storedFilters=t.model)}async saveConfig(){await this.config.save({model:this.state.storedFilters})}async storeFilter(t){this.state.storedFilters.push({name:t,data:{...this.data}}),await this.saveConfig()}applyStoredFilter(t){const e=this.state.storedFilters[t];if(!e)throw new o("没有找到可以应用的搜索条件");e.data&&Object.assign(this.data,e.data),this.search()}async removeStoredFilter(t){if(!this.state.storedFilters[t])throw new o("没有找到保存的搜索条件");this.state.storedFilters.splice(t,1),await this.saveConfig()}}),t("FormDetailState",class{constructor(t){this.parent=t,this.disabled=!1,this.layout={width:"",height:"",extraStyle:{},extraClass:[],contentStyle:{}},this.class={container:[],containerDyna:[],label:[],labelDyna:[]},this.required=!1,this.showMoreMode=0,this.readonly=!1;let e,a,i=!0;Object.defineProperty(this,"visible",{enumerable:!0,configurable:!0,get(){if(this.parent){if(!1===this.parent.visible)return!1;if(1===this.showMoreMode&&!1===this.parent.isShowMore)return!1}return i},set:t=>(i=t,!0)}),Object.defineProperty(this,"keepAlive",{enumerable:!0,configurable:!0,get(){return void 0!==e?e:!!this.parent&&this.parent.keepAlive},set:t=>(e=t,!0)}),Object.defineProperty(this,"readonly",{enumerable:!0,configurable:!0,get(){return void 0!==a?a:!!this.context&&!(!0!==this.context.srfreadonly&&"true"!==this.context.srfreadonly)},set:t=>(a=t,!0)})}})),Lc=t("FormDetailEventName",(t=>(t.CLICK="onClick",t.FOCUS="onFocus",t.BLUR="onBlur",t.CHANGE="onChange",t.ENTER="onEnter",t))(Lc||{})),_c=t("PanelItemEventName",(t=>(t.CLICK="onClick",t.FOCUS="onFocus",t.BLUR="onBlur",t.CHANGE="onChange",t.ENTER="onEnter",t))(_c||{})),Fc=t("FormDetailController",class{constructor(t,e,a){this.dynaLogicResult={visible:void 0,disabled:void 0,required:void 0},this.model=t,this.form=e,this.parent=a,this.state=this.createState(),this.state.context=this.context}get data(){return this.form.data}get context(){return this.form.context}get params(){return this.form.params}get containerClass(){return[...this.state.class.container,...this.state.class.containerDyna]}get labelClass(){return[...this.state.class.label,...this.state.class.labelDyna]}async init(){await this.onInit()}async onInit(){this.state.showMoreMode=this.model.showMoreMode;const{layoutPos:t,sysCss:e,labelSysCss:a,capLanguageRes:i}=this.model;if(t){const{width:e,height:a}=ge(t);this.state.layout.width="".concat(e),this.state.layout.height="".concat(a)}(null==e?void 0:e.cssName)&&this.state.class.container.push(e.cssName),(null==a?void 0:a.cssName)&&this.state.class.label.push(a.cssName),i&&i.lanResTag&&(this.model.caption=ibiz.i18n.t(i.lanResTag,this.model.caption))}createState(){var t;return new Oc(null==(t=this.parent)?void 0:t.state)}async dataChangeNotify(t){this.calcDynamicLogic(t),this.calcDetailDisabled(this.data),this.calcDetailVisible(this.data),this.calcDetailRequired(this.data),this.calcDynaClass(this.data)}async formStateNotify(t){this.calcDynamicLogic([],!0),this.calcDetailDisabled(this.data),this.calcDetailVisible(this.data),this.calcDetailRequired(this.data),this.calcDynaClass(this.data)}calcDynamicLogic(t,e=!1){var a;this.parent&&!this.parent.state.visible||null==(a=this.model.defdgroupLogics)||a.forEach((a=>{const i=a.relatedDetailNames||[];if(e||A(i,t))try{const t=Ze(this.data,a);switch(a.logicCat){case"ITEMBLANK":this.dynaLogicResult.required=!t;break;case"ITEMENABLE":this.dynaLogicResult.disabled=!t;break;case"PANELVISIBLE":this.dynaLogicResult.visible=t}}catch(t){ibiz.log.error(t)}}))}force(t){}calcDynaClass(t){if(this.model.dynaClass){const e=we(this.model.dynaClass,t);this.state.class.containerDyna=e}if(this.model.labelDynaClass){const e=we(this.model.labelDynaClass,t);this.state.class.labelDyna=e}}calcDetailDisabled(t){let{disabled:e}=this.dynaLogicResult;if(!0!==e&&this.form.scheduler){const a=this.form.scheduler.triggerItemEnable(this.model.id,{data:[t]});void 0!==a&&(e=!a)}void 0!==e&&(this.state.disabled=e)}calcDetailVisible(t){let{visible:e}=this.dynaLogicResult;if(!1!==e&&this.form.scheduler){const a=this.form.scheduler.triggerItemVisible(this.model.id,{data:[t]});void 0!==a&&(e=a)}void 0!==e&&(this.state.visible=e)}calcDetailRequired(t){let{required:e}=this.dynaLogicResult;if(!0!==e&&this.form.scheduler){const a=this.form.scheduler.triggerItemBlank(this.model.id,{data:[t]});void 0!==a&&(e=!a)}void 0!==e&&(this.state.required=e)}async onClick(t){t&&t.stopPropagation(),this.form.evt.emit("onFormDetailEvent",{formDetailName:this.model.id,formDetailEventName:"onClick",event:t})}}),Vc=t("FormButtonState",class extends Oc{constructor(){super(...arguments),this.loading=!1}}),kc=(t("FormButtonController",class extends Fc{constructor(){super(...arguments),this.actionState=null}createState(){var t;return new Vc(null==(t=this.parent)?void 0:t.state)}async onInit(){super.onInit(),await this.initActionStates()}async initActionStates(){const t=this.model.uiactionId;t&&(this.actionState=new Ho(this.model.id,this.form.context.srfappid,t))}async formStateNotify(t){if(this.actionState){const t=ve(this.form.model.appDataEntityId);await this.actionState.update(this.context,this.data,t)}await super.formStateNotify(t)}calcDetailDisabled(t){super.calcDetailDisabled(t),this.actionState&&(this.state.disabled=!(!this.state.disabled&&!this.actionState.disabled))}calcDetailVisible(t){super.calcDetailVisible(t),this.actionState&&(this.state.visible=!(!this.state.visible||!this.actionState.visible))}async onClick(t){this.state.loading=!0;try{"UIACTION"===this.model.actionType&&await this.doUIAction(t),await this.doFormItemUpdate()}finally{this.state.loading=!1}super.onClick(t)}async doUIAction(t){const e=this.model.uiactionId;await fc.execAndResolved(e,{context:this.form.context,params:this.form.params,data:[this.data],view:this.form.view,event:t,noWaitRoute:!0},this.model.appId)}async doFormItemUpdate(){this.model.deformItemUpdateId&&await this.form.updateFormItem(this.model.deformItemUpdateId)}}),t("FormDruipartState",class extends Oc{constructor(){super(...arguments),this.showMask=!1}})),zc=(t("FormDRUIPartController",class extends Fc{constructor(){super(...arguments),this.refreshItems=["srfkey"],this.paramItem="srfkey",this.isNewData=!1}createState(){var t;return new kc(null==(t=this.parent)?void 0:t.state)}async onInit(){if(await super.onInit(),Object.assign(this.state.layout.extraStyle,{overflow:"auto"}),this.model.refreshItems){let t=this.model.refreshItems.split(";");t=t.filter((t=>!!t)),this.refreshItems.push(...t)}this.model.paramItem&&(this.paramItem=this.model.paramItem)}async dataChangeNotify(t){await super.dataChangeNotify(t),A(this.refreshItems,t)&&this.calcViewParams()}async formStateNotify(t){await super.formStateNotify(t),this.isNewData="DRAFT"===t,0!==this.model.maskMode&&(this.state.showMask=this.isNewData),"LOAD"!==t&&"DRAFT"!==t&&"SAVE"!==t||this.calcViewParams()}calcViewParams(){let t=this.form.context.clone();const e=this.model.navigateContexts;nt(e)&&(t=Object.assign(t,oe(e,this.data,this.form.params,this.form.context)));const a=oe(this.model.navigateParams,this.data,this.form.params,this.form.context);if(this.state.viewComponentKey){if(JSON.stringify(this.navContext)!==JSON.stringify(t)||JSON.stringify(this.navParams)!==JSON.stringify(a))this.navContext=t,this.navParams=a,this.force();else if(this.embedView){if(this.isNewData)return;this.embedView.callUIAction("Refresh")}}else this.state.viewComponentKey=ct(),this.navContext=t,this.navParams=a}setEmbedView(t){this.embedView=t,this.embedView.evt.on("onMounted",(()=>{this.isNewData||this.embedView.call("Load")})),this.embedView.evt.on("onDataChange",(t=>{["LOAD","LOADDRAFT"].includes(t.actionType)||(ibiz.log.debug("接收到关系界面的数据变更事件",t),this.model.deformItemUpdateId&&this.form.updateFormItem(this.model.deformItemUpdateId))}))}}),t("FormGroupPanelState",class extends Oc{constructor(){super(...arguments),this.isShowMore=!1,this.actionGroupState=null}})),Wc=t("FormGroupPanelController",class extends Fc{get disableClose(){const{titleBarCloseMode:t}=this.model;return 0===t||void 0===t}get defaultExpansion(){const{titleBarCloseMode:t}=this.model;return this.disableClose||1===t}createState(){var t;return new zc(null==(t=this.parent)?void 0:t.state)}async onInit(){super.onInit(),await this.initActionStates()}async formStateNotify(t){if(super.formStateNotify(t),this.state.actionGroupState){const t=this.data.getOrigin?this.data.getOrigin():this.data;this.state.actionGroupState.update(this.form.context,t)}}async initActionStates(){var t;const{uiactionGroup:e}=this.model;if(!(null==(t=null==e?void 0:e.uiactionGroupDetails)?void 0:t.length))return;const a=new qo;e.uiactionGroupDetails.forEach((t=>{const e=t.uiactionId;if(e){const i=new Ho(t.id,this.form.context.srfappid,e);a.addState(t.id,i)}})),await a.update(this.form.context),this.state.actionGroupState=a}async onActionClick(t,e){const a=t.uiactionId;await fc.execAndResolved(a,{context:this.form.context,params:this.form.params,data:[this.data],view:this.form.view,event:e},t.appId)}}),Uc=t("FormItemState",class extends Oc{constructor(t){super(t),this.parent=t,this.error=null,this.enableCondDisabled=!1;let e=!1;Object.defineProperty(this,"disabled",{enumerable:!0,configurable:!0,get(){return!!this.enableCondDisabled||e},set:t=>(e=t,!0)})}}),Bc=(t("FormItemController",class extends Fc{constructor(t,e,a){super(t,e,a),this.rules=[]}createState(){var t;return new Uc(null==(t=this.parent)?void 0:t.state)}get name(){return this.model.id}get value(){return this.data[this.name]}get valueItemName(){if(this.model.editor)return this.model.editor.valueItemName}get labelCaption(){const{captionItemName:t}=this.model;return t?this.data[t]:this.model.caption}get unitName(){return this.model.unitName}get valueFormat(){return this.model.valueFormat}get dataType(){return this.model.dataType}async onInit(){var t,e;await super.onInit(),this.state.required=!this.model.allowEmpty;const{enableCond:a}=this.model;a||(this.state.enableCondDisabled=!0),!0!==this.context.srfreadonly&&"true"!==this.context.srfreadonly&&(null==(t=this.model.editor)?void 0:t.readOnly)&&(this.state.readonly=(null==(e=this.model.editor)?void 0:e.readOnly)||!1),this.model.editor&&"HIDDEN"!==this.model.editor.editorType&&(this.editorProvider=await ss(this.model.editor),this.editorProvider&&(this.editor=await this.editorProvider.createController(this.model.editor,this),await this.initRules()))}async initRules(){this.rules=[];const t=ga(this.form.model.deformItemVRs||[],this.name);t&&this.rules.push(...tr(t,this.name,this.valueItemName)),this.model.editor&&this.rules.push(...er(this.model.editor)),this.rules.length>0&&(this.validator=new vt({[this.name]:this.rules}))}calcEnableCond(){const{enableCond:t}=this.model,e=0===this.data.srfuf;(e&&2===t||!e&&1===t)&&(this.state.enableCondDisabled=!0)}async dataChangeNotify(t){await super.dataChangeNotify(t);const{resetItemNames:e}=this.model;let a=!1;e&&e.length>0&&e.forEach((e=>{t.includes(e)&&(a=!0)})),a&&this.setDataValue(null,this.name),(t.includes(this.name)||t.includes(this.valueItemName))&&this.validate(),t.includes(this.name)&&this.model.deformItemUpdateId&&await this.form.updateFormItem(this.model.deformItemUpdateId)}async formStateNotify(t){super.formStateNotify(t),this.calcEnableCond()}calcDynamicLogic(t,e=!1){this.model.hidden||super.calcDynamicLogic(t,e)}async validate(){if(!this.state.visible)return this.state.error=null,!0;if(this.state.required&&("string"==typeof this.data[this.name]?ot(this.data[this.name].trimEnd()):ot(this.data[this.name])))return this.state.error="请填写".concat(this.model.caption||""),!1;if(this.validator)try{await this.validator.validate(this.data)}catch({errors:t,_fields:e}){return this.state.error=t[0].message,!1}return this.state.error=null,!0}async setDataValue(t,e){e=e||this.name,await this.form.setDataValue(e,t),this.form.evt.emit("onFormDetailEvent",{formDetailName:this.model.id,formDetailEventName:"onChange"})}onFocus(t){this.form.evt.emit("onFormDetailEvent",{formDetailName:this.model.id,formDetailEventName:"onFocus",event:t})}onBlur(t){this.form.evt.emit("onFormDetailEvent",{formDetailName:this.model.id,formDetailEventName:"onBlur",event:t})}onEnter(t){this.form.evt.emit("onFormDetailEvent",{formDetailName:this.model.id,formDetailEventName:"onEnter",event:t})}}),class extends Oc{constructor(){super(...arguments),this.actionGroupState=null}}),Gc=t("FormMDCtrlController",class extends Fc{createState(){var t;return new Bc(null==(t=this.parent)?void 0:t.state)}get name(){return this.model.id}get context(){return this.form.context}get params(){return this.form.params}get enableCreate(){return!this.state.readonly&&P.checkPermission(this.model.buildInActions,1)}get enableUpdate(){return!this.state.readonly&&P.checkPermission(this.model.buildInActions,2)}get enableDelete(){return!this.state.readonly&&P.checkPermission(this.model.buildInActions,4)}async updateFormItem(){this.model.deformItemUpdateId&&await this.form.updateFormItem(this.model.deformItemUpdateId)}async formStateNotify(t){if(super.formStateNotify(t),this.state.actionGroupState){const t=this.data.getOrigin?this.data.getOrigin():this.data;this.state.actionGroupState.update(this.form.context,t)}}async onInit(){super.onInit(),await this.initActionStates()}async initActionStates(){var t;const{uiactionGroup:e}=this.model;if(!(null==(t=null==e?void 0:e.uiactionGroupDetails)?void 0:t.length))return;const a=new qo;e.uiactionGroupDetails.forEach((t=>{const e=t.uiactionId;if(e){const i=new Ho(t.id,this.form.context.srfappid,e);a.addState(t.id,i)}})),await a.update(this.form.context),this.state.actionGroupState=a}async onActionClick(t,e){const a=t.uiactionId;await fc.execAndResolved(a,{context:this.context,params:this.params,data:[this.data],view:this.form.view,event:e},t.appId)}refresh(){}async validate(){return!0}}),jc=(t("FormMDCtrlMDController",class extends Gc{constructor(){super(...arguments),this.ignoreNextSelfChange=!1}get name(){return this.model.id}async onInit(){await super.onInit();const{contentControl:t}=this.model;if(!t)throw new a(this.model,"多数据部件未配置内容部件");"GRID"===t.controlType&&T(t,{enableRowEdit:this.enableCreate||this.enableUpdate,enableRowNew:this.enableCreate});const e=await es(t);e&&(this.mdProvider=e)}setMDControl(t){this.mdController=t,t.evt.on("onSaveSuccess",(()=>{this.notifyFormDataChange()})),t.evt.on("onRemoveSuccess",(()=>{this.notifyFormDataChange()}))}updateFormItem(){const t=this.mdController.state.items||[];return this.data[this.name]=t,super.updateFormItem()}remove(){this.mdController.remove()}create(){if("GRID"!==this.model.contentType)throw new i(this.model,"多数据部件类型".concat(this.model.contentType,"暂不支持添加数据"));this.mdController.newRow()}refresh(){this.mdController?this.mdController.refresh():ibiz.log.debug("mdController不存在")}async formStateNotify(t){await super.formStateNotify(t),this.refresh()}async dataChangeNotify(t){t.includes(this.model.id)&&this.ignoreNextSelfChange?this.ignoreNextSelfChange=!1:(await super.dataChangeNotify(t),t.includes(this.model.id)&&this.refresh())}notifyFormDataChange(){this.updateFormItem(),this.ignoreNextSelfChange=!0,this.form.dataChangeNotify([this.name])}}),class extends Bc{}),Kc=(t("FormMDCtrlFormController",class extends Gc{constructor(){super(...arguments),this.ignoreNextSelfChange=!1,this.formMap=new Map}createState(){var t;return new jc(null==(t=this.parent)?void 0:t.state)}async onInit(){super.onInit();const{contentControl:t}=this.model;if(!t)throw new a(this.model,"多数据部件未配置内容部件");t.enableAutoSave=this.enableCreate||this.enableUpdate;const e=await es(t);e&&(this.formProvider=e);const{appDataEntityId:i}=this.model.contentControl;this.deName=ve(i)}async fetchData(){const{appDataEntityId:t}=this.model.contentControl,e=await ibiz.hub.getApp(this.model.appId).deService.exec(t,"fetchdefault",this.context,this.params);e.ok&&(this.state.items=e.data.map((t=>{const e=this.context.clone();e[this.deName]=t.srfkey;const a={...this.params};return{id:t.srfkey,context:e,params:a}})))}async formStateNotify(t){await super.formStateNotify(t),await this.refresh()}setFormController(t,e){this.formMap.set(t,e),e.evt.on("onSaveSuccess",(e=>{const a=e.data[0],i=this.state.items.find((e=>e.id===t));i&&i.context[this.deName]!==a.srfkey&&(i.context[this.deName]=a.srfkey),this.notifyFormDataChange()})),e.evt.on("onRemoveSuccess",(()=>{this.notifyFormDataChange()}))}async remove(t){const e=this.formMap.get(t);if(!e)throw new o("没有找到对应".concat(t,"的表单控制器"));await e.remove();const a=this.state.items.findIndex((e=>e.id===t));-1!==a&&this.state.items.splice(a,1)}create(t){const e=this.context.clone(),a={...this.params};this.state.items||(this.state.items=[]);const i={id:ct(),context:e,params:a};void 0!==t?this.state.items.splice(t,0,i):this.state.items.push(i)}refresh(){this.fetchData()}async dataChangeNotify(t){t.includes(this.model.id)&&this.ignoreNextSelfChange?this.ignoreNextSelfChange=!1:(await super.dataChangeNotify(t),t.includes(this.model.id)&&this.refresh())}notifyFormDataChange(){this.updateFormItem(),this.ignoreNextSelfChange=!0,this.form.dataChangeNotify([this.name])}}),t("FormMDCtrlRepeaterController",class extends Gc{constructor(){super(...arguments),this.repeaterStyle="MultiForm",this.isSingleData=!1}get value(){return this.data[this.model.id]}async onInit(){switch(await super.onInit(),this.model.detailStyle){case"DEFAULT":this.repeaterStyle="MultiForm",this.isSingleData=!1;break;case"STYLE2":this.repeaterStyle="Grid",this.isSingleData=!1;break;case"STYLE3":this.repeaterStyle="SingleForm",this.isSingleData=!0;break;default:throw new i(this.model,"暂不支持重复器样式".concat(this.model.detailStyle))}this.prepareRepeatedForm()}prepareRepeatedForm(){const t="".concat(this.model.id,"repeatedform"),e={appId:this.model.appId,id:t,codeName:t,name:t,deformPages:[{appId:this.model.appId,id:"formpage1",deformDetails:this.model.deformDetails,detailType:"FORMPAGE",detailStyle:"DEFAULT",layout:this.model.layout}]};["appId","controlType","deformItemVRs"].forEach((t=>{e[t]=this.form.model[t]})),this.repeatedForm=Z(e)}setValue(t){this.form.setDataValue(this.name,t)}create(t){if(this.isSingleData)this.setValue({});else{let e=this.value;e=e?[...e]:[],void 0!==t?e.splice(t,0,{}):e.push({}),this.setValue(e)}}remove(t){if(this.isSingleData)return void this.setValue(null);const e=this.value.filter(((e,a)=>t!==a));this.setValue(e)}async dataChangeNotify(t){await super.dataChangeNotify(t);const{resetItemNames:e}=this.model;let a=!1;e&&e.length>0&&e.forEach((e=>{t.includes(e)&&(a=!0)})),a&&this.setValue(null),t.includes(this.name)&&await this.updateFormItem()}}),t("FormPageState",class extends zc{})),Xc=(t("FormPageController",class extends Wc{createState(){var t;return new Kc(null==(t=this.parent)?void 0:t.state)}}),t("FormRawItemState",class extends Oc{})),Hc=(t("FormRawItemController",class extends Fc{createState(){var t;return new Xc(null==(t=this.parent)?void 0:t.state)}}),t("FormTabPageState",class extends Oc{})),qc=(t("FormTabPageController",class extends Fc{createState(){var t;return new Hc(null==(t=this.parent)?void 0:t.state)}get isActive(){return this.parent.state.activeTab===this.model.id}}),t("FormTabPanelState",class extends Oc{constructor(){super(...arguments),this.activeTab=""}})),Yc=(t("FormTabPanelController",class extends Fc{createState(){var t;return new qc(null==(t=this.parent)?void 0:t.state)}async onInit(){var t;await super.onInit(),this.state.activeTab=(null==(t=this.model.deformTabPages)?void 0:t[0].id)||""}onTabChange(t){this.state.activeTab=t}getCounter(t){const{counters:e}=this.form;return e&&e[t]?e[t]:null}}),t("EditFormService",class extends Rc{async get(t,e={}){var a;let i=await this.exec((null==(a=this.model.getControlAction)?void 0:a.appDEMethodId)||"get",t,void 0,e);return i=this.handleResponse(i),i.ok&&i.data&&this.setDefault(i.data,t,e,"update"),i}async getDraft(t,e={}){var a;let i=await this.exec((null==(a=this.model.getDraftControlAction)?void 0:a.appDEMethodId)||"getdraft",t,void 0,e);return i=this.handleResponse(i),i.ok&&i.data&&this.setDefault(i.data,t,e,"create"),i}async remove(t,e={}){var a;return await this.exec((null==(a=this.model.removeControlAction)?void 0:a.appDEMethodId)||"remove",t,void 0,e)}async create(t,e){var a;const i=e instanceof En?e.getOrigin():e,s=this.getFilteredData(i);let n=await this.exec((null==(a=this.model.createControlAction)?void 0:a.appDEMethodId)||"create",t,s);return n=this.handleResponse(n),n}async update(t,e){var a;const i=e instanceof En?e.getOrigin():e,s=this.getFilteredData(i);let n=await this.exec((null==(a=this.model.updateControlAction)?void 0:a.appDEMethodId)||"update",t,s);return n=this.handleResponse(n),n}async goBack(t,e){var i;const s=null==(i=this.model.goBackControlAction)?void 0:i.appDEMethodId;if(!s)throw new a(this.model,"缺少返回操作实体行为");let n=await this.exec(s,t,e instanceof En?e.getOrigin():e);return n=this.handleResponse(n),n}async updateFormItem(t,e,a={}){let i=await this.exec(t,e,a);return i=this.handleResponse(i),i}async wfStart(t,e,a){var i;const s=(null==(i=this.model.wfstartControlAction)?void 0:i.appDEMethodId)||"wfstart";return(await this.app.deService.getService(t,this.model.appDataEntityId)).wf.exec(s,t,e,a instanceof En?a.getOrigin():a)}async wfSubmit(t,e,a){var i;const s=this.model;let n="";n=e.type?e.type:(null==(i=s.wfsubmitControlAction)?void 0:i.appDEMethodId)||"wfsubmit";return(await this.app.deService.getService(t,this.model.appDataEntityId)).wf.exec(n,t,e,a instanceof En?a.getOrigin():a)}initUIDataMap(){super.initUIDataMap();const t=["srfwfmemo","srfwftransferor","srfactionparam","srffrontuf","srfnextform"];r(this.model,(e=>{if("FORMITEM"===e.detailType||"MDCTRL"===e.detailType){const a=e,i=a.id.toLowerCase(),s=a.fieldName||e.appDEFieldId;let n;n=s?new fo(i,s,{isOriginField:!0,dataType:a.dataType}):new fo(i,i,{isOriginField:t.includes(i)}),this.dataUIMap.set(i,n)}}),{childrenFields:["deformPages","deformTabPages","deformDetails"]})}handleResponse(t){const e=super.handleResponse(t);return e.ok&&e.data&&(e.data=this.toUIData(e.data)),e}getFilteredData(t){const e={};return this.dataUIMap.forEach((a=>{void 0!==t[a.dataKey]&&(e[a.dataKey]=t[a.dataKey])})),e}})),Qc=(t("EditFormController",class extends Nc{constructor(){super(...arguments),this.oldData=new En}get view(){return this.ctx.view}async onCreated(){await super.onCreated(),this.service=new Yc(this.model),await this.service.init(this.context),this.autoSave=V(this.autoSave.bind(this),500,{trailing:!0})}async onMounted(){await super.onMounted(),!this.state.isSimple&&this.state.loadDefault&&this.load()}async loadDraft(t){const{context:e,params:a}=this.handlerAbilityParams(t);let i;try{await this.startLoading(),await this.evt.emit("onBeforeLoadDraft",{params:a}),i=await this.service.getDraft(e,a)}catch(t){throw await this.evt.emit("onLoadDraftError",void 0),this.actionNotification("GETDRAFTERROR",{error:t}),t}finally{await this.endLoading()}return this.state.data=i.data,this.formStateNotify("DRAFT"),await this.evt.emit("onLoadDraftSuccess",void 0),this.actionNotification("GETDRAFTSUCCESS"),this.state.isLoaded=!0,this.data}async copy(){const t=Z(this.context),e=Z(this.params),a=(await ibiz.hub.getAppDataEntity(this.model.appDataEntityId,this.model.appId)).keyAppDEFieldId;if(a&&this.params[a]){t[ve(this.model.appDataEntityId)]=this.params[a],delete e[a],delete this.params[a],delete e.srfcopymode,delete this.params.srfcopymode}let i;try{await this.startLoading(),await this.evt.emit("onBeforeLoad",{args:e}),i=await this.service.get(t,e)}catch(t){throw await this.evt.emit("onLoadError",{args:t}),this.actionNotification("GETERROR",{error:t}),t}finally{await this.endLoading()}return i.data.srfkey=void 0,i.data.tempsrfkey=ct(),this.state.modified=!1,this.state.data=i.data,this.formStateNotify("LOAD"),await this.evt.emit("onLoadSuccess",{args:i.data}),this.actionNotification("GETSUCCESS"),this.state.isLoaded=!0,this.data}async load(t){if(this.params.srfcopymode)return this.copy();if(!Ie(this.context,ve(this.model.appDataEntityId)))return this.loadDraft();const{context:e,params:a}=this.handlerAbilityParams(t),i=Z(a);let s;try{await this.startLoading(),await this.evt.emit("onBeforeLoad",{args:i}),s=await this.service.get(e,i)}catch(t){throw await this.evt.emit("onLoadError",{args:t}),this.actionNotification("GETERROR",{error:t}),t}finally{await this.endLoading()}return this.state.modified=!1,this.state.data=s.data,this.oldData=this.data.clone(),this.formStateNotify("LOAD"),await this.evt.emit("onLoadSuccess",{args:s.data}),this.actionNotification("GETSUCCESS"),this.state.isLoaded=!0,this.data}async save(t){const e=!0===(null==t?void 0:t.silent);if(this.state.processing){return await x(500,this.save.bind(this),[t])}if(!await this.validate())throw new o("请检查表单填写!");e||await this.startLoading();const{context:a,data:i}=this.handlerAbilityParams(t),s=i[0],n=0===s.srfuf;let r;try{await this.evt.emit("onBeforeSave",{args:s}),r=n?await this.service.create(a,s):await this.service.update(a,s)}catch(t){throw await this.evt.emit("onSaveError",{args:t}),this.actionNotification("".concat(n?"CREATE":"UPDATE","ERROR"),{error:t}),t}finally{e||await this.endLoading()}const c=!0===(null==t?void 0:t.noFillBack);return r.data&&(c?(this.data.updatedate=r.data.updatedate,this.data.srfkey=r.data.srfkey):T(this.data,r.data),this.oldData=this.data.clone(),this.data.tempsrfkey=this.data.srfkey),this.state.modified=!1,await this.evt.emit("onSaveSuccess",{args:r.data}),this.view.state.isClosing||this.formStateNotify("SAVE"),e||this.actionNotification("".concat(n?"CREATE":"UPDATE","SUCCESS"),{default:"".concat(this.data.srfmajortext||"","保存成功")}),this.emitDEDataChange(n?"create":"update",r.data),this.data}async remove(t){const{context:e,params:a}=this.handlerAbilityParams(t);let i,s=!1;if(await this.evt.emit("onBeforeRemove",{args:this.data}),1===this.data.srfuf){if(s=await ibiz.modal.confirm({title:"提示",desc:"确认删除吗?"}),!s)return!1;await this.startLoading();try{i=await this.service.remove(e,a)}catch(t){throw await this.evt.emit("onRemoveError",{args:t}),this.actionNotification("REMOVEERROR",{error:t}),t}finally{await this.endLoading()}s=i.ok}return this.emitDEDataChange("remove",this.data),this.state.data=new En,this.state.modified=!1,await this.evt.emit("onRemoveSuccess",{args:this.data}),this.actionNotification("REMOVESUCCESS"),s}async goBack(){let t;await this.startLoading();try{t=await this.service.goBack(this.context,this.data)}finally{await this.endLoading()}return t.data&&T(this.data,t.data),this.data}async updateFormItem(t){var e;const a=null==(e=this.model.deformItemUpdates)?void 0:e.find((e=>e.id===t));if(!a)throw new o("没找到".concat(t,"表单项更新"));const{appDEMethodId:i,defiupdateDetails:s,customCode:n,scriptCode:r,showBusyIndicator:c}=a,d=null==s?void 0:s.map((t=>t.id));try{let t;if(c&&this.startLoading(),n&&r)t=Qe.execScriptFn({...this.getEventArgs(),data:this.data},r,{isAsync:!1});else{const e={...this.params,...this.data.getOrigin()},a=await this.service.updateFormItem(i,this.context,e);t=a.data}t&&(null==d?void 0:d.length)&&await Promise.all(d.map((e=>this.setDataValue(e,t[e]))))}finally{c&&this.endLoading()}}async wfStart(t){if(!await this.validate())throw new o("请检查表单填写!");await this.startLoading();const{context:e,params:a}=this.handlerAbilityParams(t);try{await this.service.wfStart(e,a,this.data),this.emitDEDataChange("update",this.data),this.emitDEDataChange("update",{srfdecodename:"SysTodo"})}catch(t){throw this.actionNotification("WFSTARTERROR",{error:t}),t}finally{await this.endLoading()}this.actionNotification("WFSTARTSUCCESS",{default:"流程启动成功"})}async wfSubmit(t){if(!await this.validate())throw new o("请检查表单填写!");await this.startLoading();const{context:e,params:a}=this.handlerAbilityParams(t);try{await this.service.wfSubmit(e,a,this.data),this.emitDEDataChange("update",this.data),this.emitDEDataChange("update",{srfdecodename:"SysTodo"})}catch(t){throw this.actionNotification("WFSUBMITERROR",{error:t}),t}finally{await this.endLoading()}this.actionNotification("WFSUBMITSUCCESS",{default:"流程提交成功"})}async dataChangeNotify(t){await super.dataChangeNotify(t),this.autoSave()}async autoSave(){if(!this.model.enableAutoSave)return;const{autoSaveMode:t}=this.model,e={silent:!0,noFillBack:!0};if(3===t)e.data=this.getDiffData(),e.context=d.create({srfsimple:!0});try{await this.save(e)}catch(t){ibiz.log.error(t)}}getDiffData(){const{data:t}=this.state,e={};return Object.keys(t).forEach((a=>{Array.isArray(t[a])?v(t[a],this.oldData[a])||(e[a]=t[a]):t[a]===this.oldData[a]&&a!==t.srfkeyfield||(e[a]=t[a])})),e.srfuf=t.srfuf,new En(e,this.oldData.$dataUIMap)}setSimpleData(t){const e=this.service.toUIData(t).clone();this.formItems.forEach((t=>{Object.prototype.hasOwnProperty.call(e,t.name)||(e[t.name]=null)})),this.state.modified=!1,this.state.data=e,this.state.isLoaded?this.dataChangeNotify(Object.keys(this.state.data)):(this.formStateNotify("LOAD"),this.state.isLoaded=!0)}onDEDataChange(t){var e;if("OBJECTUPDATED"===t.subtype&&(Q(t.triggerKey)||t.triggerKey!==this.triggerKey)&&this.model.appDataEntityId){const a=ve(this.model.appDataEntityId);if(!t.data||(null==(e=t.data.srfdecodename)?void 0:e.toLowerCase())!==a||t.data.srfkey!==this.data.srfkey)return;this.doNextActive((()=>this.load()),{key:"load"})}}}),t("GridColumnController",class{constructor(t,e){var a;this.isAdaptiveColumn=!1,this.isCustomCode=!1,this.model=t,this.grid=e,this.isAdaptiveColumn="STAR"===t.widthUnit,this.isAdaptiveColumn&&(this.grid.hasAdaptiveColumn=!0),(null==(a=this.deGridDataItem)?void 0:a.customCode)&&(this.isCustomCode=!0)}get context(){return this.grid.context}get params(){return this.grid.params}get enableRowEdit(){return!(!this.grid.model.enableRowEdit||!this.model.enableRowEdit)}get deGridDataItem(){var t;return null==(t=this.grid.model.degridDataItems)?void 0:t.find((t=>t.id===this.model.id))}get valueFormat(){var t;return null==(t=this.deGridDataItem)?void 0:t.format}get dataType(){var t;return null==(t=this.deGridDataItem)?void 0:t.dataType}async init(){await this.onInit()}async onInit(){}getCustomHtml(t){var e;if(null==(e=this.deGridDataItem)?void 0:e.scriptCode)return Qe.execScriptFn({data:t.data},this.deGridDataItem.scriptCode,{singleRowReturn:!0,isAsync:!1})}})),$c=t("GridRowState",class{constructor(t,e){this.errors={},this.uaColStates={},this.editColStates={},this.uiActionGroupStates={},this.showRowEdit=!1,this.modified=!1,this.processing=!1,this.data=t,this.oldData=t.clone(),Object.keys(this.data).forEach((t=>{void 0===this.errors[t]&&(this.errors[t]=null)})),Object.values(e.uaColumns).forEach((t=>{t.initActionStates(this)})),Object.values(e.fieldColumns).forEach((t=>{t.initActionStates(this)})),Object.values(e.editColumns).forEach((t=>{let a;this.editColStates[t.fieldName]={disabled:!1,readonly:!1,editable:"all"===ibiz.config.grid.editShowMode,required:!1},Object.defineProperty(this.editColStates[t.fieldName],"readonly",{enumerable:!0,configurable:!0,get:()=>void 0!==a?a:!!e.context&&!(!0!==e.context.srfreadonly&&"true"!==e.context.srfreadonly),set:t=>(a=t,!0)})}))}getDiffData(){const t={};return Object.keys(this.data).forEach((e=>{this.data[e]===this.oldData[e]&&e!==this.data.srfkeyfield||(t[e]=this.data[e])})),t.srfuf=this.data.srfuf,t.srfkey=this.data.srfkey,new En(t,this.oldData.$dataUIMap)}}),Jc=t("GridService",class extends vn{initUIDataMap(){var t;if(super.initUIDataMap(),this.model.degridColumns){const e=this.model.degridDataItems||[];null==(t=this.model.degridColumns)||t.forEach((t=>{const i=t.id.toLowerCase(),s=t.appDEFieldId;let n;if(s){const o=s.toLowerCase(),r=e.find((e=>e.id===t.dataItemName));if(!r)throw new a(t,"未找到对应的表格数据项[".concat(s,"]"));n=new fo(i,o,{isOriginField:!0,dataType:r.dataType})}else n=new fo(i,i);this.dataUIMap.set(i,n)}))}}async updateGridEditItem(t,e,a={}){const i=await this.app.deService.getService(e,this.model.appDataEntityId);let s=await i.exec(t,e,a);return s=this.handleResponse(s),s}}),Zc={string:25,number:6,integer:9,date:5};var td=t("GridController",class extends Cr{constructor(){super(...arguments),this.hasAdaptiveColumn=!1,this.isMultistageHeader=!1,this.addSchemaColumn=!1,this.columns={},this.fieldColumns={},this.uaColumns={},this.editColumns={},this.providers={},this.aggTitle="合计",this.dataExportParam={},this.allExportColumns=[],this.allExportCodelistMap=new Map,this.formatValue=(t,e="")=>{const a="".concat(e);if(!t)return a;if(yt(a,t,!0).isValid()){return yt(a).format(t)}return ibiz.util.text.format(a,t)}}get _evt(){return this.evt}get groupCodeListItems(){var t;return null==(t=this.groupFieldColumn)?void 0:t.codeListItems}get enableAgg(){return"NONE"!==this.model.aggMode}get allowRowEdit(){return!!this.model.enableRowEdit&&this.state.rowEditOpen}get overflowMode(){return ibiz.config.grid.overflowMode}initState(){super.initState(),this.state.rows=[],this.state.noSort=!0===this.model.noSort,this.state.size=this.model.pagingSize||20,this.state.singleSelect=!0===this.model.singleSelect,this.state.columnStates=[],this.state.aggResult={},this.state.rowEditOpen=!1}async onCreated(){await this.initByEntitySchema(),await super.onCreated(),this.service=new Jc(this.model),await this.service.init(this.context),this.initColumnStates(),await this.initGridColumns(),this.dataChangeNotify=C(this.dataChangeNotify.bind(this),((t,e)=>[t[0],Array.from(new Set([...t[1],...e[1]]))]),200),await this.initGroup(),await this.initExportData()}async initByEntitySchema(){if(!this.addSchemaColumn)return;const t=await gr(this.model.appDataEntityId,this.context);if(!t)return;const e=await async function(t,e){var a;if(!t.properties)return;const{properties:i}=t;if(!(Object.keys(i).length>0))return;const s=[];Object.keys(i).forEach((t=>{let e;switch(i[t].type){case"string":e="string","date-time"===i[t].format&&(e="date");break;case"integer":e="integer";break;case"number":e="number";break;default:return void ibiz.log.error("未支持的类型".concat(i[t].type))}s.push({key:t,description:i[t].description,type:e})}));const n={};null==(a=(await ibiz.hub.getAppDataEntity(e.model.appDataEntityId,e.model.appId)).appDEFields)||a.forEach((t=>{n[t.codeName.toLowerCase()]=t.id}));const o=[],r=[];return s.forEach((t=>{o.push({appId:e.model.appId,appDEFieldId:n[t.key],id:t.key,codeName:t.key,columnType:"DEFGRIDCOLUMN",width:150,widthUnit:"PX",valueType:"SIMPLE",caption:t.description,dataItemName:t.key}),r.push({appId:e.model.appId,appDEFieldId:n[t.key],id:t.key,valueType:"SIMPLE",dataType:Zc[t.type]})})),{degridColumns:o,degridDataItems:r}}(t,this);if(e&&e.degridColumns.length>0){const{degridColumns:t,degridDataItems:a}=e;this.model=Z(this.model),this.model.degridColumns=[...(this.model.degridColumns||[]).filter((e=>-1===t.findIndex((t=>t.id===e.id)))),...t],this.model.degridDataItems=[...(this.model.degridDataItems||[]).filter((t=>-1===a.findIndex((e=>e.id===t.id)))),...a]}}async initExportData(){var t;if(this.model.dedataExportId&&(this.dataExport=null==(t=this.dataEntity.appDEDataExports)?void 0:t.find((t=>t.id===this.model.dedataExportId)),this.dataExport&&(this.allExportColumns=await this.findAllExportColumns(this.dataExport))),this.allExportColumns.length>0)this.allExportColumns.forEach((t=>{t.codeListItems&&this.allExportCodelistMap.set(t.appDEFieldId,t.codeListItems)})),this.dataExportParam.fields=this.allExportColumns.map((t=>t.appDEFieldId)),this.dataExportParam.header=this.allExportColumns.map((t=>t.caption));else{Object.keys(this.fieldColumns).forEach((t=>{this.fieldColumns[t].codeList&&this.allExportCodelistMap.set(t,this.fieldColumns[t].codeListItems)}));const{degridColumns:t=[]}=this.model;this.dataExportParam.fields=t.map((t=>t.id)),this.dataExportParam.header=t.map((t=>t.caption))}}async initGroup(){if(!this.model.enableGroup)return;const{groupAppDEFieldId:t,groupCodeListId:e,groupMode:i}=this.model;if(this.groupFieldColumn=Object.values(this.fieldColumns).find((e=>e.model.appDEFieldId===t)),!this.groupFieldColumn)throw new a(this.model,"没有配置分组属性的属性列");const s=this.groupFieldColumn.model.id;if(!this.groupFieldColumn.model.appCodeListId)throw new a(this.groupFieldColumn.model,"分组属性的属性列".concat(s,"没有配置代码表"));const n=this.state.columnStates.findIndex((t=>t.key===this.groupFieldColumn.model.codeName));if(-1!==n&&0!==n){if(this.isMultistageHeader)throw new a(this.model,"请将分组属性列".concat(s,"配置为第一列"));const t=this.state.columnStates.splice(n,1);this.state.columnStates.unshift(...t)}if("CODELIST"===i){if(!e)throw new a(this.model,"代码表分组模式需要配置代码表");if(this.groupFieldColumn.model.appCodeListId!==e)throw new a(this.model,"分组代码表与属性列".concat(s,"的代码表不一致"))}this.calcColumnFixed()}async afterLoad(t,e){return await super.afterLoad(t,e),await ba(Object.values(this.fieldColumns).map((async t=>{await t.loadCodeList()})),!1),this.state.rows=e.map((t=>{const e=new $c(t,this);return this.gridStateNotify(e,"LOAD"),e})),await this.updateRows(this.state.rows),this.calcGroupData(e),this.calcAggResult(e),e}async updateRows(t){for(const e of t)await Promise.all([...Object.values(e.uaColStates).map((t=>t.update(this.context,e.data.getOrigin(),this.model.appDataEntityId))),...Object.values(e.uiActionGroupStates).map((t=>t.update(this.context,e.data.getOrigin(),this.model.appDataEntityId)))])}calcGroupData(t){const{enableGroup:e,groupMode:a}=this.model;if(e){const e=new Map,i="CODELIST"===a,s=this.groupFieldColumn.model.id;i&&this.groupCodeListItems.forEach((t=>{e.set(t.value,[])})),t.forEach((t=>{const a=t[s];i||e.has(a)||e.set(a,[]),e.has(a)&&e.get(a).push(t)})),this.state.groups=[],e.forEach(((t,e)=>{const a=this.groupCodeListItems.find((t=>t.value===e));this.state.groups.push({caption:(null==a?void 0:a.text)||"".concat(e),key:e,children:t})}))}}async loadRemoteAgg(){const{aggMode:t,aggAppDataEntityId:e,aggAppDEDataSetId:i}=this.model;if("ALL"!==t)return;if(!i||!e)throw new a(this.model,"缺少配置聚合实体或聚合数据集");const s=await this.getFetchParams(),n=ibiz.hub.getApp(this.context.srfappid),o=await n.deService.exec(e,i,this.context,void 0,s);o.data.length&&([this.state.remoteAggResult]=o.data)}async getFetchParams(t={}){return!0===this.model.enableItemPrivilege&&(t.srfdataaccessaction=!0),super.getFetchParams(t)}calcAggResult(t){Object.values(this.fieldColumns).forEach((e=>{const a=e.calcFieldAgg(t);a&&(this.state.aggResult[e.model.id]=a)}))}afterRemove(t){super.afterRemove(t);const e=this.findRowStateIndex(t);this.state.rows.splice(e,1),this.state.groups.forEach((e=>{if(e.children.length){const a=e.children.findIndex((e=>e.srfkey===t.srfkey));-1!==a&&e.children.splice(a,1)}}))}async newRow(){const{enableRowEdit:t,enableRowNew:e}=this.model,{editShowMode:a}=ibiz.config.grid;if(!t||!e||!["row","all"].includes(a))return void ibiz.log.error("不支持新建行");if("row"===a){if(this.state.rows.find((t=>t.showRowEdit)))throw new o("请先完成当前行编辑中的行的操作")}const i={...this.params},s=this.calcDefaultValue({},!0);let n;Object.assign(i,s);try{n=await this.service.getDraft(this.context,i)}catch(t){throw this.actionNotification("GETDRAFTERROR",{error:t}),t}const r=n.data;S(r,s),this.state.items.unshift(r);const c=new $c(r,this);this.state.rows.unshift(c),this.gridStateNotify(c,"DRAFT"),"row"===a&&this.switchRowEdit(this.state.rows[0],!0),this.actionNotification("GETDRAFTSUCCESS",{data:r})}async save(t){if(this.state.isSimple)return;const e=0===t.srfuf,a=this.findRowState(t);if(!a)throw new o("行数据不存在");if(!a.modified)return void ibiz.log.debug("值没有发生改变");if(a.processing)return void await x(500,this.save.bind(this),[t]);if(!await this.validate(a))throw new o("行数据校验不通过,保存取消");let i;this.model.enableRowEditChangedOnly&&(t=a.getDiffData());const s=ve(this.model.appDataEntityId),n=this.context.clone();n[s]=t.srfkey;try{i=e?await this.service.create(n,t):await this.service.update(n,t)}catch(t){throw await this._evt.emit("onSaveError",void 0),this.actionNotification("".concat(e?"CREATE":"UPDATE","ERROR"),{error:t,data:a.data,rowState:a}),t}const r=this.findRowStateIndex(t);this.state.items.splice(r,1,i.data),a.data=i.data,a.oldData=i.data.clone(),a.modified=!1,this.gridStateNotify(a,"SAVE"),await this._evt.emit("onSaveSuccess",void 0),this.emitDEDataChange(e?"create":"update",i.data)}async saveAll(){const t=this.state.rows.filter((t=>t.modified)).map((t=>t.data));t.length&&await ba(t.map((t=>this.save(t))))}async initColumnsController(t){var e;const a=await ls(t,this.model);if(!a)return;this.providers[t.codeName]=a;const i=await a.createController(t,this);this.columns[t.codeName]=i,"DEFGRIDCOLUMN"===t.columnType||"DEFTREEGRIDCOLUMN"===t.columnType?(this.fieldColumns[t.codeName]=i,t.enableRowEdit&&(this.editColumns[t.codeName]=i)):"UAGRIDCOLUMN"===t.columnType?this.uaColumns[t.codeName]=i:"GROUPGRIDCOLUMN"===t.columnType&&(this.isMultistageHeader=!0,await Promise.all((null==(e=t.degridColumns)?void 0:e.map((async t=>{await this.initColumnsController(t)})))||[]))}initColumnStates(){this.state.columnStates=[];const t=localStorage.getItem("".concat(this.view.model.id,".").concat(this.model.name,".columnStates"));if(t){const e=JSON.parse(t);this.addSchemaColumn&&e.schemaColumnStates?this.state.columnStates=e.schemaColumnStates:!this.addSchemaColumn&&e.defaultColumnStates&&(this.state.columnStates=e.defaultColumnStates)}0===this.state.columnStates.length&&r(this.model,(t=>{"GROUPGRIDCOLUMN"!==t.columnType&&this.state.columnStates.push({key:t.codeName,caption:t.caption,hidden:!!t.hideDefault||!!t.hiddenDataItem,uaColumn:"UAGRIDCOLUMN"===t.columnType,adaptive:"STAR"===t.widthUnit})}),{childrenFields:["degridColumns"]}),this.calcColumnFixed()}calcColumnFixed(){const t=this.state.columnStates.filter((t=>!t.hidden)),e=t.length,{frozenFirstColumn:a,frozenLastColumn:i}=this.model;this.hasAdaptiveColumn=!1,t.forEach(((t,s)=>{t.adaptive&&(this.hasAdaptiveColumn=!0),t.uaColumn?t.fixed=s+1<=Math.floor(e/2)?"left":"right":a&&s<a?t.fixed="left":i&&s>=e-i&&(t.fixed="right")}))}async initGridColumns(){this.model.degridColumns&&await Promise.all(this.model.degridColumns.map((async t=>this.initColumnsController(t))))}async setRowValue(t,e,a){if(!Object.prototype.hasOwnProperty.call(t.data,e)||Jo(t.data[e],a)){t.data[e]=a,t.modified=!0,t.processing=!0;try{await this.dataChangeNotify(t,[e]),await this._evt.emit("onGridDataChange",{data:this.state.rows.map((t=>t.data))})}finally{t.processing=!1}}}async dataChangeNotify(t,e){await ba(Object.values(this.editColumns).map((async a=>a.dataChangeNotify(t,e))))}gridStateNotify(t,e){Object.values(this.editColumns).forEach((a=>{a.gridStateNotify(t,e)}))}async validate(t){return-1===(await Promise.all(Object.values(this.editColumns).map((e=>e.validate(t))))).findIndex((t=>!t))}async toggleRowEdit(){if(!this.model.enableRowNew)throw new o("当前表格不支持行编辑,无法切换开启行编辑");this.state.rowEditOpen=!this.state.rowEditOpen}async switchRowEdit(t,e,a=!0){if(!this.allowRowEdit)return;const i=void 0===e?!t.showRowEdit:e;if(t.showRowEdit!==i){if(!1===i)if(a)await this.save(t.data);else{if(0===t.data.srfuf)return t.showRowEdit=!1,this._evt.emit("onRowEditChange",{row:t}),this.remove({data:[t.data],silent:!0});t.cacheData&&(t.data=t.cacheData,delete t.cacheData)}else{if(this.state.rows.find((t=>t.showRowEdit)))throw new o("同时只能有一行开启行编辑");if(1===t.data.srfuf){t.cacheData=Z(t.data);const e=this.calcDefaultValue(t.data,!1);Object.assign(t.data,e)}}t.showRowEdit=i,Object.values(this.editColumns).forEach((e=>{t.editColStates[e.fieldName].editable=i})),this._evt.emit("onRowEditChange",{row:t})}}getSortModel(){return{minorSortAppDEFieldId:this.model.minorSortAppDEFieldId,minorSortDir:this.model.minorSortDir}}setSort(t,e){let a;t&&(a=this.fieldIdNameMap.get(t).toLowerCase()),super.setSort(a,e)}async updateGridEditItem(t,e){var a;const i=null==(a=this.model.degridEditItemUpdates)?void 0:a.find((t=>t.id===e));if(!i)throw new o("没找到".concat(e,"编辑列更新"));const{appDEMethodId:s,degeiupdateDetails:n,customCode:r,scriptCode:c}=i,d=n.map((t=>t.id));let l;if(r&&c)l=Qe.execScriptFn({...this.getEventArgs(),data:t.data},c,{isAsync:!1});else{const e={...this.params,...t.data.getOrigin()},a=await this.service.updateGridEditItem(s,this.context,e);l=a.data}l&&(null==d?void 0:d.length)&&await Promise.all(d.map((e=>this.setRowValue(t,e,l[e]))))}async loadData(t){const{context:e}=this.handlerAbilityParams(t),a=await this.getFetchParams(null==t?void 0:t.viewParam);let i;await this.startLoading();try{i=await this.service.fetch(e,a)}finally{await this.endLoading()}return i.data}async findAllExportColumns(t){var e;const a=ibiz.hub.getApp(this.context.srfappid),i=null==(e=t.dedataExportItems)?void 0:e.map((async t=>{const e={...t};return t.codeListId&&(e.codeList=a.codeList.getCodeList(t.codeListId),e.codeListItems=await a.codeList.get(t.codeListId,this.context)),e}));return i?Promise.all(i):[]}formatExcelData(t){const{fields:e=[]}=this.dataExportParam,a=Z(t.map((t=>e.reduce(((e,a)=>(e[a]=t[a],e)),{}))));return a.forEach((t=>{Object.keys(t).forEach((e=>{var a;let i=t[e];const s=this.allExportColumns.find((t=>t.appDEFieldId===e)),n=this.fieldColumns[e],o=(null==s?void 0:s.format)||(null==n?void 0:n.valueFormat),r=(null==n?void 0:n.model.unitName)||"";i=this.allExportCodelistMap.get(e)?(null==(a=this.allExportCodelistMap.get(e).find((a=>a.value===t[e])))?void 0:a.text)||i:this.formatValue(o,i)+r,t[e]=i}))})),a}async getExportData(t){var e;const{type:a}=t;let i=[];if(a&&"activatedPage"!==a)if("maxRowCount"===a||"customPage"===a){const{size:s}=this.state,{startPage:n,endPage:o}=t,r="customPage"===a?{page:0,offset:(n-1)*s,size:(o-n+1)*s}:{size:(null==(e=this.dataExport)?void 0:e.maxRowCount)||1e3,page:0};i=await this.loadData({viewParam:r})}else"selectedRows"===a&&(i=this.getData());else i=this.state.rows.map((t=>t.data));if(0===i.length)throw new o("无导出数据");return i}async exportData(t){const{header:e}=this.dataExportParam;if(!e)throw new o("无表格列");const a=await this.getExportData(t.params),i=this.formatExcelData(a).map((t=>Object.values(t)));await dr(e,i,this.model.logicName)}calcDefaultValue(t,e){const a={};return Object.values(this.editColumns).forEach((i=>{const{createDV:s,createDVT:n,updateDV:o,updateDVT:r}=i.editItem,c=e?n:r,d=e?s:o,l=ir({name:i.fieldName,valueType:c,defaultValue:d,valueFormat:i.valueFormat},{data:t,context:this.context,params:this.params});void 0!==l&&(a[i.fieldName]=l)})),a}findRowStateIndex(t){const e=0===t.srfuf?"tempsrfkey":"srfkey";return this.state.rows.findIndex((a=>a.data[e]===t[e]))}findRowState(t){const e=this.findRowStateIndex(t);return-1!==e?this.state.rows[e]:void 0}async onRowClick(t){this.setSelection([t]),1===this.state.mdctrlActiveMode&&await this.setActive(t)}convertMultipleLanguages(){const t=e=>{e.forEach((e=>{e.capLanguageRes&&e.capLanguageRes.lanResTag&&(e.caption=ibiz.i18n.t(e.capLanguageRes.lanResTag,e.caption)),"GROUPGRIDCOLUMN"===e.columnType&&e.degridColumns&&t(e.degridColumns)}))};this.model.degridColumns&&this.model.degridColumns.length>0&&t(this.model.degridColumns)}setColumnVisible(t){t.hidden=!t.hidden,this.calcColumnFixed(),this.saveColumnStates()}setGroupParams(t){t.sort?(this.state.sortQuery=t.sort,this.isSetSort=!0):this.state.sortQuery="",t.columnstates?(this.state.columnStates=t.columnstates,this.calcColumnFixed()):this.initColumnStates()}changeColumnStateSort(t,e,a){const i=this.state.columnStates.find((e=>e.key===t));i&&(this.state.columnStates.splice(a,1),this.state.columnStates.splice(e,0,i),this.calcColumnFixed(),this.saveColumnStates())}saveColumnStates(){let t={};const e=localStorage.getItem("".concat(this.view.model.id,".").concat(this.model.name,".columnStates"));e&&(t=JSON.parse(e)),this.addSchemaColumn?t.schemaColumnStates=this.state.columnStates:t.defaultColumnStates=this.state.columnStates,localStorage.setItem("".concat(this.view.model.id,".").concat(this.model.name,".columnStates"),JSON.stringify(t))}actionNotification(t,e){if((null==e?void 0:e.error)&&(null==e?void 0:e.rowState)&&e.error instanceof b){const{details:t}=e.error,{errors:a}=e.rowState;t.forEach((t=>{a[t.name]=t.errorInfo}))}super.actionNotification(t,{...e||{}})}}),ed=t("GridFieldColumnController",class extends Qc{constructor(){super(...arguments),this.codeList=void 0}get isLinkColumn(){return!!this.model.enableLinkView&&!!this.model.linkAppViewId}get hasAction(){return!!this.model.deuiactionId}get fieldName(){return this.model.id.toLowerCase()}async onInit(){await super.onInit(),this.loadCodeList=V(this.loadCodeList,300,{leading:!0,trailing:!1}),this.loadCodeList()}initActionStates(t){const{deuiactionGroup:e}=this.model;if(e&&e.uiactionGroupDetails){const a=new qo;e.uiactionGroupDetails.forEach((t=>{const e=t.uiactionId;if(e){const i=new Ho(t.id,this.grid.context.srfappid,e);a.addState(t.id,i)}})),t.uiActionGroupStates[this.model.codeName]=a}}clickable(t){const e=t.data[this.fieldName];return(this.isLinkColumn||this.hasAction)&&e}handlePublicParams(t,e,a){const{userParam:i}=this.model;if(!i)return{context:e,params:a};const{navigateContexts:s,navigateParams:n}=pe(i);let o={};s&&t&&(o=oe(s,t,a,e));const r=Object.assign(e.clone(),o);let c={};n&&t&&(c=oe(n,t,a,e));return{context:r,params:{...a,...c}}}async openLinkView(t,e){if(!t.data[this.fieldName])return;const a=this.model.linkValueItem||"srfkey",s=t.data[a];if(null==s)throw new i(this.model,"未在行数据中取到 ".concat(a," 的值"));const{linkAppViewId:n}=this.model;if(!n)return;const o=aa(t.data),r=Object.assign(this.context.clone(),{srfkey:s,...o}),c=Z(this.params),{context:d,params:l}=this.handlePublicParams(t.data,r,c),h=await ibiz.commands.execute(So.TAG,n,d,l,{event:e});(null==h?void 0:h.ok)&&this.grid.load()}async triggerAction(t,e){const a=this.model.deuiactionId;await fc.execAndResolved(a,{context:this.context,params:this.params,data:[t.data],view:this.grid.view,event:e},this.model.appId)}async loadCodeList(){const t=this.model.appCodeListId;if(!t)return;const e=ibiz.hub.getApp(this.context.srfappid);this.codeList||(this.codeList=e.codeList.getCodeList(t));const a=await e.codeList.get(t,this.context,this.params);return this.codeListItems=a,a}calcFieldAgg(t){const{aggField:e,aggMode:a,aggValueFormat:s,unitName:n}=this.model;if(Q(a)||"NONE"===a)return;const o=e||this.model.id;let r;if(t=t.filter((t=>!Q(t[o]))),"PAGE"!==this.grid.model.aggMode)throw"ALL"===this.grid.model.aggMode?new i(this.model,"远程聚合暂未支持"):new i(this.grid.model,"暂未支持聚合模式".concat(this.grid.model.aggMode));switch(a){case"SUM":r=t.map((t=>t[o])).reduce(((t,e)=>N(t,e)),0);break;case"AVG":r=t.map((t=>t[o])).reduce(((t,e)=>N(t,e)),0)/t.length;break;case"MAX":r=Math.max(...t.map((t=>t[o])));break;case"MIN":r=Math.min(...t.map((t=>t[o])));break;default:throw new i(this.model,"暂未支持属性列聚合模式".concat(a))}let c="".concat(r);if(s)try{c=ibiz.util.text.format("".concat(r),s)}catch(t){ibiz.log.error("".concat(r," 值格式化错误"))}return c&&n&&(c+=n),c}formatValue(t=""){if("SIMPLE"!==this.model.valueType)return ar.toText(this.model,t);const e="".concat(t);if(!this.valueFormat)return e;if(l.isDate(this.dataType)){const t=yt(e).format(this.valueFormat);return"Invalid Date"!==t?t:e}return ibiz.util.text.format(e,this.valueFormat)}async onActionClick(t,e,a){const i=t.uiactionId;await fc.execAndResolved(i,{context:this.context,params:this.params,data:[e.data],view:this.grid.view,event:a},t.appId)}}),ad=(t("GridUAColumnController",class extends Qc{initActionStates(t){var e;const{deuiactionGroup:i}=this.model;if(!i)throw new a(this.model,"操作列没有配置界面行为组");if(!(null==(e=i.uiactionGroupDetails)?void 0:e.length))return void ibiz.log.debug("操作列界面行为组没有配置界面行为");const s=new qo;i.uiactionGroupDetails.forEach((t=>{const e=t.uiactionId;if(e){const a=new Ho(t.id,this.grid.context.srfappid,e);s.addState(t.id,a)}})),t.uaColStates[this.model.codeName]=s}async onActionClick(t,e,a){const i=t.uiactionId;await fc.execAndResolved(i,{context:this.context,params:this.params,data:[e.data],view:this.grid.view,event:a},t.appId)}}),t("GridFieldEditColumnController",class extends ed{constructor(){super(...arguments),this.rules=[]}get unitName(){return this.editItem.unitName}get valueFormat(){return this.model.valueFormat}get valueItemName(){if(this.editItem.editor)return this.editItem.editor.valueItemName}async onInit(){await super.onInit();const t=Se(this.grid.model,this.model.codeName);t&&(this.editItem=t,this.editItem.editor&&"HIDDEN"!==this.editItem.editor.editorType&&(this.editorProvider=await ss(this.editItem.editor),this.editorProvider&&(this.editor=await this.editorProvider.createController(this.editItem.editor,this),await this.initRules())))}async initRules(){this.rules=[];const t=ga(this.grid.model.degridEditItemVRs||[],this.fieldName);t&&this.rules.push(...tr(t,this.fieldName,this.valueItemName)),this.editItem.editor&&this.rules.push(...er(this.editItem.editor)),this.rules.length>0&&(this.validator=new vt({[this.fieldName]:this.rules}))}async setRowValue(t,e,a){a=a||this.fieldName,await this.grid.setRowValue(t,a,e)}async dataChangeNotify(t,e){const{resetItemNames:a}=this.editItem;let i=!1;a&&a.length>0&&a.forEach((t=>{e.includes(t)&&(i=!0)})),i&&this.setRowValue(t,null),this.calcColumnDisabled(t);const s=t.editColStates[this.fieldName].required;this.calcColumnRequired(t);if(s!==t.editColStates[this.fieldName].required||e.includes(this.fieldName)||e.includes(this.valueItemName)){if(!await this.validate(t))throw new o("".concat(this.editItem.codeName,"校验报错,").concat(t.errors[this.fieldName]))}e.includes(this.fieldName)&&this.editItem.degridEditItemUpdateId&&await this.grid.updateGridEditItem(t,this.editItem.degridEditItemUpdateId)}gridStateNotify(t,e){this.calcColumnDisabled(t),this.calcColumnReadonly(t),this.calcColumnRequired(t)}calcColumnDisabled(t){let e=this.calcEnableCond(t);if(e&&this.grid.scheduler){const a=this.grid.scheduler.triggerItemEnable(this.fieldName,{data:[t.data]});void 0!==a&&(e=a)}t.editColStates[this.fieldName].disabled=!e}calcColumnRequired(t){let e=!1!==this.editItem.allowEmpty;if(e&&this.grid.scheduler){const a=this.grid.scheduler.triggerItemBlank(this.fieldName,{data:[t.data]});void 0!==a&&(e=a)}t.editColStates[this.fieldName].required=!e}calcColumnReadonly(t){var e;const a=!!(null==(e=this.editItem.editor)?void 0:e.readOnly);a&&(t.editColStates[this.fieldName].readonly=a)}calcEnableCond(t){const{enableCond:e}=this.editItem,a=0===t.data.srfuf;switch(e){case 0:return!1;case 1:return a;case 2:return!a;default:return!0}}async validate(t){const e=this.fieldName;if("cell"!==ibiz.config.grid.editShowMode&&!0===t.editColStates[e].required&&("string"==typeof t.data[e]?ot(t.data[e].trimEnd()):ot(t.data[e])))return t.errors[e]="请填写".concat(this.model.caption||""),!1;if(this.rules.length&&this.validator)try{await this.validator.validate(t.data)}catch(a){const{errors:i}=a;return t.errors[e]=i[0].message,!1}return t.errors[e]=null,!0}}),t("GridGroupColumnController",class extends Qc{}),t("ListService",class extends vn{initUIDataMap(){var t;super.initUIDataMap(),null==(t=this.model.delistDataItems)||t.forEach((t=>{const e=t.id.toLowerCase(),a=t.appDEFieldId;let i;if(a){const s=a.toLowerCase();i=new fo(e,s,{isOriginField:!0,dataType:t.dataType})}else i=new fo(e,e);this.dataUIMap.set(e,i)}))}})),id=(t("ListController",class extends Cr{initState(){super.initState(),this.state.noSort=!0===this.model.noSort}async onCreated(){await super.onCreated(),this.state.size=this.model.pagingSize||20,this.service=new ad(this.model),await this.service.init(this.context)}getSortModel(){return{minorSortAppDEFieldId:this.model.minorSortAppDEFieldId,minorSortDir:this.model.minorSortDir}}async loadMore(){this.state.total>this.state.items.length&&await this.load({isLoadMore:!0})}async afterLoad(t,e){return await this.handleDataGroup(),e}setData(t){this.state.items=t}getAllData(){return this.state.items}async handleDataGroup(){const{enableGroup:t,groupMode:e}=this.model;t&&e&&("AUTO"===e?this.handleAutoGroup():"CODELIST"===e&&await this.handleCodeListGroup())}handleAutoGroup(){const{groupAppDEFieldId:t}=this.model;if(t){const{items:e}=this.state,a=new Map;e.forEach((e=>{const i=a.get(e[t])||[];i.push(e),a.set(e[t],i)}));const i=[];a.forEach(((t,e)=>{i.push({caption:e,key:e,children:[...t]})})),this.state.groups=i}}async handleCodeListGroup(){const{groupAppDEFieldId:t,groupCodeListId:e}=this.model;if(t&&e){const{items:a}=this.state,i=[],s=ibiz.hub.getApp(this.context.srfappid),n=await s.codeList.get(e,this.context,this.params),o=[];n.forEach((e=>{const s=a.filter((a=>a[t]===e.value));i.push({caption:e.text,key:e.value,children:[...s]}),o.push(e.value)}));const r=a.filter((e=>-1===o.indexOf(e[t])));r.length>0&&i.push({caption:"其他",key:"其他",children:[...r]}),this.state.groups=i}}}),t("PanelController",class extends Dr{constructor(t,e,a,i,s){super(t,e,a,i),this.panelItems={},this.providers={},this.container=s}get _evt(){return this.evt}get data(){return this.state.data}initState(){super.initState(),this.state.data={}}setInputData(t){this.inputData=t}getData(){return[this.data]}async onCreated(){var t;await super.onCreated(),await this.initPanelItemControllers(),(null==(t=this.scheduler)?void 0:t.hasControlEventTrigger)&&this._evt.on("onPanelItemEvent",(t=>{this.scheduler.triggerControlEvent(t.panelItemName,t.panelItemEventName,t)}))}async onMounted(){this.load()}async onDestroyed(){var t,e;await super.onDestroyed(),null==(e=(t=this.data).destroy)||e.call(t),Object.values(this.panelItems).forEach((t=>{t.destroy()}))}async initPanelItemControllers(t=this.model.rootPanelItems,e=this,a=void 0){t&&await Promise.all(t.map((async t=>{var i,s;const n=await ps(t,e.model,e.view.model);if(!n)return;e.providers[t.id]=n;const o=await n.createController(t,e,a);e.panelItems[t.id]=o,(null==(i=t.panelItems)?void 0:i.length)&&!o.isDataContainer&&await this.initPanelItemControllers(t.panelItems,e,o),(null==(s=t.panelTabPages)?void 0:s.length)&&await this.initPanelItemControllers(t.panelTabPages,e,o)})))}async load(){var t,e;const a=await this.prepareData();if(!a)throw new o("未获取到面板数据");const i=this.convertData(a);null==(e=(t=this.data).destroy)||e.call(t),this.state.data=i,this.panelStateNotify("LOAD")}async prepareData(){let t;if(1===this.model.dataMode)this.inputData&&(t=this.inputData);else t=this.inputData||{};return t}convertData(t){const e=ke(this.model),a=e.map((t=>t.id)),i=new yo(e,t);return i._evt.on("change",(t=>{a.includes(t)&&this.dataChangeNotify([t])})),i}dataChangeNotify(t){Object.values(this.panelItems).forEach((e=>{e.dataChangeNotify(t)}))}panelStateNotify(t){Object.values(this.panelItems).forEach((e=>{e.panelStateNotify(t)}))}async setDataValue(t,e){Object.prototype.hasOwnProperty.call(this.state.data,t)&&this.state.data[t]===e||(this.state.data[t]=e)}initControlScheduler(t=[]){const e=[...t];r(this.model,(t=>{t.controlLogics&&e.push(...t.controlLogics)}),{childrenFields:["rootPanelItems","panelItems","panelTabPages"]}),super.initControlScheduler(e)}})),sd=(t("ViewLayoutPanelController",class extends id{async onCreated(){var t;this.preprocessModel(),await super.onCreated(),(null==(t=this.scheduler)?void 0:t.hasControlEventTrigger)&&this.evt.on("onControlEvent",(t=>{this.scheduler.triggerControlEvent(t.triggerControlName,t.triggerEventName,t.triggerEvent)}))}registerToCtx(){}preprocessModel(t){var e;const a=t=>{const e=[];return t.forEach((t=>{"CONTAINER"===t.itemType&&"PANELPART"===t.predefinedType?e.push(...t.panelItems||[]):e.push(t)})),e.forEach((t=>{"CONTAINER"===t.itemType&&this.preprocessModel(t)})),e};t?t.panelItems=a(t.panelItems||[]):(null==(e=this.model.rootPanelItems)?void 0:e.length)&&(this.model.rootPanelItems=a(this.model.rootPanelItems||[]))}}),t("PanelItemState",class{constructor(t){this.parent=t,this.disabled=!1,this.layout={width:"",height:"",extraStyle:{},extraClass:[],contentStyle:{}},this.class={container:[],containerDyna:[],label:[],labelDyna:[]},this.required=!1,this.readonly=!1;let e,a,i=!0;Object.defineProperty(this,"visible",{enumerable:!0,configurable:!0,get(){var t;return!1!==(null==(t=this.parent)?void 0:t.visible)&&i},set:t=>(i=t,!0)}),Object.defineProperty(this,"keepAlive",{enumerable:!0,configurable:!0,get(){return void 0!==e?e:!!this.parent&&this.parent.keepAlive},set:t=>(e=t,!0)}),Object.defineProperty(this,"readonly",{enumerable:!0,configurable:!0,get(){return void 0!==a?a:!!this.context&&!(!0!==this.context.srfreadonly&&"true"!==this.context.srfreadonly)},set:t=>(a=t,!0)})}})),nd=(t("PanelItemController",class{constructor(t,e,a){this.model=t,this.panel=e,this.parent=a,this.dynaLogicResult={visible:void 0,disabled:void 0,required:void 0},this.state=this.createState(),this.state.context=this.panel.context}get dataParent(){return this.findDataParent(this)}get data(){return this.dataParent.data}get containerClass(){return[...this.state.class.container,...this.state.class.containerDyna]}get labelClass(){return[...this.state.class.label,...this.state.class.labelDyna]}async init(){var t;!!(null==(t=this.model.panelItemGroupLogics)?void 0:t.find((t=>"PANELVISIBLE"===t.logicCat)))&&(this.state.visible=!1),await this.onInit()}async onInit(){const{layoutPos:t,sysCss:e,labelSysCss:a}=this.model;if(t){const{width:e,height:a}=ge(t);this.state.layout.width="".concat(e),this.state.layout.height="".concat(a)}(null==e?void 0:e.cssName)&&this.state.class.container.push(e.cssName),(null==a?void 0:a.cssName)&&this.state.class.label.push(a.cssName)}destroy(){}createState(){var t;return new sd(null==(t=this.parent)?void 0:t.state)}async dataChangeNotify(t){this.calcDynamicLogic(t),this.calcItemDisabled(this.data),this.calcItemVisible(this.data),this.calcItemRequired(this.data),this.calcDynaClass(this.data)}async panelStateNotify(t){this.calcDynamicLogic([],!0),this.calcItemDisabled(this.data),this.calcItemVisible(this.data),this.calcItemRequired(this.data),this.calcDynaClass(this.data)}calcItemDisabled(t){let{disabled:e}=this.dynaLogicResult;if(!0!==e&&this.panel.scheduler){const a=this.panel.scheduler.triggerItemEnable(this.model.id,{data:[t]});void 0!==a&&(e=!a)}void 0!==e&&(this.state.disabled=e)}calcItemVisible(t){let{visible:e}=this.dynaLogicResult;if(!1!==e&&this.panel.scheduler){const a=this.panel.scheduler.triggerItemVisible(this.model.id,{data:[t]});void 0!==a&&(e=a)}void 0!==e&&(this.state.visible=e)}calcItemRequired(t){let{required:e}=this.dynaLogicResult;if(!0!==e&&this.panel.scheduler){const a=this.panel.scheduler.triggerItemBlank(this.model.id,{data:[t]});void 0!==a&&(e=!a)}void 0!==e&&(this.state.required=e)}calcDynamicLogic(t,e=!1){var a;this.parent&&!this.parent.state.visible||null==(a=this.model.panelItemGroupLogics)||a.forEach((a=>{const i=a.relatedItemNames||[];if(e||A(i,t))try{const t=ta(this.data,a);switch(a.logicCat){case"ITEMBLANK":this.dynaLogicResult.required=!t;break;case"ITEMENABLE":this.dynaLogicResult.disabled=!t;break;case"PANELVISIBLE":this.dynaLogicResult.visible=t}}catch(t){ibiz.log.error(t)}}))}findDataParent(t){const{parent:e}=t;return e?e.isDataContainer?e:this.findDataParent(e):t.panel}calcDynaClass(t){if(this.model.dynaClass){const e=we(this.model.dynaClass,t);e.length&&(this.state.class.containerDyna=e)}if(this.model.labelDynaClass){const e=we(this.model.labelDynaClass,t);e.length&&(this.state.class.labelDyna=e)}}onClick(){this.panel.evt.emit("onPanelItemEvent",{panelItemName:this.model.id,panelItemEventName:"onClick"})}}),t("PickupViewPanelController",class extends Dr{async onCreated(){await super.onCreated(),this.mountCounter.enroll(this.model.embeddedAppDEViewId)}updateContextParams(t){super.updateContextParams(t),this.initNavParam()}initNavParam(){const{navigateContexts:t,navigateParams:e}=this.model,a=this.context.clone(),i={...this.params};t&&Object.assign(a,oe(t,this.params,this.context)),e&&Object.assign(i,oe(e,this.params,this.context)),this.state.context=a,this.state.params=i}setEmbedView(t){this.embedView=t,this.embedView.state.isMounted?this.mountCounter.attend(this.model.embeddedAppDEViewId):this.embedView.evt.on("onMounted",(()=>{this.mountCounter.attend(this.model.embeddedAppDEViewId)})),this.embedView.evt.on("onSelectionChange",(t=>{this.evt.emit("onSelectionChange",t)})),this.embedView.evt.on("onDataActive",(t=>{this.evt.emit("onDataActive",{data:t.data})}))}async getSelectedData(){return await this.embedView.call("GetData")}async getAllData(){return await this.embedView.call("GetAllData")}}),t("ItemsValueOPs",["EXISTS","NOTEXISTS"])),od=/^N_(.\w+)_(.\w+)$/;function rd(t){var e;return"SIMPLE"===(null==(e=t.userParam)?void 0:e.ITEMTYPE)}function cd(t){var e;return"HIDDEN"===(null==(e=t.userParam)?void 0:e.ITEMTYPE)}function dd(t){const e=t.split("__")[1].match(od);return{field:e[1],op:e[2]}}var ld=["ISNULL","ISNOTNULL","EXISTS","NOTEXISTS"],hd=/\$\{[^}]*\}/,ud=t("SearchBarFilterController",class{constructor(t,e,a,i){var s;let n;this.model=t,this.appDataEntity=e,this.context=a,this.params=i,this.noEditor=!1,this.type="FIELD",this.hidden=cd(t),t.appDEFieldId&&(n=be(this.appDataEntity,t.appDEFieldId)),this.fieldName=n?n.codeName.toLowerCase():t.id,this.key=this.fieldName,this.label=t.caption||(null==n?void 0:n.logicName)||t.id,this.valueOP=null==(s=t.defsearchMode)?void 0:s.valueOP,this.noEditor=this.valueOP?ld.includes(this.valueOP):!this.model.editor}get valueItem(){return this.editor?this.editor.valueItem:void 0}async init(){if(!this.noEditor){if(!this.model.editor)throw new a(this.model,"缺少编辑器模型");this.editorProvider=await ss(this.model.editor),this.editorProvider&&(this.editor=await this.editorProvider.createController(this.model.editor,this))}}calcEditorProps(t){const e={};let a=t.value;return t.disabled&&hd.test(a)&&(a=a.replace("${context.srfpersonid}","当前用户"),a=a.replace("${context.srforgid}","当前组织")),this.valueItem&&(e[this.valueItem]=t.valueItem),{value:a,data:e}}onEditorChange(t,e,a){this.valueItem&&a===this.valueItem?t.valueItem=e:t.value=e}}),pd=class{constructor(t,e){this.themeUrl="/extension/app_view_themes",this.model=t,this.viewTag=e}async init(t){this.app=ibiz.hub.getApp(this.model.appId)}async fetch(){const t=[{condop:"EQ",condtype:"DEFIELD",fieldname:"app_view_tag",value:this.viewTag}],e=await this.app.net.post("".concat(this.themeUrl,"/fetch_cur_user_all"),{searchconds:t,sort:"create_time,asc"});return e.ok&&(e.data=this.convertBackDataToFront(e.data)),e}async get(t){const e=await this.app.net.get("".concat(this.themeUrl,"/").concat(t));return e.ok&&([e.data]=this.convertBackDataToFront([e.data])),e}async remove(t){return await this.app.net.delete("".concat(this.themeUrl,"/").concat(t))}async create(t){return await this.app.net.post("".concat(this.themeUrl),{name:"".concat(this.viewTag,"___").concat(t),caption:t,app_tag:this.model.appId,app_view_tag:this.viewTag})}async createWithParams(t,e){return await this.app.net.post("".concat(this.themeUrl),{name:t.name,caption:t.caption,app_tag:this.model.appId,app_view_tag:this.viewTag,theme_model:JSON.stringify(e),valid_flag:t.show?1:0})}async createBatch(t){const e=this.convertFrontDataToBack(t);return await this.app.net.post("".concat(this.themeUrl),e)}async update(t,e){const[a]=this.convertFrontDataToBack([e]);return await this.app.net.put("".concat(this.themeUrl,"/").concat(t),a)}async updateBatch(t){const e=this.convertFrontDataToBack(t),a=e.map((t=>t.id)).join(";");return await this.app.net.put("".concat(this.themeUrl,"/").concat(a),e)}convertBackDataToFront(t){return t.map((t=>{const e={...t};return t.id&&(e.id=t.id),t.name&&(e.name=t.name),t.caption&&(e.caption=t.caption),t.theme_model&&(e.searchGroupData=JSON.parse(t.theme_model)),"number"==typeof t.valid_flag&&(e.show=1===t.valid_flag),t.order_value&&(e.order=t.order_value),e}))}convertFrontDataToBack(t){return t.map((t=>{const e={app_tag:this.model.appId,app_view_tag:this.viewTag};return t.id&&(e.id=t.id),t.name&&(e.name=t.name),t.caption&&(e.caption=t.caption),t.searchGroupData&&Object.keys(t.searchGroupData).length>0&&(e.theme_model=JSON.stringify(t.searchGroupData)),"boolean"==typeof t.show&&(e.valid_flag=t.show?1:0),t.order&&(e.order_value=t.order),e}))}},md="",fd={string:["EQ","NOTEQ","ISNULL","ISNOTNULL","USERLIKE","LIKE","LIFTLIKE","RIGHT_LIKE"],number:["EQ","GT","GTANDEQ","LT","LTANDEQ","NOTEQ","ISNULL","ISNOTNULL","IN","NOTIN"],date:["EQ","GT","GTANDEQ","LT","LTANDEQ","NOTEQ","ISNULL","ISNOTNULL","IN","NOTIN"]},gd={};function wd(t,e){if(t.enumSource)return{appId:md,editorType:"DROPDOWNLIST",singleSelect:!0,valueType:"SIMPLE",appCodeListId:t.enumSource,id:"".concat(t.key,"_").concat(e)};return gd["".concat(t.type,"_").concat(e)]}async function Ed(t,e,a){var i;if(!t.properties)return[];const{properties:s}=t;if(!(Object.keys(s).length>0))return[];const n=[];Object.keys(s).forEach((t=>{let e;switch(s[t].type){case"string":e="string","date-time"===s[t].format&&(e="date");break;case"integer":case"number":e="number";break;default:return void ibiz.log.error("未支持的类型".concat(s[t].type))}n.push({key:t,description:s[t].description,type:e,enumSource:s[t].enumSource})}));const o={};null==(i=(await ibiz.hub.getAppDataEntity(e,a)).appDEFields)||i.forEach((t=>{o[t.codeName.toLowerCase()]=t.id}));const r=[];return n.forEach((t=>{const e=fd[t.type];e?e.forEach((e=>{t&&r.push({appId:md,appDEFieldId:o[t.key],id:t.key,caption:t.description,defsearchMode:{appId:md,valueOP:e},editor:wd(t,e)})})):ibiz.log.error("未支持的类型",t.type)})),r}Object.keys(fd).forEach((t=>{fd[t].forEach((e=>{if(ld.includes(e))return;const a="".concat(t,"_").concat(e);gd[a]||("date"!==t||["IN","NOTIN"].includes(e)?gd[a]={appId:md,editorType:"TEXTBOX",id:a}:gd[a]={appId:md,editorType:"DATEPICKER",id:a})}))}));var yd=/^N_(.\w+)_(.\w+)$/,vd=t("SearchBarFilterItemsController",class extends ud{constructor(t,e,a,i){super(t[0],e,a,i),this.filterModels=t,this.allFields=[],this.subFilterCMap=new Map,this.type="ITEMS"}calcKey(t,e){return"".concat(t.toUpperCase(),"_").concat(e.toUpperCase())}async initMinorAppDE(){var t;const e=this.filterModels[0].appDEFieldId;let a="";if(null==(t=this.appDataEntity.appDEMethodDTOs)||t.find((t=>{var i;const s=null==(i=t.appDEMethodDTOFields)?void 0:i.find((t=>t.appDEFieldId===e));return!!s&&(a=s.refAppDataEntityId,!0)})),!a)throw new o("找不到属性".concat(e,"对应的关联实体"));this.minorAppDE=await ibiz.hub.getAppDataEntity(a,this.context.srfappid)}async initAllFields(){var t;const e=new Map;this.filterModels.forEach((t=>{var a;const i=(null==(a=t.defsearchMode.codeName)?void 0:a.split("__")[1]).match(yd),s=i[1],n=i[2],o=Z(t);o.defsearchMode.valueOP=n,o.id=s;const r=new ud(o,this.appDataEntity,this.context,this.params);this.subFilterCMap.set(this.calcKey(s,n),r),r.hidden||(e.has(s)||e.set(s,{name:s,label:"",valueOPs:[],fieldName:s}),e.get(s).valueOPs.push(n))})),null==(t=this.minorAppDE.appDEFields)||t.forEach((t=>{const a=t.codeName.toUpperCase();e.has(a)&&(e.get(a).label=t.logicName)})),this.allFields=Array.from(e.values()),await Promise.all(Array.from(this.subFilterCMap.values()).map((t=>t.init())))}async init(){await this.initMinorAppDE(),await this.initAllFields(),this.hidden=Array.from(this.subFilterCMap.values()).every((t=>t.hidden))}getSubFilterController(t,e){return this.subFilterCMap.get(this.calcKey(t,e))}});function Id(){return[{nodeType:"GROUP",logicType:"AND",children:[{nodeType:"FIELD",field:null,valueOP:null,value:null}]}]}function Dd(t){const e={pass:!1};let a=!1,i=!1;return r(t[0],(t=>{i||("FIELD"===t.nodeType?(a=!0,i=!t.field||!t.valueOP||Q(t.value)):i="ITEMS"===t.nodeType?!t.field||!t.valueOP:!t.logicType)})),a&&!i&&(e.pass=!0),e}function Cd(t,e){let a;if("GROUP"===t.nodeType){const i={condop:t.logicType,condtype:"GROUP"};t.children.length>0&&(i.searchconds=t.children.map((t=>Cd(t,e)))),a=i,t.notMode&&(i.notmode=t.notMode)}else if("FIELD"===t.nodeType){const e={condtype:"DEFIELD",fieldname:t.field,value:t.value,condop:t.valueOP};t.valueItem&&(e.value=t.valueItem),a=e}else{const i={condop:t.valueOP,fieldname:t.field,condtype:"ITEMS"};t.children.length>0&&(i.searchconds=t.children.map((t=>Cd(t,e)))),a=i}return(null==e?void 0:e.after)&&e.after(t,a),a}function bd(t,e){const{pass:a}=Dd(t);if(!a)return;return t.map((t=>Cd(t,e)))}function Ad(t){var e,a;let i;if("GROUP"===t.condtype){const a={logicType:t.condop,nodeType:"GROUP",children:[]};(null==(e=t.searchconds)?void 0:e.length)&&(a.children=t.searchconds.map((t=>Ad(t)))),i=a,t.notmode&&(a.notMode=t.notmode)}else if("DEFIELD"===t.condtype){const e={nodeType:"FIELD",field:t.fieldname,value:t.value,valueOP:t.condop};t.valueItem&&(e.valueItem=t.valueItem),i=e}else{const e={nodeType:"ITEMS",field:t.fieldname,valueOP:t.condop,children:[]};(null==(a=t.searchconds)?void 0:a.length)&&(e.children=t.searchconds.map((t=>Ad(t)))),t.simple&&(e.simple=t.simple),i=e}return!0===t.hidden&&(i.hidden=!0),i}function Pd(t){let e;if("GROUP"===t.nodeType){const a={condop:t.logicType,condtype:"GROUP"};t.children.length>0&&(a.searchconds=t.children.map((t=>Pd(t)))),e=a,t.notMode&&(a.notmode=t.notMode)}else if("FIELD"===t.nodeType){const a={condtype:"DEFIELD",fieldname:t.field,value:t.value,condop:t.valueOP};t.valueItem&&(a.valueItem=t.valueItem),e=a}else{const a={condop:t.valueOP,fieldname:t.field,condtype:"ITEMS"};t.children.length>0&&(a.searchconds=t.children.map((t=>Pd(t)))),t.simple&&(a.simple=t.simple),e=a}return!0===t.hidden&&(e.hidden=!0),e}function Td(t){const{pass:e}=Dd(t);if(!e)return;return t.map(Pd)}var xd=t("SearchBarFilterSimpleItemsController",class extends ud{constructor(t,e,a,i){super(t,e,a,i),this.noEditor=!1,this.key=this.model.id,this.type="SIMPLE_ITEMS";const s=dd(t.defsearchMode.codeName);this.subFieldName=s.field,this.subValueOP=s.op}addSimpleFilterNode(t){Object.assign(t,{simple:!0,field:this.fieldName,nodeType:"ITEMS",valueOP:this.valueOP,children:[{nodeType:"FIELD",field:this.subFieldName,valueOP:this.subValueOP,value:null}]})}}),Sd=/\$\{[^}]*\}/,Nd=(t("SearchBarController",class extends Dr{constructor(){super(...arguments),this.placeHolder="",this.filterControllers=[],this.currentEditGroup=null,this.isBackendSearchGroup="SEARCHBAR2"===this.model.searchBarStyle,this.hasDefaultSelect=!1,this.addSchemaFilters=!1}get enableFilter(){return!0===this.model.enableFilter}get searchBarFilters(){return this.model.searchBarFilters||[]}get grid(){return this.ctx.getController("grid")||this.ctx.getController("treegrid")}initState(){super.initState(),this.state.query="",this.state.selectedGroupItem=null,this.state.searchBarGroups=[],this.state.selectedSearchGroupItem=null,this.state.advancedQuickSearch=!1,this.state.quickSearchItems=[],this.state.quickSearchFieldNames=[],this.state.quickSearchPlaceHolder="",this.resetFilter(),this.state.visible=!!(this.model.enableQuickSearch||this.model.enableGroup||this.enableFilter)}async onCreated(){await this.initByEntitySchema(),await super.onCreated();const t=await ibiz.hub.getAppDataEntity(this.model.appDataEntityId,this.context.srfappid);t&&(this.appDataEntity=t,this.calcQuickSearchPlaceholder(),this.initAdvancedQuickSearch()),this.isBackendSearchGroup&&this.view.model.codeName&&(this.service=new pd(this.model,this.view.model.codeName.toLowerCase()),await this.service.init(this.context)),await this.initSearchBarFilters(),await this.initSearBarGroups(!0)}async initByEntitySchema(){var t;if(!this.addSchemaFilters)return;const e=await gr(this.model.appDataEntityId,this.context);if(!e)return;const a=await Ed(e,this.model.appDataEntityId,this.model.appId),i=[];null==(t=this.model.searchBarFilters)||t.forEach((t=>{-1===a.findIndex((e=>{var a;return e.appDEFieldId===t.appDEFieldId&&(!(null==(a=t.defsearchMode)?void 0:a.valueOP)||e.defsearchMode.valueOP===t.defsearchMode.valueOP)}))&&i.push(t)})),a.length>0&&(this.model=Z(this.model),this.model.searchBarFilters=a.concat(...i),this.model.enableFilter=!0)}calcQuickSearchPlaceholder(){if(!this.appDataEntity)return;const t=this.appDataEntity.appDEFields.filter((t=>t.enableQuickSearch));if(t.length){const e=[];t.forEach((t=>{t.lnlanguageRes&&t.lnlanguageRes.lanResTag?e.push(ibiz.i18n.t(t.lnlanguageRes.lanResTag,t.logicName)):t.logicName&&e.push(t.logicName)})),e.length>0&&(this.placeHolder=e.join("、"),this.state.quickSearchPlaceHolder=this.placeHolder)}}handleInput(t){this.state.query=t}onSearch(){this.evt.emit("onSearch",void 0)}findFilterController(t,e){return this.filterControllers.find((a=>a.fieldName===t&&(!a.valueOP||a.valueOP===e)))}getFilterParams(){var t;const e={};if(this.state.query&&(e.query=this.state.query,this.state.advancedQuickSearch&&this.state.quickSearchFieldNames.length&&(e.queryconds=this.state.quickSearchFieldNames.map((t=>"n_".concat(t,"_like"))))),(null==(t=this.state.selectedGroupItem)?void 0:t.data)&&"string"==typeof this.state.selectedGroupItem.data&&!this.isBackendSearchGroup){const t=oe(Qe.execSingleLine(this.state.selectedGroupItem.data),this.params,this.context);Object.assign(e,t)}const a=this.calcFilters();return a&&(e.searchconds=a),e}resetFilter(){this.state.filterNodes=[{nodeType:"GROUP",logicType:"AND",children:[{nodeType:"FIELD",field:null,valueOP:null,value:null}]}],this.evt.emit("onSearch",void 0)}async initSearchBarFilters(){var t;if(null==(t=this.searchBarFilters)?void 0:t.length){const t=new Map;this.searchBarFilters.forEach((e=>{var a;if((null==(a=e.defsearchMode)?void 0:a.valueOP)&&nd.includes(e.defsearchMode.valueOP)){if(rd(e))return void this.filterControllers.push(new xd(e,this.appDataEntity,this.context,this.params));const a="".concat(e.appDEFieldId,"_").concat(e.defsearchMode.valueOP);return t.has(a)||t.set(a,[]),void t.get(a).push(e)}const i=new ud(e,this.appDataEntity,this.context,this.params);this.filterControllers.push(i)})),t.size>0&&t.forEach((t=>{const e=new vd(t,this.appDataEntity,this.context,this.params);this.filterControllers.push(e)})),await Promise.all(this.filterControllers.map((t=>t.init())))}}calcFilters(){if(!this.enableFilter)return;return bd(this.state.filterNodes,{after:(t,e)=>{"FIELD"===t.nodeType&&L(t.value)&&Sd.test(t.value)&&(e.value=Qe.execSingleLine("`".concat(t.value,"`"),{...this.getEventArgs()}))}})}async initSearBarGroups(t=!1){if(this.state.searchBarGroups=[],this.isBackendSearchGroup){this.model.searchBarGroups&&this.model.searchBarGroups.length>0&&(this.state.searchBarGroups=this.model.searchBarGroups.map(((t,e)=>{const a={name:t.id,caption:t.caption,saved:!1,show:!0,searchGroupData:{},order:100*(e+1),defaultSelect:!1,noEdit:!0};if(t.data)try{const e=JSON.parse(t.data);e.theme_model&&(e.theme_model.sort&&(a.searchGroupData.sort=e.theme_model.sort),e.theme_model.columnstates&&(a.searchGroupData.columnstates=e.theme_model.columnstates),e.theme_model.searchconds&&(a.searchGroupData.searchconds=e.theme_model.searchconds)),e.valid_flag&&(a.show="1"===e.valid_flag)}catch(e){ibiz.log.error("".concat(t.data,"非标准JSON格式:"),e)}return t.defaultGroup&&(a.defaultSelect=!0),a})));const e=await this.service.fetch();if(e.ok&&e.data.forEach((t=>{const e=this.state.searchBarGroups.find((e=>e.name===t.name));if(e)T(e,t),e.saved=!0;else{const e=this.state.searchBarGroups.reduce(((t,e,a)=>e.order>this.state.searchBarGroups[t].order?a:t),0);this.state.searchBarGroups.push({saved:!0,show:!0,searchGroupData:{},order:100*(e+2),...t})}})),this.state.searchBarGroups.sort(((t,e)=>t.order-e.order)),this.state.searchBarGroups.forEach(((t,e)=>{t.order=100*(e+1)})),t&&this.state.searchBarGroups&&this.state.searchBarGroups.length>0){this.state.searchBarGroups.find((t=>t.defaultSelect))&&(this.hasDefaultSelect=!0)}}}setDefaultSelect(){if(this.state.searchBarGroups&&this.state.searchBarGroups.length>0){const t=this.state.searchBarGroups.find((t=>t.defaultSelect));t&&this.handleGroupClick(t)}}async handleSave(){if(this.grid&&this.state.selectedSearchGroupItem){const t={searchconds:Td(this.state.filterNodes),sort:this.grid.state.sortQuery,columnstates:this.grid.state.columnStates};if(this.state.selectedSearchGroupItem.saved)await this.service.update(this.state.selectedSearchGroupItem.id,{searchGroupData:t,show:this.state.selectedSearchGroupItem.show,order:this.state.selectedSearchGroupItem.order}),ibiz.message.success("保存成功");else{const e=await this.service.createWithParams(this.state.selectedSearchGroupItem,t);if(e.ok){const t=this.state.searchBarGroups.find((t=>t.name===e.data.name));t&&(T(t,e.data),t.saved=!0),ibiz.message.success("保存成功")}}}}async handleGroupClick(t){if(this.state.selectedSearchGroupItem=t,t.saved){const e=await this.service.get(t.id);e.ok&&(T(t,e.data),t.show=!0)}if(t.searchGroupData&&t.searchGroupData.searchconds&&t.searchGroupData.searchconds.length>0){const e=t.searchGroupData.searchconds.map((t=>Ad(t)));this.state.filterNodes=e}else this.state.filterNodes=[{nodeType:"GROUP",logicType:"AND",children:[{nodeType:"FIELD",field:null,valueOP:null,value:null}]}];r(this.state.filterNodes[0],(t=>{"FIELD"===t.nodeType&&t.field&&t.valueOP&&L(t.value)&&Sd.test(t.value)&&(t.disabled=!0)})),this.grid&&t&&t.searchGroupData&&(this.grid.setGroupParams(t.searchGroupData),await this.grid.load({isInitialLoad:!0}))}initAdvancedQuickSearch(){var t;2===this.model.quickSearchMode&&(null==(t=this.model.searchBarQuickSearchs)?void 0:t.length)&&(this.state.advancedQuickSearch=!0,this.state.quickSearchItems=[],this.state.quickSearchFieldNames=[],this.model.searchBarQuickSearchs.forEach((t=>{const e=be(this.appDataEntity,t.appDEFieldId),a=e.codeName.toLowerCase();this.state.quickSearchItems.push({fieldName:a,label:e.logicName}),this.state.quickSearchFieldNames.push(a)})),this.calcQuickSearchPlaceHolder())}calcQuickSearchPlaceHolder(){if(this.state.advancedQuickSearch)if(this.state.quickSearchFieldNames.length){const t=[];this.state.quickSearchItems.forEach((e=>{this.state.quickSearchFieldNames.includes(e.fieldName)&&t.push(e.label)})),this.state.quickSearchPlaceHolder=t.join("、")}else this.state.quickSearchPlaceHolder=this.placeHolder}}),t("TabExpPanelController",class extends Dr{constructor(){super(...arguments),this.isShowCaption=!0,this.isShowIcon=!1}get isCache(){return"CACHE"===this.controlParams.expcache||"NO_CACHE"!==this.controlParams.expcache&&ibiz.config.view.expCacheMode.includes(this.model.controlType)}get routeDepth(){return this.view.modal.routeDepth}initState(){super.initState(),this.state.tabPages=[],this.state.activeName="",this.state.expViewParams={}}async onCreated(){await super.onCreated(),this.layoutPanel=this.view.layoutPanel,this.initTabPages(),this.initIconCaption()}initTabPages(){const t=this.model.controls,e=[];t.forEach((t=>{e.push({caption:t.caption,tabTag:t.id,class:t.sysCss?[t.sysCss.cssName]:[],sysImage:t.sysImage})})),this.state.tabPages=e,e.length>0&&this.initDefaultPage()}initIconCaption(){if(this.params.showmode)switch(this.params.showmode){case"ICONANDSHORTWORD":this.isShowIcon=!0,this.isShowCaption=!0;break;case"ICON":this.isShowIcon=!0,this.isShowCaption=!1;break;case"SHORTWORD":this.isShowIcon=!1,this.isShowCaption=!0}}initDefaultPage(){if(this.state.defaultTabName){const t=this.state.tabPages.find((t=>t.tabTag===this.state.defaultTabName));if(t)return this.state.activeName=t.tabTag,void this.changeToTab(this.activeTabViewPanelModel,void 0!==this.routeDepth&&$o(this.routeDepth))}this.state.activeName=this.state.tabPages[0].tabTag,this.handleTabChange()}changeToTab(t=this.activeTabViewPanelModel,e=!1){const a=this.getNavViewMsg(t);!0===e&&(a.isRoutePushed=!0),this.evt.emit("onNavViewChange",{navViewMsg:a}),this.evt.emit("onTabChange",{tab:t})}get activeTabViewPanelModel(){const{activeName:t}=this.state;return this.model.controls.find((e=>e.id===t))}async handleTabChange(){this.activeTabViewPanelModel&&this.changeToTab()}prepareParams(t){const{navDER:e,navFilter:a,navigateContexts:i,navigateParams:s,appDataEntityId:n}=t,o={deName:ve(n),navFilter:a,pickupDEFName:null==e?void 0:e.pickupDEFName,navContexts:i,navParams:s},r={context:this.context,params:this.params,data:{}},{resultContext:c,resultParams:d}=le(o,r);return{context:Object.assign(this.context.clone(),c,{currentSrfNav:this.state.activeName}),params:{...d,...this.state.expViewParams}}}getNavViewMsg(t){const{context:e,params:a}=this.prepareParams(t);return{key:t.codeName.toLowerCase(),context:e,params:a,viewId:t.embeddedAppDEViewId,isCache:this.isCache,modalOptions:{replace:!0}}}refresh(){const t=this.getNavViewMsg(this.activeTabViewPanelModel);t.key+=ct(),this.evt.emit("onNavViewChange",{navViewMsg:t})}}),t("TreeService",class extends vn{async fetchChildNodes(t,e){const{hasQuery:a}=e;let i=[];if(t){const s=xe(this.model,{parentId:null==t?void 0:t._nodeId,hasQuery:a});if(0===s.length)return;(await ba(s.map((async a=>{const i=Te(this.model,a.childDETreeNodeId);return this.fetchNodeDatasByType(i,a,t,e)})),!1)).forEach((t=>{i.push(...t)}))}else{const t=Pe(this.model);i=await this.fetchNodeDatasByType(t,void 0,void 0,e)}return i}async fetchNodeDatasByType(t,e,a,s){const n=0===xe(this.model,{parentId:t.id,hasQuery:s.hasQuery}).length,o={...s,leaf:n};let r=[];if(t.accessKey){if(!this.app.authority.calcByResCode(t.accessKey))return r}switch(t.treeNodeType){case"STATIC":r=[await this.getStaticNodeData(t,e,a,o)];break;case"DE":r=await this.getDENodeDatas(t,e,a,o);break;case"CODELIST":r=await this.getCodeListNodeDatas(t,e,a,o);break;default:throw new i(t,"".concat(t.treeNodeType,"节点类型未支持"))}const{expandFirstOnly:c,expanded:d,rootNode:l}=t,h=l&&!this.model.rootVisible;return n||await Promise.all(r.map((async(t,e)=>{var a;if(d&&(!c||c&&0===e)||(null==(a=s.defaultExpandedKeys)?void 0:a.length)&&s.defaultExpandedKeys.includes(t._id)||h){const e=await this.fetchChildNodes(t,s);t._children=e}}))),r}async getStaticNodeData(t,e,a,i){return new mo(t,a,{parentValueLevel:null==e?void 0:e.parentValueLevel,leaf:!!i.leaf})}getNodeRSFilterParams(t,e,a){const{parentValueLevel:i,navigateContexts:s,navigateParams:n,parentFilter:o,parentDER1N:r}=t,c=null==r?void 0:r.pickupDEFName,d={...a.params},l={...a.context,...(null==e?void 0:e._context)||{}};let h,u,p,m={};if(e){h=e;for(let t=1;t<i;t++)h=null==h?void 0:h._parent}if(h){m=h._deData||{};const t=Te(this.model,h._nodeId);t.appDataEntityId&&(p=ve(t.appDataEntityId)),u=h._value}const{resultContext:f,resultParams:g}=le({deName:p,navFilter:o?"n_".concat(o.toLowerCase(),"_eq"):void 0,pickupDEFName:c,navParams:n,navContexts:s},{derValue:u,context:l,params:d,data:m});return Object.assign(l,f),Object.assign(d,g),{context:l,params:d,navContext:f,navParams:g}}async getDENodeDatas(t,e,a,i){const{appDEDataSetId:s,appDataEntityId:n}=t,{context:o,params:r,navContext:c,navParams:d}=e?this.getNodeRSFilterParams(e,a,i):{context:i.context,params:i.params,navContext:{},navParams:{}};r.size=t.maxSize||1e3,t.sortAppDEFieldId&&Object.assign(r,{sort:"".concat(t.sortAppDEFieldId.toLowerCase(),",").concat(t.sortDir?t.sortDir.toLowerCase():"asc")});const l=await this.app.deService.exec(n,s,o,r);if(l.data.length){return l.data.map((e=>new po(t,a,{data:e,leaf:!!i.leaf,navContext:c,navParams:d})))}return[]}async getCodeListNodeDatas(t,e,a,i){const{context:s,params:n,navContext:o,navParams:r}=e?this.getNodeRSFilterParams(e,a,i):{context:i.context,params:i.params,navContext:{},navParams:{}},c=await this.app.codeList.get(t.codeListId,s,n);if(c.length){return c.map((e=>new ho(t,a,{data:e,leaf:!!i.leaf,navContext:o,navParams:r})))}return[]}async removeItem(t,e,a={}){var i;const s=(null==(i=this.model.removeControlAction)?void 0:i.appDEMethodId)||"remove";return await this.execWithEntityId(t,s,e,void 0,a)}async execWithEntityId(t,e,a,i,s){const n=this.handleCustomRequestHeader();return await this.app.deService.exec(t,e,a,i,s,n)}})),Rd=t("TreeController",class extends Cr{constructor(){super(...arguments),this.contextMenus={},this.enableQuickSearch=!1,this.dropNodeRss=new Map,this.contextMenuInfos={}}get _evt(){return this.evt}initState(){super.initState(),this.state.defaultExpandedKeys=[],this.state.expandedKeys=[],this.state.navigational=!1,this.state.size=0,this.state.query=""}async onCreated(){var t,e;if(await super.onCreated(),this.state.expandedKeys=[...this.state.defaultExpandedKeys],(null==(t=this.model.detreeNodes)?void 0:t[0].enableQuickSearch)&&(this.enableQuickSearch=!0),this.dataEntity){const t=null==(e=this.dataEntity.appDEFields)?void 0:e.filter((t=>t.enableQuickSearch)),a=[];null==t||t.forEach((t=>{(null==t?void 0:t.lnlanguageRes)&&t.lnlanguageRes.lanResTag?a.push(ibiz.i18n.t(t.lnlanguageRes.lanResTag,t.logicName)):(null==t?void 0:t.logicName)&&a.push(t.logicName)})),a.length>0&&(this.state.placeHolder=a.join("、"))}this.initDropNodeRss(),this.initNodeClickTBUIActionItem(),await this.initService(),await this.initCounter(),this.model.detreeNodes.forEach((t=>{var e,a;(null==(a=null==(e=t.decontextMenu)?void 0:e.detoolbarItems)?void 0:a.length)&&(this.contextMenus[t.decontextMenu.id]=new bc(t.decontextMenu,this.context,this.params,this.ctx))})),await Promise.all(Object.values(this.contextMenus).map((t=>t.created())))}async onDestroyed(){await super.onDestroyed(),this.counter&&this.counter.destroy()}async initService(){this.service=new Nd(this.model),await this.service.init(this.context)}async initCounter(){const{appCounterRefs:t}=this.model,e=null==t?void 0:t[0];e&&(this.counter=await ln.getCounterByRef(e,this.context))}initDropNodeRss(){var t;null==(t=this.model.detreeNodes)||t.forEach((t=>{if(!t.allowDrop)return;const e=[];xe(this.model,{parentId:t.id,hasQuery:!1}).forEach((t=>{var a;if(null==(a=t.parentDER1N)?void 0:a.pickupDEFName){const a=this.getNodeModel(t.childDETreeNodeId);"DE"===(null==a?void 0:a.treeNodeType)&&a.appDataEntityId&&e.push({minorEntityId:a.appDataEntityId,pickupDEFName:t.parentDER1N.pickupDEFName.toLowerCase(),childDETreeNodeId:t.childDETreeNodeId})}})),e.length>0&&this.dropNodeRss.set(t.id,e)}))}initNodeClickTBUIActionItem(){var t;null==(t=this.model.detreeNodes)||t.forEach((t=>{var e;const a=t.decontextMenu;if(null==(e=null==a?void 0:a.detoolbarItems)?void 0:e.length){let e=0;const i=[];r(a,(t=>{if("DEUIACTION"===t.itemType){e+=1;const a=t;200===a.actionLevel&&i.push(a)}}),{childrenFields:["detoolbarItems"]}),this.contextMenuInfos[t.id]={onlyOneActionItem:1===e,clickTBUIActionItem:i[0]}}}))}async load(t={}){const e=!0===t.isInitialLoad;let a;e&&await this.startLoading();try{a=await this.loadNodes()}finally{e&&await this.endLoading()}return await this.afterLoad(t,a),this.state.isLoaded=!0,await this._evt.emit("onLoadSuccess",{isInitialLoad:e}),a}async getFetchParams(t){const e=await super.getFetchParams(t);return this.state.query&&(e.query=this.state.query),e}async loadNodes(t){const e=await this.getFetchParams(),a=!!e.query;let i;this.state.isLoading=!0;try{i=await this.service.fetchChildNodes(t,{context:this.context.clone(),params:e,hasQuery:a,defaultExpandedKeys:this.state.expandedKeys})||[]}finally{this.state.isLoading=!1}return t?t._children=i:this.state.rootNodes=i,await this.afterLoadNodes(i),i}async afterLoadNodes(t){this.state.items=[],r({_children:this.state.rootNodes},(t=>{this.state.items.push(t)}),{childrenFields:["_children"]}),this.state.expandedKeys=this.calcExpandedKeys(t)}async onTreeNodeClick(t,e){var a;const i=null==(a=this.contextMenuInfos[t._nodeId])?void 0:a.clickTBUIActionItem;if(i)return this.doUIAction(i.uiactionId,t,e,i.appId);if(this.state.navigational){const e=this.getNodeModel(t._nodeId);if(!(null==e?void 0:e.navAppViewId))return}if(this.state.singleSelect&&!t._disableSelect){const{selectedData:e}=this.state,a=e.filter((e=>e._id!==t._id));a.length===e.length?this.setSelection(this.state.singleSelect?[t]:e.concat([t])):this.setSelection(a)}1===this.state.mdctrlActiveMode&&await this.setActive(t)}onExpandChange(t,e){const a=this.state.expandedKeys.includes(t._id);if(e&&!a)this.state.expandedKeys.push(t._id);else if(!e&&a){const e=this.state.expandedKeys.indexOf(t._id);-1!==e&&this.state.expandedKeys.splice(e,1)}}async onDbTreeNodeClick(t){2===this.state.mdctrlActiveMode&&await this.setActive(t)}setActive(t){const e=this.parseTreeNodeData(t);return this._evt.emit("onActive",{...e,nodeData:t})}setSelection(t){const e=t.map((t=>t._id)),a=this.state.items.filter((t=>e.includes(t._id)));super.setSelection(a)}getNodeModel(t){var e;return null==(e=this.model.detreeNodes)?void 0:e.find((e=>e.id===t))}getNodeData(t){const e=this.state.items.find((e=>e._id===t));return e||this.state.items.find((e=>e._uuid===t))}async doUIAction(t,e,a,i){const s=this.getEventArgs(),n=this.parseTreeNodeData(e),o=await fc.exec(t,{...s,...n,event:a},i);if(o.closeView)this.view.closeView();else if(o.refresh)switch(o.refreshMode){case 1:this.refreshNodeChildren(e);break;case 2:this.refreshNodeChildren(e,!0);break;case 3:this.refresh()}}parseTreeNodeData(t){let e=null;return e="DE"===t._nodeType?t:{...t,...t._deData||{}},{data:[e],context:Object.assign(this.context.clone(),t._context||{}),params:{...this.params,...t._params||{}}}}calcExpandedKeys(t){let e=[...this.state.expandedKeys];return r({_children:t},(t=>{var a;(null==(a=t._children)?void 0:a.length)&&e.push(t._id)}),{childrenFields:["_children"]}),e=Array.from(new Set(e)),e}async refreshNodeChildren(t,e=!1){const a=t.srfkey?"srfkey":"_id",i=this.state.items.find((e=>e[a]===t[a]));if(!i)return void ibiz.log.error("找不到对应的树节点数据",t);if(e){const{_parent:t}=i;if(!t||!this.model.rootVisible&&this.state.rootNodes.includes(t))return void await this.refresh()}const s=e?i._parent:i,n=await this.loadNodes(s);this._evt.emit("onAfterRefreshParent",{parentNode:s,children:n})}async expandNodeByKey(t){const e=t.filter((t=>!this.state.expandedKeys.includes(t)));if(0===e.length)return;const a=this.state.items.filter((t=>e.includes(t._id)));this.state.expandedKeys.push(...e),0!==a.length&&await Promise.all(a.map((t=>this.loadNodes(t))))}calcAllowDrag(t){const e=this.getNodeModel(t._nodeId);return!0===(null==e?void 0:e.allowDrag)}calcAllowDrop(t,e,a){var i,s;const n=this.getNodeModel(t._nodeId);if("inner"===a)return!!this.findDropNodeRS(e._nodeId,n.appDataEntityId);if((null==(i=t._parent)?void 0:i._id)===(null==(s=e._parent)?void 0:s._id)){const t=this.getNodeModel(e._nodeId);return!0===(null==t?void 0:t.allowOrder)}return!!e._parent&&!!this.findDropNodeRS(e._parent._nodeId,n.appDataEntityId)}findDropNodeRS(t,e){const a=this.dropNodeRss.get(t);return null==a?void 0:a.find((t=>t.minorEntityId===e))}async onNodeDrop(t,e,i){var s,n,o;"inner"!==i||e._leaf||void 0!==e._children||await this.expandNodeByKey([e._id]);const r=[],c=this.getNodeModel(t._nodeId),d="inner"===i?e:e._parent,l=(null==e?void 0:e._id)!==(null==(s=t._parent)?void 0:s._id);let h=this.getNodeModel(e._nodeId);if("inner"===i||(null==(n=e._parent)?void 0:n._id)!==(null==(o=t._parent)?void 0:o._id)){const e=this.findDropNodeRS(d._nodeId,c.appDataEntityId);e&&(t._deData[e.pickupDEFName]=d._value,r.push(t),h=this.getNodeModel(e.childDETreeNodeId))}const u=t._parent._children;if(u.splice(u.indexOf(t),1),"inner"===i)e._children||(e._children=[],e._leaf=!0,this.state.expandedKeys.push(e._id)),e._children.push(t);else{let a=d._children.indexOf(e);"next"===i&&(a+=1),d._children.splice(a,0,t)}("inner"===i||l)&&(t._parent=d,t._nodeId=h.id,this.state.expandedKeys=this.calcExpandedKeys([d]));const{sortAppDEFieldId:p,sortDir:m,allowOrder:f}=h;if(!0===f){if(!p)throw new a(h,"缺少配置排序属性");const e=p.toLowerCase(),i="ASC"===m,s=[...d._children];i||s.reverse();const n=t=>t+(100-t%100),o=t=>t[e]||0;let c;s.forEach(((a,i)=>{const d=a._deData;void 0===c?a===t&&(c=0===i?100:n(o(s[i-1]._deData)),d[e]=c,-1===r.indexOf(a)&&r.push(a)):(c>=o(d)&&(d[e]=n(c),r.push(a)),c=o(d))}))}await this.updateDeNodeData(r),this._evt.emit("onAfterNodeDrop",{isChangedParent:l})}async updateDeNodeData(t){const e=ibiz.hub.getApp(this.context.srfappid);await Promise.all(t.map((async t=>{const a=this.getNodeModel(t._nodeId);let i=t._deData;t._changedOnly&&(i=t.getDiffData());const s=ve(a.appDataEntityId),n=this.context.clone();n[s]=i.srfkey;const o=await e.deService.exec(a.appDataEntityId,"update",n,i);o.data&&(t._deData=o.data,t._oldDeData=o.data.clone())})))}async modifyNodeText(t,e){const i=this.getNodeModel(t._nodeId);if(!i.allowEditText)throw new a(i,"树节点没有配置编辑模式:名称");if("DE"!==t._nodeType)throw new o("不是实体树节点数据");t._text=e,await this.updateDeNodeData([t]),this.emitDEDataChange("update",t._deData)}async handleItemRemove(t,e,a){let i=!1;const s=this.getNodeModel(t._nodeId);if(!s)throw new o("未找到树节点");const n=s.appDataEntityId;if(n){const s=ve(n);if(0!==t.srfuf){const o=e.clone();o[s]=t.srfkey,await this.service.removeItem(n,o,a),i=!0}}return i}onDEDataChange(t){if(!Q(t.triggerKey)&&t.triggerKey===this.triggerKey)return;if("OBJECTCREATED"===t.subtype)return;const e=t.data,a=this.state.items.find((t=>"DE"===t._nodeType&&t._deData&&t._deData.srfdecodename===e.srfdecodename&&t._deData.srfkey===e.srfkey));a&&this.doNextActive((()=>this.refreshNodeChildren(a,!0)),{key:"refresh".concat(a._id)})}}),Md=t("WizardPanelService",class extends yn{async initialize(t,e={},a={}){var i;const s=null==(i=this.model.initControlAction)?void 0:i.appDEMethodId;let n=await this.exec(s,t,e,a);return n=this.handleResponse(n),n}async finish(t,e={},a={}){var i;const s=null==(i=this.model.finishControlAction)?void 0:i.appDEMethodId;let n=await this.exec(s,t,e,a);return n=this.handleResponse(n),n}}),Od=(t("WizardPanelController",class extends Dr{constructor(){super(...arguments),this.tagHistory=[],this.providers={},this.firstForm=void 0,this.formControllers=new Map,this.steps=[],this.stepTags={},this.formData={}}initState(){super.initState()}async onCreated(){var t,e;await super.onCreated(),this.model.dewizard.dewizardForms.forEach((t=>{var e,a,i;t.firstForm&&(this.firstForm=t);const s="".concat(this.model.name,"_form_").concat(null==(e=t.formTag)?void 0:e.toLowerCase()),n=null==(i=null==(a=this.model.dewizard)?void 0:a.dewizardSteps)?void 0:i.find((e=>e.id===t.dewizardStepId)),o=null==n?void 0:n.stepTag;this.stepTags[s]=o})),null==(e=null==(t=this.model.dewizard)?void 0:t.dewizardSteps)||e.forEach((t=>{this.steps.push(t.stepTag)})),this.service=new Md(this.model),await this.service.init(this.context);const{deeditForms:a}=this.model;a&&a.length>0&&await Promise.all(a.map((async t=>{const{formTag:e}=t.dewizardForm;if(e){const a=await es(t);a&&(this.providers[e]=a)}})))}get activeWizardForm(){const{activeFormTag:t}=this.state,e=this.model.dewizard.dewizardForms.find((e=>e.formTag===t));return e||ibiz.log.debug("找不到".concat(t,"的向导表单")),e}get activeFormController(){const{activeFormTag:t}=this.state,e=this.formControllers.get(t);if(!e)throw new o("找不到".concat(t,"的表单控制器"));return e}async onFormMounted(t,e){const a=e.ctrl;this.formControllers.set(t,a);const i=await a.load();Object.assign(this.formData,i)}onFormSaved(t){const e=t.data[0];Object.assign(this.formData,e);const a=ve(this.model.appDataEntityId);!this.context[a]&&e&&e.srfkey&&(this.context[a]=e.srfkey)}getWizardFormByTag(t){var e;if(!(null==(e=this.model.dewizard)?void 0:e.dewizardForms))throw new o("没有配置向导表单集合");const a=this.model.dewizard.dewizardForms.find((e=>e.formTag===t));if(!a)throw new o("找不到标识为".concat(t,"的向导表单"));return a}async initialize(){var t;if(null==(t=this.model.initControlAction)?void 0:t.appDEMethodId){const t=await this.service.initialize(this.context,{},this.params),e=ve(this.model.appDataEntityId);if(t.data&&t.data.srfkey&&(this.formData=t.data,this.context[e]=t.data.srfkey),t.data&&this.model.stateAppDEFieldId&&t.data[this.model.stateAppDEFieldId]){const e=this.getWizardFormByTag(t.data[this.model.stateAppDEFieldId]);e&&(this.state.activeFormTag=e.formTag)}}!this.state.activeFormTag&&this.firstForm&&(this.state.activeFormTag=this.firstForm.formTag,this.tagHistory.push(this.firstForm.formTag))}async finish(){await this.service.finish(this.context,this.formData,this.params),this.evt.emit("onFinishSuccess",void 0)}async onPrevClick(){let t,e;if(this.activeFormController.model.goBackControlAction&&(t=await this.activeFormController.goBack()),this.model.stateAppDEFieldId&&t&&t[this.model.stateAppDEFieldId]){this.getWizardFormByTag(t[this.model.stateAppDEFieldId])&&(e=t[this.model.stateAppDEFieldId])}else this.tagHistory.pop(),e=this.tagHistory[this.tagHistory.length-1];if(!e)throw new o("没有上一个表单");this.state.activeFormTag=e}async onNextClick(){const t=await this.activeFormController.save({silent:!0});let e;if(t.srfnextform){this.getWizardFormByTag(t.srfnextform)&&(e=t.srfnextform,this.tagHistory.push(e))}else if(this.model.stateAppDEFieldId&&t[this.model.stateAppDEFieldId]){this.getWizardFormByTag(t[this.model.stateAppDEFieldId])&&(e=t[this.model.stateAppDEFieldId])}else{const t=this.model.dewizard.dewizardSteps,a=this.model.dewizard.dewizardForms;if(t&&a){const a=t.findIndex((t=>t.id===this.activeWizardForm.dewizardStepId)),i=t[a+1];if(!i)throw new o("找不到下一个向导步骤");const s=this.getWizardFormByTag(i.stepTag);s&&s.formTag&&(e=s.formTag)}}if(!e)throw new o("找不到下一个向导表单");this.state.activeFormTag=e,this.tagHistory.push(e)}async onFinishClick(){await this.activeFormController.save(),await this.finish()}}),t("MDCtrlService",class extends vn{initUIDataMap(){var t;super.initUIDataMap(),null==(t=this.model.delistDataItems)||t.forEach((t=>{const e=t.id.toLowerCase(),a=t.appDEFieldId;let i;if(a){const s=a.toLowerCase();i=new fo(e,s,{isOriginField:!0,dataType:t.dataType})}else i=new fo(e,e);this.dataUIMap.set(e,i)}))}})),Ld=t("MobMDCtrlRowState",class{constructor(t,e){this.data=t,this.controller=e,this.uaColStates={},this.data=t}}),_d=(t("MDCtrlController",class extends Cr{initState(){super.initState(),this.state.rows=[],this.state.noSort=!0===this.model.noSort,this.state.mdctrlActiveMode=1}async onCreated(){await super.onCreated(),this.service=new Od(this.model),await this.service.init(this.context),this.setSort()}async loadMore(){this.state.total>this.state.items.length&&!this.state.isLoading&&await this.load({isLoadMore:!0,silent:!0})}async refresh(){this.doNextActive((()=>this.load({isInitialLoad:!0})),{key:"refresh"})}async afterLoad(t,e){return t.isInitialLoad&&(this.state.rows=[]),e&&e.length>0&&this.state.rows.push(...e.map((t=>{const e=new Ld(t,this);return this.initActionStates(e),e}))),await this.initGroupCodeListItems(),await this.handleDataGroup(),super.afterLoad(t,e)}setData(t){const e=t.map((t=>new Ld(t,this)));this.state.rows=e}getAllData(){return this.state.rows.map((t=>t.data))}async onActionClick(t,e,a){const i=t.uiactionId;await fc.execAndResolved(i,{context:this.context,params:this.params,data:[e.data],view:this.view,event:a},t.appId)}initActionStates(t){const{deuiactionGroup:e,deuiactionGroup2:a}=this.model;e&&this.initUIActionGroup(t,e),a&&this.initUIActionGroup(t,a)}initUIActionGroup(t,e){var a;(null==(a=e.uiactionGroupDetails)?void 0:a.length)||ibiz.log.debug("操作列界面行为组没有配置界面行为");const i=new qo;(e.uiactionGroupDetails||[]).forEach((t=>{const e=t.uiactionId;if(e){const a=new Ho(t.id,this.context.srfappid,e);i.addState(t.id,a)}})),i.update(this.context,t.data.getOrigin()),t.uaColStates[e.id]=i}async handleDataGroup(){const{enableGroup:t,groupMode:e,groupAppDEFieldId:i}=this.model;if(t&&e){if(!i)throw new a(this.model,"分组属性没有配置");"AUTO"===e?this.handleAutoGroup():"CODELIST"===e&&await this.handleCodeListGroup()}}handleAutoGroup(){const{groupAppDEFieldId:t}=this.model;if(t){const{items:e}=this.state,a=new Map;e.forEach((e=>{const i=e[t];Q(i)||(a.has(i)||a.set(i,[]),a.get(i).push(new Ld(e,this)))}));const i=[];a.forEach(((t,e)=>{i.push({caption:e,key:e,children:[...t]})})),this.state.groups=i}}async initGroupCodeListItems(){const{groupCodeListId:t}=this.model;if(!t)return;const e=ibiz.hub.getApp(this.context.srfappid);this.groupCodeListItems=await e.codeList.get(t,this.context,this.params)}async handleCodeListGroup(){const{groupAppDEFieldId:t,groupCodeListId:e}=this.model;if(!e)throw new a(this.model,"分组代码表没有配置");const{items:i}=this.state,s=new Map;this.groupCodeListItems.forEach((t=>{s.set(t.value,[])})),i.forEach((e=>{const a=e[t],i=s.get(a);i&&i.push(new Ld(e,this))}));const n=[];s.forEach(((t,e)=>{const a=this.groupCodeListItems.find((t=>t.value===e));n.push({caption:a.text,key:a.value,children:t})})),this.state.groups=n}}),t("KanbanService",class extends Tc{async updateGroup(t,e){var a;const i=(null==(a=this.model.updateGroupControlAction)?void 0:a.appDEMethodId)||"update";let s=await this.exec(i,t,e.getOrigin());return s=this.handleResponse(s),s}})),Fd=(t("KanbanController",class extends xc{get enableEditOrder(){return!0===this.model.enableCardEditOrder}get enableEditGroup(){return!0===this.model.enableCardEditGroup}async initControlService(){this.service=new _d(this.model),await this.service.init(this.context)}initState(){super.initState(),this.state.size=this.model.pagingSize||1e3,this.state.updating=!1,this.state.batching=!1,this.state.selectGroupKey="",this.state.draggable=this.enableEditOrder||this.enableEditGroup,this.state.uaState={}}async onCreated(){await super.onCreated(),this.setToolbarHooks()}sortItems(t){const e=this.model.minorSortAppDEFieldId,{minorSortDir:i}=this.model;if(!e)throw new a(this.model,"排序属性没配置");if(!i)throw new a(this.model,"排序方向没配置");const s="ASC"===i;t.forEach((t=>{const a=t[e];if(Q(a))t[e]=0;else{const e=Number(a);if(Number.isNaN(e))throw new o("".concat(t.srfmajortext,"的排序属性无法转换成数值"))}})),t.sort(((t,a)=>s?t[e]-a[e]:a[e]-t[e]))}async afterLoad(t,e){var a;this.sortItems(this.state.items),super.afterLoad(t,e);const i=[];return null==(a=this.model.dedataViewItems)||a.forEach((t=>{"ACTIONITEM"===t.itemType&&t.deuiactionGroup&&t.deuiactionGroup.uiactionGroupDetails&&i.push(...t.deuiactionGroup.uiactionGroupDetails)})),i&&i.length>0&&e.forEach((t=>{const e=new qo;i.forEach((t=>{const a=t.uiactionId;if(a){const i=new Ho(t.id,this.context.srfappid,a);e.addState(t.id,i)}})),this.state.uaState[t.srfkey]=e})),e.forEach((t=>{this.state.uaState[t.srfkey]&&Object.keys(this.state.uaState[t.srfkey]).length>0&&this.state.uaState[t.srfkey].update(this.context,t.getOrigin(),this.model.appDataEntityId)})),e}async onRowClick(t){const{groupAppDEFieldId:e}=this.model;if(this.state.batching&&e){if(t[e]!==this.state.selectGroupKey)return void(1===this.state.mdctrlActiveMode&&await this.setActive(t))}super.onRowClick(t)}onClickNew(t,e){this.setSelectGroup(e),super.onClickNew(t,e)}async onGroupToolbarClick(t,e,a){this.setSelectGroup(a.key),super.onGroupToolbarClick(t,e,a)}async onGroupActionClick(t,e,a,i){this.setSelectGroup(i.key);const s={...this.params,srfgroup:i},n=t.uiactionId;await fc.execAndResolved(n,{context:this.context,params:s,data:[e],view:this.view,event:a},t.appId)}handleDataGroup(){if(!this.model.enableGroup||"NONE"===this.model.groupMode)throw new o("看板部件必须开启分组");return super.handleDataGroup()}handleAutoGroup(){const{groupAppDEFieldId:t}=this.model;if(t){const{items:e}=this.state,a=new Map;e.forEach((e=>{const i=e[t];Q(i)||(a.has(i)||a.set(i,[]),a.get(i).push(e))}));const i=[];a.forEach(((t,e)=>{const a=this.groupCodeListItems.find((t=>t.value===e));i.push({caption:a.text,color:a.color,key:a.value,children:[...t]})})),this.state.groups=i}}async handleCodeListGroup(){const{groupAppDEFieldId:t,groupCodeListId:e}=this.model;if(!e)throw new a(this.model,"分组代码表没有配置");const{items:i}=this.state,s=new Map;this.groupCodeListItems.forEach((t=>{s.set(t.value,[])})),i.forEach((e=>{const a=e[t],i=s.get(a);i&&i.push(e)}));const n=[];s.forEach(((t,e)=>{const a=this.groupCodeListItems.find((t=>t.value===e));n.push({caption:a.text,color:a.color,key:a.value,children:t})})),this.state.groups=n}async onDragChange(t){if(!this.enableEditGroup&&t.from!==t.to)return void ibiz.message.warning("当前看板不允许调整分组!");const e="ASC"===this.model.minorSortDir,{from:a,to:i,fromIndex:s,toIndex:n}=t,o=this.model.groupAppDEFieldId,r=this.model.minorSortAppDEFieldId,c=[],d=this.state.groups.find((t=>t.key===a)),l=this.state.groups.find((t=>t.key===i));if(!this.enableEditOrder){if(t.from===t.to)return void ibiz.message.warning("当前看板不允许调整次序");const e=d.children[s];return e[o]=t.to,this.updateChangedItems([e])}const h=t=>t+(100-t%100),u=[...l.children],p=[...l.children],m=d.children[s];t.from!==t.to?(m[o]=t.to,p.splice(n,0,m)):(p.splice(s,1),p.splice(n,0,m));const f=d.children.splice(s,1);let g;l.children.splice(n,0,...f),e||(u.reverse(),p.reverse());let w,E=[];p.forEach(((t,e)=>{void 0===g?t!==u[e]&&(g=u[e]?u[e][r]||100:0===e?100:h(u[e-1][r]),t[r]=g,c.push(t)):(g>=t[r]?(E.length>0&&(E.forEach((t=>{t[r]=h(w),c.push(t),w=t[r]})),g=w,w=0,E=[]),t[r]=h(g),c.push(t)):(0===E.length&&(w=g),E.push(t)),g=t[r])})),this.updateChangedItems(c)}async updateChangedItems(t){try{this.state.updating=!0,await Promise.all(t.map((async t=>{const e=ve(this.model.appDataEntityId),a=this.context.clone();a[e]=t.srfkey;const i=await this.service.updateGroup(a,t);if(i.data){const e=this.state.items.findIndex((e=>e.srfkey===t.srfkey));this.state.items.splice(e,1,i.data)}})))}finally{this.state.updating=!1,await this.afterLoad({},this.state.items)}}getFullscreen(){return document.isFullScreen||document.mozIsFullScreen||document.webkitIsFullScreen}onFullScreen(t){const e=this.getFullscreen();return e?document.documentElement.requestFullScreen?document.exitFullScreen():document.documentElement.webkitRequestFullScreen?document.webkitCancelFullScreen():document.documentElement.mozRequestFullScreen&&document.mozCancelFullScreen():t&&(t.webkitRequestFullscreen?t.webkitRequestFullscreen():t.mozRequestFullScreen?t.mozRequestFullScreen():t.msRequestFullscreen?t.msRequestFullscreen():t.requestFullscreen&&t.requestFullscreen()),!e}setSelectGroup(t){this.state.batching||(this.state.selectGroupKey=t)}setGroupController(t,e,a){const i=this.state.groups.find((e=>e.key===t));i&&(i[e]=a)}setToolbarHooks(){this.listenNewController(((t,e)=>{(t.startsWith("".concat(this.model.name,"_quicktoolbar"))||t.startsWith("".concat(this.model.name,"_groupquicktoolbar")))&&this.setQuickToolbarClickHook(t,e),t.startsWith("".concat(this.model.name,"_batchtoolbar"))&&this.setBatchToolbarClickHook(t,e)}))}setQuickToolbarClickHook(t,e){const a=t.split("quicktoolbar_")[1];this.setGroupController(a,"quickToolbarController",e),e.evt.on("onClick",(t=>{const e=t.targetName.split("quicktoolbar_")[1];this.setSelectGroup(e),Object.assign(t.params,{srfgroup:e})}))}setBatchToolbarClickHook(t,e){const a=t.split("batchtoolbar_")[1];this.setGroupController(a,"batchToolbarController",e),e.evt.on("onClick",(t=>{const e=t.targetName.split("batchtoolbar_")[1];this.setSelectGroup(e),Object.assign(t.params,{srfgroup:e})}))}openBatch(t){this.state.selectGroupKey=t,this.state.batching=!0,this.state.selectedData=[],this.state.groups.forEach((t=>{t.selectedData=[]}))}closeBatch(){this.state.selectGroupKey="",this.state.batching=!1,this.state.selectedData=[],this.state.groups.forEach((t=>{t.selectedData=[]}))}}),t("TreeGridExService",class extends Nd{})),Vd=t("TreeGridExRowState",class{constructor(t,e){this.errors={},this.columnActionsStates={},this.editColStates={},this.modified=!1,this.showRowEdit=!1,this.processing=!1,this.data=t,"DE"===t._nodeType&&(Object.values(e.uaColumns).forEach((t=>{t.initActionStates(this)})),Object.values(e.fieldColumns).forEach((t=>{t.initActionStates(this)})),Object.values(e.fieldColumns).forEach((t=>{this.editColStates[t.name]={disabled:!1,readonly:!1,editable:"all"===ibiz.config.grid.editShowMode,required:!1}})))}}),kd=t("TreeGridExController",class extends Rd{constructor(){super(...arguments),this.providers={},this.columns={},this.fieldColumns={},this.uaColumns={}}get _evt(){return this.evt}get hasAdaptiveColumn(){return!!Object.values(this.columns).find((t=>t.isAdaptiveColumn))}get overflowMode(){return ibiz.config.grid.overflowMode}get allowRowEdit(){return this.state.rowEditOpen}initState(){super.initState(),this.state.columnStates=[],this.state.rootNodes=[],this.state.rows={},this.state.rowEditOpen=!0}async onCreated(){await super.onCreated(),await this.initGridColumns(),this.initColumnStates()}async initService(){this.service=new Fd(this.model),await this.service.init(this.context)}async initGridColumns(){this.model.detreeColumns&&await Promise.all(this.model.detreeColumns.map((async t=>this.initColumnsController(t))))}async initColumnsController(t){const e=await Ws(t);if(!e)return;this.providers[t.codeName]=e;const a=await e.createController(t,this);this.columns[t.codeName]=a,"DEFGRIDCOLUMN"===t.columnType?this.fieldColumns[t.codeName]=a:"UAGRIDCOLUMN"===t.columnType&&(this.uaColumns[t.codeName]=a)}initColumnStates(){var t;null==(t=this.model.detreeColumns)||t.forEach((t=>{this.state.columnStates.push({key:t.codeName,caption:t.caption,hidden:!!t.hideDefault,uaColumn:"UAGRIDCOLUMN"===t.columnType})})),this.calcColumnFixed()}calcColumnFixed(){const t=this.state.columnStates.filter((t=>!t.hidden)),e=t.length;t.forEach(((t,a)=>{t.uaColumn&&(t.fixed=a+1<=Math.floor(e/2)?"left":"right")}))}getRowState(t){const e=this.getNodeData(t);if(e)return this.state.rows[e._uuid]}async afterLoadNodes(t){await super.afterLoadNodes(t),r({_children:t},(t=>{this.state.rows[t._uuid]=new Vd(t,this)}),{childrenFields:["_children"]})}convertMultipleLanguages(){this.model.detreeColumns&&this.model.detreeColumns.length>0&&this.model.detreeColumns.forEach((t=>{t.capLanguageRes&&t.capLanguageRes.lanResTag&&(t.caption=ibiz.i18n.t(t.capLanguageRes.lanResTag,t.caption))}))}async save(t){if(this.state.isSimple)return void ibiz.log.debug("简单模式,不保存");if("DE"!==t._nodeType)throw new o("非实体节点数据不能保存");const e=this.state.rows[t._uuid];if(!e)throw new o("行数据不存在");if(!e.modified)return void ibiz.log.debug("值没有发生改变");if(e.processing)return void await x(500,this.save.bind(this),[t]);const i=this.getNodeModel(t._nodeId),{appDataEntityId:s,updateAppDEActionId:n}=i,r=0===t._deData.srfuf;if(r)throw new o("暂不支持新建");if(!n)throw new a(i,"树节点没有配置更新实体行为");const c=ve(s),d=this.context.clone();d[c]=t._deData.srfkey;const l=ibiz.hub.getApp(this.context.srfappid);let h;try{h=await l.deService.exec(s,n,d,t._deData)}catch(t){throw await this._evt.emit("onSaveError",void 0),this.actionNotification("".concat(r?"CREATE":"UPDATE","ERROR"),{error:t,data:e.data}),t}e.data._deData=h.data,e.modified=!1,this.gridStateNotify(e,"SAVE"),await this._evt.emit("onSaveSuccess",void 0)}async saveAll(){const t=Object.values(this.state.rows).filter((t=>t.modified)).map((t=>t.data));t.length&&await ba(t.map((t=>this.save(t))))}gridStateNotify(t,e){Object.values(this.columns).forEach((a=>{a.gridStateNotify(t,e)}))}async setRowValue(t,e,a){if(!Object.prototype.hasOwnProperty.call(t.data,e)||Jo(t.data[e],a)){t.data[e]=a,t.modified=!0,t.processing=!0;try{await this.dataChangeNotify(t,[e])}finally{t.processing=!1}}}async dataChangeNotify(t,e){await ba(Object.values(this.columns).map((async a=>a.dataChangeNotify(t,e))))}async toggleRowEdit(){this.state.rowEditOpen=!this.state.rowEditOpen}calcDefaultValue(t,e){const a={};return Object.values(this.fieldColumns).forEach((i=>{const s=i.nodeColumnControllerMap.get(t._nodeId);if(!s||!s.nodeEditItem)return;const{createDV:n,createDVT:o,updateDV:r,updateDVT:c}=s.nodeEditItem,d=e?o:c,l=e?n:r,h=ir({name:i.name,valueType:d,defaultValue:l,valueFormat:s.valueFormat},{data:t,context:this.context,params:this.params});void 0!==h&&(a[i.name]=h)})),a}async switchRowEdit(t,e,a=!0){if(!this.allowRowEdit)return;if("DE"!==t.data._nodeType)return;const i=void 0===e?!t.showRowEdit:e;if(t.showRowEdit!==i){if(!1===i)if(a)await this.save(t.data);else{if(0===t.data._deData.srfuf)return t.showRowEdit=!1,this._evt.emit("onRowEditChange",{row:t}),this.remove({data:[t.data],silent:!0});t.cacheData&&(t.data=t.cacheData,delete t.cacheData)}else{if(Object.values(this.state.rows).find((t=>t.showRowEdit)))throw new o("同时只能有一行开启行编辑");if(1===t.data._deData.srfuf){t.cacheData=Z(t.data);const e=this.calcDefaultValue(t.data,!1);Object.assign(t.data,e)}}t.showRowEdit=i,Object.values(this.fieldColumns).forEach((e=>{t.editColStates[e.name].editable=i})),this._evt.emit("onRowEditChange",{row:t})}}}),zd=t("TreeGridExColumnController",class{constructor(t,e){this.isAdaptiveColumn=!1,this.isCustomCode=!1,this.model=t,this.treeGrid=e,this.isAdaptiveColumn="STAR"===t.widthUnit}get context(){return this.treeGrid.context}get params(){return this.treeGrid.params}get isFirstShowColumn(){const t=this.treeGrid.state.columnStates.find((t=>!t.hidden));return(null==t?void 0:t.key)===this.model.codeName}async init(){await this.onInit()}async onInit(){}gridStateNotify(t,e){}async dataChangeNotify(t,e){}}),Wd=t("TreeGridExNodeColumnController",class{constructor(t,e){this.fieldColumn=t,this.nodeModel=e,this.codeList=void 0;const{detreeNodeColumns:i,detreeNodeDataItems:s,detreeNodeEditItems:n}=e,o=null==i?void 0:i.find((t=>t.detreeColumnId===this.fieldColumn.model.id)),r=null==s?void 0:s.find((t=>t.id===o.dataItemName));if(!o||!r)throw new a(e,"节点没有配置对应表格列".concat(this.fieldColumn.name,"的数据项"));if(this.nodeColumn=o,this.nodeDataItem=r,o.enableRowEdit){const t=null==n?void 0:n.find((t=>t.id===o.id));if(!t)throw new a(e,"没有找到对应表格列".concat(this.fieldColumn.name,"的编辑项模型"));this.nodeEditItem=t}}get unitName(){var t;return null==(t=this.nodeEditItem)?void 0:t.unitName}get valueFormat(){return this.nodeColumn.valueFormat}get context(){return this.fieldColumn.context}get params(){return this.fieldColumn.params}get dataType(){var t;return null==(t=this.nodeDataItem)?void 0:t.dataType}get name(){return this.fieldColumn.name}get treeGrid(){return this.fieldColumn.treeGrid}get isLinkColumn(){return!!this.nodeColumn.enableLinkView&&!!this.nodeColumn.linkAppViewId}get hasClickAction(){return!!this.nodeColumn.deuiactionId}get overflowMode(){return this.fieldColumn.treeGrid.overflowMode}async init(){var t;(null==(t=this.nodeEditItem)?void 0:t.editor)&&"HIDDEN"!==this.nodeEditItem.editor.editorType&&(this.editorProvider=await ss(this.nodeEditItem.editor),this.editorProvider&&(this.editor=await this.editorProvider.createController(this.nodeEditItem.editor,this))),this.nodeEditItem||await this.loadCodeList()}initActionStates(t){const{deuiactionGroup:e}=this.nodeColumn;if(e&&e.uiactionGroupDetails){const a=new qo;e.uiactionGroupDetails.forEach((t=>{const e=t.uiactionId;if(e){const i=new Ho(t.id,this.context.srfappid,e);a.addState(t.id,i)}})),t.columnActionsStates[this.name]=a}}onTextClick(t,e){this.isLinkColumn?(e.stopPropagation(),this.openLinkView(t,e)):this.hasClickAction&&(e.stopPropagation(),this.triggerAction(t,e))}async openLinkView(t,e){if(!t.data[this.fieldColumn.name])return;const a=this.nodeColumn.linkValueItem||"srfkey",i=t.data[a];if(null==i)throw new o("未在行数据中取到 ".concat(a," 的值"));const{linkAppViewId:s}=this.nodeColumn;if(!s)return;const n=aa(t.data),r=Object.assign(this.context.clone(),{srfkey:i,...n}),c=Z(this.params),{userParam:d}=this.nodeColumn;if(d){const{navigateContexts:e,navigateParams:a}=pe(d);let i={};e&&t.data&&(i=oe(e,t.data,c,r)),Object.assign(r,i);let s={};a&&t.data&&(s=oe(a,t.data,c,r)),Object.assign(c,s)}const l=await ibiz.commands.execute(So.TAG,s,r,c,{event:e});(null==l?void 0:l.ok)&&this.fieldColumn.treeGrid.refresh()}async triggerAction(t,e){const a=this.nodeColumn.deuiactionId;await fc.execAndResolved(a,{context:this.context,params:this.params,data:[t.data],view:this.treeGrid.view,event:e},this.nodeColumn.appId)}async onActionClick(t,e,a){const i=t.uiactionId;await this.treeGrid.doUIAction(i,e.data,a,t.appId)}formatValue(t=""){if("SIMPLE"!==this.nodeColumn.valueType)return ar.toText(this.nodeColumn,t);const e="".concat(t);if(!this.valueFormat)return e;if(l.isDate(this.dataType)||"createdate"===this.fieldColumn.name){const t=yt(e).format(this.valueFormat);return"Invalid Date"!==t?t:e}return ibiz.util.text.format(e,this.valueFormat)}async loadCodeList(){const t=this.nodeColumn.appCodeListId;if(!t)return;const e=ibiz.hub.getApp(this.context.srfappid);this.codeList||(this.codeList=e.codeList.getCodeList(t));const a=await e.codeList.get(t,this.context,this.params);return this.codeListItems=a,a}gridStateNotify(t,e){if("LOAD"===e||"SAVE"===e){const e=t.columnActionsStates[this.name];e&&"DE"===t.data._nodeType&&e.update(this.context,t.data._deData)}}async setRowValue(t,e,a){a=a||this.name,await this.treeGrid.setRowValue(t,a,e)}}),Ud=(t("TreeGridExFieldColumnController",class extends zd{constructor(){super(...arguments),this.nodeColumnControllerMap=new Map}get name(){return this.model.id}async init(){await this.onInit(),await this.initNodeColumnController()}async initNodeColumnController(){var t;null==(t=this.treeGrid.model.detreeNodes)||t.forEach((t=>{var e;if("DE"!==t.treeNodeType)return;(null==(e=t.detreeNodeColumns)?void 0:e.find((t=>t.detreeColumnId===this.model.id)))&&this.nodeColumnControllerMap.set(t.id,new Wd(this,t))})),await Promise.all(Array.from(this.nodeColumnControllerMap.values()).map((t=>t.init())))}initActionStates(t){const e=this.nodeColumnControllerMap.get(t.data._nodeId);e&&e.initActionStates(t)}gridStateNotify(t,e){super.gridStateNotify(t,e);const a=this.nodeColumnControllerMap.get(t.data._nodeId);a&&a.gridStateNotify(t,e)}}),t("TreeGridExUAColumnController",class extends zd{constructor(){super(...arguments),this.nodeColumnMap=new Map}async init(){await this.onInit(),await this.initNodeColumnMap()}initNodeColumnMap(){var t;null==(t=this.treeGrid.model.detreeNodes)||t.forEach((t=>{var e;if("DE"!==t.treeNodeType)return;const a=null==(e=t.detreeNodeColumns)?void 0:e.find((t=>t.detreeColumnId===this.model.id));a&&this.nodeColumnMap.set(t.id,a)}))}getUIActionGroup(t){let{deuiactionGroup:e}=this.model;if("DE"===t.data._nodeType&&this.nodeColumnMap.get(t.data._nodeId)){const a=this.nodeColumnMap.get(t.data._nodeId);a.deuiactionGroup&&(e=a.deuiactionGroup)}return e}initActionStates(t){var e;const a=this.getUIActionGroup(t);if(!a)return void ibiz.log.warn("".concat(this.model.id,"操作列没有配置界面行为组"));if(!(null==(e=a.uiactionGroupDetails)?void 0:e.length))return void ibiz.log.debug("操作列界面行为组没有配置界面行为");const i=new qo;a.uiactionGroupDetails.forEach((t=>{const e=t.uiactionId;if(e){const a=new Ho(t.id,this.treeGrid.context.srfappid,e);i.addState(t.id,a)}})),t.columnActionsStates[this.model.id]=i}async onActionClick(t,e,a){const i=t.uiactionId;await this.treeGrid.doUIAction(i,e.data,a,t.appId)}gridStateNotify(t,e){if(super.gridStateNotify(t,e),"LOAD"===e||"SAVE"===e){const e=t.columnActionsStates[this.model.id];e&&"DE"===t.data._nodeType&&e.update(this.context,t.data._deData)}}}),t("TreeGridController",class extends td{constructor(){super(...arguments),this.treeGridValueField="",this.treeGridParentField=""}initState(){super.initState(),this.state.showTreeGrid=!0}async onCreated(){await super.onCreated(),this.initTreeGridField()}initTreeGridField(){var t,e;const i=null==(t=this.model.degridColumns)?void 0:t.find((t=>4===t.treeColumnMode||12===t.treeColumnMode)),s=null==(e=this.model.degridColumns)?void 0:e.find((t=>2===t.treeColumnMode||3===t.treeColumnMode));if(!i)throw new a(this.model,"树表格无值列模式");if(!s)throw new a(this.model,"树表格无父值列模式");this.treeGridValueField=s.appDEFieldId.toLowerCase(),this.treeGridParentField=i.appDEFieldId.toLowerCase()}switchTreeGridShow(){this.state.showTreeGrid=!this.state.showTreeGrid}}),t("TreeGridService",class extends Jc{}),t("MEditViewPanelService",class extends vn{})),Bd=(t("MEditViewPanelController",class extends Cr{constructor(){super(...arguments),this.parameters=[]}async onCreated(){await super.onCreated(),this.service=new Ud(this.model),await this.service.init(this.context),await this.initParameters()}initState(){super.initState(),this.state.panelUiItems=[],this.state.activeTab="",this.state.size=1e3,this.state.isNeedScroll=!1}async initParameters(){var t,e;if(this.model.embeddedAppViewId){const a=await ibiz.hub.getAppView(this.model.embeddedAppViewId);if(a.appDataEntityId){const i=await ibiz.hub.getAppDataEntity(a.appDataEntityId,a.appId);this.parameters=a&&i?[{parameterName:null==(t=i.keyAppDEFieldId)?void 0:t.toLowerCase(),pathName:null==(e=i.codeName)?void 0:e.toLowerCase()}]:[]}}}async afterLoad(t,e){await super.afterLoad(t,e);const a=this.state.panelUiItems.filter((t=>t.id.startsWith("mockId:")));return this.state.panelUiItems=[],this.doItems(e,a),"TAB_TOP"===this.model.panelStyle&&this.state.panelUiItems.length>0&&0===a.length&&(this.state.activeTab=this.state.panelUiItems[0].id),e}handlePanelItemParams(t){const[{parameterName:e}]=this.parameters,a={id:t[e]?t[e]:"mockId:".concat(ct()),context:this.context.clone(),params:{},data:t,srfmajortext:""};return this.parameters.forEach((e=>{const{parameterName:i,pathName:s}=e;t[i]&&!Object.is(t[i],"")&&Object.assign(a.context,{[s]:t[i]}),t.srfmajortext&&!Object.is(t.srfmajortext,"")?Object.assign(a,{srfmajortext:t.srfmajortext}):0===t.srfuf&&Object.assign(a,{srfmajortext:"草稿--新建"})})),a}doItems(t,e){t.forEach((t=>{const e=this.handlePanelItemParams(t);this.state.panelUiItems.push(e)})),e&&this.state.panelUiItems.push(...e)}async handleAdd(){this.state.isNeedScroll=!0,this.doItems([{srfuf:0}]),"TAB_TOP"===this.model.panelStyle&&(this.state.activeTab=this.state.panelUiItems[this.state.panelUiItems.length-1].id)}async handleDelete(t){if(this.state.isNeedScroll=!1,0===t.data.srfuf){const e=this.state.panelUiItems.findIndex((e=>e===t));this.state.panelUiItems.splice(e,1)}else await this.remove({data:[t.data],notRefresh:!0})}async handleTabDelete(t,e){let a=!1;t.id===this.state.activeTab&&e===this.state.panelUiItems.length-1&&e>0&&(a=!0),await this.handleDelete(t),a&&(this.state.activeTab=this.state.panelUiItems[this.state.panelUiItems.length-1].id)}afterRemove(t){super.afterRemove(t);const e=this.state.panelUiItems.findIndex((e=>e.data.srfkey===t.srfkey));-1!==e&&this.state.panelUiItems.splice(e,1)}onViewDataChange(t,e){"onSaveSuccess"===t.eventName&&this.handleDataChange(t.data[0],e)}async handleDataChange(t,e){const a=this.state.panelUiItems.findIndex((t=>t.id===e));if(a<0)throw new o("编辑视图面板部件UI数据不存在");const i=this.state.panelUiItems[a];i.id.startsWith("mockId:")?this.state.panelUiItems[a]=this.handlePanelItemParams(t):i.srfmajortext=t.srfmajortext,"TAB_TOP"===this.model.panelStyle&&(this.state.activeTab=this.state.panelUiItems[a].id)}}),t("MapService",class extends vn{async init(t){await super.init(t)}async fetchAll(t,e={}){var a;const i=[];if(null==(a=this.model.sysMapItems)?void 0:a.length){const a=ibiz.hub.getApp(t.srfappid);await Promise.all(this.model.sysMapItems.map((async s=>{const{appDataEntityId:n,appDEDataSetId:o,customCond:r}=s,c=t.clone(),d={...e};if(r){const a=Qe.execSingleLine(r);if(a){const{navigateContexts:i,navigateParams:s}=pe(a);i&&Object.assign(c,oe(i,e,t)),s&&Object.assign(d,oe(i,e,t))}}const l=await a.deService.exec(n,o,c,d);l.data&&i.push(...l.data.map((t=>new Eo(t,s))))})))}return new p(i,200)}})),Gd=(t("MapController",class extends Cr{initState(){super.initState(),this.state.size=1e3,this.state.pointData=[],this.state.areaData=[],this.calcDefaultOptions()}async onCreated(){await super.onCreated(),this.service=new Bd(this.model),await this.service.init(this.context)}async load(t={}){if(this.state.isSimple)return[];await this.startLoading();try{const e=!0===t.isInitialLoad,{context:a}=this.handlerAbilityParams(t),i=await this.getFetchParams(null==t?void 0:t.viewParam);a.srfareacode=this.state.areaCode;const s=await this.service.fetchAll(a,i);this.state.items=s.data,await this.afterLoad(t,s.data),this.state.isLoaded=!0,await this._evt.emit("onLoadSuccess",{isInitialLoad:e})}catch(t){throw await this._evt.emit("onLoadError",void 0),this.actionNotification("FETCHERROR",{error:t}),t}finally{await this.endLoading()}return this.actionNotification("FETCHSUCCESS"),this.state.items}async afterLoad(t,e){const a=await super.afterLoad(t,e),i=[],s=[];return a.forEach((t=>{"REGION"===t._itemStyle?i.push(t):"POINT"===t._itemStyle&&s.push(t)})),this.state.pointData=s,this.state.areaData=i,a}calcDefaultOptions(){var t;if(this.state.strAreaCode=!1,this.state.defaultAreaCode=1e5,null==(t=this.model.controlParam)?void 0:t.ctrlParams){const{ctrlParams:t}=this.model.controlParam;Object.keys(t).forEach((e=>{const a=t[e];switch(e.toLowerCase()){case"defaultareacode":this.state.defaultAreaCode=a;break;case"strareacode":this.state.strAreaCode="true"===a;break;case"jsonbaseurl":this.state.jsonBaseUrl=a}}))}this.state.defaultAreaCode=this.state.strAreaCode?"".concat(this.state.defaultAreaCode):Number(this.state.defaultAreaCode),this.state.areaCode=this.state.defaultAreaCode}onMapChange(t){this.state.areaCode=t,this.load({}),this.evt.emit("onMapChange",{areaCode:t})}onAreaClick(t){this.evt.emit("onAreaClick",{data:[t]})}onPointClick(t){this.evt.emit("onPointClick",{data:[t]})}}),t("ReportPanelService",class extends yn{async fetch(t,e={}){this.dataEntity=await ibiz.hub.getAppDataEntity(this.model.appDataEntityId,this.model.appId);const a="".concat(this.dataEntity.deapicodeName2,"/report?srfreporttag=").concat(this.model.codeName);let i=await ibiz.net.request(a,{method:"post",data:e});return i=this.handleResponse(i),i}})),jd=class{constructor(t){this.config={},this.model=t,this.setConfig()}setConfig(){}init(t){this.protoRef=t}load(t){return Promise.resolve(t)}},Kd=class extends jd{setConfig(){this.config={CONFIG:{fitView:!0,minZoom:.002,layout:{type:"force",preventOverlap:!0,linkDistance:200,nodeSize:80,nodeSpacing:30}},NODELEGENDCONFIG:{valueField:"source_lables||target_lables",selected:"{{return Object.is(data.source_lables, 'NEO4J_ZT') || Object.is(data.target_lables, 'NEO4J_ZT')}}",codeListTag:"web.nodetype"},EDGELEGENDCONFIG:{valueField:"relationship_type",codeListTag:"web.relationshiptype"},PLUGINCONFIG:{gridConfig:{},miniMapConfig:{}},HOOKS:{g6Hooks:[{name:"afterrender",callBack:"{{ const nodes = data.controller.graph.getNodes(); if (nodes.length < 25) { data.controller.graph.zoomTo(1); data.controller.graph.fitCenter() } }}"}],nodeDataHook:"{{ data.forEach(node => { const type = node.data.source_lables || node.data.target_lables; Object.assign(node, { label: node.data.name, size: 66, style: { fill: node.color },donutAttrs: { prop1: 10000, prop2: 10 },donutColorMap: { prop1: node.color, prop2: node.color },icon: {show: true,img: type === 'NEO4J_ZT' ? resource.dir('assets/images/user-avatar.png') : resource.dir('assets/images/phone.png'),width: 40,height: 40}})})}}",edgeDataHook:"{{ data.forEach(edge => {Object.assign(edge, { label: edge.name })}) }}"}}}load(t){return this.protoRef&&this.protoRef.setData(t),Promise.resolve(t)}},Xd=class extends jd{},Hd=class{static getInstance(t){if(!t||!t.appDEReport||!t.appDEReport.reportType)throw new Error("报表面板生成器工厂参数错误,报表面板未指定报表类型");switch(t.appDEReport.reportType){case"USER":return new Kd(t);case"USER2":return new Xd(t);default:throw new Error("指定报表".concat(t.appDEReport.reportType,"类型报表面板生成器暂未实现"))}}},qd=(t("ReportPanelController",class extends Dr{get _evt(){return this.evt}initState(){super.initState(),this.state.data={},this.state.searchParams={},this.state.reportType=this.model.appDEReport&&this.model.appDEReport.reportType||""}async onCreated(){await super.onCreated(),this.generator=Hd.getInstance(this.model),this.dataEntity=await ibiz.hub.getAppDataEntity(this.model.appDataEntityId,this.model.appId),this.service=new Gd(this.model),await this.service.init(this.context)}async onMounted(){await super.onMounted(),this.state.loadDefault&&this.load({isInitialLoad:!0})}onDestroyed(){return super.onDestroyed()}async load(t={}){await this.startLoading();try{const{context:e}=this.handlerAbilityParams(t),a=await this.getFetchParams(null==t?void 0:t.viewParam),i=await this.service.fetch(e,a);this.state.data=i.data,await this.afterLoad(t,i.data),this.state.isLoaded=!0,await this._evt.emit("onLoadSuccess",void 0)}catch(t){throw await this._evt.emit("onLoadError",void 0),this.actionNotification("FETCHERROR",{error:t}),t}finally{await this.endLoading()}return this.actionNotification("FETCHSUCCESS"),this.state.data}async afterLoad(t,e){return e}async getFetchParams(t){const e={...this.params};return await this._evt.emit("onBeforeLoad",void 0),Object.assign(e,{...this.state.searchParams}),t&&Object.assign(e,t),e}getData(){return[this.state.data]}async refresh(){this.doNextActive((()=>this.load({isInitialLoad:!1})),{key:"refresh"})}}),t("GanttService",class extends Nd{async getNodeDraft(t,e,a,i){var s;const{appDataEntityId:n}=t,{context:o,params:r,navContext:c,navParams:d}=e?this.getNodeRSFilterParams(e,a,i):{context:i.context,params:i.params,navContext:{},navParams:{}},l=await this.app.deService.exec(n,"getdraft",o,r),{data:h}=l;return(null==(s=null==e?void 0:e.parentDER1N)?void 0:s.pickupDEFName)&&a&&(h[e.parentDER1N.pickupDEFName]=a._value),new Co(this.model,t,a,{data:l.data,leaf:!0,navContext:c,navParams:d})}async fetchChildNodes(t,e){const{hasQuery:a}=e;let i=[];if(t){const s=xe(this.model,{parentId:t._nodeId,hasQuery:a});if(0===s.length)return;(await ba(s.map((async a=>{const i=Te(this.model,a.childDETreeNodeId);return this.fetchNodeDatasByType(i,a,t,e)})),!1)).forEach((t=>{i.push(...t)}))}else{const t=Pe(this.model);i=await this.fetchNodeDatasByType(t,void 0,void 0,e)}return i}async fetchNodeDatasByType(t,e,a,s){const n=0===xe(this.model,{parentId:t.id,hasQuery:s.hasQuery}).length,o={...s,leaf:n};let r=[];switch(t.treeNodeType){case"STATIC":r=[await this.getStaticGanttNodeData(t,e,a,o)];break;case"DE":r=await this.getDEGanttNodeDatas(t,e,a,o);break;case"CODELIST":r=await this.getCodeListGanttNodeDatas(t,e,a,o);break;default:throw new i(t,"".concat(t.treeNodeType,"节点类型未支持"))}const{expandFirstOnly:c,expanded:d,rootNode:l}=t,h=l&&!this.model.rootVisible;return n||await Promise.all(r.map((async(t,e)=>{if(d&&(!c||c&&0===e)||h){const e=await this.fetchChildNodes(t,s);t._children=e}}))),r}async getStaticGanttNodeData(t,e,a,i){return new Do(this.model,t,a,{parentValueLevel:null==e?void 0:e.parentValueLevel,leaf:!!i.leaf})}async getDEGanttNodeDatas(t,e,a,i){const{appDEDataSetId:s,appDataEntityId:n}=t,{context:o,params:r,navContext:c,navParams:d}=e?this.getNodeRSFilterParams(e,a,i):{context:i.context,params:i.params,navContext:{},navParams:{}};r.size=t.maxSize||1e3,t.sortAppDEFieldId&&Object.assign(r,{sort:"".concat(t.sortAppDEFieldId.toLowerCase(),",").concat(t.sortDir?t.sortDir.toLowerCase():"asc")});const l=await this.app.deService.exec(n,s,o,r);if(l.data.length){return l.data.map((e=>new Co(this.model,t,a,{data:e,leaf:!!i.leaf,navContext:c,navParams:d})))}return[]}async getCodeListGanttNodeDatas(t,e,a,i){const{context:s,params:n,navContext:o,navParams:r}=e?this.getNodeRSFilterParams(e,a,i):{context:i.context,params:i.params,navContext:{},navParams:{}},c=await this.app.codeList.get(t.codeListId,s,n);if(c.length){return c.map((e=>new bo(this.model,t,a,{data:e,leaf:!!i.leaf,navContext:o,navParams:r})))}return[]}})),Yd=(t("GanttController",class extends kd{get _evt(){return this.evt}initState(){super.initState(),this.state.ganttStyle={}}onDataChange(t){}async initService(){this.service=new qd(this.model),await this.service.init(this.context)}setGanttStyle(t){this.state.ganttStyle=t}async onCreated(){await super.onCreated(),this.initViewScheduler()}initViewScheduler(){const t=this.model.appViewLogics||[];0!==t.length&&(this.viewScheduler=ibiz.scheduler.createViewScheduler(t),this.viewScheduler.defaultParamsCb=()=>this.getEventArgs(),this.viewScheduler.hasViewEventTrigger&&this.evt.onAll(((t,e)=>{this.viewScheduler.triggerViewEvent(e)})))}async setActive(t){const e=this.parseTreeNodeData(t);return"DE"===t._nodeType&&await this.onNodeDataActive(e),this._evt.emit("onActive",{...e,nodeData:t})}async onNodeDataActive(t){(await this.openData(t)).cancel||this.refreshNodeChildren(t.data[0],!0)}async openData({data:t,context:e,params:i}){var s,n;const o=t[0],r=this.getNodeModel(o._nodeId),{appDataEntityId:c}=r;e[ve(c).toLowerCase()]=null==(s=o._deData)?void 0:s.srfkey;const d=await(null==(n=this.viewScheduler)?void 0:n.triggerCustom("".concat(r.id.toLowerCase(),"_opendata"),{context:e,params:i,data:t,event:void 0,view:this.view,ctrl:this}));if(-1===d)throw new a(r,"缺少".concat(r.id.toLowerCase(),"_opendata的视图逻辑"));return{cancel:!d||d.ok}}async setRowValue(t,e,a){const{beginDataItemName:i,endDataItemName:s}=this.model;if(!Object.prototype.hasOwnProperty.call(t.data,e)||Jo(t.data[e],a)){t.data[e]=a,e===i?t.data._beginDataItemValue=a:e===s&&(t.data._endDataItemValue=a),t.modified=!0,t.processing=!0;try{await this.dataChangeNotify(t,[e])}finally{t.processing=!1}}}async modifyNodeTime(t,{begin:e,end:a}){if("DE"!==t._nodeType)throw new o("不是实体甘特节点数据");const i=this.getRowState(t._id);if(!i)throw new o("行数据不存在");const{beginDataItemName:s,endDataItemName:n}=this.model;this.setRowValue(i,s,e),this.setRowValue(i,n,a),await this.save(i.data)}async save(t){if(this.state.isSimple)return void ibiz.log.debug("简单模式,不保存");if("DE"!==t._nodeType)throw new o("非实体节点数据不能保存");const e=this.state.rows[t._uuid];if(!e)throw new o("行数据不存在");if(!e.modified)return void ibiz.log.debug("值没有发生改变");if(e.processing)return void await x(500,this.save.bind(this),[t]);const a=this.getNodeModel(t._nodeId),{appDataEntityId:i}=a,s=0===t._deData.srfuf,n=ve(i),r=this.context.clone();r[n]=t._deData.srfkey;const c=ibiz.hub.getApp(this.context.srfappid);let d;try{d=await c.deService.exec(i,s?"create":"update",r,t._deData)}catch(t){throw await this._evt.emit("onSaveError",void 0),this.actionNotification("".concat(s?"CREATE":"UPDATE","ERROR"),{error:t,data:e.data}),t}e.data._deData=d.data,e.modified=!1,this.gridStateNotify(e,"SAVE"),await this._evt.emit("onSaveSuccess",void 0)}async remove(t){const{context:e,params:a,data:i}=this.handlerAbilityParams(t);if(!(null==i?void 0:i.length))throw new o("未选中数据");if(!0!==(null==t?void 0:t.silent)){if(!await ibiz.confirm.error({title:"数据删除",desc:"确认删除数据?"}))return}await this._evt.emit("onBeforeRemove",void 0),await this.startLoading();let s,n=!1;try{const o=ibiz.hub.getApp(this.context.srfappid);await ba(i.map((async t=>{if("DE"===t._nodeType){const i=e.clone(),r=this.getNodeModel(t._nodeId);if(r&&0!==t._deData.srfuf){const{appDataEntityId:e}=r;if(i[ve(e)]=t.srfkey,await o.deService.exec(e,"remove",i,a),!s&&t._parent){const e=this.getNodeData(t._parent._id);s=e}n=!0}this.afterRemove(t)}}))),!0!==(null==t?void 0:t.silent)&&this.actionNotification("REMOVESUCCESS",{data:i,default:"数据[".concat(i.map((t=>t.srfmajortext)).join("、"),"]删除成功!")}),n&&s&&!(null==t?void 0:t.notRefresh)&&await this.refreshNodeChildren(s)}catch(t){throw await this._evt.emit("onRemoveError",void 0),this.actionNotification("REMOVEERROR",{error:t,data:i}),t}finally{await this.endLoading()}this.state.selectedData=[],await this._evt.emit("onRemoveSuccess",void 0)}afterRemove(t){var e;const a=this.state.items.findIndex((e=>e._uuid===t._uuid));if(-1!==a&&this.state.items.splice(a,1),this.state.rows[t._uuid]&&delete this.state.rows[t._uuid],t._parent){const a=this.getNodeData(t._parent._id),i=a._children.findIndex((e=>e._uuid===t._uuid));-1!==i&&(null==(e=a._children)||e.splice(i,1))}}async newRow(t={}){var e;const{data:a}=t,{editShowMode:i}=ibiz.config.grid;if("row"===i){if(Object.values(this.state.rows).find((t=>t.showRowEdit)))throw new o("请先完成当前行编辑中的行的操作")}let s,n;if(a){const t=Array.isArray(a)?a[0]:a;n=this.getNodeData(t._id),s=this.getNodeModel(n._nodeId)}else n=this.state.rootNodes[0],s=Pe(this.model);if(s){let t,a;if(xe(this.model,{parentId:s.id,hasQuery:!1}).forEach((e=>{const i=this.getNodeModel(e.childDETreeNodeId);"DE"===(null==i?void 0:i.treeNodeType)&&i.appDataEntityId&&(t=e,a=i)})),a){let s;try{s=await this.service.getNodeDraft(a,t,n,{hasQuery:!1,context:this.context.clone(),params:this.params})}catch(t){throw this.actionNotification("GETDRAFTERROR",{error:t}),t}const o=this.calcDefaultValue(s,!0);Object.assign(s,o);const r=this.getRowState(n._id);(null==(e=n._children)?void 0:e.length)?n._children.push(s):n._children=[s],this.state.items.push(s);const c=new Vd(s,this);this.state.rows[s._uuid]=c,this.gridStateNotify(c,"DRAFT"),"row"===i&&this.switchRowEdit(c,!0),this._evt.emit("onNewRow",{row:r}),this.actionNotification("GETDRAFTSUCCESS",{data:s})}}}}),t("HubController",class{constructor(){this.session={}}login(t,e){return ibiz.auth.login(t,e)}async logout(){const t=await ibiz.auth.logout();if(t){const t=window.location;if(-1!==t.search.indexOf("isAnonymous=true")){const e="".concat(t.origin).concat(t.pathname).concat(t.hash);window.history.replaceState({},"",e)}}return t}})),Qd=class{constructor(){this.evt=new dt,this.total=0,this.actions=[],this.doingNum=0,this.finishedStates=[30,40],this.service=new bn}async init(){this.listenMessage()}listenMessage(){ibiz.mc.command.asyncAction.on((async t=>{if(!t.data||"ASYNCACTION"!==t.subtype)return;const e=this.formatAsyncAction(t.data);-1===this.actions.findIndex((t=>t.asyncacitonid===e.asyncacitonid))?this.add(e):this.update(e)}))}formatAsyncAction(t){if(["begintime","endtime","createdate","updatedate"].forEach((e=>{Y(t[e])&&(t[e]=yt(t[e]).format("YYYY-MM-DD HH:mm:ss"))})),!O(t.actionresult))try{const e=JSON.parse(t.actionresult);t.actionresult=e}catch(t){}if(!O(t.completionrate)){const e=Number(t.completionrate);Number.isNaN(e)?t.completionrate=void 0:t.completionrate=e}return t}add(t){this.actions.unshift(t),this.finishedStates.includes(t.actionstate)?this.noticeResult(t):(this.doingNum+=1,ibiz.notice.showDoingNotice({num:this.doingNum})),this.evt.emit("add",Z(t)),this.evt.emit("dataChange")}update(t){const e=this.actions.findIndex((e=>e.asyncacitonid===t.asyncacitonid));this.actions.splice(e,1,t),this.finishedStates.includes(t.actionstate)&&(this.doingNum-=1,this.doingNum<=0&&ibiz.notice.closeDoingNotice(),this.noticeResult(t)),this.evt.emit("change",Z(t)),this.evt.emit("dataChange")}noticeResult(t){ibiz.notice.showAsyncAction(t)}};function $d(t){if(""===t)return!1;const e=(new DOMParser).parseFromString(t,"text/html");return Array.from(e.body.childNodes).some((t=>1===t.nodeType))}var Jd=class{constructor(){this.evt=new dt,this.total=0,this.unreadCount=0,this.page=0,this.size=20,this.messages=[],this.unreadOnly=!1,this.service=new ro,this.ns=null,this.provider=null}async init(){this.listenMqtt(),await this.refreshUnreadCount()}async load(){try{await this.fetch(!1)}catch(t){ibiz.log.error(t)}}async loadMore(){await this.fetch(!0)}async refreshUnreadCount(){try{this.unreadCount=await this.service.getUnreadNum(),this.evt.emit("unreadCountChange",this.unreadCount)}catch(t){ibiz.log.error(t)}}toggleUnReadOnly(t){const e=void 0===t?!this.unreadOnly:t;this.unreadOnly!==e&&(this.unreadOnly=e,this.evt.emit("unreadOnlyChange",this.unreadOnly),this.load())}async fetch(t=!1){!1===t?this.page=0:this.page+=1;const e={page:this.page,size:this.size,sort:"update_time,desc"};this.unreadOnly&&(e.searchconds=[{condtype:"GROUP",condop:"AND",bnotmode:!1,searchconds:[{condop:"EQ",condtype:"DEFIELD",fieldname:"status",value:"RECEIVED"}]}]);const a=await this.service.fetch(e);this.total=a.total,t?this.messages.push(...a.data):this.messages=a.data,this.evt.emit("dataChange")}listenMqtt(){ibiz.mc.command.internalMessage.on((async t=>{var e;ibiz.log.debug("mqtt internalMessage: ",t),"INTERNALMESSAGE"===t.subtype&&(t.content&&ibiz.notification.default({isHtmlDesc:$d(t.content),desc:t.content,position:"bottom-right",class:null==(e=this.ns)?void 0:e.b("notice"),onClick:()=>{const e=ibiz.env.isMob?t.mobileurl:t.url;this.provider&&this.provider.openViewByUrl(e)}}),this.refreshUnreadCount())}))}async markRead(t){const e=this.messages.find((e=>e.id===t.id));e&&"RECEIVED"===e.status&&(await this.service.markRead(t.id),e.status="READ",this.unreadCount-=1,this.evt.emit("unreadCountChange",this.unreadCount),this.evt.emit("dataChange"))}async batchMarkRead(){await this.service.batchMarkRead(),await this.fetch(),this.unreadCount=0,this.evt.emit("unreadCountChange",this.unreadCount)}async get(t){return(await this.service.get(t)).data}},Zd=class{constructor(){this.evt=new dt,this.total=0,this.asyncAction=new Qd,this.internalMessage=new Jd}async init(){this.internalMessage.evt.on("unreadCountChange",(()=>{this.total=this.internalMessage.unreadCount,this.evt.emit("totalChange",this.total)})),await this.internalMessage.init(),await this.asyncAction.init()}},tl=class{constructor(){this.convert=new _o,this.controller=new Yd,this.appMap=new Map,this.view2appMap=new Map,this.view2appPriorityMap=new Map,this.views=new Map,this.dataEntities=new Map,this.config=new Vo,this.notice=new Zd,this.defaultAppIndexViewName="Index"}calcAppViewId(t){let e="";if(-1!==t.indexOf(".")){const a=t.split(".");e=a[a.length-1]}else e=t.toLowerCase();return e}registerModelLoaderProvider(t){this.modelLoaderProvider=t}registerAppView(t){this.views.set(t.codeName.toLowerCase(),t)}registerAppDataEntity(t,e=ibiz.env.appId){this.dataEntities.has(e)||this.dataEntities.set(e,new Map);this.dataEntities.get(e).set(t.id,t)}setAppView(t,e=ibiz.env.appId,a=-1){const i=this.calcAppViewId(t);if(this.view2appMap.has(i)){const t=this.view2appPriorityMap.get(i);if(t&&t<a)return}this.view2appMap.set(i,e),-1!==a&&this.view2appPriorityMap.set(i,a)}hasAppView(t){const e=this.calcAppViewId(t);return this.view2appMap.has(e)}async getAppStyle(t){return this.modelLoaderProvider?this.modelLoaderProvider.getAppStyle(t):null}async getAppView(t){const e=this.calcAppViewId(t),a=this.view2appMap.get(e)||ibiz.env.appId;if(this.appMap.has(a)||await this.createApp(a),this.views.has(e))return this.views.get(e);if(this.modelLoaderProvider){const t=await this.modelLoaderProvider.getAppView(a,e);return this.registerAppView(t),t}throw new o("视图[".concat(e,"]不存在"))}async loadAppView(t,e,a){if(this.modelLoaderProvider){return await this.modelLoaderProvider.loadAppView(t,e,a)}throw new o("视图[".concat(e,"]不存在"))}async getAppDataEntity(t,e=ibiz.env.appId){if(this.dataEntities.has(e)){const a=this.dataEntities.get(e);if(a.has(t))return a.get(t)}if(this.modelLoaderProvider){let a;return a=-1!==t.indexOf(".")?await this.modelLoaderProvider.getAppDataEntity(e,t):await this.modelLoaderProvider.getAppDataEntityByCodeName(e,t),this.registerAppDataEntity(a,e),a}throw new o("未找到应用实体[".concat(t,"]"))}async createApp(t){if(this.appMap.has(t))return this.appMap.get(t);if(!this.modelLoaderProvider)throw new o("请先注册模型加载适配器");const e=await this.modelLoaderProvider.getApp(t),a=new Oo(e);return this.appMap.set(t,a),await this.modelLoaderProvider.initApp(t),await a.init(),this.configCache||(this.configCache=new dn(ibiz.env.appId,"PSSysHub","Global")),a}async getAppAsync(t=ibiz.env.appId){return this.createApp(t)}getApp(t){let e=null;return e=t?t instanceof Object?t.id:t:ibiz.env.appId,this.appMap.get(e)}getAllApps(){return this.appMap.size>0?Array.from(this.appMap.values()):[]}async getAppDEService(t,e,a){return(await this.getAppAsync(t)).deService.getService(a,e)}reset(){this.appMap.clear(),this.configCache=void 0}destroy(){ibiz.hub.getAllApps().forEach((t=>{t.destroy()}))}},el=t("EngineFactory",class{constructor(){this.viewEngines=new Map}register(t,e){this.viewEngines.set(t,e)}unRegister(t){this.viewEngines.delete(t)}getEngine(t,...e){const{engineType:a,engineCat:i}=t,s="".concat(i,"_").concat(a),n=this.viewEngines.get(s);if(n)return n(...e);ibiz.log.error("没有".concat(s,"对应的引擎"),t)}}),al=t("ViewEngineBase",class{constructor(t){this.view=t,this.init(),this.initViewState()}get toolbar(){return this.view.getController("toolbar")}get leftToolbar(){return this.view.getController("lefttoolbar")}get rightToolbar(){return this.view.getController("righttoolbar")}get footerToolbar(){return this.view.getController("footertoolbar")}get viewLayoutPanel(){return this.view.layoutPanel}init(){}handleContextParams(){}async onCreated(){const{childNames:t,modal:e}=this.view;e.hooks.shouldDismiss.tapPromise((async t=>{this.view.state.isLoading&&(t.allowClose=!1)})),t.push("captionbar","toolbar"),this.calcDynamicLayout()}calcDynamicLayout(){const t=this.calcRemoveLayoutModel();ibiz.log.debug("".concat(this.view.model.codeName,"删除模型:").concat(t.join(";"))),this.removeLayoutModel(t)}calcRemoveLayoutModel(){const{model:t}=this.view,e=[];!1===t.showCaptionBar&&e.push("view_captionbar");return["lefttoolbar","righttoolbar","footertoolbar"].forEach((a=>{ue(t,a)||e.push(a)})),this.calcViewHeaderVisible()||e.push("view_header"),ibiz.env.isMob?(this.calcViewFooterVisible()||e.push("view_footer"),this.isExistAndInLayout("lefttoolbar")||this.isExistAndInLayout("righttoolbar")||!1!==t.showCaptionBar||e.push("view_toolbar")):ue(t,"toolbar")||e.push("view_toolbar","toolbar"),e}removeLayoutModel(t,e=this.view.model.viewLayoutPanel){if(!e)return;const a=e.rootPanelItems||e.panelItems||[],i=a.findIndex((e=>t.includes(e.id)));-1!==i&&a.splice(i,1),a.forEach((e=>{"CONTAINER"===e.itemType&&this.removeLayoutModel(t,e)}))}async onMounted(){const{model:t,childNames:e}=this.view;ibiz.log.debug("".concat(t.id,"的子组件:").concat(e.join(";"),"都已mounted"))}async onDestroyed(){}async call(t,e){if("GetData"===t)return this.getData()}initViewState(){}getData(){return[]}calcViewHeaderVisible(){let t=!1;const{model:e}=this.view;return e.showCaptionBar&&(t=!0),ibiz.env.isMob?(this.isExistAndInLayout("lefttoolbar")&&(t=!0),this.isExistAndInLayout("righttoolbar")&&(t=!0)):this.isExistAndInLayout("toolbar")&&(t=!0),t}isExistAndInLayout(t){const e=this.view.model.viewLayoutPanel;if(!e)return!1;const a=I(e,t,{compareField:"id",childrenFields:["panelItems","rootPanelItems"]}),{model:i}=this.view,s=ue(i,t);let n=!(!a||!s);if("TOOLBAR"===(null==s?void 0:s.controlType)){const t=s.detoolbarItems;n=!!(n&&t&&t.length>0)}return n}calcViewFooterVisible(){let t=!1;return this.isExistAndInLayout("footertoolbar")&&(t=!0),t}async loadEntityData(){const{appDataEntityId:t}=this.view.model,{evt:e,context:a,params:i}=this.view;if(!t)throw new o("该视图没有实体,无法加载实体数据");const s=ibiz.hub.getApp(a.srfappid),n=await s.deService.exec(t,"get",a,i),{data:r}=n;r&&(this.view.state.srfactiveviewdata=r,e.emit("onDataChange",{actionType:"LOAD",data:[r]}),r.srfkey&&e.emit("onViewInfoChange",{dataInfo:r.srfmajortext||""}))}}),il=(t("MDViewEngine",class extends al{get xdataControlName(){return this.view.model.xdataControlName}get searchForm(){return this.view.getController("searchform")}get searchBar(){return this.view.getController("searchbar")}get tabToolbar(){return this.view.getController("tabtoolbar")}get tabSearchForm(){return this.view.getController("tabsearchform")}get tabSearchBar(){return this.view.getController("tabsearchbar")}get xdataControl(){return this.view.getController(this.xdataControlName)}async onCreated(){await super.onCreated();const{childNames:t}=this.view;t.push(this.xdataControlName,"searchform","searchbar","tabtoolbar","tabsearchform","tabsearchbar"),this.xdataControlName&&(this.view.slotProps[this.xdataControlName]||(this.view.slotProps[this.xdataControlName]={}),this.view.slotProps[this.xdataControlName].loadDefault=!1)}async onMounted(){await super.onMounted();const{model:t}=this.view;this.xdataControl.evt.on("onActive",this.onXDataActive.bind(this)),this.xdataControl.evt.on("onSelectionChange",(async t=>{var e,a;null==(e=this.toolbar)||e.calcButtonState(t.data[0],this.xdataControl.model.appDataEntityId),null==(a=this.tabToolbar)||a.calcButtonState(t.data[0],this.xdataControl.model.appDataEntityId)})),this.xdataControl.evt.on("onBeforeLoad",(()=>{this.xdataControl.state.searchParams=this.getSearchParams()})),this.xdataControl.evt.on("onLoadSuccess",(t=>{this.view.evt.emit("onDataChange",{...t,actionType:"LOAD"})})),this.xdataControl.evt.on("onRemoveSuccess",(t=>{this.view.evt.emit("onDataChange",{...t,actionType:"REMOVE"})})),this.xdataControl.evt.on("onSaveSuccess",(t=>{this.view.evt.emit("onDataChange",{...t,actionType:"SAVE"})}));const e=this.viewLayoutPanel.panelItems.view_searchform;if(e){const a=!!this.searchForm;e.state.keepAlive=a,e.state.visible=a&&!!t.expandSearchForm}if(this.searchForm&&this.searchForm.evt.on("onSearch",(()=>{this.reLoad()})),this.searchBar&&this.searchBar.evt.on("onSearch",(()=>{this.reLoad()})),this.tabSearchForm&&this.tabSearchForm.evt.on("onSearch",(()=>{this.reLoad()})),this.tabSearchBar&&this.tabSearchBar.evt.on("onSearch",(()=>{this.reLoad()})),!this.view.state.noLoadDefault&&t.loadDefault){const t=this.searchBar||this.tabSearchBar;t&&t.hasDefaultSelect&&("grid"===this.xdataControlName||"treegrid"===this.xdataControlName)?t.setDefaultSelect():this.load()}}handleContextParams(){super.handleContextParams(),this.view.context.srfsimple||(this.view.context.srfsimple=!0)}async onXDataActive(t){await this.openData(t)}async call(t,e){if("ToggleFilter"===t)return this.toggleFilter(),null;if("Edit"===t||"View"===t)return this.openData(e);if("New"===t)return this.newData(e);if("Remove"===t)return await this.remove(e),null;if("Import"===t)return await this.importData(),null;if("Refresh"===t)return await this.refresh(),null;if("ExportExcel"===t)return await this.exportData(e),null;if("Search"===t){const t=this.searchForm||this.tabSearchForm;return await t.search(),null}if("Reset"===t){const t=this.searchForm||this.tabSearchForm;return await t.reset(),null}return"Copy"===t?(this.copy(e),null):"Load"===t?(this.load(e),null):"GetAllData"===t?this.xdataControl.state.items:super.call(t,e)}getData(){return this.xdataControl.getData()}async openData(t){var e,i;const{data:s,event:n}=t,o=(t.context||this.view.context).clone();o.srfpaginationviewid=this.view.id;const r=t.params||this.view.params;o[((null==(e=s[0].srfdecodename)?void 0:e.toLowerCase())||ve(this.xdataControl.model.appDataEntityId)).toLowerCase()]=s[0].srfkey;const c=await(null==(i=this.view.scheduler)?void 0:i.triggerCustom("opendata",{context:o,params:r,data:s,event:n,view:this.view}));if(-1===c)throw new a(this.view.model,"缺少opendata的视图逻辑");return{cancel:!c.ok}}async newData(t){var e,i,s;const{data:n,event:o,copyMode:r}=t;if(!(null==(i=null==(e=this.view.model.viewLayoutPanel)?void 0:e.appViewLogics)?void 0:i.find((t=>"newdata"===t.id))))throw new a(this.view.model,"缺少newdata的视图逻辑");const c=Z(this.view.params);r&&(c.srfcopymode=r);const d=await(null==(s=this.view.scheduler)?void 0:s.triggerCustom("newdata",{context:this.view.context,params:c,data:n,event:o,view:this.view}));if(-1===d)throw new a(this.view.model,"缺少newdata的视图逻辑");return{cancel:!d.ok}}async remove(t){await this.xdataControl.remove(t)}async load(t={}){await this.xdataControl.load({isInitialLoad:!0,...t})}async refresh(){await this.xdataControl.refresh()}async reLoad(){await this.xdataControl.load({isInitialLoad:!0})}getSearchParams(){const t={};return this.searchForm&&Object.assign(t,this.searchForm.getFilterParams()),this.searchBar&&Object.assign(t,this.searchBar.getFilterParams()),this.tabSearchForm&&Object.assign(t,this.tabSearchForm.getFilterParams()),this.tabSearchBar&&Object.assign(t,this.tabSearchBar.getFilterParams()),t}async importData(){await this.xdataControl.importData()}async exportData(t){await this.xdataControl.exportData(t)}async copy(t){this.newData(Object.assign(t,{copyMode:!0}))}calcViewHeaderVisible(){const t=super.calcViewHeaderVisible();return this.calcViewSearchBarVisible()||t}calcViewSearchBarVisible(){const{model:t}=this.view,e=this.isExistAndInLayout("searchbar");if(!e)return e;const a=ue(t,"searchbar");return!(!a.enableQuickSearch&&!a.enableGroup&&!0!==a.enableFilter)}toggleFilter(){if(this.searchForm){const t=this.viewLayoutPanel.panelItems.view_searchform;t&&(t.state.visible=!t.state.visible)}}calcRemoveLayoutModel(){const{model:t}=this.view,e=super.calcRemoveLayoutModel();return ue(t,"searchform")||e.push("searchform"),this.calcViewSearchBarVisible()||e.push("view_searchbar"),e}}),document.title),sl=class{constructor(){this.layoutPanel=new ea,this.theme=new Ea,this.text=new wa,this.hbs=new se,this.rawValue=new Da,this.action=fc,this.error=new Ft,this.viewStack=new Ca,this.anime=new Vi,this.file=new ki,this.error.register(new _t)}showAppLoading(){const t=document.getElementById("app-loading-x");t&&(t.style.display="none")}hiddenAppLoading(){setTimeout((()=>{const t=document.getElementById("app-loading-x");t&&(t.style.display="none")}),300)}setBrowserTitle(t){const e=ibiz.hub.getApp();let a="";a=ibiz.env.AppTitle?ibiz.env.AppTitle:e.model.title?e.model.title:il,document.title=t?"".concat(a," - ").concat(t):a}getGlobalParam(){throw new o("获取应用全局变量没有实现")}getRouterParams(){throw new o("获取视图路由参数变量没有实现")}},nl=class{constructor(t,e){this.logic=t,this.scheduler=e,this.type=t.logicType}execute(t){throw new o("Method not implemented.")}destroy(){}},ol=class{constructor(){this.constructorMap=new Map}register(t,e){this.constructorMap.set(t,e)}createExecutor(t,e){const a=this.constructorMap.get(t.logicType);if(!a)throw new i(t,"逻辑类型 ".concat(t.logicType," 暂未支持!"));return a(t,e)}},rl=class extends nl{constructor(){super(...arguments),this.initialized=!1}convertScriptArgs(t){return t}init(t,e,a){this.convertScriptArgs=e;const i=this.logic.scriptCode;this.scriptFn=Qe.createScriptFn(t,i,a),this.initialized=!0}execute(t){const e=this.convertScriptArgs(t);return this.scriptFn.exec(e)}},cl=class extends nl{execute(t){const{appDEUILogicId:e,appDataEntityId:i}=this.logic;if(!e)throw new a(this.logic,"没有配置实体界面逻辑");return mc(e,i,t)}},dl=class{constructor(t){this.triggers=new Map,this.executors=new Map,this.hasViewEventTrigger=!1,this.hasControlEventTrigger=!1,this.logics=t,t.forEach((t=>{try{const e=this.createExecutor(t);this.executors.set(t.id,e);const a=this.createTrigger(t);this.triggers.set(t.id,a),a.bindExecutor(e)}catch(t){ibiz.log.error(t.message)}}))}destroy(){this.triggers.forEach((t=>t.destroy())),this.executors.forEach((t=>t.destroy()))}getExecuteParams(t){let e={};return this.defaultParamsCb&&(e=this.defaultParamsCb()),at(t,e)}createTrigger(t){switch(t.triggerType){case"VIEWEVENT":this.hasViewEventTrigger=!0;break;case"CTRLEVENT":this.hasControlEventTrigger=!0}return ibiz.scheduler.triggerFactory.createTrigger(t,this)}createExecutor(t){return ibiz.scheduler.executorFactory.createExecutor(t,this)}getMatchTriggers(t){const e=[];return this.triggers.forEach((a=>{a.match(t)&&e.push(a)})),e}triggerAndExecute(t,e={}){const a=this.getMatchTriggers(t);if(a.length>0){const t=this.getExecuteParams(e);return a.map((e=>e.execute(t)))}}triggerItemDynaLogic(t,e,a){const i={itemName:t,triggerType:e},s=this.triggerAndExecute(i,a);if(null==s?void 0:s.length)return s.pop()}triggerItemVisible(t,e){return this.triggerItemDynaLogic(t,"ITEMVISIBLE",e)}triggerItemEnable(t,e){return this.triggerItemDynaLogic(t,"ITEMENABLE",e)}triggerItemBlank(t,e){return this.triggerItemDynaLogic(t,"ITEMBLANK",e)}startTimerTrigger(){this.getMatchTriggers({triggerType:"TIMER"}).forEach((t=>t.start()))}triggerCustom(t,e){const a=this.triggers.get(t);if(!a)return-1;const i=this.getExecuteParams(e);return a.execute(i)}triggerControlEvent(t,e,a){const i={ctrlName:t,eventName:e,triggerType:"CTRLEVENT"};this.triggerAndExecute(i,a)}},ll=class extends dl{constructor(t){const e=t.filter((t=>"APPVIEWENGINE"!==t.triggerType));e.forEach((t=>{"CTRLEVENT"===t.triggerType&&(t.ctrlName=t.itemName||t.logicTag)})),super(e)}},hl=class extends dl{constructor(t){t.forEach((t=>{t.triggerType=t.logicTrigger})),super(t)}triggerViewEvent(t){const e={eventName:t.eventName,triggerType:"VIEWEVENT"};this.triggerAndExecute(e,t)}},ul=class{constructor(){this.constructorMap=new Map}register(t,e){this.constructorMap.set(t,e)}createTrigger(t,e){const a=this.constructorMap.get(t.triggerType);if(!a)throw new i(t,"触发器类型 ".concat(t.triggerType," 暂未支持!"));return a(t,e)}},pl=class{constructor(){this.executorFactory=new ol,this.triggerFactory=new ul}createViewScheduler(t){return new hl(t)}createControlScheduler(t){return new ll(t)}},ml=class{constructor(t,e){this.logic=t,this.scheduler=e,this.type=t.triggerType}bindExecutor(t){this.executor=t,"SCRIPT"===this.executor.type&&this.bindScriptExecutor(t)}bindScriptExecutor(t){t.initialized||t.init([],(t=>t),{isAsync:!0,singleRowReturn:!1})}match(t){return t.triggerType===this.type}execute(t){if(this.executor)return this.executor.execute(t);throw new o("".concat(this.logic.id,"没有绑定executor"))}destroy(){this.executor=void 0}},fl=class extends ml{},gl=class extends ml{bindExecutor(t){if(super.bindExecutor(t),"SCRIPT"!==this.executor.type)throw new o("预定义逻辑类型".concat(this.type,"的触发器类型只能是脚本"))}bindScriptExecutor(t){t.init(["context","viewparams","data","env","view"],(t=>{const{context:e,params:a,data:i,view:s}=t;return{context:e,params:a,data:(null==i?void 0:i[0])||{},env:ibiz.env,view:s}}),{singleRowReturn:!0,isAsync:!1})}match(t){var e,a;return super.match(t)&&(null==(e=t.itemName)?void 0:e.toLowerCase())===(null==(a=this.logic.itemName)?void 0:a.toLowerCase())}execute(t){return!!this.executor.execute(t)}},wl=class extends ml{constructor(){super(...arguments),this.timer=null}start(){if(!this.logic.timer)throw new a(this.logic,"定时器缺少定时间隔");this.timer=setInterval((()=>{if(!this.scheduler.defaultParamsCb)throw new o("定时器缺少默认参数回调");const t=this.scheduler.defaultParamsCb();this.executor.execute(t)}),this.logic.timer)}destroy(){super.destroy(),this.timer&&clearInterval(this.timer)}},El=class extends nl{async execute(t){let e;try{this.logic.builtinAppUILogic&&"APP_OPENDATA"===this.logic.builtinAppUILogic.viewLogicType?e=await this.executeOpenDataAppUILogic(this.logic.builtinAppUILogic,t):this.logic.builtinAppUILogic&&"APP_NEWDATA"===this.logic.builtinAppUILogic.viewLogicType&&(e=await this.executeNewDataAppUILogic(this.logic.builtinAppUILogic,t))}catch(t){ibiz.log.error(t)}return e}async executeOpenDataAppUILogic(t,e){const{context:i,params:s,...n}=e,{data:r}=e;if(!(null==r?void 0:r[0]))throw new o("opendata没有可操作数据!");let c;if(t.openDataAppViews)c=await this.calcOpenViewRef(t,e);else if(c=t.openDataAppView,!c)throw new a(t,"opendata视图逻辑没有配置默认打开视图");const d=c.refAppViewId;if(!d)throw new a(t,"opendata视图逻辑的默认打开视图没有实际引用视图");const l=c.navigateContexts||[],h=Object.assign(i,oe(l,r[0],s,i));let u={};const p=c.navigateParams;return nt(p)&&(u=oe(p,r[0],s,i)),ibiz.commands.execute(So.TAG,d,h,u,{...n,openMode:c.openMode})}async calcOpenViewRef(t,e){const i=await ibiz.hub.getAppDataEntity(e.view.model.appDataEntityId,e.view.model.appId),s=i.formTypeAppDEFieldId||i.dataTypeAppDEFieldId;if(!s)throw new a(t,"".concat(i.codeName,"[多表单实体] or [索引实体]缺少类型属性配置"));const{data:n}=e,r=n[0][s];if(!r)throw new a(t,"数据源无表单类型应用实体属性值");const c=t.openDataAppViews,d=null==c?void 0:c.find((t=>t.refMode===r));if(!d)throw new o("没有找到与表单类型".concat(r,"相关的实体的编辑视图"));return d}async executeNewDataAppUILogic(t,e){const{context:s,params:n,...o}=e,{data:r,view:c}=e,{enableWizardAdd:d,enableBatchAdd:l,batchAddOnly:h,newDataAppView:u}=t;let p;if(d){if(p=await this.getWizardNewViewRef(t,e),!p)return{ok:!1}}else if(l){const e=ve(c.parentView.model.appDataEntityId),i=t.batchAddAppViews;if(p=null==i?void 0:i.find((t=>t.refMode.toLowerCase()!==e)),!p)throw new a(t,"没有找到批添加需要打开的选择视图")}else{if(h)throw new i(t,"batchAddOnly暂未支持");if(p=u,!p||!p.refAppViewId)throw new a(t,"newdata视图逻辑没有配置默认新建数据视图")}let m={},f={};const g=(null==r?void 0:r[0])||{},w=p.navigateContexts;nt(w)&&(m=oe(w,g,n,s)),m=Object.assign(s,m);const E=p.navigateParams;if(nt(E)&&(f=oe(E,g,n,s)),n.srfcopymode){const t=(await ibiz.hub.getAppDataEntity(c.model.appDataEntityId,c.model.appId)).keyAppDEFieldId;t&&g&&(f[t]=g.srfkey,f.srfcopymode=!0)}f.srfuf=0;const y=await ibiz.commands.execute(So.TAG,p.refAppViewId,m,f,{...o,openMode:p.openMode});return l&&y.data&&await this.doBatchAdd(t,y.data,s,p,e.view),y}async getWizardNewViewRef(t,e){var i;const{wizardAppView:s,newDataAppViews:n}=t,{context:r,params:c,...d}=e;if(!s||!s.refAppViewId)throw new a(t,"缺少默认索引实体选择视图");const l=await ibiz.commands.execute(So.TAG,s.refAppViewId,r,c,{...d,openMode:"POPUPMODAL"});if(!l.ok)return;const h=null==(i=l.data)?void 0:i[0];if(!h)throw new o("请选中一条数据");const u=h.srfkey,p=null==n?void 0:n.find((t=>{var e;return(null==(e=t.refMode)?void 0:e.toUpperCase())===u.toUpperCase()}));if(!p)throw new o("没有找到与索引类型".concat(u,"相关的实体的编辑视图"));return p}async doBatchAdd(t,e,i,s,n){var r;if(null==e?void 0:e.length){const c=await ibiz.hub.getAppDataEntity(t.appDataEntityId,i.srfappid),d=c.minorAppDERSs,l=s.refMode.toLowerCase();if(!d)throw new a(c,"实体没有从关系集合!");let h="";if(null==d||d.forEach((t=>{const e=ve(t.majorAppDataEntityId);l===e&&(h=t.parentAppDEFieldId)})),void 0===h)throw new o("没有找到".concat(l,"在当前实体的外键属性"));const u={srfkey:h},p=null==(r=n.model.appViewParams)?void 0:r.find((t=>t.key.toLowerCase()==="PROPERTYMAP".toLowerCase()));if(p){const t=p.value.split(",");for(const e of t){const[t,a]=e.split(":");t&&a&&(u[t]=a)}}ibiz.log.debug("批量新建转换映射属性",u);const m=e.map((t=>{const e={};return Object.keys(u).forEach((a=>{const i=u[a];e[i]=t[a]})),e}));ibiz.log.debug("批量新建创建数据",m);const f=ibiz.hub.getApp(i.srfappid).deService;await f.exec(c.id,"Create",i,m)}}},yl=class extends ml{constructor(t,e){super(t,e),this.logic=t,this.scheduler=e,this.listenEventNames=[];const a=t.eventNames.split(";");this.listenEventNames=a.map((t=>oa[t]||t))}match(t){return super.match(t)&&this.listenEventNames.includes(t.eventName)}},vl=class extends ml{constructor(t,e){super(t,e),this.logic=t,this.scheduler=e,this.listenEventNames=[];const a=t.eventNames.split(";");this.listenEventNames=a.map((t=>ca[t]||t))}match(t){return super.match(t)&&t.ctrlName.toLowerCase()===this.logic.ctrlName.toLowerCase()&&this.listenEventNames.includes(t.eventName)}},Il=class extends nl{execute(t){if(!this.logic.appDEUIActionId)throw new a(this.logic,"逻辑中缺少触发应用实体界面行为id");fc.execAndResolved(this.logic.appDEUIActionId,t,this.logic.appId)}};t("PluginStaticResource",class{constructor(t){this.urlReg=/^http[s]?:\/\/[^\s]*/,this.styleElementMap=new Map,this.url=new URL(t),this.baseDir=It.dirname(this.url.pathname)}dir(t){return this.urlReg.test(t)?t:this.url.origin+It.resolve(this.baseDir,t)}async loadStyle(t){const e=t.map((t=>{const e=this.urlReg.test(t)?t:this.dir(t);return!this.styleElementMap.has(e)&&(this.styleElementMap.set(e,null),new Promise(((t,a)=>{const i=document.createElement("link");i.setAttribute("type","text/css"),i.setAttribute("rel","stylesheet"),i.setAttribute("href",e),i.onload=t,i.onerror=a,document.head.appendChild(i)})))}));try{await Promise.all(e)}catch(t){ibiz.log.error(t)}}}),t("RemotePluginItem",class{constructor(t,e,a){this.tag=t,this.repo=e,this.config=a}})}}}));