devfab 1.1.0 → 1.2.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/dist/index.esm.js CHANGED
@@ -1 +1,3 @@
1
- function e(e,t){(null==t||t>e.length)&&(t=e.length);for(var a=0,n=Array(t);a<t;a++)n[a]=e[a];return n}function t(e,t,a){return t=o(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,u()?Reflect.construct(t,a||[],o(e).constructor):t.apply(e,a))}function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function n(e,t){for(var a=0;a<t.length;a++){var n=t[a];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,v(n.key),n)}}function i(e,t,a){return t&&n(e.prototype,t),a&&n(e,a),Object.defineProperty(e,"prototype",{writable:!1}),e}function r(e,t,a){return(t=v(t))in e?Object.defineProperty(e,t,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[t]=a,e}function o(e){return o=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},o(e)}function s(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&&h(e,t)}function u(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(u=function(){return!!e})()}function l(e,t){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),a.push.apply(a,n)}return a}function c(e){for(var t=1;t<arguments.length;t++){var a=null!=arguments[t]?arguments[t]:{};t%2?l(Object(a),!0).forEach(function(t){r(e,t,a[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(a)):l(Object(a)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(a,t))})}return e}function d(e,t){if(null==e)return{};var a,n,i=function(e,t){if(null==e)return{};var a={};for(var n in e)if({}.hasOwnProperty.call(e,n)){if(-1!==t.indexOf(n))continue;a[n]=e[n]}return a}(e,t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);for(n=0;n<r.length;n++)a=r[n],-1===t.indexOf(a)&&{}.propertyIsEnumerable.call(e,a)&&(i[a]=e[a])}return i}function h(e,t){return h=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},h(e,t)}function f(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var a=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=a){var n,i,r,o,s=[],u=!0,l=!1;try{if(r=(a=a.call(e)).next,0===t){if(Object(a)!==a)return;u=!1}else for(;!(u=(n=r.call(a)).done)&&(s.push(n.value),s.length!==t);u=!0);}catch(e){l=!0,i=e}finally{try{if(!u&&null!=a.return&&(o=a.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}(e,t)||p(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)||p(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 v(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var a=e[Symbol.toPrimitive];if(void 0!==a){var n=a.call(e,t||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}function y(e){return y="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},y(e)}function p(t,a){if(t){if("string"==typeof t)return e(t,a);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?e(t,a):void 0}}var w=["component","children","render"],m=!1,S={},k=null;function x(e){return S[e]}function R(e,t){if(Array.isArray(e)){var a=[];return e.forEach(function(e,n){var i=e.component,r=e.children,o=e.render,s=d(e,w),u=x(i);u||"function"==typeof o||console.log("[warning] Component ".concat(i," is not registered!"));var l={component:u,children:R(r,t)};s.index=n;var c=Object.assign({},null==t?void 0:t.props,s);"function"==typeof o?a.push(o({node:l,props:c})):"function"==typeof k?a.push(k({node:l,props:c})):(Object.assign(l,c),a.push(l))}),a}}var b=function(){return i(function e(){a(this,e)},[{key:"init",value:function(e){m||("function"==typeof e&&e(),m=!0)}},{key:"initComponent",value:function(e,t){!function(e,t){if(e)"string"==typeof e?S[e]?console.log("[warning] Component ".concat(e," is exist!")):S[e]=t:Object.assign(S,e)}(e,t)}},{key:"getComponents",value:function(){return c({},S)}},{key:"getComponent",value:function(e){return x(e)}},{key:"hasComponent",value:function(e){return!!x(e)}},{key:"initRenderFactory",value:function(e){!function(e){k=e}(e)}},{key:"initRequest",value:function(){}},{key:"render",value:function(e,t){return R(e,t)}},{key:"clear",value:function(){S={},k=null,m=!1}}])}(),C=function(){return i(function e(t){a(this,e),this._init(t)},[{key:"_init",value:function(e){this.cache=Object.assign({},e)}},{key:"set",value:function(e,t){this.cache[e]=t}},{key:"get",value:function(e){var t;return null===(t=this.cache)||void 0===t?void 0:t[e]}},{key:"clear",value:function(e){delete this.cache[e]}}])}(),I=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,a){var n=this.events.get(e);Array.isArray(n)||(n=[]),n.push({callback:t,context:a}),this.events.set(e,n)}},{key:"onFirst",value:function(e,t,a){var n=this.firstevents.get(e);Array.isArray(n)||(n=[]),n.splice(0,0,{callback:t,context:a}),this.firstevents.set(e,n)}},{key:"execute",value:function(e){for(var t=arguments.length,a=new Array(t>1?t-1:0),n=1;n<t;n++)a[n-1]=arguments[n];var i=this.events.get(e),r=this.firstevents.get(e);if(!i&&!r)return!0;var o=!0;return[].concat(g(r||[]),g(i||[])).forEach(function(e){if(!1!==o){var t=e.callback.apply(e.context||void 0,a);o=!1!==t&&o}}),o}},{key:"un",value:function(e,t){this._unEvents(e,t,this.events),this._unEvents(e,t,this.firstevents)}},{key:"_unEvents",value:function(e,t,a){if(e&&a.has(e))if(t){var n=a.get(e),i=null==n?void 0:n.findIndex(function(e){return e.callback===t});-1!==i&&(null==n||n.splice(i,1))}else a.delete(e)}},{key:"hasEvent",value:function(e){var t,a;return e?((null===(t=this.events.get(e))||void 0===t?void 0:t.length)||0)+((null===(a=this.firstevents.get(e))||void 0===a?void 0:a.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,a){for(var n,i=this,r=a.resolve,o=a.reject,s=a.args,u=!0,l=t||[],c=!1,d=function(t){var a,n=l[t];if(!1===u)return 0;if(c)return{v:void 0};if("development"===process.env.nodeEnv)a=n.callback.apply(n.context||i,s);else try{a=n.callback.apply(n.context||i,s)}catch(e){throw e.isAddedMsg||(e.message="(领域扩展事件执行失败,请打开控制台查看详细错误信息并修复):".concat(e.message)),e.isAddedMsg=!0,e}a instanceof Promise?(c=!0,(u=a).callbacks&&u.callbacks.push({reject:function(){u.reject(),t===l.length-1&&(null==o||o())},resolve:function(a){t===l.length-1?(s.length>1&&(s[0]=a),null==r||r(s)):i._asyncExecute(e,l.slice(t+1),{resolve:r,reject:o,args:s})}})):(u=!1!==a&&u,t===l.length-1&&(u?null==r||r(s):null==o||o()))},h=0;h<l.length&&0!==(n=d(h));h++)if(n)return n.v;return u}},{key:"_asyncPromiseExecute",value:function(e,t,a,n){var i=this.events.get(e),r=this.firstevents.get(e);if(!((Array.isArray(i)?i.length:i)||(Array.isArray(r)?r.length:r)))return null==t?void 0:t();var o=[].concat(g(r||[]),g(i||[]));return this._asyncExecute(e,o,{resolve:t,reject:a,args:n})}},{key:"promiseExecute",value:function(e,t){var a=this,n=e,i=1;if("boolean"==typeof e&&(n=t,i=2),n){for(var r=arguments.length,o=new Array(r>2?r-2:0),s=2;s<r;s++)o[s-2]=arguments[s];var u=2===i?o:[t].concat(o);if(u.length){var l,c=u.length-1,d=u[c];if("function"!=typeof d){if("object"!==y(d)||!d[0]||"function"!=typeof d[0]||!d[1]||"function"!=typeof d[1])return;l=d[1],d=d[0]}if(this.__ASYNC_EXECUTE__)return this._asyncPromiseExecute(n,function(e){d.apply(a,e)},function(){l&&"function"==typeof l&&l()},u);u.splice(c,1),u.unshift(n);var h=this.execute.apply(this,u);if(h instanceof Promise){var f=this;h.then(function(){for(var e=arguments.length,t=new Array(e),a=0;a<e;a++)t[a]=arguments[a];d.apply(f,t)},function(){l&&"function"==typeof l&&l()})}else if(!h)return void(l&&"function"==typeof l&&l())}}}},{key:"clearEvents",value:function(){this.events.clear(),this.firstevents.clear()}}])}();function P(e){this.pathname="",this.query={};var t=e;this.init=function(){t||(t=location.search);var e=t.indexOf("?"),a=t.indexOf("#");if(e>=0){if(this.pathname=t.substr(0,e),(t=a<0?t.substr(e+1):t.substring(e+1,a)).length>0)for(var n=(t=t.replace(/\+/g," ")).split("&"),i=0,r=n.length;i<r;i++){var o=n[i]||"";if(o){var s=o.indexOf("="),u="",l="";s<0?l=u=window.decode(o):(u=window.decode(o.substr(0,s)),l=window.decode(o.substr(s+1))),this.query[u]=l}}}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 D(e,t){if(!t)return e;var a=[],n=new P(e);for(var i in t)n.get(i)||a.push("".concat(i,"=").concat(t[i]));if(!a.length)return e;var r=a.join("&");return e.indexOf("?")>=0?"".concat(e,"&").concat(r):"".concat(e,"?").concat(r)}String.prototype.equalsIgnoreCase=function(e){return null!=e&&this.toLowerCase()===e.toLowerCase()};var E=["onBeforeRequest","_onAfterRequest"],O=["_onBeforeRequest","onAfterRequest"];var q={_xhrs:[],_jsonps:{index:0},doRequest:function(e){var t=e||{},a=t.onBeforeRequest;t._onAfterRequest;var n,i=d(t,E),r=i.method||"GET",o=i.url;try{null!=i&&i.requestHeaders&&(n=i.requestHeaders,i.requestHeaders=void 0,delete i.requestHeaders)}catch(e){console.log('[ajax]: [doRequest]: options["requestHeaders"] ERR : ',e)}try{i.params&&i.params.requestHeaders&&(n=i.params.requestHeaders,i.params.requestHeaders=void 0,delete i.params.requestHeaders)}catch(e){console.log('[ajax]: [doRequest]: options.params["requestHeaders"] ERR : ',e)}var s=null;if(r.equalsIgnoreCase("get")||r.equalsIgnoreCase("delete")?o=D(o,i.params):(r.equalsIgnoreCase("post")||r.equalsIgnoreCase("put"))&&(s=JSON.stringify(i.params)),i.jsonp)return this.getJsonp(o,i.callback);var u=this.getXMLHttpRequest();if(u){var l;if(u.open(r,o,!1!==i.async),i.timeout&&(u.timeout=i.timeout,u.setRequestHeader("timeout",i.timeout),u.ontimeout=function(){q.onerror(this,i,"timeout")}),i.contentType){if(u.setRequestHeader("Content-Type",i.contentType),i.contentType.indexOf("x-www-form-urlencoded")>=0)s=null===(l=new URLSearchParams(i.params))||void 0===l?void 0:l.toString()}else i.dateType?s=i.params:u.setRequestHeader("Content-Type","application/json;charset=utf-8");i.domainKey&&u.setRequestHeader("Domain-Key",i.domainKey);try{if(n&&"[object Object]"===Object.prototype.toString.call(n))for(var c in n)u.setRequestHeader(c,n[c])}catch(e){console.log('[ajax]: [doRequest]: options.params["requestHeaders"] ERR : ',e)}u.withCredentials=null==i||!i.hasOwnProperty("withCredentials")||i.withCredentials;try{u.send(s)}catch(e){return{error:"NetWorkError",options:i}}if(!1===i.async)return null==a||a(i),this.onreadystatechange(u,i);u.onreadystatechange=function(){q.onreadystatechange(this,i)},null==a||a(i)}},beforeReadystatechange:function(e,t,a){null==a||a()},onreadystatechange:function(e,t){var a=t||{};a._onBeforeRequest;var n=a.onAfterRequest,i=d(a,O);if(4===e.readyState){if(null==n||n(),200===e.status){var r;try{if("blob"===i.responseType){var o=function(e){var t=e.xhr.getAllResponseHeaders(),a={};return t.split("\r\n").map(function(e){var t=f(e.split(": "),2),n=t[0],i=t[1];a[n]=i}),a}({xhr:e});r={code:e.status,data:{data:e.response,headers:o}}}else r=JSON.parse(e.responseText)}catch(t){q.onerror(e,i,e.responseText)}if(!1===i.async)return e.isBusy=!1,i.precallback&&i.precallback(r),q.processAjaxResult(r,!1,null,null,i,e);q.processAjaxResult(r,i.async,i.callback,i.context,i,e),i.precallback&&i.precallback(r)}else if(0===e.status)q.onerror(e,i,"网络连接已断开,请检查设备网络状态后重试");else if(502===e.status||504===e.status)q.onerror(e,i,"服务出错了,请稍后再试");else{if(401!==e.status){var s={};try{s=JSON.parse(e.responseText)}catch(t){s={code:e.status,message:e.responseText}}return q.onerror(e,i,s)}q.onerror(e,i,"登录信息失效,请重新登录或联系技术人员")}e.isBusy=!1}},onerror:function(e,t,a){var n="[ajax]: [onerror]: 接口返回错误 \n [状态码]: ".concat(e.status," \n [错误信息]: ").concat(("object"===y(a)?JSON.stringify(a):a)||"空"," \n [请求地址]: ").concat(t.url," \n [浏览器Token]: ").concat(document.cookie);console.log("Error.E01000",n);var i="object"===y(a)?a:{code:500,message:a};t.precallback&&t.precallback(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 a=e,n="callback"+this._jsonps.index++,i=document.createElement("script");this._jsonps[n]=function(e){try{t(e)}finally{document.body.removeChild(i)}},a+=-1===a.indexOf("?")?"?":"&callback=cb.rest.AjaxRequestManager._jsonps."+n,i.src=a,document.body.appendChild(i)},processAjaxResult:function(e,t,a,n,i,r){if(e){if(!e.code)return!1===t?e:void(a&&a.call(n,null,e));if(200==e.code){if(!1===t)return{result:e.data};a&&a.call(n,null,e.data,e.message,e.errorDetail,e.code,e.displayCode&&e)}else{if(!1===t)return{error:e};a&&a.call(n,e)}}}};function j(e,t){this.init&&this.init(e),this.queryParams=t}j.create=function(e,t){return new j(e,t)},j.prototype.init=function(e){if(e)for(var t in this.config=e,this.config)this[t]=function(e){return function(t,a,n){return this.Do(e,t,a,null,n)}}(t),this["".concat(t,"Sync")]=function(e){return function(t){return this.Do(e,t,null,!1)}}(t)},j.prototype.Do=function(e,t,a,n,i){var r,o,s;if(this.config&&this.config[e]&&this.config[e].url){var u=this.config[e],l=u.url;this.queryParams||(this.queryParams={}),null!==(r=u.options)&&void 0!==r&&r.proxyServiceCode&&(this.queryParams.serviceCode=u.options.proxyServiceCode),null!==(o=u.options)&&void 0!==o&&o.billnum&&(this.queryParams.billnum=u.options.billnum),null!==(s=this.queryParams)&&void 0!==s&&s.serviceCode&&(l=D(l,this.queryParams));var c=l,d=Object.assign({},u.options);return d.method=u.method||"GET","function"==typeof t?(d.callback=t,d.context=i||d.context||this):d.params=t,a&&(d.callback=a,d.context=i||d.context||this),!1===n&&(d.async=!1),this.ajax(c,d)}},j.prototype.ajax=function(e,t){return function(e,t){return t.url=e,q.doRequest(t)}(e,t)};var M=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 a in e)t.push(a);Object.assign(this._data,{components:[],propertyNames:t},e),this._data.cache=new C,this._data.events=new I}},{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 C,events:new I}}},{key:"_set_data",value:function(e,t,a){if(e){if(a){var n=this._data.propertyNames||[];n.indexOf(e)<0&&n.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 a;if(!t)return this._get_data(e);var n=(this._get_data("components")||[]).find(function(e){return e.ctrlName===t});return n?null===(a=n.getState)||void 0===a?void 0:a.call(n,e):this._get_data(e)}},{key:"setState",value:function(e,t,a){a||this._set_data(e,t,!0);var n={};n[e]=t,this.doPropertyChange("setState",n,a)}},{key:"doPropertyChange",value:function(e,t,a){var n=this,i=this._get_data("components")||[];if(!i.length)return i;var r=[];if(a){var o=i.find(function(e){return e.ctrlName===a});o&&!this.notifyComponent(o,e,t)&&r.push(o)}else i.forEach(function(a){n.notifyComponent(a,e,t)||r.push(a)});return r.length?r:void 0}},{key:"notifyComponent",value:function(e,t,a){return"function"==typeof e[t]&&(this.viewUpdater(e,t,a),!0)}},{key:"viewUpdater",value:function(e,t,a){if("setState"===t)e[t](a);else{var n=this.getCache("name");e[t](a,n)}}},{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 a=this._get_data("components")||[];a.indexOf(e)>=0||a.push(e)}}},{key:"removeComponent",value:function(e){var t=this._get_data("components")||[],a=t.indexOf(e);a<0||t.splice(a,1)}},{key:"_applyState",value:function(e,t,a){var n=this;a||this._set_data(e,t,!0);var i="set".concat(e.charAt(0).toUpperCase()).concat(e.slice(1)),r=this.doPropertyChange(i,t,a);if(r){var o={};o[e]=t,r.forEach(function(e){n.notifyComponent(e,"setState",o)})}}},{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,a){var n=this,i=this.getValue();if(e!==i){var r={value:e,oldValue:i},o=this._get_data("forceFireEvent");t||o?this.promiseExecute("beforeValueChange",r,[function(){n._set_data("value",e,!0),n._applyState("value",e,a),n.execute("afterValueChange",r)},function(){n._set_data("value",i,!0),n._applyState("value",i,a)}]):(this._set_data("value",e,!0),this._applyState("value",e,a))}}},{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,a){this._get_data("events").on(e,t,a)}},{key:"onFirst",value:function(e,t,a){this._get_data("events").onFirst(e,t,a)}},{key:"execute",value:function(e){for(var t,a=arguments.length,n=new Array(a>1?a-1:0),i=1;i<a;i++)n[i-1]=arguments[i];return(t=this._get_data("events")).execute.apply(t,[e].concat(n))}},{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 a,n=arguments.length,i=new Array(n>2?n-2:0),r=2;r<n;r++)i[r-2]=arguments[r];(a=this._get_data("events")).promiseExecute.apply(a,[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").clear(e)}},{key:"setProxy",value:function(e){if(!(e instanceof j)){var t,a=this._get_data("__requestHeaders__");for(var n in e){var i,r,o;if(a&&(null===(i=e[n])||void 0===i||null===(i=i.options)||void 0===i||!i.requestHeaders))null!==(o=e[n])&&void 0!==o&&o.options||(e[n].options={}),e[n].options.requestHeaders=a;null!==(r=this.getProxy())&&void 0!==r&&r[n]&&console.warn("[baseModel.prototype.setProxy]: Proxy ".concat(n," already exists on the model. Please change the name of ").concat(n," and try again"))}return this._set_data("proxy",j.create(c(c({},(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")}}])}(),A=function(){function e(){return a(this,e),t(this,e,arguments)}return s(e,M),i(e,[{key:"mounted",value:function(){var e=this,t=this.get("conditions"),a={};t.forEach(function(t){e.get(t.name),a[t.name]=t.defaultValue}),this._set_data("params",a)}},{key:"unmounted",value:function(){this._set_data("params",{}),this._set_data("conditions",[])}},{key:"getParams",value:function(){var e=this,t={};return this.get("conditions").forEach(function(a){var n=e.get(a.name);t[a.name]=null==n?void 0:n.getValue()}),this._set_data("params",t),t}},{key:"search",value:function(){var e=this.getParams();this.execute("search",e)}}])}(),F=function(){function e(n){return a(this,e),t(this,e,[n])}return s(e,M),i(e,[{key:"getDisabled",value:function(){return this.getState("disabled")}},{key:"setDisabled",value:function(e){return this.setState("disabled",!!e)}},{key:"getReadonly",value:function(){return this.getState("readonly")}},{key:"setReadonly",value:function(e){this.setState("readonly",!!e)}}])}(),N="",K="Insert",T="Update",V="Delete",B=Array.isArray,H=function(e){return null==e||""===e},U=function(e){return!e||0===Object.keys(e).length};function z(e){if(B(e))return e.map(z);if(e instanceof Date)return new Date(e.getTime());if(e&&"object"===y(e)){var t={};for(var a in e)t[a]=z(e[a]);return t}return e}function L(e){var t={};return(B(e)?e:Object.keys(e||{}).map(function(t){var a;return c(c({},e[t]||{}),{},{field:(null===(a=e[t])||void 0===a?void 0:a.field)||t})})).forEach(function(e,a){if(e){var n=e.field||e.cCaption||e.cFieldName||"col_".concat(a);t[n]=c(c({},e),{},{field:n,fieldName:e.fieldName||n,cCaption:e.cCaption||n,index:void 0===e.index?a:e.index})}}),t}function J(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=this.getIdFlag(),a=this.getRowKeyField(),n=this._get_data("rowIdSeq")||0;return e.forEach(function(e){if(e&&void 0===e[t]){var i=e[a];null!=i&&""!==i?e[t]=String(i):(n+=1,e[t]="rowId_".concat(n))}}),this._set_data("rowIdSeq",n),e}var X=function(e,t,a,n,i,r,o){var s=this;this.promiseExecute("beforeBatchModifyPull",function(){var r=s.setProxy({queryData:e}),o={page:{pageSize:s.getPageSize(),pageIndex:s.getPageIndex()}};o.page.pageSize||(s.setPageSize(10),o.page.pageSize=10);var u=s._get_data("bLoadPagination");u||i||(o.page.totalCount=1);var l=s._get_data("delayLoadPageInfo");u&&l&&(n&&s.setState("showDelayPagination",!0),o.page.totalCount=1);var c=Object.assign(o,t);s.setCache("proxyCache",{proxyConfig:e,params:c});var d=0,h={},f=s.getRootParent(),g=s,v=(new Date).valueOf();c.queryId=v;if(!1!==f.execute("beforeQueryData",c)){g.setCache("lastGridFilterCondition",JSON.stringify(null==c?void 0:c.condition));var y=_.cloneDeep(c);if(r.queryData(y,function(e,t,r,o){var s,c;if(setTimeout(function(){g.clearCache("isGridInLoading")},0),null==f||f.clearCache("lazySearch"),e)return this.setState("showDelayPagination",!1),void this.clearCache("setPageIndexFromBack");t=t||{},this._set_data("dataSourceMode","remote"),n&&u&&l&&(d++,t=Object.assign(h,t));var v=Array.isArray(t.recordList)?t.recordList:[];if(u&&l&&2!==d||!a||a.call(this,t,r,o),this.getCache("setPageIndexFromBack"),this.clearCache("setPageIndexFromBack"),this.execute("beforeSetDataSource",v)){var y=this._get_data("rowKeyField"),p={};v.forEach(function(e){p[e[y]]=e}),this._set_data("keyMap",p),n||!1!==this._get_data("override")?(this._set_data("dataSource",v,!0),this.doPropertyChange("resetCellStatus"),this._set_data("cellState",{},!0),this._set_data("rowState",{},!0)):this._set_data("dataSource",this._get_data("dataSource").concat(v),!0),this.setCache("currentGridData",v),v.length&&J.call(this,v),this.initRowState(),setCachePaginationRowData.call(this,v),this._get_data("sortParams");var _=this._get_data("colFilterParams");this.showRows(null,!cb.utils.isEmptyObject(_));var w=this._get_data("pageInfo");u&&!l&&(this._get_data("bLoadPagination")||i)?(w={pageSize:t.pageSize,pageIndex:t.pageIndex,pageCount:t.pageCount,recordCount:t.recordCount},this.setPageInfo(w)):(w.pageIndex=t.pageIndex,w.from="showPageInner",this.setPageInfo(w)),resetSelected.call(this),"splitview"!==(null===(s=this.getParent)||void 0===s||null===(s=s.call(this))||void 0===s||null===(c=s.getParams)||void 0===c||null===(c=c.call(s))||void 0===c?void 0:c.templateType)&&this._set_data("focusedRowIndex",-1);for(var m=arguments.length,S=new Array(m>4?m-4:0),k=4;k<m;k++)S[k-4]=arguments[k];this.execute("afterSetDataSource",v,t.viewmodel,null==S?void 0:S[1])}},s),n&&u&&l){var p=JSON.parse(JSON.stringify(e));p.options||(p.options={}),p.options.mask=!1;G.call(s,p,c,function(e){!function(e){d++,Object.assign(h,e),2===d&&a&&a.call(s,h)}(e)})}}})};function G(e,t,a){this.setCache("queryPageCountLoading",!0);var n=this.setProxy({queryPageCount:c({},e)}),i=Object.assign(!0,t,{page:{totalCount:-1}});this.__queryPageCountRequestId||(this.__queryPageCountRequestId=0),this.__queryPageCountRequestId++;n.queryPageCount(i,function(e,t,n){if(this.__queryPageCountRequestId===e)if(this.setCache("queryPageCountLoading",!1),this.setState("showDelayPagination",!1),t){var i=this._get_data("pageInfo");i&&this.setPageInfo(i)}else{var r={beginPageIndex:(n=n||{}).beginPageIndex,endPageIndex:n.endPageIndex,pageSize:n.pageSize,pageIndex:n.pageIndex,pageCount:n.pageCount,recordCount:n.recordCount};a&&a.call(this,r),this.setPageInfo(r),this.execute("afterQueryPageInfo",n)}}.bind(this,this.__queryPageCountRequestId),this)}var Y=function(){function e(){var n,i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};a(this,e);var r=c(c({},{columns:{},dataSource:[],rows:[],readOnly:!0,dataSourceMode:"local",columnMode:"local",editMode:"cell",cellState:{},rowState:{},showCheckBox:!0,multiple:!0,showRowNo:!0,pagination:!0,pageInfo:{pageIndex:1,pageSize:20,pageCount:0},innerUsedAttrs:{id:"_id",selected:"_selected",status:"_status"},multiRowModel:!1,editRowModels:{},loading:!1,params:{},originalKeyMap:{},defaultRowDatas:new Map}),i);B(r.dataSource)||(r.dataSource=[]),B(r.rows)||(r.rows=[]);var o=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=c({},e.proxyConfig||{});return"function"==typeof e.dataSource&&(t.load=t.load||e.dataSource),"string"==typeof e.cUrl&&(t.load=t.load||e.cUrl),t.load||"string"!=typeof e.url||(t.load=e.url),t}(i);r.proxyConfig=o,r.dataSourceMode=i.dataSourceMode||(o.load?"remote":"local");var s=i.cData||(B(i.data)?i.data:null);return(n=t(this,e,[r])).initPageInfo(i.cPage||i.page),n.initColumns(r.columns),n.initRowState(),n.afterInit(),s&&n.setDataSource(s),n}return s(e,M),i(e,[{key:"afterInit",value:function(){"single"===this._get_data("parentRelation")&&this._set_data("defaultSelectedRowIndexes",!0)}},{key:"initColumns",value:function(e){var t=L(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=c({},this.getPageInfo());t.pageIndex=e.pageNo||e.pageIndex||t.pageIndex||1,t.pageSize=e.pageSize||t.pageSize||20,!1===this.get("pagination")&&(t.pageSize=-1),this.applyPageInfo(t)}},{key:"initRowState",value:function(){var e=this,t=this._get_data("dataSource");this._set_data("rowsDataState",(B(t)?t:[]).map(function(t){return(null==t?void 0:t[e.getStatusFlag()])||N}),!0)}},{key:"getInnerUsedAttrs",value:function(){return this._get_data("innerUsedAttrs")}},{key:"getIdFlag",value:function(){return this.getInnerUsedAttrs().id}},{key:"getSelectedFlag",value:function(){return this.getInnerUsedAttrs().selected}},{key:"getStatusFlag",value:function(){return this.getInnerUsedAttrs().status}},{key:"getRowKeyField",value:function(){return this._get_data("rowKeyField")||"id"}},{key:"getProxyConfig",value:function(){return this._get_data("proxyConfig")||{}}},{key:"isRemote",value:function(){return"remote"===this._get_data("dataSourceMode")}},{key:"isPagination",value:function(){return!!this.get("pagination")&&-1!==this.getPageSize()}},{key:"getReadOnly",value:function(){return!!this._get_data("readOnly")}},{key:"setReadOnly",value:function(e){this._applyState("readOnly",!!e)}},{key:"getParams",value:function(){return c(c({},this.get("cParams")||{}),this._get_data("params")||{})}},{key:"setParams",value:function(e){this._set_data("params",e||{})}},{key:"setMeta",value:function(e){this._set_data("meta",e)}},{key:"getColumns",value:function(e){var t=this._get_data("columns")||{},a={};return(e?B(e)?e:[e]:Object.getOwnPropertyNames(t)).forEach(function(e){t[e]&&(a[e]=c(c({},t[e]),{},{fieldName:t[e].fieldName||e}))}),a}},{key:"getColumn",value:function(e){var t,a=null===(t=this._get_data("columns"))||void 0===t?void 0:t[e];return a?c(c({},a),{},{fieldName:a.fieldName||e}):void 0}},{key:"hasColumn",value:function(e){return!!(this._get_data("columns")||{})[e]}},{key:"getColumnList",value:function(e){var t=this.getColumns(e);return Object.keys(t).sort(function(e,a){return(t[e].index||0)-(t[a].index||0)}).map(function(e){return t[e]})}},{key:"getVisibleColumns",value:function(e){return this.getColumnList(e).filter(function(e){return!0!==e.bHidden&&!1!==e.bShowIt})}},{key:"setColumns",value:function(e){e&&this._applyState("columns",L(e))}},{key:"setColumnMode",value:function(e){this._set_data("columnMode","remote"===e?"remote":"local",!0)}},{key:"addColumns",value:function(e){var t=L(e);this._applyState("columns",c(c({},this._get_data("columns")||{}),t))}},{key:"resetColumns",value:function(e){this.setColumns(e||this.get("cColumns"))}},{key:"getColumnState",value:function(e,t,a){var n,i=this.getRowKey(e);return i?((null===(n=this._get_data("cellState"))||void 0===n||null===(n=n[i])||void 0===n?void 0:n[t])||{})[a]:void 0}},{key:"setColumnState",value:function(e,t,a,n){this.setCellState(e,t,a,n)}},{key:"setColumnStates",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];this.setCellStates(e.map(function(e){return c(c({},e),{},{cellName:e.cellName||e.columnName})}))}},{key:"setColumnValue",value:function(e,t,a){var n=this._get_data("columns")||{};n[e]&&this._applyState("columns",c(c({},n),{},r({},e,c(c({},n[e]),{},r({},t,a)))))}},{key:"load",value:function(e,t,a){this.setProxy({load:e}).load(t,function(e,t){e?cb.utils.alert(e,"error"):(t.schema&&(this._set_data("columnMode","remote"),this.setColumns(t.schema)),this.setDataSource(t.data),a&&a.call(this))},this)}},{key:"refresh",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this.hasEvent("refresh")?this.execute("refresh",e):this.fetch({body:e})}},{key:"loadData",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this.refresh(e)}},{key:"queryData",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this.refresh(e)}},{key:"getDataSource",value:function(){var e=this._get_data("dataSource")||[];if(!this.hasDeletedRow())return e;var t=this._get_data("rowsDataState")||[];return e.filter(function(e,a){return t[a]!==V})}},{key:"getRealData",value:function(){return this.getDataSource()}},{key:"getRealRows",value:function(){return this._get_data("rows")||[]}},{key:"getRowsCount",value:function(){return(this._get_data("rows")||[]).length}},{key:"getDataSourceCount",value:function(){return(this._get_data("dataSource")||[]).length}},{key:"hasDeletedRow",value:function(){return(this._get_data("rowsDataState")||[]).some(function(e){return e===V})}},{key:"getData",value:function(e,t){var a=e||t?this._get_data("rows"):this._get_data("dataSource");return this.collectRows(a,e)}},{key:"getAllData",value:function(){return this.getData(!0)}},{key:"getPageData",value:function(){return this.getData(!0)}},{key:"getEffeData",value:function(){var e=this._get_data("dataSource")||[],t=this._get_data("rowsDataState")||[];return this.collectRows(e.filter(function(e,a){return t[a]!==V}),!1)}},{key:"getRows",value:function(e){var t=this._get_data("rows")||[];return!1===e?t:t.map(function(e){return z(e)})}},{key:"collectRows",value:function(e,t){var a=this._get_data("columns")||{},n=this.getStatusFlag(),i=this.getSelectedFlag();return(e||[]).map(function(e){var r={};for(var o in e){var s;t&&o===n||(t||o!==i)&&!1!==(null===(s=a[o])||void 0===s?void 0:s.needCollect)&&(r[o]=e[o])}return r})}},{key:"getShowRows",value:function(e){return(e||this._get_data("rows")||[]).map(function(e){return c({},e)})}},{key:"getRow",value:function(e,t){var a,n=null===(a=this._get_data("rows"))||void 0===a?void 0:a[e];if(n)return!1===t?n:z(n)}},{key:"getRowIndex",value:function(e){if(!e)return-1;var t=this._get_data("rows")||[],a=this.getRowKeyField();return void 0!==e[a]?t.findIndex(function(t){return t[a]===e[a]}):t.indexOf(e)}},{key:"getRowIndexByRowId",value:function(e){var t=this;return(this._get_data("rows")||[]).findIndex(function(a){return(null==a?void 0:a[t.getIdFlag()])===e})}},{key:"getDataSourceIndexByRowId",value:function(e){var t=this;return(this._get_data("dataSource")||[]).findIndex(function(a){return(null==a?void 0:a[t.getIdFlag()])===e})}},{key:"getRowKey",value:function(e){var t,a;return null!==(t=null===(a=this._get_data("rows"))||void 0===a||null===(a=a[e])||void 0===a?void 0:a[this.getIdFlag()])&&void 0!==t?t:e}},{key:"getRowKeys",value:function(e){var t=void 0===e?this.getRows():B(e)?e:[e],a=this.getRowKeyField();return t.filter(function(e){return e&&void 0!==e[a]}).map(function(e){return e[a]})}},{key:"getRowsByIndexes",value:function(e){var t=this._get_data("rows")||[];return(B(e)?e:[e]).map(function(e){return t[e]}).filter(Boolean)}},{key:"getCellValue",value:function(e,t){var a,n=e>=0?null===(a=this._get_data("rows"))||void 0===a?void 0:a[e]:null;if(n&&t)return n[t]}},{key:"setCellValue",value:function(e,t,a){var n=(this._get_data("rows")||[])[e];if(n&&t){var i=n[t];if(i!==a){var r={rowIndex:e,rowId:n[this.getIdFlag()],cellName:t,value:a,oldValue:i};this.execute("beforeCellValueChange",r)&&(n[t]=r.value,this.markRowState(e,T),this.execute("afterCellValueChange",r),this.doPropertyChange("setCellValue",r))}}}},{key:"setCellValues",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];B(t)&&t.forEach(function(t){return e.setCellValue(t.rowIndex,t.cellName||t.field,t.value)})}},{key:"getCellState",value:function(e,t,a){var n,i=this.getRowKey(e),r=i?null===(n=this._get_data("cellState"))||void 0===n||null===(n=n[i])||void 0===n?void 0:n[t]:null;if(r)return r[a]}},{key:"setCellState",value:function(e,t,a,n){var i,o=null===(i=this._get_data("rows"))||void 0===i||null===(i=i[e])||void 0===i?void 0:i[this.getIdFlag()],s=o||e;if(!H(s)){var u=this.getCellState(e,t,a);if(u!==n){var l={rowIndex:e,rowId:o,cellName:t,propertyName:a,value:n,oldValue:u};if(this.execute("beforeCellStateChange",l)){var d=c({},this._get_data("cellState")||{});d[s]=c({},d[s]||{}),d[s][t]=c(c({},d[s][t]||{}),{},r({},a,n)),this._applyState("cellState",d),this.execute("afterCellStateChange",l)}}}}},{key:"setCellStates",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];B(t)&&t.forEach(function(t){return e.setCellState(t.rowIndex,t.cellName,t.propertyName||t.name,t.value)})}},{key:"getRowDataState",value:function(e){var t,a=this.getDataSourceIndexByRow(e);return null===(t=this._get_data("rowsDataState"))||void 0===t?void 0:t[a]}},{key:"getDataSourceIndexByRow",value:function(e){var t=this,a=(this._get_data("rows")||[])[e];if(!a)return-1;var n=this._get_data("dataSource")||[],i=n.indexOf(a);return i>-1?i:n.findIndex(function(e){return(null==e?void 0:e[t.getIdFlag()])===(null==a?void 0:a[t.getIdFlag()])})}},{key:"setRowDataState",value:function(e,t){var a=this.getDataSourceIndexByRow(e);if(!(a<0)){var n=g(this._get_data("rowsDataState")||[]);n[a]=t,this._set_data("rowsDataState",n,!0)}}},{key:"markRowState",value:function(e,t){var a=this.getRowDataState(e);a!==K&&a!==t&&this.setRowDataState(e,t)}},{key:"markRowUpdate",value:function(e){var t="number"==typeof e?e:this.getRowIndex(e);t<0||this.markRowState(t,T)}},{key:"getRowState",value:function(e,t){var a,n=this.getRowKey(e),i=n?null===(a=this._get_data("rowState"))||void 0===a?void 0:a[n]:null;if(i&&t)return i[t]}},{key:"setRowState",value:function(e,t,a){var n,i=null===(n=this._get_data("rows"))||void 0===n?void 0:n[e];if(i&&t){var o=this.getRowKey(e),s=this.getRowState(e,t);if(s!==a){var u={rowIndex:e,rowId:i[this.getIdFlag()],propertyName:t,value:a,oldValue:s};if(this.execute("beforeRowStateChange",u)){var l=c({},this._get_data("rowState")||{});l[o]=c(c({},l[o]||{}),{},r({},t,a)),this._applyState("rowState",l),this.execute("afterRowStateChange",u)}}}}},{key:"setRowStates",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];B(t)&&t.forEach(function(t){return e.setRowState(t.rowIndex,t.propertyName||t.name,t.value)})}},{key:"getDirtyData",value:function(e){var t=this,a=this._get_data("dataSource")||[],n=this._get_data("rowsDataState")||[],i=[];return a.forEach(function(e,a){var r=n[a];if(r){var o=z(e);o[t.getStatusFlag()]=r,i.push(o)}}),i.length?i:void 0}},{key:"getDirtyRowIndexes",value:function(){var e=this;return(this._get_data("rows")||[]).map(function(e,t){return t}).filter(function(t){return!!e.getRowDataState(t)})}},{key:"isDirty",value:function(){return!!this.getDirtyData()}},{key:"backupState",value:function(){this._set_data("backupData",{dataSource:z(this._get_data("dataSource")||[]),rowsDataState:g(this._get_data("rowsDataState")||[])})}},{key:"restoreState",value:function(){var e=this._get_data("backupData");e&&(this._set_data("dataSource",e.dataSource,!0),this._set_data("rowsDataState",g(e.rowsDataState),!0),this.showPage())}},{key:"insertRow",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},a=arguments.length>3?arguments[3]:void 0,n=this._get_data("rows")||[],i=Math.min(n.length,Math.max(0,void 0===e?n.length:e)),r={index:i,row:c({},t),isCopy:a};if(this.execute("beforeInsertRow",r)){var o=r.row;delete o[this.getIdFlag()],J.call(this,[o]);var s=this._get_data("dataSource")||[],u=i<n.length?this.getDataSourceIndexByRow(i):s.length;s.splice(u<0?s.length:u,0,o);var l=g(this._get_data("rowsDataState")||[]);return l.splice(u<0?l.length:u,0,K),n.splice(i,0,o),this._set_data("rowsDataState",l,!0),this.setRows(n),this.execute("afterInsertRow",c(c({},r),{},{rowIndex:i})),o}}},{key:"insertRows",value:function(e){var t=this,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],n=[];return(B(a)?a:[a]).forEach(function(a,i){n.push(t.insertRow(e+i,a))}),n}},{key:"appendRow",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this.insertRow(this.getRowsCount(),e)}},{key:"updateRow",value:function(e){var t,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=null===(t=this._get_data("rows"))||void 0===t?void 0:t[e];n&&this.execute("beforeUpdateRow",{index:e,row:a})&&(Object.assign(n,a),this.markRowState(e,T),this.setRows(this._get_data("rows")),this.execute("afterUpdateRow",{index:e,row:n}))}},{key:"updateRows",value:function(){var e=this;(arguments.length>0&&void 0!==arguments[0]?arguments[0]:[]).forEach(function(t){var a;return e.updateRow(null!==(a=t.rowIndex)&&void 0!==a?a:t.index,t.rowData||t.row)})}},{key:"deleteRows",value:function(e){var t=this,a=(B(e)?e:[e]).filter(function(e){return e>=0&&e<t.getRowsCount()}).sort(function(e,t){return e-t});if(a.length){var n=this.getRowsByIndexes(a);if(this.execute("beforeDeleteRows",n,a)){var i=this._get_data("dataSource")||[],r=g(this._get_data("rowsDataState")||[]),o=new Set,s=new Set;n.forEach(function(e){var a=i.indexOf(e);if(!(a<0)){var n=e[t.getIdFlag()];o.add(n),r[a]===K&&s.add(n)}});var u=[],l=[];i.forEach(function(e,a){var n=e[t.getIdFlag()];if(!o.has(n))return u.push(e),void l.push(r[a]);s.has(n)||(u.push(e),l.push(V))}),this._set_data("dataSource",u,!0),this._set_data("rowsDataState",l,!0),this.showPage(),this.execute("afterDeleteRows",{rowIndexes:a,rows:n})}}}},{key:"deleteAllRows",value:function(){this.deleteRows(this.getRows().map(function(e,t){return t}))}},{key:"clear",value:function(){this._set_data("dataSource",[],!0),this._set_data("rows",[],!0),this._set_data("rowsDataState",[],!0),this.clearSelection(),this.applyPageInfo(c(c({},this.getPageInfo()),{},{recordCount:0,pageIndex:1})),this.setDataSourceView()}},{key:"select",value:function(e,t){var a=this;if(null!=e||!0===t){!0===t&&this.unselectAll({silent:!0});var n=!0===t?this.getRows().map(function(e,t){return t}):B(e)?e:[e];n=n.filter(function(e){return e>=0&&e<a.getRowsCount()});var i=this._get_data("rows")||[],r=this.getSelectedFlag(),o=n.filter(function(e){return!i[e][r]});if(o.length){var s={rowIndexes:o,rows:o.map(function(e){return i[e]})};this.execute("beforeSelect",s)&&(o.forEach(function(e){i[e][r]=!0,a.cacheSelectedRow(i[e],!0)}),this.flushSelection())}else!0===t&&this.flushSelection()}}},{key:"unselect",value:function(e){var t=this;if(null!=e){var a=B(e)?e:[e],n=this._get_data("rows")||[],i=this.getSelectedFlag(),r=a.filter(function(e){var t;return null===(t=n[e])||void 0===t?void 0:t[i]});r.length&&this.execute("beforeUnselect",r)&&(r.forEach(function(e){n[e][i]=!1,t.cacheSelectedRow(n[e],!1)}),this.flushSelection())}}},{key:"selectAll",value:function(){var e=this,t=this._get_data("rows")||[],a=this.getSelectedFlag();t.forEach(function(t){t[a]=!0,e.cacheSelectedRow(t,!0)}),this.flushSelection()}},{key:"unselectAll",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},a=this.getSelectedFlag();((t.onlyPage?this._get_data("rows"):this._get_data("dataSource"))||[]).forEach(function(e){e[a]=!1}),t.onlyPage?(this._get_data("rows")||[]).forEach(function(t){return e.cacheSelectedRow(t,!1)}):(this._set_data("selectedKeys",[],!0),this._set_data("selectedRowsMap",{},!0),this._set_data("selectedKeysSet",new Set,!0)),t.silent||this.flushSelection()}},{key:"clearSelection",value:function(){this.unselectAll()}},{key:"setSelectedRows",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],a=B(t)?t:[],n=this.getRowKeyField(),i=new Set(a.map(function(e){var t;return String(null!==(t=null==e?void 0:e[n])&&void 0!==t?t:e)})),r=this._get_data("rows")||[],o=this.getSelectedFlag();r.forEach(function(t){var a=i.has(String(t[n]));a!==!!t[o]&&(t[o]=a,e.cacheSelectedRow(t,a))}),this.flushSelection()}},{key:"setSelection",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];this.unselectAll({silent:!0}),this.setSelectedRows(e)}},{key:"getSelectedRows",value:function(e){var t=this._get_data("rows")||[],a=this.getSelectedFlag(),n=e&&new Set(B(e)?e:[e]);return t.filter(function(e,t){return e[a]&&(!n||n.has(t))})}},{key:"getSelectedRowIndexes",value:function(){var e=this._get_data("rows")||[],t=this.getSelectedFlag(),a=[];return e.forEach(function(e,n){e[t]&&a.push(n)}),a}},{key:"getSelectedKeys",value:function(){return this._get_data("selectedKeys")||[]}},{key:"getAllCacheSelectedRows",value:function(){var e=this._get_data("selectedKeys")||[],t=this._get_data("selectedRowsMap")||{};return e.map(function(e){return t[e]}).filter(Boolean)}},{key:"selectByKeys",value:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],a=this.getRowKeyField(),n=B(e)?e:[e],i=this._get_data("rows")||[],r=[];n.forEach(function(e){var t=i.findIndex(function(t){return String(t[a])===String(e)});t>-1&&r.push(t)}),r.length&&(t?this.select(r):this.unselect(r))}},{key:"getSelectedNodes",value:function(){return this.getAllCacheSelectedRows()}},{key:"cacheSelectedRow",value:function(e,t){var a=String(null==e?void 0:e[this.getRowKeyField()]),n=(this._get_data("selectedKeys")||[]).filter(function(e){return e!==a}),i=c({},this._get_data("selectedRowsMap")||{});t&&n.push(a),t?i[a]=e:delete i[a],this._set_data("selectedKeys",n,!0),this._set_data("selectedRowsMap",i,!0),this._set_data("selectedKeysSet",new Set(n),!0)}},{key:"flushSelection",value:function(){this._applyState("selectedRows",this.getSelectedRows()),this.execute("selectionChange",{value:this.getSelectedRows(),keys:this.getSelectedKeys(),indexes:this.getSelectedRowIndexes()})}},{key:"restoreSelectedFlags",value:function(){if(this.get("cacheSelectedRows")){var e=this._get_data("selectedKeysSet")||new Set;if(e.size){var t=this.getRowKeyField(),a=this.getSelectedFlag();(this.getRows()||[]).forEach(function(n){n[a]=e.has(String(n[t]))})}}}},{key:"setPagination",value:function(e){this._applyState("pagination",!!e),this.showPage()}},{key:"getPageInfo",value:function(){return this._get_data("pageInfo")||createDefaults().pageInfo}},{key:"getPageIndex",value:function(){return this.getPageInfo().pageIndex}},{key:"getPageSize",value:function(){return this.getPageInfo().pageSize}},{key:"getTotalCount",value:function(){return this.getPageInfo().recordCount}},{key:"setPageInfo",value:function(e){this.applyPageInfo(c(c({},this.getPageInfo()),e),{refresh:!0})}},{key:"setPageIndex",value:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];"number"==typeof e&&this.applyPageInfo(c(c({},this.getPageInfo()),{},{pageIndex:Math.max(1,e)}),{refresh:t})}},{key:"setPageSize",value:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];"number"==typeof e&&this.applyPageInfo(c(c({},this.getPageInfo()),{},{pageSize:Math.max(-1,e),pageIndex:1}),{refresh:t})}},{key:"setRecordCount",value:function(e){this.applyPageInfo(c(c({},this.getPageInfo()),{},{recordCount:e||0}))}},{key:"applyPageInfo",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},a=c({},e||{}),n=-1===a.pageSize?-1:a.pageSize||20,i=a.recordCount||0,r=i>0;return a.pageSize=n,a.recordCount=i,a.pageCount=n>0?Math.max(1,Math.ceil(i/n)):1,a.pageIndex=n>0?Math.max(1,r?Math.min(a.pageIndex||1,a.pageCount):a.pageIndex||1):1,a.beginPageIndex=n>0?(a.pageIndex-1)*n+1:1,a.endPageIndex=n>0?Math.min(a.pageIndex*n,i):i,this._set_data("pageInfo",a,!0),t.silent||(this._applyState("pageInfo",a),this.isRemote()||this.showPage(),t.refresh&&this.isRemote()&&this.refresh()),a}},{key:"showPage",value:function(){var e=this._get_data("dataSource")||[];if(!this.isRemote()&&this.isPagination()){var t=this.getPageInfo(),a=t.pageIndex,n=t.pageSize,i=(a-1)*n;this.setRows(e.slice(i,i+n))}else this.setRows(e)}},{key:"setDataSource",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},a=arguments.length>2?arguments[2]:void 0;if("local"===this._get_data("dataSourceMode")){var n=cb.utils.isArray(e)?e:[];if(!this.execute("beforeSetDataSource",n))return;var i=this._get_data("rowKeyField"),r={};n.forEach(function(e){r[e[i]]=e}),this._set_data("keyMap",r),this._set_data("dataSource",n,!0),this.getCache("grandson"),n.length&&J.call(this,n),this.initRowState(),setCachePaginationRowData.call(this,n),this.doPropertyChange("resetCellStatus"),this._set_data("rowState",{},!0),this.doPropertyChange("setDataSource",this.getShowRows()),this._set_data("delayInsertRows",[]),this._get_data("isSorting")&&this._set_data("isSorting",!1),this.execute("afterSetDataSource",n)}else{if(!this.execute("beforeProxyLoad",t))return;this._get_data("pageInfo").pageIndex=1;this._set_data("proxyConfig",e),this._set_data("queryParams",t),this._set_data("callback",a),X.call(this,e,t,a,!0,!0)}}},{key:"setRows",value:function(e){var t=B(e)?e:[];this._set_data("rows",t,!0),this.setRowsIdMap(),this._applyState("data",t)}},{key:"setDataSourceView",value:function(){this._applyState("data",this._get_data("rows")||[])}},{key:"setRowsIdMap",value:function(){var e=this,t={};(this._get_data("rows")||[]).forEach(function(a){void 0!==(null==a?void 0:a[e.getIdFlag()])&&(t[a[e.getIdFlag()]]=a)}),this._set_data("rowsIdMap",t)}},{key:"getRowIdMap",value:function(){return this._get_data("rowsIdMap")||{}}},{key:"validate",value:function(e,t){var a=this;if(e)return this.doPropertyChange("validate",{type:"",message:"",errors:[]}),this._set_data("validateErrors",[]),!1;this.deleteNotModifiedRows();var n=this._get_data("columns")||{},i=t?this.getRowsByIndexes(t):this.getRows(),r=[];i.forEach(function(e,t){for(var i in n){var o=n[i];if(a.isRequiredColumn(o)){var s=e[i];if(H(s)||B(s)&&!s.length||U(s)){var u=o.cShowCaption||o.cCaption||o.cCaption||o.title||i;r.push({rowIndex:t,rowId:e[a.getIdFlag()],cellName:i,message:"".concat(u,"不能为空")}),a.setCellState(t,i,"msg","不能为空")}}}}),this._set_data("validateErrors",r);var o=r.length?r[0].message:"";return this.doPropertyChange("validate",{type:r.length?"error":"",message:o,errors:r}),this.execute("afterValidate",{valid:!r.length,errors:r}),!r.length}}])}(),Q=function(){function e(){return a(this,e),t(this,e,arguments)}return s(e,M),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 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 a=this.get(e);null!=a&&a.setData?a.setData(t):this.set(e,t)}},{key:"getData",value:function(){var e=this,t=this._get_data("propertyNames")||[],a={};return t.forEach(function(t){var n,i=e.get(t);i instanceof M&&!1!==i._get_data("needCollect")&&(a[t]=null===(n=i.getData)||void 0===n?void 0:n.call(i))}),a}},{key:"getAllData",value:function(e){var t=this,a=this._get_data("propertyNames")||[],n={};return a.forEach(function(a){var i,r=t.get(a);if(r instanceof M&&!1!==r._get_data("needCollect")&&(!e||!r._get_data("isGrid"))){var o=null===(i=r.getData)||void 0===i?void 0:i.call(r);void 0!==o&&(n[a]=o)}}),n}},{key:"removeProperty",value:function(e){var t=this._get_data("propertyNames")||[],a=t.indexOf(e);-1!==a&&t.splice(a,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(a){var n,i=t.get(a);i instanceof M&&!1!==i._get_data("needClear")&&(null===(n=i.clear)||void 0===n||n.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 a=this._get_data("gridModel");if(a)return a;var n=null===(t=this.getParams())||void 0===t?void 0:t.masterGridModelName;if(n)return this.get(n);for(var i=this._get_data("propertyNames"),r=0,o=i.length;r<o;r++){if((a=this.get(i[r]))instanceof Y)return this._set_data("gridModel",a),a}}},{key:"getGridModels",value:function(){for(var e=this._get_data("propertyNames"),t=[],a=0,n=e.length;a<n;a++){var i=this.get(e[a]);i instanceof Y&&t.push(i)}return t}}])}();function W(e,n){var r,o=null===(r=window.__devfab)||void 0===r?void 0:r.require,u=n||{},l=u.domainKeyField,c=void 0===l?"domainKey":l,d=u.billNoField,h=void 0===d?"billNo":d,f=u.modelNameField,g=void 0===f?"modelName":f,v=u.enableExtendjs,y=void 0===v||v;null!=n&&n.require&&(o=null==n?void 0:n.require);var p=e[c]||"",_=e[h],w=function(){function e(){return a(this,e),t(this,e,arguments)}return s(e,Q),i(e,[{key:"init",value:function(e,t){var a=this.createModels(e,t);this.setData(a),this.setDirty(!1)}},{key:"createModels",value:function(e,t){var a={};return(Array.isArray(e)?e:[]).forEach(function(e){var i,r,o=null==n||null===(i=n.createModelFactory)||void 0===i?void 0:i.call(n,e);o||(o=function(e){var t;"input"===e.cControlType.toLowerCase()&&(t=new F(e));return t}(e));var s={model:o,field:e,meta:t};null==n||null===(r=n.onBeforeCreateModel)||void 0===r||r.call(n,s),a[e[g]]=s.model}),a}},{key:"initData",value:function(){this.initExtendJs()}},{key:"initExtendJs",value:function(){window&&window.__debugger_initExtendJs;var e=this;if(y){var t="".concat(_,"_VM.Extend.js"),a=[t];if("function"!=typeof o)return console.warn("requirejs.js 未加载,跳过扩展脚本:".concat(t)),void e.execute("extendReady",e);o(p,a,function(a,n){if(a&&a.doAction)try{a.doAction("init",e),n&&n.doAction("init",e)}catch(e){console.error("扩展脚本异常:",e)}else console.error("".concat(t,"扩展文件extend.*.min.js文件加载失败 或 未注册扩展脚本"));e.execute("extendReady",e)},function(a){console.warn("未找到扩展脚本:".concat(t,"错误信息:"),a),e.execute("extendReady",e)})}else e.execute("extendReady",e)}}])}();return w.prototype.modelType="ViewModel",w}var $={BaseModel:M,FilterModel:A,SimpleModel:F,GridModel:Y,ViewModel:Q,createViewModel:W,initViewModel:function(e,t){var a=new(W(e,t));return a.init(e.models,e),a}},Z={Builder:b,CacheUtil:C,EventUtil:I,DynamicProxy:j},ee={utils:{builder:new Z.Builder,cache:new Z.CacheUtil,event:new Z.EventUtil},common:{Builder:b,models:$,utils:Z}};export{ee as default};
1
+ function e(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,a=Array(t);n<t;n++)a[n]=e[n];return a}function t(e,t,n,a,r,i,o){try{var s=e[i](o),u=s.value}catch(e){return void n(e)}s.done?t(u):Promise.resolve(u).then(a,r)}function n(e){return function(){var n=this,a=arguments;return new Promise(function(r,i){var o=e.apply(n,a);function s(e){t(o,r,i,s,u,"next",e)}function u(e){t(o,r,i,s,u,"throw",e)}s(void 0)})}}function a(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,c()?Reflect.construct(t,n||[],u(e).constructor):t.apply(e,n))}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){for(var n=0;n<t.length;n++){var a=t[n];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,m(a.key),a)}}function o(e,t,n){return t&&i(e.prototype,t),n&&i(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function s(e,t,n){return(t=m(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 l(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 c(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(c=function(){return!!e})()}function d(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,a)}return n}function f(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?d(Object(n),!0).forEach(function(t){s(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):d(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function h(e,t){if(null==e)return{};var n,a,r=function(e,t){if(null==e)return{};var n={};for(var a in e)if({}.hasOwnProperty.call(e,a)){if(-1!==t.indexOf(a))continue;n[a]=e[a]}return n}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(a=0;a<i.length;a++)n=i[a],-1===t.indexOf(n)&&{}.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function v(){
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:{},a=n.iterator||"@@iterator",r=n.toStringTag||"@@toStringTag";function i(n,a,r,i){var u=a&&a.prototype instanceof s?a:s,l=Object.create(u.prototype);return g(l,"_invoke",function(n,a,r){var i,s,u,l=0,c=r||[],d=!1,f={p:0,n:0,v:e,a:h,f:h.bind(e,4),d:function(t,n){return i=t,s=0,u=e,f.n=n,o}};function h(n,a){for(s=n,u=a,t=0;!d&&l&&!r&&t<c.length;t++){var r,i=c[t],h=f.p,v=i[2];n>3?(r=v===a)&&(u=i[(s=i[4])?5:(s=3,3)],i[4]=i[5]=e):i[0]<=h&&((r=n<2&&h<i[1])?(s=0,f.v=a,f.n=i[1]):h<v&&(r=n<3||i[0]>a||a>v)&&(i[4]=n,i[5]=a,f.n=v,s=0))}if(r||n>1)return o;throw d=!0,a}return function(r,c,v){if(l>1)throw TypeError("Generator is already running");for(d&&1===c&&h(c,v),s=c,u=v;(t=s<2?e:u)||!d;){i||(s?s<3?(s>1&&(f.n=-1),h(s,u)):f.n=u:f.v=u);try{if(l=2,i){if(s||(r="next"),t=i[r]){if(!(t=t.call(i,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=i.return)&&t.call(i),s<2&&(u=TypeError("The iterator does not provide a '"+r+"' method"),s=1);i=e}else if((t=(d=f.n<0)?u:n.call(a,f))!==o)break}catch(t){i=e,s=1,u=t}finally{l=1}}return{value:t,done:d}}}(n,r,i),!0),l}var o={};function s(){}function u(){}function l(){}t=Object.getPrototypeOf;var c=[][a]?t(t([][a]())):(g(t={},a,function(){return this}),t),d=l.prototype=s.prototype=Object.create(c);function f(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,l):(e.__proto__=l,g(e,r,"GeneratorFunction")),e.prototype=Object.create(d),e}return u.prototype=l,g(d,"constructor",l),g(l,"constructor",u),u.displayName="GeneratorFunction",g(l,r,"GeneratorFunction"),g(d),g(d,r,"Generator"),g(d,a,function(){return this}),g(d,"toString",function(){return"[object Generator]"}),(v=function(){return{w:i,m:f}})()}function g(e,t,n,a){var r=Object.defineProperty;try{r({},"",{})}catch(e){r=0}g=function(e,t,n,a){function i(t,n){g(e,t,function(e){return this._invoke(t,n,e)})}t?r?r(e,t,{value:n,enumerable:!a,configurable:!a,writable:!a}):e[t]=n:(i("next",0),i("throw",1),i("return",2))},g(e,t,n,a)}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 a,r,i,o,s=[],u=!0,l=!1;try{if(i=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;u=!1}else for(;!(u=(a=i.call(n)).done)&&(s.push(a.value),s.length!==t);u=!0);}catch(e){l=!0,r=e}finally{try{if(!u&&null!=n.return&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw r}}return s}}(e,t)||k(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 w(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)||k(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 m(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var a=n.call(e,t||"default");if("object"!=typeof a)return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}function S(e){return S="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},S(e)}function k(t,n){if(t){if("string"==typeof t)return e(t,n);var a={}.toString.call(t).slice(8,-1);return"Object"===a&&t.constructor&&(a=t.constructor.name),"Map"===a||"Set"===a?Array.from(t):"Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a)?e(t,n):void 0}}var x=["component","children","render"],b=!1,R={},C=null;function P(e){return R[e]}function I(e,t){if(Array.isArray(e)){var n=[];return e.forEach(function(e,a){var r=e.component,i=e.children,o=e.render,s=h(e,x),u=P(r);u||"function"==typeof o||console.log("[warning] Component ".concat(r," is not registered!"));var l={component:u,children:I(i,t)};s.index=a;var c=Object.assign({},null==t?void 0:t.props,s);"function"==typeof o?n.push(o({node:l,props:c})):"function"==typeof C?n.push(C({node:l,props:c})):(Object.assign(l,c),n.push(l))}),n}}var D=function(){return o(function e(){r(this,e)},[{key:"init",value:function(e){b||("function"==typeof e&&e(),b=!0)}},{key:"initComponent",value:function(e,t){!function(e,t){if(e)"string"==typeof e?R[e]?console.log("[warning] Component ".concat(e," is exist!")):R[e]=t:Object.assign(R,e)}(e,t)}},{key:"getComponents",value:function(){return f({},R)}},{key:"getComponent",value:function(e){return P(e)}},{key:"hasComponent",value:function(e){return!!P(e)}},{key:"initRenderFactory",value:function(e){!function(e){C=e}(e)}},{key:"initRequest",value:function(){}},{key:"render",value:function(e,t){return I(e,t)}},{key:"clear",value:function(){R={},C=null,b=!1}}])}(),j=function(){return o(function e(t){r(this,e),this._init(t)},[{key:"_init",value:function(e){this.cache=Object.assign({},e)}},{key:"set",value:function(e,t){this.cache[e]=t}},{key:"get",value:function(e){var t;return null===(t=this.cache)||void 0===t?void 0:t[e]}},{key:"clear",value:function(e){delete this.cache[e]}}])}(),E=function(){return o(function e(t){r(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 a=this.events.get(e);Array.isArray(a)||(a=[]),a.push({callback:t,context:n}),this.events.set(e,a)}},{key:"onFirst",value:function(e,t,n){var a=this.firstevents.get(e);Array.isArray(a)||(a=[]),a.splice(0,0,{callback:t,context:n}),this.firstevents.set(e,a)}},{key:"execute",value:function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),a=1;a<t;a++)n[a-1]=arguments[a];var r=this.events.get(e),i=this.firstevents.get(e);if(!r&&!i)return!0;var o=!0;return[].concat(w(i||[]),w(r||[])).forEach(function(e){if(!1!==o){var t=e.callback.apply(e.context||void 0,n);o=!1!==t&&o}}),o}},{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 a=n.get(e),r=null==a?void 0:a.findIndex(function(e){return e.callback===t});-1!==r&&(null==a||a.splice(r,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 a,r=this,i=n.resolve,o=n.reject,s=n.args,u=!0,l=t||[],c=!1,d=function(t){var n,a=l[t];if(!1===u)return 0;if(c)return{v:void 0};if("development"===process.env.nodeEnv)n=a.callback.apply(a.context||r,s);else try{n=a.callback.apply(a.context||r,s)}catch(e){throw e.isAddedMsg||(e.message="(领域扩展事件执行失败,请打开控制台查看详细错误信息并修复):".concat(e.message)),e.isAddedMsg=!0,e}n instanceof Promise?(c=!0,(u=n).callbacks&&u.callbacks.push({reject:function(){u.reject(),t===l.length-1&&(null==o||o())},resolve:function(n){t===l.length-1?(s.length>1&&(s[0]=n),null==i||i(s)):r._asyncExecute(e,l.slice(t+1),{resolve:i,reject:o,args:s})}})):(u=!1!==n&&u,t===l.length-1&&(u?null==i||i(s):null==o||o()))},f=0;f<l.length&&0!==(a=d(f));f++)if(a)return a.v;return u}},{key:"_asyncPromiseExecute",value:function(e,t,n,a){var r=this.events.get(e),i=this.firstevents.get(e);if(!((Array.isArray(r)?r.length:r)||(Array.isArray(i)?i.length:i)))return null==t?void 0:t();var o=[].concat(w(i||[]),w(r||[]));return this._asyncExecute(e,o,{resolve:t,reject:n,args:a})}},{key:"promiseExecute",value:function(e,t){var n=this,a=e,r=1;if("boolean"==typeof e&&(a=t,r=2),a){for(var i=arguments.length,o=new Array(i>2?i-2:0),s=2;s<i;s++)o[s-2]=arguments[s];var u=2===r?o:[t].concat(o);if(u.length){var l,c=u.length-1,d=u[c];if("function"!=typeof d){if("object"!==S(d)||!d[0]||"function"!=typeof d[0]||!d[1]||"function"!=typeof d[1])return;l=d[1],d=d[0]}if(this.__ASYNC_EXECUTE__)return this._asyncPromiseExecute(a,function(e){d.apply(n,e)},function(){l&&"function"==typeof l&&l()},u);u.splice(c,1),u.unshift(a);var f=this.execute.apply(this,u);if(f instanceof Promise){var h=this;f.then(function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];d.apply(h,t)},function(){l&&"function"==typeof l&&l()})}else if(!f)return void(l&&"function"==typeof l&&l())}}}},{key:"clearEvents",value:function(){this.events.clear(),this.firstevents.clear()}}])}();function O(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 a=(t=t.replace(/\+/g," ")).split("&"),r=0,i=a.length;r<i;r++){var o=a[r]||"";if(o){var s=o.indexOf("="),u="",l="";s<0?l=u=window.decode(o):(u=window.decode(o.substr(0,s)),l=window.decode(o.substr(s+1))),this.query[u]=l}}}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 q(e,t){if(!t)return e;var n=[],a=new O(e);for(var r in t)a.get(r)||n.push("".concat(r,"=").concat(t[r]));if(!n.length)return e;var i=n.join("&");return e.indexOf("?")>=0?"".concat(e,"&").concat(i):"".concat(e,"?").concat(i)}String.prototype.equalsIgnoreCase=function(e){return null!=e&&this.toLowerCase()===e.toLowerCase()};var M=["onBeforeRequest","_onAfterRequest"],A=["_onBeforeRequest","onAfterRequest"];var F={_xhrs:[],_jsonps:{index:0},doRequest:function(e){var t=e||{},n=t.onBeforeRequest;t._onAfterRequest;var a,r=h(t,M),i=r.method||"GET",o=r.url;try{null!=r&&r.requestHeaders&&(a=r.requestHeaders,r.requestHeaders=void 0,delete r.requestHeaders)}catch(e){console.log('[ajax]: [doRequest]: options["requestHeaders"] ERR : ',e)}try{r.params&&r.params.requestHeaders&&(a=r.params.requestHeaders,r.params.requestHeaders=void 0,delete r.params.requestHeaders)}catch(e){console.log('[ajax]: [doRequest]: options.params["requestHeaders"] ERR : ',e)}var s=null;if(i.equalsIgnoreCase("get")||i.equalsIgnoreCase("delete")?o=q(o,r.params):(i.equalsIgnoreCase("post")||i.equalsIgnoreCase("put"))&&(s=JSON.stringify(r.params)),r.jsonp)return this.getJsonp(o,r.callback);var u=this.getXMLHttpRequest();if(u){var l;if(u.open(i,o,!1!==r.async),r.timeout&&(u.timeout=r.timeout,u.setRequestHeader("timeout",r.timeout),u.ontimeout=function(){F.onerror(this,r,"timeout")}),r.contentType){if(u.setRequestHeader("Content-Type",r.contentType),r.contentType.indexOf("x-www-form-urlencoded")>=0)s=null===(l=new URLSearchParams(r.params))||void 0===l?void 0:l.toString()}else r.dateType?s=r.params:u.setRequestHeader("Content-Type","application/json;charset=utf-8");r.domainKey&&u.setRequestHeader("Domain-Key",r.domainKey);try{if(a&&"[object Object]"===Object.prototype.toString.call(a))for(var c in a)u.setRequestHeader(c,a[c])}catch(e){console.log('[ajax]: [doRequest]: options.params["requestHeaders"] ERR : ',e)}u.withCredentials=null==r||!r.hasOwnProperty("withCredentials")||r.withCredentials;try{u.send(s)}catch(e){return{error:"NetWorkError",options:r}}if(!1===r.async)return null==n||n(r),this.onreadystatechange(u,r);u.onreadystatechange=function(){F.onreadystatechange(this,r)},null==n||n(r)}},beforeReadystatechange:function(e,t,n){null==n||n()},onreadystatechange:function(e,t){var n=t||{};n._onBeforeRequest;var a=n.onAfterRequest,r=h(n,A);if(4===e.readyState){if(null==a||a(),200===e.status){var i;try{if("blob"===r.responseType){var o=function(e){var t=e.xhr.getAllResponseHeaders(),n={};return t.split("\r\n").map(function(e){var t=p(e.split(": "),2),a=t[0],r=t[1];n[a]=r}),n}({xhr:e});i={code:e.status,data:{data:e.response,headers:o}}}else i=JSON.parse(e.responseText)}catch(t){F.onerror(e,r,e.responseText)}if(!1===r.async)return e.isBusy=!1,r.precallback&&r.precallback(i),F.processAjaxResult(i,!1,null,null,r,e);F.processAjaxResult(i,r.async,r.callback,r.context,r,e),r.precallback&&r.precallback(i)}else if(0===e.status)F.onerror(e,r,"网络连接已断开,请检查设备网络状态后重试");else if(502===e.status||504===e.status)F.onerror(e,r,"服务出错了,请稍后再试");else{if(401!==e.status){var s={};try{s=JSON.parse(e.responseText)}catch(t){s={code:e.status,message:e.responseText}}return F.onerror(e,r,s)}F.onerror(e,r,"登录信息失效,请重新登录或联系技术人员")}e.isBusy=!1}},onerror:function(e,t,n){var a="[ajax]: [onerror]: 接口返回错误 \n [状态码]: ".concat(e.status," \n [错误信息]: ").concat(("object"===S(n)?JSON.stringify(n):n)||"空"," \n [请求地址]: ").concat(t.url," \n [浏览器Token]: ").concat(document.cookie);console.log("Error.E01000",a);var r="object"===S(n)?n:{code:500,message:n};t.precallback&&t.precallback(r)},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,a="callback"+this._jsonps.index++,r=document.createElement("script");this._jsonps[a]=function(e){try{t(e)}finally{document.body.removeChild(r)}},n+=-1===n.indexOf("?")?"?":"&callback=cb.rest.AjaxRequestManager._jsonps."+a,r.src=n,document.body.appendChild(r)},processAjaxResult:function(e,t,n,a,r,i){if(e){if(!e.code)return!1===t?e:void(n&&n.call(a,null,e));if(200==e.code){if(!1===t)return{result:e.data};n&&n.call(a,null,e.data,e.message,e.errorDetail,e.code,e.displayCode&&e)}else{if(!1===t)return{error:e};n&&n.call(a,e)}}}};function N(e,t){this.init&&this.init(e),this.queryParams=t}N.create=function(e,t){return new N(e,t)},N.prototype.init=function(e){if(e)for(var t in this.config=e,this.config)this[t]=function(e){return function(t,n,a){return this.Do(e,t,n,null,a)}}(t),this["".concat(t,"Sync")]=function(e){return function(t){return this.Do(e,t,null,!1)}}(t)},N.prototype.Do=function(e,t,n,a,r){var i,o,s;if(this.config&&this.config[e]&&this.config[e].url){var u=this.config[e],l=u.url;this.queryParams||(this.queryParams={}),null!==(i=u.options)&&void 0!==i&&i.proxyServiceCode&&(this.queryParams.serviceCode=u.options.proxyServiceCode),null!==(o=u.options)&&void 0!==o&&o.billnum&&(this.queryParams.billnum=u.options.billnum),null!==(s=this.queryParams)&&void 0!==s&&s.serviceCode&&(l=q(l,this.queryParams));var c=l,d=Object.assign({},u.options);return d.method=u.method||"GET","function"==typeof t?(d.callback=t,d.context=r||d.context||this):d.params=t,n&&(d.callback=n,d.context=r||d.context||this),!1===a&&(d.async=!1),this.ajax(c,d)}},N.prototype.ajax=function(e,t){return function(e,t){return t.url=e,F.doRequest(t)}(e,t)};var T=function(){return o(function e(t){r(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 j,this._data.events=new E}},{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 j,events:new E}}},{key:"_set_data",value:function(e,t,n){if(e){if(n){var a=this._data.propertyNames||[];a.indexOf(e)<0&&a.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 a=(this._get_data("components")||[]).find(function(e){return e.ctrlName===t});return a?null===(n=a.getState)||void 0===n?void 0:n.call(a,e):this._get_data(e)}},{key:"setState",value:function(e,t,n){n||this._set_data(e,t,!0);var a={};a[e]=t,this.doPropertyChange("setState",a,n)}},{key:"doPropertyChange",value:function(e,t,n){var a=this,r=this._get_data("components")||[];if(!r.length)return r;var i=[];if(n){var o=r.find(function(e){return e.ctrlName===n});o&&!this.notifyComponent(o,e,t)&&i.push(o)}else r.forEach(function(n){a.notifyComponent(n,e,t)||i.push(n)});return i.length?i: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 a=this.getCache("name");e[t](n,a)}}},{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 a=this;n||this._set_data(e,t,!0);var r="set".concat(e.charAt(0).toUpperCase()).concat(e.slice(1)),i=this.doPropertyChange(r,t,n);if(i){var o={};o[e]=t,i.forEach(function(e){a.notifyComponent(e,"setState",o)})}}},{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 a=this,r=this.getValue();if(e!==r){var i={value:e,oldValue:r},o=this._get_data("forceFireEvent");t||o?this.promiseExecute("beforeValueChange",i,[function(){a._set_data("value",e,!0),a._applyState("value",e,n),a.execute("afterValueChange",i)},function(){a._set_data("value",r,!0),a._applyState("value",r,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,a=new Array(n>1?n-1:0),r=1;r<n;r++)a[r-1]=arguments[r];return(t=this._get_data("events")).execute.apply(t,[e].concat(a))}},{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,a=arguments.length,r=new Array(a>2?a-2:0),i=2;i<a;i++)r[i-2]=arguments[i];(n=this._get_data("events")).promiseExecute.apply(n,[e,t].concat(r))}},{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").clear(e)}},{key:"setProxy",value:function(e){if(!(e instanceof N)){var t,n=this._get_data("__requestHeaders__");for(var a in e){var r,i,o;if(n&&(null===(r=e[a])||void 0===r||null===(r=r.options)||void 0===r||!r.requestHeaders))null!==(o=e[a])&&void 0!==o&&o.options||(e[a].options={}),e[a].options.requestHeaders=n;null!==(i=this.getProxy())&&void 0!==i&&i[a]&&console.warn("[baseModel.prototype.setProxy]: Proxy ".concat(a," already exists on the model. Please change the name of ").concat(a," and try again"))}return this._set_data("proxy",N.create(f(f({},(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")}}])}(),K=function(){function e(){return r(this,e),a(this,e,arguments)}return l(e,T),o(e,[{key:"mounted",value:function(){var e=this,t=this.get("conditions"),n={};t.forEach(function(t){e.get(t.name),n[t.name]=t.defaultValue}),this._set_data("params",n)}},{key:"unmounted",value:function(){this._set_data("params",{}),this._set_data("conditions",[])}},{key:"getParams",value:function(){var e=this,t={};return this.get("conditions").forEach(function(n){var a=e.get(n.name);t[n.name]=null==a?void 0:a.getValue()}),this._set_data("params",t),t}},{key:"search",value:function(){var e=this.getParams();this.execute("search",e)}}])}(),V=function(){function e(t){return r(this,e),a(this,e,[t])}return l(e,T),o(e,[{key:"getDisabled",value:function(){return this.getState("disabled")}},{key:"setDisabled",value:function(e){return this.setState("disabled",!!e)}},{key:"getReadonly",value:function(){return this.getState("readonly")}},{key:"setReadonly",value:function(e){this.setState("readonly",!!e)}}])}(),U="",H="Insert",B="Update",L="Delete",z=Array.isArray,G=function(e){return null==e||""===e},X=function(e){return!e||0===Object.keys(e).length};function J(e){if(z(e))return e.map(J);if(e instanceof Date)return new Date(e.getTime());if(e&&"object"===S(e)){var t={};for(var n in e)t[n]=J(e[n]);return t}return e}function Y(e){var t={};return(z(e)?e:Object.keys(e||{}).map(function(t){var n;return f(f({},e[t]||{}),{},{field:(null===(n=e[t])||void 0===n?void 0:n.field)||t})})).forEach(function(e,n){if(e){var a=e.field||e.cCaption||e.cFieldName||"col_".concat(n);t[a]=f(f({},e),{},{field:a,fieldName:e.fieldName||a,cCaption:e.cCaption||a,index:void 0===e.index?n:e.index})}}),t}function Q(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=this.getIdFlag(),n=this.getRowKeyField(),a=this._get_data("rowIdSeq")||0;return e.forEach(function(e){if(e&&void 0===e[t]){var r=e[n];null!=r&&""!==r?e[t]=String(r):(a+=1,e[t]="rowId_".concat(a))}}),this._set_data("rowIdSeq",a),e}function W(e,t,n){var a=this;this.promiseExecute("beforeQuery",{proxyConfig:e,queryParams:t},function(){var r=a,i=a.setProxy({queryData:e}),o={page:{pageSize:a.getPageSize(),pageIndex:a.getPageIndex()}},s=Object.assign(o,t);a.setCache("proxyCache",{proxyConfig:e,params:s}),a.getRootParent();if(!1!==a.execute("beforeQueryData",s)){var u=_.cloneDeep(s);i.queryData(u,function(e,t,a,r){if(!e){this._set_data("dataSourceMode","remote");var i=function(e){if(!e)return[];if(z(e))return e;if(z(e.data))return e.data;if(z(e.records))return e.records;if(z(e.list))return e.list;if(z(e.rows))return e.rows;var t=e.data&&"object"===S(e.data)?e.data:e.result;return z(t)?t:t&&"object"===S(t)&&(t.records||t.list||t.rows||t.data)||[]}(t=Object.assign({},t));null==n||n.call(this,i)}},r)}})}function $(e){if(this.execute("beforeSetDataSource",e)){var t=this._get_data("rowKeyField"),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 Z=function(){function e(){var t,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};r(this,e);var i=f(f({},{columns:{},dataSource:[],rows:[],readOnly:!0,dataSourceMode:"local",columnMode:"local",editMode:"cell",cellState:{},rowState:{},showCheckBox:!0,multiple:!0,showRowNo:!0,pagination:!0,pageInfo:{pageIndex:1,pageSize:20,pageCount:0},innerUsedAttrs:{id:"_id",selected:"_selected",status:"_status"},multiRowModel:!1,editRowModels:{},loading:!1,params:{},originalKeyMap:{},defaultRowDatas:new Map}),n);z(i.dataSource)||(i.dataSource=[]),z(i.rows)||(i.rows=[]);var o=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=f({},e.proxyConfig||{});return"function"==typeof e.dataSource&&(t.load=t.load||e.dataSource),"string"==typeof e.cUrl&&(t.load=t.load||e.cUrl),t.load||"string"!=typeof e.url||(t.load=e.url),t}(n);i.proxyConfig=o,i.dataSourceMode=n.dataSourceMode||(o.load?"remote":"local");var u=n.cData||(z(n.data)?n.data:null);return s(t=a(this,e,[i]),"modelType","GridModel"),t.initPageInfo(n.cPage||n.page),t.initColumns(i.columns),t.initRowState(),t.afterInit(),u&&t.setDataSource(u),t}return l(e,T),o(e,[{key:"afterInit",value:function(){"single"===this._get_data("parentRelation")&&this._set_data("defaultSelectedRowIndexes",!0)}},{key:"initColumns",value:function(e){var t=Y(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=f({},this.getPageInfo());t.pageIndex=e.pageNo||e.pageIndex||t.pageIndex||1,t.pageSize=e.pageSize||t.pageSize||20,!1===this.get("pagination")&&(t.pageSize=-1),this.applyPageInfo(t)}},{key:"initRowState",value:function(){var e=this,t=this._get_data("dataSource");this._set_data("rowsDataState",(z(t)?t:[]).map(function(t){return(null==t?void 0:t[e.getStatusFlag()])||U}),!0)}},{key:"getInnerUsedAttrs",value:function(){return this._get_data("innerUsedAttrs")}},{key:"getIdFlag",value:function(){return this.getInnerUsedAttrs().id}},{key:"getSelectedFlag",value:function(){return this.getInnerUsedAttrs().selected}},{key:"getStatusFlag",value:function(){return this.getInnerUsedAttrs().status}},{key:"getRowKeyField",value:function(){return this._get_data("rowKeyField")||"id"}},{key:"getProxyConfig",value:function(){return this._get_data("proxyConfig")||{}}},{key:"isRemote",value:function(){return"remote"===this._get_data("dataSourceMode")}},{key:"isPagination",value:function(){return!!this.get("pagination")&&-1!==this.getPageSize()}},{key:"getReadOnly",value:function(){return!!this._get_data("readOnly")}},{key:"setReadOnly",value:function(e){this._applyState("readOnly",!!e)}},{key:"getParams",value:function(){return f(f({},this.get("cParams")||{}),this._get_data("params")||{})}},{key:"setParams",value:function(e){this._set_data("params",e||{})}},{key:"setMeta",value:function(e){this._set_data("meta",e)}},{key:"getColumns",value:function(e){var t=this._get_data("columns")||{},n={};return(e?z(e)?e:[e]:Object.getOwnPropertyNames(t)).forEach(function(e){t[e]&&(n[e]=f(f({},t[e]),{},{fieldName:t[e].fieldName||e}))}),n}},{key:"getColumn",value:function(e){var t,n=null===(t=this._get_data("columns"))||void 0===t?void 0:t[e];return n?f(f({},n),{},{fieldName:n.fieldName||e}):void 0}},{key:"hasColumn",value:function(e){return!!(this._get_data("columns")||{})[e]}},{key:"getColumnList",value:function(e){var t=this.getColumns(e);return Object.keys(t).sort(function(e,n){return(t[e].index||0)-(t[n].index||0)}).map(function(e){return t[e]})}},{key:"getVisibleColumns",value:function(e){return this.getColumnList(e).filter(function(e){return!0!==e.bHidden&&!1!==e.bShowIt})}},{key:"setColumns",value:function(e){e&&this._applyState("columns",Y(e))}},{key:"setColumnMode",value:function(e){this._set_data("columnMode","remote"===e?"remote":"local",!0)}},{key:"addColumns",value:function(e){var t=Y(e);this._applyState("columns",f(f({},this._get_data("columns")||{}),t))}},{key:"resetColumns",value:function(e){this.setColumns(e||this.get("cColumns"))}},{key:"getColumnState",value:function(e,t,n){var a,r=this.getRowKey(e);return r?((null===(a=this._get_data("cellState"))||void 0===a||null===(a=a[r])||void 0===a?void 0:a[t])||{})[n]:void 0}},{key:"setColumnState",value:function(e,t,n,a){this.setCellState(e,t,n,a)}},{key:"setColumnStates",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];this.setCellStates(e.map(function(e){return f(f({},e),{},{cellName:e.cellName||e.columnName})}))}},{key:"setColumnValue",value:function(e,t,n){var a=this._get_data("columns")||{};a[e]&&this._applyState("columns",f(f({},a),{},s({},e,f(f({},a[e]),{},s({},t,n)))))}},{key:"setDataSource",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},a=arguments.length>2?arguments[2]:void 0;if("local"===this._get_data("dataSourceMode")){$(cb.utils.isArray(e)?e:[])}else{if(!this.execute("beforeProxyLoad",n))return;this._get_data("pageInfo").pageIndex=1,this._set_data("proxyConfig",e),this._set_data("queryParams",n),this._set_data("loadDataCallback",a),W.call(this,e,n,function(e){$.call(t,e),null==a||a.call(t)})}}},{key:"reload",value:function(){var e=this;this.getProxy();var t=this._get_data("proxyConfig"),n=this._get_data("queryParams"),a=this._get_data("loadDataCallback");W.call(this,t,n,function(t){$.call(e,t),null==a||a.call(e)})}},{key:"getDataSource",value:function(){return this._get_data("dataSource")||[]}},{key:"getData",value:function(e,t){var n=e||t?this._get_data("rows"):this._get_data("dataSource");return this.collectRows(n,e)}},{key:"getAllData",value:function(){return this.getData(!0)}},{key:"getPageData",value:function(){return this.getData(!0)}},{key:"getEffeData",value:function(){var e=this._get_data("dataSource")||[],t=this._get_data("rowsDataState")||[];return this.collectRows(e.filter(function(e,n){return t[n]!==L}),!1)}},{key:"getRows",value:function(e){var t=this._get_data("rows")||[];return!1===e?t:t.map(function(e){return J(e)})}},{key:"collectRows",value:function(e,t){var n=this._get_data("columns")||{},a=this.getStatusFlag(),r=this.getSelectedFlag();return(e||[]).map(function(e){var i={};for(var o in e){var s;t&&o===a||(t||o!==r)&&!1!==(null===(s=n[o])||void 0===s?void 0:s.needCollect)&&(i[o]=e[o])}return i})}},{key:"getShowRows",value:function(e){return(e||this._get_data("rows")||[]).map(function(e){return f({},e)})}},{key:"getRow",value:function(e,t){var n,a=null===(n=this._get_data("rows"))||void 0===n?void 0:n[e];if(a)return!1===t?a:J(a)}},{key:"getRowIndex",value:function(e){if(!e)return-1;var t=this._get_data("rows")||[],n=this.getRowKeyField();return void 0!==e[n]?t.findIndex(function(t){return t[n]===e[n]}):t.indexOf(e)}},{key:"getRowIndexByRowId",value:function(e){var t=this;return(this._get_data("rows")||[]).findIndex(function(n){return(null==n?void 0:n[t.getIdFlag()])===e})}},{key:"getDataSourceIndexByRowId",value:function(e){var t=this;return(this._get_data("dataSource")||[]).findIndex(function(n){return(null==n?void 0:n[t.getIdFlag()])===e})}},{key:"getRowKey",value:function(e){var t,n;return null!==(t=null===(n=this._get_data("rows"))||void 0===n||null===(n=n[e])||void 0===n?void 0:n[this.getIdFlag()])&&void 0!==t?t:e}},{key:"getRowKeys",value:function(e){var t=void 0===e?this.getRows():z(e)?e:[e],n=this.getRowKeyField();return t.filter(function(e){return e&&void 0!==e[n]}).map(function(e){return e[n]})}},{key:"getRowsByIndexes",value:function(e){var t=this._get_data("rows")||[];return(z(e)?e:[e]).map(function(e){return t[e]}).filter(Boolean)}},{key:"getCellValue",value:function(e,t){var n,a=e>=0?null===(n=this._get_data("rows"))||void 0===n?void 0:n[e]:null;if(a&&t)return a[t]}},{key:"setCellValue",value:function(e,t,n){var a=(this._get_data("rows")||[])[e];if(a&&t){var r=a[t];if(r!==n){var i={rowIndex:e,rowId:a[this.getIdFlag()],cellName:t,value:n,oldValue:r};this.execute("beforeCellValueChange",i)&&(a[t]=i.value,this.markRowState(e,B),this.execute("afterCellValueChange",i),this.doPropertyChange("setCellValue",i))}}}},{key:"setCellValues",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];z(t)&&t.forEach(function(t){return e.setCellValue(t.rowIndex,t.cellName||t.field,t.value)})}},{key:"getCellState",value:function(e,t,n){var a,r=this.getRowKey(e),i=r?null===(a=this._get_data("cellState"))||void 0===a||null===(a=a[r])||void 0===a?void 0:a[t]:null;if(i)return i[n]}},{key:"setCellState",value:function(e,t,n,a){var r,i=null===(r=this._get_data("rows"))||void 0===r||null===(r=r[e])||void 0===r?void 0:r[this.getIdFlag()],o=i||e;if(!G(o)){var u=this.getCellState(e,t,n);if(u!==a){var l={rowIndex:e,rowId:i,cellName:t,propertyName:n,value:a,oldValue:u};if(this.execute("beforeCellStateChange",l)){var c=f({},this._get_data("cellState")||{});c[o]=f({},c[o]||{}),c[o][t]=f(f({},c[o][t]||{}),{},s({},n,a)),this._applyState("cellState",c),this.execute("afterCellStateChange",l)}}}}},{key:"setCellStates",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];z(t)&&t.forEach(function(t){return e.setCellState(t.rowIndex,t.cellName,t.propertyName||t.name,t.value)})}},{key:"getRowDataState",value:function(e){var t,n=this.getDataSourceIndexByRow(e);return null===(t=this._get_data("rowsDataState"))||void 0===t?void 0:t[n]}},{key:"getDataSourceIndexByRow",value:function(e){var t=this,n=(this._get_data("rows")||[])[e];if(!n)return-1;var a=this._get_data("dataSource")||[],r=a.indexOf(n);return r>-1?r:a.findIndex(function(e){return(null==e?void 0:e[t.getIdFlag()])===(null==n?void 0:n[t.getIdFlag()])})}},{key:"setRowDataState",value:function(e,t){var n=this.getDataSourceIndexByRow(e);if(!(n<0)){var a=w(this._get_data("rowsDataState")||[]);a[n]=t,this._set_data("rowsDataState",a,!0)}}},{key:"markRowState",value:function(e,t){var n=this.getRowDataState(e);n!==H&&n!==t&&this.setRowDataState(e,t)}},{key:"markRowUpdate",value:function(e){var t="number"==typeof e?e:this.getRowIndex(e);t<0||this.markRowState(t,B)}},{key:"getRowState",value:function(e,t){var n,a=this.getRowKey(e),r=a?null===(n=this._get_data("rowState"))||void 0===n?void 0:n[a]:null;if(r&&t)return r[t]}},{key:"setRowState",value:function(e,t,n){var a,r=null===(a=this._get_data("rows"))||void 0===a?void 0:a[e];if(r&&t){var i=this.getRowKey(e),o=this.getRowState(e,t);if(o!==n){var u={rowIndex:e,rowId:r[this.getIdFlag()],propertyName:t,value:n,oldValue:o};if(this.execute("beforeRowStateChange",u)){var l=f({},this._get_data("rowState")||{});l[i]=f(f({},l[i]||{}),{},s({},t,n)),this._applyState("rowState",l),this.execute("afterRowStateChange",u)}}}}},{key:"setRowStates",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];z(t)&&t.forEach(function(t){return e.setRowState(t.rowIndex,t.propertyName||t.name,t.value)})}},{key:"getDirtyData",value:function(e){var t=this,n=this._get_data("dataSource")||[],a=this._get_data("rowsDataState")||[],r=[];return n.forEach(function(e,n){var i=a[n];if(i){var o=J(e);o[t.getStatusFlag()]=i,r.push(o)}}),r.length?r:void 0}},{key:"getDirtyRowIndexes",value:function(){var e=this;return(this._get_data("rows")||[]).map(function(e,t){return t}).filter(function(t){return!!e.getRowDataState(t)})}},{key:"isDirty",value:function(){return!!this.getDirtyData()}},{key:"backupState",value:function(){this._set_data("backupData",{dataSource:J(this._get_data("dataSource")||[]),rowsDataState:w(this._get_data("rowsDataState")||[])})}},{key:"restoreState",value:function(){var e=this._get_data("backupData");e&&(this._set_data("dataSource",e.dataSource,!0),this._set_data("rowsDataState",w(e.rowsDataState),!0),this.showPage())}},{key:"insertRow",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>3?arguments[3]:void 0,a=this._get_data("rows")||[],r=Math.min(a.length,Math.max(0,void 0===e?a.length:e)),i={index:r,row:f({},t),isCopy:n};if(this.execute("beforeInsertRow",i)){var o=i.row;delete o[this.getIdFlag()],Q.call(this,[o]);var s=this._get_data("dataSource")||[],u=r<a.length?this.getDataSourceIndexByRow(r):s.length;s.splice(u<0?s.length:u,0,o);var l=w(this._get_data("rowsDataState")||[]);return l.splice(u<0?l.length:u,0,H),a.splice(r,0,o),this._set_data("rowsDataState",l,!0),this.setRows(a),this.execute("afterInsertRow",f(f({},i),{},{rowIndex:r})),o}}},{key:"insertRows",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],a=[];return(z(n)?n:[n]).forEach(function(n,r){a.push(t.insertRow(e+r,n))}),a}},{key:"appendRow",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this.insertRow(this.getRowsCount(),e)}},{key:"updateRow",value:function(e){var t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},a=null===(t=this._get_data("rows"))||void 0===t?void 0:t[e];a&&this.execute("beforeUpdateRow",{index:e,row:n})&&(Object.assign(a,n),this.markRowState(e,B),this.setRows(this._get_data("rows")),this.execute("afterUpdateRow",{index:e,row:a}))}},{key:"updateRows",value:function(){var e=this;(arguments.length>0&&void 0!==arguments[0]?arguments[0]:[]).forEach(function(t){var n;return e.updateRow(null!==(n=t.rowIndex)&&void 0!==n?n:t.index,t.rowData||t.row)})}},{key:"deleteRows",value:function(e){var t=this,n=(z(e)?e:[e]).filter(function(e){return e>=0&&e<t.getRowsCount()}).sort(function(e,t){return e-t});if(n.length){var a=this.getRowsByIndexes(n);if(this.execute("beforeDeleteRows",a,n)){var r=this._get_data("dataSource")||[],i=w(this._get_data("rowsDataState")||[]),o=new Set,s=new Set;a.forEach(function(e){var n=r.indexOf(e);if(!(n<0)){var a=e[t.getIdFlag()];o.add(a),i[n]===H&&s.add(a)}});var u=[],l=[];r.forEach(function(e,n){var a=e[t.getIdFlag()];if(!o.has(a))return u.push(e),void l.push(i[n]);s.has(a)||(u.push(e),l.push(L))}),this._set_data("dataSource",u,!0),this._set_data("rowsDataState",l,!0),this.showPage(),this.execute("afterDeleteRows",{rowIndexes:n,rows:a})}}}},{key:"deleteAllRows",value:function(){this.deleteRows(this.getRows().map(function(e,t){return t}))}},{key:"clear",value:function(){this._set_data("dataSource",[],!0),this._set_data("rows",[],!0),this._set_data("rowsDataState",[],!0),this.clearSelection(),this.applyPageInfo(f(f({},this.getPageInfo()),{},{recordCount:0,pageIndex:1})),this.setDataSourceView()}},{key:"select",value:function(e,t){var n=this;if(null!=e||!0===t){!0===t&&this.unselectAll({silent:!0});var a=!0===t?this.getRows().map(function(e,t){return t}):z(e)?e:[e];a=a.filter(function(e){return e>=0&&e<n.getRowsCount()});var r=this._get_data("rows")||[],i=this.getSelectedFlag(),o=a.filter(function(e){return!r[e][i]});if(o.length){var s={rowIndexes:o,rows:o.map(function(e){return r[e]})};this.execute("beforeSelect",s)&&(o.forEach(function(e){r[e][i]=!0,n.cacheSelectedRow(r[e],!0)}),this.flushSelection())}else!0===t&&this.flushSelection()}}},{key:"unselect",value:function(e){var t=this;if(null!=e){var n=z(e)?e:[e],a=this._get_data("rows")||[],r=this.getSelectedFlag(),i=n.filter(function(e){var t;return null===(t=a[e])||void 0===t?void 0:t[r]});i.length&&this.execute("beforeUnselect",i)&&(i.forEach(function(e){a[e][r]=!1,t.cacheSelectedRow(a[e],!1)}),this.flushSelection())}}},{key:"selectAll",value:function(){var e=this,t=this._get_data("rows")||[],n=this.getSelectedFlag();t.forEach(function(t){t[n]=!0,e.cacheSelectedRow(t,!0)}),this.flushSelection()}},{key:"unselectAll",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=this.getSelectedFlag();((t.onlyPage?this._get_data("rows"):this._get_data("dataSource"))||[]).forEach(function(e){e[n]=!1}),t.onlyPage?(this._get_data("rows")||[]).forEach(function(t){return e.cacheSelectedRow(t,!1)}):(this._set_data("selectedKeys",[],!0),this._set_data("selectedRowsMap",{},!0),this._set_data("selectedKeysSet",new Set,!0)),t.silent||this.flushSelection()}},{key:"clearSelection",value:function(){this.unselectAll()}},{key:"setSelectedRows",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],n=z(t)?t:[],a=this.getRowKeyField(),r=new Set(n.map(function(e){var t;return String(null!==(t=null==e?void 0:e[a])&&void 0!==t?t:e)})),i=this._get_data("rows")||[],o=this.getSelectedFlag();i.forEach(function(t){var n=r.has(String(t[a]));n!==!!t[o]&&(t[o]=n,e.cacheSelectedRow(t,n))}),this.flushSelection()}},{key:"setSelection",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];this.unselectAll({silent:!0}),this.setSelectedRows(e)}},{key:"getSelectedRows",value:function(e){var t=this._get_data("rows")||[],n=this.getSelectedFlag(),a=e&&new Set(z(e)?e:[e]);return t.filter(function(e,t){return e[n]&&(!a||a.has(t))})}},{key:"getSelectedRowIndexes",value:function(){var e=this._get_data("rows")||[],t=this.getSelectedFlag(),n=[];return e.forEach(function(e,a){e[t]&&n.push(a)}),n}},{key:"getSelectedKeys",value:function(){return this._get_data("selectedKeys")||[]}},{key:"getAllCacheSelectedRows",value:function(){var e=this._get_data("selectedKeys")||[],t=this._get_data("selectedRowsMap")||{};return e.map(function(e){return t[e]}).filter(Boolean)}},{key:"selectByKeys",value:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],n=this.getRowKeyField(),a=z(e)?e:[e],r=this._get_data("rows")||[],i=[];a.forEach(function(e){var t=r.findIndex(function(t){return String(t[n])===String(e)});t>-1&&i.push(t)}),i.length&&(t?this.select(i):this.unselect(i))}},{key:"getSelectedNodes",value:function(){return this.getAllCacheSelectedRows()}},{key:"cacheSelectedRow",value:function(e,t){var n=String(null==e?void 0:e[this.getRowKeyField()]),a=(this._get_data("selectedKeys")||[]).filter(function(e){return e!==n}),r=f({},this._get_data("selectedRowsMap")||{});t&&a.push(n),t?r[n]=e:delete r[n],this._set_data("selectedKeys",a,!0),this._set_data("selectedRowsMap",r,!0),this._set_data("selectedKeysSet",new Set(a),!0)}},{key:"flushSelection",value:function(){this._applyState("selectedRows",this.getSelectedRows()),this.execute("selectionChange",{value:this.getSelectedRows(),keys:this.getSelectedKeys(),indexes:this.getSelectedRowIndexes()})}},{key:"restoreSelectedFlags",value:function(){if(this.get("cacheSelectedRows")){var e=this._get_data("selectedKeysSet")||new Set;if(e.size){var t=this.getRowKeyField(),n=this.getSelectedFlag();(this.getRows()||[]).forEach(function(a){a[n]=e.has(String(a[t]))})}}}},{key:"setPagination",value:function(e){this._applyState("pagination",!!e),this.showPage()}},{key:"getPageInfo",value:function(){return this._get_data("pageInfo")||createDefaults().pageInfo}},{key:"getPageIndex",value:function(){return this.getPageInfo().pageIndex}},{key:"getPageSize",value:function(){return this.getPageInfo().pageSize}},{key:"getTotalCount",value:function(){return this.getPageInfo().recordCount}},{key:"setPageInfo",value:function(e){this.applyPageInfo(f(f({},this.getPageInfo()),e),{refresh:!0})}},{key:"setPageIndex",value:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];"number"==typeof e&&this.applyPageInfo(f(f({},this.getPageInfo()),{},{pageIndex:Math.max(1,e)}),{refresh:t})}},{key:"setPageSize",value:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];"number"==typeof e&&this.applyPageInfo(f(f({},this.getPageInfo()),{},{pageSize:Math.max(-1,e),pageIndex:1}),{refresh:t})}},{key:"setRecordCount",value:function(e){this.applyPageInfo(f(f({},this.getPageInfo()),{},{recordCount:e||0}))}},{key:"applyPageInfo",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=f({},e||{}),a=-1===n.pageSize?-1:n.pageSize||20,r=n.recordCount||0,i=r>0;return n.pageSize=a,n.recordCount=r,n.pageCount=a>0?Math.max(1,Math.ceil(r/a)):1,n.pageIndex=a>0?Math.max(1,i?Math.min(n.pageIndex||1,n.pageCount):n.pageIndex||1):1,n.beginPageIndex=a>0?(n.pageIndex-1)*a+1:1,n.endPageIndex=a>0?Math.min(n.pageIndex*a,r):r,this._set_data("pageInfo",n,!0),t.silent||(this._applyState("pageInfo",n),this.isRemote()||this.showPage(),t.refresh&&this.isRemote()&&this.refresh()),n}},{key:"showPage",value:function(){var e=this._get_data("dataSource")||[];if(!this.isRemote()&&this.isPagination()){var t=this.getPageInfo(),n=t.pageIndex,a=t.pageSize,r=(n-1)*a;this.setRows(e.slice(r,r+a))}else this.setRows(e)}},{key:"setRows",value:function(e){var t=z(e)?e:[];this._set_data("rows",t,!0),this.setRowsIdMap(),this._applyState("data",t)}},{key:"setDataSourceView",value:function(){this._applyState("data",this._get_data("rows")||[])}},{key:"setRowsIdMap",value:function(){var e=this,t={};(this._get_data("rows")||[]).forEach(function(n){void 0!==(null==n?void 0:n[e.getIdFlag()])&&(t[n[e.getIdFlag()]]=n)}),this._set_data("rowsIdMap",t)}},{key:"getRowIdMap",value:function(){return this._get_data("rowsIdMap")||{}}},{key:"validate",value:function(e,t){var n=this;if(e)return this.doPropertyChange("validate",{type:"",message:"",errors:[]}),this._set_data("validateErrors",[]),!1;this.deleteNotModifiedRows();var a=this._get_data("columns")||{},r=t?this.getRowsByIndexes(t):this.getRows(),i=[];r.forEach(function(e,t){for(var r in a){var o=a[r];if(n.isRequiredColumn(o)){var s=e[r];if(G(s)||z(s)&&!s.length||X(s)){var u=o.cShowCaption||o.cCaption||o.cCaption||o.title||r;i.push({rowIndex:t,rowId:e[n.getIdFlag()],cellName:r,message:"".concat(u,"不能为空")}),n.setCellState(t,r,"msg","不能为空")}}}}),this._set_data("validateErrors",i);var o=i.length?i[0].message:"";return this.doPropertyChange("validate",{type:i.length?"error":"",message:o,errors:i}),this.execute("afterValidate",{valid:!i.length,errors:i}),!i.length}}])}(),ee=function(){function e(){return r(this,e),a(this,e,arguments)}return l(e,T),o(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 T&&(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 a,r=e.get(t);r instanceof T&&!1!==r._get_data("needCollect")&&(n[t]=null===(a=r.getData)||void 0===a?void 0:a.call(r))}),n}},{key:"getAllData",value:function(e){var t=this,n=this._get_data("propertyNames")||[],a={};return n.forEach(function(n){var r,i=t.get(n);if(i instanceof T&&!1!==i._get_data("needCollect")&&(!e||!i._get_data("isGrid"))){var o=null===(r=i.getData)||void 0===r?void 0:r.call(i);void 0!==o&&(a[n]=o)}}),a}},{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 a,r=t.get(n);r instanceof T&&!1!==r._get_data("needClear")&&(null===(a=r.clear)||void 0===a||a.call(r,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 a=null===(t=this.getParams())||void 0===t?void 0:t.masterGridModelName;if(a)return this.get(a);for(var r=this._get_data("propertyNames"),i=0,o=r.length;i<o;i++){if((n=this.get(r[i]))instanceof Z||"GridModel"==n.modelType)return this._set_data("gridModel",n),n}}},{key:"getGridModels",value:function(){for(var e=this._get_data("propertyNames"),t=[],n=0,a=e.length;n<a;n++){var r=this.get(e[n]);(r instanceof Z||"GridModel"==r.modelType)&&t.push(r)}return t}}])}();function te(e){var t=this;window&&window.__debugger_initExtendJs;var n=e.requirejs,a=e.extendFilePath,r=e.pageKey,i=e.enableExtendJs,o=void 0===i||i,s=e.extendJsPath,u=void 0===s?"_VM.Extend.js":s;if(o){var l="".concat(r).concat(u),c=[l];if("function"!=typeof n.require)return console.warn("requirejs.js 未加载,跳过扩展脚本:".concat(l)),void t.execute("extendReady",t);n.require(a,c,function(e,n){if(e&&e.doAction)try{e.doAction("init",t),n&&n.doAction("init",t)}catch(e){console.error("扩展脚本异常:",e)}else console.error("".concat(l,"扩展文件extend.*.min.js文件加载失败 或 未注册扩展脚本"));t.execute("extendReady",t)},function(e){console.warn("未找到扩展脚本:".concat(l,"错误信息:"),e),t.execute("extendReady",t)})}else t.execute("extendReady",t)}var ne=function(){var e=n(v().m(function e(t,a,r){var i,o,s,u;return v().w(function(e){for(;;)switch(e.n){case 0:if(s=t.extscripturls,u=void 0===s?[]:s,u=(u=(a.getCache("localDynamicScripts")||[]).concat(u)).concat(window.__devfab__EXT_BILL_SCRIPTS__||[]),null!==(i=a.getParams())&&void 0!==i&&i.initVMExtUrls&&(u=u.concat([a.getParams().initVMExtUrls])),null===(o=u)||void 0===o||!o.length){e.n=2;break}return u=w(new Set(u)),e.n=1,Promise.all(u.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 1:u=e.v;case 2:return t.extscripturls=u,e.a(2,new Promise(function(e,n){ae(t,a,r,function(){e(!0)})}))}},e)}));return function(t,n,a){return e.apply(this,arguments)}}();function ae(e,t,n,a){var r=e.extscripturls,i=void 0===r?[]:r;if(null!=i&&i.length)try{var o,s=null==n||null===(o=n.requirejs)||void 0===o?void 0:o.requireInner;if("function"!=typeof s)return console.warn("requirejs.js 未加载,跳过客开扩展脚本"),void(null==a||a(e,t));s(i,function(){var n=!0;if(arguments.length){for(var r=0,i=arguments.length;r<i;r++){var o=r<0||arguments.length<=r?void 0:arguments[r];o?o.doAction("init",t):n=!1}n&&(null==a||a(e,t))}else n=!1;n||console.log("[error] [extendjs] 租户级扩展脚本有语法错误,请修改正确后刷新浏览器重试!")},function(n){null==a||a(e,t)})}catch(n){null==a||a(e,t)}else null==a||a(e,t)}function re(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.extendFilePathField,i=void 0===n?"domainKey":n,s=t.pageKeyField,u=void 0===s?"billNo":s,c=t.modelNameField,d=void 0===c?"cName":c,h=e[i]||"",v=e[u]||"",g=function(){function e(){return r(this,e),a(this,e,arguments)}return l(e,ee),o(e,[{key:"init",value:function(e,t){var n=this.createModels(e,t);this.setData(n),this.setDirty(!1)}},{key:"createModels",value:function(e,n){var a={};return(Array.isArray(e)?e:[]).forEach(function(e){var r,i,o=null==t||null===(r=t.createModelFactory)||void 0===r?void 0:r.call(t,e);o||(o=function(e){var t;"input"===e.cControlType.toLowerCase()&&(t=new V(e));return t}(e));var s={model:o,field:e,meta:n};null==t||null===(i=t.onBeforeCreateModel)||void 0===i||i.call(t,s),a[e[d]]=s.model}),a}},{key:"initData",value:function(){te.call(this,f(f({},t),{},{extendFilePath:h,pageKey:v}))}}])}();return g.prototype.modelType="ViewModel",g}var ie={BaseModel:T,FilterModel:K,SimpleModel:V,GridModel:Z,ViewModel:ee,initViewModel:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},a=arguments.length>2?arguments[2]:void 0;null!=t&&t.requirejs||(t.requirejs=window.__devfab);var r=function(e,t){var n=new(re(e,t));return n.init(e.models,e),n}(e,t);return r.on("destroyVM",function(){var e,t;null===(e=r)||void 0===e||null===(t=e.destroyVM)||void 0===t||t.call(e),r=null}),r.on("extendReady",n(v().m(function n(){var i;return v().w(function(n){for(;;)switch(n.n){case 0:return(i=[]).push(ne(e,r,t)),n.n=1,Promise.all(i);case 1:null==a||a(r,e);case 2:return n.a(2)}},n)}))),r.initData(),r}},oe={Builder:D,CacheUtil:j,EventUtil:E,DynamicProxy:N},se={utils:{builder:new oe.Builder,cache:new oe.CacheUtil,event:new oe.EventUtil},common:{Builder:D,models:ie,utils:oe}};export{se as default};
package/dist/index.js CHANGED
@@ -1 +1,3 @@
1
- "use strict";function e(e,t){(null==t||t>e.length)&&(t=e.length);for(var a=0,n=Array(t);a<t;a++)n[a]=e[a];return n}function t(e,t,a){return t=o(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,u()?Reflect.construct(t,a||[],o(e).constructor):t.apply(e,a))}function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function n(e,t){for(var a=0;a<t.length;a++){var n=t[a];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,v(n.key),n)}}function i(e,t,a){return t&&n(e.prototype,t),a&&n(e,a),Object.defineProperty(e,"prototype",{writable:!1}),e}function r(e,t,a){return(t=v(t))in e?Object.defineProperty(e,t,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[t]=a,e}function o(e){return o=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},o(e)}function s(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&&h(e,t)}function u(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(u=function(){return!!e})()}function l(e,t){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),a.push.apply(a,n)}return a}function c(e){for(var t=1;t<arguments.length;t++){var a=null!=arguments[t]?arguments[t]:{};t%2?l(Object(a),!0).forEach(function(t){r(e,t,a[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(a)):l(Object(a)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(a,t))})}return e}function d(e,t){if(null==e)return{};var a,n,i=function(e,t){if(null==e)return{};var a={};for(var n in e)if({}.hasOwnProperty.call(e,n)){if(-1!==t.indexOf(n))continue;a[n]=e[n]}return a}(e,t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);for(n=0;n<r.length;n++)a=r[n],-1===t.indexOf(a)&&{}.propertyIsEnumerable.call(e,a)&&(i[a]=e[a])}return i}function h(e,t){return h=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},h(e,t)}function f(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var a=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=a){var n,i,r,o,s=[],u=!0,l=!1;try{if(r=(a=a.call(e)).next,0===t){if(Object(a)!==a)return;u=!1}else for(;!(u=(n=r.call(a)).done)&&(s.push(n.value),s.length!==t);u=!0);}catch(e){l=!0,i=e}finally{try{if(!u&&null!=a.return&&(o=a.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}(e,t)||p(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)||p(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 v(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var a=e[Symbol.toPrimitive];if(void 0!==a){var n=a.call(e,t||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}function y(e){return y="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},y(e)}function p(t,a){if(t){if("string"==typeof t)return e(t,a);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?e(t,a):void 0}}Object.defineProperty(exports,"__esModule",{value:!0});var w=["component","children","render"],m=!1,S={},k=null;function x(e){return S[e]}function R(e,t){if(Array.isArray(e)){var a=[];return e.forEach(function(e,n){var i=e.component,r=e.children,o=e.render,s=d(e,w),u=x(i);u||"function"==typeof o||console.log("[warning] Component ".concat(i," is not registered!"));var l={component:u,children:R(r,t)};s.index=n;var c=Object.assign({},null==t?void 0:t.props,s);"function"==typeof o?a.push(o({node:l,props:c})):"function"==typeof k?a.push(k({node:l,props:c})):(Object.assign(l,c),a.push(l))}),a}}var b=function(){return i(function e(){a(this,e)},[{key:"init",value:function(e){m||("function"==typeof e&&e(),m=!0)}},{key:"initComponent",value:function(e,t){!function(e,t){if(e)"string"==typeof e?S[e]?console.log("[warning] Component ".concat(e," is exist!")):S[e]=t:Object.assign(S,e)}(e,t)}},{key:"getComponents",value:function(){return c({},S)}},{key:"getComponent",value:function(e){return x(e)}},{key:"hasComponent",value:function(e){return!!x(e)}},{key:"initRenderFactory",value:function(e){!function(e){k=e}(e)}},{key:"initRequest",value:function(){}},{key:"render",value:function(e,t){return R(e,t)}},{key:"clear",value:function(){S={},k=null,m=!1}}])}(),C=function(){return i(function e(t){a(this,e),this._init(t)},[{key:"_init",value:function(e){this.cache=Object.assign({},e)}},{key:"set",value:function(e,t){this.cache[e]=t}},{key:"get",value:function(e){var t;return null===(t=this.cache)||void 0===t?void 0:t[e]}},{key:"clear",value:function(e){delete this.cache[e]}}])}(),I=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,a){var n=this.events.get(e);Array.isArray(n)||(n=[]),n.push({callback:t,context:a}),this.events.set(e,n)}},{key:"onFirst",value:function(e,t,a){var n=this.firstevents.get(e);Array.isArray(n)||(n=[]),n.splice(0,0,{callback:t,context:a}),this.firstevents.set(e,n)}},{key:"execute",value:function(e){for(var t=arguments.length,a=new Array(t>1?t-1:0),n=1;n<t;n++)a[n-1]=arguments[n];var i=this.events.get(e),r=this.firstevents.get(e);if(!i&&!r)return!0;var o=!0;return[].concat(g(r||[]),g(i||[])).forEach(function(e){if(!1!==o){var t=e.callback.apply(e.context||void 0,a);o=!1!==t&&o}}),o}},{key:"un",value:function(e,t){this._unEvents(e,t,this.events),this._unEvents(e,t,this.firstevents)}},{key:"_unEvents",value:function(e,t,a){if(e&&a.has(e))if(t){var n=a.get(e),i=null==n?void 0:n.findIndex(function(e){return e.callback===t});-1!==i&&(null==n||n.splice(i,1))}else a.delete(e)}},{key:"hasEvent",value:function(e){var t,a;return e?((null===(t=this.events.get(e))||void 0===t?void 0:t.length)||0)+((null===(a=this.firstevents.get(e))||void 0===a?void 0:a.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,a){for(var n,i=this,r=a.resolve,o=a.reject,s=a.args,u=!0,l=t||[],c=!1,d=function(t){var a,n=l[t];if(!1===u)return 0;if(c)return{v:void 0};if("development"===process.env.nodeEnv)a=n.callback.apply(n.context||i,s);else try{a=n.callback.apply(n.context||i,s)}catch(e){throw e.isAddedMsg||(e.message="(领域扩展事件执行失败,请打开控制台查看详细错误信息并修复):".concat(e.message)),e.isAddedMsg=!0,e}a instanceof Promise?(c=!0,(u=a).callbacks&&u.callbacks.push({reject:function(){u.reject(),t===l.length-1&&(null==o||o())},resolve:function(a){t===l.length-1?(s.length>1&&(s[0]=a),null==r||r(s)):i._asyncExecute(e,l.slice(t+1),{resolve:r,reject:o,args:s})}})):(u=!1!==a&&u,t===l.length-1&&(u?null==r||r(s):null==o||o()))},h=0;h<l.length&&0!==(n=d(h));h++)if(n)return n.v;return u}},{key:"_asyncPromiseExecute",value:function(e,t,a,n){var i=this.events.get(e),r=this.firstevents.get(e);if(!((Array.isArray(i)?i.length:i)||(Array.isArray(r)?r.length:r)))return null==t?void 0:t();var o=[].concat(g(r||[]),g(i||[]));return this._asyncExecute(e,o,{resolve:t,reject:a,args:n})}},{key:"promiseExecute",value:function(e,t){var a=this,n=e,i=1;if("boolean"==typeof e&&(n=t,i=2),n){for(var r=arguments.length,o=new Array(r>2?r-2:0),s=2;s<r;s++)o[s-2]=arguments[s];var u=2===i?o:[t].concat(o);if(u.length){var l,c=u.length-1,d=u[c];if("function"!=typeof d){if("object"!==y(d)||!d[0]||"function"!=typeof d[0]||!d[1]||"function"!=typeof d[1])return;l=d[1],d=d[0]}if(this.__ASYNC_EXECUTE__)return this._asyncPromiseExecute(n,function(e){d.apply(a,e)},function(){l&&"function"==typeof l&&l()},u);u.splice(c,1),u.unshift(n);var h=this.execute.apply(this,u);if(h instanceof Promise){var f=this;h.then(function(){for(var e=arguments.length,t=new Array(e),a=0;a<e;a++)t[a]=arguments[a];d.apply(f,t)},function(){l&&"function"==typeof l&&l()})}else if(!h)return void(l&&"function"==typeof l&&l())}}}},{key:"clearEvents",value:function(){this.events.clear(),this.firstevents.clear()}}])}();function P(e){this.pathname="",this.query={};var t=e;this.init=function(){t||(t=location.search);var e=t.indexOf("?"),a=t.indexOf("#");if(e>=0){if(this.pathname=t.substr(0,e),(t=a<0?t.substr(e+1):t.substring(e+1,a)).length>0)for(var n=(t=t.replace(/\+/g," ")).split("&"),i=0,r=n.length;i<r;i++){var o=n[i]||"";if(o){var s=o.indexOf("="),u="",l="";s<0?l=u=window.decode(o):(u=window.decode(o.substr(0,s)),l=window.decode(o.substr(s+1))),this.query[u]=l}}}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 D(e,t){if(!t)return e;var a=[],n=new P(e);for(var i in t)n.get(i)||a.push("".concat(i,"=").concat(t[i]));if(!a.length)return e;var r=a.join("&");return e.indexOf("?")>=0?"".concat(e,"&").concat(r):"".concat(e,"?").concat(r)}String.prototype.equalsIgnoreCase=function(e){return null!=e&&this.toLowerCase()===e.toLowerCase()};var E=["onBeforeRequest","_onAfterRequest"],O=["_onBeforeRequest","onAfterRequest"];var j={_xhrs:[],_jsonps:{index:0},doRequest:function(e){var t=e||{},a=t.onBeforeRequest;t._onAfterRequest;var n,i=d(t,E),r=i.method||"GET",o=i.url;try{null!=i&&i.requestHeaders&&(n=i.requestHeaders,i.requestHeaders=void 0,delete i.requestHeaders)}catch(e){console.log('[ajax]: [doRequest]: options["requestHeaders"] ERR : ',e)}try{i.params&&i.params.requestHeaders&&(n=i.params.requestHeaders,i.params.requestHeaders=void 0,delete i.params.requestHeaders)}catch(e){console.log('[ajax]: [doRequest]: options.params["requestHeaders"] ERR : ',e)}var s=null;if(r.equalsIgnoreCase("get")||r.equalsIgnoreCase("delete")?o=D(o,i.params):(r.equalsIgnoreCase("post")||r.equalsIgnoreCase("put"))&&(s=JSON.stringify(i.params)),i.jsonp)return this.getJsonp(o,i.callback);var u=this.getXMLHttpRequest();if(u){var l;if(u.open(r,o,!1!==i.async),i.timeout&&(u.timeout=i.timeout,u.setRequestHeader("timeout",i.timeout),u.ontimeout=function(){j.onerror(this,i,"timeout")}),i.contentType){if(u.setRequestHeader("Content-Type",i.contentType),i.contentType.indexOf("x-www-form-urlencoded")>=0)s=null===(l=new URLSearchParams(i.params))||void 0===l?void 0:l.toString()}else i.dateType?s=i.params:u.setRequestHeader("Content-Type","application/json;charset=utf-8");i.domainKey&&u.setRequestHeader("Domain-Key",i.domainKey);try{if(n&&"[object Object]"===Object.prototype.toString.call(n))for(var c in n)u.setRequestHeader(c,n[c])}catch(e){console.log('[ajax]: [doRequest]: options.params["requestHeaders"] ERR : ',e)}u.withCredentials=null==i||!i.hasOwnProperty("withCredentials")||i.withCredentials;try{u.send(s)}catch(e){return{error:"NetWorkError",options:i}}if(!1===i.async)return null==a||a(i),this.onreadystatechange(u,i);u.onreadystatechange=function(){j.onreadystatechange(this,i)},null==a||a(i)}},beforeReadystatechange:function(e,t,a){null==a||a()},onreadystatechange:function(e,t){var a=t||{};a._onBeforeRequest;var n=a.onAfterRequest,i=d(a,O);if(4===e.readyState){if(null==n||n(),200===e.status){var r;try{if("blob"===i.responseType){var o=function(e){var t=e.xhr.getAllResponseHeaders(),a={};return t.split("\r\n").map(function(e){var t=f(e.split(": "),2),n=t[0],i=t[1];a[n]=i}),a}({xhr:e});r={code:e.status,data:{data:e.response,headers:o}}}else r=JSON.parse(e.responseText)}catch(t){j.onerror(e,i,e.responseText)}if(!1===i.async)return e.isBusy=!1,i.precallback&&i.precallback(r),j.processAjaxResult(r,!1,null,null,i,e);j.processAjaxResult(r,i.async,i.callback,i.context,i,e),i.precallback&&i.precallback(r)}else if(0===e.status)j.onerror(e,i,"网络连接已断开,请检查设备网络状态后重试");else if(502===e.status||504===e.status)j.onerror(e,i,"服务出错了,请稍后再试");else{if(401!==e.status){var s={};try{s=JSON.parse(e.responseText)}catch(t){s={code:e.status,message:e.responseText}}return j.onerror(e,i,s)}j.onerror(e,i,"登录信息失效,请重新登录或联系技术人员")}e.isBusy=!1}},onerror:function(e,t,a){var n="[ajax]: [onerror]: 接口返回错误 \n [状态码]: ".concat(e.status," \n [错误信息]: ").concat(("object"===y(a)?JSON.stringify(a):a)||"空"," \n [请求地址]: ").concat(t.url," \n [浏览器Token]: ").concat(document.cookie);console.log("Error.E01000",n);var i="object"===y(a)?a:{code:500,message:a};t.precallback&&t.precallback(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 a=e,n="callback"+this._jsonps.index++,i=document.createElement("script");this._jsonps[n]=function(e){try{t(e)}finally{document.body.removeChild(i)}},a+=-1===a.indexOf("?")?"?":"&callback=cb.rest.AjaxRequestManager._jsonps."+n,i.src=a,document.body.appendChild(i)},processAjaxResult:function(e,t,a,n,i,r){if(e){if(!e.code)return!1===t?e:void(a&&a.call(n,null,e));if(200==e.code){if(!1===t)return{result:e.data};a&&a.call(n,null,e.data,e.message,e.errorDetail,e.code,e.displayCode&&e)}else{if(!1===t)return{error:e};a&&a.call(n,e)}}}};function q(e,t){this.init&&this.init(e),this.queryParams=t}q.create=function(e,t){return new q(e,t)},q.prototype.init=function(e){if(e)for(var t in this.config=e,this.config)this[t]=function(e){return function(t,a,n){return this.Do(e,t,a,null,n)}}(t),this["".concat(t,"Sync")]=function(e){return function(t){return this.Do(e,t,null,!1)}}(t)},q.prototype.Do=function(e,t,a,n,i){var r,o,s;if(this.config&&this.config[e]&&this.config[e].url){var u=this.config[e],l=u.url;this.queryParams||(this.queryParams={}),null!==(r=u.options)&&void 0!==r&&r.proxyServiceCode&&(this.queryParams.serviceCode=u.options.proxyServiceCode),null!==(o=u.options)&&void 0!==o&&o.billnum&&(this.queryParams.billnum=u.options.billnum),null!==(s=this.queryParams)&&void 0!==s&&s.serviceCode&&(l=D(l,this.queryParams));var c=l,d=Object.assign({},u.options);return d.method=u.method||"GET","function"==typeof t?(d.callback=t,d.context=i||d.context||this):d.params=t,a&&(d.callback=a,d.context=i||d.context||this),!1===n&&(d.async=!1),this.ajax(c,d)}},q.prototype.ajax=function(e,t){return function(e,t){return t.url=e,j.doRequest(t)}(e,t)};var M=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 a in e)t.push(a);Object.assign(this._data,{components:[],propertyNames:t},e),this._data.cache=new C,this._data.events=new I}},{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 C,events:new I}}},{key:"_set_data",value:function(e,t,a){if(e){if(a){var n=this._data.propertyNames||[];n.indexOf(e)<0&&n.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 a;if(!t)return this._get_data(e);var n=(this._get_data("components")||[]).find(function(e){return e.ctrlName===t});return n?null===(a=n.getState)||void 0===a?void 0:a.call(n,e):this._get_data(e)}},{key:"setState",value:function(e,t,a){a||this._set_data(e,t,!0);var n={};n[e]=t,this.doPropertyChange("setState",n,a)}},{key:"doPropertyChange",value:function(e,t,a){var n=this,i=this._get_data("components")||[];if(!i.length)return i;var r=[];if(a){var o=i.find(function(e){return e.ctrlName===a});o&&!this.notifyComponent(o,e,t)&&r.push(o)}else i.forEach(function(a){n.notifyComponent(a,e,t)||r.push(a)});return r.length?r:void 0}},{key:"notifyComponent",value:function(e,t,a){return"function"==typeof e[t]&&(this.viewUpdater(e,t,a),!0)}},{key:"viewUpdater",value:function(e,t,a){if("setState"===t)e[t](a);else{var n=this.getCache("name");e[t](a,n)}}},{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 a=this._get_data("components")||[];a.indexOf(e)>=0||a.push(e)}}},{key:"removeComponent",value:function(e){var t=this._get_data("components")||[],a=t.indexOf(e);a<0||t.splice(a,1)}},{key:"_applyState",value:function(e,t,a){var n=this;a||this._set_data(e,t,!0);var i="set".concat(e.charAt(0).toUpperCase()).concat(e.slice(1)),r=this.doPropertyChange(i,t,a);if(r){var o={};o[e]=t,r.forEach(function(e){n.notifyComponent(e,"setState",o)})}}},{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,a){var n=this,i=this.getValue();if(e!==i){var r={value:e,oldValue:i},o=this._get_data("forceFireEvent");t||o?this.promiseExecute("beforeValueChange",r,[function(){n._set_data("value",e,!0),n._applyState("value",e,a),n.execute("afterValueChange",r)},function(){n._set_data("value",i,!0),n._applyState("value",i,a)}]):(this._set_data("value",e,!0),this._applyState("value",e,a))}}},{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,a){this._get_data("events").on(e,t,a)}},{key:"onFirst",value:function(e,t,a){this._get_data("events").onFirst(e,t,a)}},{key:"execute",value:function(e){for(var t,a=arguments.length,n=new Array(a>1?a-1:0),i=1;i<a;i++)n[i-1]=arguments[i];return(t=this._get_data("events")).execute.apply(t,[e].concat(n))}},{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 a,n=arguments.length,i=new Array(n>2?n-2:0),r=2;r<n;r++)i[r-2]=arguments[r];(a=this._get_data("events")).promiseExecute.apply(a,[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").clear(e)}},{key:"setProxy",value:function(e){if(!(e instanceof q)){var t,a=this._get_data("__requestHeaders__");for(var n in e){var i,r,o;if(a&&(null===(i=e[n])||void 0===i||null===(i=i.options)||void 0===i||!i.requestHeaders))null!==(o=e[n])&&void 0!==o&&o.options||(e[n].options={}),e[n].options.requestHeaders=a;null!==(r=this.getProxy())&&void 0!==r&&r[n]&&console.warn("[baseModel.prototype.setProxy]: Proxy ".concat(n," already exists on the model. Please change the name of ").concat(n," and try again"))}return this._set_data("proxy",q.create(c(c({},(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")}}])}(),A=function(){function e(){return a(this,e),t(this,e,arguments)}return s(e,M),i(e,[{key:"mounted",value:function(){var e=this,t=this.get("conditions"),a={};t.forEach(function(t){e.get(t.name),a[t.name]=t.defaultValue}),this._set_data("params",a)}},{key:"unmounted",value:function(){this._set_data("params",{}),this._set_data("conditions",[])}},{key:"getParams",value:function(){var e=this,t={};return this.get("conditions").forEach(function(a){var n=e.get(a.name);t[a.name]=null==n?void 0:n.getValue()}),this._set_data("params",t),t}},{key:"search",value:function(){var e=this.getParams();this.execute("search",e)}}])}(),F=function(){function e(n){return a(this,e),t(this,e,[n])}return s(e,M),i(e,[{key:"getDisabled",value:function(){return this.getState("disabled")}},{key:"setDisabled",value:function(e){return this.setState("disabled",!!e)}},{key:"getReadonly",value:function(){return this.getState("readonly")}},{key:"setReadonly",value:function(e){this.setState("readonly",!!e)}}])}(),N="",K="Insert",T="Update",V="Delete",B=Array.isArray,H=function(e){return null==e||""===e},U=function(e){return!e||0===Object.keys(e).length};function z(e){if(B(e))return e.map(z);if(e instanceof Date)return new Date(e.getTime());if(e&&"object"===y(e)){var t={};for(var a in e)t[a]=z(e[a]);return t}return e}function L(e){var t={};return(B(e)?e:Object.keys(e||{}).map(function(t){var a;return c(c({},e[t]||{}),{},{field:(null===(a=e[t])||void 0===a?void 0:a.field)||t})})).forEach(function(e,a){if(e){var n=e.field||e.cCaption||e.cFieldName||"col_".concat(a);t[n]=c(c({},e),{},{field:n,fieldName:e.fieldName||n,cCaption:e.cCaption||n,index:void 0===e.index?a:e.index})}}),t}function J(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=this.getIdFlag(),a=this.getRowKeyField(),n=this._get_data("rowIdSeq")||0;return e.forEach(function(e){if(e&&void 0===e[t]){var i=e[a];null!=i&&""!==i?e[t]=String(i):(n+=1,e[t]="rowId_".concat(n))}}),this._set_data("rowIdSeq",n),e}var X=function(e,t,a,n,i,r,o){var s=this;this.promiseExecute("beforeBatchModifyPull",function(){var r=s.setProxy({queryData:e}),o={page:{pageSize:s.getPageSize(),pageIndex:s.getPageIndex()}};o.page.pageSize||(s.setPageSize(10),o.page.pageSize=10);var u=s._get_data("bLoadPagination");u||i||(o.page.totalCount=1);var l=s._get_data("delayLoadPageInfo");u&&l&&(n&&s.setState("showDelayPagination",!0),o.page.totalCount=1);var c=Object.assign(o,t);s.setCache("proxyCache",{proxyConfig:e,params:c});var d=0,h={},f=s.getRootParent(),g=s,v=(new Date).valueOf();c.queryId=v;if(!1!==f.execute("beforeQueryData",c)){g.setCache("lastGridFilterCondition",JSON.stringify(null==c?void 0:c.condition));var y=_.cloneDeep(c);if(r.queryData(y,function(e,t,r,o){var s,c;if(setTimeout(function(){g.clearCache("isGridInLoading")},0),null==f||f.clearCache("lazySearch"),e)return this.setState("showDelayPagination",!1),void this.clearCache("setPageIndexFromBack");t=t||{},this._set_data("dataSourceMode","remote"),n&&u&&l&&(d++,t=Object.assign(h,t));var v=Array.isArray(t.recordList)?t.recordList:[];if(u&&l&&2!==d||!a||a.call(this,t,r,o),this.getCache("setPageIndexFromBack"),this.clearCache("setPageIndexFromBack"),this.execute("beforeSetDataSource",v)){var y=this._get_data("rowKeyField"),p={};v.forEach(function(e){p[e[y]]=e}),this._set_data("keyMap",p),n||!1!==this._get_data("override")?(this._set_data("dataSource",v,!0),this.doPropertyChange("resetCellStatus"),this._set_data("cellState",{},!0),this._set_data("rowState",{},!0)):this._set_data("dataSource",this._get_data("dataSource").concat(v),!0),this.setCache("currentGridData",v),v.length&&J.call(this,v),this.initRowState(),setCachePaginationRowData.call(this,v),this._get_data("sortParams");var _=this._get_data("colFilterParams");this.showRows(null,!cb.utils.isEmptyObject(_));var w=this._get_data("pageInfo");u&&!l&&(this._get_data("bLoadPagination")||i)?(w={pageSize:t.pageSize,pageIndex:t.pageIndex,pageCount:t.pageCount,recordCount:t.recordCount},this.setPageInfo(w)):(w.pageIndex=t.pageIndex,w.from="showPageInner",this.setPageInfo(w)),resetSelected.call(this),"splitview"!==(null===(s=this.getParent)||void 0===s||null===(s=s.call(this))||void 0===s||null===(c=s.getParams)||void 0===c||null===(c=c.call(s))||void 0===c?void 0:c.templateType)&&this._set_data("focusedRowIndex",-1);for(var m=arguments.length,S=new Array(m>4?m-4:0),k=4;k<m;k++)S[k-4]=arguments[k];this.execute("afterSetDataSource",v,t.viewmodel,null==S?void 0:S[1])}},s),n&&u&&l){var p=JSON.parse(JSON.stringify(e));p.options||(p.options={}),p.options.mask=!1;G.call(s,p,c,function(e){!function(e){d++,Object.assign(h,e),2===d&&a&&a.call(s,h)}(e)})}}})};function G(e,t,a){this.setCache("queryPageCountLoading",!0);var n=this.setProxy({queryPageCount:c({},e)}),i=Object.assign(!0,t,{page:{totalCount:-1}});this.__queryPageCountRequestId||(this.__queryPageCountRequestId=0),this.__queryPageCountRequestId++;n.queryPageCount(i,function(e,t,n){if(this.__queryPageCountRequestId===e)if(this.setCache("queryPageCountLoading",!1),this.setState("showDelayPagination",!1),t){var i=this._get_data("pageInfo");i&&this.setPageInfo(i)}else{var r={beginPageIndex:(n=n||{}).beginPageIndex,endPageIndex:n.endPageIndex,pageSize:n.pageSize,pageIndex:n.pageIndex,pageCount:n.pageCount,recordCount:n.recordCount};a&&a.call(this,r),this.setPageInfo(r),this.execute("afterQueryPageInfo",n)}}.bind(this,this.__queryPageCountRequestId),this)}var Y=function(){function e(){var n,i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};a(this,e);var r=c(c({},{columns:{},dataSource:[],rows:[],readOnly:!0,dataSourceMode:"local",columnMode:"local",editMode:"cell",cellState:{},rowState:{},showCheckBox:!0,multiple:!0,showRowNo:!0,pagination:!0,pageInfo:{pageIndex:1,pageSize:20,pageCount:0},innerUsedAttrs:{id:"_id",selected:"_selected",status:"_status"},multiRowModel:!1,editRowModels:{},loading:!1,params:{},originalKeyMap:{},defaultRowDatas:new Map}),i);B(r.dataSource)||(r.dataSource=[]),B(r.rows)||(r.rows=[]);var o=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=c({},e.proxyConfig||{});return"function"==typeof e.dataSource&&(t.load=t.load||e.dataSource),"string"==typeof e.cUrl&&(t.load=t.load||e.cUrl),t.load||"string"!=typeof e.url||(t.load=e.url),t}(i);r.proxyConfig=o,r.dataSourceMode=i.dataSourceMode||(o.load?"remote":"local");var s=i.cData||(B(i.data)?i.data:null);return(n=t(this,e,[r])).initPageInfo(i.cPage||i.page),n.initColumns(r.columns),n.initRowState(),n.afterInit(),s&&n.setDataSource(s),n}return s(e,M),i(e,[{key:"afterInit",value:function(){"single"===this._get_data("parentRelation")&&this._set_data("defaultSelectedRowIndexes",!0)}},{key:"initColumns",value:function(e){var t=L(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=c({},this.getPageInfo());t.pageIndex=e.pageNo||e.pageIndex||t.pageIndex||1,t.pageSize=e.pageSize||t.pageSize||20,!1===this.get("pagination")&&(t.pageSize=-1),this.applyPageInfo(t)}},{key:"initRowState",value:function(){var e=this,t=this._get_data("dataSource");this._set_data("rowsDataState",(B(t)?t:[]).map(function(t){return(null==t?void 0:t[e.getStatusFlag()])||N}),!0)}},{key:"getInnerUsedAttrs",value:function(){return this._get_data("innerUsedAttrs")}},{key:"getIdFlag",value:function(){return this.getInnerUsedAttrs().id}},{key:"getSelectedFlag",value:function(){return this.getInnerUsedAttrs().selected}},{key:"getStatusFlag",value:function(){return this.getInnerUsedAttrs().status}},{key:"getRowKeyField",value:function(){return this._get_data("rowKeyField")||"id"}},{key:"getProxyConfig",value:function(){return this._get_data("proxyConfig")||{}}},{key:"isRemote",value:function(){return"remote"===this._get_data("dataSourceMode")}},{key:"isPagination",value:function(){return!!this.get("pagination")&&-1!==this.getPageSize()}},{key:"getReadOnly",value:function(){return!!this._get_data("readOnly")}},{key:"setReadOnly",value:function(e){this._applyState("readOnly",!!e)}},{key:"getParams",value:function(){return c(c({},this.get("cParams")||{}),this._get_data("params")||{})}},{key:"setParams",value:function(e){this._set_data("params",e||{})}},{key:"setMeta",value:function(e){this._set_data("meta",e)}},{key:"getColumns",value:function(e){var t=this._get_data("columns")||{},a={};return(e?B(e)?e:[e]:Object.getOwnPropertyNames(t)).forEach(function(e){t[e]&&(a[e]=c(c({},t[e]),{},{fieldName:t[e].fieldName||e}))}),a}},{key:"getColumn",value:function(e){var t,a=null===(t=this._get_data("columns"))||void 0===t?void 0:t[e];return a?c(c({},a),{},{fieldName:a.fieldName||e}):void 0}},{key:"hasColumn",value:function(e){return!!(this._get_data("columns")||{})[e]}},{key:"getColumnList",value:function(e){var t=this.getColumns(e);return Object.keys(t).sort(function(e,a){return(t[e].index||0)-(t[a].index||0)}).map(function(e){return t[e]})}},{key:"getVisibleColumns",value:function(e){return this.getColumnList(e).filter(function(e){return!0!==e.bHidden&&!1!==e.bShowIt})}},{key:"setColumns",value:function(e){e&&this._applyState("columns",L(e))}},{key:"setColumnMode",value:function(e){this._set_data("columnMode","remote"===e?"remote":"local",!0)}},{key:"addColumns",value:function(e){var t=L(e);this._applyState("columns",c(c({},this._get_data("columns")||{}),t))}},{key:"resetColumns",value:function(e){this.setColumns(e||this.get("cColumns"))}},{key:"getColumnState",value:function(e,t,a){var n,i=this.getRowKey(e);return i?((null===(n=this._get_data("cellState"))||void 0===n||null===(n=n[i])||void 0===n?void 0:n[t])||{})[a]:void 0}},{key:"setColumnState",value:function(e,t,a,n){this.setCellState(e,t,a,n)}},{key:"setColumnStates",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];this.setCellStates(e.map(function(e){return c(c({},e),{},{cellName:e.cellName||e.columnName})}))}},{key:"setColumnValue",value:function(e,t,a){var n=this._get_data("columns")||{};n[e]&&this._applyState("columns",c(c({},n),{},r({},e,c(c({},n[e]),{},r({},t,a)))))}},{key:"load",value:function(e,t,a){this.setProxy({load:e}).load(t,function(e,t){e?cb.utils.alert(e,"error"):(t.schema&&(this._set_data("columnMode","remote"),this.setColumns(t.schema)),this.setDataSource(t.data),a&&a.call(this))},this)}},{key:"refresh",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this.hasEvent("refresh")?this.execute("refresh",e):this.fetch({body:e})}},{key:"loadData",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this.refresh(e)}},{key:"queryData",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this.refresh(e)}},{key:"getDataSource",value:function(){var e=this._get_data("dataSource")||[];if(!this.hasDeletedRow())return e;var t=this._get_data("rowsDataState")||[];return e.filter(function(e,a){return t[a]!==V})}},{key:"getRealData",value:function(){return this.getDataSource()}},{key:"getRealRows",value:function(){return this._get_data("rows")||[]}},{key:"getRowsCount",value:function(){return(this._get_data("rows")||[]).length}},{key:"getDataSourceCount",value:function(){return(this._get_data("dataSource")||[]).length}},{key:"hasDeletedRow",value:function(){return(this._get_data("rowsDataState")||[]).some(function(e){return e===V})}},{key:"getData",value:function(e,t){var a=e||t?this._get_data("rows"):this._get_data("dataSource");return this.collectRows(a,e)}},{key:"getAllData",value:function(){return this.getData(!0)}},{key:"getPageData",value:function(){return this.getData(!0)}},{key:"getEffeData",value:function(){var e=this._get_data("dataSource")||[],t=this._get_data("rowsDataState")||[];return this.collectRows(e.filter(function(e,a){return t[a]!==V}),!1)}},{key:"getRows",value:function(e){var t=this._get_data("rows")||[];return!1===e?t:t.map(function(e){return z(e)})}},{key:"collectRows",value:function(e,t){var a=this._get_data("columns")||{},n=this.getStatusFlag(),i=this.getSelectedFlag();return(e||[]).map(function(e){var r={};for(var o in e){var s;t&&o===n||(t||o!==i)&&!1!==(null===(s=a[o])||void 0===s?void 0:s.needCollect)&&(r[o]=e[o])}return r})}},{key:"getShowRows",value:function(e){return(e||this._get_data("rows")||[]).map(function(e){return c({},e)})}},{key:"getRow",value:function(e,t){var a,n=null===(a=this._get_data("rows"))||void 0===a?void 0:a[e];if(n)return!1===t?n:z(n)}},{key:"getRowIndex",value:function(e){if(!e)return-1;var t=this._get_data("rows")||[],a=this.getRowKeyField();return void 0!==e[a]?t.findIndex(function(t){return t[a]===e[a]}):t.indexOf(e)}},{key:"getRowIndexByRowId",value:function(e){var t=this;return(this._get_data("rows")||[]).findIndex(function(a){return(null==a?void 0:a[t.getIdFlag()])===e})}},{key:"getDataSourceIndexByRowId",value:function(e){var t=this;return(this._get_data("dataSource")||[]).findIndex(function(a){return(null==a?void 0:a[t.getIdFlag()])===e})}},{key:"getRowKey",value:function(e){var t,a;return null!==(t=null===(a=this._get_data("rows"))||void 0===a||null===(a=a[e])||void 0===a?void 0:a[this.getIdFlag()])&&void 0!==t?t:e}},{key:"getRowKeys",value:function(e){var t=void 0===e?this.getRows():B(e)?e:[e],a=this.getRowKeyField();return t.filter(function(e){return e&&void 0!==e[a]}).map(function(e){return e[a]})}},{key:"getRowsByIndexes",value:function(e){var t=this._get_data("rows")||[];return(B(e)?e:[e]).map(function(e){return t[e]}).filter(Boolean)}},{key:"getCellValue",value:function(e,t){var a,n=e>=0?null===(a=this._get_data("rows"))||void 0===a?void 0:a[e]:null;if(n&&t)return n[t]}},{key:"setCellValue",value:function(e,t,a){var n=(this._get_data("rows")||[])[e];if(n&&t){var i=n[t];if(i!==a){var r={rowIndex:e,rowId:n[this.getIdFlag()],cellName:t,value:a,oldValue:i};this.execute("beforeCellValueChange",r)&&(n[t]=r.value,this.markRowState(e,T),this.execute("afterCellValueChange",r),this.doPropertyChange("setCellValue",r))}}}},{key:"setCellValues",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];B(t)&&t.forEach(function(t){return e.setCellValue(t.rowIndex,t.cellName||t.field,t.value)})}},{key:"getCellState",value:function(e,t,a){var n,i=this.getRowKey(e),r=i?null===(n=this._get_data("cellState"))||void 0===n||null===(n=n[i])||void 0===n?void 0:n[t]:null;if(r)return r[a]}},{key:"setCellState",value:function(e,t,a,n){var i,o=null===(i=this._get_data("rows"))||void 0===i||null===(i=i[e])||void 0===i?void 0:i[this.getIdFlag()],s=o||e;if(!H(s)){var u=this.getCellState(e,t,a);if(u!==n){var l={rowIndex:e,rowId:o,cellName:t,propertyName:a,value:n,oldValue:u};if(this.execute("beforeCellStateChange",l)){var d=c({},this._get_data("cellState")||{});d[s]=c({},d[s]||{}),d[s][t]=c(c({},d[s][t]||{}),{},r({},a,n)),this._applyState("cellState",d),this.execute("afterCellStateChange",l)}}}}},{key:"setCellStates",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];B(t)&&t.forEach(function(t){return e.setCellState(t.rowIndex,t.cellName,t.propertyName||t.name,t.value)})}},{key:"getRowDataState",value:function(e){var t,a=this.getDataSourceIndexByRow(e);return null===(t=this._get_data("rowsDataState"))||void 0===t?void 0:t[a]}},{key:"getDataSourceIndexByRow",value:function(e){var t=this,a=(this._get_data("rows")||[])[e];if(!a)return-1;var n=this._get_data("dataSource")||[],i=n.indexOf(a);return i>-1?i:n.findIndex(function(e){return(null==e?void 0:e[t.getIdFlag()])===(null==a?void 0:a[t.getIdFlag()])})}},{key:"setRowDataState",value:function(e,t){var a=this.getDataSourceIndexByRow(e);if(!(a<0)){var n=g(this._get_data("rowsDataState")||[]);n[a]=t,this._set_data("rowsDataState",n,!0)}}},{key:"markRowState",value:function(e,t){var a=this.getRowDataState(e);a!==K&&a!==t&&this.setRowDataState(e,t)}},{key:"markRowUpdate",value:function(e){var t="number"==typeof e?e:this.getRowIndex(e);t<0||this.markRowState(t,T)}},{key:"getRowState",value:function(e,t){var a,n=this.getRowKey(e),i=n?null===(a=this._get_data("rowState"))||void 0===a?void 0:a[n]:null;if(i&&t)return i[t]}},{key:"setRowState",value:function(e,t,a){var n,i=null===(n=this._get_data("rows"))||void 0===n?void 0:n[e];if(i&&t){var o=this.getRowKey(e),s=this.getRowState(e,t);if(s!==a){var u={rowIndex:e,rowId:i[this.getIdFlag()],propertyName:t,value:a,oldValue:s};if(this.execute("beforeRowStateChange",u)){var l=c({},this._get_data("rowState")||{});l[o]=c(c({},l[o]||{}),{},r({},t,a)),this._applyState("rowState",l),this.execute("afterRowStateChange",u)}}}}},{key:"setRowStates",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];B(t)&&t.forEach(function(t){return e.setRowState(t.rowIndex,t.propertyName||t.name,t.value)})}},{key:"getDirtyData",value:function(e){var t=this,a=this._get_data("dataSource")||[],n=this._get_data("rowsDataState")||[],i=[];return a.forEach(function(e,a){var r=n[a];if(r){var o=z(e);o[t.getStatusFlag()]=r,i.push(o)}}),i.length?i:void 0}},{key:"getDirtyRowIndexes",value:function(){var e=this;return(this._get_data("rows")||[]).map(function(e,t){return t}).filter(function(t){return!!e.getRowDataState(t)})}},{key:"isDirty",value:function(){return!!this.getDirtyData()}},{key:"backupState",value:function(){this._set_data("backupData",{dataSource:z(this._get_data("dataSource")||[]),rowsDataState:g(this._get_data("rowsDataState")||[])})}},{key:"restoreState",value:function(){var e=this._get_data("backupData");e&&(this._set_data("dataSource",e.dataSource,!0),this._set_data("rowsDataState",g(e.rowsDataState),!0),this.showPage())}},{key:"insertRow",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},a=arguments.length>3?arguments[3]:void 0,n=this._get_data("rows")||[],i=Math.min(n.length,Math.max(0,void 0===e?n.length:e)),r={index:i,row:c({},t),isCopy:a};if(this.execute("beforeInsertRow",r)){var o=r.row;delete o[this.getIdFlag()],J.call(this,[o]);var s=this._get_data("dataSource")||[],u=i<n.length?this.getDataSourceIndexByRow(i):s.length;s.splice(u<0?s.length:u,0,o);var l=g(this._get_data("rowsDataState")||[]);return l.splice(u<0?l.length:u,0,K),n.splice(i,0,o),this._set_data("rowsDataState",l,!0),this.setRows(n),this.execute("afterInsertRow",c(c({},r),{},{rowIndex:i})),o}}},{key:"insertRows",value:function(e){var t=this,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],n=[];return(B(a)?a:[a]).forEach(function(a,i){n.push(t.insertRow(e+i,a))}),n}},{key:"appendRow",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this.insertRow(this.getRowsCount(),e)}},{key:"updateRow",value:function(e){var t,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=null===(t=this._get_data("rows"))||void 0===t?void 0:t[e];n&&this.execute("beforeUpdateRow",{index:e,row:a})&&(Object.assign(n,a),this.markRowState(e,T),this.setRows(this._get_data("rows")),this.execute("afterUpdateRow",{index:e,row:n}))}},{key:"updateRows",value:function(){var e=this;(arguments.length>0&&void 0!==arguments[0]?arguments[0]:[]).forEach(function(t){var a;return e.updateRow(null!==(a=t.rowIndex)&&void 0!==a?a:t.index,t.rowData||t.row)})}},{key:"deleteRows",value:function(e){var t=this,a=(B(e)?e:[e]).filter(function(e){return e>=0&&e<t.getRowsCount()}).sort(function(e,t){return e-t});if(a.length){var n=this.getRowsByIndexes(a);if(this.execute("beforeDeleteRows",n,a)){var i=this._get_data("dataSource")||[],r=g(this._get_data("rowsDataState")||[]),o=new Set,s=new Set;n.forEach(function(e){var a=i.indexOf(e);if(!(a<0)){var n=e[t.getIdFlag()];o.add(n),r[a]===K&&s.add(n)}});var u=[],l=[];i.forEach(function(e,a){var n=e[t.getIdFlag()];if(!o.has(n))return u.push(e),void l.push(r[a]);s.has(n)||(u.push(e),l.push(V))}),this._set_data("dataSource",u,!0),this._set_data("rowsDataState",l,!0),this.showPage(),this.execute("afterDeleteRows",{rowIndexes:a,rows:n})}}}},{key:"deleteAllRows",value:function(){this.deleteRows(this.getRows().map(function(e,t){return t}))}},{key:"clear",value:function(){this._set_data("dataSource",[],!0),this._set_data("rows",[],!0),this._set_data("rowsDataState",[],!0),this.clearSelection(),this.applyPageInfo(c(c({},this.getPageInfo()),{},{recordCount:0,pageIndex:1})),this.setDataSourceView()}},{key:"select",value:function(e,t){var a=this;if(null!=e||!0===t){!0===t&&this.unselectAll({silent:!0});var n=!0===t?this.getRows().map(function(e,t){return t}):B(e)?e:[e];n=n.filter(function(e){return e>=0&&e<a.getRowsCount()});var i=this._get_data("rows")||[],r=this.getSelectedFlag(),o=n.filter(function(e){return!i[e][r]});if(o.length){var s={rowIndexes:o,rows:o.map(function(e){return i[e]})};this.execute("beforeSelect",s)&&(o.forEach(function(e){i[e][r]=!0,a.cacheSelectedRow(i[e],!0)}),this.flushSelection())}else!0===t&&this.flushSelection()}}},{key:"unselect",value:function(e){var t=this;if(null!=e){var a=B(e)?e:[e],n=this._get_data("rows")||[],i=this.getSelectedFlag(),r=a.filter(function(e){var t;return null===(t=n[e])||void 0===t?void 0:t[i]});r.length&&this.execute("beforeUnselect",r)&&(r.forEach(function(e){n[e][i]=!1,t.cacheSelectedRow(n[e],!1)}),this.flushSelection())}}},{key:"selectAll",value:function(){var e=this,t=this._get_data("rows")||[],a=this.getSelectedFlag();t.forEach(function(t){t[a]=!0,e.cacheSelectedRow(t,!0)}),this.flushSelection()}},{key:"unselectAll",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},a=this.getSelectedFlag();((t.onlyPage?this._get_data("rows"):this._get_data("dataSource"))||[]).forEach(function(e){e[a]=!1}),t.onlyPage?(this._get_data("rows")||[]).forEach(function(t){return e.cacheSelectedRow(t,!1)}):(this._set_data("selectedKeys",[],!0),this._set_data("selectedRowsMap",{},!0),this._set_data("selectedKeysSet",new Set,!0)),t.silent||this.flushSelection()}},{key:"clearSelection",value:function(){this.unselectAll()}},{key:"setSelectedRows",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],a=B(t)?t:[],n=this.getRowKeyField(),i=new Set(a.map(function(e){var t;return String(null!==(t=null==e?void 0:e[n])&&void 0!==t?t:e)})),r=this._get_data("rows")||[],o=this.getSelectedFlag();r.forEach(function(t){var a=i.has(String(t[n]));a!==!!t[o]&&(t[o]=a,e.cacheSelectedRow(t,a))}),this.flushSelection()}},{key:"setSelection",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];this.unselectAll({silent:!0}),this.setSelectedRows(e)}},{key:"getSelectedRows",value:function(e){var t=this._get_data("rows")||[],a=this.getSelectedFlag(),n=e&&new Set(B(e)?e:[e]);return t.filter(function(e,t){return e[a]&&(!n||n.has(t))})}},{key:"getSelectedRowIndexes",value:function(){var e=this._get_data("rows")||[],t=this.getSelectedFlag(),a=[];return e.forEach(function(e,n){e[t]&&a.push(n)}),a}},{key:"getSelectedKeys",value:function(){return this._get_data("selectedKeys")||[]}},{key:"getAllCacheSelectedRows",value:function(){var e=this._get_data("selectedKeys")||[],t=this._get_data("selectedRowsMap")||{};return e.map(function(e){return t[e]}).filter(Boolean)}},{key:"selectByKeys",value:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],a=this.getRowKeyField(),n=B(e)?e:[e],i=this._get_data("rows")||[],r=[];n.forEach(function(e){var t=i.findIndex(function(t){return String(t[a])===String(e)});t>-1&&r.push(t)}),r.length&&(t?this.select(r):this.unselect(r))}},{key:"getSelectedNodes",value:function(){return this.getAllCacheSelectedRows()}},{key:"cacheSelectedRow",value:function(e,t){var a=String(null==e?void 0:e[this.getRowKeyField()]),n=(this._get_data("selectedKeys")||[]).filter(function(e){return e!==a}),i=c({},this._get_data("selectedRowsMap")||{});t&&n.push(a),t?i[a]=e:delete i[a],this._set_data("selectedKeys",n,!0),this._set_data("selectedRowsMap",i,!0),this._set_data("selectedKeysSet",new Set(n),!0)}},{key:"flushSelection",value:function(){this._applyState("selectedRows",this.getSelectedRows()),this.execute("selectionChange",{value:this.getSelectedRows(),keys:this.getSelectedKeys(),indexes:this.getSelectedRowIndexes()})}},{key:"restoreSelectedFlags",value:function(){if(this.get("cacheSelectedRows")){var e=this._get_data("selectedKeysSet")||new Set;if(e.size){var t=this.getRowKeyField(),a=this.getSelectedFlag();(this.getRows()||[]).forEach(function(n){n[a]=e.has(String(n[t]))})}}}},{key:"setPagination",value:function(e){this._applyState("pagination",!!e),this.showPage()}},{key:"getPageInfo",value:function(){return this._get_data("pageInfo")||createDefaults().pageInfo}},{key:"getPageIndex",value:function(){return this.getPageInfo().pageIndex}},{key:"getPageSize",value:function(){return this.getPageInfo().pageSize}},{key:"getTotalCount",value:function(){return this.getPageInfo().recordCount}},{key:"setPageInfo",value:function(e){this.applyPageInfo(c(c({},this.getPageInfo()),e),{refresh:!0})}},{key:"setPageIndex",value:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];"number"==typeof e&&this.applyPageInfo(c(c({},this.getPageInfo()),{},{pageIndex:Math.max(1,e)}),{refresh:t})}},{key:"setPageSize",value:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];"number"==typeof e&&this.applyPageInfo(c(c({},this.getPageInfo()),{},{pageSize:Math.max(-1,e),pageIndex:1}),{refresh:t})}},{key:"setRecordCount",value:function(e){this.applyPageInfo(c(c({},this.getPageInfo()),{},{recordCount:e||0}))}},{key:"applyPageInfo",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},a=c({},e||{}),n=-1===a.pageSize?-1:a.pageSize||20,i=a.recordCount||0,r=i>0;return a.pageSize=n,a.recordCount=i,a.pageCount=n>0?Math.max(1,Math.ceil(i/n)):1,a.pageIndex=n>0?Math.max(1,r?Math.min(a.pageIndex||1,a.pageCount):a.pageIndex||1):1,a.beginPageIndex=n>0?(a.pageIndex-1)*n+1:1,a.endPageIndex=n>0?Math.min(a.pageIndex*n,i):i,this._set_data("pageInfo",a,!0),t.silent||(this._applyState("pageInfo",a),this.isRemote()||this.showPage(),t.refresh&&this.isRemote()&&this.refresh()),a}},{key:"showPage",value:function(){var e=this._get_data("dataSource")||[];if(!this.isRemote()&&this.isPagination()){var t=this.getPageInfo(),a=t.pageIndex,n=t.pageSize,i=(a-1)*n;this.setRows(e.slice(i,i+n))}else this.setRows(e)}},{key:"setDataSource",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},a=arguments.length>2?arguments[2]:void 0;if("local"===this._get_data("dataSourceMode")){var n=cb.utils.isArray(e)?e:[];if(!this.execute("beforeSetDataSource",n))return;var i=this._get_data("rowKeyField"),r={};n.forEach(function(e){r[e[i]]=e}),this._set_data("keyMap",r),this._set_data("dataSource",n,!0),this.getCache("grandson"),n.length&&J.call(this,n),this.initRowState(),setCachePaginationRowData.call(this,n),this.doPropertyChange("resetCellStatus"),this._set_data("rowState",{},!0),this.doPropertyChange("setDataSource",this.getShowRows()),this._set_data("delayInsertRows",[]),this._get_data("isSorting")&&this._set_data("isSorting",!1),this.execute("afterSetDataSource",n)}else{if(!this.execute("beforeProxyLoad",t))return;this._get_data("pageInfo").pageIndex=1;this._set_data("proxyConfig",e),this._set_data("queryParams",t),this._set_data("callback",a),X.call(this,e,t,a,!0,!0)}}},{key:"setRows",value:function(e){var t=B(e)?e:[];this._set_data("rows",t,!0),this.setRowsIdMap(),this._applyState("data",t)}},{key:"setDataSourceView",value:function(){this._applyState("data",this._get_data("rows")||[])}},{key:"setRowsIdMap",value:function(){var e=this,t={};(this._get_data("rows")||[]).forEach(function(a){void 0!==(null==a?void 0:a[e.getIdFlag()])&&(t[a[e.getIdFlag()]]=a)}),this._set_data("rowsIdMap",t)}},{key:"getRowIdMap",value:function(){return this._get_data("rowsIdMap")||{}}},{key:"validate",value:function(e,t){var a=this;if(e)return this.doPropertyChange("validate",{type:"",message:"",errors:[]}),this._set_data("validateErrors",[]),!1;this.deleteNotModifiedRows();var n=this._get_data("columns")||{},i=t?this.getRowsByIndexes(t):this.getRows(),r=[];i.forEach(function(e,t){for(var i in n){var o=n[i];if(a.isRequiredColumn(o)){var s=e[i];if(H(s)||B(s)&&!s.length||U(s)){var u=o.cShowCaption||o.cCaption||o.cCaption||o.title||i;r.push({rowIndex:t,rowId:e[a.getIdFlag()],cellName:i,message:"".concat(u,"不能为空")}),a.setCellState(t,i,"msg","不能为空")}}}}),this._set_data("validateErrors",r);var o=r.length?r[0].message:"";return this.doPropertyChange("validate",{type:r.length?"error":"",message:o,errors:r}),this.execute("afterValidate",{valid:!r.length,errors:r}),!r.length}}])}(),Q=function(){function e(){return a(this,e),t(this,e,arguments)}return s(e,M),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 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 a=this.get(e);null!=a&&a.setData?a.setData(t):this.set(e,t)}},{key:"getData",value:function(){var e=this,t=this._get_data("propertyNames")||[],a={};return t.forEach(function(t){var n,i=e.get(t);i instanceof M&&!1!==i._get_data("needCollect")&&(a[t]=null===(n=i.getData)||void 0===n?void 0:n.call(i))}),a}},{key:"getAllData",value:function(e){var t=this,a=this._get_data("propertyNames")||[],n={};return a.forEach(function(a){var i,r=t.get(a);if(r instanceof M&&!1!==r._get_data("needCollect")&&(!e||!r._get_data("isGrid"))){var o=null===(i=r.getData)||void 0===i?void 0:i.call(r);void 0!==o&&(n[a]=o)}}),n}},{key:"removeProperty",value:function(e){var t=this._get_data("propertyNames")||[],a=t.indexOf(e);-1!==a&&t.splice(a,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(a){var n,i=t.get(a);i instanceof M&&!1!==i._get_data("needClear")&&(null===(n=i.clear)||void 0===n||n.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 a=this._get_data("gridModel");if(a)return a;var n=null===(t=this.getParams())||void 0===t?void 0:t.masterGridModelName;if(n)return this.get(n);for(var i=this._get_data("propertyNames"),r=0,o=i.length;r<o;r++){if((a=this.get(i[r]))instanceof Y)return this._set_data("gridModel",a),a}}},{key:"getGridModels",value:function(){for(var e=this._get_data("propertyNames"),t=[],a=0,n=e.length;a<n;a++){var i=this.get(e[a]);i instanceof Y&&t.push(i)}return t}}])}();function W(e,n){var r,o=null===(r=window.__devfab)||void 0===r?void 0:r.require,u=n||{},l=u.domainKeyField,c=void 0===l?"domainKey":l,d=u.billNoField,h=void 0===d?"billNo":d,f=u.modelNameField,g=void 0===f?"modelName":f,v=u.enableExtendjs,y=void 0===v||v;null!=n&&n.require&&(o=null==n?void 0:n.require);var p=e[c]||"",_=e[h],w=function(){function e(){return a(this,e),t(this,e,arguments)}return s(e,Q),i(e,[{key:"init",value:function(e,t){var a=this.createModels(e,t);this.setData(a),this.setDirty(!1)}},{key:"createModels",value:function(e,t){var a={};return(Array.isArray(e)?e:[]).forEach(function(e){var i,r,o=null==n||null===(i=n.createModelFactory)||void 0===i?void 0:i.call(n,e);o||(o=function(e){var t;"input"===e.cControlType.toLowerCase()&&(t=new F(e));return t}(e));var s={model:o,field:e,meta:t};null==n||null===(r=n.onBeforeCreateModel)||void 0===r||r.call(n,s),a[e[g]]=s.model}),a}},{key:"initData",value:function(){this.initExtendJs()}},{key:"initExtendJs",value:function(){window&&window.__debugger_initExtendJs;var e=this;if(y){var t="".concat(_,"_VM.Extend.js"),a=[t];if("function"!=typeof o)return console.warn("requirejs.js 未加载,跳过扩展脚本:".concat(t)),void e.execute("extendReady",e);o(p,a,function(a,n){if(a&&a.doAction)try{a.doAction("init",e),n&&n.doAction("init",e)}catch(e){console.error("扩展脚本异常:",e)}else console.error("".concat(t,"扩展文件extend.*.min.js文件加载失败 或 未注册扩展脚本"));e.execute("extendReady",e)},function(a){console.warn("未找到扩展脚本:".concat(t,"错误信息:"),a),e.execute("extendReady",e)})}else e.execute("extendReady",e)}}])}();return w.prototype.modelType="ViewModel",w}var $={BaseModel:M,FilterModel:A,SimpleModel:F,GridModel:Y,ViewModel:Q,createViewModel:W,initViewModel:function(e,t){var a=new(W(e,t));return a.init(e.models,e),a}},Z={Builder:b,CacheUtil:C,EventUtil:I,DynamicProxy:q},ee={utils:{builder:new Z.Builder,cache:new Z.CacheUtil,event:new Z.EventUtil},common:{Builder:b,models:$,utils:Z}};exports.default=ee;
1
+ "use strict";function e(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,a=Array(t);n<t;n++)a[n]=e[n];return a}function t(e,t,n,a,r,i,o){try{var s=e[i](o),u=s.value}catch(e){return void n(e)}s.done?t(u):Promise.resolve(u).then(a,r)}function n(e){return function(){var n=this,a=arguments;return new Promise(function(r,i){var o=e.apply(n,a);function s(e){t(o,r,i,s,u,"next",e)}function u(e){t(o,r,i,s,u,"throw",e)}s(void 0)})}}function a(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,c()?Reflect.construct(t,n||[],u(e).constructor):t.apply(e,n))}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){for(var n=0;n<t.length;n++){var a=t[n];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,m(a.key),a)}}function o(e,t,n){return t&&i(e.prototype,t),n&&i(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function s(e,t,n){return(t=m(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 l(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 c(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(c=function(){return!!e})()}function d(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,a)}return n}function f(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?d(Object(n),!0).forEach(function(t){s(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):d(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function h(e,t){if(null==e)return{};var n,a,r=function(e,t){if(null==e)return{};var n={};for(var a in e)if({}.hasOwnProperty.call(e,a)){if(-1!==t.indexOf(a))continue;n[a]=e[a]}return n}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(a=0;a<i.length;a++)n=i[a],-1===t.indexOf(n)&&{}.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function v(){
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:{},a=n.iterator||"@@iterator",r=n.toStringTag||"@@toStringTag";function i(n,a,r,i){var u=a&&a.prototype instanceof s?a:s,l=Object.create(u.prototype);return g(l,"_invoke",function(n,a,r){var i,s,u,l=0,c=r||[],d=!1,f={p:0,n:0,v:e,a:h,f:h.bind(e,4),d:function(t,n){return i=t,s=0,u=e,f.n=n,o}};function h(n,a){for(s=n,u=a,t=0;!d&&l&&!r&&t<c.length;t++){var r,i=c[t],h=f.p,v=i[2];n>3?(r=v===a)&&(u=i[(s=i[4])?5:(s=3,3)],i[4]=i[5]=e):i[0]<=h&&((r=n<2&&h<i[1])?(s=0,f.v=a,f.n=i[1]):h<v&&(r=n<3||i[0]>a||a>v)&&(i[4]=n,i[5]=a,f.n=v,s=0))}if(r||n>1)return o;throw d=!0,a}return function(r,c,v){if(l>1)throw TypeError("Generator is already running");for(d&&1===c&&h(c,v),s=c,u=v;(t=s<2?e:u)||!d;){i||(s?s<3?(s>1&&(f.n=-1),h(s,u)):f.n=u:f.v=u);try{if(l=2,i){if(s||(r="next"),t=i[r]){if(!(t=t.call(i,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=i.return)&&t.call(i),s<2&&(u=TypeError("The iterator does not provide a '"+r+"' method"),s=1);i=e}else if((t=(d=f.n<0)?u:n.call(a,f))!==o)break}catch(t){i=e,s=1,u=t}finally{l=1}}return{value:t,done:d}}}(n,r,i),!0),l}var o={};function s(){}function u(){}function l(){}t=Object.getPrototypeOf;var c=[][a]?t(t([][a]())):(g(t={},a,function(){return this}),t),d=l.prototype=s.prototype=Object.create(c);function f(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,l):(e.__proto__=l,g(e,r,"GeneratorFunction")),e.prototype=Object.create(d),e}return u.prototype=l,g(d,"constructor",l),g(l,"constructor",u),u.displayName="GeneratorFunction",g(l,r,"GeneratorFunction"),g(d),g(d,r,"Generator"),g(d,a,function(){return this}),g(d,"toString",function(){return"[object Generator]"}),(v=function(){return{w:i,m:f}})()}function g(e,t,n,a){var r=Object.defineProperty;try{r({},"",{})}catch(e){r=0}g=function(e,t,n,a){function i(t,n){g(e,t,function(e){return this._invoke(t,n,e)})}t?r?r(e,t,{value:n,enumerable:!a,configurable:!a,writable:!a}):e[t]=n:(i("next",0),i("throw",1),i("return",2))},g(e,t,n,a)}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 a,r,i,o,s=[],u=!0,l=!1;try{if(i=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;u=!1}else for(;!(u=(a=i.call(n)).done)&&(s.push(a.value),s.length!==t);u=!0);}catch(e){l=!0,r=e}finally{try{if(!u&&null!=n.return&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw r}}return s}}(e,t)||k(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 w(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)||k(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 m(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var a=n.call(e,t||"default");if("object"!=typeof a)return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}function S(e){return S="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},S(e)}function k(t,n){if(t){if("string"==typeof t)return e(t,n);var a={}.toString.call(t).slice(8,-1);return"Object"===a&&t.constructor&&(a=t.constructor.name),"Map"===a||"Set"===a?Array.from(t):"Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a)?e(t,n):void 0}}Object.defineProperty(exports,"__esModule",{value:!0});var x=["component","children","render"],b=!1,R={},C=null;function P(e){return R[e]}function I(e,t){if(Array.isArray(e)){var n=[];return e.forEach(function(e,a){var r=e.component,i=e.children,o=e.render,s=h(e,x),u=P(r);u||"function"==typeof o||console.log("[warning] Component ".concat(r," is not registered!"));var l={component:u,children:I(i,t)};s.index=a;var c=Object.assign({},null==t?void 0:t.props,s);"function"==typeof o?n.push(o({node:l,props:c})):"function"==typeof C?n.push(C({node:l,props:c})):(Object.assign(l,c),n.push(l))}),n}}var D=function(){return o(function e(){r(this,e)},[{key:"init",value:function(e){b||("function"==typeof e&&e(),b=!0)}},{key:"initComponent",value:function(e,t){!function(e,t){if(e)"string"==typeof e?R[e]?console.log("[warning] Component ".concat(e," is exist!")):R[e]=t:Object.assign(R,e)}(e,t)}},{key:"getComponents",value:function(){return f({},R)}},{key:"getComponent",value:function(e){return P(e)}},{key:"hasComponent",value:function(e){return!!P(e)}},{key:"initRenderFactory",value:function(e){!function(e){C=e}(e)}},{key:"initRequest",value:function(){}},{key:"render",value:function(e,t){return I(e,t)}},{key:"clear",value:function(){R={},C=null,b=!1}}])}(),j=function(){return o(function e(t){r(this,e),this._init(t)},[{key:"_init",value:function(e){this.cache=Object.assign({},e)}},{key:"set",value:function(e,t){this.cache[e]=t}},{key:"get",value:function(e){var t;return null===(t=this.cache)||void 0===t?void 0:t[e]}},{key:"clear",value:function(e){delete this.cache[e]}}])}(),E=function(){return o(function e(t){r(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 a=this.events.get(e);Array.isArray(a)||(a=[]),a.push({callback:t,context:n}),this.events.set(e,a)}},{key:"onFirst",value:function(e,t,n){var a=this.firstevents.get(e);Array.isArray(a)||(a=[]),a.splice(0,0,{callback:t,context:n}),this.firstevents.set(e,a)}},{key:"execute",value:function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),a=1;a<t;a++)n[a-1]=arguments[a];var r=this.events.get(e),i=this.firstevents.get(e);if(!r&&!i)return!0;var o=!0;return[].concat(w(i||[]),w(r||[])).forEach(function(e){if(!1!==o){var t=e.callback.apply(e.context||void 0,n);o=!1!==t&&o}}),o}},{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 a=n.get(e),r=null==a?void 0:a.findIndex(function(e){return e.callback===t});-1!==r&&(null==a||a.splice(r,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 a,r=this,i=n.resolve,o=n.reject,s=n.args,u=!0,l=t||[],c=!1,d=function(t){var n,a=l[t];if(!1===u)return 0;if(c)return{v:void 0};if("development"===process.env.nodeEnv)n=a.callback.apply(a.context||r,s);else try{n=a.callback.apply(a.context||r,s)}catch(e){throw e.isAddedMsg||(e.message="(领域扩展事件执行失败,请打开控制台查看详细错误信息并修复):".concat(e.message)),e.isAddedMsg=!0,e}n instanceof Promise?(c=!0,(u=n).callbacks&&u.callbacks.push({reject:function(){u.reject(),t===l.length-1&&(null==o||o())},resolve:function(n){t===l.length-1?(s.length>1&&(s[0]=n),null==i||i(s)):r._asyncExecute(e,l.slice(t+1),{resolve:i,reject:o,args:s})}})):(u=!1!==n&&u,t===l.length-1&&(u?null==i||i(s):null==o||o()))},f=0;f<l.length&&0!==(a=d(f));f++)if(a)return a.v;return u}},{key:"_asyncPromiseExecute",value:function(e,t,n,a){var r=this.events.get(e),i=this.firstevents.get(e);if(!((Array.isArray(r)?r.length:r)||(Array.isArray(i)?i.length:i)))return null==t?void 0:t();var o=[].concat(w(i||[]),w(r||[]));return this._asyncExecute(e,o,{resolve:t,reject:n,args:a})}},{key:"promiseExecute",value:function(e,t){var n=this,a=e,r=1;if("boolean"==typeof e&&(a=t,r=2),a){for(var i=arguments.length,o=new Array(i>2?i-2:0),s=2;s<i;s++)o[s-2]=arguments[s];var u=2===r?o:[t].concat(o);if(u.length){var l,c=u.length-1,d=u[c];if("function"!=typeof d){if("object"!==S(d)||!d[0]||"function"!=typeof d[0]||!d[1]||"function"!=typeof d[1])return;l=d[1],d=d[0]}if(this.__ASYNC_EXECUTE__)return this._asyncPromiseExecute(a,function(e){d.apply(n,e)},function(){l&&"function"==typeof l&&l()},u);u.splice(c,1),u.unshift(a);var f=this.execute.apply(this,u);if(f instanceof Promise){var h=this;f.then(function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];d.apply(h,t)},function(){l&&"function"==typeof l&&l()})}else if(!f)return void(l&&"function"==typeof l&&l())}}}},{key:"clearEvents",value:function(){this.events.clear(),this.firstevents.clear()}}])}();function O(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 a=(t=t.replace(/\+/g," ")).split("&"),r=0,i=a.length;r<i;r++){var o=a[r]||"";if(o){var s=o.indexOf("="),u="",l="";s<0?l=u=window.decode(o):(u=window.decode(o.substr(0,s)),l=window.decode(o.substr(s+1))),this.query[u]=l}}}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 q(e,t){if(!t)return e;var n=[],a=new O(e);for(var r in t)a.get(r)||n.push("".concat(r,"=").concat(t[r]));if(!n.length)return e;var i=n.join("&");return e.indexOf("?")>=0?"".concat(e,"&").concat(i):"".concat(e,"?").concat(i)}String.prototype.equalsIgnoreCase=function(e){return null!=e&&this.toLowerCase()===e.toLowerCase()};var M=["onBeforeRequest","_onAfterRequest"],A=["_onBeforeRequest","onAfterRequest"];var F={_xhrs:[],_jsonps:{index:0},doRequest:function(e){var t=e||{},n=t.onBeforeRequest;t._onAfterRequest;var a,r=h(t,M),i=r.method||"GET",o=r.url;try{null!=r&&r.requestHeaders&&(a=r.requestHeaders,r.requestHeaders=void 0,delete r.requestHeaders)}catch(e){console.log('[ajax]: [doRequest]: options["requestHeaders"] ERR : ',e)}try{r.params&&r.params.requestHeaders&&(a=r.params.requestHeaders,r.params.requestHeaders=void 0,delete r.params.requestHeaders)}catch(e){console.log('[ajax]: [doRequest]: options.params["requestHeaders"] ERR : ',e)}var s=null;if(i.equalsIgnoreCase("get")||i.equalsIgnoreCase("delete")?o=q(o,r.params):(i.equalsIgnoreCase("post")||i.equalsIgnoreCase("put"))&&(s=JSON.stringify(r.params)),r.jsonp)return this.getJsonp(o,r.callback);var u=this.getXMLHttpRequest();if(u){var l;if(u.open(i,o,!1!==r.async),r.timeout&&(u.timeout=r.timeout,u.setRequestHeader("timeout",r.timeout),u.ontimeout=function(){F.onerror(this,r,"timeout")}),r.contentType){if(u.setRequestHeader("Content-Type",r.contentType),r.contentType.indexOf("x-www-form-urlencoded")>=0)s=null===(l=new URLSearchParams(r.params))||void 0===l?void 0:l.toString()}else r.dateType?s=r.params:u.setRequestHeader("Content-Type","application/json;charset=utf-8");r.domainKey&&u.setRequestHeader("Domain-Key",r.domainKey);try{if(a&&"[object Object]"===Object.prototype.toString.call(a))for(var c in a)u.setRequestHeader(c,a[c])}catch(e){console.log('[ajax]: [doRequest]: options.params["requestHeaders"] ERR : ',e)}u.withCredentials=null==r||!r.hasOwnProperty("withCredentials")||r.withCredentials;try{u.send(s)}catch(e){return{error:"NetWorkError",options:r}}if(!1===r.async)return null==n||n(r),this.onreadystatechange(u,r);u.onreadystatechange=function(){F.onreadystatechange(this,r)},null==n||n(r)}},beforeReadystatechange:function(e,t,n){null==n||n()},onreadystatechange:function(e,t){var n=t||{};n._onBeforeRequest;var a=n.onAfterRequest,r=h(n,A);if(4===e.readyState){if(null==a||a(),200===e.status){var i;try{if("blob"===r.responseType){var o=function(e){var t=e.xhr.getAllResponseHeaders(),n={};return t.split("\r\n").map(function(e){var t=p(e.split(": "),2),a=t[0],r=t[1];n[a]=r}),n}({xhr:e});i={code:e.status,data:{data:e.response,headers:o}}}else i=JSON.parse(e.responseText)}catch(t){F.onerror(e,r,e.responseText)}if(!1===r.async)return e.isBusy=!1,r.precallback&&r.precallback(i),F.processAjaxResult(i,!1,null,null,r,e);F.processAjaxResult(i,r.async,r.callback,r.context,r,e),r.precallback&&r.precallback(i)}else if(0===e.status)F.onerror(e,r,"网络连接已断开,请检查设备网络状态后重试");else if(502===e.status||504===e.status)F.onerror(e,r,"服务出错了,请稍后再试");else{if(401!==e.status){var s={};try{s=JSON.parse(e.responseText)}catch(t){s={code:e.status,message:e.responseText}}return F.onerror(e,r,s)}F.onerror(e,r,"登录信息失效,请重新登录或联系技术人员")}e.isBusy=!1}},onerror:function(e,t,n){var a="[ajax]: [onerror]: 接口返回错误 \n [状态码]: ".concat(e.status," \n [错误信息]: ").concat(("object"===S(n)?JSON.stringify(n):n)||"空"," \n [请求地址]: ").concat(t.url," \n [浏览器Token]: ").concat(document.cookie);console.log("Error.E01000",a);var r="object"===S(n)?n:{code:500,message:n};t.precallback&&t.precallback(r)},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,a="callback"+this._jsonps.index++,r=document.createElement("script");this._jsonps[a]=function(e){try{t(e)}finally{document.body.removeChild(r)}},n+=-1===n.indexOf("?")?"?":"&callback=cb.rest.AjaxRequestManager._jsonps."+a,r.src=n,document.body.appendChild(r)},processAjaxResult:function(e,t,n,a,r,i){if(e){if(!e.code)return!1===t?e:void(n&&n.call(a,null,e));if(200==e.code){if(!1===t)return{result:e.data};n&&n.call(a,null,e.data,e.message,e.errorDetail,e.code,e.displayCode&&e)}else{if(!1===t)return{error:e};n&&n.call(a,e)}}}};function N(e,t){this.init&&this.init(e),this.queryParams=t}N.create=function(e,t){return new N(e,t)},N.prototype.init=function(e){if(e)for(var t in this.config=e,this.config)this[t]=function(e){return function(t,n,a){return this.Do(e,t,n,null,a)}}(t),this["".concat(t,"Sync")]=function(e){return function(t){return this.Do(e,t,null,!1)}}(t)},N.prototype.Do=function(e,t,n,a,r){var i,o,s;if(this.config&&this.config[e]&&this.config[e].url){var u=this.config[e],l=u.url;this.queryParams||(this.queryParams={}),null!==(i=u.options)&&void 0!==i&&i.proxyServiceCode&&(this.queryParams.serviceCode=u.options.proxyServiceCode),null!==(o=u.options)&&void 0!==o&&o.billnum&&(this.queryParams.billnum=u.options.billnum),null!==(s=this.queryParams)&&void 0!==s&&s.serviceCode&&(l=q(l,this.queryParams));var c=l,d=Object.assign({},u.options);return d.method=u.method||"GET","function"==typeof t?(d.callback=t,d.context=r||d.context||this):d.params=t,n&&(d.callback=n,d.context=r||d.context||this),!1===a&&(d.async=!1),this.ajax(c,d)}},N.prototype.ajax=function(e,t){return function(e,t){return t.url=e,F.doRequest(t)}(e,t)};var T=function(){return o(function e(t){r(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 j,this._data.events=new E}},{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 j,events:new E}}},{key:"_set_data",value:function(e,t,n){if(e){if(n){var a=this._data.propertyNames||[];a.indexOf(e)<0&&a.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 a=(this._get_data("components")||[]).find(function(e){return e.ctrlName===t});return a?null===(n=a.getState)||void 0===n?void 0:n.call(a,e):this._get_data(e)}},{key:"setState",value:function(e,t,n){n||this._set_data(e,t,!0);var a={};a[e]=t,this.doPropertyChange("setState",a,n)}},{key:"doPropertyChange",value:function(e,t,n){var a=this,r=this._get_data("components")||[];if(!r.length)return r;var i=[];if(n){var o=r.find(function(e){return e.ctrlName===n});o&&!this.notifyComponent(o,e,t)&&i.push(o)}else r.forEach(function(n){a.notifyComponent(n,e,t)||i.push(n)});return i.length?i: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 a=this.getCache("name");e[t](n,a)}}},{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 a=this;n||this._set_data(e,t,!0);var r="set".concat(e.charAt(0).toUpperCase()).concat(e.slice(1)),i=this.doPropertyChange(r,t,n);if(i){var o={};o[e]=t,i.forEach(function(e){a.notifyComponent(e,"setState",o)})}}},{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 a=this,r=this.getValue();if(e!==r){var i={value:e,oldValue:r},o=this._get_data("forceFireEvent");t||o?this.promiseExecute("beforeValueChange",i,[function(){a._set_data("value",e,!0),a._applyState("value",e,n),a.execute("afterValueChange",i)},function(){a._set_data("value",r,!0),a._applyState("value",r,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,a=new Array(n>1?n-1:0),r=1;r<n;r++)a[r-1]=arguments[r];return(t=this._get_data("events")).execute.apply(t,[e].concat(a))}},{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,a=arguments.length,r=new Array(a>2?a-2:0),i=2;i<a;i++)r[i-2]=arguments[i];(n=this._get_data("events")).promiseExecute.apply(n,[e,t].concat(r))}},{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").clear(e)}},{key:"setProxy",value:function(e){if(!(e instanceof N)){var t,n=this._get_data("__requestHeaders__");for(var a in e){var r,i,o;if(n&&(null===(r=e[a])||void 0===r||null===(r=r.options)||void 0===r||!r.requestHeaders))null!==(o=e[a])&&void 0!==o&&o.options||(e[a].options={}),e[a].options.requestHeaders=n;null!==(i=this.getProxy())&&void 0!==i&&i[a]&&console.warn("[baseModel.prototype.setProxy]: Proxy ".concat(a," already exists on the model. Please change the name of ").concat(a," and try again"))}return this._set_data("proxy",N.create(f(f({},(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")}}])}(),K=function(){function e(){return r(this,e),a(this,e,arguments)}return l(e,T),o(e,[{key:"mounted",value:function(){var e=this,t=this.get("conditions"),n={};t.forEach(function(t){e.get(t.name),n[t.name]=t.defaultValue}),this._set_data("params",n)}},{key:"unmounted",value:function(){this._set_data("params",{}),this._set_data("conditions",[])}},{key:"getParams",value:function(){var e=this,t={};return this.get("conditions").forEach(function(n){var a=e.get(n.name);t[n.name]=null==a?void 0:a.getValue()}),this._set_data("params",t),t}},{key:"search",value:function(){var e=this.getParams();this.execute("search",e)}}])}(),V=function(){function e(t){return r(this,e),a(this,e,[t])}return l(e,T),o(e,[{key:"getDisabled",value:function(){return this.getState("disabled")}},{key:"setDisabled",value:function(e){return this.setState("disabled",!!e)}},{key:"getReadonly",value:function(){return this.getState("readonly")}},{key:"setReadonly",value:function(e){this.setState("readonly",!!e)}}])}(),U="",H="Insert",B="Update",L="Delete",z=Array.isArray,G=function(e){return null==e||""===e},X=function(e){return!e||0===Object.keys(e).length};function J(e){if(z(e))return e.map(J);if(e instanceof Date)return new Date(e.getTime());if(e&&"object"===S(e)){var t={};for(var n in e)t[n]=J(e[n]);return t}return e}function Y(e){var t={};return(z(e)?e:Object.keys(e||{}).map(function(t){var n;return f(f({},e[t]||{}),{},{field:(null===(n=e[t])||void 0===n?void 0:n.field)||t})})).forEach(function(e,n){if(e){var a=e.field||e.cCaption||e.cFieldName||"col_".concat(n);t[a]=f(f({},e),{},{field:a,fieldName:e.fieldName||a,cCaption:e.cCaption||a,index:void 0===e.index?n:e.index})}}),t}function Q(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=this.getIdFlag(),n=this.getRowKeyField(),a=this._get_data("rowIdSeq")||0;return e.forEach(function(e){if(e&&void 0===e[t]){var r=e[n];null!=r&&""!==r?e[t]=String(r):(a+=1,e[t]="rowId_".concat(a))}}),this._set_data("rowIdSeq",a),e}function W(e,t,n){var a=this;this.promiseExecute("beforeQuery",{proxyConfig:e,queryParams:t},function(){var r=a,i=a.setProxy({queryData:e}),o={page:{pageSize:a.getPageSize(),pageIndex:a.getPageIndex()}},s=Object.assign(o,t);a.setCache("proxyCache",{proxyConfig:e,params:s}),a.getRootParent();if(!1!==a.execute("beforeQueryData",s)){var u=_.cloneDeep(s);i.queryData(u,function(e,t,a,r){if(!e){this._set_data("dataSourceMode","remote");var i=function(e){if(!e)return[];if(z(e))return e;if(z(e.data))return e.data;if(z(e.records))return e.records;if(z(e.list))return e.list;if(z(e.rows))return e.rows;var t=e.data&&"object"===S(e.data)?e.data:e.result;return z(t)?t:t&&"object"===S(t)&&(t.records||t.list||t.rows||t.data)||[]}(t=Object.assign({},t));null==n||n.call(this,i)}},r)}})}function $(e){if(this.execute("beforeSetDataSource",e)){var t=this._get_data("rowKeyField"),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 Z=function(){function e(){var t,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};r(this,e);var i=f(f({},{columns:{},dataSource:[],rows:[],readOnly:!0,dataSourceMode:"local",columnMode:"local",editMode:"cell",cellState:{},rowState:{},showCheckBox:!0,multiple:!0,showRowNo:!0,pagination:!0,pageInfo:{pageIndex:1,pageSize:20,pageCount:0},innerUsedAttrs:{id:"_id",selected:"_selected",status:"_status"},multiRowModel:!1,editRowModels:{},loading:!1,params:{},originalKeyMap:{},defaultRowDatas:new Map}),n);z(i.dataSource)||(i.dataSource=[]),z(i.rows)||(i.rows=[]);var o=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=f({},e.proxyConfig||{});return"function"==typeof e.dataSource&&(t.load=t.load||e.dataSource),"string"==typeof e.cUrl&&(t.load=t.load||e.cUrl),t.load||"string"!=typeof e.url||(t.load=e.url),t}(n);i.proxyConfig=o,i.dataSourceMode=n.dataSourceMode||(o.load?"remote":"local");var u=n.cData||(z(n.data)?n.data:null);return s(t=a(this,e,[i]),"modelType","GridModel"),t.initPageInfo(n.cPage||n.page),t.initColumns(i.columns),t.initRowState(),t.afterInit(),u&&t.setDataSource(u),t}return l(e,T),o(e,[{key:"afterInit",value:function(){"single"===this._get_data("parentRelation")&&this._set_data("defaultSelectedRowIndexes",!0)}},{key:"initColumns",value:function(e){var t=Y(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=f({},this.getPageInfo());t.pageIndex=e.pageNo||e.pageIndex||t.pageIndex||1,t.pageSize=e.pageSize||t.pageSize||20,!1===this.get("pagination")&&(t.pageSize=-1),this.applyPageInfo(t)}},{key:"initRowState",value:function(){var e=this,t=this._get_data("dataSource");this._set_data("rowsDataState",(z(t)?t:[]).map(function(t){return(null==t?void 0:t[e.getStatusFlag()])||U}),!0)}},{key:"getInnerUsedAttrs",value:function(){return this._get_data("innerUsedAttrs")}},{key:"getIdFlag",value:function(){return this.getInnerUsedAttrs().id}},{key:"getSelectedFlag",value:function(){return this.getInnerUsedAttrs().selected}},{key:"getStatusFlag",value:function(){return this.getInnerUsedAttrs().status}},{key:"getRowKeyField",value:function(){return this._get_data("rowKeyField")||"id"}},{key:"getProxyConfig",value:function(){return this._get_data("proxyConfig")||{}}},{key:"isRemote",value:function(){return"remote"===this._get_data("dataSourceMode")}},{key:"isPagination",value:function(){return!!this.get("pagination")&&-1!==this.getPageSize()}},{key:"getReadOnly",value:function(){return!!this._get_data("readOnly")}},{key:"setReadOnly",value:function(e){this._applyState("readOnly",!!e)}},{key:"getParams",value:function(){return f(f({},this.get("cParams")||{}),this._get_data("params")||{})}},{key:"setParams",value:function(e){this._set_data("params",e||{})}},{key:"setMeta",value:function(e){this._set_data("meta",e)}},{key:"getColumns",value:function(e){var t=this._get_data("columns")||{},n={};return(e?z(e)?e:[e]:Object.getOwnPropertyNames(t)).forEach(function(e){t[e]&&(n[e]=f(f({},t[e]),{},{fieldName:t[e].fieldName||e}))}),n}},{key:"getColumn",value:function(e){var t,n=null===(t=this._get_data("columns"))||void 0===t?void 0:t[e];return n?f(f({},n),{},{fieldName:n.fieldName||e}):void 0}},{key:"hasColumn",value:function(e){return!!(this._get_data("columns")||{})[e]}},{key:"getColumnList",value:function(e){var t=this.getColumns(e);return Object.keys(t).sort(function(e,n){return(t[e].index||0)-(t[n].index||0)}).map(function(e){return t[e]})}},{key:"getVisibleColumns",value:function(e){return this.getColumnList(e).filter(function(e){return!0!==e.bHidden&&!1!==e.bShowIt})}},{key:"setColumns",value:function(e){e&&this._applyState("columns",Y(e))}},{key:"setColumnMode",value:function(e){this._set_data("columnMode","remote"===e?"remote":"local",!0)}},{key:"addColumns",value:function(e){var t=Y(e);this._applyState("columns",f(f({},this._get_data("columns")||{}),t))}},{key:"resetColumns",value:function(e){this.setColumns(e||this.get("cColumns"))}},{key:"getColumnState",value:function(e,t,n){var a,r=this.getRowKey(e);return r?((null===(a=this._get_data("cellState"))||void 0===a||null===(a=a[r])||void 0===a?void 0:a[t])||{})[n]:void 0}},{key:"setColumnState",value:function(e,t,n,a){this.setCellState(e,t,n,a)}},{key:"setColumnStates",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];this.setCellStates(e.map(function(e){return f(f({},e),{},{cellName:e.cellName||e.columnName})}))}},{key:"setColumnValue",value:function(e,t,n){var a=this._get_data("columns")||{};a[e]&&this._applyState("columns",f(f({},a),{},s({},e,f(f({},a[e]),{},s({},t,n)))))}},{key:"setDataSource",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},a=arguments.length>2?arguments[2]:void 0;if("local"===this._get_data("dataSourceMode")){$(cb.utils.isArray(e)?e:[])}else{if(!this.execute("beforeProxyLoad",n))return;this._get_data("pageInfo").pageIndex=1,this._set_data("proxyConfig",e),this._set_data("queryParams",n),this._set_data("loadDataCallback",a),W.call(this,e,n,function(e){$.call(t,e),null==a||a.call(t)})}}},{key:"reload",value:function(){var e=this;this.getProxy();var t=this._get_data("proxyConfig"),n=this._get_data("queryParams"),a=this._get_data("loadDataCallback");W.call(this,t,n,function(t){$.call(e,t),null==a||a.call(e)})}},{key:"getDataSource",value:function(){return this._get_data("dataSource")||[]}},{key:"getData",value:function(e,t){var n=e||t?this._get_data("rows"):this._get_data("dataSource");return this.collectRows(n,e)}},{key:"getAllData",value:function(){return this.getData(!0)}},{key:"getPageData",value:function(){return this.getData(!0)}},{key:"getEffeData",value:function(){var e=this._get_data("dataSource")||[],t=this._get_data("rowsDataState")||[];return this.collectRows(e.filter(function(e,n){return t[n]!==L}),!1)}},{key:"getRows",value:function(e){var t=this._get_data("rows")||[];return!1===e?t:t.map(function(e){return J(e)})}},{key:"collectRows",value:function(e,t){var n=this._get_data("columns")||{},a=this.getStatusFlag(),r=this.getSelectedFlag();return(e||[]).map(function(e){var i={};for(var o in e){var s;t&&o===a||(t||o!==r)&&!1!==(null===(s=n[o])||void 0===s?void 0:s.needCollect)&&(i[o]=e[o])}return i})}},{key:"getShowRows",value:function(e){return(e||this._get_data("rows")||[]).map(function(e){return f({},e)})}},{key:"getRow",value:function(e,t){var n,a=null===(n=this._get_data("rows"))||void 0===n?void 0:n[e];if(a)return!1===t?a:J(a)}},{key:"getRowIndex",value:function(e){if(!e)return-1;var t=this._get_data("rows")||[],n=this.getRowKeyField();return void 0!==e[n]?t.findIndex(function(t){return t[n]===e[n]}):t.indexOf(e)}},{key:"getRowIndexByRowId",value:function(e){var t=this;return(this._get_data("rows")||[]).findIndex(function(n){return(null==n?void 0:n[t.getIdFlag()])===e})}},{key:"getDataSourceIndexByRowId",value:function(e){var t=this;return(this._get_data("dataSource")||[]).findIndex(function(n){return(null==n?void 0:n[t.getIdFlag()])===e})}},{key:"getRowKey",value:function(e){var t,n;return null!==(t=null===(n=this._get_data("rows"))||void 0===n||null===(n=n[e])||void 0===n?void 0:n[this.getIdFlag()])&&void 0!==t?t:e}},{key:"getRowKeys",value:function(e){var t=void 0===e?this.getRows():z(e)?e:[e],n=this.getRowKeyField();return t.filter(function(e){return e&&void 0!==e[n]}).map(function(e){return e[n]})}},{key:"getRowsByIndexes",value:function(e){var t=this._get_data("rows")||[];return(z(e)?e:[e]).map(function(e){return t[e]}).filter(Boolean)}},{key:"getCellValue",value:function(e,t){var n,a=e>=0?null===(n=this._get_data("rows"))||void 0===n?void 0:n[e]:null;if(a&&t)return a[t]}},{key:"setCellValue",value:function(e,t,n){var a=(this._get_data("rows")||[])[e];if(a&&t){var r=a[t];if(r!==n){var i={rowIndex:e,rowId:a[this.getIdFlag()],cellName:t,value:n,oldValue:r};this.execute("beforeCellValueChange",i)&&(a[t]=i.value,this.markRowState(e,B),this.execute("afterCellValueChange",i),this.doPropertyChange("setCellValue",i))}}}},{key:"setCellValues",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];z(t)&&t.forEach(function(t){return e.setCellValue(t.rowIndex,t.cellName||t.field,t.value)})}},{key:"getCellState",value:function(e,t,n){var a,r=this.getRowKey(e),i=r?null===(a=this._get_data("cellState"))||void 0===a||null===(a=a[r])||void 0===a?void 0:a[t]:null;if(i)return i[n]}},{key:"setCellState",value:function(e,t,n,a){var r,i=null===(r=this._get_data("rows"))||void 0===r||null===(r=r[e])||void 0===r?void 0:r[this.getIdFlag()],o=i||e;if(!G(o)){var u=this.getCellState(e,t,n);if(u!==a){var l={rowIndex:e,rowId:i,cellName:t,propertyName:n,value:a,oldValue:u};if(this.execute("beforeCellStateChange",l)){var c=f({},this._get_data("cellState")||{});c[o]=f({},c[o]||{}),c[o][t]=f(f({},c[o][t]||{}),{},s({},n,a)),this._applyState("cellState",c),this.execute("afterCellStateChange",l)}}}}},{key:"setCellStates",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];z(t)&&t.forEach(function(t){return e.setCellState(t.rowIndex,t.cellName,t.propertyName||t.name,t.value)})}},{key:"getRowDataState",value:function(e){var t,n=this.getDataSourceIndexByRow(e);return null===(t=this._get_data("rowsDataState"))||void 0===t?void 0:t[n]}},{key:"getDataSourceIndexByRow",value:function(e){var t=this,n=(this._get_data("rows")||[])[e];if(!n)return-1;var a=this._get_data("dataSource")||[],r=a.indexOf(n);return r>-1?r:a.findIndex(function(e){return(null==e?void 0:e[t.getIdFlag()])===(null==n?void 0:n[t.getIdFlag()])})}},{key:"setRowDataState",value:function(e,t){var n=this.getDataSourceIndexByRow(e);if(!(n<0)){var a=w(this._get_data("rowsDataState")||[]);a[n]=t,this._set_data("rowsDataState",a,!0)}}},{key:"markRowState",value:function(e,t){var n=this.getRowDataState(e);n!==H&&n!==t&&this.setRowDataState(e,t)}},{key:"markRowUpdate",value:function(e){var t="number"==typeof e?e:this.getRowIndex(e);t<0||this.markRowState(t,B)}},{key:"getRowState",value:function(e,t){var n,a=this.getRowKey(e),r=a?null===(n=this._get_data("rowState"))||void 0===n?void 0:n[a]:null;if(r&&t)return r[t]}},{key:"setRowState",value:function(e,t,n){var a,r=null===(a=this._get_data("rows"))||void 0===a?void 0:a[e];if(r&&t){var i=this.getRowKey(e),o=this.getRowState(e,t);if(o!==n){var u={rowIndex:e,rowId:r[this.getIdFlag()],propertyName:t,value:n,oldValue:o};if(this.execute("beforeRowStateChange",u)){var l=f({},this._get_data("rowState")||{});l[i]=f(f({},l[i]||{}),{},s({},t,n)),this._applyState("rowState",l),this.execute("afterRowStateChange",u)}}}}},{key:"setRowStates",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];z(t)&&t.forEach(function(t){return e.setRowState(t.rowIndex,t.propertyName||t.name,t.value)})}},{key:"getDirtyData",value:function(e){var t=this,n=this._get_data("dataSource")||[],a=this._get_data("rowsDataState")||[],r=[];return n.forEach(function(e,n){var i=a[n];if(i){var o=J(e);o[t.getStatusFlag()]=i,r.push(o)}}),r.length?r:void 0}},{key:"getDirtyRowIndexes",value:function(){var e=this;return(this._get_data("rows")||[]).map(function(e,t){return t}).filter(function(t){return!!e.getRowDataState(t)})}},{key:"isDirty",value:function(){return!!this.getDirtyData()}},{key:"backupState",value:function(){this._set_data("backupData",{dataSource:J(this._get_data("dataSource")||[]),rowsDataState:w(this._get_data("rowsDataState")||[])})}},{key:"restoreState",value:function(){var e=this._get_data("backupData");e&&(this._set_data("dataSource",e.dataSource,!0),this._set_data("rowsDataState",w(e.rowsDataState),!0),this.showPage())}},{key:"insertRow",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>3?arguments[3]:void 0,a=this._get_data("rows")||[],r=Math.min(a.length,Math.max(0,void 0===e?a.length:e)),i={index:r,row:f({},t),isCopy:n};if(this.execute("beforeInsertRow",i)){var o=i.row;delete o[this.getIdFlag()],Q.call(this,[o]);var s=this._get_data("dataSource")||[],u=r<a.length?this.getDataSourceIndexByRow(r):s.length;s.splice(u<0?s.length:u,0,o);var l=w(this._get_data("rowsDataState")||[]);return l.splice(u<0?l.length:u,0,H),a.splice(r,0,o),this._set_data("rowsDataState",l,!0),this.setRows(a),this.execute("afterInsertRow",f(f({},i),{},{rowIndex:r})),o}}},{key:"insertRows",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],a=[];return(z(n)?n:[n]).forEach(function(n,r){a.push(t.insertRow(e+r,n))}),a}},{key:"appendRow",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this.insertRow(this.getRowsCount(),e)}},{key:"updateRow",value:function(e){var t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},a=null===(t=this._get_data("rows"))||void 0===t?void 0:t[e];a&&this.execute("beforeUpdateRow",{index:e,row:n})&&(Object.assign(a,n),this.markRowState(e,B),this.setRows(this._get_data("rows")),this.execute("afterUpdateRow",{index:e,row:a}))}},{key:"updateRows",value:function(){var e=this;(arguments.length>0&&void 0!==arguments[0]?arguments[0]:[]).forEach(function(t){var n;return e.updateRow(null!==(n=t.rowIndex)&&void 0!==n?n:t.index,t.rowData||t.row)})}},{key:"deleteRows",value:function(e){var t=this,n=(z(e)?e:[e]).filter(function(e){return e>=0&&e<t.getRowsCount()}).sort(function(e,t){return e-t});if(n.length){var a=this.getRowsByIndexes(n);if(this.execute("beforeDeleteRows",a,n)){var r=this._get_data("dataSource")||[],i=w(this._get_data("rowsDataState")||[]),o=new Set,s=new Set;a.forEach(function(e){var n=r.indexOf(e);if(!(n<0)){var a=e[t.getIdFlag()];o.add(a),i[n]===H&&s.add(a)}});var u=[],l=[];r.forEach(function(e,n){var a=e[t.getIdFlag()];if(!o.has(a))return u.push(e),void l.push(i[n]);s.has(a)||(u.push(e),l.push(L))}),this._set_data("dataSource",u,!0),this._set_data("rowsDataState",l,!0),this.showPage(),this.execute("afterDeleteRows",{rowIndexes:n,rows:a})}}}},{key:"deleteAllRows",value:function(){this.deleteRows(this.getRows().map(function(e,t){return t}))}},{key:"clear",value:function(){this._set_data("dataSource",[],!0),this._set_data("rows",[],!0),this._set_data("rowsDataState",[],!0),this.clearSelection(),this.applyPageInfo(f(f({},this.getPageInfo()),{},{recordCount:0,pageIndex:1})),this.setDataSourceView()}},{key:"select",value:function(e,t){var n=this;if(null!=e||!0===t){!0===t&&this.unselectAll({silent:!0});var a=!0===t?this.getRows().map(function(e,t){return t}):z(e)?e:[e];a=a.filter(function(e){return e>=0&&e<n.getRowsCount()});var r=this._get_data("rows")||[],i=this.getSelectedFlag(),o=a.filter(function(e){return!r[e][i]});if(o.length){var s={rowIndexes:o,rows:o.map(function(e){return r[e]})};this.execute("beforeSelect",s)&&(o.forEach(function(e){r[e][i]=!0,n.cacheSelectedRow(r[e],!0)}),this.flushSelection())}else!0===t&&this.flushSelection()}}},{key:"unselect",value:function(e){var t=this;if(null!=e){var n=z(e)?e:[e],a=this._get_data("rows")||[],r=this.getSelectedFlag(),i=n.filter(function(e){var t;return null===(t=a[e])||void 0===t?void 0:t[r]});i.length&&this.execute("beforeUnselect",i)&&(i.forEach(function(e){a[e][r]=!1,t.cacheSelectedRow(a[e],!1)}),this.flushSelection())}}},{key:"selectAll",value:function(){var e=this,t=this._get_data("rows")||[],n=this.getSelectedFlag();t.forEach(function(t){t[n]=!0,e.cacheSelectedRow(t,!0)}),this.flushSelection()}},{key:"unselectAll",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=this.getSelectedFlag();((t.onlyPage?this._get_data("rows"):this._get_data("dataSource"))||[]).forEach(function(e){e[n]=!1}),t.onlyPage?(this._get_data("rows")||[]).forEach(function(t){return e.cacheSelectedRow(t,!1)}):(this._set_data("selectedKeys",[],!0),this._set_data("selectedRowsMap",{},!0),this._set_data("selectedKeysSet",new Set,!0)),t.silent||this.flushSelection()}},{key:"clearSelection",value:function(){this.unselectAll()}},{key:"setSelectedRows",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],n=z(t)?t:[],a=this.getRowKeyField(),r=new Set(n.map(function(e){var t;return String(null!==(t=null==e?void 0:e[a])&&void 0!==t?t:e)})),i=this._get_data("rows")||[],o=this.getSelectedFlag();i.forEach(function(t){var n=r.has(String(t[a]));n!==!!t[o]&&(t[o]=n,e.cacheSelectedRow(t,n))}),this.flushSelection()}},{key:"setSelection",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];this.unselectAll({silent:!0}),this.setSelectedRows(e)}},{key:"getSelectedRows",value:function(e){var t=this._get_data("rows")||[],n=this.getSelectedFlag(),a=e&&new Set(z(e)?e:[e]);return t.filter(function(e,t){return e[n]&&(!a||a.has(t))})}},{key:"getSelectedRowIndexes",value:function(){var e=this._get_data("rows")||[],t=this.getSelectedFlag(),n=[];return e.forEach(function(e,a){e[t]&&n.push(a)}),n}},{key:"getSelectedKeys",value:function(){return this._get_data("selectedKeys")||[]}},{key:"getAllCacheSelectedRows",value:function(){var e=this._get_data("selectedKeys")||[],t=this._get_data("selectedRowsMap")||{};return e.map(function(e){return t[e]}).filter(Boolean)}},{key:"selectByKeys",value:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],n=this.getRowKeyField(),a=z(e)?e:[e],r=this._get_data("rows")||[],i=[];a.forEach(function(e){var t=r.findIndex(function(t){return String(t[n])===String(e)});t>-1&&i.push(t)}),i.length&&(t?this.select(i):this.unselect(i))}},{key:"getSelectedNodes",value:function(){return this.getAllCacheSelectedRows()}},{key:"cacheSelectedRow",value:function(e,t){var n=String(null==e?void 0:e[this.getRowKeyField()]),a=(this._get_data("selectedKeys")||[]).filter(function(e){return e!==n}),r=f({},this._get_data("selectedRowsMap")||{});t&&a.push(n),t?r[n]=e:delete r[n],this._set_data("selectedKeys",a,!0),this._set_data("selectedRowsMap",r,!0),this._set_data("selectedKeysSet",new Set(a),!0)}},{key:"flushSelection",value:function(){this._applyState("selectedRows",this.getSelectedRows()),this.execute("selectionChange",{value:this.getSelectedRows(),keys:this.getSelectedKeys(),indexes:this.getSelectedRowIndexes()})}},{key:"restoreSelectedFlags",value:function(){if(this.get("cacheSelectedRows")){var e=this._get_data("selectedKeysSet")||new Set;if(e.size){var t=this.getRowKeyField(),n=this.getSelectedFlag();(this.getRows()||[]).forEach(function(a){a[n]=e.has(String(a[t]))})}}}},{key:"setPagination",value:function(e){this._applyState("pagination",!!e),this.showPage()}},{key:"getPageInfo",value:function(){return this._get_data("pageInfo")||createDefaults().pageInfo}},{key:"getPageIndex",value:function(){return this.getPageInfo().pageIndex}},{key:"getPageSize",value:function(){return this.getPageInfo().pageSize}},{key:"getTotalCount",value:function(){return this.getPageInfo().recordCount}},{key:"setPageInfo",value:function(e){this.applyPageInfo(f(f({},this.getPageInfo()),e),{refresh:!0})}},{key:"setPageIndex",value:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];"number"==typeof e&&this.applyPageInfo(f(f({},this.getPageInfo()),{},{pageIndex:Math.max(1,e)}),{refresh:t})}},{key:"setPageSize",value:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];"number"==typeof e&&this.applyPageInfo(f(f({},this.getPageInfo()),{},{pageSize:Math.max(-1,e),pageIndex:1}),{refresh:t})}},{key:"setRecordCount",value:function(e){this.applyPageInfo(f(f({},this.getPageInfo()),{},{recordCount:e||0}))}},{key:"applyPageInfo",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=f({},e||{}),a=-1===n.pageSize?-1:n.pageSize||20,r=n.recordCount||0,i=r>0;return n.pageSize=a,n.recordCount=r,n.pageCount=a>0?Math.max(1,Math.ceil(r/a)):1,n.pageIndex=a>0?Math.max(1,i?Math.min(n.pageIndex||1,n.pageCount):n.pageIndex||1):1,n.beginPageIndex=a>0?(n.pageIndex-1)*a+1:1,n.endPageIndex=a>0?Math.min(n.pageIndex*a,r):r,this._set_data("pageInfo",n,!0),t.silent||(this._applyState("pageInfo",n),this.isRemote()||this.showPage(),t.refresh&&this.isRemote()&&this.refresh()),n}},{key:"showPage",value:function(){var e=this._get_data("dataSource")||[];if(!this.isRemote()&&this.isPagination()){var t=this.getPageInfo(),n=t.pageIndex,a=t.pageSize,r=(n-1)*a;this.setRows(e.slice(r,r+a))}else this.setRows(e)}},{key:"setRows",value:function(e){var t=z(e)?e:[];this._set_data("rows",t,!0),this.setRowsIdMap(),this._applyState("data",t)}},{key:"setDataSourceView",value:function(){this._applyState("data",this._get_data("rows")||[])}},{key:"setRowsIdMap",value:function(){var e=this,t={};(this._get_data("rows")||[]).forEach(function(n){void 0!==(null==n?void 0:n[e.getIdFlag()])&&(t[n[e.getIdFlag()]]=n)}),this._set_data("rowsIdMap",t)}},{key:"getRowIdMap",value:function(){return this._get_data("rowsIdMap")||{}}},{key:"validate",value:function(e,t){var n=this;if(e)return this.doPropertyChange("validate",{type:"",message:"",errors:[]}),this._set_data("validateErrors",[]),!1;this.deleteNotModifiedRows();var a=this._get_data("columns")||{},r=t?this.getRowsByIndexes(t):this.getRows(),i=[];r.forEach(function(e,t){for(var r in a){var o=a[r];if(n.isRequiredColumn(o)){var s=e[r];if(G(s)||z(s)&&!s.length||X(s)){var u=o.cShowCaption||o.cCaption||o.cCaption||o.title||r;i.push({rowIndex:t,rowId:e[n.getIdFlag()],cellName:r,message:"".concat(u,"不能为空")}),n.setCellState(t,r,"msg","不能为空")}}}}),this._set_data("validateErrors",i);var o=i.length?i[0].message:"";return this.doPropertyChange("validate",{type:i.length?"error":"",message:o,errors:i}),this.execute("afterValidate",{valid:!i.length,errors:i}),!i.length}}])}(),ee=function(){function e(){return r(this,e),a(this,e,arguments)}return l(e,T),o(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 T&&(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 a,r=e.get(t);r instanceof T&&!1!==r._get_data("needCollect")&&(n[t]=null===(a=r.getData)||void 0===a?void 0:a.call(r))}),n}},{key:"getAllData",value:function(e){var t=this,n=this._get_data("propertyNames")||[],a={};return n.forEach(function(n){var r,i=t.get(n);if(i instanceof T&&!1!==i._get_data("needCollect")&&(!e||!i._get_data("isGrid"))){var o=null===(r=i.getData)||void 0===r?void 0:r.call(i);void 0!==o&&(a[n]=o)}}),a}},{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 a,r=t.get(n);r instanceof T&&!1!==r._get_data("needClear")&&(null===(a=r.clear)||void 0===a||a.call(r,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 a=null===(t=this.getParams())||void 0===t?void 0:t.masterGridModelName;if(a)return this.get(a);for(var r=this._get_data("propertyNames"),i=0,o=r.length;i<o;i++){if((n=this.get(r[i]))instanceof Z||"GridModel"==n.modelType)return this._set_data("gridModel",n),n}}},{key:"getGridModels",value:function(){for(var e=this._get_data("propertyNames"),t=[],n=0,a=e.length;n<a;n++){var r=this.get(e[n]);(r instanceof Z||"GridModel"==r.modelType)&&t.push(r)}return t}}])}();function te(e){var t=this;window&&window.__debugger_initExtendJs;var n=e.requirejs,a=e.extendFilePath,r=e.pageKey,i=e.enableExtendJs,o=void 0===i||i,s=e.extendJsPath,u=void 0===s?"_VM.Extend.js":s;if(o){var l="".concat(r).concat(u),c=[l];if("function"!=typeof n.require)return console.warn("requirejs.js 未加载,跳过扩展脚本:".concat(l)),void t.execute("extendReady",t);n.require(a,c,function(e,n){if(e&&e.doAction)try{e.doAction("init",t),n&&n.doAction("init",t)}catch(e){console.error("扩展脚本异常:",e)}else console.error("".concat(l,"扩展文件extend.*.min.js文件加载失败 或 未注册扩展脚本"));t.execute("extendReady",t)},function(e){console.warn("未找到扩展脚本:".concat(l,"错误信息:"),e),t.execute("extendReady",t)})}else t.execute("extendReady",t)}var ne=function(){var e=n(v().m(function e(t,a,r){var i,o,s,u;return v().w(function(e){for(;;)switch(e.n){case 0:if(s=t.extscripturls,u=void 0===s?[]:s,u=(u=(a.getCache("localDynamicScripts")||[]).concat(u)).concat(window.__devfab__EXT_BILL_SCRIPTS__||[]),null!==(i=a.getParams())&&void 0!==i&&i.initVMExtUrls&&(u=u.concat([a.getParams().initVMExtUrls])),null===(o=u)||void 0===o||!o.length){e.n=2;break}return u=w(new Set(u)),e.n=1,Promise.all(u.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 1:u=e.v;case 2:return t.extscripturls=u,e.a(2,new Promise(function(e,n){ae(t,a,r,function(){e(!0)})}))}},e)}));return function(t,n,a){return e.apply(this,arguments)}}();function ae(e,t,n,a){var r=e.extscripturls,i=void 0===r?[]:r;if(null!=i&&i.length)try{var o,s=null==n||null===(o=n.requirejs)||void 0===o?void 0:o.requireInner;if("function"!=typeof s)return console.warn("requirejs.js 未加载,跳过客开扩展脚本"),void(null==a||a(e,t));s(i,function(){var n=!0;if(arguments.length){for(var r=0,i=arguments.length;r<i;r++){var o=r<0||arguments.length<=r?void 0:arguments[r];o?o.doAction("init",t):n=!1}n&&(null==a||a(e,t))}else n=!1;n||console.log("[error] [extendjs] 租户级扩展脚本有语法错误,请修改正确后刷新浏览器重试!")},function(n){null==a||a(e,t)})}catch(n){null==a||a(e,t)}else null==a||a(e,t)}function re(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.extendFilePathField,i=void 0===n?"domainKey":n,s=t.pageKeyField,u=void 0===s?"billNo":s,c=t.modelNameField,d=void 0===c?"cName":c,h=e[i]||"",v=e[u]||"",g=function(){function e(){return r(this,e),a(this,e,arguments)}return l(e,ee),o(e,[{key:"init",value:function(e,t){var n=this.createModels(e,t);this.setData(n),this.setDirty(!1)}},{key:"createModels",value:function(e,n){var a={};return(Array.isArray(e)?e:[]).forEach(function(e){var r,i,o=null==t||null===(r=t.createModelFactory)||void 0===r?void 0:r.call(t,e);o||(o=function(e){var t;"input"===e.cControlType.toLowerCase()&&(t=new V(e));return t}(e));var s={model:o,field:e,meta:n};null==t||null===(i=t.onBeforeCreateModel)||void 0===i||i.call(t,s),a[e[d]]=s.model}),a}},{key:"initData",value:function(){te.call(this,f(f({},t),{},{extendFilePath:h,pageKey:v}))}}])}();return g.prototype.modelType="ViewModel",g}var ie={BaseModel:T,FilterModel:K,SimpleModel:V,GridModel:Z,ViewModel:ee,initViewModel:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},a=arguments.length>2?arguments[2]:void 0;null!=t&&t.requirejs||(t.requirejs=window.__devfab);var r=function(e,t){var n=new(re(e,t));return n.init(e.models,e),n}(e,t);return r.on("destroyVM",function(){var e,t;null===(e=r)||void 0===e||null===(t=e.destroyVM)||void 0===t||t.call(e),r=null}),r.on("extendReady",n(v().m(function n(){var i;return v().w(function(n){for(;;)switch(n.n){case 0:return(i=[]).push(ne(e,r,t)),n.n=1,Promise.all(i);case 1:null==a||a(r,e);case 2:return n.a(2)}},n)}))),r.initData(),r}},oe={Builder:D,CacheUtil:j,EventUtil:E,DynamicProxy:N},se={utils:{builder:new oe.Builder,cache:new oe.CacheUtil,event:new oe.EventUtil},common:{Builder:D,models:ie,utils:oe}};exports.default=se;