devfab 2.0.0 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +98 -31
- package/dist/common/models.esm.js +2 -2
- package/dist/common/models.js +2 -2
- package/dist/common/require.esm.js +2 -2
- package/dist/common/require.js +2 -2
- package/dist/common/utils.esm.js +2 -2
- package/dist/common/utils.js +2 -2
- package/dist/index.esm.js +2 -2
- package/dist/index.js +2 -2
- package/dist/index.umd.js +2 -2
- package/lib/devfab.js +130 -125
- package/lib/devfab.min.js +2 -2
- package/lib/devfab.require.js +74 -122
- package/lib/devfab.require.min.js +2 -2
- package/package.json +1 -1
package/dist/common/utils.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
"use strict";function e(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function t(e,t,n,r,
|
|
1
|
+
"use strict";function e(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function t(e,t,n,r,a,o,i){try{var s=e[o](i),u=s.value}catch(e){return void n(e)}s.done?t(u):Promise.resolve(u).then(r,a)}function n(e){return function(){var n=this,r=arguments;return new Promise(function(a,o){var i=e.apply(n,r);function s(e){t(i,a,o,s,u,"next",e)}function u(e){t(i,a,o,s,u,"throw",e)}s(void 0)})}}function r(e,t,n){return t=u(t),function(e,t){if(t&&("object"==typeof t||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(e,l()?Reflect.construct(t,n||[],u(e).constructor):t.apply(e,n))}function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,_(r.key),r)}}function i(e,t,n){return t&&o(e.prototype,t),n&&o(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function s(e,t,n){return(t=_(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function u(e){return u=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},u(e)}function c(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&y(e,t)}function l(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(l=function(){return!!e})()}function f(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function d(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?f(Object(n),!0).forEach(function(t){s(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):f(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function v(){
|
|
2
2
|
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */
|
|
3
|
-
var e,t,n="function"==typeof Symbol?Symbol:{},r=n.iterator||"@@iterator",i=n.toStringTag||"@@toStringTag";function o(n,r,i,o){var u=r&&r.prototype instanceof s?r:s,c=Object.create(u.prototype);return v(c,"_invoke",function(n,r,i){var o,s,u,c=0,l=i||[],f=!1,d={p:0,n:0,v:e,a:h,f:h.bind(e,4),d:function(t,n){return o=t,s=0,u=e,d.n=n,a}};function h(n,r){for(s=n,u=r,t=0;!f&&c&&!i&&t<l.length;t++){var i,o=l[t],h=d.p,v=o[2];n>3?(i=v===r)&&(u=o[(s=o[4])?5:(s=3,3)],o[4]=o[5]=e):o[0]<=h&&((i=n<2&&h<o[1])?(s=0,d.v=r,d.n=o[1]):h<v&&(i=n<3||o[0]>r||r>v)&&(o[4]=n,o[5]=r,d.n=v,s=0))}if(i||n>1)return a;throw f=!0,r}return function(i,l,v){if(c>1)throw TypeError("Generator is already running");for(f&&1===l&&h(l,v),s=l,u=v;(t=s<2?e:u)||!f;){o||(s?s<3?(s>1&&(d.n=-1),h(s,u)):d.n=u:d.v=u);try{if(c=2,o){if(s||(i="next"),t=o[i]){if(!(t=t.call(o,u)))throw TypeError("iterator result is not an object");if(!t.done)return t;u=t.value,s<2&&(s=0)}else 1===s&&(t=o.return)&&t.call(o),s<2&&(u=TypeError("The iterator does not provide a '"+i+"' method"),s=1);o=e}else if((t=(f=d.n<0)?u:n.call(r,d))!==a)break}catch(t){o=e,s=1,u=t}finally{c=1}}return{value:t,done:f}}}(n,i,o),!0),c}var a={};function s(){}function u(){}function c(){}t=Object.getPrototypeOf;var l=[][r]?t(t([][r]())):(v(t={},r,function(){return this}),t),f=c.prototype=s.prototype=Object.create(l);function d(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,c):(e.__proto__=c,v(e,i,"GeneratorFunction")),e.prototype=Object.create(f),e}return u.prototype=c,v(f,"constructor",c),v(c,"constructor",u),u.displayName="GeneratorFunction",v(c,i,"GeneratorFunction"),v(f),v(f,i,"Generator"),v(f,r,function(){return this}),v(f,"toString",function(){return"[object Generator]"}),(h=function(){return{w:o,m:d}})()}function v(e,t,n,r){var i=Object.defineProperty;try{i({},"",{})}catch(e){i=0}v=function(e,t,n,r){function o(t,n){v(e,t,function(e){return this._invoke(t,n,e)})}t?i?i(e,t,{value:n,enumerable:!r,configurable:!r,writable:!r}):e[t]=n:(o("next",0),o("throw",1),o("return",2))},v(e,t,n,r)}function p(e,t){return p=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},p(e,t)}function y(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,i,o,a,s=[],u=!0,c=!1;try{if(o=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;u=!1}else for(;!(u=(r=o.call(n)).done)&&(s.push(r.value),s.length!==t);u=!0);}catch(e){c=!0,i=e}finally{try{if(!u&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(c)throw i}}return s}}(e,t)||b(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function g(t){return function(t){if(Array.isArray(t))return e(t)}(t)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(t)||b(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function _(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}function m(e){return m="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},m(e)}function b(t,n){if(t){if("string"==typeof t)return e(t,n);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?e(t,n):void 0}}function k(e){return e||window.devfab&&window.devfab.debug}function w(e){this.pathname="",this.query={};var t=e;this.init=function(){t||(t=location.search);var e=t.indexOf("?"),n=t.indexOf("#");if(e>=0){if(this.pathname=t.substr(0,e),(t=n<0?t.substr(e+1):t.substring(e+1,n)).length>0)for(var r=(t=t.replace(/\+/g," ")).split("&"),i=0,o=r.length;i<o;i++){var a=r[i]||"";if(a){var s=a.indexOf("="),u="",c="";s<0?c=u=window.decode(a):(u=window.decode(a.substr(0,s)),c=window.decode(a.substr(s+1))),this.query[u]=c}}}else this.pathname=t},this.set=function(e,t){this.query[e]=t},this.get=function(e){return this.query[e]},this.del=function(e){delete this.query[e]},this.has=function(e){return null!=this.query[e]},this.toStr=function(){var e=["?"];for(var t in this.query)e.push(encodeURIComponent(t)),e.push("="),e.push(encodeURIComponent(this.query[t])),e.push("&");return 1===e.length?"":(e.splice(e.length-1,1),e.join(""))},this.init()}function x(e,t){if(!t)return e;var n=[],r=new w(e);for(var i in t)r.get(i)||n.push("".concat(i,"=").concat(t[i]));if(!n.length)return e;var o=n.join("&");return e.indexOf("?")>=0?"".concat(e,"&").concat(o):"".concat(e,"?").concat(o)}Object.defineProperty(exports,"__esModule",{value:!0}),String.prototype.equalsIgnoreCase=function(e){return null!=e&&this.toLowerCase()===e.toLowerCase()};var P=function(e){return null!=e&&""!==e};var S=["children","render"],j=function(){return a(function e(){i(this,e),s(this,"_config",{componentField:["component"]}),s(this,"_components",{}),s(this,"_renderFactory",null)},[{key:"init",value:function(e,t,n){this._initConfig(e),this._initComponent(t),this._initRenderFactory(n)}},{key:"_initConfig",value:function(e){this._config=Object.assign(this._config,e)}},{key:"_initComponent",value:function(e,t){if(e)if("string"==typeof e){if(this._components[e])return void console.log("[warning] Component ".concat(e," is exist!"));this._components[e]=t}else"function"==typeof e?Object.assign(this._components,null==e?void 0:e()):"object"===m(e)&&Object.assign(this._components,e)}},{key:"_getComponent",value:function(e){return this._components[e]}},{key:"_clearComponents",value:function(){this._components={}}},{key:"_initRenderFactory",value:function(e){this._renderFactory=e}},{key:"_renderComponent",value:function(e,t){var n=this;if(Array.isArray(e)){var r=[];return e.forEach(function(e,i){var o=d({},e),a=function(e,t,n){if(e){var r=n;"string"==typeof t&&Array.isArray(r)&&(r=s({},t,n));var i=r&&r[t];if(!i)return P(e[t])?e[t]:void 0;for(var o=0;o<i.length;o++){var a=e[i[o]];if(P(a))return a}}}(o,"component",n._config.componentField),u=o.children,c=o.render,l=function(e,t){if(null==e)return{};var n,r,i=function(e,t){if(null==e)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(-1!==t.indexOf(r))continue;n[r]=e[r]}return n}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(r=0;r<o.length;r++)n=o[r],-1===t.indexOf(n)&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}(o,S),f=n._getComponent(a);f||"function"==typeof c||console.log("[warning] Component ".concat(a," is not registered!"));var h={component:f,children:n._renderComponent(u,t)};l.index=i;var v=Object.assign({},null==t?void 0:t.props,{meta:l});"function"==typeof c?r.push(c({node:h,props:v})):"function"==typeof n._renderFactory?r.push(n._renderFactory({node:h,props:v})):(Object.assign(h,v),r.push(h))}),r}}},{key:"clear",value:function(){this._clearComponents(),this._renderFactory=null}}])}(),C=function(){function e(){return i(this,e),r(this,e,arguments)}return c(e,j),a(e,[{key:"initComponent",value:function(e,t){this._initComponent(e,t)}},{key:"getComponents",value:function(){return d({},this._components)}},{key:"getComponent",value:function(e){return this._getComponent(e)}},{key:"hasComponent",value:function(e){return!!this._getComponent(e)}},{key:"initRenderFactory",value:function(e){this._initRenderFactory(e)}},{key:"render",value:function(e,t){return this._renderComponent(e,t)}}])}();C.create=function(e){return new C(e)};var O={_xhrs:[],_jsonps:{index:0},doRequest:function(e){var t,n=e.method||"GET",r=e.url;try{null!=e&&e.requestHeaders&&(t=e.requestHeaders,e.requestHeaders=void 0,delete e.requestHeaders)}catch(e){k()&&console.log('[devfab][ajax]: [doRequest]: options["requestHeaders"] ERR : ',e)}try{e.params&&e.params.requestHeaders&&(t=e.params.requestHeaders,e.params.requestHeaders=void 0,delete e.params.requestHeaders)}catch(e){k()&&console.log('[devfab][ajax]: [doRequest]: options.params["requestHeaders"] ERR : ',e)}var i=null;if(n.equalsIgnoreCase("get")||n.equalsIgnoreCase("delete")?r=x(r,e.params):(n.equalsIgnoreCase("post")||n.equalsIgnoreCase("put"))&&(i=JSON.stringify(e.params)),e.jsonp)return this.getJsonp(r,e.callback);var o=this.getXMLHttpRequest();if(o){var a;if(o.open(n,r,!1!==e.async),e.timeout&&(o.timeout=e.timeout,o.setRequestHeader("timeout",e.timeout),o.ontimeout=function(){O.onerror(this,e,"timeout")}),e.contentType){if(o.setRequestHeader("Content-Type",e.contentType),e.contentType.indexOf("x-www-form-urlencoded")>=0)i=null===(a=new URLSearchParams(e.params))||void 0===a?void 0:a.toString()}else e.dateType?i=e.params:o.setRequestHeader("Content-Type","application/json;charset=utf-8");try{if(t&&"[object Object]"===Object.prototype.toString.call(t))for(var s in t)o.setRequestHeader(s,t[s])}catch(e){k()&&console.log('[devfab][ajax]: [doRequest]: options.params["requestHeaders"] ERR : ',e)}o.withCredentials=null==e||!e.hasOwnProperty("withCredentials")||e.withCredentials,e.onBeforeRequest&&e.onBeforeRequest(o,i);try{o.send(i)}catch(t){return{error:"NetWorkError",options:e}}if(!1===e.async)return this.onreadystatechange(o,e);o.onreadystatechange=function(){O.onreadystatechange(this,e)}}},onreadystatechange:function(e,t){if(4===e.readyState){if(200===e.status){var n;try{if("blob"===t.responseType){var r=function(e){var t=e.xhr.getAllResponseHeaders(),n={};return t.split("\r\n").map(function(e){var t=y(e.split(": "),2),r=t[0],i=t[1];n[r]=i}),n}({xhr:e});n={code:e.status,data:{data:e.response,headers:r}}}else n=JSON.parse(e.responseText)}catch(n){O.onerror(e,t,e.responseText)}if(!1===t.async)return e.isBusy=!1,t.onAfterRequest&&t.onAfterRequest(n),O.parseAjaxResult(n,!1,null,null,t,e);O.parseAjaxResult(n,t.async,t.callback,t.context,t,e),t.onAfterRequest&&t.onAfterRequest(n)}else if(0===e.status)O.onerror(e,t,"The network connection has been disconnected. Please check the network status of the device and try.");else if(502===e.status||504===e.status)O.onerror(e,t,"An error has occurred with the service. Please try again later.");else{if(401!==e.status){var i={};try{i=JSON.parse(e.responseText)}catch(t){i={code:e.status,message:e.responseText}}return O.onerror(e,t,i)}O.onerror(e,t,"Login information has expired. Please log in again or contact technical staff.")}e.isBusy=!1}},onerror:function(e,t,n){var r="[devfab][ajax]: [onerror]: api error \n [code]: ".concat(e.status," \n [error]: ").concat(("object"===m(n)?JSON.stringify(n):n)||"空"," \n [url]: ").concat(t.url," \n [token]: ").concat(document.cookie);k()&&console.log(r);var i="object"===m(n)?n:{code:500,message:n};t.onAfterRequest&&t.onAfterRequest(i)},getXMLHttpRequest:function(){return this.createXMLHttpRequest()},createXMLHttpRequest:function(){return window.XMLHttpRequest?new XMLHttpRequest:window.ActiveXObject?new window.ActiveXObject("Microsoft.XMLHTTP"):null},getJsonp:function(e,t){var n=e,r="callback"+this._jsonps.index++,i=document.createElement("script");this._jsonps[r]=function(e){try{t(e)}finally{document.body.removeChild(i)}},n+=-1===n.indexOf("?")?"?":"&callback=cb.rest.AjaxUtil._jsonps."+r,i.src=n,document.body.appendChild(i)},parseAjaxResult:function(e,t,n,r,i,o){if(e){if(!e.code)return!1===t?e:void(n&&n.call(r,null,e));if(200==e.code){if(!1===t)return{result:e.data};n&&n.call(r,null,e.data,e.message,e.errorDetail,e.code,e.displayCode&&e)}else{if(!1===t)return{error:e};n&&n.call(r,e)}}}};function A(e,t){this.init&&this.init(e),this.queryParams=t}A.create=function(e,t){return new A(e,t)},A.prototype.init=function(e){if(e)for(var t in this.config=e,this.config)this[t]=function(e){return function(t,n,r){return this.Do(e,t,n,null,r)}}(t),this["".concat(t,"Sync")]=function(e){return function(t){return this.Do(e,t,null,!1)}}(t)},A.prototype.Do=function(e,t,n,r,i){var o,a,s;if(this.config&&this.config[e]&&this.config[e].url){var u=this.config[e],c=u.url;this.queryParams||(this.queryParams={}),null!==(o=u.options)&&void 0!==o&&o.proxyServiceCode&&(this.queryParams.serviceCode=u.options.proxyServiceCode),null!==(a=u.options)&&void 0!==a&&a.billnum&&(this.queryParams.billnum=u.options.billnum),null!==(s=this.queryParams)&&void 0!==s&&s.serviceCode&&(c=x(c,this.queryParams));var l=c,f=Object.assign({},u.options);return f.method=u.method||"GET","function"==typeof t?(f.callback=t,f.context=i||f.context||this):f.params=t,n&&(f.callback=n,f.context=i||f.context||this),!1===r&&(f.async=!1),this.ajax(l,f)}},A.prototype.ajax=function(e,t){return function(e,t){return t.url=e,O.doRequest(t)}(e,t)};var q=function(){return a(function e(t){i(this,e),this._init(t)},[{key:"_init",value:function(e){var t;this.__ASYNC_EXECUTE__=null===(t=null==e?void 0:e.__ASYNC_EXECUTE__)||void 0===t||t,this._events=new Map,this._firstevents=new Map}},{key:"on",value:function(e,t,n){var r=this._events.get(e);Array.isArray(r)||(r=[]),r.push({callback:t,context:n}),this._events.set(e,r)}},{key:"onFirst",value:function(e,t,n){var r=this._firstevents.get(e);Array.isArray(r)||(r=[]),r.splice(0,0,{callback:t,context:n}),this._firstevents.set(e,r)}},{key:"execute",value:function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];var i=this._events.get(e),o=this._firstevents.get(e);if(!i&&!o)return!0;var a=!0;return[].concat(g(o||[]),g(i||[])).forEach(function(e){if(!1!==a){var t=e.callback.apply(e.context||void 0,n);a=!1!==t&&a}}),a}},{key:"un",value:function(e,t){this._unEvents(e,t,this._events),this._unEvents(e,t,this._firstevents)}},{key:"_unEvents",value:function(e,t,n){if(e&&n.has(e))if(t){var r=n.get(e),i=null==r?void 0:r.findIndex(function(e){return e.callback===t});-1!==i&&(null==r||r.splice(i,1))}else n.delete(e)}},{key:"hasEvent",value:function(e){var t,n;return e?((null===(t=this._events.get(e))||void 0===t?void 0:t.length)||0)+((null===(n=this._firstevents.get(e))||void 0===n?void 0:n.length)||0):0}},{key:"fireEvent",value:function(e,t){this.execute("before".concat(e),t)&&(this.execute(e,t),this.execute("after".concat(e),t))}},{key:"_asyncExecute",value:function(e,t,n){for(var r,i=this,o=n.resolve,a=n.reject,s=n.args,u=!0,c=t||[],l=!1,f=function(t){var n,r=c[t];if(!1===u)return 0;if(l)return{v:void 0};if("development"===process.env.nodeEnv)n=r.callback.apply(r.context||i,s);else try{n=r.callback.apply(r.context||i,s)}catch(e){throw e.isAddedMsg||(e.message="(领域扩展事件执行失败,请打开控制台查看详细错误信息并修复):".concat(e.message)),e.isAddedMsg=!0,e}n instanceof Promise?(l=!0,(u=n).callbacks&&u.callbacks.push({reject:function(){u.reject(),t===c.length-1&&(null==a||a())},resolve:function(n){t===c.length-1?(s.length>1&&(s[0]=n),null==o||o(s)):i._asyncExecute(e,c.slice(t+1),{resolve:o,reject:a,args:s})}})):(u=!1!==n&&u,t===c.length-1&&(u?null==o||o(s):null==a||a()))},d=0;d<c.length&&0!==(r=f(d));d++)if(r)return r.v;return u}},{key:"_asyncPromiseExecute",value:function(e,t,n,r){var i=this._events.get(e),o=this._firstevents.get(e);if(!((Array.isArray(i)?i.length:i)||(Array.isArray(o)?o.length:o)))return null==t?void 0:t();var a=[].concat(g(o||[]),g(i||[]));return this._asyncExecute(e,a,{resolve:t,reject:n,args:r})}},{key:"promiseExecute",value:function(e,t){var n=this,r=e,i=1;if("boolean"==typeof e&&(r=t,i=2),r){for(var o=arguments.length,a=new Array(o>2?o-2:0),s=2;s<o;s++)a[s-2]=arguments[s];var u=2===i?a:[t].concat(a);if(u.length){var c,l=u.length-1,f=u[l];if("function"!=typeof f){if("object"!==m(f)||!f[0]||"function"!=typeof f[0]||!f[1]||"function"!=typeof f[1])return;c=f[1],f=f[0]}if(this.__ASYNC_EXECUTE__)return this._asyncPromiseExecute(r,function(e){f.apply(n,e)},function(){c&&"function"==typeof c&&c()},u);u.splice(l,1),u.unshift(r);var d=this.execute.apply(this,u);if(d instanceof Promise){var h=this;d.then(function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];f.apply(h,t)},function(){c&&"function"==typeof c&&c()})}else if(!d)return void(c&&"function"==typeof c&&c())}}}},{key:"clear",value:function(){this._events.clear(),this._firstevents.clear()}}])}();q.create=function(e){return new q(e)};var E=function(){return a(function e(t){i(this,e),this._init(t)},[{key:"_init",value:function(e){this._data=Object.assign({},e)}},{key:"set",value:function(e,t){this._data[e]=t}},{key:"get",value:function(e){var t;return null===(t=this._data)||void 0===t?void 0:t[e]}},{key:"delete",value:function(e){delete this._data[e]}},{key:"clear",value:function(){this._data={}}}])}();E.create=function(e){return new E};var M=function(){return a(function e(t){i(this,e),this._init(t)},[{key:"_init",value:function(e){this._data={};var t=[];if(e)for(var n in e)t.push(n);Object.assign(this._data,{components:[],propertyNames:t},e),this._data.cache=new E,this._data.events=new q}},{key:"_del_data",value:function(e){e&&delete this._data[e]}},{key:"_cls_data",value:function(){this._data.cache.clear(),this._data.events.clear(),this._data={components:[],propertyNames:[],cache:new E,events:new q}}},{key:"_set_data",value:function(e,t,n){if(e){if(n){var r=this._data.propertyNames||[];r.indexOf(e)<0&&r.push(e)}this._data[e]=t}}},{key:"_get_data",value:function(e){if(e)return this._data[e]}},{key:"getData",value:function(){return this._get_data("value")}},{key:"getState",value:function(e,t){var n;if(!t)return this._get_data(e);var r=(this._get_data("components")||[]).find(function(e){return e.ctrlName===t});return r?null===(n=r.getState)||void 0===n?void 0:n.call(r,e):this._get_data(e)}},{key:"setState",value:function(e,t,n){n||this._set_data(e,t,!0);var r={};r[e]=t,this.doPropertyChange("setState",r,n)}},{key:"doPropertyChange",value:function(e,t,n){var r=this,i=this._get_data("components")||[];if(!i.length)return i;var o=[];if(n){var a=i.find(function(e){return e.ctrlName===n});a&&!this.notifyComponent(a,e,t)&&o.push(a)}else i.forEach(function(n){r.notifyComponent(n,e,t)||o.push(n)});return o.length?o:void 0}},{key:"notifyComponent",value:function(e,t,n){return"function"==typeof e[t]&&(this.viewUpdater(e,t,n),!0)}},{key:"viewUpdater",value:function(e,t,n){if("setState"===t)e[t](n);else{var r=this.getCache("name");e[t](n,r)}}},{key:"get",value:function(e){return this._get_data(e)}},{key:"addComponent",value:function(e,t){if(e){t&&!e.ctrlName&&(e.ctrlName=t);var n=this._get_data("components")||[];n.indexOf(e)>=0||n.push(e)}}},{key:"removeComponent",value:function(e){var t=this._get_data("components")||[],n=t.indexOf(e);n<0||t.splice(n,1)}},{key:"_applyState",value:function(e,t,n){var r=this;n||this._set_data(e,t,!0);var i="set".concat(e.charAt(0).toUpperCase()).concat(e.slice(1)),o=this.doPropertyChange(i,t,n);if(o){var a={};a[e]=t,o.forEach(function(e){r.notifyComponent(e,"setState",a)})}}},{key:"getVisible",value:function(e){return this.getState("visible",e)}},{key:"setVisible",value:function(e,t){this._applyState("visible",e,t)}},{key:"getValue",value:function(){return this.getData()}},{key:"setValue",value:function(e,t,n){var r=this,i=this.getValue();if(e!==i){var o={value:e,oldValue:i},a=this._get_data("forceFireEvent");t||a?this.promiseExecute("beforeValueChange",o,[function(){r._set_data("value",e,!0),r._applyState("value",e,n),r.execute("afterValueChange",o)},function(){r._set_data("value",i,!0),r._applyState("value",i,n)}]):(this._set_data("value",e,!0),this._applyState("value",e,n))}}},{key:"getDisabled",value:function(e){return this.getState("disabled",e)}},{key:"setDisabled",value:function(e,t){this._applyState("disabled",e,t)}},{key:"setParent",value:function(e){this.setCache("parent",e)}},{key:"getParent",value:function(){return this.getCache("parent")}},{key:"getRootParent",value:function(){for(var e=this.getParent();null!==(t=e)&&void 0!==t&&t.getParent();){var t;e=e.getParent()}return e}},{key:"setName",value:function(e){this.setCache("name",e)}},{key:"getName",value:function(){return this.getCache("name")}},{key:"setDirty",value:function(e){e?this._set_data("isDirty",!0):(this._del_data("isDirty"),this._set_data("originalData",this.getData()))}},{key:"getDirtyData",value:function(e){var t=this.getData();return!1!==e&&this._get_data("isDirty")||t!==this._get_data("originalData")?t:void 0}},{key:"clear",value:function(e){void 0===e?this._set_data("value",this._get_data("cDefaultValue")):e||this._set_data("value",void 0),this._del_data("isDirty"),this._del_data("checking"),this._del_data("checkMsg")}},{key:"on",value:function(e,t,n){this._get_data("events").on(e,t,n)}},{key:"onFirst",value:function(e,t,n){this._get_data("events").onFirst(e,t,n)}},{key:"execute",value:function(e){for(var t,n=arguments.length,r=new Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];return(t=this._get_data("events")).execute.apply(t,[e].concat(r))}},{key:"un",value:function(e,t){this._get_data("events").un(e,t)}},{key:"hasEvent",value:function(e){return this._get_data("events").hasEvent(e)}},{key:"fireEvent",value:function(e,t){this._get_data("events").fireEvent(e,t)}},{key:"promiseExecute",value:function(e,t){for(var n,r=arguments.length,i=new Array(r>2?r-2:0),o=2;o<r;o++)i[o-2]=arguments[o];(n=this._get_data("events")).promiseExecute.apply(n,[e,t].concat(i))}},{key:"setCache",value:function(e,t){this._get_data("cache").set(e,t)}},{key:"getCache",value:function(e){return this._get_data("cache").get(e)}},{key:"clearCache",value:function(e){this._get_data("cache").delete(e)}},{key:"setProxy",value:function(e){if(!(e instanceof A)){var t,n=this._get_data("__requestHeaders__");for(var r in e){var i,o,a;if(n&&(null===(i=e[r])||void 0===i||null===(i=i.options)||void 0===i||!i.requestHeaders))null!==(a=e[r])&&void 0!==a&&a.options||(e[r].options={}),e[r].options.requestHeaders=n;null!==(o=this.getProxy())&&void 0!==o&&o[r]&&window.devfab.debug&&console.warn("[devfab][baseModel.prototype.setProxy]: Proxy ".concat(r," already exists on the model. Please change the name of ").concat(r," and try again"))}return this._set_data("proxy",A.create(d(d({},(null===(t=this.getProxy())||void 0===t?void 0:t.config)||{}),e))),this.getProxy()}this._set_data("proxy",e)}},{key:"getProxy",value:function(){return this._get_data("proxy")}}])}(),R=function(){function e(){var t;i(this,e);for(var n=arguments.length,o=new Array(n),a=0;a<n;a++)o[a]=arguments[a];return s(t=r(this,e,[].concat(o)),"modelType","SimpleModel"),t}return c(e,M),a(e,[{key:"getDisabled",value:function(){return this.getState("disabled")}},{key:"setDisabled",value:function(e,t){this._applyState("disabled",e,t)}},{key:"getReadonly",value:function(){return this.getState("readonly")}},{key:"setReadonly",value:function(e,t){this._applyState("readonly",e,t)}}])}(),D=Array.isArray;function I(e){if(D(e))return e.map(I);if(e instanceof Date)return new Date(e.getTime());if(e&&"object"===m(e)){var t={};for(var n in e)t[n]=I(e[n]);return t}return e}function T(e,t,n){var r=this;this.promiseExecute("beforeQuery",{proxyConfig:e,queryParams:t},function(){var i=r,o=r.setProxy({queryData:e}),a=r._get_data("innerUsedAttrs").pageIndex,u={page:s(s({},r._get_data("innerUsedAttrs").pageSize,r.getPageSize()),a,r.getPageIndex())},c=Object.assign(t,u);r.setCache("proxyCache",{proxyConfig:e,params:c,callback:n});if(!1!==r.execute("beforeQueryData",c)){var l=I(c);o.queryData(l,function(e,t,r,i){if(!e){var o=t;this._set_data("dataSourceMode","remote");var a=function(e){if(!e)return[];if(D(e))return e;if(D(e.data))return e.data;if(D(e.records))return e.records;if(D(e.list))return e.list;if(D(e.rows))return e.rows;var t=e.data&&"object"===m(e.data)?e.data:e.result;return D(t)?t:t&&"object"===m(t)&&(t.records||t.list||t.rows||t.data)||[]}(o=Object.assign({},o));this.execute("afterQueryData",o),null==n||n.call(this,a)}},i)}})}function U(e){if(this.execute("beforeSetDataSource",e)){var t=this.getRowKeyField(),n={};e.forEach(function(e){n[e[t]]=e}),this._set_data("keyMap",n),this._set_data("dataSource",e,!0),this.doPropertyChange("setDataSource"),this.execute("afterSetDataSource",e)}}var N=function(){function e(){var t,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};i(this,e);var o,a=d(d({},{columns:{},dataSource:[],rows:[],readOnly:!0,dataSourceMode:"local",columnMode:"local",editMode:"cell",rowKeyField:"id",cellState:{},rowState:{},showCheckBox:!1,multiple:!0,showRowNo:!0,pagination:!0,pageInfo:s(s(s({},(o={id:"_id",selected:"_selected",status:"_status",pageIndex:"pageNo",pageSize:"pageSize",pageCount:"total"}).pageIndex,1),o.pageSize,20),o.pageCount,0),innerUsedAttrs:o,multiRowModel:!1,editRowModels:{},loading:!1,params:{},originalKeyMap:{},defaultRowDatas:new Map}),n);D(a.dataSource)||(a.dataSource=[]),D(a.rows)||(a.rows=[]);var u=function(){return d({},(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).proxyConfig||{})}(n);return a.proxyConfig=u,a.dataSourceMode=n.dataSourceMode||a.dataSourceMode,s(t=r(this,e,[a]),"modelType","GridModel"),t.initColumns(a.columns),t.initPageInfo(n.cPage||n.page),t.afterInit(),t}return c(e,M),a(e,[{key:"afterInit",value:function(){this.execute("afterInit")}},{key:"initColumns",value:function(e){var t=function(e){var t={};return(D(e)?e:Object.keys(e||{}).map(function(t){var n;return d(d({},e[t]||{}),{},{field:(null===(n=e[t])||void 0===n?void 0:n.field)||t})})).forEach(function(e,n){if(e){var r=e.field||e.cFieldName||e.cName||"col_".concat(n);t[r]=d(d({},e),{},{field:r,label:e.label||e.title||e.cCaption||r,index:void 0===e.index?n:e.index})}}),t}(e);return this._set_data("columns",t,!0),t}},{key:"initPageInfo",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=d({},this.getPageInfo()),n=this._get_data("innerUsedAttrs").pageIndex,r=this._get_data("innerUsedAttrs").pageSize;t[n]=e.pageNo||e.pageIndex||t.pageIndex||1,t[r]=e.pageSize||t.pageSize||20,!1===this.get("pagination")&&(t[n]=-1),this._set_data("pageInfo",t)}},{key:"getRowKeyField",value:function(){return this._get_data("rowKeyField")}},{key:"isRemote",value:function(){return"remote"===this._get_data("dataSourceMode")}},{key:"getReadOnly",value:function(){return!!this._get_data("readOnly")}},{key:"setReadOnly",value:function(e){this._applyState("readOnly",!!e)}},{key:"setShowCheckbox",value:function(e){this._applyState("showCheckBox",!!e)}},{key:"setShowRowNo",value:function(e){this._applyState("showRowNo",!!e)}},{key:"getParams",value:function(){return d(d({},this.get("cParams")||{}),this._get_data("params")||{})}},{key:"setParams",value:function(e){this._set_data("params",e||{})}},{key:"getInnerUsedAttrs",value:function(e){var t=this._get_data("innerUsedAttrs");return e?t[e]:t}},{key:"getId",value:function(){return this.getInnerUsedAttrs("id")}},{key:"setDataSource",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2?arguments[2]:void 0;if("local"===this._get_data("dataSourceMode")){U(D(e)?e:[])}else{if(!this.execute("beforeProxyLoad",n))return;this.setPageIndex(1),T.call(this,e,n,function(e){U.call(t,e),null==r||r.call(t)})}}},{key:"reloadData",value:function(){var e=this,t=this.getCache("proxyCache");if(t){var n=t.proxyConfig,r=t.params,i=t.callback;T.call(this,n,r,function(t){null==i||i.call(e,t)})}else k()&&console.log("[devfab][GridModel] proxyConfig is null")}},{key:"getDataSource",value:function(){return this._get_data("dataSource")||[]}},{key:"getData",value:function(e){return e?this._get_data("rows"):this._get_data("dataSource")}},{key:"getAllData",value:function(){return this.getData(!0)}},{key:"clear",value:function(){this._set_data("dataSource",[],!0),this._set_data("rows",[],!0)}},{key:"getPageInfo",value:function(){return this._get_data("pageInfo")}},{key:"getPageIndex",value:function(){var e=this._get_data("innerUsedAttrs").pageIndex;return this.getPageInfo()[e]}},{key:"getPageSize",value:function(){var e=this._get_data("innerUsedAttrs").pageSize;return this.getPageInfo()[e]}},{key:"getTotalCount",value:function(){var e=this._get_data("innerUsedAttrs").pageCount;return this.getPageInfo()[e]}},{key:"setPageInfo",value:function(e){var t=this.getPageInfo();this._set_data("pageInfo",d(d({},t),e)),this.reloadData()}},{key:"setPageIndex",value:function(e){if("number"==typeof e){var t=this._get_data("innerUsedAttrs").pageIndex;this._set_data("pageInfo",d(d({},this.getPageInfo()),{},s({},t,Math.max(1,e))))}}},{key:"setPageSize",value:function(e){if("number"==typeof e){var t=this._get_data("innerUsedAttrs").pageIndex,n=this._get_data("innerUsedAttrs").pageSize;this._set_data("pageInfo",d(d({},this.getPageInfo()),{},s(s({},n,Math.max(-1,e)),t,1)))}}},{key:"setTotalCount",value:function(e){var t=this._get_data("innerUsedAttrs").pageCount;this.getPageInfo()[t]=e}}])}(),H=function(){function e(){var t;i(this,e);for(var n=arguments.length,o=new Array(n),a=0;a<n;a++)o[a]=arguments[a];return s(t=r(this,e,[].concat(o)),"modelType","ViewModel"),t}return c(e,M),a(e,[{key:"getParams",value:function(){return this._get_data("params")}},{key:"setParams",value:function(e){this._set_data("params",e,!0)}},{key:"set",value:function(e,t){t instanceof M&&(t.setParent(this),t.setName(e)),this._set_data(e,t,!0)}},{key:"setData",value:function(e){for(var t in e)this.addProperty(t,e[t])}},{key:"addProperty",value:function(e,t){var n=this.get(e);null!=n&&n.setData?n.setData(t):this.set(e,t)}},{key:"getData",value:function(){var e=this,t=this._get_data("propertyNames")||[],n={};return t.forEach(function(t){var r,i=e.get(t);i instanceof M&&!1!==i._get_data("needCollect")&&(n[t]=null===(r=i.getData)||void 0===r?void 0:r.call(i))}),n}},{key:"getAllData",value:function(e){var t=this,n=this._get_data("propertyNames")||[],r={};return n.forEach(function(n){var i,o=t.get(n);if(o instanceof M&&!1!==o._get_data("needCollect")&&(!e||!o._get_data("isGrid"))){var a=null===(i=o.getData)||void 0===i?void 0:i.call(o);void 0!==a&&(r[n]=a)}}),r}},{key:"removeProperty",value:function(e){var t=this._get_data("propertyNames")||[],n=t.indexOf(e);-1!==n&&t.splice(n,1),this._del_data(e)}},{key:"loadData",value:function(e){this.setCache("isLoadData",!0),this.clear(),this.setData(e),this.setDirty(!1),this.setCache("isLoadData",!1)}},{key:"clear",value:function(e){var t=this;(this._get_data("propertyNames")||[]).forEach(function(n){var r,i=t.get(n);i instanceof M&&!1!==i._get_data("needClear")&&(null===(r=i.clear)||void 0===r||r.call(i,e))})}},{key:"setDirty",value:function(e){e?this._set_data("isDirty",!0):(this._del_data("isDirty"),this._set_data("originalData",this.getData()))}},{key:"getGridModel",value:function(e){var t;if(e)return this.get(e);var n=this._get_data("gridModel");if(n)return n;var r=null===(t=this.getParams())||void 0===t?void 0:t.masterGridModelName;if(r)return this.get(r);for(var i=this._get_data("propertyNames"),o=0,a=i.length;o<a;o++){if((n=this.get(i[o]))instanceof N||"GridModel"==n.modelType)return this._set_data("gridModel",n),n}}},{key:"getGridModels",value:function(){for(var e=this._get_data("propertyNames"),t=[],n=0,r=e.length;n<r;n++){var i=this.get(e[n]);(i instanceof N||"GridModel"==i.modelType)&&t.push(i)}return t}},{key:"getGridFilterModel",value:function(e){return this.getGridModel(e).getCache("FilterViewModel")}}])}(),V=403;function F(e){return String(null==e?"":e).replace(/\\/g,"/").replace(/^\.\//,"").replace(/^\/+/,"")}var G=function(){return a(function e(t){i(this,e),this.manifest=null,this.origins=null,this.lockVersion=null,this.verifyHash=!0,this.fetch=null,this._index=null,this.configure(t)},[{key:"configure",value:function(e){var t=e||{};return void 0!==t.manifest&&(this.manifest=t.manifest||null),void 0!==t.origins&&(this.origins=t.origins?[].concat(t.origins).map(function(e){return String(e).trim().replace(/\/+$/,"")}):null),void 0!==t.lockVersion&&(this.lockVersion=t.lockVersion||null),void 0!==t.verifyHash&&(this.verifyHash=!!t.verifyHash),void 0!==t.fetch?this.fetch=t.fetch||null:this.fetch||"function"!=typeof fetch||(this.fetch=function(){return fetch.apply(void 0,arguments)}),this._index=null,this}},{key:"enabled",get:function(){return!!this.manifest}},{key:"_moduleIndex",value:function(){if(this._index)return this._index;var e={},t=this.manifest&&this.manifest.modules;return Array.isArray(t)?t.forEach(function(t){t&&t.path&&(e[F(t.path)]=t)}):t&&"object"===m(t)&&Object.keys(t).forEach(function(n){e[F(n)]=t[n]||{}}),this._index=e,e}},{key:"entryOf",value:function(e){return this.manifest&&this._moduleIndex()[F(e)]||null}},{key:"checkVersion",value:function(){if(!this.lockVersion||!this.manifest)return null;var e=String(this.manifest.version||"");return e===String(this.lockVersion)?null:{code:V,message:"清单版本 ".concat(e||"(未声明)"," 与锁定版本 ").concat(this.lockVersion," 不一致,拒绝加载")}}},{key:"checkModules",value:function(e){var t=this.checkVersion();if(t)return t;if(!this.manifest)return null;for(var n=0;n<e.length;n++){var r=F(e[n]);if(!this._moduleIndex()[r])return{code:V,message:"Module ".concat(r," not registered in the list, loading denied.")}}return null}},{key:"checkOrigin",value:function(e){if(!this.origins)return null;if(!function(e){return/^(?:[a-z][a-z0-9+.-]*:)?\/\//i.test(e)||/^(?:blob|data):/i.test(e)}(e))return null;var t;try{t=new URL(e).origin}catch(t){return{code:V,message:"无法解析的地址:".concat(e)}}return-1===this.origins.indexOf(t)?{code:V,message:"来源 ".concat(t," 不在白名单内(允许:").concat(this.origins.join(", "),")")}:null}},{key:"verify",value:function(e,t){var n=this;if(!this.verifyHash)return Promise.resolve({ok:!0,skipped:"disabled"});if(!t)return Promise.resolve({ok:!0});var r="undefined"!=typeof globalThis&&globalThis.crypto&&globalThis.crypto.subtle;return r?this.fetch?Promise.resolve().then(function(){return n.fetch(e)}).then(function(e){return e&&e.ok?e.arrayBuffer().then(function(e){return r.digest("SHA-256",e)}):{ok:!1,message:"完整性预检请求失败:HTTP ".concat(e&&e.status||"unknown")}}).then(function(e){if(!e||!1===e.ok)return e;var n=function(e){for(var t=new Uint8Array(e),n="",r=0;r<t.length;r++)n+=t[r].toString(16).padStart(2,"0");return n}(e),r=String(t).toLowerCase();return n!==r?{ok:!1,message:"sha256 不匹配:期望 ".concat(r,",实际 ").concat(n)}:{ok:!0}}).catch(function(e){return{ok:!1,message:"完整性预检异常:".concat(e&&e.message||e),error:e}}):Promise.resolve({ok:!0,skipped:"fetch unavailable"}):Promise.resolve({ok:!0,skipped:"crypto.subtle unavailable(需要 https / localhost)"})}},{key:"describe",value:function(){return{manifest:this.enabled?this.manifest.name||"(unnamed)":null,version:this.manifest&&this.manifest.version||null,lockVersion:this.lockVersion,modules:this.enabled?Object.keys(this._moduleIndex()).length:0,origins:this.origins?this.origins.slice():null,verifyHash:this.verifyHash}}}])}(),L=["$","jQuery","define","require","requirejs","devfab","__devfab","__devfab_requirejs"],z=function(){return a(function e(t){i(this,e);var n=t||{};this.maxPollution=void 0===n.maxPollution?3:Number(n.maxPollution),this.watch=[].concat(n.watch||L),this.target=n.target||("undefined"!=typeof window?window:null),this.enabled=void 0===n.enabled||!!n.enabled,this._pending=0,this._before=null,this.lastWarnings=[]},[{key:"_snapshot",value:function(){var e=new Map,t=this.target;return t?(Object.keys(t).forEach(function(n){e.set(n,t[n])}),e):e}},{key:"_diff",value:function(){var e=this,t=this._before,n=this._snapshot(),r=[];if(!t)return r;n.forEach(function(n,i){var o=-1!==e.watch.indexOf(i);t.has(i)?t.get(i)!==n&&r.push({type:"overwritten",key:i,watched:o}):r.push({type:"added",key:i,watched:o})});var i=r.filter(function(e){return e.watched}).length,o=r.filter(function(e){return"added"===e.type}).length;return!i&&o<=this.maxPollution?[]:r}},{key:"begin",value:function(){var e=this;if(!this.enabled||!this.target)return{end:function(){return[]}};this._pending++,1===this._pending&&(this._before=this._snapshot());var t=!1;return{end:function(){if(t)return[];if(t=!0,e._pending--,e._pending>0)return[];var n=e._diff();return e._before=null,e.lastWarnings=n,n}}}},{key:"configure",value:function(e){var t=e||{};return void 0!==t.enabled&&(this.enabled=!!t.enabled),void 0!==t.maxPollution&&(this.maxPollution=Number(t.maxPollution)),void 0!==t.watch&&(this.watch=[].concat(t.watch||[])),void 0!==t.target&&(this.target=t.target||null),this}}])}(),B=null;try{B=new Function("s","return import(s)")}catch(e){B=null}function X(e,t,n,r){var i=e,o=t,a=n;Array.isArray(e)&&!Array.isArray(t)&&(i=null==r?void 0:r.path,o=e,a="function"==typeof t?t:n);var s=(o=Array.isArray(o)?o:[]).join(","),u={code:0,message:"",data:[],warnings:[]};return("require"===r.type&&"function"!=typeof r.require||"define"===r.type&&"function"!=typeof r.define)&&(u.code=404,u.message="requirejs is undefined, the fiels: ".concat(s)),{path:i,files:o,callback:a,filesStr:s,result:u}}function J(e,t){var n="";return Array.isArray(e)?n=e.filter(Boolean).join("/"):"string"==typeof e&&(n=e.replace(/\/+$/,"")),t.map(function(e){var t=String(e).replace(/^\/+/,"");return n?"".concat(n,"/").concat(t):t})}function K(e,t){var n=Number(e);return Number.isFinite(n)?n:t}var W="",Q=15e3,$=0,Y="",Z=function(){return a(function e(t){var n,r,o,a;i(this,e);var s=t||{};this.__debug=null!==(n=s.__debug)&&void 0!==n&&n,this.__rootPath=void 0,this.__define=s.define||(null===(r=window.__devfab_requirejs)||void 0===r?void 0:r.define),this.__require=s.require||(null===(o=window.__devfab_requirejs)||void 0===o?void 0:o.require),this.__undef=s.undef||("function"==typeof(null===(a=this.__require)||void 0===a?void 0:a.undef)?this.__require.undef:null),this.__requireConfig=s.requireConfig||this._pickRequireConfig(this.__require),this.__import=s.importer||null,this._setTimer=s.setTimeout||function(e,t){return setTimeout(e,t)},this._clearTimer=s.clearTimeout||function(e){return clearTimeout(e)},this.options={version:s.version?String(s.version):W,timeout:void 0===s.timeout?Q:Math.max(0,K(s.timeout,0)),retry:void 0===s.retry?$:Math.max(0,K(s.retry,0)),strict:!!s.strict,baseUrl:s.baseUrl||Y},this.policy=new G(s),this.guard=new z(this._guardOptions(s)),this.options.version&&this._applyUrlArgs()},[{key:"_pickRequireConfig",value:function(e){var t,n=e&&"function"==typeof e.config?e:null===(t=window.__devfab_requirejs)||void 0===t?void 0:t.require;return n&&"function"==typeof n.config?n.config.bind(n):null}},{key:"_guardOptions",value:function(e){return!1===e.pollution?{enabled:!1,target:e.target}:e.pollution&&"object"===m(e.pollution)?Object.assign({target:e.target},e.pollution):{target:e.target,watch:e.watch,maxPollution:e.maxPollution,enabled:void 0===e.pollution||!!e.pollution}}},{key:"configure",value:function(e){var t=e||{};return void 0!==t.debug&&(this.__debug=!!t.debug),void 0!==t.version&&this.setVersion(t.version),void 0!==t.timeout&&(this.options.timeout=Math.max(0,K(t.timeout,this.options.timeout))),void 0!==t.retry&&(this.options.retry=Math.max(0,K(t.retry,this.options.retry))),void 0!==t.strict&&(this.options.strict=!!t.strict),void 0!==t.baseUrl&&(this.options.baseUrl=t.baseUrl||""),void 0===t.manifest&&void 0===t.origins&&void 0===t.lockVersion&&void 0===t.verifyHash&&void 0===t.fetch||this.policy.configure(t),void 0!==t.pollution?this.guard.configure(this._guardOptions(t)):void 0===t.watch&&void 0===t.maxPollution&&void 0===t.target||this.guard.configure(t),this}},{key:"setVersion",value:function(e){return this.options.version=e?String(e):"",this._applyUrlArgs(),this}},{key:"_applyUrlArgs",value:function(){if("function"!=typeof this.__requireConfig)return!1;try{return this.__requireConfig({urlArgs:this.options.version?"v=".concat(encodeURIComponent(this.options.version)):""}),!0}catch(e){return!1}}},{key:"getVersion",value:function(){return this.options.version}},{key:"_snapshotConfig",value:function(){return{__debug:this.__debug,version:this.options.version,timeout:this.options.timeout,retry:this.options.retry,strict:this.options.strict,baseUrl:this.options.baseUrl,manifest:this.policy.manifest,origins:this.policy.origins,lockVersion:this.policy.lockVersion,verifyHash:this.policy.verifyHash,fetch:this.policy.fetch,pollution:this.guard.enabled,watch:this.guard.watch,maxPollution:this.guard.maxPollution,target:this.guard.target}}},{key:"describe",value:function(){return Object.assign({},this.options,{debug:this.__debug,policy:this.policy.describe(),pollutionGuard:this.guard.enabled,canUndef:"function"==typeof this.__undef,canNativeImport:"function"==typeof(this.__import||B)})}},{key:"_define",value:function(e,t,n){var r=X(e,t,n,{path:this.__rootPath,define:this.__define,type:"define"}),i=r.path,o=r.files,a=r.callback,s=r.result;404!==s.code?this.__define(i,o,a):null==a||a(s)}},{key:"_mergeWarnings",value:function(e,t){var n=(e||[]).slice();return(t||[]).forEach(function(e){n.some(function(t){return t.type===e.type&&t.key===e.key})||n.push(e)}),n}},{key:"_undefModules",value:function(e){var t=this;"function"==typeof this.__undef&&e.forEach(function(e){try{t.__undef(e)}catch(e){}})}},{key:"_load",value:function(e,t,n){var r=this,i=this.options,o=X(e,t,n,{path:this.__rootPath,require:this.__require,type:"require"}),a=o.path,s=o.files,u=o.callback,c=o.result,l=o.filesStr;if(404!==c.code){var f=J(a,s),d=this.policy.checkModules(f);if(d)return c.code=d.code,c.message=d.message,void(null==u||u(c));var h=!1,v=0,p=null,y=null,g=function(){y&&(c.warnings=r._mergeWarnings(c.warnings,y.end()),y=null)},_=function(){h||(h=!0,null!==p&&(r._clearTimer(p),p=null),g(),i.strict&&c.warnings.length&&(c.code=500,c.message="Global pollution detection failed:".concat(c.warnings.map(function(e){return"".concat(e.type,":").concat(e.key)}).join(", "))),null==u||u(c))},m=function(){v++,y=r.guard.begin(),i.timeout>0&&(p=r._setTimer(function(){if(!h){var e=new Error("load timeout after ".concat(i.timeout,"ms: ").concat(l));e.__devfabTimeout=!0,b(e,"files load timeout after ".concat(i.timeout,"ms, the files: ").concat(l))}},i.timeout)),r.__require(a,s,function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];c.data=t,_()},function(e){b(e)})},b=function(e,t){if(!h){if(null!==p&&(r._clearTimer(p),p=null),v<=i.retry)return g(),r._undefModules(f),void m();c.code=e&&e.__devfabTimeout?504:500,c.message=t||"files load error, the files: ".concat(l),c.error=e,_()}};m()}else null==u||u(c)}},{key:"load",value:function(e,t,n){this._load(e,t,n)}},{key:"resolveUrl",value:function(e){var t=String(null==e?"":e);if(/^[a-z][a-z0-9+.-]*:/i.test(t)||/^\/\//.test(t))return t;var n=this.options.baseUrl||("undefined"!=typeof document&&document.baseURI?document.baseURI:"");if(!n)return t;try{return new URL(t,n).href}catch(e){return t}}},{key:"_importOne",value:function(e){var t=this,n=this.resolveUrl(e),r=this.policy.checkOrigin(n);if(r)return Promise.resolve({ok:!1,code:r.code,message:r.message});var i=this.policy.entryOf(e),o=i&&i.sha256,a=function(){var e=t.__import||B;return"function"!=typeof e?Promise.resolve({ok:!1,code:500,message:"native import() is unavailable(CSP 是否禁用了 unsafe-eval?)"}):Promise.resolve().then(function(){return e(n)}).then(function(e){return{ok:!0,module:e}},function(e){return{ok:!1,code:500,message:"module load error: ".concat(n),error:e}})};return o?this.policy.verify(n,o).then(function(e){return e.ok?a():{ok:!1,code:V,message:"".concat(e.message,"(").concat(n,")")}}):a()}},{key:"loadModules",value:function(e,t,n){var r=this,i=X(e,t,n,{path:this.__rootPath,type:"module"}),o=i.path,a=i.files,s=i.callback,u=i.result,c=i.filesStr,l=J(o,a),f=function(e){return null==s||s(e),e},d=this.policy.checkModules(l);if(d)return u.code=d.code,u.message=d.message,Promise.resolve(f(u));if(!a.length)return Promise.resolve(f(u));var h=this.guard.begin();return Promise.all(l.map(function(e){return r._importOne(e)})).then(function(e){u.warnings=h.end();var t=e.filter(function(e){return!e.ok});return t.length?(u.code=t[0].code||500,u.message="".concat(t.map(function(e){return e.message}).join("; "),"(the files: ").concat(c,")"),u.error=t[0].error):u.data=e.map(function(e){return e.module}),f(u)})}},{key:"loadModule",value:function(e,t){return this.loadModules([e],t)}}])}(),ee=function(){function e(){return i(this,e),r(this,e,arguments)}return c(e,Z),a(e,[{key:"define",value:function(e,t,n){this._define(e,t,n)}},{key:"defineScript",value:function(e){this.provideScript(e)}},{key:"provideScript",value:function(e){var t=e;"function"!=typeof e&&(t=function(){return e}),this.define([],t)}},{key:"require",value:function(e,t,n){this._load(e,t,n)}},{key:"injectScript",value:function(e,t,n,r){var i=this,o=e,a=t,s=n,u=r;Array.isArray(e)&&"function"==typeof t&&(o=void 0,a=e,s=t,u=n),this._load(o,a,function(e){if(0==e.code&&Array.isArray(e.data))for(var t=0,n=e.data.length;t<n;t++){var r,o=e.data[t];null===(r=s)||void 0===r||r(o,t)}else"function"==typeof u?u(e):i.__debug&&console.error("[devfab][FileRequire][injectScript] error: ",e)})}},{key:"requireScript",value:function(e,t,n){this.injectScript(e,t,n)}}])}(),te=new ee;function ne(e,t,n,r,i){var o,a=t,s=n,u=r,c=i;Array.isArray(t)&&"function"==typeof n&&(a=void 0,s=t,u=n,c=r);var l=(null===(o=c)||void 0===o?void 0:o.viewModel)||this,f=(s=Array.isArray(s)?s:[]).join(",");return te.create({require:e}).require(a,s,function(e){var t;if(0==e.code&&Array.isArray(e.data))for(var n=0,r=e.data.length;n<r;n++){var i=e.data[n];if(i&&i.doAction)try{i.doAction("init",l)}catch(t){e.code=500,e.message="".concat(f," script execute error"),e.error=t;break}else try{var o;"function"==typeof(null===(o=c)||void 0===o?void 0:o.onFileBack)&&c.onFileBack(i,n)}catch(t){e.code=500,e.message="".concat(f," script customize execute error");break}}0!=e.code&&window.__devfab.debug&&console.info("[devfab][models][extend][loadScripts] ".concat(f," \n [message]: ").concat(e.message," \n").concat(e.error?" \n [error]: ":""),e.error),null===(t=u)||void 0===t||t(e)})}function re(e){var t=this;window.__devfab&&window.__devfab.__debugger_initExtendJs;var n=e.requirejs,r=e.extendScriptParams,i=e.readyEventName,o=void 0===i?"extendReady":i,a=r||{},s=a.enableJs,u=void 0!==s&&s,c=a.filepath,l=a.scriptUrl;if(!u)return window.__devfab.debug&&console.info("[devfab][extend][js] not enable extend script"),void t.execute(o,t);if(!l)return window.__devfab.debug&&console.info("[devfab][extend][js] extend script is not defined"),void t.execute(o,t);var f=c,d=[l];t.getEnv&&t.getEnv("everyCommonExtend")&&d.push(t.getEnv("everyCommonExtend")),ne.call(t,null==n?void 0:n.require,f,d,function(e){t.execute(o,t,e)})}te.create=function(e){return new ee(d(d({},this._snapshotConfig()),e))};var ie=function(){var e=n(h().m(function e(t,r,i){var o,a,s,u,c,l,f,d,v,p,y;return h().w(function(e){for(;;)switch(e.n){case 0:if(window.__devfab&&window.__devfab.__debugger_initExtJs,s=i.requirejs,u=i.extendScriptParams,l=(c=u||{}).enableExtJs,f=void 0!==l&&l,d=c.exturlsField,v=void 0===d?"extscripturls":d,f){e.n=1;break}return window.__devfab.debug&&console.info("[devfab][extend][exturls] ext script is not enable"),e.a(2,Promise.resolve(!0));case 1:if(t){e.n=2;break}return window.__devfab.debug&&console.info("[devfab][extend][exturls] script data is null"),e.a(2,Promise.resolve(!0));case 2:if(p=null==t?void 0:t[v],y=Array.isArray(p)?p:[],y=(y=(r.getCache("localScripts")||[]).concat(y)).concat(window.__devfab__GLOBAL_EXT_SCRIPTS__||[]),null!==(o=r.getParams())&&void 0!==o&&o.selfExtUrls&&(y=y.concat([r.getParams().selfExtUrls])),null===(a=y)||void 0===a||!a.length){e.n=4;break}return y=g(new Set(y)),e.n=3,Promise.all(y.map(function(){var e=n(h().m(function e(t){return h().w(function(e){for(;;)if(0===e.n)return e.a(2,t)},e)}));return function(t){return e.apply(this,arguments)}}()));case 3:y=e.v;case 4:return t[v]=y,e.a(2,new Promise(function(e,t){ne.call(r,null==s?void 0:s.require,y,function(t){e(t)})}))}},e)}));return function(t,n,r){return e.apply(this,arguments)}}(),oe=M,ae=R,se=H,ue=N;function ce(e){var t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=n.modelNameField,s=void 0===o?"cName":o,u=function(e){function t(){return i(this,t),r(this,t,arguments)}return c(t,e),a(t,[{key:"init",value:function(e,t){var n=this.createModels(e,t);this.setData(n),this.setDirty(!1)}},{key:"createModels",value:function(e,t){var r={};return(Array.isArray(e)?e:[]).forEach(function(e){var t,i,o=function(e,t){var n=(null==t?void 0:t.SimpleModel)||R,r=e.cControlType||e.component||e.controlType||e.ctrlType;return r=r.toLowerCase(),new n(e)}(e,n),a={model:o,meta:e,childModel:!0,modelName:e[s]};null==n||null===(t=n.onBeforeInitModel)||void 0===t||t.call(n,a),r[a.modelName]=a.model,null==n||null===(i=n.onAfterInitModel)||void 0===i||i.call(n,a)}),r}},{key:"initData",value:function(){re.call(this,n)}}])}((null==n||null===(t=n.models)||void 0===t?void 0:t.ViewModel)||H);return u.prototype.modelType="ViewModel",u}var le={models:Object.freeze({__proto__:null,BaseModel:oe,SimpleModel:ae,GridModel:ue,ViewModel:se,initViewModel:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2?arguments[2]:void 0,i=function(e,t){var n,r,i,o=new(ce(e,t)),a={model:o,meta:e};return null==t||null===(n=t.onBeforeInitModel)||void 0===n||n.call(t,a),a.model=o,null==o||null===(r=o.init)||void 0===r||r.call(o,e.models,e),null==t||null===(i=t.onAfterInitModel)||void 0===i||i.call(t,a),o}(e,t);return i.on("destroyVM",function(){var e,t;null===(e=i)||void 0===e||null===(t=e.destroyVM)||void 0===t||t.call(e),i=null,window.devfab.debug&&console.info("[devfab][models][initVM]: destory vm ".concat((new Date).toString()))}),i.on("extendReady",n(h().m(function n(){var o;return h().w(function(n){for(;;)switch(n.n){case 0:return(o=[]).push(ie(e,i,t)),n.n=1,Promise.all(o);case 1:window.devfab.debug&&console.info("[devfab][models][initVM]: after vm init ".concat((new Date).toString())),null==r||r(i,e);case 2:return n.a(2)}},n)}))),i.initData(),i},loadScripts:ne}),Builder:C,Cache:E,Event:q,Ajax:A};exports.default=le;
|
|
3
|
+
var e,t,n="function"==typeof Symbol?Symbol:{},r=n.iterator||"@@iterator",a=n.toStringTag||"@@toStringTag";function o(n,r,a,o){var u=r&&r.prototype instanceof s?r:s,c=Object.create(u.prototype);return h(c,"_invoke",function(n,r,a){var o,s,u,c=0,l=a||[],f=!1,d={p:0,n:0,v:e,a:v,f:v.bind(e,4),d:function(t,n){return o=t,s=0,u=e,d.n=n,i}};function v(n,r){for(s=n,u=r,t=0;!f&&c&&!a&&t<l.length;t++){var a,o=l[t],v=d.p,h=o[2];n>3?(a=h===r)&&(u=o[(s=o[4])?5:(s=3,3)],o[4]=o[5]=e):o[0]<=v&&((a=n<2&&v<o[1])?(s=0,d.v=r,d.n=o[1]):v<h&&(a=n<3||o[0]>r||r>h)&&(o[4]=n,o[5]=r,d.n=h,s=0))}if(a||n>1)return i;throw f=!0,r}return function(a,l,h){if(c>1)throw TypeError("Generator is already running");for(f&&1===l&&v(l,h),s=l,u=h;(t=s<2?e:u)||!f;){o||(s?s<3?(s>1&&(d.n=-1),v(s,u)):d.n=u:d.v=u);try{if(c=2,o){if(s||(a="next"),t=o[a]){if(!(t=t.call(o,u)))throw TypeError("iterator result is not an object");if(!t.done)return t;u=t.value,s<2&&(s=0)}else 1===s&&(t=o.return)&&t.call(o),s<2&&(u=TypeError("The iterator does not provide a '"+a+"' method"),s=1);o=e}else if((t=(f=d.n<0)?u:n.call(r,d))!==i)break}catch(t){o=e,s=1,u=t}finally{c=1}}return{value:t,done:f}}}(n,a,o),!0),c}var i={};function s(){}function u(){}function c(){}t=Object.getPrototypeOf;var l=[][r]?t(t([][r]())):(h(t={},r,function(){return this}),t),f=c.prototype=s.prototype=Object.create(l);function d(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,c):(e.__proto__=c,h(e,a,"GeneratorFunction")),e.prototype=Object.create(f),e}return u.prototype=c,h(f,"constructor",c),h(c,"constructor",u),u.displayName="GeneratorFunction",h(c,a,"GeneratorFunction"),h(f),h(f,a,"Generator"),h(f,r,function(){return this}),h(f,"toString",function(){return"[object Generator]"}),(v=function(){return{w:o,m:d}})()}function h(e,t,n,r){var a=Object.defineProperty;try{a({},"",{})}catch(e){a=0}h=function(e,t,n,r){function o(t,n){h(e,t,function(e){return this._invoke(t,n,e)})}t?a?a(e,t,{value:n,enumerable:!r,configurable:!r,writable:!r}):e[t]=n:(o("next",0),o("throw",1),o("return",2))},h(e,t,n,r)}function y(e,t){return y=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},y(e,t)}function p(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,a,o,i,s=[],u=!0,c=!1;try{if(o=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;u=!1}else for(;!(u=(r=o.call(n)).done)&&(s.push(r.value),s.length!==t);u=!0);}catch(e){c=!0,a=e}finally{try{if(!u&&null!=n.return&&(i=n.return(),Object(i)!==i))return}finally{if(c)throw a}}return s}}(e,t)||b(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function g(t){return function(t){if(Array.isArray(t))return e(t)}(t)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(t)||b(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function _(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}function m(e){return m="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},m(e)}function b(t,n){if(t){if("string"==typeof t)return e(t,n);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?e(t,n):void 0}}function k(e){return e||!("undefined"==typeof window||!window.__devfab||!window.__devfab.debug)}function w(e){this.pathname="",this.query={};var t=e;this.init=function(){t||(t=location.search);var e=t.indexOf("?"),n=t.indexOf("#");if(e>=0){if(this.pathname=t.substr(0,e),(t=n<0?t.substr(e+1):t.substring(e+1,n)).length>0)for(var r=(t=t.replace(/\+/g," ")).split("&"),a=0,o=r.length;a<o;a++){var i=r[a]||"";if(i){var s=i.indexOf("="),u="",c="";s<0?c=u=window.decode(i):(u=window.decode(i.substr(0,s)),c=window.decode(i.substr(s+1))),this.query[u]=c}}}else this.pathname=t},this.set=function(e,t){this.query[e]=t},this.get=function(e){return this.query[e]},this.del=function(e){delete this.query[e]},this.has=function(e){return null!=this.query[e]},this.toStr=function(){var e=["?"];for(var t in this.query)e.push(encodeURIComponent(t)),e.push("="),e.push(encodeURIComponent(this.query[t])),e.push("&");return 1===e.length?"":(e.splice(e.length-1,1),e.join(""))},this.init()}function x(e,t){return!(!e||!t)&&e.toLowerCase()===t.toLowerCase()}function S(e,t){if(!t)return e;var n=[],r=new w(e);for(var a in t)r.get(a)||n.push("".concat(a,"=").concat(t[a]));if(!n.length)return e;var o=n.join("&");return e.indexOf("?")>=0?"".concat(e,"&").concat(o):"".concat(e,"?").concat(o)}Object.defineProperty(exports,"__esModule",{value:!0});var P=function(e){return null!=e&&""!==e};var C=["children","render"],j=function(){return i(function e(){a(this,e),s(this,"_config",{componentField:["component"]}),s(this,"_components",{}),s(this,"_renderFactory",null)},[{key:"init",value:function(e,t,n){this._initConfig(e),this._initComponent(t),this._initRenderFactory(n)}},{key:"_initConfig",value:function(e){this._config=Object.assign(this._config,e)}},{key:"_initComponent",value:function(e,t){if(e)if("string"==typeof e){if(this._components[e])return void console.log("[warning] Component ".concat(e," is exist!"));this._components[e]=t}else"function"==typeof e?Object.assign(this._components,null==e?void 0:e()):"object"===m(e)&&Object.assign(this._components,e)}},{key:"_getComponent",value:function(e){return this._components[e]}},{key:"_clearComponents",value:function(){this._components={}}},{key:"_initRenderFactory",value:function(e){this._renderFactory=e}},{key:"_renderComponent",value:function(e,t){var n=this;if(Array.isArray(e)){var r=[];return e.forEach(function(e,a){var o=d({},e),i=function(e,t,n){if(e){var r=n;"string"==typeof t&&Array.isArray(r)&&(r=s({},t,n));var a=r&&r[t];if(!a)return P(e[t])?e[t]:void 0;for(var o=0;o<a.length;o++){var i=e[a[o]];if(P(i))return i}}}(o,"component",n._config.componentField),u=o.children,c=o.render,l=function(e,t){if(null==e)return{};var n,r,a=function(e,t){if(null==e)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(-1!==t.indexOf(r))continue;n[r]=e[r]}return n}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(r=0;r<o.length;r++)n=o[r],-1===t.indexOf(n)&&{}.propertyIsEnumerable.call(e,n)&&(a[n]=e[n])}return a}(o,C),f=n._getComponent(i);f||"function"==typeof c||console.log("[warning] Component ".concat(i," is not registered!"));var v={component:f,children:n._renderComponent(u,t)};l.index=a;var h=Object.assign({},null==t?void 0:t.props,{meta:l});"function"==typeof c?r.push(c({node:v,props:h})):"function"==typeof n._renderFactory?r.push(n._renderFactory({node:v,props:h})):(Object.assign(v,h),r.push(v))}),r}}},{key:"clear",value:function(){this._clearComponents(),this._renderFactory=null}}])}(),O=function(){function e(){return a(this,e),r(this,e,arguments)}return c(e,j),i(e,[{key:"initComponent",value:function(e,t){this._initComponent(e,t)}},{key:"getComponents",value:function(){return d({},this._components)}},{key:"getComponent",value:function(e){return this._getComponent(e)}},{key:"hasComponent",value:function(e){return!!this._getComponent(e)}},{key:"initRenderFactory",value:function(e){this._initRenderFactory(e)}},{key:"render",value:function(e,t){return this._renderComponent(e,t)}}])}();O.create=function(e){return new O(e)};var A={_xhrs:[],_jsonps:{index:0},doRequest:function(e){var t,n=e.method||"GET",r=e.url;try{null!=e&&e.requestHeaders&&(t=e.requestHeaders,e.requestHeaders=void 0,delete e.requestHeaders)}catch(e){k()&&console.log('[devfab][ajax]: [doRequest]: options["requestHeaders"] ERR : ',e)}try{e.params&&e.params.requestHeaders&&(t=e.params.requestHeaders,e.params.requestHeaders=void 0,delete e.params.requestHeaders)}catch(e){k()&&console.log('[devfab][ajax]: [doRequest]: options.params["requestHeaders"] ERR : ',e)}var a=null;if(x(n,"get")||x(n,"delete")?r=S(r,e.params):(x(n,"post")||x(n,"put"))&&(a=JSON.stringify(e.params)),e.jsonp)return this.getJsonp(r,e.callback);var o=this.getXMLHttpRequest();if(o){var i;if(o.open(n,r,!1!==e.async),e.timeout&&(o.timeout=e.timeout,o.setRequestHeader("timeout",e.timeout),o.ontimeout=function(){A.onerror(this,e,"timeout")}),e.contentType){if(o.setRequestHeader("Content-Type",e.contentType),e.contentType.indexOf("x-www-form-urlencoded")>=0)a=null===(i=new URLSearchParams(e.params))||void 0===i?void 0:i.toString()}else e.dateType?a=e.params:o.setRequestHeader("Content-Type","application/json;charset=utf-8");try{if(t&&"[object Object]"===Object.prototype.toString.call(t))for(var s in t)o.setRequestHeader(s,t[s])}catch(e){k()&&console.log('[devfab][ajax]: [doRequest]: options.params["requestHeaders"] ERR : ',e)}o.withCredentials=null==e||!e.hasOwnProperty("withCredentials")||e.withCredentials,e.onBeforeRequest&&e.onBeforeRequest(o,a);try{o.send(a)}catch(t){return{error:"NetWorkError",options:e}}if(!1===e.async)return this.onreadystatechange(o,e);o.onreadystatechange=function(){A.onreadystatechange(this,e)}}},onreadystatechange:function(e,t){if(4===e.readyState){if(200===e.status){var n;try{if("blob"===t.responseType){var r=function(e){var t=e.xhr.getAllResponseHeaders(),n={};return t.split("\r\n").map(function(e){var t=p(e.split(": "),2),r=t[0],a=t[1];n[r]=a}),n}({xhr:e});n={code:e.status,data:{data:e.response,headers:r}}}else n=JSON.parse(e.responseText)}catch(n){A.onerror(e,t,e.responseText)}if(!1===t.async)return e.isBusy=!1,t.onAfterRequest&&t.onAfterRequest(n),A.parseAjaxResult(n,!1,null,null,t,e);A.parseAjaxResult(n,t.async,t.callback,t.context,t,e),t.onAfterRequest&&t.onAfterRequest(n)}else if(0===e.status)A.onerror(e,t,"The network connection has been disconnected. Please check the network status of the device and try.");else if(502===e.status||504===e.status)A.onerror(e,t,"An error has occurred with the service. Please try again later.");else{if(401!==e.status){var a={};try{a=JSON.parse(e.responseText)}catch(t){a={code:e.status,message:e.responseText}}return A.onerror(e,t,a)}A.onerror(e,t,"Login information has expired. Please log in again or contact technical staff.")}e.isBusy=!1}},onerror:function(e,t,n){var r="[devfab][ajax]: [onerror]: api error \n [code]: ".concat(e.status," \n [error]: ").concat(("object"===m(n)?JSON.stringify(n):n)||"空"," \n [url]: ").concat(t.url," \n [token]: ").concat(document.cookie);k()&&console.log(r);var a="object"===m(n)?n:{code:500,message:n};t.onAfterRequest&&t.onAfterRequest(a)},getXMLHttpRequest:function(){return this.createXMLHttpRequest()},createXMLHttpRequest:function(){return window.XMLHttpRequest?new XMLHttpRequest:window.ActiveXObject?new window.ActiveXObject("Microsoft.XMLHTTP"):null},getJsonp:function(e,t){var n=e,r="callback"+this._jsonps.index++,a=document.createElement("script");this._jsonps[r]=function(e){try{t(e)}finally{document.body.removeChild(a)}},n+=-1===n.indexOf("?")?"?":"&callback=cb.rest.AjaxUtil._jsonps."+r,a.src=n,document.body.appendChild(a)},parseAjaxResult:function(e,t,n,r,a,o){if(e){if(!e.code)return!1===t?e:void(n&&n.call(r,null,e));if(200==e.code){if(!1===t)return{result:e.data};n&&n.call(r,null,e.data,e.message,e.errorDetail,e.code,e.displayCode&&e)}else{if(!1===t)return{error:e};n&&n.call(r,e)}}}};function E(e,t){this.init&&this.init(e),this.queryParams=t}E.create=function(e,t){return new E(e,t)},E.prototype.init=function(e){if(e)for(var t in this.config=e,this.config)this[t]=function(e){return function(t,n,r){return this.Do(e,t,n,null,r)}}(t),this["".concat(t,"Sync")]=function(e){return function(t){return this.Do(e,t,null,!1)}}(t)},E.prototype.Do=function(e,t,n,r,a){var o,i,s;if(this.config&&this.config[e]&&this.config[e].url){var u=this.config[e],c=u.url;this.queryParams||(this.queryParams={}),null!==(o=u.options)&&void 0!==o&&o.proxyServiceCode&&(this.queryParams.serviceCode=u.options.proxyServiceCode),null!==(i=u.options)&&void 0!==i&&i.billnum&&(this.queryParams.billnum=u.options.billnum),null!==(s=this.queryParams)&&void 0!==s&&s.serviceCode&&(c=S(c,this.queryParams));var l=c,f=Object.assign({},u.options);return f.method=u.method||"GET","function"==typeof t?(f.callback=t,f.context=a||f.context||this):f.params=t,n&&(f.callback=n,f.context=a||f.context||this),!1===r&&(f.async=!1),this.ajax(l,f)}},E.prototype.ajax=function(e,t){return function(e,t){return t.url=e,A.doRequest(t)}(e,t)};var D=function(){return i(function e(t){a(this,e),this._init(t)},[{key:"_init",value:function(e){var t;this.__ASYNC_EXECUTE__=null===(t=null==e?void 0:e.__ASYNC_EXECUTE__)||void 0===t||t,this._events=new Map,this._firstevents=new Map}},{key:"on",value:function(e,t,n){var r=this._events.get(e);Array.isArray(r)||(r=[]),r.push({callback:t,context:n}),this._events.set(e,r)}},{key:"onFirst",value:function(e,t,n){var r=this._firstevents.get(e);Array.isArray(r)||(r=[]),r.splice(0,0,{callback:t,context:n}),this._firstevents.set(e,r)}},{key:"execute",value:function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];var a=this._events.get(e),o=this._firstevents.get(e);if(!a&&!o)return!0;var i=!0;return[].concat(g(o||[]),g(a||[])).forEach(function(e){if(!1!==i){var t=e.callback.apply(e.context||void 0,n);i=!1!==t&&i}}),i}},{key:"un",value:function(e,t){this._unEvents(e,t,this._events),this._unEvents(e,t,this._firstevents)}},{key:"_unEvents",value:function(e,t,n){if(e&&n.has(e))if(t){var r=n.get(e),a=null==r?void 0:r.findIndex(function(e){return e.callback===t});-1!==a&&(null==r||r.splice(a,1))}else n.delete(e)}},{key:"hasEvent",value:function(e){var t,n;return e?((null===(t=this._events.get(e))||void 0===t?void 0:t.length)||0)+((null===(n=this._firstevents.get(e))||void 0===n?void 0:n.length)||0):0}},{key:"fireEvent",value:function(e,t){this.execute("before".concat(e),t)&&(this.execute(e,t),this.execute("after".concat(e),t))}},{key:"_asyncExecute",value:function(e,t,n){for(var r,a=this,o=n.resolve,i=n.reject,s=n.args,u=!0,c=t||[],l=!1,f=function(t){var n,r=c[t];if(!1===u)return 0;if(l)return{v:void 0};if("development"===process.env.nodeEnv)n=r.callback.apply(r.context||a,s);else try{n=r.callback.apply(r.context||a,s)}catch(e){throw e.isAddedMsg||(e.message="(领域扩展事件执行失败,请打开控制台查看详细错误信息并修复):".concat(e.message)),e.isAddedMsg=!0,e}n instanceof Promise?(l=!0,(u=n).callbacks&&u.callbacks.push({reject:function(){u.reject(),t===c.length-1&&(null==i||i())},resolve:function(n){t===c.length-1?(s.length>1&&(s[0]=n),null==o||o(s)):a._asyncExecute(e,c.slice(t+1),{resolve:o,reject:i,args:s})}})):(u=!1!==n&&u,t===c.length-1&&(u?null==o||o(s):null==i||i()))},d=0;d<c.length&&0!==(r=f(d));d++)if(r)return r.v;return u}},{key:"_asyncPromiseExecute",value:function(e,t,n,r){var a=this._events.get(e),o=this._firstevents.get(e);if(!((Array.isArray(a)?a.length:a)||(Array.isArray(o)?o.length:o)))return null==t?void 0:t();var i=[].concat(g(o||[]),g(a||[]));return this._asyncExecute(e,i,{resolve:t,reject:n,args:r})}},{key:"promiseExecute",value:function(e,t){var n=this,r=e,a=1;if("boolean"==typeof e&&(r=t,a=2),r){for(var o=arguments.length,i=new Array(o>2?o-2:0),s=2;s<o;s++)i[s-2]=arguments[s];var u=2===a?i:[t].concat(i);if(u.length){var c,l=u.length-1,f=u[l];if("function"!=typeof f){if("object"!==m(f)||!f[0]||"function"!=typeof f[0]||!f[1]||"function"!=typeof f[1])return;c=f[1],f=f[0]}if(this.__ASYNC_EXECUTE__)return this._asyncPromiseExecute(r,function(e){f.apply(n,e)},function(){c&&"function"==typeof c&&c()},u);u.splice(l,1),u.unshift(r);var d=this.execute.apply(this,u);if(d instanceof Promise){var v=this;d.then(function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];f.apply(v,t)},function(){c&&"function"==typeof c&&c()})}else if(!d)return void(c&&"function"==typeof c&&c())}}}},{key:"clear",value:function(){this._events.clear(),this._firstevents.clear()}}])}();D.create=function(e){return new D(e)};var M=function(){return i(function e(t){a(this,e),this._init(t)},[{key:"_init",value:function(e){this._data=Object.assign({},e)}},{key:"set",value:function(e,t){this._data[e]=t}},{key:"get",value:function(e){var t;return null===(t=this._data)||void 0===t?void 0:t[e]}},{key:"delete",value:function(e){delete this._data[e]}},{key:"clear",value:function(){this._data={}}}])}();M.create=function(e){return new M};var R=function(){return i(function e(t){a(this,e),this._init(t)},[{key:"_init",value:function(e){this._data={};var t=[];if(e)for(var n in e)t.push(n);Object.assign(this._data,{components:[],propertyNames:t},e),this._data.cache=new M,this._data.events=new D}},{key:"_del_data",value:function(e){e&&delete this._data[e]}},{key:"_cls_data",value:function(){this._data.cache.clear(),this._data.events.clear(),this._data={components:[],propertyNames:[],cache:new M,events:new D}}},{key:"_set_data",value:function(e,t,n){if(e){if(n){var r=this._data.propertyNames||[];r.indexOf(e)<0&&r.push(e)}this._data[e]=t}}},{key:"_get_data",value:function(e){if(e)return this._data[e]}},{key:"getData",value:function(){return this._get_data("value")}},{key:"getState",value:function(e,t){var n;if(!t)return this._get_data(e);var r=(this._get_data("components")||[]).find(function(e){return e.ctrlName===t});return r?null===(n=r.getState)||void 0===n?void 0:n.call(r,e):this._get_data(e)}},{key:"setState",value:function(e,t,n){n||this._set_data(e,t,!0);var r={};r[e]=t,this.doPropertyChange("setState",r,n)}},{key:"doPropertyChange",value:function(e,t,n){var r=this,a=this._get_data("components")||[];if(!a.length)return a;var o=[];if(n){var i=a.find(function(e){return e.ctrlName===n});i&&!this.notifyComponent(i,e,t)&&o.push(i)}else a.forEach(function(n){r.notifyComponent(n,e,t)||o.push(n)});return o.length?o:void 0}},{key:"notifyComponent",value:function(e,t,n){return"function"==typeof e[t]&&(this.viewUpdater(e,t,n),!0)}},{key:"viewUpdater",value:function(e,t,n){if("setState"===t)e[t](n);else{var r=this.getCache("name");e[t](n,r)}}},{key:"get",value:function(e){return this._get_data(e)}},{key:"addComponent",value:function(e,t){if(e){t&&!e.ctrlName&&(e.ctrlName=t);var n=this._get_data("components")||[];n.indexOf(e)>=0||n.push(e)}}},{key:"removeComponent",value:function(e){var t=this._get_data("components")||[],n=t.indexOf(e);n<0||t.splice(n,1)}},{key:"_applyState",value:function(e,t,n){var r=this;n||this._set_data(e,t,!0);var a="set".concat(e.charAt(0).toUpperCase()).concat(e.slice(1)),o=this.doPropertyChange(a,t,n);if(o){var i={};i[e]=t,o.forEach(function(e){r.notifyComponent(e,"setState",i)})}}},{key:"getVisible",value:function(e){return this.getState("visible",e)}},{key:"setVisible",value:function(e,t){this._applyState("visible",e,t)}},{key:"getValue",value:function(){return this.getData()}},{key:"setValue",value:function(e,t,n){var r=this,a=this.getValue();if(e!==a){var o={value:e,oldValue:a},i=this._get_data("forceFireEvent");t||i?this.promiseExecute("beforeValueChange",o,[function(){r._set_data("value",e,!0),r._applyState("value",e,n),r.execute("afterValueChange",o)},function(){r._set_data("value",a,!0),r._applyState("value",a,n)}]):(this._set_data("value",e,!0),this._applyState("value",e,n))}}},{key:"getDisabled",value:function(e){return this.getState("disabled",e)}},{key:"setDisabled",value:function(e,t){this._applyState("disabled",e,t)}},{key:"setParent",value:function(e){this.setCache("parent",e)}},{key:"getParent",value:function(){return this.getCache("parent")}},{key:"getRootParent",value:function(){for(var e=this.getParent();null!==(t=e)&&void 0!==t&&t.getParent();){var t;e=e.getParent()}return e}},{key:"setName",value:function(e){this.setCache("name",e)}},{key:"getName",value:function(){return this.getCache("name")}},{key:"setDirty",value:function(e){e?this._set_data("isDirty",!0):(this._del_data("isDirty"),this._set_data("originalData",this.getData()))}},{key:"getDirtyData",value:function(e){var t=this.getData();return!1!==e&&this._get_data("isDirty")||t!==this._get_data("originalData")?t:void 0}},{key:"clear",value:function(e){void 0===e?this._set_data("value",this._get_data("cDefaultValue")):e||this._set_data("value",void 0),this._del_data("isDirty"),this._del_data("checking"),this._del_data("checkMsg")}},{key:"on",value:function(e,t,n){this._get_data("events").on(e,t,n)}},{key:"onFirst",value:function(e,t,n){this._get_data("events").onFirst(e,t,n)}},{key:"execute",value:function(e){for(var t,n=arguments.length,r=new Array(n>1?n-1:0),a=1;a<n;a++)r[a-1]=arguments[a];return(t=this._get_data("events")).execute.apply(t,[e].concat(r))}},{key:"un",value:function(e,t){this._get_data("events").un(e,t)}},{key:"hasEvent",value:function(e){return this._get_data("events").hasEvent(e)}},{key:"fireEvent",value:function(e,t){this._get_data("events").fireEvent(e,t)}},{key:"promiseExecute",value:function(e,t){for(var n,r=arguments.length,a=new Array(r>2?r-2:0),o=2;o<r;o++)a[o-2]=arguments[o];(n=this._get_data("events")).promiseExecute.apply(n,[e,t].concat(a))}},{key:"setCache",value:function(e,t){this._get_data("cache").set(e,t)}},{key:"getCache",value:function(e){return this._get_data("cache").get(e)}},{key:"clearCache",value:function(e){this._get_data("cache").delete(e)}},{key:"setProxy",value:function(e){if(!(e instanceof E)){var t,n=this._get_data("__requestHeaders__");for(var r in e){var a,o,i;if(n&&(null===(a=e[r])||void 0===a||null===(a=a.options)||void 0===a||!a.requestHeaders))null!==(i=e[r])&&void 0!==i&&i.options||(e[r].options={}),e[r].options.requestHeaders=n;null!==(o=this.getProxy())&&void 0!==o&&o[r]&&k()&&console.warn("[devfab][baseModel.prototype.setProxy]: Proxy ".concat(r," already exists on the model. Please change the name of ").concat(r," and try again"))}return this._set_data("proxy",E.create(d(d({},(null===(t=this.getProxy())||void 0===t?void 0:t.config)||{}),e))),this.getProxy()}this._set_data("proxy",e)}},{key:"getProxy",value:function(){return this._get_data("proxy")}}])}(),q=function(){function e(){var t;a(this,e);for(var n=arguments.length,o=new Array(n),i=0;i<n;i++)o[i]=arguments[i];return s(t=r(this,e,[].concat(o)),"modelType","SimpleModel"),t}return c(e,R),i(e,[{key:"getDisabled",value:function(){return this.getState("disabled")}},{key:"setDisabled",value:function(e,t){this._applyState("disabled",e,t)}},{key:"getReadonly",value:function(){return this.getState("readonly")}},{key:"setReadonly",value:function(e,t){this._applyState("readonly",e,t)}}])}(),I=Array.isArray;function T(e){if(I(e))return e.map(T);if(e instanceof Date)return new Date(e.getTime());if(e&&"object"===m(e)){var t={};for(var n in e)t[n]=T(e[n]);return t}return e}function N(e,t,n){var r=this;this.promiseExecute("beforeQuery",{proxyConfig:e,queryParams:t},function(){var a=r,o=r.setProxy({queryData:e}),i=r._get_data("innerUsedAttrs").pageIndex,u={page:s(s({},r._get_data("innerUsedAttrs").pageSize,r.getPageSize()),i,r.getPageIndex())},c=Object.assign(t,u);r.setCache("proxyCache",{proxyConfig:e,params:c,callback:n});if(!1!==r.execute("beforeQueryData",c)){var l=T(c);o.queryData(l,function(e,t,r,a){if(!e){var o=t;this._set_data("dataSourceMode","remote");var i=function(e){if(!e)return[];if(I(e))return e;if(I(e.data))return e.data;if(I(e.records))return e.records;if(I(e.list))return e.list;if(I(e.rows))return e.rows;var t=e.data&&"object"===m(e.data)?e.data:e.result;return I(t)?t:t&&"object"===m(t)&&(t.records||t.list||t.rows||t.data)||[]}(o=Object.assign({},o));this.execute("afterQueryData",o),null==n||n.call(this,i)}},a)}})}function F(e){if(this.execute("beforeSetDataSource",e)){var t=this.getRowKeyField(),n={};e.forEach(function(e){n[e[t]]=e}),this._set_data("keyMap",n),this._set_data("dataSource",e,!0),this.doPropertyChange("setDataSource"),this.execute("afterSetDataSource",e)}}var U=function(){function e(){var t,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};a(this,e);var o,i=d(d({},{columns:{},dataSource:[],rows:[],readOnly:!0,dataSourceMode:"local",columnMode:"local",editMode:"cell",rowKeyField:"id",cellState:{},rowState:{},showCheckBox:!1,multiple:!0,showRowNo:!0,pagination:!0,pageInfo:s(s(s({},(o={id:"_id",selected:"_selected",status:"_status",pageIndex:"pageNo",pageSize:"pageSize",pageCount:"total"}).pageIndex,1),o.pageSize,20),o.pageCount,0),innerUsedAttrs:o,multiRowModel:!1,editRowModels:{},loading:!1,params:{},originalKeyMap:{},defaultRowDatas:new Map}),n);I(i.dataSource)||(i.dataSource=[]),I(i.rows)||(i.rows=[]);var u=function(){return d({},(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).proxyConfig||{})}(n);return i.proxyConfig=u,i.dataSourceMode=n.dataSourceMode||i.dataSourceMode,s(t=r(this,e,[i]),"modelType","GridModel"),t.initColumns(i.columns),t.initPageInfo(n.cPage||n.page),t.afterInit(),t}return c(e,R),i(e,[{key:"afterInit",value:function(){this.execute("afterInit")}},{key:"initColumns",value:function(e){var t=function(e){var t={};return(I(e)?e:Object.keys(e||{}).map(function(t){var n;return d(d({},e[t]||{}),{},{field:(null===(n=e[t])||void 0===n?void 0:n.field)||t})})).forEach(function(e,n){if(e){var r=e.field||e.cFieldName||e.cName||"col_".concat(n);t[r]=d(d({},e),{},{field:r,label:e.label||e.title||e.cCaption||r,index:void 0===e.index?n:e.index})}}),t}(e);return this._set_data("columns",t,!0),t}},{key:"initPageInfo",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=d({},this.getPageInfo()),n=this._get_data("innerUsedAttrs").pageIndex,r=this._get_data("innerUsedAttrs").pageSize;t[n]=e.pageNo||e.pageIndex||t.pageIndex||1,t[r]=e.pageSize||t.pageSize||20,!1===this.get("pagination")&&(t[n]=-1),this._set_data("pageInfo",t)}},{key:"getRowKeyField",value:function(){return this._get_data("rowKeyField")}},{key:"isRemote",value:function(){return"remote"===this._get_data("dataSourceMode")}},{key:"getReadOnly",value:function(){return!!this._get_data("readOnly")}},{key:"setReadOnly",value:function(e){this._applyState("readOnly",!!e)}},{key:"setShowCheckbox",value:function(e){this._applyState("showCheckBox",!!e)}},{key:"setShowRowNo",value:function(e){this._applyState("showRowNo",!!e)}},{key:"getParams",value:function(){return d(d({},this.get("cParams")||{}),this._get_data("params")||{})}},{key:"setParams",value:function(e){this._set_data("params",e||{})}},{key:"getInnerUsedAttrs",value:function(e){var t=this._get_data("innerUsedAttrs");return e?t[e]:t}},{key:"getId",value:function(){return this.getInnerUsedAttrs("id")}},{key:"setDataSource",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2?arguments[2]:void 0;if("local"===this._get_data("dataSourceMode")){F(I(e)?e:[])}else{if(!this.execute("beforeProxyLoad",n))return;this.setPageIndex(1),N.call(this,e,n,function(e){F.call(t,e),null==r||r.call(t)})}}},{key:"reloadData",value:function(){var e=this,t=this.getCache("proxyCache");if(t){var n=t.proxyConfig,r=t.params,a=t.callback;N.call(this,n,r,function(t){null==a||a.call(e,t)})}else k()&&console.log("[devfab][GridModel] proxyConfig is null")}},{key:"getDataSource",value:function(){return this._get_data("dataSource")||[]}},{key:"getData",value:function(e){return e?this._get_data("rows"):this._get_data("dataSource")}},{key:"getAllData",value:function(){return this.getData(!0)}},{key:"clear",value:function(){this._set_data("dataSource",[],!0),this._set_data("rows",[],!0)}},{key:"getPageInfo",value:function(){return this._get_data("pageInfo")}},{key:"getPageIndex",value:function(){var e=this._get_data("innerUsedAttrs").pageIndex;return this.getPageInfo()[e]}},{key:"getPageSize",value:function(){var e=this._get_data("innerUsedAttrs").pageSize;return this.getPageInfo()[e]}},{key:"getTotalCount",value:function(){var e=this._get_data("innerUsedAttrs").pageCount;return this.getPageInfo()[e]}},{key:"setPageInfo",value:function(e){var t=this.getPageInfo();this._set_data("pageInfo",d(d({},t),e)),this.reloadData()}},{key:"setPageIndex",value:function(e){if("number"==typeof e){var t=this._get_data("innerUsedAttrs").pageIndex;this._set_data("pageInfo",d(d({},this.getPageInfo()),{},s({},t,Math.max(1,e))))}}},{key:"setPageSize",value:function(e){if("number"==typeof e){var t=this._get_data("innerUsedAttrs").pageIndex,n=this._get_data("innerUsedAttrs").pageSize;this._set_data("pageInfo",d(d({},this.getPageInfo()),{},s(s({},n,Math.max(-1,e)),t,1)))}}},{key:"setTotalCount",value:function(e){var t=this._get_data("innerUsedAttrs").pageCount;this.getPageInfo()[t]=e}}])}(),H=function(){function e(){var t;a(this,e);for(var n=arguments.length,o=new Array(n),i=0;i<n;i++)o[i]=arguments[i];return s(t=r(this,e,[].concat(o)),"modelType","ViewModel"),t}return c(e,R),i(e,[{key:"getParams",value:function(){return this._get_data("params")}},{key:"setParams",value:function(e){this._set_data("params",e,!0)}},{key:"set",value:function(e,t){t instanceof R&&(t.setParent(this),t.setName(e)),this._set_data(e,t,!0)}},{key:"setData",value:function(e){for(var t in e)this.addProperty(t,e[t])}},{key:"addProperty",value:function(e,t){var n=this.get(e);null!=n&&n.setData?n.setData(t):this.set(e,t)}},{key:"getData",value:function(){var e=this,t=this._get_data("propertyNames")||[],n={};return t.forEach(function(t){var r,a=e.get(t);a instanceof R&&!1!==a._get_data("needCollect")&&(n[t]=null===(r=a.getData)||void 0===r?void 0:r.call(a))}),n}},{key:"getAllData",value:function(e){var t=this,n=this._get_data("propertyNames")||[],r={};return n.forEach(function(n){var a,o=t.get(n);if(o instanceof R&&!1!==o._get_data("needCollect")&&(!e||!o._get_data("isGrid"))){var i=null===(a=o.getData)||void 0===a?void 0:a.call(o);void 0!==i&&(r[n]=i)}}),r}},{key:"removeProperty",value:function(e){var t=this._get_data("propertyNames")||[],n=t.indexOf(e);-1!==n&&t.splice(n,1),this._del_data(e)}},{key:"loadData",value:function(e){this.setCache("isLoadData",!0),this.clear(),this.setData(e),this.setDirty(!1),this.setCache("isLoadData",!1)}},{key:"clear",value:function(e){var t=this;(this._get_data("propertyNames")||[]).forEach(function(n){var r,a=t.get(n);a instanceof R&&!1!==a._get_data("needClear")&&(null===(r=a.clear)||void 0===r||r.call(a,e))})}},{key:"setDirty",value:function(e){e?this._set_data("isDirty",!0):(this._del_data("isDirty"),this._set_data("originalData",this.getData()))}},{key:"getGridModel",value:function(e){var t;if(e)return this.get(e);var n=this._get_data("gridModel");if(n)return n;var r=null===(t=this.getParams())||void 0===t?void 0:t.masterGridModelName;if(r)return this.get(r);for(var a=this._get_data("propertyNames"),o=0,i=a.length;o<i;o++){if((n=this.get(a[o]))instanceof U||"GridModel"==n.modelType)return this._set_data("gridModel",n),n}}},{key:"getGridModels",value:function(){for(var e=this._get_data("propertyNames"),t=[],n=0,r=e.length;n<r;n++){var a=this.get(e[n]);(a instanceof U||"GridModel"==a.modelType)&&t.push(a)}return t}},{key:"getGridFilterModel",value:function(e){return this.getGridModel(e).getCache("FilterViewModel")}}])}();function G(e,t,n,r,a){var o,i=t,s=n,u=r,c=a;Array.isArray(t)&&"function"==typeof n&&(i=void 0,s=t,u=n,c=r);var l=(null===(o=c)||void 0===o?void 0:o.viewModel)||this,f=(s=Array.isArray(s)?s:[]).join(",");if(!e||"function"!=typeof e.inject){var d,v=function(e){return{code:404,message:"params.fileRequire is required, the files: ".concat(e),data:[],warnings:[]}}(f);return k()&&console.error("[devfab][models][extend][loadScripts] ".concat(v.message)),null===(d=u)||void 0===d||d(v),v}return e.inject(i,s,function(e){var t;if(0==e.code&&Array.isArray(e.data))for(var n=0,r=e.data.length;n<r;n++){var a=e.data[n];if(a&&a.doAction)try{a.doAction("init",l)}catch(t){e.code=500,e.message="".concat(f," script execute error"),e.error=t;break}else try{var o;"function"==typeof(null===(o=c)||void 0===o?void 0:o.onFileBack)&&c.onFileBack(a,n)}catch(t){e.code=500,e.message="".concat(f," script customize execute error");break}}0!=e.code&&k()&&console.info("[devfab][models][extend][loadScripts] ".concat(f," \n [message]: ").concat(e.message," \n").concat(e.error?" \n [error]: ":""),e.error),null===(t=u)||void 0===t||t(e)})}function V(e){var t=this;window.__devfab&&window.__devfab.__debugger_initExtendJs;var n=e.fileRequire,r=e.extendScriptParams,a=e.readyEventName,o=void 0===a?"extendReady":a,i=r||{},s=i.enableJs,u=void 0!==s&&s,c=i.filepath,l=i.scriptUrl;if(!u)return k()&&console.info("[devfab][extend][js] not enable extend script"),void t.execute(o,t);if(!l)return k()&&console.info("[devfab][extend][js] extend script is not defined"),void t.execute(o,t);var f=c,d=[l];t.getEnv&&t.getEnv("everyCommonExtend")&&d.push(t.getEnv("everyCommonExtend")),G.call(t,n,f,d,function(e){t.execute(o,t,e)})}var L=function(){var e=n(v().m(function e(t,r,a){var o,i,s,u,c,l,f,d,h,y,p;return v().w(function(e){for(;;)switch(e.n){case 0:if(window.__devfab&&window.__devfab.__debugger_initExtJs,s=a.fileRequire,u=a.extendScriptParams,l=(c=u||{}).enableExtJs,f=void 0!==l&&l,d=c.exturlsField,h=void 0===d?"extscripturls":d,f){e.n=1;break}return k()&&console.info("[devfab][extend][exturls] ext script is not enable"),e.a(2,Promise.resolve(!0));case 1:if(t){e.n=2;break}return k()&&console.info("[devfab][extend][exturls] script data is null"),e.a(2,Promise.resolve(!0));case 2:if(y=null==t?void 0:t[h],p=Array.isArray(y)?y:[],p=(p=(r.getCache("localScripts")||[]).concat(p)).concat(window.__devfab__GLOBAL_EXT_SCRIPTS__||[]),null!==(o=r.getParams())&&void 0!==o&&o.selfExtUrls&&(p=p.concat([r.getParams().selfExtUrls])),null===(i=p)||void 0===i||!i.length){e.n=4;break}return p=g(new Set(p)),e.n=3,Promise.all(p.map(function(){var e=n(v().m(function e(t){return v().w(function(e){for(;;)if(0===e.n)return e.a(2,t)},e)}));return function(t){return e.apply(this,arguments)}}()));case 3:p=e.v;case 4:return t[h]=p,e.a(2,new Promise(function(e,t){G.call(r,s,p,function(t){e(t)})}))}},e)}));return function(t,n,r){return e.apply(this,arguments)}}(),B=R,z=q,X=H,J=U;function K(e){var t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=n.modelNameField,s=void 0===o?"cName":o,u=function(e){function t(){return a(this,t),r(this,t,arguments)}return c(t,e),i(t,[{key:"init",value:function(e,t){var n=this.createModels(e,t);this.setData(n),this.setDirty(!1)}},{key:"createModels",value:function(e,t){var r={};return(Array.isArray(e)?e:[]).forEach(function(e){var t,a,o=function(e,t){var n=(null==t?void 0:t.SimpleModel)||q,r=e.cControlType||e.component||e.controlType||e.ctrlType;return r=r.toLowerCase(),new n(e)}(e,n),i={model:o,meta:e,childModel:!0,modelName:e[s]};null==n||null===(t=n.onBeforeInitModel)||void 0===t||t.call(n,i),r[i.modelName]=i.model,null==n||null===(a=n.onAfterInitModel)||void 0===a||a.call(n,i)}),r}},{key:"initData",value:function(){V.call(this,n)}}])}((null==n||null===(t=n.models)||void 0===t?void 0:t.ViewModel)||H);return u.prototype.modelType="ViewModel",u}var Q={models:Object.freeze({__proto__:null,BaseModel:B,SimpleModel:z,GridModel:J,ViewModel:X,initViewModel:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2?arguments[2]:void 0,a=function(e,t){var n,r,a,o=new(K(e,t)),i={model:o,meta:e};return null==t||null===(n=t.onBeforeInitModel)||void 0===n||n.call(t,i),i.model=o,null==o||null===(r=o.init)||void 0===r||r.call(o,e.models,e),null==t||null===(a=t.onAfterInitModel)||void 0===a||a.call(t,i),o}(e,t);return a.on("destroyVM",function(){var e,t;null===(e=a)||void 0===e||null===(t=e.destroyVM)||void 0===t||t.call(e),a=null,k()&&console.info("[devfab][models][initVM]: destory vm ".concat((new Date).toString()))}),a.on("extendReady",n(v().m(function n(){var o;return v().w(function(n){for(;;)switch(n.n){case 0:return(o=[]).push(L(e,a,t)),n.n=1,Promise.all(o);case 1:k()&&console.info("[devfab][models][initVM]: after vm init ".concat((new Date).toString())),null==r||r(a,e);case 2:return n.a(2)}},n)}))),a.initData(),a},loadScripts:G}),Builder:O,Cache:M,Event:D,Ajax:E};exports.default=Q;
|