iweb-tool
Version:
a build tool based gulp & webpack
3 lines • 70.2 kB
JavaScript
+function(e){"use strict";function t(e){var t,i;for(t in e)i=e[t],n.Mutators.hasOwnProperty(t)?n.Mutators[t].call(this,i):this.prototype[t]=i}function i(e){return e.extend=n.extend,e.implement=t,e}function a(){}function s(e,t,i){for(var a in t)if(t.hasOwnProperty(a)){if(i&&-1===u(i,a))continue;"prototype"!==a&&(e[a]=t[a])}}var n=function(e){return this instanceof n||!h(e)?void 0:i(e)};n.create=function(e,a){function o(){e.apply(this,arguments),this.constructor===o&&this.initialize&&this.initialize.apply(this,arguments)}return h(e)||(a=e,e=null),a||(a={}),e||(e=a.Extends||n),a.Extends=e,e!==n&&s(o,e,e.StaticsWhiteList),t.call(o,a),i(o)},n.extend=function(e){return e||(e={}),e.Extends=this,n.create(e)},n.Mutators={Extends:function(e){var t=this.prototype,i=o(e.prototype);s(i,t),i.constructor=this,this.prototype=i,this.superclass=e.prototype},Implements:function(e){l(e)||(e=[e]);for(var t,i=this.prototype;t=e.shift();)s(i,t.prototype||t)},Statics:function(e){s(this,e)}};var o=Object.__proto__?function(e){return{__proto__:e}}:function(e){return a.prototype=e,new a},r=Object.prototype.toString,l=Array.isArray||function(e){return"[object Array]"===r.call(e)},h=function(e){return"[object Function]"===r.call(e)},u=Array.prototype.indexOf?function(e,t){return e.indexOf(t)}:function(e,t){for(var i=0,a=e.length;a>i;i++)if(e[i]===t)return i;return-1};e.Class=n}($),+function(e){var t=e.Class.create({initialize:function(t,i,a){this.element=t,this.id=i.id,this.options=i,this.viewModel=a;var s=i.events||{};for(var n in s)this.isDomEvent(n)?this.addDomEvent(n,e.getFunction(a,s[n])):this.on(n,e.getFunction(a,s[n]))},on:function(e,t){e=e.toLowerCase(),this._events||(this._events={});var i=this._events[e]||(this._events[e]=[]);return i.push({callback:t}),this},trigger:function(e){if(e=e.toLowerCase(),!this._events||!this._events[e])return this;for(var t=Array.prototype.slice.call(arguments,1),i=this._events[e],a=0,s=i.length;s>a;a++)i[a].callback.apply(this,t);return this},addDomEvent:function(t,i){return e(this.element).on(t,i),this},removeDomEvent:function(t){return e(this.element).off(t),this},setEnable:function(e){return this},isDomEvent:function(e){return void 0===this.element["on"+e]?!1:!0},Statics:{compName:"",EVENT_VALUE_CHANGE:"valueChange",getName:function(){return this.compName}}});e.BaseComponent=t}($),+function(e){var t=e.BaseComponent.extend({initialize:function(e,i,a){t.superclass.initialize.apply(this,arguments),this.dataModel=null,this.hasDataTable=!1,this.parseDataModel(),this.required=i.required,this.maxLength=null,this.minLength=null,this.max=null,this.min=null,this.placement=i.placement},create:function(){var t=this;this.dataModel&&(this.hasDataTable?(this.dataModel.ref(this.field).subscribe(function(e){t.modelValueChange(e)}),this.dataModel.refEnable(this.field).subscribe(function(e){t.setEnable(e)}),this.dataModel.refRowMeta(this.field,"enable").subscribe(function(e){t.setEnable(e)}),this.dataModel.refRowMeta(this.field,"required").subscribe(function(e){t.setRequired(e)}),this.setEnable(this.dataModel.isEnable(this.field)),this.setRequired(this.dataModel.getMeta(this.field,"required"))):this.dataModel.subscribe(function(e){t.modelValueChange(e)}),this.modelValueChange(this.hasDataTable?this.dataModel.getValue(this.field):this.dataModel())),this.validType&&(this.validate=e(this.element).validate({single:!0,validMode:"manually",required:this.required,validType:this.validType,placement:this.placement,maxLength:this.maxLength,minLength:this.minLength,max:this.max,min:this.min})),"INPUT"!=this.element.nodeName||e(this.element).attr("type")&&"text"!=e(this.element).attr("type")||(e(this.element).focusin(function(e){t.setShowValue(t.getValue())}),e(this.element).blur(function(e){!t.doValidate()&&t._needClean()?t.element.value=t.getShowValue():t.setValue(t.element.value)}))},modelValueChange:function(e){},parseDataModel:function(){this.options&&this.options.data&&(this.dataModel=e.getJSObject(this.viewModel,this.options.data),this.dataModel instanceof e.DataTable&&(this.hasDataTable=!0,this.field=this.options.field))},setModelValue:function(e){this.dataModel&&(this.hasDataTable?this.dataModel.setValue(this.field,e):this.dataModel(e))},setValue:function(e){},getValue:function(){return this.trueValue},setShowValue:function(e){},getShowValue:function(){return this.showValue},setEnable:function(t){t===!0||"true"===t?(this.enable=!0,e(this.element).removeAttr("readonly"),e(this.element).parent().removeClass("disablecover")):(t===!1||"false"===t)&&(this.enable=!1,e(this.element).attr("readonly","readonly"),e(this.element).parent().addClass("disablecover"))},setRequired:function(t){t===!0||"true"===t?(this.required=!0,e(this.element).siblings(".u-mustFlag").show()):(t===!1||"false"===t)&&(this.required=!1,e(this.element).siblings(".u-mustFlag").hide())},doValidate:function(e){return this.validate?e?this.validate.check(this.getValue()):this.validate.check():!0},_needClean:function(){return this.validate?this.validate._needClean():!1},Statics:{}});e.InputComp=t}($),+function(e){"use strict";var t=function(){};t.fn=t.prototype,t.fn.on=function(e,t){e=e.toLowerCase(),this._events||(this._events={});var i=this._events[e]||(this._events[e]=[]);return i.push({callback:t}),this},t.fn.trigger=function(e){if(e=e.toLowerCase(),!this._events||!this._events[e])return this;for(var t=Array.prototype.slice.call(arguments,1),i=this._events[e],a=0,s=i.length;s>a;a++)i[a].callback.apply(this,t);return this},t.fn.getEvent=function(e){return e=e.toLowerCase(),this._events||(this._events={}),this._events[e]};var i=function(e){this.id=e.id,this.meta=i.createMetaItems(e.meta),this.enable=e.enable||i.DEFAULTS.enable,this.pageSize=ko.observable(e.pageSize||i.DEFAULTS.pageSize),this.pageIndex=ko.observable(e.pageIndex||i.DEFAULTS.pageIndex),this.totalPages=ko.observable(e.totalPages||i.DEFAULTS.totalPages),this.totalRow=ko.observable(),this.pageCache=void 0===e.pageCache?i.DEFAULTS.pageCache:e.pageCache,this.rows=ko.observableArray([]),this.selectedIndices=ko.observableArray([]),this.focusIndex=-1,this.cachedPages=[],this.createDefaultEvents(),this.metaChange=ko.observable(1),this.valueChange=ko.observable(1),this.enableChange=ko.observable(1),this.params=e.params||{},this.master=e.master||""};i.fn=i.prototype=new t,i.DEFAULTS={pageSize:20,pageIndex:0,totalPages:20,pageCache:!1,enable:!0},i.META_DEFAULTS={enable:!0,required:!1,descs:{}},i.createMetaItems=function(t){var a={};for(var s in t){var n=t[s];"string"==typeof n&&(n={}),a[s]=e.extend({},i.META_DEFAULTS,n)}return a},i.ON_ROW_SELECT="select",i.ON_ROW_UNSELECT="unSelect",i.ON_ROW_ALLSELECT="allSelect",i.ON_ROW_ALLUNSELECT="allUnselect",i.ON_VALUE_CHANGE="valueChange",i.ON_INSERT="insert",i.ON_UPDATE="update",i.ON_DELETE="delete",i.ON_DELETE_ALL="deleteAll",i.ON_ROW_FOCUS="focus",i.ON_ROW_UNFOCUS="unFocus",i.ON_LOAD="load",i.ON_ENABLE_CHANGE="enableChange",i.ON_META_CHANGE="metaChange",i.ON_ROW_META_CHANGE="rowMetaChange",i.SUBMIT={current:"current",focus:"focus",all:"all",select:"select",change:"change",empty:"empty"},i.fn.createDefaultEvents=function(){},i.fn.addParam=function(e,t){this.params[e]=t},i.fn.addParams=function(e){for(var t in e)this.params[t]=e[t]},i.fn.getParam=function(e){return this.params[e]},i.fn.getMeta=function(e,t){return 0==arguments.length?this.meta:this.meta[e][t]},i.fn.setMeta=function(e,t,a){var s=this.meta[e][t];this.meta[e][t]=a,this.metaChange(-this.metaChange()),"enable"==t&&this.enableChange(-this.enableChange()),this.trigger(i.ON_META_CHANGE,{eventType:"dataTableEvent",dataTable:this.id,field:e,meta:t,oldValue:s,newValue:a})},i.fn.setCurrentPage=function(e){this.pageIndex(e);var t=this.cachedPages[this.pageIndex()];t&&(this.removeAllRows(),this.setRows(t.rows),this.setRowsSelect(t.selectedIndcies))},i.fn.isChanged=function(){for(var e=this.getAllRows(),t=0;t<e.length;t++)if(e[t].status!=a.STATUS.NORMAL)return!0;return!1},i.fn.updateMeta=function(e){if(e){for(var t in e)for(var i in e[t])"default"===i?(this.meta[t]["default"]||(this.meta[t]["default"]={}),this.meta[t]["default"].value=e[t][i]):"display"===i?(this.meta[t]["default"]||(this.meta[t]["default"]={}),this.meta[t]["default"].display=e[t][i]):this.meta[t][i]=e[t][i];this.metaChange(-this.metaChange())}},i.fn.setData=function(e){var t=e.pageIndex,i=e.pageSize||this.pageSize(),a=e.totalPages||this.totalPages(),s=e.totalRow;e.type;this.setRows(e.rows),this.pageIndex(t),this.pageSize(i),this.totalPages(a),this.totalRow(s),this.updateSelectedIndices(),e.select&&e.select.length>0&&this.rows().length>0&&this.setRowsSelect(e.select),e.focus&&this.setRowFocus(e.focus)},i.fn.setRows=function(t){for(var s=[],n=0;n<t.length;n++){var o=t[n];if(o.id||(o.id=a.getRandomRowId()),o.status==a.STATUS.DELETE)this.removeRowByRowId(o.id);else{var r=this.getRowByRowId(o.id);r?(r.updateRow(o),e.isEmptyObject(o.data)||(this.trigger(i.ON_UPDATE,{index:n,rows:[r]}),r==this.getCurrentRow()?(this.valueChange(-this.valueChange()),r.valueChange(-r.valueChange())):r.valueChange(-r.valueChange()))):(r=new a({parent:this,id:o.id}),r.setData(t[n]),s.push(r))}}s.length>0&&this.addRows(s)},i.fn.clearCache=function(){this.cachedPages=[]},i.fn.cacheCurrentPage=function(){this.pageCache&&(this.cachedPages[this.pageIndex()]={rows:this.rows().slice(),selectedIndcies:this.selectedIndices().slice(),pageSize:this.pageSize()})},i.fn.hasPage=function(e){return this.pageCache&&this.cachedPages[e]&&this.cachedPages[e].pageSize==this.pageSize()?!0:!1},i.fn.copyRow=function(e,t){var i=new a({parent:this});t&&i.setData(t.getData()),this.insertRows(void 0===e?this.rows().length:e,[i])},i.fn.addRow=function(e){this.insertRow(this.rows().length,e)},i.fn.addRows=function(e){this.insertRows(this.rows().length,e)},i.fn.insertRow=function(e,t){t||(t=new a({parent:this})),this.insertRows(e,[t])},i.fn.insertRows=function(e,t){for(var a=0;a<t.length;a++)this.rows.splice(e+a,0,t[a]),this.updateSelectedIndices(e+a,"+"),this.updateFocusIndex(e,"+");this.trigger(i.ON_INSERT,{index:e,rows:t})},i.fn.createEmptyRow=function(){var e=new a({parent:this});return this.addRow(e),e},i.fn.removeRowByRowId=function(e){var t=this.getIndexByRowId(e);-1!=t&&this.removeRow(t)},i.fn.removeRow=function(e){e instanceof a&&(e=this.getIndexByRowId(e.rowId)),this.removeRows([e])},i.fn.removeAllRows=function(){this.rows([]),this.selectedIndices([]),this.focusIndex=-1,this.trigger(i.ON_DELETE_ALL)},i.fn.removeRows=function(e){e=this._formatToIndicesArray(e),e=e.sort();for(var t=[],a=this.rows(),s=[],n=e.length-1;n>=0;n--){var o=e[n],r=a[o];if(null!=r){t.push(r.rowId);var l=a.splice(o,1);s.push(l[0]),this.updateSelectedIndices(o,"-"),this.updateFocusIndex(o,"-")}}this.rows(a),this.deleteRows=s,this.trigger(i.ON_DELETE,{indices:e,rowIds:t,deleteRows:s})},i.fn.setRowDelete=function(e){e instanceof a&&(e=this.getIndexByRowId(e.rowId)),this.setRowDelete([e])},i.fn.setAllRowsDelete=function(){for(var e=new Array(this.rows().length),t=0;t<e.length;t++)e[t]=t;this.setRowsDelete(e)},i.fn.setRowsDelete=function(e){e=this._formatToIndicesArray(e);for(var t=0;t<e.length;t++){var s=this.getRow(e[t]);s.status==a.STATUS.NEW?(this.rows(this.rows().splice(e[t],1)),this.updateSelectedIndices(e[t],"-"),this.updateFocusIndex(index,"-")):s.status=a.STATUS.FALSE_DELETE}var n=this.getRowIdsByIndices(e);this.trigger(i.ON_ROW_DELETE,{falseDelete:!0,indices:e,rowIds:n})},i.fn.setAllRowsSelect=function(){for(var e=new Array(this.rows().length),t=0;t<e.length;t++)e[t]=t;this.setRowsSelect(e),this.trigger(i.ON_ROW_ALLSELECT,{})},i.fn.setRowSelect=function(e){e instanceof a&&(e=this.getIndexByRowId(e.rowId)),this.setRowsSelect([e]),this.setRowFocus(this.getSelectedIndex())},i.fn.setRowsSelect=function(t){t=this._formatToIndicesArray(t);var a=this.selectedIndices();if("array"!=e.type(t)||"array"!=e.type(a)||t.join()!=a.join()){this.setAllRowsUnSelect({quiet:!0}),this.selectedIndices(t);var s=this.getRowIdsByIndices(t);this.valueChange(-this.valueChange()),this.trigger(i.ON_ROW_SELECT,{indices:t,rowIds:s})}},i.fn.addRowsSelect=function(e){e=this._formatToIndicesArray(e);for(var t=this.selectedIndices().slice(),a=0;a<e.length;a++){for(var s=e[a],n=!0,o=0;o<t.length;o++)t[o]==s&&(n=!1);n&&t.push(e[a])}this.selectedIndices(t);var r=this.getRowIdsByIndices(e);this.trigger(i.ON_ROW_SELECT,{indices:e,rowIds:r})},i.fn.getRowIdsByIndices=function(e){for(var t=[],i=0;i<e.length;i++)t.push(this.getRow(e[i]).rowId);return t},i.fn.setAllRowsUnSelect=function(e){this.selectedIndices([]),e&&e.quiet||this.trigger(i.ON_ROW_ALLUNSELECT)},i.fn.setRowUnSelect=function(e){this.setRowsUnSelect([e])},i.fn.setRowsUnSelect=function(e){e=this._formatToIndicesArray(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);var o=this.getRowIdsByIndices(e);this.trigger(i.ON_ROW_UNSELECT,{indices:e,rowIds:o})}},i.fn.updateSelectedIndices=function(e,t){var i=this.selectedIndices().slice();if(null!=i&&0!=i.length){for(var a=0,s=i.length;s>a;a++)"+"==t?i[a]>=e&&(i[a]=parseInt(i[a])+1):"-"==t&&(i[a]==e?i.splice(a,1):i[a]>e&&(i[a]=i[a]-1));this.selectedIndices(i)}},i.fn.updateFocusIndex=function(e,t){e<=this.focusIndex&&-1!=this.focusIndex&&("+"===t?this.focusIndex++:"-"===t&&(this.focusIndex===this.opIndex?this.focusIndex=-1:this.focusIndex--))},i.fn.getSelectedIndex=function(){var e=this.selectedIndices();return null==e||0==e.length?-1:e[0]},i.fn.getSelectedIndexs=function(){var e=this.selectedIndices();return null==e||0==e.length?[]:e},i.fn.getFocusIndex=function(){return this.focusIndex},i.fn.getIndexByRowId=function(e){for(var t=0,i=this.rows().length;i>t;t++)if(this.rows()[t].rowId==e)return t;return-1},i.fn.getAllDatas=function(){for(var e=this.getAllRows(),t=[],i=0,a=e.length;a>i;i++)e[i]&&t.push(e[i].getData());return t},i.fn.getData=function(){for(var e=[],t=0;t<this.rows().length;t++)e.push(this.rows()[t].getData());return e},i.fn.getDataByRule=function(e){var t={},a=null;if(t.meta=this.meta,t.params=this.params,e=e||i.SUBMIT.current,e==i.SUBMIT.current){var s=this.focusIndex;-1==s&&(s=this.getSelectedIndex()),a=[];for(var n=0,o=this.rows().length;o>n;n++)n==s?a.push(this.rows()[n].getData()):a.push(this.rows()[n].getEmptyData())}else if(e==i.SUBMIT.focus){a=[];for(var n=0,o=this.rows().length;o>n;n++)n==this.focusIndex?a.push(this.rows()[n].getData()):a.push(this.rows()[n].getEmptyData())}else e==i.SUBMIT.all?a=this.getData():e==i.SUBMIT.select?a=this.getSelectedDatas(!0):e==i.SUBMIT.change?a=this.getChangedDatas():e===i.SUBMIT.empty&&(a=[]);return t.rows=a,t.select=this.getSelectedIndexs(),t.focus=this.getFocusIndex(),t.pageSize=this.pageSize(),t.pageIndex=this.pageIndex(),t.isChanged=this.isChanged(),t.master=this.master,t},i.fn.getSelectedDatas=function(e){for(var t=this.selectedIndices(),i=[],a=[],s=0,n=t.length;n>s;s++)a.push(t[s]);for(var s=0,n=this.rows().length;n>s;s++)-1!=a.indexOf(s)?i.push(this.rows()[s].getData()):1==e&&i.push(this.rows()[s].getEmptyData());return i},i.fn.refSelectedRows=function(){return ko.pureComputed({read:function(){for(var e=this.selectedIndices()||[],t=this.rows(),i=[],a=0;a<e.length;a++)i.push(t[a]);return i},owner:this})},i.fn.ref=function(e){return ko.pureComputed({read:function(){this.valueChange();var t=this.getCurrentRow();return t?t.getValue(e):""},write:function(t){var i=this.getCurrentRow();i&&i.setValue(e,t)},owner:this})},i.fn.refMeta=function(e,t){return ko.pureComputed({read:function(){return this.metaChange(),this.getMeta(e,t)},write:function(i){this.setMeta(e,t,i)},owner:this})},i.fn.refRowMeta=function(e,t){return ko.pureComputed({read:function(){this.metaChange();var i=this.getCurrentRow();return i?i.getMeta(e,t):this.getMeta(e,t)},write:function(t){var i=this.getCurrentRow();i&&i.setMeta(e,t)},owner:this})},i.fn.refEnable=function(e){return ko.pureComputed({read:function(){if(this.enableChange(),!e)return this.enable;var t=this.getMeta(e,"enable");return("undefined"==typeof t||null==t)&&(t=!0),t&&this.enable},owner:this})},i.fn.isEnable=function(e){var t=this.getMeta(e,"enable");return("undefined"==typeof t||null==t)&&(t=!0),t&&this.enable},i.fn.getValue=function(e,t){return t=t||this.getCurrentRow(),t?t.getValue(e):""},i.fn.setValue=function(e,t,i,a){i=i?i:this.getCurrentRow(),i&&i.setValue(e,t,a)},i.fn.setEnable=function(e){this.enable!=e&&(this.enable=e,this.enableChange(-this.enableChange()),this.trigger(i.ON_ENABLE_CHANGE,{enable:this.enable}))},i.fn.getCurrentRow=function(){if(-1!=this.focusIndex)return this.getFocusRow();var e=this.getSelectedIndex();return-1==e?null:this.getRow(e)},i.fn.getFocusRow=function(){return-1!=this.focusIndex?this.getRow(this.focusIndex):null},i.fn.setRowFocus=function(e,t,s){var n=null;e instanceof a&&(e=this.getIndexByRowId(e.rowId),n=e.rowId),-1===e||e===this.focusIndex&&!s||(this.focusIndex=e,t||(this.valueChange(-this.valueChange()),n||(n=this.getRow(e).rowId),this.trigger(i.ON_ROW_FOCUS,{index:e,rowId:n})))},i.fn.setRowUnFocus=function(){this.valueChange(-this.valueChange());var e=this.focusIndex,t=null;-1!==e&&(t=this.getRow(e).rowId),this.trigger(i.ON_ROW_UNFOCUS,{index:e,rowId:t}),this.focusIndex=-1},i.fn.getRow=function(e){return this.rows()[e]},i.fn.getAllRows=function(){return this.rows()},i.fn.getRowByRowId=function(e){for(var t=0,i=this.rows().length;i>t;t++)if(this.rows()[t].rowId==e)return this.rows()[t];return null},i.fn.getChangedDatas=function(e){for(var t=[],i=0,s=this.rows().length;s>i;i++)this.rows()[i]&&this.rows()[i].status!=a.STATUS.NORMAL?t.push(this.rows()[i].getData()):1==e&&t.push(this.rows()[i].getEmptyData());return t},i.fn._formatToIndicesArray=function(t){if("string"==typeof t||"number"==typeof t)t=[t];else if(t instanceof a)t=this.getIndexByRowId(t.rowId);else if("array"===e.type(t)&&t.length>0&&t[0]instanceof a)for(var i=0;i<t.length;i++)t[i]=this.getIndexByRowId(t[i].rowId);return t};var a=function(e){this.rowId=e.id||a.getRandomRowId(),this.status=a.STATUS.NEW,this.parent=e.parent,this.initValue=null,this.data={},this.metaChange=ko.observable(1),this.valueChange=ko.observable(1),this.init()};a.STATUS={NORMAL:"nrm",UPDATE:"upd",NEW:"new",DELETE:"del",FALSE_DELETE:"fdel"},a.fn=a.prototype=new t,a.fn.init=function(){var e=this.parent.meta;for(var t in e)if(this.data[t]={},e[t]["default"]){var i=e[t]["default"];for(var a in i)"value"==a?this.data[t].value=i[a]:(this.data[t].meta=this.data[t].meta||{},this.data[t].meta[a]=i[a])}},a.fn.ref=function(e){return ko.pureComputed({read:function(){return this.valueChange(),this._getField(e).value},write:function(t){this.setValue(e,t)},owner:this})},a.fn.refMeta=function(e,t){return ko.pureComputed({read:function(){return this.metaChange(),this.getMeta(e,t)},write:function(i){this.setMeta(e,t,i)},owner:this})},a.fn.refCombo=function(t,i){return ko.pureComputed({read:function(){this.valueChange();var a=e.getJSObject(this.parent.parent,i);if(void 0===this._getField(t).value||""===this._getField(t).value)return"";for(var s=this._getField(t).value,n="string"==typeof s?s.split(","):[s],o=[],r=0,l=a.length;l>r;r++)for(var h=0;h<n.length;h++)a[r].pk==n[h]&&o.push(a[r].name);return o.toString()},write:function(e){this.setValue(t,e)},owner:this})},a.fn.refDate=function(e,t){return ko.pureComputed({read:function(){if(this.valueChange(),!this._getField(e).value)return"";var i=this._getField(e).value;return i?i=moment(i).format(t):""},write:function(t){this.setValue(e,t)},owner:this})},a.fn.getValue=function(e){return this._getField(e).value},a.fn.setValue=function(e,t,s,n){var o=this.getValue(e)||"";o!=(t||"")&&(this._getField(e).value=t,this._getField(e).changed=!0,this.status!=a.STATUS.NEW&&(this.status=a.STATUS.UPDATE),this.valueChange(-this.valueChange()),this.parent.getCurrentRow()==this&&this.parent.valueChange(-this.parent.valueChange()),this.parent.trigger(i.ON_VALUE_CHANGE,{eventType:"dataTableEvent",dataTable:this.parent.id,rowId:this.rowId,field:e,oldValue:o,newValue:t,ctx:s||""}),this.parent.trigger(e+"."+i.ON_VALUE_CHANGE,{eventType:"dataTableEvent",dataTable:this.parent.id,rowId:this.rowId,field:e,oldValue:o,newValue:t,ctx:s||""}))},a.fn.getMeta=function(e,t){if(0==arguments.length){var i={};for(var a in this.data)i[a]=this.data[a].meta?this.data[a].meta:{};return i}var s=this._getField(e).meta;return s&&s[t]?s[t]:this.parent.getMeta(e,t)},a.fn.setMeta=function(e,t,a){var s=this._getField(e).meta;s||(s=this._getField(e).meta={});var n=s[t];s[t]=a,this.metaChange(-this.metaChange()),"enable"==t&&this.parent.enableChange(-this.parent.enableChange()),this.parent.getCurrentRow()==this&&this.parent.metaChange(-this.parent.metaChange()),this.parent.trigger(i.ON_ROW_META_CHANGE,{eventType:"dataTableEvent",dataTable:this.parent.id,field:e,meta:t,oldValue:n,newValue:a,row:this})},a.fn.setData=function(t){this.status=t.status;for(var i in t.data)if(this.data[i]){var a=t.data[i];if("string"==typeof a||"number"==typeof a||null===a)this.data[i].value=this.formatValue(i,a);else if(a.error)e.showMessageDialog({title:"警告",msg:a.error,backdrop:!0});else{this.data[i].value=this.formatValue(i,a.value);for(var s in a.meta)this.setMeta(i,s,a.meta[s])}}},a.fn.formatValue=function(e,t){var i=this.parent.getMeta(e,"type");return i&&("date"==i||"datetime"==i)?s(t):t},a.fn.updateRow=function(e){this.setData(e)},a.fn.getData=function(){var e=ko.toJS(this.data),t=this.parent.getMeta();for(var i in t)t[i]&&t[i].type&&("date"==t[i].type||"datetime"==t[i].type)&&(e[i].value=n(e[i].value));return{id:this.rowId,status:this.status,data:e}},a.fn.getEmptyData=function(){return{id:this.rowId,status:this.status,data:{}}},a.fn._getField=function(e){if(!this.data[e])throw new Error("field:"+e+" not exist in dataTable:"+this.parent.id+"!");return this.data[e]},a.getRandomRowId=function(){return setTimeout(function(){})};var s=function(e){if(!e)return e;var t=new Date;t.setTime(e);var i=t.getFullYear(),a=t.getMonth()+1;parseInt(a)<10&&(a="0"+a);var s=t.getDate();parseInt(s)<10&&(s="0"+s);var n=t.getHours();parseInt(n)<10&&(n="0"+n);var o=t.getMinutes();parseInt(o)<10&&(o="0"+o);var r=t.getSeconds();parseInt(r)<10&&(r="0"+r);var l=i+"-"+a+"-"+s+" "+n+":"+o+":"+r;return l},n=function(e){if(!e)return"";e.indexOf("-")>-1&&(e=e.replace(/\-/g,"/"));var t=Date.parse(e);return isNaN(t)?"":t};e.Row=a,e.DataTable=i}($),+function(e,t){"use strict";var i={plugs:{},apply:function(a,s){s=s||document.body,e(s).find("[u-meta]").each(function(){if(!(e(this).data("u-meta")||e(this).parent("[u-meta]").length>0)){var t=JSON.parse(e(this).attr("u-meta"));if(t&&t.type){var s=i._createComp(this,t,a,app);s&&e(this).data("u-meta",s)}}}),t.applyBindings(a,s)},addPlug:function(e){var t=e.getName();if(this.plugs||(this.plugs={}),this.plugs[t])throw new Error("plug has exist:"+t);this.plugs[t]=e},_createComp:function(e,t,i,a){var s=t.type,n=this.plugs[s];if(!n)return null;var o=new n(e,t,i,a);return o.type=s,o}};e.compManager=i}($,ko),+function(e){var t=e.InputComp.extend({initialize:function(i,a,s){var n=this;t.superclass.initialize.apply(this,arguments),this.maskerMeta=iweb.Core.getMaskerMeta("float")||{},this.maskerMeta.precision=a.precision||this.maskerMeta.precision,this.validType="float",this.max=a.max,this.min=a.min,this.dataModel&&this.hasDataTable&&(this.dataModel.refRowMeta(this.field,"precision").subscribe(function(e){void 0!==e&&n.setPrecision(e)}),this.maskerMeta.precision=this.dataModel.getMeta(this.field,"precision")||this.maskerMeta.precision,this.min=this.dataModel.getMeta(this.field,"min")||this.min,this.max=this.dataModel.getMeta(this.field,"max")||this.max),this.formater=new e.NumberFormater(this.maskerMeta.precision),this.masker=new NumberMasker(this.maskerMeta),this.create()},modelValueChange:function(e){e=e||"";var t=this.formater.format(e);this.trueValue=t,this.element.trueValue=this.trueValue,this.showValue=this.masker.format(t).value,this.setShowValue(this.showValue)},setValue:function(e){this.trueValue=this.formater.format(e),this.element.trueValue=this.trueValue,this.showValue=this.masker.format(this.trueValue).value,this.setShowValue(this.showValue),this.setModelValue(this.trueValue),this.trigger(t.EVENT_VALUE_CHANGE,this.trueValue)},getValue:function(){return this.trueValue},setShowValue:function(e){this.showValue=e,this.element.value=e,this.element.title=e},getShowValue:function(){return this.showValue},setPrecision:function(t){this.maskerMeta.precision!=t&&(this.maskerMeta.precision=t,this.formater=new e.NumberFormater(this.maskerMeta.precision),this.masker=new NumberMasker(this.maskerMeta))},Statics:{compName:"float"}});e.compManager&&e.compManager.addPlug(t)}($),+function($){var Grid=function(element,options,viewModel,app){var oThis=this,compDiv=null,comp=null;this.dataTable=$.getJSObject(viewModel,options.data),this.element=element,this.$element=$(element),this.editComponentDiv={},this.editComponent={},this.id=options.id,this.gridOptions=options,this.gridOptions.onBeforeRowSelected=$.getFunction(viewModel,this.gridOptions.onBeforeRowSelected),this.gridOptions.onRowSelected=$.getFunction(viewModel,this.gridOptions.onRowSelected),this.gridOptions.onBeforeRowUnSelected=$.getFunction(viewModel,this.gridOptions.onBeforeRowUnSelected),this.gridOptions.onRowUnSelected=$.getFunction(viewModel,this.gridOptions.onRowUnSelected),this.gridOptions.onBeforeAllRowSelected=$.getFunction(viewModel,this.gridOptions.onBeforeAllRowSelected),this.gridOptions.onAllRowSelected=$.getFunction(viewModel,this.gridOptions.onAllRowSelected),this.gridOptions.onBeforeAllRowUnSelected=$.getFunction(viewModel,this.gridOptions.onBeforeAllRowUnSelected),this.gridOptions.onAllRowUnSelected=$.getFunction(viewModel,this.gridOptions.onAllRowUnSelected),this.gridOptions.onBeforeRowFocus=$.getFunction(viewModel,this.gridOptions.onBeforeRowFocus),this.gridOptions.onRowFocus=$.getFunction(viewModel,this.gridOptions.onRowFocus),this.gridOptions.onBeforeRowUnFocus=$.getFunction(viewModel,this.gridOptions.onBeforeRowUnFocus),this.gridOptions.onRowUnFocus=$.getFunction(viewModel,this.gridOptions.onRowUnFocus),this.gridOptions.onDblClickFun=$.getFunction(viewModel,this.gridOptions.onDblClickFun),this.gridOptions.onValueChange=$.getFunction(viewModel,this.gridOptions.onValueChange);var columns=[];$("div",this.$element).each(function(){var ops=$(this).attr("options");if("undefined"==typeof ops)var column=eval("("+ops+")");else var column=JSON.parse(ops);var eType=$.getFunction(viewModel,column.editType),rType=$.getFunction(viewModel,column.renderType),eOptions={};if(column.editOptions)if("undefined"==typeof column.editOptions)var eOptions=eval("("+column.editOptions+")");else var eOptions=column.editOptions;eOptions.data=options.data,eOptions.field=column.field,""==eType&&(eType="string"),"string"==eType||"integer"==eType||"checkbox"==eType||"combo"==eType||"radio"==eType||"float"==eType||"currency"==eType||"datetime"==eType||"date"==eType?("string"==eType?(compDiv=$('<div><input type="text" class="u-grid-edit-item-string"></div>'),options.editType&&"default"!=options.editType||compDiv.addClass("eType-input"),comp=new $.compManager.plugs.string(compDiv.find("input")[0],eOptions,viewModel)):"integer"==eType?(compDiv=$('<div><input type="text" class="u-grid-edit-item-integer"></div>'),options.editType&&"default"!=options.editType||compDiv.addClass("eType-input"),comp=new $.compManager.plugs.integer(compDiv.find("input")[0],eOptions,viewModel)):"checkbox"==eType?(compDiv=$('<input id="'+oThis.id+"_edit_field_"+column.field+'" type="checkbox" class="u-grid-edit-item-checkbox">'),comp=new $.compManager.plugs.check(compDiv[0],eOptions,viewModel)):"combo"==eType?(compDiv=$('<div class="input-group form_date u-grid-edit-item-comb"><div type="text" class="form-control grid-combox"></div><i class="input-group-addon" ><i class="fa fa-angle-down"></i></i></div>'),comp=new $.compManager.plugs.combo(compDiv[0],eOptions,viewModel)):"radio"==eType?(compDiv=null,comp=null):"float"==eType?(compDiv=$('<div><input type="text" class="u-grid-edit-item-float"></div>'),options.editType&&"default"!=options.editType||compDiv.addClass("eType-input"),comp=new $.compManager.plugs["float"](compDiv.find("input")[0],eOptions,viewModel)):"currency"==eType?(compDiv=$('<div><input type="text" class="u-grid-edit-item-currency"></div>'),options.editType&&"default"!=options.editType||compDiv.addClass("eType-input"),comp=new $.compManager.plugs.currency(compDiv.find("input")[0],eOptions,viewModel)):"datetime"==eType?(compDiv=$('<div class="input-group u-grid-edit-item-datetime" ><input class="form-control" /><div class="input-group-addon"><i class="glyphicon glyphicon-calendar"></i></div></div>'),eOptions.widgetParent=$("body"),comp=new $.compManager.plugs.datetime(compDiv[0],eOptions,viewModel)):"date"==eType&&(compDiv=$('<div class="input-group u-grid-edit-item-date" ><input class="form-control" /><div class="input-group-addon"><i class="glyphicon glyphicon-calendar"></i></div></div>'),eOptions.widgetParent=$("body"),comp=new $.compManager.plugs.date(compDiv[0],eOptions,viewModel)),oThis.editComponentDiv[column.field]=compDiv,oThis.editComponent[column.field]=comp,column.editType=function(e){var t=oThis.editComponent[column.field];if(t){e.element.innerHTML="";var i=$('<div class="u-grid-content-td-div" style="margin:0px;"></div>');oThis.getDataTableRow(e.rowObj);$(e.element).append(i),i.append(oThis.editComponentDiv[column.field]),t.required&&$(e.element).parent().find(".u-grid-edit-mustFlag").show(),t.modelValueChange(e.value)}}):"function"==typeof eType&&(column.editType=eType),"booleanRender"==rType?column.renderType=function(e){var t="";"Y"==e.value&&(t="checked");var i='<input type="checkbox" style="cursor:default;" disabled '+t+">";e.element.innerHTML=i}:"integerRender"==rType?column.renderType=function(e){e.element.innerHTML=e.value,$(e.element).css("text-align","right")}:"currencyRender"==rType?column.renderType=function(e){var t=e.gridObj,i=e.gridCompColumn,a=i.options.field,s=e.rowIndex,n=t.dataTable,o=$(t.dataSourceObj.rows[s].value).attr("$_#_@_id"),r=n.getRowByRowId(o),l=r.getMeta(a,"precision")||"",h=iweb.Core.getMaskerMeta("currency")||{};h.precision=l||h.precision;var u=new $.NumberFormater(h.precision),d=new NumberMasker(h),c=d.format(u.format(e.value)).value;e.element.innerHTML=c,$(e.element).css("text-align","right"),$(e.element).attr("title",c)}:"floatRender"==rType?column.renderType=function(e){var t=e.gridObj,i=e.gridCompColumn,a=i.options.field,s=e.rowIndex,n=t.dataTable,o=$(t.dataSourceObj.rows[s].value).attr("$_#_@_id"),r=n.getRowByRowId(o),l=r.getMeta(a,"precision")||"",h=iweb.Core.getMaskerMeta("float")||{};h.precision=l||h.precision;var u=new $.NumberFormater(h.precision),d=new NumberMasker(h),c=d.format(u.format(e.value)).value;e.element.innerHTML=c,$(e.element).css("text-align","right"),$(e.element).attr("title",c)}:"comboRender"==rType?column.renderType=function(e){var t=$.getJSObject(viewModel,eOptions.datasource);e.element.innerHTML="",a&&(a.length=0);for(var i=e.value.split(","),a=[],s=0,n=t.length;n>s;s++)for(var o=0;o<i.length;o++)t[s].pk==i[o]&&a.push(t[s].name);var r=a.toString();e.element.innerHTML=r,$(e.element).attr("title",r)}:"dateRender"==rType?column.renderType=function(e){var t=moment(e.value).format("YYYY-M-D ");e.element.innerHTML=t,$(e.element).attr("title",t)}:"dateTimeRender"==rType?column.renderType=function(e){var t=moment(e.value).format("YYYY-M-D HH:mm");e.element.innerHTML=t,$(e.element).attr("title",t)}:"function"==typeof rType?column.renderType=rType:"radioRender"==rType&&(column.renderType=function(e){var t=$.getJSObject(viewModel,eOptions.datasource),i=e.value,a=$('<div class="u-grid-edit-item-radio"></div>');e.element.innerHTML="",$(e.element).append(a);for(var s=0;s<t.length;s++)t[s].pk==i?a.append('<input type="radio" value='+t[s].pk+' checked /><i data-role="name">'+t[s].name+"</i>"):a.append('<input type="radio" value="'+t[s].pk+'"/><i data-role="name">'+t[s].name+"</i>");a.find(":radio").each(function(){
$(this).on("click",function(){var t=this.value;a.find(":radio").each(function(){this.value==t?this.checked=!0:this.checked=!1});var i=e.gridObj,s=e.gridCompColumn,n=s.options.field,o=e.rowIndex,r=i.dataTable,l=$(i.dataSourceObj.rows[o].value).attr("$_#_@_id"),h=r.getRowByRowId(l);h.setValue(n,t)})})}),columns.push(column)}),app&&app.adjustFunc&&app.adjustFunc.call(app,{id:this.id,type:"gridColumn",columns:columns}),this.gridOptions.columns=columns;var onRowSelectedFun=this.gridOptions.onRowSelected;this.gridOptions.onRowSelected=function(e){var t=oThis.grid.dataSourceObj.rows[e.rowIndex].value["$_#_@_id"],i=oThis.dataTable.getIndexByRowId(t);oThis.grid.options.multiSelect?oThis.dataTable.addRowsSelect([i]):oThis.dataTable.setRowSelect(i),onRowSelectedFun&&onRowSelectedFun.call(oThis,e)},this.dataTable.on($.DataTable.ON_ROW_SELECT,function(e){$.each(e.rowIds,function(){var e=oThis.grid.getRowIndexByValue("$_#_@_id",this),t=!0;e>-1&&(t=oThis.grid.setRowSelect(parseInt(e)),t||oThis.dataTable.setRowUnSelect(oThis.dataTable.getIndexByRowId(this)))})}),this.dataTable.on($.DataTable.ON_ROW_ALLSELECT,function(e){oThis.grid.setAllRowSelect()}),this.dataTable.on($.DataTable.ON_ROW_ALLUNSELECT,function(e){oThis.grid.setAllRowUnSelect()});var onRowUnSelectedFun=this.gridOptions.onRowUnSelected;this.gridOptions.onRowUnSelected=function(e){var t=oThis.grid.dataSourceObj.rows[e.rowIndex].value["$_#_@_id"],i=oThis.dataTable.getIndexByRowId(t);oThis.dataTable.setRowUnSelect(i),onRowUnSelectedFun&&onRowUnSelectedFun.call(oThis,e)},this.dataTable.on($.DataTable.ON_ROW_UNSELECT,function(e){$.each(e.rowIds,function(){var e=oThis.grid.getRowIndexByValue("$_#_@_id",this),t=!0;e>-1&&(t=oThis.grid.setRowUnselect(parseInt(e)),t||(oThis.grid.options.multiSelect?oThis.dataTable.addRowsSelect([oThis.dataTable.getIndexByRowId(this)]):oThis.dataTable.setRowSelect(oThis.dataTable.getIndexByRowId(this))))})});var onRowFocusFun=this.gridOptions.onRowFocus;this.gridOptions.onRowFocus=function(e){var t=oThis.grid.dataSourceObj.rows[e.rowIndex].value["$_#_@_id"],i=oThis.dataTable.getIndexByRowId(t);oThis.grid.options.rowClickBan?oThis.dataTable.setRowFocus(i,!0):oThis.dataTable.setRowFocus(i),onRowFocusFun&&onRowFocusFun.call(oThis,e)},this.dataTable.on($.DataTable.ON_ROW_FOCUS,function(e){var t=oThis.grid.getRowIndexByValue("$_#_@_id",e.rowId);if(t==oThis.grid.focusRowIndex)return void(oThis.grid.eidtRowIndex!=t&&"form"==oThis.grid.eidtType&&oThis.editRowFun(t));var i=!0;t>-1&&(i=oThis.grid.setRowFocus(parseInt(t)),oThis.grid.eidtRowIndex!=t&&"form"==oThis.grid.eidtType&&oThis.editRowFun(t),i||oThis.dataTable.setRowUnFocus(oThis.dataTable.getIndexByRowId(e.rowId)))});var onRowUnFocusFun=this.gridOptions.onRowUnFocus;this.gridOptions.onRowUnFocus=function(e){var t=oThis.grid.dataSourceObj.rows[e.rowIndex].value["$_#_@_id"],i=oThis.dataTable.getIndexByRowId(t);oThis.dataTable.setRowUnFocus(i),onRowUnFocusFun&&onRowUnFocusFun.call(oThis,e)},this.dataTable.on($.DataTable.ON_ROW_UNFOCUS,function(e){var t=oThis.grid.getRowIndexByValue("$_#_@_id",e.rowId),i=!0;t>-1&&(i=oThis.grid.setRowUnFocus(parseInt(t)),i||oThis.dataTable.setRowFocus(oThis.dataTable.getIndexByRowId(e.rowId)))}),this.dataTable.on($.DataTable.ON_INSERT,function(e){var t=new Array;$.each(e.rows,function(){var e=this.data,i=this.rowId,a={};for(var s in e)a[s]=e[s].value;a["$_#_@_id"]=i,t.push(a)}),oThis.grid.addRows(t,e.index)}),this.dataTable.on($.DataTable.ON_UPDATE,function(e){$.each(e.rows,function(){var e=this.data,t=this.rowId,i={};for(var a in e)i[a]=e[a].value;i["$_#_@_id"]=t;var s=oThis.grid.getRowIndexByValue("$_#_@_id",t);oThis.grid.updateRow(s,i)})}),this.dataTable.on($.DataTable.ON_VALUE_CHANGE,function(e){var t=e.rowId,i=oThis.grid.getRowIndexByValue("$_#_@_id",t);if(-1!=i){var a=e.field,s=e.newValue;oThis.grid.updateValueAt(i,a,s)}}),this.dataTable.on($.DataTable.ON_DELETE,function(e){var t=new Array;$.each(e.rowIds,function(){var e=oThis.grid.getRowIndexByValue("$_#_@_id",this);t.push(e)}),oThis.grid.deleteRows(t)}),this.dataTable.on($.DataTable.ON_DELETE_ALL,function(e){oThis.grid.setDataSource({})});var onValueChangeFun=this.gridOptions.onValueChange;this.gridOptions.onValueChange=function(e){var t=oThis.getDataTableRow(oThis.grid.dataSourceObj.rows[e.rowIndex].value);t&&("object"==$.type(e.newValue)?(t.setValue(e.field,e.newValue.trueValue),t.setMeta(e.field,"display",e.newValue.showValue)):t.setValue(e.field,e.newValue)),onValueChangeFun&&onValueChangeFun.call(oThis,e)},this.dataTable.on("valueChange",function(e){var t=e.field,i=e.rowId,a=(e.oldValue,e.newValue),s=oThis.grid.getRowIndexByValue("$_#_@_id",i);s>-1&&oThis.grid.updateValueAt(s,t,a)}),this.dataTable.on($.DataTable.ON_LOAD,function(e){if(e.length>0){var t=new Array;$.each(e,function(){var e={},i=this.data,a=this.rowId;for(var s in i){var n=i[s].value;e[s]=n}e["$_#_@_id"]=a,t.push(e)});var i={};i.values=t,oThis.grid.setDataSource(i)}}),this.dataTable.on($.DataTable.ON_ENABLE_CHANGE,function(e){oThis.grid.setEditable(e.enable)}),this.dataTable.on($.DataTable.ON_ROW_META_CHANGE,function(e){var t=e.field,i=e.meta;"required"==i&&oThis.grid.setRequired(t,e.newValue)}),this.grid=$(element).grid(this.gridOptions),this.grid.dataTable=this.dataTable,this.grid.viewModel=viewModel,this.grid.gridModel=this;var data=this.dataTable.rows();if(data.length>0){var values=new Array;$.each(data,function(){var e={},t=this.data,i=this.rowId;for(var a in t){var s=t[a].value;e[a]=s}e["$_#_@_id"]=i,values.push(e)});var dataSource={};dataSource.values=values,oThis.grid.setDataSource(dataSource)}var selectIndexs=this.dataTable.getSelectedIndexs();return selectIndexs.length>0&&$.each(selectIndexs,function(){oThis.grid.setRowSelect(this)}),this};Grid.getName=function(){return"grid"},Grid.fn=Grid.prototype,Grid.fn.getDataTableRow=function(e){var t=e["$_#_@_id"],i=null,a=this.dataTable.getIndexByRowId(t);return a>-1&&(i=this.dataTable.getRow(a)),i},Grid.fn.setEnable=function(e){this.grid.setEditable(e)},Grid.fn.setShowHeader=function(e){this.grid.setShowHeader(e)},Grid.fn.editRowFun=function(e){this.dataTable.setRowSelect(e),this.grid.editRowIndexFun(e)},$.compManager&&$.compManager.addPlug(Grid)}($),+function($){var Tree=function(element,options,viewModel){var oThis=this;this.dataTable=$.getJSObject(viewModel,options.data),this.element=element,this.$element=$(element),this.id=options.id,this.element.id=this.id,this.options=options,this.events=$.extend(!0,{},options.events);var treeSettingDefault={data:{simpleData:{enable:!0}},check:{chkboxType:{Y:"",N:""}},callback:{beforeClick:function(e,t,i){oThis.events.beforeClick&&$.getFunction(viewModel,oThis.events.beforeClick)(e,t,i)},onCheck:function(e,t,i){var a=i.id,s=oThis.getRowIdByIdValue(a),n=oThis.dataTable.getIndexByRowId(s);i.checked?oThis.options.multiSelect?oThis.dataTable.addRowsSelect([n]):oThis.dataTable.setRowSelect(n):oThis.dataTable.setRowUnSelect(n)},onClick:function(e,t,i){if(!oThis.options.multiSelect){var a=i.id,s=oThis.getRowIdByIdValue(a),n=oThis.dataTable.getIndexByRowId(s);oThis.dataTable.setRowSelect(n),oThis.events.onClick&&$.getFunction(viewModel,oThis.events.onClick)(e,t,i)}}}},setting={};this.options.setting&&(setting="undefined"==typeof JSON?eval("("+this.options.setting+")"):$.getJSObject(viewModel,this.options.setting)||$.getJSObject(window,this.options.setting));var treeSetting=$.extend({},treeSettingDefault,setting),treeData=[],data=this.dataTable.rows();if(data.length>0)if(this.options.codeTree){data.sort(function(e,t){var i=e.data,a=t.data,s=i[oThis.options.idField].value+"",n=a[oThis.options.idField].value+"";try{return s.localeCompare(n)}catch(o){return 0}});var idArr=new Array;$.each(data,function(){var e=this.data,t=e[oThis.options.idField].value;idArr.push(t)});var preValue="";$.each(data,function(){var e={},t=this.data,i=t[oThis.options.idField].value,a=t[oThis.options.nameField].value,s="",n=-1;if(""!=preValue)var n=i.indexOf(preValue);if(0==n)s=preValue;else for(var o=1;o<preValue.length;o++){var r=preValue.substr(0,o),l=i.indexOf(r);if(0!=l)break;var h=$.inArray(r,idArr);(h>0||0==h)&&(s=r)}e.id=i,e.pId=s,e.name=a,treeData.push(e),preValue=i})}else{var values=new Array;$.each(data,function(){var e={},t=this.data,i=t[oThis.options.idField].value,a=t[oThis.options.pidField].value,s=t[oThis.options.nameField].value;e.id=i,e.pId=a,e.name=s,treeData.push(e)})}return this.tree=$.fn.zTree.init(this.$element,treeSetting,treeData),this.dataTable.on($.DataTable.ON_ROW_SELECT,function(e){$.each(e.rowIds,function(){var e=oThis.dataTable.getRowByRowId(this),t=e.data,i=t[oThis.options.idField].value,a=oThis.tree.getNodeByParam("id",i);oThis.options.multiSelect&&!a.checked?oThis.tree.checkNode(a):oThis.tree.selectNode(a,!1)})}),this.dataTable.on($.DataTable.ON_ROW_UNSELECT,function(e){$.each(e.rowIds,function(){var e=oThis.dataTable.getRowByRowId(this),t=e.data,i=t[oThis.options.idField].value,a=oThis.tree.getNodeByParam("id",i);oThis.options.multiSelect&&a.checked?oThis.tree.checkNode(a):oThis.tree.cancelPreSelectedNode(treeSetting,a)})}),this.dataTable.on($.DataTable.ON_INSERT,function(e){new Array;$.each(e.rows,function(){var e={},t=this.data,i=t[oThis.options.idField].value,a=t[oThis.options.pidField].value,s=t[oThis.options.nameField].value;e.id=i,e.pId=a,e.name=s;var n=oThis.tree.getNodeByParam("id",a);oThis.tree.addNodes(n,e,!0)})}),this.dataTable.on($.DataTable.ON_DELETE,function(e){new Array;if(this.deleteRows.length>0)for(var t=0;t<this.deleteRows.length;t++){var i=this.deleteRows[t],a=i.data,s=a[oThis.options.idField].value,n=oThis.tree.getNodeByParam("id",s);oThis.tree.removeNode(n)}}),this.dataTable.on($.DataTable.ON_DELETE_ALL,function(e){for(var t=oThis.tree.getNodes(),i=0,a=t.length;a>i;i++){var s=oThis.tree.getNodeByParam("id",t[i].id);oThis.tree.removeNode(s),i--,a=t.length}}),this.dataTable.on($.DataTable.ON_LOAD,function(e){var e=oThis.dataTable.rows();if(e.length>0){new Array;$.each(e,function(){var e={},t=this.data,i=t[oThis.options.idField].value,a=t[oThis.options.pidField].value,s=t[oThis.options.nameField].value;e.id=i,e.pId=a,e.name=s,treeData.push(e)})}this.tree=$.fn.zTree.init(this.$element,treeSetting,treeData)}),this.dataTable.on($.DataTable.ON_VALUE_CHANGE,function(e){var t=oThis.dataTable.getRowByRowId(e.rowId);if(t){var i=t.getValue(oThis.options.idField),a=oThis.tree.getNodeByParam("id",i),s=e.field,n=e.newValue;if(oThis.options.nameField==s)a.name=n,oThis.tree.updateNode(a);else if(oThis.options.pidField==s){var o=oThis.tree.getNodeByParam("id",n);oThis.tree.moveNode(o,a,"inner")}}}),this.getRowIdByIdValue=function(e){var t=this,i=null;return $.each(this.dataTable.rows(),function(){var a=this.data,s=this.rowId;a[t.options.idField].value==e&&(i=s)}),i},this};Tree.getName=function(){return"tree"},$.compManager&&$.compManager.addPlug(Tree)}($),+function(e){var t=e.InputComp.extend({initialize:function(i,a,s){var n=this;t.superclass.initialize.apply(this,arguments),this.datasource=e.getJSObject(s,a.datasource),this.single=a.single,this.mutil=a.mutil,this.validType="combo",e(this.element).children().length>0?this.comboEle=e(this.element).find("div")[0]:this.comboEle=this.element,this.create(),this.mutil&&e(this.comboEle).on("mutilSelect",function(e,t){n.setValue(t)}),this.comp=e(this.comboEle).Combobox({readchange:!1,dataSource:this.datasource,single:this.single,mutil:this.mutil,onSelect:function(e){n.setValue(e.pk),n.trigger("onSelect",e)}})},addDomEvent:function(t,i){return e(this.comboEle).on(t,i),this},removeDomEvent:function(t){e(this.comboEle).off(t)},modelValueChange:function(t){this.slice||(this.trueValue=t,e(this.comboEle).val(t))},setValue:function(i){this.trueValue=i,e(this.comboEle).val(i),this.slice=!0,this.setModelValue(this.trueValue),this.slice=!1,this.trigger(t.EVENT_VALUE_CHANGE,this.trueValue)},getValue:function(){return this.trueValue},setEnable:function(t){t===!0||"true"===t?(this.enable=!0,e(this.comboEle).data("enable",!0),e(this.comboEle).parent().removeClass("disablecover")):(t===!1||"false"===t)&&(this.enable=!1,e(this.comboEle).data("enable",!1),e(this.comboEle).parent().addClass("disablecover"))},Statics:{compName:"combo"}});e.compManager&&e.compManager.addPlug(t)}($),+function(e){var t=e.InputComp.extend({initialize:function(i,a,s){var n=this;t.superclass.initialize.apply(this,arguments),this.validType="string",this.maxLength=a.maxLength,this.minLength=a.minLength,this.dataModel&&this.hasDataTable&&(this.minLength=this.dataModel.getMeta(this.field,"minLength")||this.minLength,this.maxLength=this.dataModel.getMeta(this.field,"maxLength")||this.maxLength),this.create(),"INPUT"==this.element.nodeName&&(e(this.element).focusin(function(e){n.setShowValue(n.getValue())}),e(this.element).blur(function(e){n.setValue(n.element.value)}))},modelValueChange:function(e){this.slice||(e=e||"",this.trueValue=e,this.showValue=e,this.setShowValue(this.showValue))},setValue:function(e){this.trueValue=e,this.showValue=e,this.setShowValue(this.showValue),this.slice=!0,this.setModelValue(this.trueValue),this.slice=!1,this.trigger(t.EVENT_VALUE_CHANGE,this.trueValue)},getValue:function(){return this.trueValue},setShowValue:function(e){this.showValue=e,this.element.value=e,this.element.title=e},getShowValue:function(){return this.showValue},Statics:{compName:"string"}});e.StringComp=t,e.compManager&&e.compManager.addPlug(t)}($),+function(e){var t=e.InputComp.extend({initialize:function(i,a,s){var n=this;t.superclass.initialize.apply(this,arguments),this.create(),e.app?e(this.element).wrap("<label class='label-switch'></label>").after("<div class='checkbox'></div>").css("display","none"):0!==e(this.element).parent(".checkbox").length||iweb.browser.isIE8||e(this.element).wrap("<div class='checkbox check-success'></div>").after("<label for="+i.id+"></label>"),e(this.element).on("change",function(){var e=i.checked?"Y":"N";n.setValue(e)})},modelValueChange:function(e){this.slice||(e=e||"",this.trueValue=e,"Y"==e||"true"==e?this.showValue=!0:"N"==e||"false"==e?this.showValue=!1:this.showValue=!1,this.setShowValue(this.showValue))},setValue:function(e){this.trueValue=e,"Y"==e||"true"==e?this.showValue=!0:"N"==e||"false"==e?this.showValue=!1:this.showValue=!1,this.setShowValue(this.showValue),this.slice=!0,this.setModelValue(this.trueValue),this.slice=!1,this.trigger(t.EVENT_VALUE_CHANGE,this.trueValue)},getValue:function(){return this.trueValue},setShowValue:function(e){this.showValue=e,this.element.checked=e},getShowValue:function(){return this.showValue},Statics:{compName:"check"}});e.compManager&&e.compManager.addPlug(t)}($),+function(e){var t=e.InputComp.extend({initialize:function(i,a,s){var n=this;this.pks=[],t.superclass.initialize.apply(this,arguments),this.validType="checkboxGroup";var o=e.getJSObject(s,a.datasource);if(e.isArray(o)){var r=e(this.element).children();if(r.is(":checkbox")){for(var l=0,h=o.length-1;h>l;l++)r.clone().appendTo(this.element);for(var u=e(this.element).children("[type=checkbox]"),d=e(this.element).children("[data-role=name]"),c=0;c<u.length;c++)u[c].value=o[c].pk,d[c].innerHTML=o[c].name,this.pks.push(o[c].pk);this.valArr=[],this.create(),e(this.element).find(":checkbox").each(function(){e(this).on("click",function(){if(0==n.valArr.length)this.checked&&n.valArr.push(this.value);else if(this.checked){for(var e=null,t=0;t<n.valArr.length;t++)this.value==n.valArr[t]&&(e=t);null==e&&n.valArr.push(this.value)}else for(var i=0;i<n.valArr.length;i++)this.value==n.valArr[i]&&n.valArr.splice(i,1);n.setValue(n.valArr.toString())})})}}},modelValueChange:function(e){this.slice||(""!=e&&null!=e&&(this.valArr=e.split(",")),this.setValue(e))},setValue:function(i){if(this.trueValue=i,""==i||null==i)var a="";else a=i.split(",");for(var s=this.pks.slice(),n=0;n<s.length;n++){var o=s[n];-1!==a.indexOf(o)&&(s.splice(n,1),--n)}e(this.element).find(":checkbox").each(function(){-1!==a.indexOf(this.value)&&(this.checked=!0),-1!==s.indexOf(this.value)&&(this.checked=!1)}),this.slice=!0,this.setModelValue(this.trueValue),this.slice=!1,this.trigger(t.EVENT_VALUE_CHANGE,this.trueValue)},getValue:function(){return this.trueValue},Statics:{compName:"checkboxGroup"}});e.compManager&&e.compManager.addPlug(t)}($),+function(e){var t=e.InputComp.extend({initialize:function(i,a,s){var n=this;this.outerDiv=i,i=e(i).find("input")[0],t.superclass.initialize.apply(this,arguments),this.maskerMeta=iweb.Core.getMaskerMeta("datetime")||{},this.maskerMeta.format=a.format||this.maskerMeta.format,this.dataModel&&this.hasDataTable&&(this.dataModel.refRowMeta(this.field,"format").subscribe(function(e){n.setFormat(e)}),this.maskerMeta.format=this.dataModel.getMeta(this.field,"format")||this.maskerMeta.format),this.validType="datetime",this.options.picker_type="datetime",a.format||(this.options.format="YYYY-MM-DD HH:mm:ss"),this.formater=new e.DateFormater(this.maskerMeta.format),this.masker=new DateTimeMasker(this.maskerMeta),this.create(),this.comp=e(this.outerDiv).datetimepicker(this.options),e(this.element).focusin(function(e){n.setShowValue(n.getValue())}).blur(function(e){!n.doValidate()&&n._needClean()?n.setShowValue(n.getShowValue()):n.setValue(this.value)}),e.app&&e(this.element).on("picker_open",function(){n.setShowValue(n.getValue())}).on("picker_close",function(){n.setValue(this.value)})},modelValueChange:function(e){if(!this.slice){e=e||"",this.trueValue=e;var t=this.masker.format(e).value;this.setShowValue(t)}},setValue:function(e){this.trueValue=e,this.setShowValue(this.trueValue),this.slice=!0,this.setModelValue(e),this.slice=!1,this.trigger(t.EVENT_VALUE_CHANGE,this.trueValue)},getValue:function(){return this.trueValue},setShowValue:function(t){this.showValue=t,e(this.element).val(t),e(this.outerDiv).data("DateTimePicker")&&e(this.outerDiv).data("DateTimePicker").date(t)},getShowValue:function(){return this.showValue},setFormat:function(t){this.maskerMeta.format!=t&&(this.maskerMeta.format=t,this.formater=new e.DateFormater(this.maskerMeta.format),this.masker=new DateTimeMasker(this.maskerMeta))},setEnable:function(t){t===!0||"true"===t?(this.enable=!0,e.app||e(this.element).removeAttr("readonly"),e(this.element).attr("h7picker","true")):(t===!1||"false"===t)&&(this.enable=!1,e(this.element).attr("h7picker","false"),e(this.element).attr("readonly","readonly"))},Statics:{compName:"datetime"}}),i=t.extend({initialize:function(i,a,s){var n=this;this.outerDiv=i,i=e(i).find("input")[0],t.superclass.initialize.apply(this,arguments),this.maskerMeta=iweb.Core.getMaskerMeta("date")||{},this.maskerMeta.format=a.format||this.maskerMeta.format,this.dataModel&&this.hasDataTable&&(this.dataModel.refRowMeta(this.field,"format").subscribe(function(e){n.setFormat(e)}),this.maskerMeta.format=this.dataModel.getMeta(this.field,"format")||this.maskerMeta.format),this.validType="date",this.options.picker_type="datecomp",a.format||(this.options.format="YYYY-MM-DD"),this.formater=new e.DateFormater(this.maskerMeta.format),this.masker=new DateMasker(this.maskerMeta),this.create(),this.comp=e(this.outerDiv).datetimepicker(this.options),e(this.element).focusin(function(e){n.setShowValue(n.getValue())}).blur(function(e){!n.doValidate()&&n._needClean()?n.setShowValue(n.getShowValue()):n.setValue(this.value)})},setFormat:function(t){this.maskerMeta.format!=t&&(this.maskerMeta.format=t,this.formater=new e.DateFormater(this.maskerMeta.format),this.masker=new DateMasker(this.maskerMeta))},Statics:{compName:"date"}});e.compManager&&(e.compManager.addPlug(t),e.compManager.addPlug(i))}($),+function(e){var t=e.InputComp.extend({initialize:function(i,a,s){var n=this;t.superclass.initialize.apply(this,arguments);var o=e.getJSObject(s,a.datasource);if(e.isArray(o)){var r=e(this.element).children();if(r.is(":radio")){for(var l=0,h=o.length-1;h>l;l++)r.clone().appendTo(this.element);for(var u=e(this.element).children("[type=radio]"),d=e(this.element).children("[data-role=name]"),c=0;c<u.length;c++)u[c].value=o[c].pk,d[c].innerHTML=o[c].name;this.radioInputName=u[0].name,this.create(),e(this.element).find(":radio[name='"+this.radioInputName+"']").each(function(){e(this).on("click",function(){this.checked&&n.setValue(this.value)})})}}},modelValueChange:function(e){this.slice||this.setValue(e)},setValue:function(i){this.trueValue=i,e(this.element).find(":radio[name='"+this.radioInputName+"']").each(function(){this.value==i?this.checked=!0:this.checked=!1}),this.slice=!0,this.setModelValue(this.trueValue),this.slice=!1,this.trigger(t.EVENT_VALUE_CHANGE,this.trueValue)},getValue:function(){return this.trueValue},Statics:{compName:"radio"}});e.compManager&&e.compManager.addPlug(t)}($),+function(e){var t=e.InputComp.extend({initialize:function(e,i,a){t.superclass.initialize.apply(this,arguments),this.validType="integer",this.max=i.max,this.min=i.min,this.dataModel&&this.hasDataTable&&(this.min=this.dataModel.getMeta(this.field,"min")||this.min,this.max=this.dataModel.getMeta(this.field,"max")||this.max),this.create()},modelValueChange:function(e){this.slice||(e=e||"",this.trueValue=e,this.showValue=e,this.setShowValue(this.showValue))},setValue:function(e){this.trueValue=e,this.showValue=e,this.setShowValue(this.showValue),this.slice=!0,this.setModelValue(this.trueValue),this.slice=!1,this.trigger(t.EVENT_VALUE_CHANGE,this.trueValue)},getValue:function(){return this.trueValue},setShowValue:function(e){this.showValue=e,this.element.value=e},getShowValue:function(){return this.showValue},Statics:{compName:"integer"}});e.compManager&&e.compManager.addPlug(t)}($),+function(e){var t=e.InputComp.extend({initialize:function(i,a,s){var n=this;t.superclass.initialize.apply(this,arguments),this.maskerMeta=iweb.Core.getMaskerMeta("currency")||{},this.maskerMeta.precision=a.precision||this.maskerMeta.precision,this.maskerMeta.curSymbol=a.curSymbol||this.maskerMeta.curSymbol,this.validType="float",this.max=a.max,this.min=a.min,this.dataModel&&this.hasDataTable&&(this.dataModel.refRowMeta(this.field,"precision").subscribe(function(e){n.setPrecision(e)}),this.maskerMeta.precision=this.dataModel.getMeta(this.field,"precision")||this.maskerMeta.precision,this.dataModel.refRowMeta(this.field,"curSymbol").subscribe(function(e){n.setCurSymbol(e)}),this.maskerMeta.curSymbol=this.dataModel.getMeta(this.field,"curSymbol")||this.maskerMeta.curSymbol,this.min=this.dataModel.getMeta(this.field,"min")||this.min,this.max=this.dataModel.getMeta(this.field,"max")||this.max),this.formater=new e.NumberFormater(this.maskerMeta.precision),this.masker=new CurrencyMasker(this.maskerMeta),this.create()},modelValueChange:function(e){e=e||"";var t=this.formater.format(e);this.trueValue=t,this.element.trueValue=this.trueValue,this.showValue=this.masker.format(t).value,this.setShowValue(this.showValue)},setValue:function(e){this.trueValue=this.formater.format(e),this.element.trueValue=this.trueValue,this.showValue=this.masker.format(this.trueValue).value,this.setShowValue(this.showValue),this.setModelValue(this.trueValue),this.trigger(t.EVENT_VALUE_CHANGE,this.trueValue)},getValue:function(){return this.trueValue},setShowValue:function(e){this.showValue=e,this.element.value=e},getShowValue:function(){return this.showValue},setPrecision:function(t){this.maskerMeta.precision!=t&&(this.maskerMeta.precision=t,this.formater=new e.NumberFormater(this.maskerMeta.precision),this.masker=new CurrencyMasker(this.maskerMeta))},setCurSymbol:function(e){this.maskerMeta.curSymbol!=e&&(this.maskerMeta.curSymbol=e,this.masker=new CurrencyMasker(this.maskerMeta))},Statics:{compName:"currency"}});e.compManager&&e.compManager.addPlug(t)}($),+function(e){var t=e.InputComp.extend({initialize:function(a,s,n){var o=this;t.superclass.initialize.apply(this,arguments),this.create();var r=iweb.Core.getLanguages();s.multinfo&&(r=s.multinfo);var l=[];for(this.field=s.field,r.lang_name=s.field,i=0;i<r.length;i++)i?l.push(" "):l.push(" ");this.multinfo=r,this.multidata=l,e(a).multilang({multinfo:r,multidata:l}),this.$element=e(a),this.$element.on("change.u.multilang",function(e,t){o.setModelValue(t)})},create:function(){var e=this;this.dataModel&&(this.hasDataTable?(this.dataModel.ref(this.field).subscribe(function(t){e.modelValueChange(t)}),this.dataModel.refEnable(this.field).subscribe(function(t){e.setEnable(t)}),this.setEnable(this.dataModel.isEnable(this.field))):this.dataModel.subscribe(function(t){e.modelValueChange(t)}),this.modelValueChange(this.hasDataTable?this.dataModel.getValue(this.field):this.dataModel()))},parseDataModel:function(){this.options&&this.options.data&&(this.dataModel=e.getJSObject(this.viewModel,this.options.data),this.dataModel instanceof e.DataTable&&(this.hasDataTable=!0,this.field=this.options.field))},setModelValue:function(e){this.dataModel&&(this.hasDataTable?this.dataModel.setValue(e.field,e.newValue):this.dataModel(e.newValue))},modelValueChange:function(e){var t=this;if(this.multidata){for(t.multidata[0]=e,i=1;i<t.multinfo.length;i++)i&&(t.multidata[i]=t.dataModel.getValue(this.field+(i+1),t.dataTableRow));this.$element.multilang({multidata:t.multidata})}},modelValuelangChange:function(e){},Statics:{compName:"multilang"}});e.compManager&&e.compManager.addPlug(t)}($),+function(e){var t=function(t,i,a){var s=this;this.dataTable=e.getJSObject(a,i.data),this.element=t,this.$element=e(t),!this.dataTable.pageSize()&&i.pageSize&&this.dataTable.pageSize(i.pageSize),i.pageSize=this.dataTable.pageSize()||i.pageSize,this.$element.pagination(i),this.pagination=this.$element.data("u.pagination"),this.pagination.dataTable=this.dataTable,this.$element.on("pageChange",function(t,i){var n=parseInt(e(t.target.lastChild).find(".page_z").val());s.dataTable.pageSize()==n?s.dataTable.cacheCurrentPage():s.dataTable.clearCache(),s.dataTable.hasPage(--i)?s.dataTable.setCurrentPage(i):(s.dataTable.removeAllRows(),a.pageChange&&a.pageChange(i,n))}),this.dataTable.totalPages.subscribe(function(e){s.pagination.update({totalPages:e})}),this.dataTable.pageSize.subscribe(function(e){s.pagination.update({pageSize:e})}),this.dataTable.pageIndex.subscribe(function(e){s.pagination.update({currentPage:e+1})})};t.getName=function(){return"pagination"},e.compManager&&e.compManager.addPlug(t)}($),+function(e){var t=e.InputComp.extend({initialize:function(e,i,a){this.element=e,this.id=i.id,this.options=i,this.viewModel=a,this.e_editor=this.id+"editor",this.render(this.options),t.superclass.initialize.apply(this,arguments),this.create()},render:function(t){var i=t.cols||80,a=t.rows||10,s=this,n='<textarea cols="'+i+'" id="'+this.e_editor+'" name="editor" rows="'+a+'"></textarea>';e(this.element).append(n),e("#"+this.e_editor).ckeditor();var o=CKEDITOR.instances[this.e_editor];this.tmpeditor=o,this.tmpeditor.on("blur",function(){s.setValue(o.getData())}),this.tmpeditor.on("focus",function(){s.setShowValue(s.getValue())})},modelValueChange:function(e){this.slice||(e=e||"",this.trueValue=e,this.showValue=e,this.setShowValue(this.showValue))},setValue:function(e){this.trueValue=e,this.showValue=e,this.setShowValue(this.showValue),this.slice=!0,this.setModelValue(this.trueValue),this.slice=!1,this.trigger(t.EVENT_VALUE_CHANGE,this.trueValue)},getValue:function(){return this.trueValue},setShowValue:function(e){this.showValue=e,this.element.value=e,this.tmpeditor.setData(e)},getShowValue:function(){return this.showValue},getContent:function(){return e("#"+this.e_editor).html()},setContent:function(t){e("#"+this.e_editor).html(t)},Statics:{compName:"editor"}});e.compManager&&e.compManager.addPlug(t)}($),+function(e){var t=e.BaseComponent.extend({initialize:function(t,i,a){if(e.InputComp.superclass.initialize.apply(this,arguments),this.dataModel=null,this.hasDataTable=!1,this.enable=!0,this.parseDataModel(),i.click){var s=e.getJSObject(a,i.click);this.on("click",s)}this.create()},create:function(){var t=this;this.dataModel&&(this.hasDataTable?(this.dataModel.ref(this.field).subscribe(function(e){t.modelValueChange(e)}),this.dataModel.refEnable(this.field).subscribe(function(e){t.setEnable(e)}),this.setEnable(this.dataModel.isEnable(this.field))):this.dataModel.subscribe(function(e){t.modelValueChange(e)}),this.modelValueChange(this.hasDataTable?this.dataModel.getValue(this.field):this.dataModel())),e(this.element).on("click",function(){t.enable&&t.trigger("click",{field:t.field,dataTable:t.dataModel})})},modelValueChange:function(e){this.setValue(e)},parseDataModel:function(){this.options&&this.options.data&&(this.dataModel=e.getJSObject(this.viewModel,this.options.data),this.dataModel instanceof e.DataTable&&(this.hasDataTable=!0,this.field=this.options.field))},setValue:function(t){this.value=t,e(this.element).html(t)},getValue:function(){return this.value},setEnable:function(t){t===!0||"true"===t?(this.enable=!0,e(this.element).css("cursor","pointer")):(t===!1||"false"===t)&&(this.enable=!1,e(this.element).css("cursor","not-allowed"))},Statics:{compName:"link"}});e.compManager&&e.compManager.addPlug(t)}($),+function(e){var t=e.InputComp.extend({initialize:function(i,a,s){var n=this;t.superclass.initialize.apply(this,arguments),this.create(),"TEXTAREA"==this.element.nodeName&&(e(this.element).focusin(function(e){n.setShowValue(n.getValue())}),e(this.element).blur(function(e){n.setValue(n.element.value)}))},modelValueChange:function(e){this.slice||(e=e||"",this.trueValue=e,this.showValue=e,this.setShowValue(this.showValue))},setValue:function(e){this.trueValue=e,this.showValue=e,this.setShowValue(this.showValue),this.slice=!0,this.setModelValue(this.trueValue),this.slice=!1,this.trigger(t.EVENT_VALUE_CHANGE,this.trueValue)},getValue:function(){return this.trueValue},setShowValue:function(e){this.showValue=e,this.element.value=e,this.element.title=e},getShowValue:function(){return this.showValue},Statics:{compName:"textarea"}});e.compManager&&e.compManager.addPlug(t)}($),+function(e){var t=e.InputComp.extend({initialize:function(e,i,a){t.superclass.initialize.apply(this,arguments),this.validType="float",this.max=i.max,this.min=i.min,this.dataModel&&this.hasDataTable&&(this.min=this.dataModel.getMeta(this.field,"min")||this.min,this.max=this.dataModel.getMeta(this.field,"max")||this.max),this.masker=new PercentMasker,this.create()},modelValueChange:function(e){this.slice||(e=e||"",this.trueValue=e,this.showValue=this.masker.format(e).value,this.setShowValue(this.showValue))},setValue:function(e){this.trueValue=e,this.showValue=this.masker.format(e).value,this.setShowValue(this.showValue),this.slice=!0,this.setModelValue(this.trueValue),this.slice=!1,this.trigger(t.EVENT_VALUE_CHANGE,this.trueValue)},getValue:function(){return this.trueValue},setShowValue:function(e){this.showValue=e,this.element.value=e},getShowValue:function(){return this.showValue},Statics:{compName:"percent"}});e.compManager&&e.compManager.addPlug(t)}($),+function($,ko){function _updateDom(e,t){for(var i in t){var a=t[i];for(var s in a){var n=a[s];if("trigger"==s)e.trigger(n[0]);else if($.isArray(n))$.each(n,function(t,i){e[t](i)});else try{e[i](a)}catch(o){e[i](a[i])}}}}var App=function(){this.dataTables={}};App.fn=App.prototype,App.fn.init=function(e,t,i){var a=this;this.element=t||document.body,$(this.element).find("[u-meta]").each(function(){if(!($(this).data("u-meta")||$(this).parents("[u-meta]").length>0)){var t=JSON.parse($(this).attr("u-meta"));if(t&&t.type){a.adjustFunc&&a.adjustFunc.call(a,t);var i=$.compManager._createComp(this,t,e,a);i&&$(this).data("u-meta",i)}}}),$.hotkeys&&$.hotkeys.scan(this.element),_getDataTables(this,e);try{("undefined"==typeof i||1==i)&&ko.applyBindings(e,this.element)}catch(s){iweb.log.error(s)}},App.fn.setAdjustMetaFunc=function(e){this.adjustFunc=e},App.fn.addDataTable=function(e){return this.dataTables[e.id]=e,this},App.fn.getDataTable=function(e){return this.dataTables[e]},App.fn.getDataTables=function(){return this.dataTables},App.fn.getComp=function(e){var t=null;return $(this.element).find("[u-meta]").each(function(){if($(this).data("u-meta")){var i=$(this).data("u-meta");if(i.id==e)return t=i,!1}}),t},App.fn.getCompsByDataTable=function(e,t){
for(var i=this.getComps(t),a=[],s=0;s<i.length;s++)(i[s].dataModel&&i[s].dataModel.id==e||i[s].dataTable&&i[s].dataTable.id==e)&&a.push(i[s]);return a},App.fn.getComps=function(e){e=e?e:this.element;var t=[];return $(e).find("[u-meta]").each(function(){if($(this).data("u-meta")){var e=$(this).data("u-meta");e&&t.push(e)}}),t},App.fn.compsValidate=function(e){for(var t=this.getComps(e),i=!0,a=0;a<t.length;a++)t[a].doValidate&&(i=t[a].doValidate(!0)&&i);return i},App.fn.getCompsByType=function(e,t){t=t?t:this.element;var i=[];return $(t).find("[u-meta]").each(function(){if($(this).data("u-meta")){var t=$(this).data("u-meta");t&&t.type==e&&i.push(t)}}),i},App.fn.getEnvironment=function(){return window.iweb.Core.collectEnvironment()},App.fn.setClientAttribute=function(e,t){window.iweb.Core.setClientAttribute(e,t)},App.fn.getClientAttribute=function(e){window.iweb.Core.getClientAttributes()[e]},App.fn.serverEvent=function(){return new ServerEvent(this)},App.fn.ajax=function(e){e=this._wrapAjax(e),$.ajax(e)},App.fn._wrapAjax=function(e){var t=this,i=e.success,a=e.error,s=e.deferred;return s&&s.resolve||(s={resolve:function(){},reject:function(){}}),e.success=function(e,a,n){processXHRError(t,e,a,n)?(i.call(null,e),t._successFunc(e,s)):s.reject()},e.error=function(e,i,n){processXHRError(t,e,i,n)?(a.call(null,e),t._successFunc(e,s)):s.reject()},e.data?e.data.environment=ko.toJSON(window.iweb.Core.collectEnvironment()):e.data={environment:ko.toJSON(window.iweb.Core.collectEnvironment())},e},App.fn._successFunc=function(e,t){t.resolve()},window.processXHRError=function(rsl,state,xhr){return"string"==typeof rsl&&(rsl=JSON.parse(rsl)),xhr.getResponseHeader&&xhr.getResponseHeader("X-Error")?($.showMessageDialog({type:"info",title:"提示",msg:rsl.message,backdrop:!0}),rsl.operate&&eval(rsl.operate),!1):!0},App.fn.setUserCache=function(e,t){var i=this.getEnvironment().usercode;i&&localStorage.setItem(i+e,t)},App.fn.getUserCache=function(e){var t=this.getEnvironment().usercode;if(t)return localStorage.getItem(t+e)},App.fn.removeUserCache=function(e){var t=this.getEnvironment().usercode;t&&localStorage.removeItem(t+e)},App.fn.setCache=function(e,t){localStorage.setItem(e,t)},App.fn.getCache=function(e){return localStorage.getItem(e)},App.fn.removeCache=function(e){localStorage.removeItem(e)},App.fn.setSessionCache=function(e,t){sessionStorage.setItem(e,t)},App.fn.getSessionCache=function(e){return sessionStorage.getItem(e)},App.fn.removeSessionCache=function(e){sessionStorage.removeItem(e)},App.fn.setEnable=function(e){$(this.element).find("[u-meta]").each(function(){if($(this).data("u-meta")){var t=$(this).data("u-meta");t.setEnable&&t.setEnable(e)}})};var ServerEvent=function(e){this.app=e,this.datas={},this.params={},this.event=null,this.ent=window.iweb.Core.collectEnvironment(),window.pako&&0==iweb.debugMode&&(this.compression=!0)};ServerEvent.DEFAULT={async:!0,singleton:!0,url:(window.$ctx||"/iwebap")+"/evt/dispatch"},ServerEvent.fn=ServerEvent.prototype,ServerEvent.fn.addDataTable=function(e,t){var i=this.app.getDataTable(e);return this.datas[e]=i.getDataByRule(t),this},ServerEvent.fn.setCompression=function(e){window.pako||1!=e?this.compression=e:iweb.log.error("can't compression, please include pako!")},ServerEvent.fn.addDataTables=function(e){if(2==arguments.length)for(var t=0;t<e.length;t++){var i;"string"==typeof arguments[1]?i=arguments[1]:"array"==$.type(arguments[1])&&(i=arguments[1][t]),this.addDataTable(e[t],i)}else for(var t=0;t<e.length;t++){var a=e[t];if("string"==typeof a)this.addDataTable(a);else for(key in a)this.addDataTable(key,a[key])}return this},ServerEvent.fn.addAllDataTables=function(e){for(var t=this.app.dataTables,i=0;i<t.length;i++)this.addDataTable(t[i].id,e)},ServerEvent.fn.addParameter=function(e,t){return this.params[e]=t,this},ServerEvent.fn.setEvent=function(e){return this.event=e,this};var _formatEvent=function(e){return e};ServerEvent.fn.fire=function(e){var t=this,i=this.getData();i.parameters=ko.toJSON(this.params);var a={type:e.type||"POST",data:e.params||{},url:e.url||ServerEvent.DEFAULT.url,async:"undefined"==typeof e.async?ServerEvent.DEFAULT.async:e.async,singleton:e.singleton||ServerEvent.DEFAULT.singleton,success:e.success,error:e.error,dataType:"json"};a.data.ctrl=e.ctrl,a.data.method=e.method,this.event&&(a.data.event=ko.toJSON(this.event));var s=a.preSuccess||function(){},n=a.success||function(){},o=a.error;this.orignError=o;var r=a.deferred;r&&r.resolve||(r={resolve:function(){},reject:function(){}}),a.success=function(e,i,a){processXHRError(t,e,i,a)?(s.call(null,e),t._successFunc(e,r),n.call(null,e.custom),r.resolve()):r.reject()},a.error=function(e,i,a){processXHRError(t,e,i,a)?o&&o.call(null,e.custom):r.reject()},a.data=$.extend(a.data,i),$.ajax(a)},ServerEvent.fn.getData=function(){var e=ko.toJSON(this.app.getEnvironment()),t=ko.toJSON(this.datas),i="";return this.compression&&(window.isSwfCompressReady()?(e=window.swfCompress(e),t=window.swfCompress(t),i="deflate"):(e=encodeBase64(window.pako.gzip(e)),t=encodeBase64(window.pako.gzip(t)),i="gzip")),{environment:e,dataTables:t,compression:this.compression,compressType:i}},ServerEvent.fn._successFunc=function(e,t){var i=e.dataTables,a=e.dom;a&&this.updateDom(JSON.parse(a)),i&&this.updateDataTables(i,t)},ServerEvent.fn.updateDataTables=function(e,t){for(var i in e){var a=this.app.getDataTable(i);a&&(a.setData(e[i]),a.updateMeta(e[i].meta))}},ServerEvent.fn.setSuccessFunc=function(e){this._successFunc=e},ServerEvent.fn.updateDom=function(){$.each(dom,function(e,t){var i=t.two,a=$(t.one);_updateDom(a,i)})};var processXHRError=function(self,rsl,state,xhr){if("string"==typeof rsl&&(rsl=JSON.parse(rsl)),xhr.getResponseHeader&&xhr.getResponseHeader("X-Error")){if(!self.orignError)return $.showMessageDialog?$.showMessageDialog({type:"info",title:"提示",msg:rsl.message,backdrop:!0}):alert(rsl.message),rsl.operate&&eval(rsl.operate),!1;self.orignError.call(self,rsl,state,xhr)}return!0};$.createApp=function(){var e=new App;return e};var _getDataTables=function(e,t){for(var i in t)t[i]instanceof $.DataTable&&(t[i].id=i,t[i].parent=t,e.addDataTable(t[i]))}}($,ko);