123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247 |
- Ext.QuickTips.init();
- Ext.define('erp.controller.scm.sale.PreCustomer', {
- extend: 'Ext.app.Controller',
- FormUtil: Ext.create('erp.util.FormUtil'),
- BaseUtil: Ext.create('erp.util.BaseUtil'),
- views:[
- 'scm.sale.PreCustomer','core.form.Panel','core.form.FileField','core.form.MultiField',
- 'core.button.Save','core.button.Add','core.button.Submit','core.button.Print','core.button.Upload','core.button.ResAudit',
- 'core.button.Audit','core.button.Close','core.button.Delete','core.button.Update','core.button.ResSubmit',
- 'core.button.TurnCustomer','core.button.TurnFKCustomer','core.button.Flow','core.button.DownLoad','core.button.Scan',
- 'core.trigger.DbfindTrigger','core.trigger.TextAreaTrigger','core.form.YnField','core.trigger.AutoCodeTrigger','core.form.CascadingCityField'
- ],
- init:function(){
- var me = this;
- this.control({
- 'erpSaveButton': {
- click: function(btn){
- var form = me.getForm(btn),
- codeField = Ext.getCmp(form.codeField), kind =Ext.getCmp('cu_kind').value;
- if(codeField.value == null || codeField.value == ''){
- //var res = me.getLeadCode(kind);
- var res = me.getCode(kind);
- if(res != null && res != ''){
- //codeField.setValue(res + codeField.getValue());
- codeField.setValue(res);
- } else
- me.BaseUtil.getRandomNumber('Customer',10,null);//自动添加编号
- }
- var cust = Ext.getCmp('cu_code').value, custname = Ext.getCmp('cu_name').value,
- shcustcode = Ext.getCmp('cu_shcustcode').value, arcode=Ext.getCmp('cu_arcode').value;
- cust = cust != null ? cust.toUpperCase() : null;
- if(shcustcode == null || shcustcode == ''){
- Ext.getCmp('cu_shcustcode').setValue(cust);
- Ext.getCmp('cu_shcustname').setValue(custname);
- }
- if(arcode == null || arcode == ''){
- Ext.getCmp('cu_arcode').setValue(cust);
- Ext.getCmp('cu_arname').setValue(custname);
- }
- this.FormUtil.beforeSave(this);
-
- }
- },
- 'erpDeleteButton' : {
- click: function(btn){
- me.FormUtil.onDelete(Ext.getCmp('cu_id').value);
- }
- },
- 'erpUpdateButton': {
- click: function(btn){
- var cust = Ext.getCmp('cu_code').value, custname = Ext.getCmp('cu_name').value,
- shcustcode = Ext.getCmp('cu_shcustcode').value, arcode=Ext.getCmp('cu_arcode').value;
- cust = cust != null ? cust.toUpperCase() : null;
- if(shcustcode == null || shcustcode == ''){
- Ext.getCmp('cu_shcustcode').setValue(cust);
- Ext.getCmp('cu_shcustname').setValue(custname);
- }
- if(arcode == null || arcode == ''){
- Ext.getCmp('cu_arcode').setValue(cust);
- Ext.getCmp('cu_arname').setValue(custname);
- }
- this.FormUtil.onUpdate(this);
- }
- },
- 'erpAddButton': {
- click: function(){
- me.FormUtil.onAdd('addPreCustomer', '新增客户资料', 'jsps/scm/sale/preCustomer.jsp');
- }
- },
- 'erpCloseButton': {
- click: function(btn){
- me.FormUtil.beforeClose(me);
- }
- },
- 'erpSubmitButton': {
- afterrender: function(btn){
- var status = Ext.getCmp('cu_auditstatuscode');
- if(status && status.value != 'ENTERING'){
- btn.hide();
- }
- },
- click: function(btn){
- me.FormUtil.onSubmit(Ext.getCmp('cu_id').value);
- }
- },
- 'erpResSubmitButton': {
- afterrender: function(btn){
- var status = Ext.getCmp('cu_auditstatuscode');
- if(status && status.value != 'COMMITED'){
- btn.hide();
- }
- },
- click: function(btn){
- me.FormUtil.onResSubmit(Ext.getCmp('cu_id').value);
- }
- },
- 'erpAuditButton': {
- afterrender: function(btn){
- var status = Ext.getCmp('cu_auditstatuscode');
- if(status && status.value != 'COMMITED'){
- btn.hide();
- }
- },
- click: function(btn){
- me.FormUtil.onAudit(Ext.getCmp('cu_id').value);
- }
- },
- 'erpResAuditButton': {
- afterrender: function(btn){
- var status = Ext.getCmp('cu_auditstatuscode');
- if(status && status.value != 'AUDITED'){
- btn.hide();
- }
- },
- click: function(btn){
- me.FormUtil.onResAudit(Ext.getCmp('cu_id').value);
- }
- },
- 'erpPrintButton': {
- click: function(btn){
- me.FormUtil.onPrint(Ext.getCmp('cu_id').value);
- }
- },
- 'erpTurnFKCustomerButton':{
- afterrender: function(btn){
- var status = Ext.getCmp('cu_auditstatuscode');
- if(status && status.value != 'TURNED'){
- btn.hide();
- }
- },
- click:function(){
- var cu_code=Ext.getCmp('cu_code').value;
- var formCondition="cu_code='"+cu_code+"'";
- var gridCondition="shi_cucode='"+cu_code+"'";
- var linkCaller='Customer!BaseFP';
- me.FormUtil.onAdd('Customer!BaseFP', '风控客户资料', 'jsps/fa/fp/customerBaseFP.jsp?_noc=1&whoami='+linkCaller+'&formCondition='+formCondition+'&gridCondition='+gridCondition);
- }
- },
- 'erpTurnCustomerButton': {
- afterrender: function(btn){
- var status = Ext.getCmp('cu_auditstatuscode');
- if(status && status.value != 'AUDITED'){
- btn.hide();
- }
- },
- click: function(btn){
- warnMsg("确定要转入客户吗?", function(btn){
- if(btn == 'yes'){
- me.FormUtil.getActiveTab().setLoading(true);//loading...
- Ext.Ajax.request({
- url : basePath + 'scm/sale/turnCustomer.action',
- params: {
- id: Ext.getCmp('cu_id').value
- },
- method : 'post',
- callback : function(options,success,response){
- me.FormUtil.getActiveTab().setLoading(false);
- var localJson = new Ext.decode(response.responseText);
- if(localJson.exceptionInfo){
- showError(localJson.exceptionInfo);
- }
- if(localJson.success){
- turnSuccess(function(){
- var id = localJson.id;
- var url = "jsps/scm/sale/customerBase.jsp?formCondition=cu_id=" + id;
- me.FormUtil.onAdd('Customer' + id, '客户' + id, url);
- window.loaction.href = window.loaction.href;
- });
- }
- }
- });
- }
- });
- }
- }
- });
- },
- getForm: function(btn){
- return btn.ownerCt.ownerCt;
- },
- getSetting : function(fn) {
- var me = this;
- Ext.Ajax.request({
- url : basePath + 'common/getFieldData.action',
- async: false,
- params: {
- caller: 'Setting',
- field: 'se_value',
- condition: 'se_what=\'CustCodeType\''
- },
- method : 'post',
- callback : function(opt, s, res){
- var r = new Ext.decode(res.responseText);
- var t = false;
- if(r.exceptionInfo){
- showError(r.exceptionInfo);return;
- }
- if(r.success && r.data){
- t = r.data == 'true';
- }
- fn.call(me, t);
- }
- });
- },
- getLeadCode: function(type) {
- var result = null;
- Ext.Ajax.request({
- url : basePath + 'common/getFieldData.action',
- async: false,
- params: {
- caller: 'CustomerKind',
- field: 'ck_excode',
- condition: 'ck_kind=\'' + type + '\''
- },
- method : 'post',
- callback : function(opt, s, res){
- var r = new Ext.decode(res.responseText);
- if(r.exceptionInfo){
- showError(r.exceptionInfo);return;
- } else if(r.success){
- result = r.data;
- }
- }
- });
- return result;
- },
- getCode: function(type) {
- var result = null;
- Ext.Ajax.request({
- url : basePath + 'scm/sale/getCustomerCodeNum.action',
- async: false,
- params: {
- cu_kind: type
- },
- method : 'post',
- callback : function(opt, s, res){
- var r = new Ext.decode(res.responseText);
- if(r.exceptionInfo){
- showError(r.exceptionInfo);return;
- } else if(r.success){
- result = r.number;
- }
- }
- });
- return result;
- }
- });
|