| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188 |
- Ext.QuickTips.init();
- Ext.define('erp.controller.b2c.BrandInApply', {
- extend: 'Ext.app.Controller',
- FormUtil: Ext.create('erp.util.FormUtil'),
- BaseUtil: Ext.create('erp.util.BaseUtil'),
- views:[
- 'b2c.BrandInApply','core.form.Panel','core.form.FileField',
- 'core.button.Add','core.button.Save','core.button.Close',
- 'core.button.Submit','core.button.ResSubmit','core.button.Audit','core.button.ResAudit',
- 'core.button.Update','core.button.Delete','core.form.YnField',
- 'core.trigger.TextAreaTrigger','core.trigger.DbfindTrigger'
- ],
- init:function(){
- var me = this;
- _nobutton=getUrlParam('_nobutton');
- this.control({
- '#form':{
- beforeshow:function(f){
- me.getData(f);
- }
- },
- 'erpSaveButton': {
- click: function(btn){
- var form = me.getForm(btn);
- if(Ext.getCmp(form.codeField).value == null || Ext.getCmp(form.codeField).value == ''){
- me.BaseUtil.getRandomNumber();//自动添加编号
- }
- if(form.keyField){
- if(Ext.getCmp(form.keyField).value == null || Ext.getCmp(form.keyField).value == ''){
- me.FormUtil.getSeqId(form);
- }
- }
- me.save(btn);
- }
- },
- '#br_statuscode':{
- change:function(field,newvalue){
- var form=field.ownerCt,toolbar=form.down('toolbar');
- if(newvalue && toolbar){
- switch(newvalue){
- case 'COMMITED':
- toolbar.down('erpSaveButton').hide();
- toolbar.down('erpUpdateButton').hide();
- toolbar.down('erpSubmitButton').hide();
- toolbar.down('erpResAuditButton').hide();
- break;
- case 'AUDITED':
- toolbar.down('erpSaveButton').hide();
- toolbar.down('erpUpdateButton').hide();
- toolbar.down('erpSubmitButton').hide();
- toolbar.down('erpResSubmitButton').hide();
- toolbar.down('erpAuditButton').hide();
- break;
- default:
- toolbar.down('erpSaveButton').hide();
- toolbar.down('erpResSubmitButton').hide();
- toolbar.down('erpAuditButton').hide();
- toolbar.down('erpResAuditButton').hide();
- }
- }
- }
- },
- 'erpCloseButton': {
- click: function(btn){
- this.FormUtil.beforeClose(this);
- }
- },
- 'erpUpdateButton': {
- click: function(btn){
- me.update(btn);
- },
- afterrender:function (btn){
- var status = Ext.getCmp('br_statuscode'),
- br_id = Ext.getCmp("br_id");
- if(br_id && (br_id.value != '' && br_id.value != null) && status && status.value!='ENTERING'){
- btn.hide();
- }
- }
- },
- 'erpDeleteButton': {
- click: function(btn){
- me.FormUtil.onDelete(Ext.getCmp('br_id').value);
- }
- },
- 'erpAddButton': {
- click: function(){
- me.FormUtil.onAdd('addBrandInApply', '新增品牌入库申请', 'jsps/b2c/brandInApply.jsp');
- }
- },
- 'erpSubmitButton': {
- click: function(btn){
- me.FormUtil.submit(Ext.getCmp('br_id').value);
- }
- },
- 'erpResSubmitButton': {
- click: function(btn){
- me.FormUtil.onResSubmit(Ext.getCmp('br_id').value);
- }
- },
- 'erpAuditButton': {
- click: function(btn){
- me.FormUtil.onAudit(Ext.getCmp('br_id').value);
- }
- },
- 'erpResAuditButton': {
- click: function(btn){
- me.FormUtil.onResAudit(Ext.getCmp('br_id').value);
- }
- }
- });
- },
- getForm: function(btn){
- return btn.ownerCt.ownerCt;
- },
- save:function(btn){
- var me = this;
- var form = Ext.getCmp('form');
- //判断必填项是否都已经填写
- me.FormUtil.checkForm();
- var r = form.getValues();
- //去除ignore字段
- var keys = Ext.Object.getKeys(r), f;
- var reg = /[!@#$%^&*()'":,\/?]|[\t|\n|\r]/g;
- Ext.each(keys, function(k){
- f = form.down('#' + k);
- if(k == form.codeField && !Ext.isEmpty(r[k])) {
- r[k] = r[k].trim().toUpperCase().replace(reg, '');
- }
- if(k == 'br_application'){
- r[k]= Ext.getCmp('br_application').getValue()['br_application'].toString();
- }
- });
- Ext.Ajax.request({
- url : basePath + 'b2c/product/saveBrandInApply.action',
- params: {
- caller: caller,
- formStore:unescape(escape(Ext.JSON.encode(r)))
- },
- method : 'post',
- callback : function(options,success,response){
- var localJson = new Ext.decode(response.responseText);
- if(localJson.exceptionInfo){
- showError(localJson.exceptionInfo);
- }
- if(localJson.success){
- formCondition = "br_id="+Ext.getCmp("br_id").value;
- window.location.href = window.location.href +"?formCondition="+formCondition;
- }
- }
- });
- },
- update :function(btn){
- var me = this;
- var form = Ext.getCmp('form');
- //判断必填项是否都已经填写
- me.FormUtil.checkForm();
- var r = form.getValues();
- //去除ignore字段
- var keys = Ext.Object.getKeys(r), f;
- var reg = /[!@#$%^&*()'":,\/?]|[\t|\n|\r]/g;
- Ext.each(keys, function(k){
- f = form.down('#' + k);
- if(k == form.codeField && !Ext.isEmpty(r[k])) {
- r[k] = r[k].trim().toUpperCase().replace(reg, '');
- }
- if(k == 'br_application'){
- r[k]= Ext.getCmp('br_application').getValue()['br_application'].toString();
- }
- });
- Ext.Ajax.request({
- url : basePath + 'b2c/product/updateBrandInApply.action',
- params: {
- caller: caller,
- formStore:unescape(escape(Ext.JSON.encode(r)))
- },
- method : 'post',
- callback : function(options,success,response){
- var localJson = new Ext.decode(response.responseText);
- if(localJson.exceptionInfo){
- showError(localJson.exceptionInfo);
- }
- if(localJson.success){
- window.location.href = window.location.href ;
- }
- }
- });
- }
- });
|