123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167 |
- MWF.xApplication.Selector = MWF.xApplication.Selector || {};
- MWF.xDesktop.requireApp("Selector", "Person", null, false);
- MWF.xApplication.Selector.QueryTable = new Class({
- Extends: MWF.xApplication.Selector.Person,
- options: {
- "style": "default",
- "count": 0,
- "title": "",
- "values": [],
- "names": [],
- "expand": false,
- "forceSearchInItem" : true
- },
- setInitTitle: function(){
- this.setOptions({"title": MWF.xApplication.Selector.LP.selectTable});
- },
- _init : function(){
- this.selectType = "querytable";
- this.className = "QueryTable";
- },
- loadSelectItems: function(addToNext){
- this.queryAction.listApplication(function(json){
- if (json.data.length){
- json.data.each(function(data){
- if (!data.tableList){
- this.queryAction.listTable(data.id, function(tablesJson){
- data.tableList = tablesJson.data;
- }.bind(this), null, false);
- }
- if (data.tableList && data.tableList.length){
- var category = this._newItemCategory(data, this, this.itemAreaNode);
- data.tableList.each(function(d){
- d.applicationName = data.name;
- if( d.name ){
- d.nativeTableName = "QRY_DYN_" + d.name.toUpperCase();
- }
- var item = this._newItem(d, this, category.children);
- this.items.push(item);
- }.bind(this));
- }
- }.bind(this));
- }
- }.bind(this));
- },
- _scrollEvent: function(y){
- return true;
- },
- _getChildrenItemIds: function(data){
- return data.tableList || [];
- },
- _newItemCategory: function(data, selector, item, level){
- return new MWF.xApplication.Selector.QueryTable.ItemCategory(data, selector, item, level)
- },
- _listItemByKey: function(callback, failure, key){
- return false;
- },
- _getItem: function(callback, failure, id, async){
- this.queryAction.getTable(function(json){
- if (callback) callback.apply(this, [json]);
- }.bind(this), failure, ((typeOf(id)==="string") ? id : id.id), async);
- },
- _newItemSelected: function(data, selector, item){
- return new MWF.xApplication.Selector.QueryTable.ItemSelected(data, selector, item)
- },
- _listItemByPinyin: function(callback, failure, key){
- return false;
- },
- _newItem: function(data, selector, container, level){
- return new MWF.xApplication.Selector.QueryTable.Item(data, selector, container, level);
- }
- });
- MWF.xApplication.Selector.QueryTable.Item = new Class({
- Extends: MWF.xApplication.Selector.Person.Item,
- _getShowName: function(){
- return this.data.name + "(" + this.data.nativeTableName + ")";
- },
- _setIcon: function(){
- this.iconNode.setStyle("background-image", "url("+"../x_component_Selector/$Selector/default/icon/table.png)");
- },
- loadSubItem: function(){
- return false;
- },
- checkSelectedSingle: function(){
- var selectedItem = this.selector.options.values.filter(function(item, index){
- if (typeOf(item)==="object"){
- if( this.data.id && item.id ){
- return this.data.id === item.id;
- }else{
- return this.data.name === item.name;
- }
- //return (this.data.id === item.id) || (this.data.name === item.name) ;
- }
- //if (typeOf(item)==="object") return (this.data.id === item.id) || (this.data.name === item.name) ;
- if (typeOf(item)==="string") return (this.data.id === item) || (this.data.name === item);
- return false;
- }.bind(this));
- if (selectedItem.length){
- this.selectedSingle();
- }
- },
- checkSelected: function(){
- var selectedItem = this.selector.selectedItems.filter(function(item, index){
- if( item.data.id && this.data.id){
- return item.data.id === this.data.id;
- }else{
- return item.data.name === this.data.name;
- }
- //return (item.data.id === this.data.id) || (item.data.name === this.data.name);
- }.bind(this));
- if (selectedItem.length){
- //selectedItem[0].item = this;
- selectedItem[0].addItem(this);
- this.selectedItem = selectedItem[0];
- this.setSelected();
- }
- }
- });
- MWF.xApplication.Selector.QueryTable.ItemSelected = new Class({
- Extends: MWF.xApplication.Selector.Person.ItemSelected,
- _getShowName: function(){
- return this.data.name;
- },
- _setIcon: function(){
- this.iconNode.setStyle("background-image", "url("+"../x_component_Selector/$Selector/default/icon/table.png)");
- },
- check: function(){
- if (this.selector.items.length){
- var items = this.selector.items.filter(function(item, index){
- //return (item.data.id === this.data.id) || (item.data.name === this.data.name);
- if( item.data.id && this.data.id){
- return item.data.id === this.data.id;
- }else{
- return item.data.name === this.data.name;
- }
- }.bind(this));
- this.items = items;
- if (items.length){
- items.each(function(item){
- item.selectedItem = this;
- item.setSelected();
- }.bind(this));
- }
- }
- }
- });
- MWF.xApplication.Selector.QueryTable.ItemCategory = new Class({
- Extends: MWF.xApplication.Selector.Person.ItemCategory,
- _getShowName: function(){
- return this.data.name;
- },
- createNode: function(){
- this.node = new Element("div", {
- "styles": this.selector.css.selectorItemCategory_department
- }).inject(this.container);
- },
- _setIcon: function(){
- this.iconNode.setStyle("background-image", "url("+"../x_component_Selector/$Selector/default/icon/applicationicon.png)");
- },
- _hasChild: function(){
- return (this.data.tableList && this.data.tableList.length);
- },
- check: function(){}
- });
|