| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426 |
- Ext.QuickTips.init();
- Ext.define('erp.controller.scm.purchase.AcceptNotify', {
- 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','scm.purchase.AcceptNotify','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.Flow','core.trigger.MultiDbfindTrigger','core.button.VastTurnAccept',
- 'core.button.GridWin','core.button.TurnPurcProdIO','core.button.BackAll',
- 'core.trigger.DbfindTrigger','core.trigger.TextAreaTrigger','core.form.YnField'
- ],
- init:function(){
- var me = this;
- this.control({
- 'erpGridPanel2': {
- itemclick: this.onGridItemClick
- },
- '#updateacceptqty': {
- click: function(btn) {
- var record = btn.ownerCt.ownerCt.getSelectionModel().getLastSelected();
- me.updatebackqty(record);
- }
- },
- 'erpBackAllButton':{
- click:function(btn){
- warnMsg('该操作将拒收明细所有物料,确认拒收?', function(btn){
- if(btn == 'yes'){
- me.FormUtil.setLoading(true);
- var id=Ext.getCmp('an_id').getValue();
- Ext.Ajax.request({
- url : basePath + 'scm/purchase/backAll.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){
- showMessage('提示', '拒收成功!', 1000);
- window.location.reload();
- } else {
- delFailure();
- }
- }
- });
- }
- });
- }
- },
- 'erpGridWinButton':{
- afterrender: function(btn){
- var id = Ext.getCmp('an_id').value;
- btn.setConfig({
- text: '费用明细',
- caller: 'ProdChargeDetail!AN',
- condition: 'pd_anid=' + id,
- paramConfig: {
- pd_anid: id
- }
- });
- },
- beforesave : function(btn) {
- var f = btn.ownerCt.ownerCt, p = f.down('field[name=an_statuscode]');
- if (p && 'TURNIN' == p.getValue()) {
- Ext.Msg.alert("提示","该单据已入库,不能修改费用明细!");
- return false;
- }
- return true;
- }
- },
- 'erpSaveButton': {
- click: function(btn){
- var me = this;
- var form = me.getForm(btn);
- var grid = Ext.getCmp('grid'), items = grid.store.data.items;
- var whcode = Ext.getCmp('an_whcode'), whname = Ext.getCmp('an_whname');
- if(Ext.getCmp(form.codeField).value == null || Ext.getCmp(form.codeField).value == ''){
- me.BaseUtil.getRandomNumber();//自动添加编号
- }
- Ext.Array.each(items, function(item){
- if(!Ext.isEmpty(item.data['and_prodcode'])){
- if(whcode && item.data['and_whcode'] == null || item.data['and_whcode'] == ''){
- item.set('and_whcode', whcode.value);
- item.set('and_whname', whname.value);
- }
- }
- });
- this.FormUtil.beforeSave(this);
- }
- },
- 'erpDeleteButton' : {
- click: function(btn){
- me.FormUtil.onDelete(Ext.getCmp('an_id').value);
- }
- },
- 'erpUpdateButton': {
- click: function(btn){
- var me = this;
- var grid = Ext.getCmp('grid'), items = grid.store.data.items;
- var whcode = Ext.getCmp('an_whcode'), whname = Ext.getCmp('an_whname');
- Ext.Array.each(items, function(item){
- if(!Ext.isEmpty(item.data['and_prodcode'])){
- if(whcode && item.data['and_whcode'] == null || item.data['and_whcode'] == ''){
- item.set('and_whcode', whcode.value);
- item.set('and_whname', whname.value);
- }
- }
- });
- this.FormUtil.onUpdate(this);
- }
- },
- 'erpAddButton': {
- click: function(){
- me.FormUtil.onAdd('addAcceptNotify', '新增采购通知单', 'jsps/scm/purchase/acceptNotify.jsp');
- }
- },
- 'erpCloseButton': {
- click: function(btn){
- me.FormUtil.beforeClose(me);
- }
- },
- 'erpSubmitButton': {
- afterrender: function(btn){
- var status = Ext.getCmp('an_statuscode');
- if(status && status.value != 'ENTERING'){
- btn.hide();
- }
- },
- click: function(btn){
- me.FormUtil.onSubmit(Ext.getCmp('an_id').value);
- }
- },
- 'erpResSubmitButton': {
- afterrender: function(btn){
- var status = Ext.getCmp('an_statuscode');
- if(status && status.value != 'COMMITED'){
- btn.hide();
- }
- },
- click: function(btn){
- me.FormUtil.onResSubmit(Ext.getCmp('an_id').value);
- }
- },
- 'erpAuditButton': {
- afterrender: function(btn){
- var status = Ext.getCmp('an_statuscode');
- if(status && status.value != 'COMMITED'){
- btn.hide();
- }
- },
- click: function(btn){
- me.FormUtil.onAudit(Ext.getCmp('an_id').value);
- }
- },
- 'erpResAuditButton': {
- afterrender: function(btn){
- var status = Ext.getCmp('an_statuscode');
- if(status && status.value != 'AUDITED'){
- btn.hide();
- }
- },
- click: function(btn){
- me.FormUtil.onResAudit(Ext.getCmp('an_id').value);
- }
- },
- 'erpPrintButton': {
- click: function(btn){
- var reportName = '';
- reportName = "vendororder";
- var condition = '{AcceptNotify.an_id}=' + Ext.getCmp('an_id').value + '';
- var id = Ext.getCmp('an_id').value;
- me.FormUtil.onwindowsPrint(id, reportName, condition);
- }
- },
- 'field[name=an_currency]': {
- beforetrigger: function(field) {
- var t = field.up('form').down('field[name=an_date]'),
- value = t.getValue();
- if(value) {
- field.findConfig = 'cm_yearmonth=' + Ext.Date.format(value, 'Ym');
- }
- }
- },
- 'erpVastTurnAcceptButton':{
- afterrender: function(btn){
- var status = Ext.getCmp('an_statuscode');
- if(status && status.value != 'AUDITED' && status.value != 'PART2VA'){
- btn.hide();
- }
- },
- click: function(btn){
- warnMsg("确定要转入采购收料单吗?", function(btn){
- if(btn == 'yes'){
- me.FormUtil.getActiveTab().setLoading(true);//loading...
- Ext.Ajax.request({
- url : basePath + 'scm/purchase/turnVerifyApply.action',
- params: {
- id: Ext.getCmp('an_id').value
- },
- method : 'post',
- callback : function(options,success,response){
- me.FormUtil.getActiveTab().setLoading(false);
- var r = new Ext.decode(response.responseText);
- if(r.exceptionInfo){
- showError(r.exceptionInfo);
- }
- if(r.success){
- turnSuccess(function(){
- var id = r.id;
- var url = "jsps/scm/purchase/verifyApply.jsp?whoami=VerifyApply&formCondition=va_id=" + id + "&gridCondition=vad_vaid=" + id;
- me.FormUtil.onAdd('VerifyApply' + id, '采购收料单' + id, url);
- });
- }
- }
- });
- }
- });
- }
- },
- 'erpTurnPurcProdIOButton':{
- afterrender: function(btn){
- var status = Ext.getCmp('an_statuscode');
- if(status && status.value != 'AUDITED'){
- btn.hide();
- }
- },
- click: function(btn){
- warnMsg("确定要转入采购验收单吗?", function(btn){
- if(btn == 'yes'){
- var id = Ext.getCmp('an_id').value;
- me.FormUtil.setLoading(true);//loading...
- Ext.Ajax.request({
- url : basePath + 'scm/purchase/turnProdio.action',
- params: {
- id: id
- },
- method : 'post',
- callback : function(options,success,response){
- me.FormUtil.setLoading(false);
- var r = new Ext.decode(response.responseText);
- if(r.exceptionInfo){
- showError(r.exceptionInfo);
- } else {
- if(r.log) {
- showMessage('提示', r.log);
- var grid = Ext.getCmp('grid');
- grid.GridUtil.loadNewStore(grid, {
- caller: caller,
- condition: 'and_anid=' + id
- });
- }
- }
- }
- });
- }
- });
- }
- },
- 'dbfindtrigger[name=and_ordercode]': {
- focus: function(t){
- t.setHideTrigger(false);
- t.setReadOnly(false);
- if(Ext.getCmp('an_vendcode')){
- var code = Ext.getCmp('an_vendcode').value;
- if(code != null && code != ''){
- t.dbBaseCondition = "pu_vendcode" + "='" + code + "'";
- }
- }
- },
- aftertrigger: function(t, r) {
- if(Ext.getCmp('an_vendcode')){
- var obj = me.getCodeCondition();
- if(obj && obj.fields){
- me.FormUtil.getFieldsValue(obj.tablename, obj.fields, obj.myfield + "='" + t.value + "'", obj.tFields);
- }
- }
- }
- },
- 'multidbfindtrigger[name=and_orderdetno]': {
- focus: function(t){
- t.setHideTrigger(false);
- t.setReadOnly(false);//用disable()可以,但enable()无效
- var record = Ext.getCmp('grid').selModel.lastSelected;
- var code = record.data['and_ordercode'];
- if(code == null || code == ''){
- showError("请先选择关联单号!");
- t.setHideTrigger(true);
- t.setReadOnly(true);
- } else {
- t.dbBaseCondition = "pd_code='" + code + "'";
- }
- }
- },
- 'dbfindtrigger[name=and_orderdetno]': {
- focus: function(t){
- t.setHideTrigger(false);
- t.setReadOnly(false);//用disable()可以,但enable()无效
- var record = Ext.getCmp('grid').selModel.lastSelected;
- var code = record.data['and_ordercode'];
- if(code == null || code == ''){
- showError("请先选择关联单号!");
- t.setHideTrigger(true);
- t.setReadOnly(true);
- } else {
- t.dbBaseCondition = "pd_code='" + code + "'";
- }
- }
- }
- });
- },
- getCodeCondition: function(){
- var field = "pu_vendcode";
- var tFields = 'an_cardcode,an_vendname,an_currency,an_rate,an_paymentcode,an_payment,an_transport,an_paydate,an_receivecode,an_receivename';
- var fields = 'pu_vendcode,pu_vendname,pu_currency,pu_rate,pu_paymentscode,pu_payments,pu_transport,pu_suredate,pu_receivecode,pu_receivename';
- var tablename = 'Purchase';
- var myfield = 'pu_code';
- var obj = new Object();
- obj.field = field;
- obj.fields = fields;
- obj.tFields = tFields;
- obj.tablename = tablename;
- obj.myfield = myfield;
- return obj;
- },
- updatebackqty: function(record) {
- var me = this;
- var win=Ext.create('Ext.window.Window', {
- width: 430,
- height: 250,
- closeAction: 'destroy',
- title: '<h1>更改收料数量</h1>',
- layout: {
- type: 'vbox'
- },
- items: [{
- margin: '5 0 0 5',
- xtype: 'numberfield',
- fieldLabel: '数量',
- name: 'QTYREPLY',
- hideTrigger: true,
- value: record.data.and_inqty,
- id: 'QTYREPLY'
- }],
- buttonAlign: 'center',
- buttons: [{
- xtype: 'button',
- text: '保存',
- width: 60,
- iconCls: 'x-button-icon-save',
- handler: function(btn) {
- var w = btn.up('window');
- me.saveInfo(w);
- win.close();
- win.destroy();
- }
- },
- {
- xtype: 'button',
- columnWidth: 0.1,
- text: '关闭',
- width: 60,
- iconCls: 'x-button-icon-close',
- margin: '0 0 0 10',
- handler: function(btn) {
- var win = btn.up('window');
- win.close();
- win.destroy();
- }
- }]
- });
- win.show();
- },
- saveInfo: function(w) {
- var qty = w.down('field[name=QTYREPLY]').getValue();
- grid = Ext.getCmp('grid'),
- record = grid.getSelectionModel().getLastSelected();
- if (qty == null || qty < 0) {
- showError('请先设置修改数量');
- return;
- } else {
- var dd = {
- and_id: record.data.and_id,
- and_inqty: qty ? qty: 0
- };
- Ext.Ajax.request({
- url: basePath + 'scm/purchase/saveAcceptNotifyQty.action',
- params: {
- data: unescape(Ext.JSON.encode(dd)),
- caller: caller
- },
- method: 'post',
- callback: function(opt, s, res) {
- var r = new Ext.decode(res.responseText);
- if (r.success) {
- grid.GridUtil.loadNewStore(grid, {
- caller: caller,
- condition: gridCondition
- });
- showMessage('提示', '更新成功!', 1000);
- } else if (r.exceptionInfo) {
- showError(r.exceptionInfo);
- } else {
- saveFailure();
- }
- }
- });
- }
- },
- onGridItemClick: function(selModel, record) { //grid行选择
- if (record.data.and_id != 0 && record.data.and_id != null && record.data.and_id != '' && (record.data.and_yqty==0 || record.data.and_yqty==null )) {
- var btn = Ext.getCmp('updateacceptqty');
- btn && btn.setDisabled(false);
- }
- this.GridUtil.onGridItemClick(selModel, record);
- },
- getForm: function(btn){
- return btn.ownerCt.ownerCt;
- }
- });
|