| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302 |
- Ext.QuickTips.init();
- Ext.define('erp.controller.pm.mould.AppMould', {
- extend: 'Ext.app.Controller',
- FormUtil: Ext.create('erp.util.FormUtil'),
- GridUtil: Ext.create('erp.util.GridUtil'),
- BaseUtil: Ext.create('erp.util.BaseUtil'),
- views:[
- 'core.form.Panel','pm.mould.AppMould','core.grid.Panel2','core.toolbar.Toolbar','core.form.MultiField',
- 'core.button.Save','core.button.Add','core.button.Submit','core.button.Print','core.button.ResAudit',
- 'core.button.Audit','core.button.Close','core.button.Delete','core.button.Update','core.button.DeleteDetail','core.button.ResSubmit',
- 'core.button.TurnOffPrice','core.form.FileField','core.button.TurnSale',
- 'core.trigger.TextAreaTrigger','core.trigger.DbfindTrigger','core.form.YnField',
- 'core.grid.YnColumn', 'core.grid.YnColumnNV'
- ],
- init:function(){
- var me = this;
- this.control({
- 'erpGridPanel2': {
- afterrender: function(grid){
- var status = Ext.getCmp('app_statuscode');
- if(status && status.value != 'ENTERING' && status.value != 'COMMITED'){
- Ext.each(grid.columns, function(c){
- c.setEditor(null);
- });
- }
- },
- itemclick: this.onGridItemClick
- },
- /**
- * 更改是否报价
- */
- '#updateoffer': {
- click: function(btn) {
- var record=btn.ownerCt.ownerCt.getSelectionModel().getLastSelected();
- me.UpdateOffer(record);
- }
- },
- 'erpSaveButton': {
- click: function(btn){
- var form = me.getForm(btn);
- if(Ext.getCmp(form.codeField).value == null || Ext.getCmp(form.codeField).value == ''){
- me.BaseUtil.getRandomNumber();//自动添加编号
- }
- this.FormUtil.beforeSave(this);
- }
- },
- 'erpDeleteButton' : {
- click: function(btn){
- me.FormUtil.onDelete(Ext.getCmp('app_id').value);
- }
- },
- 'erpUpdateButton': {
- afterrender: function(btn){
- var status = Ext.getCmp('app_statuscode');
- if(status && status.value != 'ENTERING'){
- btn.hide();
- }
- },
- click: function(btn){
- this.FormUtil.onUpdate(this);
- }
- },
- 'erpAddButton': {
- click: function(){
- me.FormUtil.onAdd('addAppMould', '新增开模申请单', 'jsps/pm/mould/appMould.jsp');
- }
- },
- 'erpCloseButton': {
- click: function(btn){
- me.FormUtil.beforeClose(me);
- }
- },
- 'erpSubmitButton': {
- afterrender: function(btn){
- var status = Ext.getCmp('app_statuscode');
- if(status && status.value != 'ENTERING'){
- btn.hide();
- }
- },
- click: function(btn){
- me.FormUtil.onSubmit(Ext.getCmp('app_id').value);
- }
- },
- 'erpResSubmitButton': {
- afterrender: function(btn){
- var status = Ext.getCmp('app_statuscode');
- if(status && status.value != 'COMMITED'){
- btn.hide();
- }
- },
- click: function(btn){
- me.FormUtil.onResSubmit(Ext.getCmp('app_id').value);
- }
- },
- 'erpAuditButton': {
- afterrender: function(btn){
- var status = Ext.getCmp('app_statuscode');
- if(status && status.value != 'COMMITED'){
- btn.hide();
- }
- },
- click: function(btn){
- me.FormUtil.onAudit(Ext.getCmp('app_id').value);
- }
- },
- 'erpResAuditButton': {
- afterrender: function(btn){
- var status = Ext.getCmp('app_statuscode');
- if(status && status.value != 'AUDITED'){
- btn.hide();
- }
- },
- click: function(btn){
- me.FormUtil.onResAudit(Ext.getCmp('app_id').value);
- }
- },
- 'erpPrintButton': {
- click: function(btn){
- me.FormUtil.onPrint(Ext.getCmp('app_id').value);
- }
- },
- 'erpTurnSaleButton':{
- afterrender: function(btn){
- var status = Ext.getCmp('app_statuscode'), turnstatus = Ext.getCmp('app_turnsalecode');
- if(status && status.value != 'AUDITED'){
- btn.hide();
- }
- if(turnstatus && turnstatus.value == 'TURNSA'){
- btn.hide();
- }
- },
- click: function(btn){
- warnMsg("确定要转入模销售单吗?", function(btn){
- if(btn == 'yes'){
- var id = Ext.getCmp('app_id').value;
- me.FormUtil.setLoading(true);
- Ext.Ajax.request({
- url : basePath + 'pm/mould/turnMouldSale.action',
- params: {
- id: id
- },
- method : 'post',
- callback : function(options,success,response){
- me.FormUtil.setLoading(false);
- var localJson = new Ext.decode(response.responseText);
- if(localJson.exceptionInfo){
- showError(localJson.exceptionInfo);
- return "";
- }
- if(localJson.success){
- if(localJson.log){
- showMessage("提示", localJson.log);
- }
- window.location.reload();
- }
- }
- });
- }
- });
- }
- },
- 'erpTurnOffPriceButton':{
- afterrender: function(btn){
- var status = Ext.getCmp('app_statuscode'), turnstatus = Ext.getCmp('app_turnpricecode');
- if(status && status.value != 'AUDITED'){
- btn.hide();
- }
- if(turnstatus && turnstatus.value == 'TURNPM'){
- btn.hide();
- }
- },
- click: function(btn){
- warnMsg("确定要转入模具报价单吗?", function(btn){
- if(btn == 'yes'){
- me.FormUtil.getActiveTab().setLoading(true);//loading...
- Ext.Ajax.request({
- url : basePath + 'pm/mould/turnPriceMould.action',
- params: {
- id: Ext.getCmp('app_id').value
- },
- method : 'post',
- callback : function(o, s, res){
- me.FormUtil.getActiveTab().setLoading(false);
- var r = new Ext.decode(res.responseText);
- if(r.exceptionInfo){
- showError(r.exceptionInfo);
- }
- if(r.success && r.id){
- var id = r.id, msg = '模具报价单号:<br>';
- for(var i in id) {
- msg += '<a href="javascript:openUrl(\'jsps/pm/mould/priceMould.jsp?formCondition=pd_id='
- + id[i].id + '&gridCondition=pmd_pdid=' + id[i].id + '\');">' + id[i].code + '</a><hr>';
- }
- showMessage('提示', msg);
- }
- }
- });
- }
- });
- }
- }
- });
- },
- UpdateOffer:function(record){
- var win = this.window;
- if (!win) {
- win = this.window = this.getWindow(record);
- }
- win.show();
- },
- getWindow : function(record) {
- var me = this;
- return Ext.create('Ext.window.Window',{
- width: 330,
- height: 180,
- closeAction: 'hide',
- cls: 'custom-blue',
- title:'<h1>更改是否报价</h1>',
- layout: {
- type: 'vbox'
- },
- items:[{
- margin: '5 0 0 5',
- xtype: 'erpYnField',
- fieldLabel: '是否报价',
- id:'isoffer',
- name: 'isoffer',
- readOnly:false,
- allowBlank: false,
- value : record.data.ad_isoffer
- }],
- buttonAlign:'center',
- buttons:[{
- xtype:'button',
- text:'保存',
- width:60,
- iconCls: 'x-button-icon-save',
- handler:function(btn){
- var w = btn.up('window');
- me.saveOffer(w);
- w.hide();
- }
- },{
- xtype:'button',
- columnWidth:0.1,
- text:'关闭',
- width:60,
- iconCls: 'x-button-icon-close',
- margin:'0 0 0 10',
- handler:function(btn){
- btn.up('window').hide();
- }
- }]
- });
- },
- saveOffer: function(w) {
- var isoffer = w.down('#isoffer').getValue(),
- grid = Ext.getCmp('grid'),
- app_id = Ext.getCmp('app_id').value,
- record = grid.getSelectionModel().getLastSelected();
- if(!isoffer) {
- showError('请先选择是否报价.') ;
- return;
- } else {
- var dd = {
- ad_id : record.data.ad_id,
- ad_appid : app_id,
- isoffer : isoffer ? isoffer : 1
- };
- Ext.Ajax.request({
- url : basePath +'pm/mould/updateIsOffer.action',
- params : {
- _noc: 1,
- data: unescape(Ext.JSON.encode(dd))
- },
- method : 'post',
- callback : function(opt, s, res){
- var r = new Ext.decode(res.responseText);
- if(r.success){
- showMessage('提示', '更新成功!', 1000);
- grid.GridUtil.loadNewStore(grid, {caller: 'AppMould', condition: 'ad_appid=' + app_id});
- } else if(r.exceptionInfo){
- showError(r.exceptionInfo);
- } else{
- saveFailure();
- }
- }
- });
- }
- },
- onGridItemClick: function(selModel, record){//grid行选择
- var id = record.get('ad_id');
- if(!Ext.isEmpty(id) && id != 0) {
- var btn = Ext.getCmp('updateoffer');
- btn && btn.setDisabled(false);
- }
- this.GridUtil.onGridItemClick(selModel, record);
- },
- getForm: function(btn){
- return btn.ownerCt.ownerCt;
- }
- });
|