| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162 |
- Ext.QuickTips.init();
- Ext.define('erp.controller.pm.make.DecomSetting', {
- extend: 'Ext.app.Controller',
- FormUtil: Ext.create('erp.util.FormUtil'),
- BaseUtil: Ext.create('erp.util.BaseUtil'),
- GridUtil: Ext.create('erp.util.GridUtil'),
- views:[
- 'pm.make.DecomSetting','core.form.Panel','pm.make.DecomSettingGrid','common.datalist.Toolbar',
- 'core.button.DownloadTemp','core.button.SNimport','core.button.ClearSN','core.button.UpExcel',
- 'core.button.Close','core.button.LoadParts','core.button.UpdateMaterial','core.form.YnField'
- ],
- init:function(){
- var me = this;
- me.BaseUtil = Ext.create('erp.util.BaseUtil');
- me.GridUtil = Ext.create('erp.util.GridUtil');
- this.control({
- 'erpFormPanel': {
- afterload: function(form) {
- var items = form.items.items;
- Ext.each(items, function(item) {
- item.setReadOnly(true);
- });
- }
- },
- '#re_code': {
- afterrender: function(field){
- me.loadData(field.value);
- }
- },
- '#ma_screcode': {
- afterrender: function(field){
- me.loadData(field.value);
- }
- },
- 'erpLoadPartsButton':{
- afterrender: function(btn){
- var status;
- if(caller == 'DecomSetting'){
- status = Ext.getCmp('re_statuscode');
- if(status && status.value != 'ENTERING' && status.value != 'COMMITED'){
- btn.hide();
- }
- }else{
- status = Ext.getCmp('ma_statuscode');
- if(status && status.value != 'ENTERING' && status.value != 'COMMITED'){
- btn.hide();
- }
- }
- },
- click: function(btn){
- /*var grid = Ext.getCmp('grid');
- var ms_sncode;
- var items = grid.getStore().data.items;//获取store里面的数据
- if(items[0].data['rd_sncode'] != null && items[0].data['rd_sncode'] != '' ){
- ms_sncode = items[0].data['rd_sncode'];
- } */
- var ma_code ;
- var re_code ;
- if(caller == 'DecomSetting'){
- ma_code = Ext.getCmp('re_rwmo').value;
- re_code = Ext.getCmp('re_code').value;
- }else{
- ma_code = Ext.getCmp('ma_code').value;
- re_code = Ext.getCmp('ma_screcode').value;
- }
- var dbwin = new Ext.window.Window({
- id : 'zrbjwin',
- title: '载入部件',
- height: "100%",
- width: "100%",
- maximizable : true,
- buttonAlign : 'center',
- layout : 'anchor',
- items: []
- });
- dbwin.show();
- var iframe = dbwin.getEl().down('iframe');
- if(!iframe) {
- dbwin.add({
- tag : 'iframe',
- frame : true,
- anchor : '100% 100%',
- layout : 'fit',
- html : '<iframe src="#" height="100%" width="100%" frameborder="0" scrolling="auto"></iframe>'
- });
- iframe = dbwin.getEl().down('iframe');
- }
- iframe.dom.src = basePath+'jsps/pm/make/loadingParts.jsp?whoami=LoadingParts&gridCondition=msd_recodeIS'+"'"+re_code+"' and ms_makecodeIS'"+ma_code+"'";
- }
- },
- 'erpUpdateMaterialButton':{
- afterrender: function(btn){
- var status;
- if(caller == 'DecomSetting'){
- status = Ext.getCmp('re_statuscode');
- if(status && status.value != 'ENTERING' && status.value != 'COMMITED'){
- btn.hide();
- }
- }else{
- status = Ext.getCmp('ma_statuscode');
- if(status && status.value != 'ENTERING' && status.value != 'COMMITED'){
- btn.hide();
- }
- }
- },
- click: function(btn){
- var grids = Ext.ComponentQuery.query('gridpanel');
- var s2 = '';
- if(grids.length > 0 && !grids[0].ignore){//check所有grid是否已修改
- Ext.each(grids, function(grid, index){
- if(grid.GridUtil){
- var msg = grid.GridUtil.checkGridDirty(grid);
- if(msg.length > 0){
- s2 = s2 + '<br/>' + msg;
- }
- }
- });
- }
- if(s2 == '' || s2 == '<br/>'){
- showError('还未添加或修改数据.');
- return;
- }
- this.FormUtil.onUpdate(this);
- }
- },
- 'erpCloseButton' : {
- click : function(btn) {
- me.FormUtil.beforeClose(me);
- }
- }
- });
- },
- onGridItemClick : function(selModel, record) {//grid行选择
- this.GridUtil.onGridItemClick(selModel, record);
- },
- getForm : function(btn) {
- return btn.ownerCt.ownerCt;
- },
- loadData: function(value) {
- var me = this;
- me.FormUtil.getFieldsValues("MakeSNDecompose left join product on pr_code=msd_fsoncode",
- ' msd_id,msd_fsoncode, pr_detail,pr_spec,msd_stepcode', "msd_recode='" +value+"' order by msd_id asc", [], function(data){
- var datas = Ext.JSON.decode(data), _datas = [];
- var grid = Ext.getCmp('grid');
- if(datas.length > 0) {
- var keys = Ext.Object.getKeys(datas[0]);
- Ext.Array.each(datas, function(d){
- var obj = {};
- Ext.Array.each(keys, function(key){
- obj[key.toLowerCase()] = d[key];
- });
- _datas.push(obj);
- });
- }
- store = grid.getStore();
- _datas.length > 0 && grid.store.loadData(_datas);
- grid.store.each(function(){
- this.dirty = true;
- });
- });
- }
- });
|