123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345 |
- /**
- * 修改客户UU按钮
- */
- Ext.define('erp.view.core.button.CustomerUU', {
- extend : 'Ext.Button',
- alias : 'widget.erpCustomerUUButton',
- iconCls : 'x-btn-uu-medium',
- cls : 'x-btn-gray',
- text : $I18N.common.button.erpCustomerUUButton,
- style : {
- marginLeft : '10px'
- },
- width : 120,
- initComponent : function() {
- this.callParent(arguments);
- },
- listeners: {
- afterrender: function(btn) {
- var status = Ext.getCmp('cu_auditstatuscode');
- if(status && status.value == 'ENTERING'){
- btn.hide();
- }
- }
- },
- handler: function() {
- var me = this, win = Ext.getCmp('customeruu-win');
- if(!win) {
- var f = Ext.getCmp('cu_uu'),
- id = Ext.getCmp('cu_id').getValue(), uu = f ? f.value : null;
- me.isEnable(id, function(enable){
- var items = [me.createCheckForm(uu, enable)];
- if(!enable)
- items.push(me.createCheckGrid());
- win = Ext.create('Ext.Window', {
- id: 'customeruu-win',
- title: '设置客户 ' + Ext.getCmp('cu_code').value + ' 的UU号',
- width: '80%',
- items: items,
- closeAction: 'hide',
- modal: true,
- autoShow: true
- });
- if(!enable)
- me.check(uu);
- });
- } else
- win.show();
- },
- createCheckForm: function(uu, enable) {
- var me = this;
- return new Ext.form.Panel({
- xtype: 'form',
- height: 120,
- bodyStyle: 'background:#f1f2f5;',
- layout: 'hbox',
- fieldDefaults: {
- margin: '15'
- },
- items: [{
- xtype: 'numberfield',
- name:'cu_uu',
- fieldLabel: '客户UU号',
- hideTrigger: true,
- readOnly: enable,
- value: uu,
- flex: 3
- },{
- xtype: 'displayfield',
- flex: 4,
- id: 'b2benable',
- fieldCls: 'x-form-field-help',
- checkedIcon: 'x-button-icon-agree',
- uncheckedIcon: 'x-button-icon-unagree',
- value: (enable ? '<i class="x-button-icon-agree"></i>验证通过' : null),
- setChecked: function(checked) {
- this.checked = checked;
- this.setValue(('<i class="' + (checked ? this.checkedIcon : this.uncheckedIcon) + '"></i>') +
- (checked ? '验证通过' : '验证失败'));
- }
- }],
- buttonAlign: 'center',
- buttons: [{
- text: '检测',
- cls: 'x-btn-gray',
- hidden: enable,
- handler: function(btn) {
- var form = btn.ownerCt.ownerCt,
- a = form.down('numberfield[name=cu_uu]');
- if(a.value) {
- me.check(a.value);
- } else
- form.down('#b2benable').setChecked(false);
- }
- }, {
- text: $I18N.common.button.erpSaveButton,
- cls: 'x-btn-gray',
- handler: function(btn) {
- var form = btn.ownerCt.ownerCt,
- a = form.down('numberfield[name=cu_uu]');
-
- if(a.value) {
- me.onConfirm(Ext.getCmp('cu_id').value, a.value);
- } else
- form.down('#b2benable').setChecked(false);
- }
- }, {
- text: $I18N.common.button.erpCloseButton,
- cls: 'x-btn-gray',
- handler: function(btn) {
- btn.up('window').hide();
- }
- }]
- });
- },
- createCheckGrid: function() {
- var me = this;
- return new Ext.grid.Panel({
- xtype: 'grid',
- title: '查找平台注册企业资料',
- height: 400,
- columnLines: true,
- columns: [{
- text: '企业名称',
- dataIndex: 'name',
- cls: 'x-grid-header-1',
- flex: 5,
- renderer: function(val, meta, record, x, y, store, view) {
- var c = view.ownerCt.searchConfig;
- if(c && c.name) {
- if(val.length > c.name.length)
- val = val.replace(c.name, '<font style="color:#c00">' + c.name + '</font>');
- else if(c.name.indexOf(val) > -1)
- val = '<font style="color:#c00">' + val + '</font>';
- }
- return val;
- }
- },{
- text: '简称',
- dataIndex: 'shortName',
- cls: 'x-grid-header-1',
- flex: 2,
- renderer: function(val, meta, record, x, y, store, view) {
- var c = view.ownerCt.searchConfig;
- if(c && c.shortName) {
- if(val.length > c.shortName.length)
- val = val.replace(c.shortName, '<font style="color:#c00">' + c.shortName + '</font>');
- else if(c.shortName.indexOf(val) > -1)
- val = '<font style="color:#c00">' + val + '</font>';
- }
- return val;
- }
- },{
- text: 'UU',
- xtype: 'numbercolumn',
- dataIndex: 'uu',
- flex: 2,
- cls: 'x-grid-header-1',
- align: 'right',
- renderer: function(val, meta, record, x, y, store, view) {
- var c = view.ownerCt.searchConfig;
- if(c && c.uu && val == c.uu) {
- val = '<font style="color:#c00">' + val + '</font>';
- }
- return val;
- }
- },{
- text: '地址',
- dataIndex: 'address',
- cls: 'x-grid-header-1',
- flex: 5
- },{
- text: '操作',
- xtype:'actioncolumn',
- cls: 'x-grid-header-1',
- flex: 1,
- align: 'center',
- items: [{
- icon: basePath + 'resource/images/32/select.png',
- tooltip: '选择',
- handler: function(grid, rowIndex, colIndex) {
- me.selectRecord(grid, grid.getStore().getAt(rowIndex));
- }
- }]
- }],
- features : [Ext.create('Ext.grid.feature.Grouping',{
- groupHeaderTpl: '按{name}查找到的全部可能结果:'
- })],
- store: new Ext.data.Store({
- fields: ['group','name','shortName','uu'],
- groupField: 'group'
- }),
- html: '<p class="x-grid-empty alert">没有查找到匹配的企业,您的供应商还未注册<a href="http://www.ubtob.com" target="_blank">优软商务平台</a>或您填写的供应商资料有误,请联系供应商确认!</p>' +
- '<p class="x-grid-tip alert arrow-border arrow-bottom-right">从查找到的结果中选择正确的供应商信息<a href="javascript:void(0);" class="pull-right close">知道了×</a></p>',
- checkEmpty: function(checked) {
- var empEl = this.getEl().select('.x-grid-empty'), tipEl = this.getEl().select('.x-grid-tip');
- empEl.applyStyles({'display': this.store.getCount() == 0 ? 'block' : 'none'});
- tipEl.applyStyles({'display': !checked && this.store.getCount() > 0 ? 'block' : 'none'});
- if(!checked && this.store.getCount() > 0) {
- Ext.EventManager.on(tipEl.el.dom.childNodes[1], {
- click: function(event, el) {
- tipEl.applyStyles({'display': 'none'});
- Ext.EventManager.stopEvent(event);
- },
- buffer: 50
- });
- }
- }
- });
- },
- onConfirm: function(veId, uu) {
- var me = this, grid = Ext.getCmp('customeruu-win').down('grid');
- if(!grid)
- me.updateVendorUU(veId, uu, null, null, 1);
- else {
- if(me.selectedConfig && me.selectedConfig.uu == uu)
- me.updateVendorUU(veId, uu, me.selectedConfig.name, me.selectedConfig.shortName, dev, 1);
- else
- me.check(uu, function(checked){
- if(checked)
- me.updateVendorUU(veId, uu, null, null, 1);
- else
- warnMsg('UU号还未验证通过,是否继续保存?', function(btn){
- if(btn == 'yes')
- me.updateVendorUU(veId, uu, null, null, 0);
- });
- });
- }
- },
- updateVendorUU: function(veId, uu, name, shortName, checked) {
- Ext.Ajax.request({
- url: basePath + 'scm/customer/updateUU.action',
- params: {
- id: veId,
- uu: uu,
- name: name,
- shortName: shortName,
- checked: checked
- },
- callback: function(opt, s, r) {
- var rs = Ext.decode(r.responseText);
- if(rs.exceptionInfo) {
- showError(rs.exceptionInfo);
- } else {
- alert('设置成功!');
- window.location.reload();
- }
- }
- });
- },
- check: function(uu, callback) {
- var name = Ext.getCmp('cu_name').getValue(), shortName = Ext.getCmp('cu_shortname').getValue();
- var grid = Ext.getCmp('customeruu-win').down('grid'), me = this;
- if(grid) {
- grid.setLoading(true);
- this.getMembers(name, shortName, uu, function(data){
- var s = [], checked = false;
- if(data) {
- for(var k in data) {
- Ext.Array.each(data[k], function(d){
- d.group = k == 'name' ? ('名称(' + name + ')') : (k == 'shortName' ?
- ('简称(' + shortName + ')') : ('UU号(' + uu + ')'));
- s.push(d);
- });
- if(!checked && k == 'uu' && data[k])
- checked = true;
- }
- }
- grid.searchConfig = {name: name, shortName: shortName, uu: uu};
- me.selectedConfig = null;
- grid.store.loadData(s);
- grid.checkEmpty(checked);
- Ext.getCmp('b2benable').setChecked(checked);
- grid.setLoading(false);
- callback && callback.call(null, checked);
- });
- }
- },
- isEnable: function(veId, callback) {
- Ext.Ajax.request({
- url : basePath + 'common/getFieldData.action',
- params: {
- caller: 'Customer',
- field: 'cu_b2benable',
- condition: 'cu_id=' + veId
- },
- method : 'post',
- callback : function(opt, s, res){
- var r = new Ext.decode(res.responseText);
- if(r.exceptionInfo){
- showError(r.exceptionInfo);
- }
- callback && callback.call(null, (!r.data || r.data != 1) ? false : true);
- }
- });
- },
- getMembers: function(name, shortName, uu, callback) {
- Ext.Ajax.request({
- url: basePath + 'b2b/queriable/members.action',
- params: {
- name: name,
- shortName: shortName,
- uu: uu
- },
- method: 'GET',
- callback: function(opt, s, r) {
- var d = [];
- if(r && r.responseText) {
- var rs = Ext.decode(r.responseText);
- if(rs.exceptionInfo) {
- showError(rs.exceptionInfo);
- } else
- d = rs;
- }
- callback.call(null, d);
- }
- });
- },
- selectRecord: function(grid, record) {
- var win = grid.up('window'), u = win.down('field[name=cu_uu]'), e = win.down('#b2benable')
- _n = Ext.getCmp('cu_name').getValue(), _t = Ext.getCmp('cu_shortname').getValue(), me = this;
- u.setValue(record.get('uu'));
- e.setChecked(true);
- me.selectedConfig = {uu: record.get('uu')};
- var s = '', n = record.get('name'), t = record.get('shortName');
- if(_n) {
- if(_n != n)
- s = '客户名称【' + _n + '】与您选择的企业注册信息【' + n + '】不一致,是否按平台的企业注册信息修改?<br>';
- } else {
- me.selectedConfig.name = n;// 为空时,直接写入
- }
- if(_t) {
- if(_t != t)
- s += '客户名称简称【' + _t + '】与您选择的企业注册信息【' + t + '】不一致,是否按平台的企业注册信息修改?<br>';
- } else {
- me.selectedConfig.shortName = t;// 为空时,直接写入
- }
- if(s.length > 0)
- warnMsg(s, function(btn){
- if(btn == 'yes') {
- me.selectedConfig.name = n;
- me.selectedConfig.shortName = t;
- }
- });
- }
- });
|