UNPKG

52 kBJavaScriptView Raw
1!function(e){"use strict";var t=!0,a={toString:1};for(var n in a)t=null;t&&(t=["hasOwnProperty","valueOf","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","constructor"]);var s=function(e,a){var n,s=arguments;if(s.length>1)for(var r=1;r<s.length;r++)if(n=s[r],e&&n&&"object"==typeof n){var i,o,l;for(i in n)e[i]=n[i];if(t)for(o=t.length;o--;)l=t[o],n.hasOwnProperty&&n.hasOwnProperty(l)&&(e[l]=n[l])}return e};Object.assign||(Object.assign=s);var r=function(e,t){this.copyRows(e,[t])},i=function(e,t){for(var a=0;a<t.length;a++){var n=new Row({parent:this});t[a]&&n.setData(t[a].getData()),this.insertRows(void 0===e?this.rows().length:e,[n])}},o={copyRow:r,copyRows:i},l=function(e,t){if(e.pageIndex||0===e.pageIndex)var a=e.pageIndex;else var a=this.pageIndex();if(e.pageSize||0===e.pageSize)var n=e.pageSize;else var n=this.pageSize();if(e.totalPages||0===e.totalPages)var s=e.totalPages;else var s=this.totalPages();if(e.totalRow||0===e.totalRow)var r=e.totalRow;else if(e.rows)var r=e.rows.length;else var r=this.totalRow();var i,o,l=!!t&&t.unSelect;if(this.pageIndex(a),this.pageSize(n),this.pageCache=e.pageCache||this.pageCache,!0===this.pageCache){if(this.updatePages(e.pages),a!=this.pageIndex())return this.setCurrentPage(a,!0),this.totalPages(s),void this.totalRow(r+this.newCount);this.removeAllRows(),i=this.getPage(a).selectedIndices,o=this.getPage(a).focus;var u=this.setRows(this.getPage(a).rows,t);this.getPage(a).rows=u,e.totalPages&&this.totalPages(e.totalPages),(e.totalRow||0===e.totalRow)&&this.totalRow(e.totalRow+this.newCount)}else i=e.select||(l?[]:[0]),o=void 0!==e.focus?e.focus:e.current,this.setRows(e.rows,t),this.totalPages(s),this.totalRow(r);this.updateSelectedIndices(),i&&i.length>0&&this.rows().length>0&&this.setRowsSelect(i),void 0!==o&&this.getRow(o)&&this.setRowFocus(o)},h=function(e,t,a,n){1===arguments.length&&(t=e,e="$data"),(a=a||this.getCurrentRow())&&a.setValue(e,t,n)},c=function(){var e=new Array;e=e.concat(this.rows());for(var t=0;t<e.length;t++){var a=e[t];this.resetValueByRow(a)}},g=function(e){if(e.status==Row.STATUS.NEW)this.setRowsDelete(e);else if(e.status==Row.STATUS.FALSE_DELETE){e.status=Row.STATUS.NORMAL;var t=[e];this.trigger(DataTable.ON_INSERT,{index:0,rows:t})}else e.status==Row.STATUS.UPDATE&&(e.status=Row.STATUS.NORMAL,e.resetValue())},d={setData:l,setValue:h,resetAllValue:c,resetValueByRow:g},f=function(e){var t=this.getMeta(e,"enable");return void 0!==t&&null!=t||(t=!0),t&&this.enable},w=function(e){this.enable!=e&&(e=!1!==e,this.enable=e,this.enableChange(-this.enableChange()),this.trigger(DataTable.ON_ENABLE_CHANGE,{enable:this.enable}))},p={isEnable:f,setEnable:w},v=function(){if(-1!=this.focusIndex())return this.getFocusRow();var e=this.getSelectedIndex();return-1==e?null:this.getRow(e)},R=function(){if(-1!=this.focusIndex())return this.focusIndex();var e=this.getSelectedIndex();return-1==e?-1:e},m={getCurrentRow:v,getCurrentIndex:R},S=function(){for(var e=[],t=this.rows(),a=0;a<t.length;a++)e.push(t[a].getData());return e},_=function(e,t){var a={};return a.focus=e.focus,a.index=t,a.select=e.selectedIndices,a},T=function(e){var t,a={},n=null;if(a.meta=this.meta,a.params=this.params,e=e||DataTable.SUBMIT.current,this.pageCache){var s=this.getPages();if(e==DataTable.SUBMIT.current||e==DataTable.SUBMIT.focus){n=[];var r=this.pageIndex(),i=s[r];if(i){var o=this.focusIndex();e==DataTable.SUBMIT.current&&-1==o&&(o=this.getSelectedIndex());var l=_(i,r);l.rows=[];for(var u=0,h=i.rows.length;u<h;u++){var c=i.rows[u].getData();u!=o&&(c.data={}),l.rows.push(c)}n.push(l)}}else if(e==DataTable.SUBMIT.all||e==DataTable.SUBMIT.allPages){n=[];for(var u=0;u<s.length;u++){var i=s[u],l=_(i,u);l.rows=[];for(var u=0;u<i.rows.length;u++)l.rows.push(i.rows[u].getData());n.push(l)}}else if(e==DataTable.SUBMIT.select){n=[];var r=this.pageIndex(),i=s[r];if(i){var l=_(i,r);l.rows=[];for(var u=0,h=i.rows.length;u<h;u++){var c=i.rows[u].getData();l.select.indexOf(u)<0&&(c.data={}),l.rows.push(c)}n.push(l)}}else if(e==DataTable.SUBMIT.allSelect){n=[];for(var u=0;u<s.length;u++){var i=s[u],l=_(i,u);l.rows=[];for(var g=0,h=i.rows.length;g<h;g++){var c=i.rows[g].getData();l.select.indexOf(g)<0&&(c.data={}),l.rows.push(c)}n.push(l)}}else if(e==DataTable.SUBMIT.change){n=[];for(var u=0;u<s.length;u++){var i=s[u],l=_(i,u);l.rows=[];for(var g=0,h=i.rows.length;g<h;g++){var c=i.rows[g].getData();c.status==Row.STATUS.NORMAL&&(c.data={}),l.rows.push(c)}n.push(l)}}else e===DataTable.SUBMIT.empty&&(n=[]);(s.length<1||!s[this.pageIndex()])&&(n=[{index:this.pageIndex(),select:[],focus:-1,rows:[]}]),a.pages=n}else{if(e==DataTable.SUBMIT.current){n=[];var o=this.focusIndex();-1==o&&(o=this.getSelectedIndex()),t=this.rows();for(var u=0,h=t.length;u<h;u++)u==o?n.push(t[u].getData()):n.push(t[u].getEmptyData())}else if(e==DataTable.SUBMIT.focus){n=[],t=this.rows();for(var u=0,h=t.length;u<h;u++)u==this.focusIndex()?n.push(t[u].getData()):n.push(t[u].getEmptyData())}else e==DataTable.SUBMIT.all?n=this.getData():e==DataTable.SUBMIT.select?n=this.getSelectedDatas(!0):e==DataTable.SUBMIT.change?n=this.getChangedDatas():e===DataTable.SUBMIT.empty&&(n=[]);a.rows=n,a.select=this.getSelectedIndexs(),a.focus=this.getFocusIndex()}return a.pageSize=this.pageSize(),a.pageIndex=this.pageIndex(),a.isChanged=this.isChanged(),a.master=this.master,a.pageCache=this.pageCache,a},C=function(e){return this.rows.peek()[e]},I=function(e){var t=e.fullField,a=e.index,n=null;if(parseInt(a)>-1)if((a+"").indexOf(".")>0){for(var s=t.split("."),r=a.split("."),i=this,o=null,l=0;l<r.length;l++)if(o=i.getRow(r[l]),l<r.length-1){if(!o){o=null;break}i=o.getValue(s[l])}n=o}else n=this.getRow(a);return n},b=function(e){for(var t=this.rows.peek(),a=0,n=t.length;a<n;a++)if(t[a].rowId==e)return t[a];return null},D=function(e){for(var t=this.rows.peek(),a=0,n=t.length;a<n;a++)if(t[a].rowId===e.rowId)return a;return-1},y=function(e,t){for(var a=this.rows.peek(),n=new Array,s=0,r=a.length;s<r;s++)a[s].getValue(e)===t&&n.push(a[s]);return n},E=function(e,t){for(var a=this.rows.peek(),n=0,s=a.length;n<s;n++)if(a[n].getValue(e)===t)return a[n];return null},O=function(){return this.rows.peek()},A=function(){for(var e,t=[],a=0;a<this.totalPages();a++){if(e=[],a==this.pageIndex())e=this.getData();else{var n=this.cachedPages[a];n&&(e=n.getData())}for(var s=0;s<e.length;s++)t.push(e[s])}return t},x=function(e){for(var t=[],a=this.rows(),n=0,s=a.length;n<s;n++)a[n]&&a[n].status!=Row.STATUS.NORMAL?t.push(a[n].getData()):1==e&&t.push(a[n].getEmptyData());return t},M=function(){for(var e=[],t=this.rows.peek(),a=0,n=t.length;a<n;a++)t[a]&&t[a].status!=Row.STATUS.NORMAL&&e.push(t[a]);return e},N=function(){for(var e=[],t=this.rows.peek(),a=0,n=t.length;a<n;a++)t[a]&&t[a].status==Row.STATUS.FALSE_DELETE&&e.push(t[a]);return e},U=function(e,t){return t=t||this.getCurrentRow(),t?t.getValue(e):""},P=function(e){for(var t=this.rows(),a=0,n=t.length;a<n;a++)if(t[a].rowId==e)return a;return-1},F=function(){for(var e=this.getAllRows(),t=[],a=0,n=e.length;a<n;a++)e[a]&&t.push(e[a].getData());return t},L=function(e){for(var t=[],a=0;a<e.length;a++)this.getRow(e[a])&&t.push(this.getRow(e[a]).rowId);return t},k=function(e){for(var t=[],a=0;a<e.length;a++)t.push(this.getRow(e[a]));return t},j={getData:S,getDataByRule:T,getRow:C,getChildRow:I,getRowByRowId:b,getRowIndex:D,getRowsByField:y,getRowByField:E,getAllRows:O,getAllPageRows:A,getChangedDatas:x,getChangedRows:M,getDeleteRows:N,getValue:U,getIndexByRowId:P,getAllDatas:F,getRowIdsByIndices:L,getRowsByIndices:k},V=function(){return-1!=this.focusIndex()?this.getRow(this.focusIndex()):null},B=function(){return this.focusIndex()},H={getFocusRow:V,getFocusIndex:B},W=function(e,t){return 0===arguments.length?this.meta:1===arguments.length?this.meta[e]:this.meta[e]&&void 0!==this.meta[e][t]?this.meta[e][t]:null},z=function(e,t){var a=this.getCurrentRow();return a?a.getMeta(e,t):this.getMeta(e,t)},Y={getMeta:W,getRowMeta:z},G=function(e){return this.pageCache?this.cachedPages[e]:-1},Z=function(){return this.pageCache?this.cachedPages:[]},J={getPage:G,getPages:Z},q=function(e){return this.params[e]},$={getParam:q},X=function(){var e=this.selectedIndices();return null==e||0==e.length?-1:e[0]},Q=function(){var e=this.selectedIndices();return null==e||0==e.length?[]:e},K=function(){return this.getSelectedIndices()},ee=function(e){for(var t=this.selectedIndices(),a=[],n=[],s=0,r=t.length;s<r;s++)n.push(t[s]);for(var i=this.rows(),s=0,r=i.length;s<r;s++)-1!=n.indexOf(s)?a.push(i[s].getData()):1==e&&a.push(i[s].getEmptyData());return a},te=function(){for(var e=this.selectedIndices(),t=[],a=this.rows.peek(),n=[],s=0,r=e.length;s<r;s++)n.push(e[s]);for(var s=0,r=a.length;s<r;s++)-1!=n.indexOf(s)&&t.push(a[s]);return t},ae={getSelectedIndex:X,getSelectedIndices:Q,getSelectedIndexs:K,getSelectedDatas:ee,getSelectedRows:te},ne=function(e){e=e||{};var t,a=[],n=e.type||"all",s=e.fields||null;if("current"===n){var r=this.getCurrentRow();t=null==r?[]:[r]}else if("focus"===n){var i=this.getFocusRow();t=null==i?[]:[i]}else if(this.pageCache){var o=this.getPages();t=[];for(var l=0;l<o.length;l++){var u=o[l];"all"===n?t=t.concat(u.rows.peek()):"select"===n?t=t.concat(u.getSelectRows()):"change"===n&&(t=t.concat(u.getSelectRows()))}}else"all"===n?t=this.rows.peek():"select"===n?t=this.getSelectedRows():"change"===n&&(t=this.getChangedRows());for(var l=0;l<t.length;l++)a.push(t[l].getSimpleData({fields:s}));return 0==a.length&&(a=this.setSimpleDataReal),a},se={getSimpleData:ne},re="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},ie=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},oe=function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)},le=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t},ue=function(e,t,a){if(this.meta[e]){var n=this.meta[e][t],s=this.getCurrentRow();this.meta[e][t]=a,this.metaChange[e+"."+t]&&this.metaChange[e+"."+t](-this.metaChange[e+"."+t]()),"enable"==t&&this.enableChange(-this.enableChange()),this.trigger(DataTable.ON_META_CHANGE,{eventType:"dataTableEvent",dataTable:this.id,field:e,meta:t,oldValue:n,newValue:a}),s&&!s.getMeta(e,t,!1)&&this.trigger(e+"."+t+"."+DataTable.ON_CURRENT_META_CHANGE,{eventType:"dataTableEvent",dataTable:this.id,oldValue:n,newValue:a})}},he=function(e){if(e)for(var t in e)for(var a in e[t]){var n=this.meta[t][a],s=e[t][a];"default"===a?(this.meta[t].default||(this.meta[t].default={}),this.meta[t].default.value=e[t][a]):"display"===a?(this.meta[t].default||(this.meta[t].default={}),this.meta[t].default.display=e[t][a]):this.meta[t][a]=e[t][a],this.metaChange[t+"."+a]&&this.metaChange[t+"."+a](-this.metaChange[t+"."+a]()),this.trigger(DataTable.ON_META_CHANGE,{eventType:"dataTableEvent",dataTable:this.id,field:t,meta:a,oldValue:n,newValue:s})}},ce=function(e,t){if(1!=this.root.strict){if(-1!=e.indexOf("."))for(var a=e.split("."),n=a[0],s=0,r=a.length;s<r;s++){if(this.meta[n]&&"child"===this.meta[n].type)return;s+1<r&&(n=n+"."+a[s+1])}if(this.meta[e]||(this.meta[e]={}),"object"===(void 0===t?"undefined":re(t)))if(t.meta)for(var i in t.meta)this.meta[e].meta[i]=t.meta[i];else for(var i in t)this.meta[e][i]=t[i];if(this.root!==this){for(var o=this.ns.split("."),l=this.root.meta,s=0;s<o.length;s++)l[o[s]]=l[o[s]]||{},l[o[s]].type=l[o[s]].type||"child",l[o[s]].meta=l[o[s]].meta||{},l=l[o[s]].meta;if(l[e]||(l[e]={}),"object"===(void 0===t?"undefined":re(t)))for(var i in t)l[e][i]||(l[e][i]=t[i])}}},ge={setMeta:ue,updateMeta:he,createField:ce},de=function(e,t){var a=this.totalRow();e!=this.pageIndex()&&1!=t&&this.cacheCurrentPage(),this.pageIndex(e);var n=this.cachedPages[this.pageIndex()];if(n){var s=n.selectedIndices;this.removeAllRows(),this.setRows(n.rows),this.setRowsSelect(s)}this.totalRow(a)},fe=function(e){var t,a,n,t,s,r,i,o,l,u,n;this.pageSize();for(r=0;r<e.length;r++)if(s=e[r].index,i=e[r].rows,o=e[r].current,l=e[r].select,"del"!==e[r].status)if(this.cachedPages[s]){t=this.cachedPages[s],t.selectedIndices=l,t.focus=o;for(var u=0;u<i.length;u++)if(a=i[u],a.id||(a.id=Row.getRandomRowId()),a.status==Row.STATUS.DELETE){var n=t.getRowByRowId(a.id);if(n){var h=this.totalRow(),c=h-1;this.totalRow(c),n.status==Row.STATUS.NEW&&(this.newCount-=1,this.newCount<0&&(this.newCount=0))}this.removeRowByRowId(a.id),t.removeRowByRowId(a.id)}else if(n=t.getRowByRowId(a.id))t.updateRow(n,a),n.status==Row.STATUS.NEW&&a.status!=Row.STATUS.NEW&&(this.newCount-=1,this.newCount<0&&(this.newCount=0)),n.setStatus(Row.STATUS.NORMAL),a.status==Row.STATUS.NEW&&n.setStatus(Row.STATUS.NEW);else{a.rowId=a.id,delete a.id,t.rows.push(a),a.status!=Row.STATUS.NEW?n.setStatus(Row.STATUS.NORMAL):this.newCount+=1;var h=this.totalRow(),c=h+1;this.totalRow(c)}}else{t=new Page({parent:this}),t.rows=i;for(var u=0;u<t.rows.length;u++)t.rows[u].rowId=t.rows[u].id,delete t.rows[u].id;this.cachedPages[s]=t,t.selectedIndices=l,t.focus=o}else this.cachedPages[s]=null},we=function(e){var t,a=this.pageSize(),n=0;this.cachedPages=[];for(var s=0;s<e.length;s++)n=Math.floor(s/a),this.cachedPages[n]||(t=new Page({parent:this}),this.cachedPages[n]=t),t.rows.push(e[s]);this.pageIndex()>-1&&this.setCurrentPage(this.pageIndex()),this.totalRow(e.length),this.totalPages(n+1)},pe=function(e){return!(!this.pageCache||!this.cachedPages[e])},ve=function(){this.cachedPages=[]},Re=function(){if(this.pageCache&&this.pageIndex()>-1){var e=new Page({parent:this});e.focus=this.getFocusIndex(),e.selectedIndices=this.selectedIndices().slice();for(var t=this.rows.peek(),a=0;a<t.length;a++){var n=t[a].getData();n.rowId=n.id,delete n.id,e.rows.push(n)}this.cachedPages[this.pageIndex()]=e}},me=function(){for(var e=this.getSelectedRows(),t=this.getPages(),a=0;a<t.length;a++){for(var n=t[a].rows,s=[],r=0;r<e.length;r++)for(var i=e[r],o=0;o<n.length;o++){var l=n[o];if(i==l){s.push(o);break}}t[a].selectedIndices=s}},Se=function(){if(this.pageCache){var e=this.pageIndex(),t=this.getPages()[e];t&&(t.rows=this.rows())}},_e=function(){if(this.pageCache){var e=this.pageIndex(),t=this.getPages()[e];if(t){var a=this.selectedIndices().slice();t.selectedIndices=a}}},Te=function(){if(this.pageCache){var e=this.pageIndex(),t=this.getPages()[e];t&&(t.focus=this.getFocusIndex())}},Ce=function(){this.updatePageRows(),this.updatePageSelect(),this.updatePageFocus()},Ie={setCurrentPage:de,updatePages:fe,setPages:we,hasPage:pe,clearCache:ve,cacheCurrentPage:Re,updatePagesSelect:me,updatePageRows:Se,updatePageSelect:_e,updatePageFocus:Te,updatePageAll:Ce},be=function(e,t){this.params[e]=t},De=function(e){for(var t in e)this.params[t]=e[t]},ye={addParam:be,addParams:De},Ee=function(){return ko.pureComputed({read:function(){for(var e=this.selectedIndices()||[],t=this.rows(),a=[],n=0;n<e.length;n++)a.push(t[n]);return a},owner:this})},Oe=function(e){return this.createField(e),this.valueChange[e]||(this.valueChange[e]=ko.observable(1)),ko.pureComputed({read:function(){this.valueChange[e](),this.currentRowChange();var t=this.getCurrentRow();return t?t.getChildValue(e):""},write:function(t){var a=this.getCurrentRow();a&&a.setChildValue(e,t)},owner:this})},Ae=function(e,t){return this.metaChange[e+"."+t]||(this.metaChange[e+"."+t]=ko.observable(1)),ko.pureComputed({read:function(){return this.metaChange[e+"."+t](),this.currentRowChange(),this.getMeta(e,t)},write:function(a){this.setMeta(e,t,a)},owner:this})},xe=function(e,t){return this.metaChange[e+"."+t]||(this.metaChange[e+"."+t]=ko.observable(1)),ko.pureComputed({read:function(){this.metaChange[e+"."+t](),this.currentRowChange();var a=this.getCurrentRow();return a?a.getMeta(e,t):this.getMeta(e,t)},write:function(t){var a=this.getCurrentRow();a&&a.setMeta(e,t)},owner:this})},Me=function(e){return ko.pureComputed({read:function(){if(this.enableChange(),!e)return this.enable;var t=this.getRowMeta(e,"enable");return void 0!==t&&null!=t||(t=!0),t&&this.enable},owner:this})},Ne={refSelectedRows:Ee,ref:Oe,refMeta:Ae,refRowMeta:xe,refEnable:Me},Ue=function(e){var t=function(){};return t.prototype=e,new t},Pe=function(e,t){if(t){if("object"==typeof t)return t;for(var a=t.split("."),n=e,s=0;s<a.length;s++)if(!(n=n[a[s]]))return null;return n}},Fe=function(e){return e-parseFloat(e)+1>=0},Le=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)},ke=function(e){var t;for(t in e)return!1;return!0};try{NodeList.prototype.forEach=Array.prototype.forEach}catch(e){}String.prototype.lengthb=function(){return this.replace(/[^\x00-\xff]/g,"**").length},String.prototype.replaceAll=function(e,t){var a=new RegExp(e,"g");return this.replace(a,t)};var je=function(e){if("string"!=typeof e)return e;if(e&&e.indexOf("-")>-1){/iphone|ipad|ipod/.test(navigator.userAgent.toLowerCase())&&(e=e.replace(/-/g,"/"),e=e.replace(/(^\s+)|(\s+$)/g,""),e.length<=8&&(e=e+="/01"))}return e},Ve=function(){for(var e=this.getAllRows(),t=0;t<e.length;t++)if(e[t].status!=Row.STATUS.NORMAL)return!0;return!1},Be=function(e,t){if("string"==typeof t||"number"==typeof t)t=[t];else if(t instanceof Row)t=[e.getIndexByRowId(t.rowId)];else if(Le(t)&&t.length>0&&t[0]instanceof Row)for(var a=0;a<t.length;a++)t[a]=e.getIndexByRowId(t[a].rowId);return t},He={isChanged:Ve,_formatToIndicesArray:Be},We=function(e){var t=this.getIndexByRowId(e);-1!=t&&this.removeRow(t)},ze=function(e){e instanceof Row&&(e=this.getIndexByRowId(e.rowId)),this.removeRows([e])},Ye=function(){this.rows([]),this.selectedIndices([]),this.focusIndex(-1),this.trigger(DataTable.ON_DELETE_ALL),this.updateCurrIndex()},Ge=function(e){this.setRowsDelete(e)},Ze=function(){this.removeAllRows(),this.cachedPages=[],this.totalPages(1),this.pageIndex(0),this.focusIndex(-1),this.selectedIndices([])},Je={removeRowByRowId:We,removeRow:ze,removeAllRows:Ye,removeRows:Ge,clear:Ze},qe=function(e,t){for(var a,n=[],s=0;s<e.length;s++){var r=e[s];if(a=r.rowId||r.id,a||(a=Row.getRandomRowId()),r.status==Row.STATUS.DELETE)this.removeRowByRowId(a);else{var i=this.getRowByRowId(a);i?(i.updateRow(r),ke(r.data)||(this.trigger(DataTable.ON_UPDATE,{index:s,rows:[i]}),i==this.getCurrentRow()?(this.currentRowChange(-this.currentRowChange()),i.currentRowChange(-i.currentRowChange()),this.trigger(DataTable.ON_CURRENT_UPDATE,{index:s,rows:[i]})):i.currentRowChange(-i.currentRowChange()))):(i=new Row({parent:this,id:a}),i.setData(e[s],null,t),n.push(i)),r.status&&i.setStatus(r.status)}}return n.length>0&&this.addRows(n),n},$e=function(e){this.insertRow(this.rows().length,e),this.resetDelRowEnd()},Xe=function(){for(var e=this.rows().length-1;e>-1;e--){var t=this.rows()[e];t.status!=Row.STATUS.DELETE&&t.status!=Row.STATUS.FALSE_DELETE||(this.rows().splice(e,1),this.rows().push(t))}},Qe=function(e){this.insertRows(this.rows().length,e),this.resetDelRowEnd()},Ke=function(e,t){t||(t=new Row({parent:this})),this.insertRows(e,[t])},et=function(e,t){for(var a=[e,0],n=0;n<t.length;n++)a.push(t[n]);this.rows.splice.apply(this.rows,a),this.updateSelectedIndices(e,"+",t.length),this.updateFocusIndex(e,"+",t.length),this.updatePageAll(),this.trigger(DataTable.ON_INSERT,{index:e,rows:t}),this.ns&&this.root.valueChange[this.ns]&&this.root.valueChange[this.ns](-this.root.valueChange[this.ns]())},tt=function(e){var t=new Row({parent:this});return this.addRow(t),!!e&&e.unSelect||this.getCurrentRow()||this.setRowSelect(t),t},at={setRows:qe,addRow:$e,addRows:Qe,insertRow:Ke,insertRows:et,createEmptyRow:tt,resetDelRowEnd:Xe},nt=function(){var e=-1!=this.focusIndex()?this.focusIndex():this.getSelectedIndex();this._oldCurrentIndex!=e&&(this._oldCurrentIndex=e,this.trigger(DataTable.ON_CURRENT_ROW_CHANGE),this.currentRowChange(-this.currentRowChange()),this.ns&&this.root.valueChange[this.ns]&&this.root.valueChange[this.ns](-this.root.valueChange[this.ns]()))},st={updateCurrIndex:nt},rt=function(e){e instanceof Row&&(e=this.getIndexByRowId(e.rowId)),this.setRowsDelete([e])},it=function(){for(var e=new Array(this.rows().length),t=0;t<e.length;t++)e[t]=t;this.setRowsDelete(e)},ot=function(e){e=He._formatToIndicesArray(this,e),e=e.sort(function(e,t){return t-e});for(var t=this.getRowIdsByIndices(e),a=this.getRowsByIndices(e),n=this.rows(),s=0;s<e.length;s++){var r=this.getRow(e[s]);if(r.status==Row.STATUS.NEW||this.forceDel)n.splice(e[s],1);else{r.setStatus(Row.STATUS.FALSE_DELETE);var i=n.splice(e[s],1);n.push(i[0])}this.updateSelectedIndices(e[s],"-"),this.updateFocusIndex(e[s],"-")}this.rows(n),this.updateCurrIndex(),this.trigger(DataTable.ON_DELETE,{falseDelete:!0,indices:e,rowIds:t,rows:a})},lt={setRowDelete:rt,setAllRowsDelete:it,setRowsDelete:ot},ut=function(){for(var e=new Array(this.rows().length),t=0;t<e.length;t++)e[t]=t;this.setRowsSelect(e),this.allSelected(!0),this.trigger(DataTable.ON_ROW_ALLSELECT,{})},ht=function(e){e instanceof Row&&(e=this.getIndexByRowId(e.rowId)),this.setRowsSelect([e]),this.setRowFocus(this.getSelectedIndex())},ct=function(e){if(-1==(e=e||-1))return void this.setAllRowsUnSelect({quiet:!0});e=He._formatToIndicesArray(this,e);var t=this.selectedIndices();if(!Le(e)||!Le(t)||e.join()!=t.join()){if(Le(e))for(var a=this.rows().length,n=0;n<e.length;n++)(e[n]<0||e[n]>=a)&&e.splice(n,1);this.setAllRowsUnSelect({quiet:!0});try{this.selectedIndices(e)}catch(e){}this.updatePageSelect();var s=this.getRowIdsByIndices(e);this.currentRowChange(-this.currentRowChange()),this.trigger(DataTable.ON_ROW_SELECT,{indices:e,rowIds:s}),this.updateCurrIndex()}},gt=function(e){e instanceof Row&&(e=this.getIndexByRowId(e.rowId)),this.addRowsSelect([e])},dt=function(e){e=He._formatToIndicesArray(this,e);for(var t=this.selectedIndices().slice(),a=!1,n=0;n<e.length;n++){for(var s=e[n],r=!0,i=0;i<t.length;i++)t[i]==s&&(r=!1);r&&e[n]>-1&&(a=!0,t.push(e[n]))}this.selectedIndices(t),this.updatePageSelect();var o=this.getRowIdsByIndices(t);a&&this.trigger(DataTable.ON_ROW_SELECT,{indices:t,rowIds:o}),this.updateCurrIndex()},ft=function(e){this.selectedIndices([]),this.updatePageSelect(),e&&e.quiet||this.trigger(DataTable.ON_ROW_ALLUNSELECT),this.updateCurrIndex(),this.allSelected(!1)},wt=function(e){e instanceof Row&&(e=this.getIndexByRowId(e.rowId)),this.setRowsUnSelect([e])},pt=function(e){e=He._formatToIndicesArray(this,e);var t=this.selectedIndices().slice();if(-1!=t.indexOf(e[0])){for(var a=0;a<e.length;a++){var n=e[a],s=t.indexOf(n);-1!=s&&t.splice(s,1)}this.selectedIndices(t),this.updatePageSelect();var r=this.getRowIdsByIndices(e);this.trigger(DataTable.ON_ROW_UNSELECT,{indices:e,rowIds:r}),this.updateCurrIndex(),this.allSelected(!1)}},vt=function(){this.allSelected()?this.setAllRowsUnSelect():this.setAllRowsSelect()},Rt=function(e,t,a){Fe(a)||(a=1);var n=this.selectedIndices().slice();if(null!=n&&0!=n.length){for(var s=0,r=n.length;s<r;s++)"+"==t?n[s]>=e&&(n[s]=parseInt(n[s])+a):"-"==t&&(n[s]>=e&&n[s]<=e+a-1?n.splice(s,1):n[s]>e+a-1&&(n[s]=n[s]-a));this.selectedIndices(n),this.updatePageSelect()}},mt={setAllRowsSelect:ut,setRowSelect:ht,setRowsSelect:ct,addRowSelect:gt,addRowsSelect:dt,setAllRowsUnSelect:ft,setRowUnSelect:wt,setRowsUnSelect:pt,toggleAllSelect:vt,updateSelectedIndices:Rt},St=function(e,t,a){var n=null;e instanceof Row&&(e=this.getIndexByRowId(e.rowId),n=e.rowId),-1===e||e===this.focusIndex()&&!a||(this.focusIndex(e),t||(this.currentRowChange(-this.currentRowChange()),n||(n=this.getRow(e).rowId),this.trigger(DataTable.ON_ROW_FOCUS,{index:e,rowId:n}),this.updateCurrIndex()))},_t=function(){this.currentRowChange(-this.currentRowChange());var e=this.focusIndex(),t=null;-1!==e&&(t=this.getRow(e).rowId),this.trigger(DataTable.ON_ROW_UNFOCUS,{index:e,rowId:t}),this.focusIndex(-1),this.updateCurrIndex()},Tt=function(e,t,a){Fe(a)||(a=1),e<=this.focusIndex()&&-1!=this.focusIndex()&&("+"===t?this.focusIndex(this.focusIndex()+a):"-"===t&&(this.focusIndex()>=e&&this.focusIndex()<=e+a-1?this.focusIndex(-1):this.focusIndex()>e+a-1&&this.focusIndex(this.focusIndex()-a)))},Ct={setRowFocus:St,setRowUnFocus:_t,updateFocusIndex:Tt},It=function(e,t){if(this.removeAllRows(),this.cachedPages=[],this.focusIndex(-1),this.selectedIndices([]),this.setSimpleDataReal=[],!e)return void(this.setSimpleDataReal=e);var a=[];Le(e)||(e=[e]);for(var n=0;n<e.length;n++){var s=e[n];"object"!==re(e[n])&&(s={$data:e[n]}),a.push({status:Row.STATUS.NORMAL,data:s})}var s={rows:a};t&&void 0===t.fieldFlag&&(t.fieldFlag=!0),this.setData(s,t)},bt=function(e,t,a){if(!e)throw new Error("dataTable.addSimpleData param can't be null!");Le(e)||(e=[e]);for(var n=0;n<e.length;n++){this.createEmptyRow(a).setSimpleData(e[n],t)}},Dt={setSimpleData:It,addSimpleData:bt},yt=function(e,t,a){var n=this,s=t;if("[object Array]"==Object.prototype.toString.call(e)){for(var r in e)this.on(e[r],t);return this}if("object"==(void 0===e?"undefined":re(e))){for(var i in e)this.on(i,e[i]);return this}return a&&(t=function(){n.off(e,t),s.apply(this,arguments)}),e=e.toLowerCase(),this._events||(this._events={}),(this._events[e]||(this._events[e]=[])).push({callback:t}),this},Et=function(e,t){if(e=e.toLowerCase(),!this._events)return this;if("[object Array]"==Object.prototype.toString.call(e)){for(var a in e)this.off(e[a],t);return this}if("object"==(void 0===e?"undefined":re(e))){for(var n in e)this.off(n,e[n]);return this}var s=this._events[e];if(!s)return this;if(t)for(var a=s.length-1;a>=0;a--)s[a]==t&&s.splice(a,1);else s=null;return this._events[e]=s,this},Ot=function(e,t){this.on(e,t,1)},At=function(e){if(e=e.toLowerCase(),!this._events||!this._events[e])return this;for(var t=Array.prototype.slice.call(arguments,1),a=this._events[e],n=0,s=a.length;n<s;n++)a[n].callback.apply(this,t);return this},xt=function(e){if(e=e.toLowerCase(),!this._events||!this._events[e])return this;for(var t=Array.prototype.slice.call(arguments,1),a=this._events[e],n=!0,s=0,r=a.length;s<r;s++)n=n&&a[s].callback.apply(this,t);return n},Mt=function(e){return e=e.toLowerCase(),this._events||(this._events={}),this._events[e]},Nt={on:yt,off:Et,one:Ot,trigger:At,triggerReturn:xt,getEvent:Mt},Ut=function e(t){ie(this,e),t=t||{},this.id=t.id,this.strict=t.strict||!1,this.meta=e.createMetaItems(t.meta),this.enable=t.enable||e.DEFAULTS.enable,this.pageSize=ko.observable(t.pageSize||e.DEFAULTS.pageSize),this.pageIndex=ko.observable(t.pageIndex||e.DEFAULTS.pageIndex),this.totalPages=ko.observable(t.totalPages||e.DEFAULTS.totalPages),this.totalRow=ko.observable(),this.pageCache=void 0===t.pageCache?e.DEFAULTS.pageCache:t.pageCache,this.forceDel=void 0===t.forceDel?e.DEFAULTS.forceDel:t.forceDel,this.rows=ko.observableArray([]),this.selectedIndices=ko.observableArray([]),this._oldCurrentIndex=-1,this.focusIndex=ko.observable(-1),this.cachedPages=[],this.metaChange={},this.valueChange={},this.currentRowChange=ko.observable(1),this.enableChange=ko.observable(1),this.params=t.params||{},this.master=t.master||"",this.allSelected=ko.observable(!1),this.dateNoConvert=t.dateNoConvert||!1,t.root?this.root=t.root:this.root=this,t.ns?this.ns=t.ns:this.ns="",this.newCount=0},Pt=Ut.prototype;Object.assign(Pt,o),Object.assign(Pt,d),Object.assign(Pt,p),Object.assign(Pt,m),Object.assign(Pt,j),Object.assign(Pt,H),Object.assign(Pt,Y),Object.assign(Pt,J),Object.assign(Pt,$),Object.assign(Pt,ae),Object.assign(Pt,se),Object.assign(Pt,Ie),Object.assign(Pt,ge),Object.assign(Pt,Ne),Object.assign(Pt,ye),Object.assign(Pt,at),Object.assign(Pt,Je),Object.assign(Pt,st),Object.assign(Pt,Dt),Object.assign(Pt,Ct),Object.assign(Pt,Nt),Object.assign(Pt,He),Object.assign(Pt,mt),Object.assign(Pt,lt),Ut.DEFAULTS={pageSize:20,pageIndex:0,totalPages:0,pageCache:!1,enable:!0,forceDel:!1},Ut.META_DEFAULTS={enable:!0,required:!1,descs:{}},Ut.ON_ROW_SELECT="select",Ut.ON_ROW_UNSELECT="unSelect",Ut.ON_ROW_ALLSELECT="allSelect",Ut.ON_ROW_ALLUNSELECT="allUnselect",Ut.ON_VALUE_CHANGE="valueChange",Ut.ON_BEFORE_VALUE_CHANGE="beforeValueChange",Ut.ON_CURRENT_VALUE_CHANGE="currentValueChange",Ut.ON_INSERT="insert",Ut.ON_UPDATE="update",Ut.ON_CURRENT_UPDATE="currentUpdate",Ut.ON_DELETE="delete",Ut.ON_DELETE_ALL="deleteAll",Ut.ON_ROW_FOCUS="focus",Ut.ON_ROW_UNFOCUS="unFocus",Ut.ON_LOAD="load",Ut.ON_ENABLE_CHANGE="enableChange",Ut.ON_META_CHANGE="metaChange",Ut.ON_ROW_META_CHANGE="rowMetaChange",Ut.ON_CURRENT_META_CHANGE="currentMetaChange",Ut.ON_CURRENT_ROW_CHANGE="currentRowChange",Ut.SUBMIT={current:"current",focus:"focus",all:"all",select:"select",change:"change",empty:"empty",allSelect:"allSelect",allPages:"allPages"},Ut.createMetaItems=function(e){var t={};for(var a in e){var n=e[a];"string"==typeof n&&(n={}),t[a]=s({},Ut.META_DEFAULTS,n)}return t};var Ft=function(e,t,a){var n=this.rows[e];n&&(n.data[t].value=a,n.status!=Row.STATUS.NEW&&n.setStatus(Row.STATUS.UPDATE))},Lt=function(e,t){if(t.data)for(var a in t.data)if(e.data[a]){var n=t.data[a];if("string"==typeof n||"number"==typeof n||null===n)e.data[a].value=n;else if(n.error)u.showMessageDialog?u.showMessageDialog({title:"警告",msg:n.error,backdrop:!0}):alert(n.error);else{e.data[a].value=n.value;for(var s in n.meta)e.data[a].meta=e.data[a].meta||{},e.data[a].meta[s]=n.meta[s]}}},kt={setRowValue:Ft,updateRow:Lt},jt=function(){var e,t=[];this.parent.getMeta();for(var a=0;a<this.rows.length;a++)e=this.rows[a],t.push({id:e.rowId,status:e.status,data:e.data});return t},Vt=function(){for(var e,t=[],a=0;a<this.rows.length;a++)e=this.rows[a],t.push({id:e.rowId,status:e.status,data:e.data});for(var a=0;a<this.selectedIndices.length;a++)e=this.rows[this.selectedIndices[a]],t.push({id:e.rowId,status:e.status,data:e.data});return t},Bt=function(){for(var e=[],t=0;t<this.selectedIndices.length;t++)e.push(this.rows[this.selectedIndices[t]]);return e},Ht=function(){for(var e=[],t=this.rows.peek(),a=0,n=t.length;a<n;a++)t[a]&&t[a].status!=Row.STATUS.NORMAL&&e.push(t[a]);return e},Wt=function(e){for(var t=0,a=this.rows.length;t<a;t++)if(this.rows[t].rowId==e)return this.rows[t];return null},zt=function(e,t){var a=this.rows[e];return a?a.data[t].value:null},Yt={getData:jt,getSelectDatas:Vt,getSelectRows:Bt,getChangedRows:Ht,getRowByRowId:Wt,getRowValue:zt},Gt=function(e,t,a){var n=this.rows[e];if(n){var s=n[t].meta;return s?s[a]:null}return null},Zt={getRowMeta:Gt},Jt=function(e,t,a,n){var s=this.rows[e];if(s){var r=s[t].meta;r||(r=s[t].meta={}),r[a]=n,s.status!=Row.STATUS.NEW&&s.setStatus(Row.STATUS.UPDATE)}},qt={setRowMeta:Jt},$t=function(e){for(var t=0,a=this.rows.length;t<a;t++)this.rows[t].rowId==e&&(this.rows.splice(t,1),a--,this.updateSelectedIndices(t,"-"),this.updateFocusIndex(t,"-"))},Xt=function(e,t,a){Fe(a)||(a=1);var n=this.selectedIndices.slice();if(null!=n&&0!=n.length){for(var s=0,r=n.length;s<r;s++)"+"==t?n[s]>=e&&(n[s]=parseInt(n[s])+a):"-"==t&&(n[s]>=e&&n[s]<=e+a-1?n.splice(s,1):n[s]>e+a-1&&(n[s]=n[s]-a));this.selectedIndices=n}},Qt=function(e,t,a){Fe(a)||(a=1),e<=this.focus&&-1!=this.focus&&("+"===t?this.focus=this.focus+a:"-"===t&&(this.focus>=e&&this.focus<=e+a-1?this.focus=this.focus-1:this.focus>e+a-1&&(this.focus=this.focus-a)))},Kt={removeRowByRowId:$t,updateSelectedIndices:Xt,updateFocusIndex:Qt},ea=function e(t){ie(this,e),this.focus=t.focus||null,this.selectedIndices=t.selectedIndices||null,this.rows=t.rows||[],this.parent=t.parent||null},ta=ea.prototype;Object.assign(ta,kt),Object.assign(ta,Yt),Object.assign(ta,Zt),Object.assign(ta,qt),Object.assign(ta,Kt);var aa=function e(){ie(this,e)},na=aa.prototype;Object.assign(na,Nt);var sa=function(e,t){return!(null!==e&&void 0!==e&&""!==e||null!==t&&void 0!==t&&""!==t)||(e+""==t+""||e===t||!!(Fe(e)&&Fe(t)&&parseFloat(e)-parseFloat(t)<5e-7&&parseFloat(e)-parseFloat(t)>-5e-7))},ra=function(e){
2if(!e)return e;var t=new Date;if(t.setTime(e),isNaN(t))return e;var a=t.getFullYear(),n=t.getMonth()+1;parseInt(n)<10&&(n="0"+n);var s=t.getDate();parseInt(s)<10&&(s="0"+s);var r=t.getHours();parseInt(r)<10&&(r="0"+r);var i=t.getMinutes();parseInt(i)<10&&(i="0"+i);var o=t.getSeconds();parseInt(o)<10&&(o="0"+o);t.getMilliseconds();return a+"-"+n+"-"+s+" "+r+":"+i+":"+o},ia=function(e){if(!e&&0!=e)return"";if("number"==typeof e)return e;e.indexOf("-")>-1&&(e=e.replace(/\-/g,"/"));var t=Date.parse(e);return isNaN(t)?"":t},oa=function(e,t,a,n){if(ha(e,t).changed=!0,e.status!=Row.STATUS.NEW&&e.setStatus(Row.STATUS.UPDATE),e.valueChange[t]&&e.valueChange[t](-e.valueChange[t]()),e.parent.getCurrentRow()==e&&e.parent.valueChange[t]&&e.parent.valueChange[t](-e.parent.valueChange[t]()),e.parent.ns){var s=e.parent.ns+"."+t;e.parent.root.valueChange[s]&&e.parent.root.valueChange[s](-e.parent.root.valueChange[s]())}var r={eventType:"dataTableEvent",dataTable:e.parent.id,rowId:e.rowId,field:t,oldValue:a,newValue:e.getValue(t),ctx:n||"",rowObj:e};e.parent.trigger(DataTable.ON_VALUE_CHANGE,r),e.parent.trigger(t+"."+DataTable.ON_VALUE_CHANGE,r),e==e.parent.getCurrentRow()&&e.parent.trigger(t+"."+DataTable.ON_CURRENT_VALUE_CHANGE,r),e.parent.ns&&(r.fullField=s,r.ns=e.parent.ns,e.parent.root.trigger(DataTable.ON_VALUE_CHANGE,r),e.parent.root.trigger(s+"."+DataTable.ON_VALUE_CHANGE,r))},la=function(e,t){var a=this.parent.getMeta(e,"type");return a&&("date"==a||"datetime"==a)?ra(t):t},ua=function(e,t){var a=e.data[t];if(!a){var n=t.split(".");if(n.length>1){for(var s=e.data,r=0;r<n.length;r++){if(s=s[n[r]],s.value instanceof DataTable){var i=s.value.getCurrentRow();i||(i=s.value.rows()[0]),i&&(s=i.data)}if(!s)break}a=s}}return a||null},ha=function(e,t){var a=ua(e,t);if(!a){var n="field:"+t+" not exist in dataTable:"+e.parent.root.id+"!";throw new Error(n)}return a},ca={formatValue:la,eq:sa,_triggerChange:oa,_getField:ha,_dateToUTCString:ia},ga=function(e,t,a,n){1===arguments.length&&(t=e,e="$data");var s=this.getValue(e);if(void 0!==s&&null!==s||(s=""),!ca.eq(s,t)){var r={eventType:"dataTableEvent",dataTable:this.parent.id,rowId:this.rowId,field:e,oldValue:s,newValue:t,ctx:a||""};if(!this.parent.triggerReturn(DataTable.ON_BEFORE_VALUE_CHANGE,r))return void ca._triggerChange(this,e,s,a);ca._getField(this,e).value=t,ca._triggerChange(this,e,s,a)}},da=function(e,t){for(var a=e.split("."),n=a[0],s=this.data[n],r=0,i=a.length;r<i;r++)if(r==i-1)s.value instanceof u.DataTable||this.setValue(e,t);else if(s&&s.value instanceof u.DataTable){var o=s.value.getCurrentRow();o&&o.setChildValue(e.replace(n+".",""),t)}else n=a[r+1],s=s[n]},fa=function(e,t){var a=e.split(".");if(a.length>1){var n=a[0],s=this.data[n];if(s&&s.value instanceof u.DataTable){var e=a[1],r=null;e&&(r=s.value.getRowByRowId(e)),r&&(2==a.length?r.setSimpleData(t):r.setChildSimpleDataByRowId(fieldName.replace(n+"."+e+".",""),t))}}},wa=function e(t,a,n,s,r,i){for(var o in a)if(!i||i.fieldFlag||t.parent.getMeta(o)){var l=r||null;n[o]=n[o]||{};var h=a[o];if(null==h||"object"!=(void 0===h?"undefined":re(h)))n[o].isChild||(n[o].value=t.formatValue(o,h)),!0===s&&c!==n[o].value&&ca._triggerChange(t,o,c);else if(h.error)u.showMessageDialog?u.showMessageDialog({title:"警告",msg:h.error,backdrop:!0}):alert(h.error);else if(h.value||null===h.value||h.meta||""===h.value||"0"===h.value||0===h.value){var c=n[o].value;n[o].value=t.formatValue(o,h.value),!0===s&&c!==n[o].value&&ca._triggerChange(t,o,c);for(var g in h.meta)t.setMeta(o,g,h.meta[g])}else if(Le(h)){n[o].isChild=!0;var d=null==l?o:l+"."+o,f=""===t.parent.ns?o:t.parent.ns+"."+d;if(t.parent.meta[d]){var w=t.parent.meta[d].meta;n[o].value=new u.DataTable({root:t.parent.root,ns:f,meta:w}),n[o].value.setSimpleData(h)}}else l=null==l?o:l+"."+o,e(t,h,n[o],null,l,i)}},pa=function(e,t,a){var n=e.data,s=this.data;if(1!=this.parent.root.strict)return wa(this,n,s,t,null,a),void this.setStatus(e.status);var r=this.parent.meta;for(var i in r){var o=newValue=null;if(r[i].type&&"child"===r[i].type){s[i].isChild=!0;var l=""===this.parent.ns?i:this.parent.ns+"."+i,r=this.parent.meta[i].meta;s[i].value=new u.DataTable({root:this.parent.root,ns:l,meta:r}),"object"===re(n[i])&&s[i].value.setSimpleData(n[i])}else if(-1!=i.indexOf(".")){for(var h=i.split("."),c=n,g=s,d=0;d<h.length;d++)c=c||{},c=c[h[d]],g=g[h[d]];o=g.value,g.value=this.formatValue(i,c),newValue=g.value}else if(null==n[i]||"object"!=re(n[i]))o=s[i].value,s[i].value=this.formatValue(i,n[i]),newValue=s[i].value;else{var f=n[i];if(f.error)u.showMessageDialog?u.showMessageDialog({title:"警告",msg:f.error,backdrop:!0}):alert(f.error);else if(f.value||null===f.value||f.meta){o=s[i].value,s[i].value=this.formatValue(i,f.value),newValue=s[i].value;for(var w in f.meta)this.setMeta(i,w,f.meta[w])}}!0===t&&o!==newValue&&ca._triggerChange(this,i,o)}},va=function(e){this.setData(e)},Ra=function(e){if(this.status=e,e==Row.STATUS.NORMAL){var t=this.data;for(var a in t){var n=t[a].value;t[a].baseValue=n}}},ma=function(){var e=this.data;for(var t in e){var a=e[t].baseValue;this.setValue(t,a)}},Sa={setValue:ga,setChildValue:da,setChildSimpleDataByRowId:fa,setData:pa,updateRow:va,setStatus:Ra,resetValue:ma},_a=function(e){return ca._getField(this,e).value},Ta=function(e){for(var t=e.split("."),a=t[0],n=0,s=t.length;n<s;n++){var r=this.getValue(a);if(n==s-1)return r instanceof u.DataTable?r.rows.peek():r;if(r instanceof u.DataTable)return r=r.getCurrentRow(),r?r.getChildValue(e.replace(a+".","")):"";a=a+"."+t[n+1]}return""},Ca=function(){var e=ko.toJS(this.data),t=this.parent.getMeta();for(var a in t)if(t[a]&&t[a].type)if("date"==t[a].type||"datetime"==t[a].type)if(a.indexOf(".")>0){for(var n=a.split("."),s=e,r=0,i=n.length;r<i;r++)s=s[n[r]];s.value=ca._dateToUTCString(s.value)}else e[a].value=ca._dateToUTCString(e[a].value);else if("child"==t[a].type){for(var o=this.getValue(a),l=o.rows(),u=[],r=0;r<l.length;r++)u.push(l[r].getData());e[a].value=JSON.stringify(u)}return{id:this.rowId,status:this.status,data:e}},Ia=function(){return{id:this.rowId,status:this.status,data:{}}},ba={getValue:_a,getChildValue:Ta,getData:Ca,getEmptyData:Ia},Da=function(e,t,a){if(0==arguments.length){var n={};for(var s in this.data)n[s]=this.data[s].meta?this.data[s].meta:{};return n}var r=ca._getField(this,e).meta;return r&&void 0!==r[t]&&null!==r[t]&&""!==r[t]?r[t]:void 0===a||0!=a?this.parent.getMeta(e,t):void 0},ya={getMeta:Da},Ea=function e(t,a){var n={},s=t.parent.getMeta()||{};for(var r in a)if("meta"!==r&&!ke(a[r]))if(a[r].isChild)n[r]=a[r].value?a[r].value.getSimpleData():{};else if("$data"===r)n=a[r].value;else if(void 0!==a[r].value){if(s[r]&&"boolean"===s[r].type?n[r]=!!a[r].value:n[r]=a[r].value,s[r]&&s[r].type){var i={meta:s,data:a,key:r};n[r]=t.formatValueFun(i,t.parent.dateNoConvert)}}else a[r].value?n[r]=e(t,a[r]):n[r]=a[r].value;return n},Oa=function(e,t){var a=e.meta,n=e.data,s=e.key;return t||"date"!=a[s].type&&"datetime"!=a[s].type?n[s].value:ca._dateToUTCString(n[s].value)},Aa=function(e){e=e||{};var t=e.fields||null,a=(this.parent.getMeta(),this.data),n=Ea(this,a),s={};if(t){for(var r in n)-1!=t.indexOf(r)&&(s[r]=n[r]);return s}return n},xa={formatValueFun:Oa,getSimpleData:Aa},Ma=function(){var e=this.parent.meta;for(var t in e){var a;if(t.indexOf(".")>0){var n=t.split(".");a=this.data[n[0]]=this.data[n[0]]||{};for(var s=1;s<n.length;s++)a[n[s]]=a[n[s]]||{},a=a[n[s]]}else this.data[t]=this.data[t]||{},a=this.data[t];if(a.value=null,e[t].type&&"child"===e[t].type){a.isChild=!0;var r=""===this.parent.ns?t:this.parent.ns+"."+t;a.value=new u.DataTable({root:this.parent.root,ns:r,meta:e[t].meta})}else if(e[t].default){var i=e[t].default;if("object"===(void 0===i?"undefined":re(i)))for(var o in i)"value"==o?"function"==typeof i[o]?a.value=this.formatValue(t,i[o]()):a.value=this.formatValue(t,i[o]):(a.meta=a.meta||{},a.meta[o]=i[o]);else a.value="function"==typeof i?this.formatValue(t,i()):this.formatValue(t,i)}}},Na={init:Ma},Ua=function(e,t,a){var n=ca._getField(this,e).meta;n||(n=ca._getField(this,e).meta={});var s=n[t];ca.eq(s,a)||(n[t]=a,this.metaChange[e+"."+t]&&this.metaChange[e+"."+t](-this.metaChange[e+"."+t]()),"enable"==t&&this.parent.enableChange(-this.parent.enableChange()),this.parent.getCurrentRow()==this&&(this.parent.metaChange[e+"."+t]&&this.parent.metaChange[e+"."+t](-this.parent.metaChange[e+"."+t]()),this.parent.trigger(e+"."+t+"."+DataTable.ON_CURRENT_META_CHANGE,{eventType:"dataTableEvent",dataTable:this.parent.id,oldValue:s,newValue:a})),this.parent.trigger(DataTable.ON_ROW_META_CHANGE,{eventType:"dataTableEvent",dataTable:this.parent.id,field:e,meta:t,oldValue:s,newValue:a,row:this}),this.parent.trigger(e+"."+t+"."+DataTable.ON_ROW_META_CHANGE,{eventType:"dataTableEvent",dataTable:this.parent.id,field:e,meta:t,oldValue:s,newValue:a,row:this}))},Pa={setMeta:Ua},Fa=function(e,t,a,n,s,r){var i=e+"="+encodeURIComponent(t);a&&(i+="; expires="+a.toGMTString()),n&&(i+="; path="+n),s&&(i+="; domain="+s),r&&(i+="; secure="+r),document.cookie=i},La=function(e){var t="(?:; )?"+e+"=([^;]*);?";return new RegExp(t).test(document.cookie)?decodeURIComponent(RegExp.$1):null},ka={},ja={},Va={},Ba={},Ha={float:{precision:2},datetime:{format:"YYYY-MM-DD HH:mm:ss",metaType:"DateTimeFormatMeta",speratorSymbol:"-"},time:{format:"HH:mm"},date:{format:"YYYY-MM-DD"},currency:{precision:2,curSymbol:"¥"},percent:{},phoneNumber:{}};Ba.getEnvironment=function(){return Ue(ka)},Ba.getClientAttributes=function(){return Ue(ja)},Ba.setContextPath=function(e){return ka[IWEB_CONTEXT_PATH]=e},Ba.getContextPath=function(e){return ka[IWEB_CONTEXT_PATH]},Ba.setClientAttribute=function(e,t){ja[e]=t},Ba.getSessionAttributes=function(){return Ue(Va)},Ba.setSessionAttribute=function(e,t){Va[e]=t,Fa("ISES_"+e,t)},Ba.removeClientAttribute=function(e){ja[e]=null,execIgnoreError(function(){delete ja[e]})},Ba.getLocale=function(){return this.getEnvironment().locale},Ba.getLanguages=function(){return this.getEnvironment().languages},Ba.collectEnvironment=function(){var e=this.getEnvironment(),t=this.getSessionAttributes();for(var a in ja)t[a]=ja[a];return e.clientAttributes=t,e},Ba.setMaskerMeta=function(e,t){if("function"==typeof e)getMetaFunc=e;else if(Ha[e])if("object"!=typeof t)Ha[e]=t;else for(var a in t)Ha[e][a]=t[a];else Ha[e]=t},Ba.getMaskerMeta=function(e){if("function"==typeof getMetaFunc){return getMetaFunc.call(this)[e]}return s({},Ha[e])},ka.languages=La("i_languages")?La("i_languages").split(","):navigator.language?navigator.language:"zh-CN","zh-cn"==ka.languages&&(ka.languages="zh-CN"),"en-us"==ka.languages&&(ka.languages="en-US"),ka.theme=La("u_theme"),ka.locale=La("u_locale"),ka.usercode=La("usercode"),document.cookie.replace(/ISES_(\w*)=([^;]*);?/gi,function(e,t,a){Va[t]=a});var Wa=function(){};Wa.prototype=Ba;var za=new Wa;if(window.getCurrentJsPath=function(){var e=document,t={},a=+new Date,n=/((?:http|https|file):\/\/.*?\/[^:]+)(?::\d+)?:\d+/,s=-1===(""+e.querySelector).indexOf("[native code]");if(e.currentScript)return e.currentScript.src;var r;try{t.b()}catch(e){r=e.stack||e.fileName||e.sourceURL||e.stacktrace}if(r){var i=n.exec(r)[1];if(i)return i}for(var o,l=e.scripts,u=l.length-1;o=l[u--];)if(o.className!==a&&"interactive"===o.readyState)return o.className=a,s?o.getAttribute("src",4):o.src},window.i18n){window.u=window.u||{};var Ya=getCurrentJsPath(),Ga=Ya.substr(0,Ya.lastIndexOf("/")),Za=Ga.substr(0,Ga.lastIndexOf("/")),Ja=u.i18nPath||Za+"/locales/__lng__/__ns__.json";i18n.init({postAsync:!1,getAsync:!1,fallbackLng:!1,ns:{namespaces:["uui-trans"]},lng:La("u_locale")||"zh",resGetPath:Ja})}var qa=function(e,t){return window.i18n?i18n.t("uui-trans:"+e):t},$a={};$a.date={_dateLocale:{"zh-CN":{months:"一月_二月_三月_四月_五月_六月_七月_八月_九月_十月_十一月_十二月".split("_"),monthsShort:"1月_2月_3月_4月_5月_6月_7月_8月_9月_10月_11月_12月".split("_"),weekdays:"星期日_星期一_星期二_星期三_星期四_星期五_星期六".split("_"),weekdaysShort:"周日_周一_周二_周三_周四_周五_周六".split("_"),weekdaysMin:"日_一_二_三_四_五_六".split("_")},"en-US":{months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),monthsShort:"Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec".split("_"),weekdays:"Sunday_Monday_Tuesday_Wednesday_Thurday_Friday_Saturday".split("_"),weekdaysShort:"Sun_Mon_Tue_Wed_Thu_Fri_Sat".split("_"),weekdaysMin:"S_M_T_W_T_F_S".split("_")}},_jsonLocale:{months:qa("date.months","一月\n二月\n三月\n四月\n五月\n六月\n七月\n八月\n九月\n十月\n十一月\n十二月").split("\n"),monthsShort:qa("date.monthsShort","1月\n2月\n3月\n4月\n5月\n6月\n7月\n8月\n9月\n10月\n11月\n12月").split("\n"),weekdays:qa("date.weekdays","星期日\n星期一\n星期二\n星期三\n星期四\n星期五\n星期六").split("\n"),weekdaysShort:qa("date.weekdaysShort","周日\n周一\n周二\n周三\n周四\n周五\n周六").split("\n"),weekdaysMin:qa("date.weekdaysMin","日\n一\n二\n三\n四\n五\n六").split("\n"),defaultMonth:["1月","2月","3月","4月","5月","6月","7月","8月","9月","10月","11月","12月"]},_formattingTokens:/(\[[^\[]*\])|(\\)?(Mo|MM?M?M?|Do|DDDo|DD?D?D?|ddd?d?|do?|w[o|w]?|W[o|W]?|Q|YYYY|YY|e|E|a|A|hh?|HH?|mm?|ss?|S{1,4}|x|X|zz?|ZZ?|.)/g,leftZeroFill:function(e,t,a){for(var n=""+Math.abs(e),s=e>=0;n.length<t;)n="0"+n;return(s?a?"+":"":"-")+n},_formats:{YY:function(e){return $a.date.leftZeroFill(e.getFullYear()%100,2)},YYYY:function(e){return e.getFullYear()},M:function(e){return e.getMonth()+1},MM:function(e){var t=$a.date._formats.M(e);return $a.date.leftZeroFill(t,2)},MMM:function(e,t){var a=e.getMonth();return $a.date._jsonLocale.monthsShort[a]},MMMM:function(e,t){var a=e.getMonth();return $a.date._jsonLocale.months[a]},D:function(e){return e.getDate()},DD:function(e){var t=$a.date._formats.D(e);return $a.date.leftZeroFill(t,2)},d:function(e){return e.getDay()},dd:function(e,t){var a=$a.date._formats.d(e);return $a.date._jsonLocale.weekdaysMin[a]},ddd:function(e,t){var a=$a.date._formats.d(e);return $a.date._jsonLocale.weekdaysShort[a]},dddd:function(e,t){var a=$a.date._formats.d(e);return $a.date._jsonLocale.weekdays[a]},a:function(e){return e.getHours()>12?"pm":"am"},h:function(e){var t=e.getHours();return t=t>12?t-12:t},hh:function(e){var t=$a.date._formats.h(e);return $a.date.leftZeroFill(t,2)},H:function(e){return e.getHours()},HH:function(e){return $a.date.leftZeroFill(e.getHours(),2)},m:function(e){return e.getMinutes()},mm:function(e){return $a.date.leftZeroFill(e.getMinutes(),2)},s:function(e){return e.getSeconds()},ss:function(e){return $a.date.leftZeroFill(e.getSeconds(),2)}},format:function(e,t,a){if(!e&&0!=e)return"";var n,s,r=t.match($a.date._formattingTokens),i="",o=$a.date.getDateObj(e);if(!o)return e;for(a=a||za.getLanguages(),n=0,s=r.length;n<s;n++)$a.date._formats[r[n]]?i+=$a.date._formats[r[n]](o,a):i+=r[n];return i},strToDateByTimezone:function(e,t){var a=$a.date.getDateObj(e),n=a.getTime(),s=6e4*a.getTimezoneOffset(),r=n+s;return r+=36e5*parseFloat(t)},getDateByTimeZonec2z:function(e,t){var a=$a.date.getDateObj(e),n=a.getTime(),s=6e4*a.getTimezoneOffset(),r=n+s,i=r+36e5*parseFloat(t);return new Date(i)},getDateByTimeZonez2c:function(e,t){var a=$a.date.getDateObj(e),n=a.getTime(),s=6e4*a.getTimezoneOffset(),r=n-36e5*parseFloat(t)-s;return new Date(r)},_addOrSubtract:function(e,t,a,n){var s=e.getTime(),r=e.getDate(),i=e.getMonth(),o=$a.date.getDateObj(e);return"ms"===t?(s+=a*n,o.setTime(s)):"s"==t?(s+=1e3*a*n,o.setTime(s)):"m"==t?(s+=6e4*a*n,o.setTime(s)):"h"==t?(s+=36e5*a*n,o.setTime(s)):"d"==t?(r+=a*n,o.setDate(r)):"w"==t?(r+=7*a*n,o.setDate(r)):"M"==t?(i+=a*n,o.setMonth(i)):"y"==t&&(i+=12*a*n,o.setMonth(i)),o},add:function(e,t,a){return $a.date._addOrSubtract(e,t,a,1)},sub:function(e,t,a){return $a.date._addOrSubtract(e,t,a,-1)},getDateObj:function(e,t){var a;if(t&&(a=t.timezone),!e&&0!=e||void 0===e)return e;var n=!1,s=new Date(je(e));if(isNaN(s)){var r,i,o,l,u,h,c;e.indexOf&&(r=e.indexOf("-"),i=e.indexOf(":"),o=e.indexOf(" "),r>0||i>0||o>0?(s=new Date,o>0?(h=e.split(" "),l=h[0].split("-"),u=h[1].split(":"),c=h[2]):r>0?l=e.split("-"):i>0&&(u=e.split(":")),l&&l.length>0&&(s.setYear(l[0]),s.setMonth(parseInt(l[1]-1)),s.setDate(l[2]?l[2]:0),s.setMonth(parseInt(l[1]-1)),s.setDate(l[2]?l[2]:0),n=!0),u&&u.length>0&&("pm"==c&&(u[0]=u[0]- -12),s.setHours(u[0]?u[0]:0),s.setMinutes(u[1]?u[1]:0),s.setSeconds(u[2]?u[2]:0),n=!0)):(s=new Date(parseInt(e)),isNaN(s)||(n=!0)))}else n=!0;return n?(a&&(s=$a.date.getDateByTimeZonec2z(s,a)),s):null}};var Xa=$a.date,Qa=function(e){return this.parent.createField(e),this.valueChange[e]||(this.valueChange[e]=ko.observable(1)),ko.pureComputed({read:function(){return this.valueChange[e](),this.currentRowChange(),this.getChildValue(e)},write:function(t){this.setChildValue(e,t)},owner:this})},Ka=function(e,t){return this.metaChange[e+"."+t]||(this.metaChange[e+"."+t]=ko.observable(1)),ko.pureComputed({read:function(){return this.metaChange[e+"."+t](),this.getMeta(e,t)},write:function(a){this.setMeta(e,t,a)},owner:this})},en=function(e,t){return this.valueChange[e]||(this.valueChange[e]=ko.observable(1)),ko.pureComputed({read:function(){this.valueChange[e](),this.currentRowChange();var a=Pe(this.parent.parent,t);if(void 0===ca._getField(this,e).value||""===ca._getField(this,e).value)return"";for(var n=ca._getField(this,e).value,s="string"==typeof n?n.split(","):[n],r=[],i=0,o=a.length;i<o;i++)for(var l=0;l<s.length;l++){var u=a[i].pk||a[i].value||"";u==s[l]&&r.push(a[i].name)}return r.toString()},write:function(t){this.setValue(e,t)},owner:this})},tn=function(e,t){return this.valueChange[e]||(this.valueChange[e]=ko.observable(1)),ko.pureComputed({read:function(){if(this.valueChange[e](),this.currentRowChange(),!ca._getField(this,e).value)return"";var a=ca._getField(this,e).value;return a?a=Xa.format(a,t):""},write:function(t){this.setValue(e,t)},owner:this})},an=function(e){return this.parent.createField(e),this.valueChange[e]||(this.valueChange[e]=ko.observable(1)),ko.pureComputed({read:function(){if(this.valueChange[e](),this.currentRowChange(),!ca._getField(this,e).value)return"";var t=ca._getField(this,e).value;return t?("N"==t?t="否":"Y"==t&&(t="是"),t):""},write:function(t){this.setValue(e,t)},owner:this})},nn={ref:Qa,refMeta:Ka,refCombo:en,refDate:tn,refEnum:an},sn=function(e){var t=this.parent.getRowIndex(this);-1!=this.parent.getSelectedIndices().indexOf(t)?this.parent.setRowUnSelect(t):"single"===e?this.parent.setRowSelect(t):this.parent.addRowSelect(t)},rn=function(){this.toggleSelect("single")},on=function(){this.toggleSelect("multi")},ln={toggleSelect:sn,singleSelect:rn,multiSelect:on},un=function(e,t){var a={};a.data=e,a.status=t||"nrm",this.setData(a,!0),this.currentRowChange(-this.currentRowChange())},hn={setSimpleData:un},cn=function(e){function t(e){ie(this,t);var a=le(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return a.rowId=e.id||t.getRandomRowId(),a.status=t.STATUS.NEW,a.parent=e.parent,a.data={},a.metaChange={},a.valueChange={},a.currentRowChange=ko.observable(1),a.selected=ko.pureComputed({read:function(){var e=this.parent.getRowIndex(this);return-1!=this.parent.getSelectedIndices().indexOf(e)},owner:a}),a.focused=ko.pureComputed({read:function(){var e=this.parent.getRowIndex(this);return this.parent.getFocusIndex()==e},owner:a}),a.init(),a}return oe(t,e),t}(aa),gn=cn.prototype;Object.assign(gn,Sa),Object.assign(gn,ba),Object.assign(gn,ya),Object.assign(gn,xa),Object.assign(gn,Na),Object.assign(gn,Pa),Object.assign(gn,nn),Object.assign(gn,ln),Object.assign(gn,hn),Object.assign(gn,ca),cn.STATUS={NORMAL:"nrm",UPDATE:"upd",NEW:"new",DELETE:"del",FALSE_DELETE:"fdel"},cn.getRandomRowId=function(){return setTimeout(function(){})+""},window.DataTable=Ut,window.Page=ea,window.Row=cn,window.u=window.u||{},u=window.u,u.DataTable=Ut,u.Row=cn,e.u=u,e.DataTable=Ut}(this.bar=this.bar||{});