| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147 |
- Ext.QuickTips.init();
- Ext.define('erp.controller.scm.product.GetUUid', {
- extend: 'Ext.app.Controller',
- FormUtil: Ext.create('erp.util.FormUtil'),
- BaseUtil: Ext.create('erp.util.BaseUtil'),
- views:[
- 'scm.product.GetUUid.ProductB2CKindTree','scm.product.GetUUid.Viewport',
- 'scm.product.GetUUid.ComponentGrid','scm.product.GetUUid.Toolbar','core.trigger.SearchField'
- ],
- init:function(){
- var me = this;
- lastSelected = null;
- me.lastCode = '';
- me.codeisnull = true;
- this.control({
- 'prodb2ckindtree': {
- itemmousedown: function(selModel, record){
- me.loadTab(selModel, record);
- lastSelected = record;
- },
- itemdblclick: function(view, record){
- lastSelected = record;
- var btn = Ext.getCmp('confirm');
- btn.fireEvent('click', btn);
- }
- },
- 'button[name=search]': {//根据原厂型号查找
- click: function(btn){
- me.search();
- }
- },
- 'textfield[name=orispecode]':{
- specialkey : function(field, e){
- if(e.getKey() == Ext.EventObject.ENTER){
- me.search();
- }
- }
- },
- 'button[name=close]': {//关闭
- click: function(){
- parent.Ext.getCmp('uuWin').close();
- }
- }
- });
- },
- loadTab: function(selModel, record){
- var me = this;
- var tree = Ext.getCmp('tree-panel');
- var parentId='';
- if (record.get('leaf')) {
- parentId=record.data['parentid'];
- //叶子节点
- Ext.getCmp('uuIdGrid').getGridData(record.data['id'],page,pageSize);
- } else {
- Ext.getCmp('uuIdGrid').store.loadData("");
- if(record.isExpanded() && record.childNodes.length > 0){//是根节点,且已展开
- record.collapse(true,true);//收拢
- } else {//未展开
- //看是否加载了其children
- if(record.childNodes.length == 0){
- //从后台加载
- tree.setLoading(true, tree.body);
- Ext.Ajax.request({//拿到tree数据
- url : basePath + tree.getUrl(),
- params: {
- parentid: record.data['id'],
- type:type
- },
- async: false,
- callback : function(options,success,response){
- tree.setLoading(false);
- var res = new Ext.decode(response.responseText);
- if(res.tree){
- record.appendChild(res.tree);
- record.expand(false,true);//展开
- } else if(res.exceptionInfo){
- showError(res.exceptionInfo);
- }
- }
- });
- } else {
- record.expand(false,true);//展开
- }
- }
- }
- tree.getExpandedItems(record);
- Ext.each(tree.expandedNodes, function(){
- if(!this.data['leaf'] && this.data['parentId']==parentId )
- this.collapse(true,true);
- });
- me.lastCode = '';
- var choose = new Array();
- tree.getExpandedItems(record);
- Ext.each(tree.expandedNodes, function(){
- me.lastCode += this.data['qtip'];
- choose.push(this.data['text']);
- });
- var c = Ext.getCmp('choose');
- c.show();
- c.update({nodes: choose});
- me.codeisnull = true;
- },
- getUrl: function(){
- type = type || 'Product';
- var url = 'scm/product/getProductKindNum.action';
- return url;
- },
-
- search:function(){
- var f = Ext.getCmp("orispecode"), tree = Ext.getCmp('tree-panel');
- if(f.value == '' || f.value == null){
- tree.getTreeRootNode(0);
- return;
- }
- tree.setLoading(true, tree.body);
- Ext.Ajax.request({//拿到tree数据
- url : basePath +'scm/product/searchByOrispecode.action?_noc=1',
- timeout:120000,
- params: {
- code: f.value,
- caller:caller
- },
- callback : function(options,success,response){
- tree.setLoading(false);
- var res = new Ext.decode(response.responseText);
- if(res.tree){
- var root = tree.getRootNode();
- root.removeAll();
- var fn = function(node, ch) {
- for(var i in ch) {
- var n = ch[i], chs = n.children;
- n.children = [];
- n.expanded = true;
- var d = node.appendChild(n);
- if(d && chs && chs.length > 0 && String(chs) != '[]') {
- fn(d, chs);
- }
- }
- };
- fn(root, res.tree);
- } else if(res.exceptionInfo){
- Ext.Msg.alert("ERROR:" + res.exceptionInfo);
- }
- }
- });
- }
- });
|