kero
Version:
<img src="http://tinper.org/assets/images/kero.png" width="120" style="max-width:100%;"/>
2 lines • 52.8 kB
JavaScript
!function(e){"use strict";var t=!0,a={toString:1};for(var s in a)t=null;t&&(t=["hasOwnProperty","valueOf","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","constructor"]);var n=function(e,a){var s,n=arguments;if(n.length>1)for(var r=1;r<n.length;r++)if(s=n[r],e&&s&&"object"==typeof s){var i,o,l;for(i in s)e[i]=s[i];if(t)for(o=t.length;o--;)l=t[o],s.hasOwnProperty&&s.hasOwnProperty(l)&&(e[l]=s[l])}return e};Object.assign||(Object.assign=n);var r=function(e,t){this.copyRows(e,[t])},i=function(e,t){for(var a=0;a<t.length;a++){var s=new Row({parent:this});t[a]&&s.setData(t[a].getData()),this.insertRows(void 0===e?this.rows().length:e,[s])}},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 s=e.pageSize;else var s=this.pageSize();if(e.totalPages||0===e.totalPages)var n=e.totalPages;else var n=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(s),this.pageCache=e.pageCache||this.pageCache,!0===this.pageCache){if(this.updatePages(e.pages),a!=this.pageIndex())return this.setCurrentPage(a,!0),this.totalPages(n),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(n),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,s,n){1===arguments.length&&(t=e,e="$data"),(a=a||this.getCurrentRow())&&a.setValue(e,t,s,void 0,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={},s=null;if(a.meta=this.meta,a.params=this.params,e=e||DataTable.SUBMIT.current,this.pageCache){var n=this.getPages();if(e==DataTable.SUBMIT.current||e==DataTable.SUBMIT.focus){s=[];var r=this.pageIndex(),i=n[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)}s.push(l)}}else if(e==DataTable.SUBMIT.all||e==DataTable.SUBMIT.allPages){s=[];for(var u=0;u<n.length;u++){var i=n[u],l=_(i,u);l.rows=[];for(var u=0;u<i.rows.length;u++)l.rows.push(i.rows[u].getData());s.push(l)}}else if(e==DataTable.SUBMIT.select){s=[];var r=this.pageIndex(),i=n[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)}s.push(l)}}else if(e==DataTable.SUBMIT.allSelect){s=[];for(var u=0;u<n.length;u++){var i=n[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)}s.push(l)}}else if(e==DataTable.SUBMIT.change){s=[];for(var u=0;u<n.length;u++){var i=n[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)}s.push(l)}}else e===DataTable.SUBMIT.empty&&(s=[]);(n.length<1||!n[this.pageIndex()])&&(s=[{index:this.pageIndex(),select:[],focus:-1,rows:[]}]),a.pages=s}else{if(e==DataTable.SUBMIT.current){s=[];var o=this.focusIndex();-1==o&&(o=this.getSelectedIndex()),t=this.rows();for(var u=0,h=t.length;u<h;u++)u==o?s.push(t[u].getData()):s.push(t[u].getEmptyData())}else if(e==DataTable.SUBMIT.focus){s=[],t=this.rows();for(var u=0,h=t.length;u<h;u++)u==this.focusIndex()?s.push(t[u].getData()):s.push(t[u].getEmptyData())}else e==DataTable.SUBMIT.all?s=this.getData():e==DataTable.SUBMIT.select?s=this.getSelectedDatas(!0):e==DataTable.SUBMIT.change?s=this.getChangedDatas():e===DataTable.SUBMIT.empty&&(s=[]);a.rows=s,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,s=null;if(parseInt(a)>-1)if((a+"").indexOf(".")>0){for(var n=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(n[l])}s=o}else s=this.getRow(a);return s},b=function(e){for(var t=this.rows.peek(),a=0,s=t.length;a<s;a++)if(t[a].rowId==e)return t[a];return null},D=function(e){for(var t=this.rows.peek(),a=0,s=t.length;a<s;a++)if(t[a].rowId===e.rowId)return a;return-1},y=function(e,t){for(var a=this.rows.peek(),s=new Array,n=0,r=a.length;n<r;n++)a[n].getValue(e)===t&&s.push(a[n]);return s},E=function(e){var t=this.rows.peek(),a=new Array;if(e&&e.length>0)for(var s=0,n=t.length;s<n;s++){for(var r=0,i=e.length,o=0;o<i;o++)t[s].getValue(e[o].field)===e[o].value&&r++;r==i&&a.push(t[s])}return a},A=function(e,t){for(var a=this.rows.peek(),s=0,n=a.length;s<n;s++)if(a[s].getValue(e)===t)return a[s];return null},O=function(){return this.rows.peek()},x=function(){for(var e,t=[],a=0;a<this.totalPages();a++){if(e=[],a==this.pageIndex())e=this.getData();else{var s=this.cachedPages[a];s&&(e=s.getData())}for(var n=0;n<e.length;n++)t.push(e[n])}return t},M=function(e){for(var t=[],a=this.rows(),s=0,n=a.length;s<n;s++)a[s]&&a[s].status!=Row.STATUS.NORMAL?t.push(a[s].getData()):1==e&&t.push(a[s].getEmptyData());return t},N=function(){for(var e=[],t=this.rows.peek(),a=0,s=t.length;a<s;a++)t[a]&&t[a].status!=Row.STATUS.NORMAL&&e.push(t[a]);return e},U=function(){for(var e=[],t=this.rows.peek(),a=0,s=t.length;a<s;a++)t[a]&&t[a].status==Row.STATUS.FALSE_DELETE&&e.push(t[a]);return e},P=function(e,t){return t=t||this.getCurrentRow(),t?t.getValue(e):""},F=function(e){for(var t=this.rows(),a=0,s=t.length;a<s;a++)if(t[a].rowId==e)return a;return-1},L=function(){for(var e=this.getAllRows(),t=[],a=0,s=e.length;a<s;a++)e[a]&&t.push(e[a].getData());return t},k=function(e){for(var t=[],a=0;a<e.length;a++)this.getRow(e[a])&&t.push(this.getRow(e[a]).rowId);return t},j=function(e){for(var t=[],a=0;a<e.length;a++)t.push(this.getRow(e[a]));return t},V={getData:S,getDataByRule:T,getRow:C,getChildRow:I,getRowByRowId:b,getRowIndex:D,getRowsByField:y,getRowByField:A,getAllRows:O,getAllPageRows:x,getChangedDatas:M,getChangedRows:N,getDeleteRows:U,getValue:P,getIndexByRowId:F,getAllDatas:L,getRowIdsByIndices:k,getRowsByIndices:j,getRowsByFields:E},B=function(){return-1!=this.focusIndex()?this.getRow(this.focusIndex()):null},H=function(){return this.focusIndex()},W={getFocusRow:B,getFocusIndex:H},z=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},Y=function(e,t){var a=this.getCurrentRow();return a?a.getMeta(e,t):this.getMeta(e,t)},G={getMeta:z,getRowMeta:Y},Z=function(e){return this.pageCache?this.cachedPages[e]:-1},J=function(){return this.pageCache?this.cachedPages:[]},q={getPage:Z,getPages:J},X=function(e){return this.params[e]},Q={getParam:X},K=function(){var e=this.selectedIndices();return null==e||0==e.length?-1:e[0]},ee=function(){var e=this.selectedIndices();return null==e||0==e.length?[]:e},te=function(){return this.getSelectedIndices()},ae=function(e){for(var t=this.selectedIndices(),a=[],s=[],n=0,r=t.length;n<r;n++)s.push(t[n]);for(var i=this.rows(),n=0,r=i.length;n<r;n++)-1!=s.indexOf(n)?a.push(i[n].getData()):1==e&&a.push(i[n].getEmptyData());return a},se=function(){for(var e=this.selectedIndices(),t=[],a=this.rows.peek(),s=[],n=0,r=e.length;n<r;n++)s.push(e[n]);for(var n=0,r=a.length;n<r;n++)-1!=s.indexOf(n)&&t.push(a[n]);return t},ne=function(){var e=[];if(this.pageCache)for(var t=this.getPages(),a=0;a<t.length;a++){var s=t[a];s&&(e=e.concat(s.getSelectRows()))}return e},re={getSelectedIndex:K,getSelectedIndices:ee,getSelectedIndexs:te,getSelectedDatas:ae,getSelectedRows:se,getAllPageSelectedRows:ne},ie=function(e){e=e||{};var t,a=[],s=e.type||"all",n=e.fields||null;if("current"===s){var r=this.getCurrentRow();t=null==r?[]:[r]}else if("focus"===s){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];u&&("all"===s?t=t.concat(u.rows):"select"===s?t=t.concat(u.getSelectRows()):"change"===s&&(t=t.concat(u.getChangedRows())))}}else"all"===s?t=this.rows.peek():"select"===s?t=this.getSelectedRows():"change"===s&&(t=this.getChangedRows());for(var l=0;l<t.length;l++)a.push(t[l].getSimpleData({fields:n}));return 0==a.length&&(a=this.setSimpleDataReal),a},oe={getSimpleData:ie},le="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},ue=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},he=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)},ce=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},ge=function(e,t,a){if(this.meta[e]){var s=this.meta[e][t],n=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:s,newValue:a}),n&&!n.getMeta(e,t,!1)&&this.trigger(e+"."+t+"."+DataTable.ON_CURRENT_META_CHANGE,{eventType:"dataTableEvent",dataTable:this.id,oldValue:s,newValue:a})}},de=function(e){if(e)for(var t in e)for(var a in e[t]){var s=this.meta[t][a],n=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:s,newValue:n})}},fe=function(e,t){if(1!=this.root.strict){if(-1!=e.indexOf("."))for(var a=e.split("."),s=a[0],n=0,r=a.length;n<r;n++){if(this.meta[s]&&"child"===this.meta[s].type)return;n+1<r&&(s=s+"."+a[n+1])}if(this.meta[e]||(this.meta[e]={}),"object"===(void 0===t?"undefined":le(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,n=0;n<o.length;n++)l[o[n]]=l[o[n]]||{},l[o[n]].type=l[o[n]].type||"child",l[o[n]].meta=l[o[n]].meta||{},l=l[o[n]].meta;if(l[e]||(l[e]={}),"object"===(void 0===t?"undefined":le(t)))for(var i in t)l[e][i]||(l[e][i]=t[i])}}},we={setMeta:ge,updateMeta:de,createField:fe},pe=function(e,t){var a=this.totalRow();e!=this.pageIndex()&&1!=t&&this.cacheCurrentPage(),this.pageIndex(e);var s=this.cachedPages[this.pageIndex()];if(s){var n=s.selectedIndices;this.removeAllRows(),this.setRows(s.rows),this.setRowsSelect(n)}this.totalRow(a)},ve=function(e){var t,a,s,t,n,r,i,o,l,u,s;this.pageSize();for(r=0;r<e.length;r++)if(n=e[r].index,i=e[r].rows,o=e[r].current,l=e[r].select,"del"!==e[r].status)if(this.cachedPages[n]){t=this.cachedPages[n],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 s=t.getRowByRowId(a.id);if(s){var h=this.totalRow(),c=h-1;this.totalRow(c),s.status==Row.STATUS.NEW&&(this.newCount-=1,this.newCount<0&&(this.newCount=0))}this.removeRowByRowId(a.id),t.removeRowByRowId(a.id)}else if(s=t.getRowByRowId(a.id))t.updateRow(s,a),s.status==Row.STATUS.NEW&&a.status!=Row.STATUS.NEW&&(this.newCount-=1,this.newCount<0&&(this.newCount=0)),s.setStatus(Row.STATUS.NORMAL),a.status==Row.STATUS.NEW&&s.setStatus(Row.STATUS.NEW);else{a.rowId=a.id,delete a.id,t.rows.push(a),a.status!=Row.STATUS.NEW?s.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[n]=t,t.selectedIndices=l,t.focus=o}else this.cachedPages[n]=null},Re=function(e){var t,a=this.pageSize(),s=0;this.cachedPages=[];for(var n=0;n<e.length;n++)s=Math.floor(n/a),this.cachedPages[s]||(t=new Page({parent:this}),this.cachedPages[s]=t),t.rows.push(e[n]);this.pageIndex()>-1&&this.setCurrentPage(this.pageIndex()),this.totalRow(e.length),this.totalPages(s+1)},me=function(e){return!(!this.pageCache||!this.cachedPages[e])},Se=function(){this.cachedPages=[]},_e=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 s=t[a].getData();s.rowId=s.id,delete s.id,e.rows.push(s)}this.cachedPages[this.pageIndex()]=e}},Te=function(){for(var e=this.getSelectedRows(),t=this.getPages(),a=0;a<t.length;a++){for(var s=t[a].rows,n=[],r=0;r<e.length;r++)for(var i=e[r],o=0;o<s.length;o++){var l=s[o];if(i==l){n.push(o);break}}t[a].selectedIndices=n}},Ce=function(){if(this.pageCache){var e=this.pageIndex(),t=this.getPages()[e];t&&(t.rows=this.rows())}},Ie=function(){if(this.pageCache){var e=this.pageIndex(),t=this.getPages()[e];if(t){var a=this.selectedIndices().slice();t.selectedIndices=a}}},be=function(){if(this.pageCache){var e=this.pageIndex(),t=this.getPages()[e];t&&(t.focus=this.getFocusIndex())}},De=function(){this.updatePageRows(),this.updatePageSelect(),this.updatePageFocus()},ye={setCurrentPage:pe,updatePages:ve,setPages:Re,hasPage:me,clearCache:Se,cacheCurrentPage:_e,updatePagesSelect:Te,updatePageRows:Ce,updatePageSelect:Ie,updatePageFocus:be,updatePageAll:De},Ee=function(e,t){this.params[e]=t},Ae=function(e){for(var t in e)this.params[t]=e[t]},Oe={addParam:Ee,addParams:Ae},xe=function(){return ko.pureComputed({read:function(){for(var e=this.selectedIndices()||[],t=this.rows(),a=[],s=0;s<e.length;s++)a.push(t[s]);return a},owner:this})},Me=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})},Ne=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})},Ue=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})},Pe=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})},Fe={refSelectedRows:xe,ref:Me,refMeta:Ne,refRowMeta:Ue,refEnable:Pe},Le=function(e){var t=function(){};return t.prototype=e,new t},ke=function(e,t){if(t){if("object"==typeof t)return t;for(var a=t.split("."),s=e,n=0;n<a.length;n++)if(!(s=s[a[n]]))return null;return s}},je=function(e){return e-parseFloat(e)+1>=0},Ve=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)},Be=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 He=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},We=function(){for(var e=this.getAllRows(),t=0;t<e.length;t++)if(e[t].status!=Row.STATUS.NORMAL)return!0;return!1},ze=function(e,t){if("string"==typeof t||"number"==typeof t)t=[t];else if(t instanceof Row)t=[e.getIndexByRowId(t.rowId)];else if(Ve(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},Ye={isChanged:We,_formatToIndicesArray:ze},Ge=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])},Je=function(){this.rows([]),this.selectedIndices([]),this.focusIndex(-1),this.trigger(DataTable.ON_DELETE_ALL),this.updateCurrIndex()},qe=function(e,t){this.setRowsDelete(e,t)},$e=function(){this.removeAllRows(),this.cachedPages=[],this.totalPages(1),this.pageIndex(0),this.focusIndex(-1),this.selectedIndices([])},Xe={removeRowByRowId:Ge,removeRow:Ze,removeAllRows:Je,removeRows:qe,clear:$e},Qe=function(e,t){for(var a,s=[],n=0;n<e.length;n++){var r=e[n];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),Be(r.data)||(this.trigger(DataTable.ON_UPDATE,{index:n,rows:[i]}),i==this.getCurrentRow()?(this.currentRowChange(-this.currentRowChange()),i.currentRowChange(-i.currentRowChange()),this.trigger(DataTable.ON_CURRENT_UPDATE,{index:n,rows:[i]})):i.currentRowChange(-i.currentRowChange()))):(i=new Row({parent:this,id:a}),i.setData(e[n],null,t),s.push(i)),r.status&&i.setStatus(r.status)}}return s.length>0&&this.addRows(s),s},Ke=function(e){this.insertRow(this.rows().length,e),this.resetDelRowEnd()},et=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))}},tt=function(e){this.insertRows(this.rows().length,e),this.resetDelRowEnd()},at=function(e,t){t||(t=new Row({parent:this})),this.insertRows(e,[t])},st=function(e,t){for(var a=[e,0],s=0;s<t.length;s++)a.push(t[s]);this.rows.splice.apply(this.rows,a),this.updateSelectedIndices(e,"+",t.length),this.updateFocusIndex(e,"+",t.length),this.updatePageAll();var n=[];$.each(t,function(e){this.status!=Row.STATUS.NORMAL&&this.status!=Row.STATUS.UPDATE&&this.status!=Row.STATUS.NEW||n.push(this)}),this.trigger(DataTable.ON_INSERT,{index:e,rows:n}),this.ns&&this.root.valueChange[this.ns]&&this.root.valueChange[this.ns](-this.root.valueChange[this.ns]())},nt=function(e){var t=new Row({parent:this});return this.addRow(t),!!e&&e.unSelect||this.getCurrentRow()||this.setRowSelect(t),t},rt={setRows:Qe,addRow:Ke,addRows:tt,insertRow:at,insertRows:st,createEmptyRow:nt,resetDelRowEnd:et},it=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]()))},ot={updateCurrIndex:it},lt=function(e){e instanceof Row&&(e=this.getIndexByRowId(e.rowId)),this.setRowsDelete([e])},ut=function(){for(var e=new Array(this.rows().length),t=0;t<e.length;t++)e[t]=t;this.setRowsDelete(e)},ht=function(e,t){var a=!!t&&t.forceDel;e=Ye._formatToIndicesArray(this,e),e=e.sort(function(e,t){return t-e});for(var s=this.getRowIdsByIndices(e),n=this.getRowsByIndices(e),r=this.rows(),i=0;i<e.length;i++){var o=this.getRow(e[i]);if(o.status==Row.STATUS.NEW||this.forceDel||a)r.splice(e[i],1);else{o.setStatus(Row.STATUS.FALSE_DELETE);var l=r.splice(e[i],1);r.push(l[0])}this.updateSelectedIndices(e[i],"-"),this.updateFocusIndex(e[i],"-")}this.rows(r),this.updateCurrIndex(),this.trigger(DataTable.ON_DELETE,{falseDelete:!0,indices:e,rowIds:s,rows:n})},ct={setRowDelete:lt,setAllRowsDelete:ut,setRowsDelete:ht},gt=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,{})},dt=function(e){e instanceof Row&&(e=this.getIndexByRowId(e.rowId)),this.setRowsSelect([e]),this.setRowFocus(this.getSelectedIndex())},ft=function(e){if(-1==(e=e||-1))return void this.setAllRowsUnSelect({quiet:!0});e=Ye._formatToIndicesArray(this,e);var t=this.selectedIndices();if(!Ve(e)||!Ve(t)||e.join()!=t.join()){if(Ve(e))for(var a=this.rows().length,s=0;s<e.length;s++)(e[s]<0||e[s]>=a)&&e.splice(s,1);this.setAllRowsUnSelect({quiet:!0});try{this.selectedIndices(e)}catch(e){}this.updatePageSelect();var n=this.getRowIdsByIndices(e);this.currentRowChange(-this.currentRowChange()),this.trigger(DataTable.ON_ROW_SELECT,{indices:e,rowIds:n}),this.updateCurrIndex(),this.setRowFocus(e[0])}},wt=function(e){e instanceof Row&&(e=this.getIndexByRowId(e.rowId)),this.addRowsSelect([e])},pt=function(e){e=Ye._formatToIndicesArray(this,e);for(var t=this.selectedIndices().slice(),a=!1,s=0;s<e.length;s++){for(var n=e[s],r=!0,i=0;i<t.length;i++)t[i]==n&&(r=!1);r&&e[s]>-1&&(a=!0,t.push(e[s]))}this.selectedIndices(t),this.updatePageSelect();var o=this.getRowIdsByIndices(t);a&&this.trigger(DataTable.ON_ROW_SELECT,{indices:t,rowIds:o}),this.updateCurrIndex()},vt=function(e){this.selectedIndices([]),this.updatePageSelect(),e&&e.quiet||this.trigger(DataTable.ON_ROW_ALLUNSELECT),this.updateCurrIndex(),this.allSelected(!1)},Rt=function(e){e instanceof Row&&(e=this.getIndexByRowId(e.rowId)),this.setRowsUnSelect([e])},mt=function(e){e=Ye._formatToIndicesArray(this,e);var t=this.selectedIndices().slice();if(-1!=t.indexOf(e[0])){for(var a=0;a<e.length;a++){var s=e[a],n=t.indexOf(s);-1!=n&&t.splice(n,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)}},St=function(){this.allSelected()?this.setAllRowsUnSelect():this.setAllRowsSelect()},_t=function(e,t,a){je(a)||(a=1);var s=this.selectedIndices().slice();if(null!=s&&0!=s.length){for(var n=0,r=s.length;n<r;n++)"+"==t?s[n]>=e&&(s[n]=parseInt(s[n])+a):"-"==t&&(s[n]>=e&&s[n]<=e+a-1?s.splice(n,1):s[n]>e+a-1&&(s[n]=s[n]-a));this.selectedIndices(s),this.updatePageSelect()}},Tt={setAllRowsSelect:gt,setRowSelect:dt,setRowsSelect:ft,addRowSelect:wt,addRowsSelect:pt,setAllRowsUnSelect:vt,setRowUnSelect:Rt,setRowsUnSelect:mt,toggleAllSelect:St,updateSelectedIndices:_t},Ct=function(e,t,a){var s=null;e instanceof Row&&(e=this.getIndexByRowId(e.rowId),s=e.rowId),-1===e||e===this.focusIndex()&&!a||(this.focusIndex()>-1&&this.setRowUnFocus(this.focusIndex()),this.focusIndex(e),t||(this.currentRowChange(-this.currentRowChange()),s||(s=this.getRow(e).rowId),this.trigger(DataTable.ON_ROW_FOCUS,{index:e,rowId:s}),this.updateCurrIndex()))},It=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()},bt=function(e,t,a){je(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)))},Dt={setRowFocus:Ct,setRowUnFocus:It,updateFocusIndex:bt},yt=function(e,t){if(this.removeAllRows(),this.cachedPages=[],this.focusIndex(-1),this.selectedIndices([]),this.setSimpleDataReal=[],!e)return void(this.setSimpleDataReal=e);var a=[];Ve(e)||(e=[e]);for(var s=0;s<e.length;s++){var n=e[s];"object"!==le(e[s])&&(n={$data:e[s]}),t&&t.status?a.push({status:t.status,data:n}):a.push({status:Row.STATUS.NORMAL,data:n})}var n={rows:a};t&&void 0===t.fieldFlag&&(t.fieldFlag=!0),this.setData(n,t)},Et=function(e,t,a){if(!e)throw new Error("dataTable.addSimpleData param can't be null!");Ve(e)||(e=[e]);for(var s=0;s<e.length;s++){this.createEmptyRow(a).setSimpleData(e[s],t)}},At={setSimpleData:yt,addSimpleData:Et},Ot=function(e,t,a){var s=this,n=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":le(e))){for(var i in e)this.on(i,e[i]);return this}return a&&(t=function(){s.off(e,t),n.apply(this,arguments)}),e=e.toLowerCase(),this._events||(this._events={}),(this._events[e]||(this._events[e]=[])).push({callback:t}),this},xt=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":le(e))){for(var s in e)this.off(s,e[s]);return this}var n=this._events[e];if(!n)return this;if(t)for(var a=n.length-1;a>=0;a--)n[a]==t&&n.splice(a,1);else n=null;return this._events[e]=n,this},Mt=function(e,t){this.on(e,t,1)},Nt=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],s=0,n=a.length;s<n;s++)a[s].callback.apply(this,t);return this},Ut=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],s=!0,n=0,r=a.length;n<r;n++)s=s&&a[n].callback.apply(this,t);return s},Pt=function(e){return e=e.toLowerCase(),this._events||(this._events={}),this._events[e]},Ft={on:Ot,off:xt,one:Mt,trigger:Nt,triggerReturn:Ut,getEvent:Pt},Lt=function e(t){ue(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},kt=Lt.prototype;Object.assign(kt,o),Object.assign(kt,d),Object.assign(kt,p),Object.assign(kt,m),Object.assign(kt,V),Object.assign(kt,W),Object.assign(kt,G),Object.assign(kt,q),Object.assign(kt,Q),Object.assign(kt,re),Object.assign(kt,oe),Object.assign(kt,ye),Object.assign(kt,we),Object.assign(kt,Fe),Object.assign(kt,Oe),Object.assign(kt,rt),Object.assign(kt,Xe),Object.assign(kt,ot),Object.assign(kt,At),Object.assign(kt,Dt),Object.assign(kt,Ft),Object.assign(kt,Ye),Object.assign(kt,Tt),Object.assign(kt,ct),Lt.DEFAULTS={pageSize:20,pageIndex:0,totalPages:0,pageCache:!1,enable:!0,forceDel:!1},Lt.META_DEFAULTS={enable:!0,required:!1,descs:{}},Lt.ON_ROW_SELECT="select",Lt.ON_ROW_UNSELECT="unSelect",Lt.ON_ROW_ALLSELECT="allSelect",Lt.ON_ROW_ALLUNSELECT="allUnselect",Lt.ON_VALUE_CHANGE="valueChange",Lt.ON_BEFORE_VALUE_CHANGE="beforeValueChange",Lt.ON_CURRENT_VALUE_CHANGE="currentValueChange",Lt.ON_INSERT="insert",Lt.ON_UPDATE="update",Lt.ON_CURRENT_UPDATE="currentUpdate",Lt.ON_DELETE="delete",Lt.ON_DELETE_ALL="deleteAll",Lt.ON_ROW_FOCUS="focus",Lt.ON_ROW_UNFOCUS="unFocus",Lt.ON_LOAD="load",Lt.ON_ENABLE_CHANGE="enableChange",Lt.ON_META_CHANGE="metaChange",Lt.ON_ROW_META_CHANGE="rowMetaChange",Lt.ON_CURRENT_META_CHANGE="currentMetaChange",Lt.ON_CURRENT_ROW_CHANGE="currentRowChange",Lt.SUBMIT={current:"current",focus:"focus",all:"all",select:"select",change:"change",empty:"empty",allSelect:"allSelect",allPages:"allPages"},Lt.createMetaItems=function(e){var t={};for(var a in e){var s=e[a];"string"==typeof s&&(s={}),t[a]=n({},Lt.META_DEFAULTS,s)}return t};var jt=function(e,t,a){var s=this.rows[e];s&&(s.data[t].value=a,s.status!=Row.STATUS.NEW&&s.setStatus(Row.STATUS.UPDATE))},Vt=function(e,t){if(t.data)for(var a in t.data)if(e.data[a]){var s=t.data[a];if("string"==typeof s||"number"==typeof s||null===s)e.data[a].value=s;else if(s.error)u.showMessageDialog?u.showMessageDialog({title:"警告",msg:s.error,backdrop:!0}):alert(s.error);else{e.data[a].value=s.value;for(var n in s.meta)e.data[a].meta=e.data[a].meta||{},e.data[a].meta[n]=s.meta[n]}}},Bt={setRowValue:jt,updateRow:Vt},Ht=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},Wt=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},zt=function(){for(var e=[],t=0;t<this.selectedIndices.length;t++)e.push(this.rows[this.selectedIndices[t]]);return e},Yt=function(){for(var e=[],t=this.rows,a=0,s=t.length;a<s;a++)t[a]&&t[a].status!=Row.STATUS.NORMAL&&e.push(t[a]);return e},Gt=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},Jt={getData:Ht,getSelectDatas:Wt,getSelectRows:zt,getChangedRows:Yt,getRowByRowId:Gt,getRowValue:Zt},qt=function(e,t,a){var s=this.rows[e];if(s){var n=s[t].meta;return n?n[a]:null}return null},$t={getRowMeta:qt},Xt=function(e,t,a,s){var n=this.rows[e];if(n){var r=n[t].meta;r||(r=n[t].meta={}),r[a]=s,n.status!=Row.STATUS.NEW&&n.setStatus(Row.STATUS.UPDATE)}},Qt={setRowMeta:Xt},Kt=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,"-"))},ea=function(e,t,a){je(a)||(a=1);var s=this.selectedIndices.slice();if(null!=s&&0!=s.length){for(var n=0,r=s.length;n<r;n++)"+"==t?s[n]>=e&&(s[n]=parseInt(s[n])+a):"-"==t&&(s[n]>=e&&s[n]<=e+a-1?s.splice(n,1):s[n]>e+a-1&&(s[n]=s[n]-a));this.selectedIndices=s}},ta=function(e,t,a){je(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)))},aa={removeRowByRowId:Kt,updateSelectedIndices:ea,updateFocusIndex:ta},sa=function e(t){ue(this,e),this.focus=t.focus||null,this.selectedIndices=t.selectedIndices||null,this.rows=t.rows||[],this.parent=t.parent||null},na=sa.prototype;Object.assign(na,Bt),Object.assign(na,Jt),Object.assign(na,$t),Object.assign(na,Qt),Object.assign(na,aa);var ra=function e(){ue(this,e)},ia=ra.prototype;Object.assign(ia,Ft);var oa=function(e,t){return!(null!==e&&void 0!==e&&""!==e||null!==t&&void 0!==t&&""!==t)||(e+""==t+""||e===t||!!(je(e)&&je(t)&&parseFloat(e)-parseFloat(t)<5e-7&&parseFloat(e)-parseFloat(t)>-5e-7))},la=function(e){if(!e)return e;var t=new Date;if(t.setTime(e),isNaN(t))return e;var a=t.getFullYear(),s=t.getMonth()+1;parseInt(s)<10&&(s="0"+s);var n=t.getDate();parseInt(n)<10&&(n="0"+n);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+"-"+s+"-"+n+" "+r+":"+i+":"+o},ua=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},ha=function(e,t,a,s){if(da(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 n=e.parent.ns+"."+t;e.parent.root.valueChange[n]&&e.parent.root.valueChange[n](-e.parent.root.valueChange[n]())}var r={eventType:"dataTableEvent",dataTable:e.parent.id,rowId:e.rowId,field:t,oldValue:a,newValue:e.getValue(t),ctx:s||"",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=n,r.ns=e.parent.ns,e.parent.root.trigger(DataTable.ON_VALUE_CHANGE,r),e.parent.root.trigger(n+"."+DataTable.ON_VALUE_CHANGE,r))},ca=function(e,t){t&&t.replace&&(t=t.replace(/</g,"<").replace(/"/g,""").replace(/'/g,"'"));var a=this.parent.getMeta(e,"type");return a&&("date"==a||"datetime"==a)?la(t):t},ga=function(e,t){var a=e.data[t];if(!a){var s=t.split(".");if(s.length>1){for(var n=e.data,r=0;r<s.length;r++){if(n=n[s[r]],n.value instanceof DataTable){var i=n.value.getCurrentRow();i||(i=n.value.rows()[0]),i&&(n=i.data)}if(!n)break}a=n}}return a||null},da=function(e,t){var a=ga(e,t);if(!a){var s="field:"+t+" not exist in dataTable:"+e.parent.root.id+"!";throw new Error(s)}return a},fa={formatValue:ca,eq:oa,_triggerChange:ha,_getField:da,_dateToUTCString:ua},wa=function(e,t,a,s,n){1===arguments.length&&(t=e,e="$data");var r=this.getValue(e);if(void 0!==r&&null!==r||(r=""),n&&"string"===n){if(r===t)return}else if(fa.eq(r,t))return;var i={eventType:"dataTableEvent",dataTable:this.parent.id,rowId:this.rowId,field:e,oldValue:r,newValue:t,ctx:a||""};if(!this.parent.triggerReturn(DataTable.ON_BEFORE_VALUE_CHANGE,i))return void fa._triggerChange(this,e,r,a);fa._getField(this,e).value=t,fa._triggerChange(this,e,r,a)},pa=function(e,t){for(var a=e.split("."),s=a[0],n=this.data[s],r=0,i=a.length;r<i;r++)if(r==i-1)n.value instanceof u.DataTable||this.setValue(e,t);else if(n&&n.value instanceof u.DataTable){var o=n.value.getCurrentRow();o&&o.setChildValue(e.replace(s+".",""),t)}else s=a[r+1],n=n[s]},va=function(e,t){var a=e.split(".");if(a.length>1){var s=a[0],n=this.data[s];if(n&&n.value instanceof u.DataTable){var e=a[1],r=null;e&&(r=n.value.getRowByRowId(e)),r&&(2==a.length?r.setSimpleData(t):r.setChildSimpleDataByRowId(fieldName.replace(s+"."+e+".",""),t))}}},Ra=function e(t,a,s,n,r,i){for(var o in a)if(!i||i.fieldFlag||t.parent.getMeta(o)){var l=r||null;s[o]=s[o]||{};var h=a[o];if(null==h||"object"!=(void 0===h?"undefined":le(h)))s[o].isChild||(s[o].value=t.formatValue(o,h)),!0===n&&c!==s[o].value&&fa._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=s[o].value;s[o].value=t.formatValue(o,h.value),!0===n&&c!==s[o].value&&fa._triggerChange(t,o,c);for(var g in h.meta)t.setMeta(o,g,h.meta[g])}else if(Ve(h)){s[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;s[o].value=new u.DataTable({root:t.parent.root,ns:f,meta:w}),s[o].value.setSimpleData(h)}}else l=null==l?o:l+"."+o,e(t,h,s[o],null,l,i)}},ma=function(e,t,a){var s=e.data,n=this.data;if(1!=this.parent.root.strict)return Ra(this,s,n,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){n[i].isChild=!0;var l=""===this.parent.ns?i:this.parent.ns+"."+i,r=this.parent.meta[i].meta;n[i].value=new u.DataTable({root:this.parent.root,ns:l,meta:r}),"object"===le(s[i])&&n[i].value.setSimpleData(s[i])}else if(-1!=i.indexOf(".")){for(var h=i.split("."),c=s,g=n,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==s[i]||"object"!=le(s[i]))o=n[i].value,n[i].value=this.formatValue(i,s[i]),newValue=n[i].value;else{var f=s[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=n[i].value,n[i].value=this.formatValue(i,f.value),newValue=n[i].value;for(var w in f.meta)this.setMeta(i,w,f.meta[w])}}!0===t&&o!==newValue&&fa._triggerChange(this,i,o)}},Sa=function(e){this.setData(e)},_a=function(e){if(this.status=e,e==Row.STATUS.NORMAL){var t=this.data;for(var a in t){var s=t[a].value;t[a].baseValue=s}}},Ta=function(){var e=this.data;for(var t in e){var a=e[t].baseValue;this.setValue(t,a)}},Ca={setValue:wa,setChildValue:pa,setChildSimpleDataByRowId:va,setData:ma,updateRow:Sa,setStatus:_a,resetValue:Ta},Ia=function(e){return fa._getField(this,e).value},ba=function(e){for(var t=e.split("."),a=t[0],s=0,n=t.length;s<n;s++){var r=this.getValue(a);if(s==n-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[s+1]}return""},Da=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 s=a.split("."),n=e,r=0,i=s.length;r<i;r++)n=n[s[r]];n.value=fa._dateToUTCString(n.value)}else e[a].value=fa._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}},ya=function(){return{id:this.rowId,status:this.status,data:{}}},Ea={getValue:Ia,getChildValue:ba,getData:Da,getEmptyData:ya},Aa=function(e,t,a){if(0==arguments.length){var s={};for(var n in this.data)s[n]=this.data[n].meta?this.data[n].meta:{};return s}var r=fa._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},Oa={getMeta:Aa},xa=function e(t,a){var s={},n=t.parent.getMeta()||{};for(var r in a)if("meta"!==r&&!Be(a[r]))if(a[r].isChild)s[r]=a[r].value?a[r].value.getSimpleData():{};else if("$data"===r)s=a[r].value;else if(void 0!==a[r].value){if(n[r]&&"boolean"===n[r].type?s[r]=!!a[r].value:s[r]=a[r].value,n[r]&&n[r].type){var i={meta:n,data:a,key:r};s[r]=t.formatValueFun(i,t.parent.dateNoConvert)}}else a[r].value?s[r]=e(t,a[r]):s[r]=a[r].value;return s},Ma=function(e,t){var a=e.meta,s=e.data,n=e.key;return t||"date"!=a[n].type&&"datetime"!=a[n].type?s[n].value:fa._dateToUTCString(s[n].value)},Na=function(e){e=e||{};var t=e.fields||null,a=(this.parent.getMeta(),this.data),s=xa(this,a),n={};if(t){for(var r in s)-1!=t.indexOf(r)&&(n[r]=s[r]);return n}return s},Ua={formatValueFun:Ma,getSimpleData:Na},Pa=function(){var e=this.parent.meta;for(var t in e){var a;if(t.indexOf(".")>0){var s=t.split(".");a=this.data[s[0]]=this.data[s[0]]||{};for(var n=1;n<s.length;n++)a[s[n]]=a[s[n]]||{},a=a[s[n]]}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":le(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)}}},Fa={init:Pa},La=function(e,t,a){var s=fa._getField(this,e).meta;s||(s=fa._getField(this,e).meta={});var n=s[t];fa.eq(n,a)||(s[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:n,newValue:a})),this.parent.trigger(DataTable.ON_ROW_META_CHANGE,{eventType:"dataTableEvent",dataTable:this.parent.id,field:e,meta:t,oldValue:n,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:n,newValue:a,row:this}))},ka={setMeta:La},ja=function(e,t,a,s,n,r){var i=e+"="+encodeURIComponent(t);a&&(i+="; expires="+a.toGMTString()),s&&(i+="; path="+s),n&&(i+="; domain="+n),r&&(i+="; secure="+r),document.cookie=i},Va=function(e){var t="(?:; )?"+e+"=([^;]*);?";return new RegExp(t).test(document.cookie)?decodeURIComponent(RegExp.$1):null},Ba={},Ha={},Wa={},za={},Ya={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:{}};za.getEnvironment=function(){return Le(Ba)},za.getClientAttributes=function(){return Le(Ha)},za.setContextPath=function(e){return Ba[IWEB_CONTEXT_PATH]=e},za.getContextPath=function(e){return Ba[IWEB_CONTEXT_PATH]},za.setClientAttribute=function(e,t){Ha[e]=t},za.getSessionAttributes=function(){return Le(Wa)},za.setSessionAttribute=function(e,t){Wa[e]=t,ja("ISES_"+e,t)},za.removeClientAttribute=function(e){Ha[e]=null,execIgnoreError(function(){delete Ha[e]})},za.getLocale=function(){return this.getEnvironment().locale},za.getLanguages=function(){return this.getEnvironment().languages},za.collectEnvironment=function(){var e=this.getEnvironment(),t=this.getSessionAttributes();for(var a in Ha)t[a]=Ha[a];return e.clientAttributes=t,e},za.setMaskerMeta=function(e,t){if("function"==typeof e)getMetaFunc=e;else if(Ya[e])if("object"!=typeof t)Ya[e]=t;else for(var a in t)Ya[e][a]=t[a];else Ya[e]=t},za.getMaskerMeta=function(e){if("function"==typeof getMetaFunc){return getMetaFunc.call(this)[e]}return n({},Ya[e])},Ba.languages=Va("i_languages")?Va("i_languages").split(","):navigator.language?navigator.language:"zh-CN","zh-cn"==Ba.languages&&(Ba.languages="zh-CN"),"en-us"==Ba.languages&&(Ba.languages="en-US"),Ba.theme=Va("u_theme"),Ba.locale=Va("u_locale"),Ba.usercode=Va("usercode"),document.cookie.replace(/ISES_(\w*)=([^;]*);?/gi,function(e,t,a){Wa[t]=a});var Ga=function(){};Ga.prototype=za;var Za=new Ga;if(window.getCurrentJsPath=function(){var e=document,t={},a=+new Date,s=/((?:http|https|file):\/\/.*?\/[^:]+)(?::\d+)?:\d+/,n=-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=s.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,n?o.getAttribute("src",4):o.src},window.i18n){window.u=window.u||{};var Ja=getCurrentJsPath(),qa=Ja.substr(0,Ja.lastIndexOf("/")),$a=qa.substr(0,qa.lastIndexOf("/")),Xa=u.i18nPath||$a+"/locales/__lng__/__ns__.json";i18n.init({postAsync:!1,getAsync:!1,fallbackLng:!1,ns:{namespaces:["uui-trans"]},lng:Va("u_locale")||"zh",resGetPath:Xa})}var Qa=function(e,t){return window.i18n?i18n.t("uui-trans:"+e):t},Ka={};Ka.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 s=""+Math.abs(e),n=e>=0;s.length<t;)s="0"+s;return(n?a?"+":"":"-")+s},_formats:{YY:function(e){return Ka.date.leftZeroFill(e.getFullYear()%100,2)},YYYY:function(e){return e.getFullYear()},M:function(e){return e.getMonth()+1},MM:function(e){var t=Ka.date._formats.M(e);return Ka.date.leftZeroFill(t,2)},MMM:function(e,t){var a=e.getMonth();return Ka.date._jsonLocale.monthsShort[a]},MMMM:function(e,t){var a=e.getMonth();return Ka.date._jsonLocale.months[a]},D:function(e){return e.getDate()},DD:function(e){var t=Ka.date._formats.D(e);return Ka.date.leftZeroFill(t,2)},d:function(e){return e.getDay()},dd:function(e,t){var a=Ka.date._formats.d(e);return Ka.date._jsonLocale.weekdaysMin[a]},ddd:function(e,t){var a=Ka.date._formats.d(e);return Ka.date._jsonLocale.weekdaysShort[a]},dddd:function(e,t){var a=Ka.date._formats.d(e);return Ka.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=Ka.date._formats.h(e);return Ka.date.leftZeroFill(t,2)},H:function(e){return e.getHours()},HH:function(e){return Ka.date.leftZeroFill(e.getHours(),2)},m:function(e){return e.getMinutes()},mm:function(e){return Ka.date.leftZeroFill(e.getMinutes(),2)},s:function(e){return e.getSeconds()},ss:function(e){return Ka.date.leftZeroFill(e.getSeconds(),2)}},format:function(e,t,a){if(!e&&0!=e)return"";var s,n,r=t.match(Ka.date._formattingTokens),i="",o=Ka.date.getDateObj(e);if(!o)return e;for(a=a||Za.getLanguages(),s=0,n=r.length;s<n;s++)Ka.date._formats[r[s]]?i+=Ka.date._formats[r[s]](o,a):i+=r[s];return i},strToDateByTimezone:function(e,t){var a=Ka.date.getDateObj(e),s=a.getTime(),n=6e4*a.getTimezoneOffset(),r=s+n;return r+=36e5*parseFloat(t)},getDateByTimeZonec2z:function(e,t){var a=Ka.date.getDateObj(e),s=a.getTime(),n=6e4*a.getTimezoneOffset(),r=s+n,i=r+36e5*parseFloat(t);return new Date(i)},getDateByTimeZonez2c:function(e,t){var a=Ka.date.getDateObj(e),s=a.getTime(),n=6e4*a.getTimezoneOffset(),r=s-36e5*parseFloat(t)-n;return new Date(r)},_addOrSubtract:function(e,t,a,s){var n=e.getTime(),r=e.getDate(),i=e.getMonth(),o=Ka.date.getDateObj(e);return"ms"===t?(n+=a*s,o.setTime(n)):"s"==t?(n+=1e3*a*s,o.setTime(n)):"m"==t?(n+=6e4*a*s,o.setTime(n)):"h"==t?(n+=36e5*a*s,o.setTime(n)):"d"==t?(r+=a*s,o.setDate(r)):"w"==t?(r+=7*a*s,o.setDate(r)):"M"==t?(i+=a*s,o.setMonth(i)):"y"==t&&(i+=12*a*s,o.setMonth(i)),o},add:function(e,t,a){return Ka.date._addOrSubtract(e,t,a,1)},sub:function(e,t,a){return Ka.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 s=!1,n=new Date(He(e));if(isNaN(n)){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?(n=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&&(n.setYear(l[0]),n.setMonth(parseInt(l[1]-1)),n.setDate(l[2]?l[2]:0),n.setMonth(parseInt(l[1]-1)),n.setDate(l[2]?l[2]:0),s=!0),u&&u.length>0&&("pm"==c&&(u[0]=u[0]- -12),n.setHours(u[0]?u[0]:0),n.setMinutes(u[1]?u[1]:0),n.setSeconds(u[2]?u[2]:0),s=!0)):(n=new Date(parseInt(e)),isNaN(n)||(s=!0)))}else s=!0;return s?(a&&(n=Ka.date.getDateByTimeZonec2z(n,a)),n):null}};var es=Ka.date,ts=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})},as=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})},ss=function(e,t){return this.valueChange[e]||(this.valueChange[e]=ko.observable(1)),ko.pureComputed({read:function(){this.valueChange[e](),this.currentRowChange();var a=ke(this.parent.parent,t);if(void 0===fa._getField(this,e).value||""===fa._getField(this,e).value)return"";for(var s=fa._getField(this,e).value,n="string"==typeof s?s.split(","):[s],r=[],i=0,o=a.length;i<o;i++)for(v