Ext.QuickTips.init();
Ext.define('erp.controller.scm.reserve.ProdInOut', {
extend: 'Ext.app.Controller',
requires: ['erp.util.FormUtil', 'erp.util.GridUtil', 'erp.util.BaseUtil'],
views:[
'core.form.Panel','scm.reserve.ProdInOut','core.grid.Panel2','core.toolbar.Toolbar','core.form.MultiField','core.form.YnField',
'core.button.Save','core.button.Add','core.button.Submit','core.button.Print','core.button.PrintA4','core.button.Upload','core.button.ResAudit',
'core.button.Audit','core.button.Close','core.button.Delete','core.button.Update','core.button.DeleteDetail','core.button.ResSubmit',
'core.button.Banned','core.button.ResBanned','core.button.Post','core.button.ResPost','core.button.Query','core.button.GetPrice',
'core.button.RePrice','core.button.BussAccount','core.button.Export','core.form.FtFindField','core.form.ConDateField','core.button.UpdateWHCode',
'core.button.FeeShare', 'core.button.TurnDefectOut','core.button.Resetbatch','core.button.PrintwithPrice','core.button.tecai','core.button.GridWin',
'core.button.TurnExOut', 'core.trigger.DbfindTrigger','core.trigger.MultiDbfindTrigger','core.trigger.TextAreaTrigger','core.button.TurnProdinoutReturn',
'core.button.TurnProdinoutIn','core.button.UpdatePdprice', 'core.button.PrintNoPrice', 'core.button.PrintPrice','core.form.FileField','core.button.TurnOutReturn',
'core.button.Split','core.button.TurnReturn','core.button.PrintBar','core.button.Printotherin','core.button.Printotherout', 'core.button.TurnProdOut',
'core.button.TurnOtherIn', 'core.button.TurnOtherOut', 'core.button.TurnOtherPurcOut','core.button.TurnAppropriationOut','core.button.TurnCustReturnOut',
'core.button.ClearSubpackage','core.button.Subpackage','core.grid.YnColumn','core.button.CatchBatch','core.button.Printnosale','core.button.PrintNoCustomer',
'core.button.SetMMQTY','core.button.TurnSaleReturn','core.button.TurnMrb','core.button.Barcode','core.button.TurnReturnMake','core.button.SendData'
],
init:function(){
var me = this;
var grid = Ext.getCmp('grid');
me.FormUtil = Ext.create('erp.util.FormUtil');
me.GridUtil = Ext.create('erp.util.GridUtil');
me.BaseUtil = Ext.create('erp.util.BaseUtil');
this.control({
'erpTurnReturnMakeButton':{//销售退货转返修工单
afterrender:function(btn){
var status = Ext.getCmp(me.getForm(btn).statuscodeField),
postStatus = Ext.getCmp('pi_statuscode');
if((status && status.value != 'AUDITED')||(postStatus&&postStatus.value!='POSTED')){
btn.hide();
}
},
click: function(btn){
me.batchdeal('ProdInOut!SaleReturn', 'pd_piid=' + Ext.getCmp('pi_id').value,'scm/purchase/turnReturnMake.action');
}
},
'erpCatchBatchButton' : {
afterrender: function(btn){
var status = Ext.getCmp('pi_statuscode');
if(status && status.value == 'POSTED'){
btn.hide();
}
},
click: function(btn){
Ext.Ajax.request({
url : basePath + 'scm/reserve/catchBatch.action',
params: {
id: Ext.getCmp('pi_id').value
},
method : 'post',
callback : function(options,success,response){
var res = new Ext.decode(response.responseText);
if(res){
if(res.exceptionInfo) {
showMessage('提示', res.exceptionInfo);
} else {
if(res.log==null||res.log=='')
showMessage('提示', '抓取成功');
me.GridUtil.loadNewStore(grid,{
caller:caller,
condition:gridCondition
});
}
}else{
showMessage('提示', '抓取失败');
}
}
});
}
},
'erpGridPanel2': {
afterrender: function(grid){
grid.plugins[0].on('beforeedit', function(args){
if(args.field == "pd_inqty") {
return me.isAllowUpdateQty(args.record);
}
});
if(caller=='ProdInOut!SaleReturn'){
if(Ext.getCmp('pi_sourcecode')&&Ext.getCmp('pi_sourcecode').value!=""){
grid.readOnly = true;
}
}
},
// reconfigure: function(grid) {
// var f = Ext.getCmp('pi_id');
// if(caller == 'ProdInOut!OtherOut'){
// if (f && !Ext.isEmpty(f.value)) {
// me.loadOnHandQty(grid, f.value);
// }
// }
// },
itemclick: function(selModel, record){
var bool = me.hasSource(selModel.ownerCt);
if(caller == 'ProdInOut!OtherIn' || caller == 'ProdInOut!OtherPurcIn') {
if(record.data.pd_id > 0){
var btn = selModel.ownerCt.down('#erpEditSubpackageButton');
if(btn && !btn.hidden)
btn.setDisabled(false);
}
}
if(record.data.pd_id != 0 && record.data.pd_id != null && record.data.pd_id != ''){
var btn = Ext.getCmp('updatebgxh');
btn && btn.setDisabled(false);
btn = Ext.getCmp('barcodebtn');
btn && btn.setDisabled(false);
}
if(!bool)
this.GridUtil.onGridItemClick(selModel, record);
}
},
/**
* 更改报关型号
*/
'#updatebgxh': {
click: function(btn) {
var record=btn.ownerCt.ownerCt.getSelectionModel().getLastSelected();
me.Updatebgxh(record);
}
},
'erpBarcodeButton':{
click: function(btn){
var pdid=btn.ownerCt.ownerCt.ownerCt.items.items[1].selModel.selected.items[0].data["pd_id"];
var id = Ext.getCmp("pi_id").value;
var formCondition1="pd_idIS"+pdid+" and pi_idIS'"+id+"'";
var gridCondition1="bi_pdidIS"+pdid+" and bi_piidIS'"+id+"'";
var linkCaller ='';
//获取出入库单DS_INOROUT字段判读是出库单还是入库单
Ext.Ajax.request({
url : basePath + '/pm/bom/getDescription.action',
params: {
tablename:"documentsetup" ,
field:'ds_inorout',
condition:"ds_name='"+Ext.getCmp("pi_class").value+"'",
caller:caller
},
method : 'post',
callback : function(options,success,response){
var res = new Ext.decode(response.responseText);
if(res.exceptionInfo) {
showError(rs.exceptionInfo);
} else {
var inOrOut = res.description ;
if(inOrOut == "IN" || inOrOut == "-OUT"){
linkCaller = "ProdInOut!BarcodeIn";
}else if(inOrOut == "-IN" || inOrOut == "OUT"){
linkCaller = "ProdInOut!BarcodeOut";
}
var win = new Ext.window.Window({
id : 'win',
height : '90%',
width : '95%',
maximizable : true,
buttonAlign : 'center',
layout : 'anchor',
items : [ {
tag : 'iframe',
frame : true,
anchor : '100% 100%',
layout : 'fit',
html : ''
}],
listeners:{
'beforeclose':function(view ,opt){
var postStatus = Ext.getCmp('pi_statuscode');
if(postStatus && postStatus.value != 'POSTED'){
var grid = Ext.getCmp("grid");
me.GridUtil.loadNewStore(grid,{
caller:caller,
condition:gridCondition
});
}
}
}
});
win.show();
}
}
});
},
afterrender:function(btn) {
btn.setDisabled(true);
}
},
'erpDeleteDetailButton': {
afterrender: function(btn){
btn.ownerCt.add({
xtype: 'erpBarcodeButton'
});
if(caller=='ProdInOut!Sale'){
btn.ownerCt.add({
xtype:'button',
text:'比例信息维护',
width:120,
iconCls: 'x-button-icon-check',
cls: 'x-btn-gray',
id:'UpdateProdInoutrateButton',
style: {
marginLeft: '10px'
},
handler:function(){
var record=btn.ownerCt.ownerCt.getSelectionModel().getLastSelected();
me.updatepdscaleremark(record);
}
});
}
}
},
'#erpEditSubpackageButton': {
afterrender: function(btn){
var status = Ext.getCmp('pi_invostatuscode');
if(status && status.value != 'AUDITED'){
btn.hide();
}
},
click: function(btn){
var record=btn.ownerCt.ownerCt.getSelectionModel().getLastSelected();
me.EditSubpackage(record);
}
},
'erpTurnProdinoutReturnButton':{
click:function(btn){
var id = Ext.getCmp('pi_id').value;
Ext.Ajax.request({
url : basePath + 'scm/sale/turnTurnProdinoutReturn.action',
params: {
id: id
},
method : 'post',
callback : function(options,success,response){
var res = new Ext.decode(response.responseText);
if(res.exceptionInfo) {
showError(rs.exceptionInfo);
} else {
if(res.log)
showMessage('提示', res.log);
}
}
});
}
},
'erpTurnReturnButton':{
beforerender:function(btn){
btn.setText('转借货归还单');
},
afterrender:function(btn){
var status = Ext.getCmp(me.getForm(btn).statuscodeField),
postStatus = Ext.getCmp('pi_statuscode');
if((status && status.value != 'AUDITED') ||(postStatus && postStatus.value == 'POSTED')){
btn.hide();
}
},
click:function(){
Ext.Ajax.request({
url : basePath + 'scm/reserve/turnOutReturn.action',
params: {
id: Ext.getCmp('pi_id').value,
caller:caller
},
method : 'post',
callback : function(options,success,response){
var res = new Ext.decode(response.responseText);
if(res.exceptionInfo){
showError(res.exceptionInfo);return;
}
if(res.log)
showMessage('提示', res.log);
}
});
}
},
'erpSplitButton':{
click:function(btn){
warnMsg("确定拆分单据?", function(btn){
if(btn == 'yes'){
var id = Ext.getCmp('pi_id').value;
var piclass = Ext.getCmp('pi_class').value;
Ext.Ajax.request({
url : basePath + 'scm/reserve/split.action',
params: {
id: id,
caller:caller,
cls:piclass
},
method : 'post',
callback : function(options,success,response){
var res = new Ext.decode(response.responseText);
if(res.exceptionInfo) {
showError(res.exceptionInfo);
} else {
if(res.log)
showMessage('提示', res.log);
}
}
});
}
});
}
},
'erpGridWinButton':{
afterrender: function(btn){
var id = Ext.getCmp('pi_id').value;
btn.setConfig({
text: '费用明细',
caller: 'ProdChargeDetail!CGYS',
condition: 'pd_piid=' + id,
paramConfig: {
pd_piid: id
}
});
},
beforesave : function(btn) {
var f = btn.ownerCt.ownerCt, p = f.down('field[name=pi_statuscode]');
if (p && 'POSTED' == p.getValue()) {
Ext.Msg.alert("提示","该单据已经过账,不能修改费用明细!");
return false;
}
return true;
}
/*aftersave:function(){
//验收单ID
var id = Ext.getCmp('pi_id').value;
Ext.Ajax.request({
url : basePath + 'scm/reserve/updatepdPrice.action',
params: {
id: id
},
method : 'post',
callback : function(options,success,response){
var res = new Ext.decode(response.responseText);
window.location.reload();
if(!res.bool){
btn.hide();
}
}
});
}*/
//yaozx@13-12-04
/*aftersave:function(btn){
var items = Ext.getCmp('grid').store.data.items;
var totalcount,parentCount;
var rate,pd_prcie;
Ext.Array.each(items, function(item){
rate = item.data['pd_rate']==0?1:item.data['pd_rate'];
totalcount = Number(totalcount) + rate*item.data['pd_amount'];
});
var parentItems = parent.Ext.getCmp('grid').store.data.items;
Ext.Array.each(parentItems, function(item){
parentCount = Number(parentCount)+item.data['pd_inqty']*item.data['pd_orderprice']*(1+item.data['pd_taxrate']/100);
});
rate = parent.Ext.getCmp('pi_rate').value==0?1:Ext.getCmp('pi_rate').value;
parentCount = Number(parentCount)*rate;
if(Number(parentCount)>0&&Number(parentCount)>0){
Ext.Array.each(parentItems, function(item){
pd_prcie = item.data['pd_orderprice']*(1+item.data['pd_taxrate']/100)+Number(parentCount)/item.data['pd_inqty']*totalcount;
item.set('pd_prcie', pd_prcie );
});
}
}*/
},
'erpSaveButton': {
click: function(btn){
var form = me.getForm(btn);
if(Ext.getCmp(form.codeField).value == null || Ext.getCmp(form.codeField).value == ''){
me.BaseUtil.getRandomNumber(caller, 2, form.codeField);//自动添加编号
}
me.save(btn);
}
},
'erpPrintA4Button': {
click: function(btn) {
var reportName = '';
var reportName = "piolist_bc4";
var condition = '{prodinout.pi_id}=' + Ext.getCmp('pi_id').value + '';
var id = Ext.getCmp('pi_id').value;
me.FormUtil.onwindowsPrint(id, reportName, condition);
}
},
'erpUpdatePdpriceButton':{
click:function(btn){
var p = Ext.getCmp('pi_statuscode');
if (p && 'POSTED' == p.getValue()) {
Ext.Msg.alert("提示","该单据已经过账,不能修改费用明细!");
return ;
}
var id = Ext.getCmp('pi_id').value;
Ext.Ajax.request({
url : basePath + 'scm/reserve/updatepdPrice.action',
params: {
id: id
},
method : 'post',
callback : function(options,success,response){
var res = new Ext.decode(response.responseText);
window.location.reload();
if(!res.bool){
btn.hide();
}
}
});
}
},
'erpDeleteButton' : {
afterrender: function(btn){
var status = Ext.getCmp(me.getForm(btn).statuscodeField);
if(status && status.value == 'DELETED'){
btn.hide();
}
},
click: function(btn){
me.FormUtil.onDelete({pu_id: Number(Ext.getCmp('pi_id').value)});
}
},
'erpResetbatchButton':{
afterrender: function(btn){
var status = Ext.getCmp('pi_statuscode');
if(status && status.value != 'UNPOST'){
btn.hide();
}/*else{
Ext.Ajax.request({
url : basePath + 'scm/reserve/checkresetBatchcode.action',
params: {
caller: caller
},
method : 'post',
callback : function(options,success,response){
var res = new Ext.decode(response.responseText);
if(!res.bool){
btn.hide();
}
}
});
}*/
},
click: function(btn){
Ext.Ajax.request({
url : basePath + 'scm/reserve/resetBatchcode.action',
params: {
id: Ext.getCmp('pi_id').value
},
method : 'post',
callback : function(options,success,response){
var res = new Ext.decode(response.responseText);
if(res.exceptionInfo){
showError(res.exceptionInfo);return;
} else if(res.success){
Ext.Msg.alert("提示","批号重置成功!");
}
}
});
}
},
'erpUpdateButton': {
afterrender: function(btn){
var status = Ext.getCmp(me.getForm(btn).statuscodeField);
if(status && status.value != 'ENTERING'){
btn.hide();
}
status = Ext.getCmp('pi_statuscode');
if(status && 'POSTED' == status.value) {
btn.hide();
}
},
click: function(btn){
var grid = Ext.getCmp('grid'), items = grid.store.data.items, c = Ext.getCmp('pi_inoutno').value;
var piclass = Ext.getCmp('pi_class').value;
Ext.Array.each(items, function(item){
if(!Ext.isEmpty(item.data['pd_prodcode'])){
item.set('pd_inoutno', c);
item.set('pd_piclass', piclass);
}
if(caller == 'ProdInOut!OtherIn' || caller == 'ProdInOut!OtherPurcIn') {
if(item.data['pd_unitpackage'] == null || item.data['pd_unitpackage'] == ''||
item.data['pd_unitpackage'] == '0' || item.data['pd_unitpackage'] == 0){
item.set('pd_unitpackage', item.data['pd_inqty']);
}
}
});
if(caller !='ProdInOut!AppropriationOut' && caller != 'ProdInOut!AppropriationIn' ) {
var whcode = Ext.getCmp('pi_whcode'), whname = Ext.getCmp('pi_whname');
if(whcode && whname) {
Ext.Array.each(items, function(item){
if(!Ext.isEmpty(item.data['pd_prodcode'])){
if(Ext.isEmpty(item.data['pd_whcode'])){
item.set('pd_whcode', whcode.value);
item.set('pd_whname', whname.value);
}
}
});
}
}
// 拨入单、拨出单,默认第一行的仓库
me.setDetailWarehouse(grid);
if(caller == 'ProdInOut!Make!Return') {
var firstItem = grid.store.getAt(0);
if(firstItem) {
var desc = firstItem.get('pd_description'), dc = firstItem.get('pd_departmentcode'),
dn = firstItem.get('pd_departmentname'), whcode = firstItem.get('pd_whcode'),
whname = firstItem.get('pd_whname');
Ext.Array.each(items, function(item){
if(!Ext.isEmpty(item.data['pd_prodcode'])){
if(Ext.isEmpty(item.data['pd_description'])){
item.set('pd_description', desc);
}
if(Ext.isEmpty(item.data['pd_departmentcode'])){
item.set('pd_departmentcode', dc);
item.set('pd_departmentname', dn);
}
if(Ext.isEmpty(item.data['pd_whcode'])){
item.set('pd_whcode', whcode);
item.set('pd_whname', whname);
}
}
});
}
}
me.FormUtil.onUpdate(me);
}
},
'erpAddButton': {
click: function(){
me.FormUtil.onAdd('add' + caller, '新增出入库单', "jsps/scm/reserve/prodInOut.jsp?whoami=" + caller);
}
},
'erpCloseButton': {
click: function(btn){
me.FormUtil.beforeClose(me);
}
},
'erpSubmitButton': {
afterrender: function(btn){
var status = Ext.getCmp(me.getForm(btn).statuscodeField);
if(status && status.value != 'ENTERING'){
btn.hide();
}
},
click: function(btn){
var grid = Ext.getCmp('grid');
var items = grid.store.data.items;
var bool = true;
if(caller=='ProdInOut!OtherIn'||caller=='ProdInOut!OtherOut'){
var type = Ext.getCmp('pi_type').value;
if(type==null||type==''){
showError("主表类型字段未填写,不能提交!");return;
}
}
/*Ext.each(items, function(item){
if(item.data[grid.necessaryField] != null && item.data[grid.necessaryField] != ''){
if(item.data['pd_outqty'] == null || item.data['pd_outqty'] == ''){
bool = false;
showError("明细第" + item.data['pd_pdno'] + "行出库数量未填写,不能提交");return;
}
}
});*/
if(caller=='ProdInOut!AppropriationOut'){
Ext.each(items, function(item){
if(item.data[grid.necessaryField] != null && item.data[grid.necessaryField] != ''){
if(Ext.getCmp('pd_outqty') && item.data['pd_outqty'] == null || item.data['pd_outqty'] == ''){
bool = false;
showError("明细第" + item.data['pd_pdno'] + "行出库数量未填写,不能提交");return;
}
}
});
}
if(bool){
me.FormUtil.onSubmit(Ext.getCmp('pi_id').value);
}
}
},
'erpResSubmitButton': {
afterrender: function(btn){
var status = Ext.getCmp(me.getForm(btn).statuscodeField);
if(status && status.value != 'COMMITED'){
btn.hide();
}
},
click: function(btn){
me.FormUtil.onResSubmit(Ext.getCmp('pi_id').value);
}
},
'erpAuditButton': {
afterrender: function(btn){
var status = Ext.getCmp(me.getForm(btn).statuscodeField);
if(status && status.value != 'COMMITED'){
btn.hide();
}
},
click: function(btn){
me.FormUtil.onAudit(Ext.getCmp('pi_id').value);
}
},
'erpResAuditButton': {
afterrender: function(btn){
var status = Ext.getCmp(me.getForm(btn).statuscodeField),
postStatus = Ext.getCmp('pi_statuscode');
if((status && status.value != 'AUDITED') ||(postStatus && postStatus.value == 'POSTED')){
btn.hide();
}
},
click: function(btn){
me.FormUtil.onResAudit(Ext.getCmp('pi_id').value);
}
},
'erpBannedButton': {
afterrender: function(btn){
var status = Ext.getCmp(me.getForm(btn).statuscodeField);
if(status && status.value != 'COMMITED'){
btn.hide();
}
},
click: function(btn){
me.FormUtil.onBanned(Ext.getCmp('pi_id').value);
}
},
'erpResBannedButton': {
afterrender: function(btn){
var status = Ext.getCmp(me.getForm(btn).statuscodeField);
if(status && status.value != 'BANNED'){
btn.hide();
}
},
click: function(btn){
me.FormUtil.onResBanned(Ext.getCmp('pi_id').value);
}
},
'erpPrintButton': {
click:function(btn){
me.onPrint();
}
},
'erpPrintotherinButton':{// 返修机入仓单
click: function(btn){
var reportName = "piolist_otherin";
var condition = '{prodinout.pi_id}=' + Ext.getCmp('pi_id').value + '';
var id = Ext.getCmp('pi_id').value;
me.FormUtil.onwindowsPrint(id, reportName, condition);
}
},
'erpPrintotheroutButton':{// 返修机出仓单
click: function(btn){
var reportName = "piolist_otherout";
var condition = '{prodinout.pi_id}=' + Ext.getCmp('pi_id').value + '';
var id = Ext.getCmp('pi_id').value;
me.FormUtil.onwindowsPrint(id, reportName, condition);
}
},
'erpPrintwithPriceButton':{// 无价打印==erpPrintButton
click: function(btn){
var reportName = "sendlist_yessale_yesprice";
var condition = '{prodinout.pi_id}=' + Ext.getCmp('pi_id').value + '';
var id = Ext.getCmp('pi_id').value;
me.FormUtil.onwindowsPrint(id, reportName, condition);
}
},
'erpPrintPriceButton':{// (有价)打印,和erpPrintwithPriceButton一样,某些客户需要默认为有效
click: function(btn){
var reportName = "sendlist_yessale_yesprice";
var condition = '{prodinout.pi_id}=' + Ext.getCmp('pi_id').value + '';
var id = Ext.getCmp('pi_id').value;
me.FormUtil.onwindowsPrint(id, reportName, condition);
}
},
'erpPrintnosaleButton':{// 无PO打印
click: function(btn){
var reportName = "sendlist_nosale";
var condition = '{prodinout.pi_id}=' + Ext.getCmp('pi_id').value + '';
var id = Ext.getCmp('pi_id').value;
me.FormUtil.onwindowsPrint(id, reportName, condition);
}
},
'erpPrintNoCustomerButton':{// 无客户打印
click: function(btn){
var reportName = "sendlist_yessale_nocustomer";
var condition = '{prodinout.pi_id}=' + Ext.getCmp('pi_id').value + '';
var id = Ext.getCmp('pi_id').value;
me.FormUtil.onwindowsPrint(id, reportName, condition);
}
},
'erpPrintNoPriceButton':{// 无价打印==erpPrintButton
click: function(btn){
me.onPrint();
}
},
'erpPostButton': {
afterrender: function(btn){
var status = Ext.getCmp('pi_statuscode');
if(status && status.value != 'UNPOST'){
btn.hide();
}
},
buffer : 1000,
click: function(btn){
me.FormUtil.onPost(Ext.getCmp('pi_id').value);
}
},
'erptecaiButton':{
afterrender: function(btn){
var status = Ext.getCmp('pi_statuscode');
if(caller!='ProdInOut!DefectIn'|| status.value != 'POSTED'){
btn.hide();
}
},
click: function(btn){
var pi_id = Ext.getCmp('pi_id').value;
Ext.Ajax.request({
url: basePath + 'scm/reserve/erptecai.action',
params: {
caller: caller,
id: pi_id
},
callback: function(opt, s, r) {
var rs = Ext.decode(r.responseText);
if(rs.exceptionInfo) {
showError(rs.exceptionInfo);
} else {
if(rs.log)
showMessage('提示', rs.log);
}
}
});
}
},
'erpResPostButton': {
afterrender: function(btn){
var status = Ext.getCmp('pi_statuscode');
if(status && status.value != 'POSTED'){
btn.hide();
}
},
click: function(btn){
me.FormUtil.onResPost(Ext.getCmp('pi_id').value);
}
},
'erpTurnProdinoutIn':{
afterrender: function(btn){
var status = Ext.getCmp(me.getForm(btn).statuscodeField);
if(caller=='ProdInOut!OtherOut' && status.value != 'AUDITED'){
btn.hide();
}
},
click: function(btn){
var id = Ext.getCmp('pi_id').value;
Ext.Ajax.request({
url: basePath + 'scm/reserve/turnProdinoutIn.action',
params: {
id: id
},
callback: function(opt, s, r) {
var rs = Ext.decode(r.responseText);
if(rs.exceptionInfo) {
showError(rs.exceptionInfo);
} else {
if(rs.log)
showMessage('提示', rs.log);
}
}
});
}
},
'erpSetMMQTYButton':{
click:function(btn){
warnMsg("确认本次发料数为当前维护的实际可发数?", function(btn){
if(btn == 'yes'){
me.FormUtil.setLoading(true);//loading...
Ext.Ajax.request({
url : basePath + 'scm/reserve/SetMMQTY.action',
params: {
id: Ext.getCmp('pi_id').value,
caller:caller
},
method : 'post',
callback: function(opt, s, r) {
me.FormUtil.setLoading(false);
var rs = Ext.decode(r.responseText);
if(rs.exceptionInfo) {
showError(rs.exceptionInfo);
} else {
if(rs.log)
showMessage('提示', rs.log);
}
window.location.reload();
}
});
}
});
}
},
'dbfindtrigger[name=pd_ordercode]': {
focus: function(t){
t.setHideTrigger(false);
t.setReadOnly(false);
if(Ext.getCmp('pi_cardcode')){
var code = Ext.getCmp('pi_cardcode').value;
if(code != null && code != ''){
var obj = me.getCodeCondition();
if(obj && obj.field){
t.dbBaseCondition = obj.field + "='" + code + "'";
}
}
}
if(caller=='ProdInOut!OutReturn'){//借货归还单
var code = Ext.getCmp('pi_cardcode').value;
if(code != null && code != ''){
if(t.dbBaseCondition==null||t.dbBaseCondition==''){
t.dbBaseCondition= "pi_cardcode='"+code+"'";
}else{
t.dbBaseCondition=t.dbBaseCondition+" and pi_cardcode='"+code+"'";
}
}
}
},
aftertrigger: function(t){
if(Ext.getCmp('pi_cardcode')){
var obj = me.getCodeCondition();
if(obj && obj.fields){
me.FormUtil.getFieldsValue(obj.tablename, obj.fields, obj.myfield + "='" + t.value + "'", obj.tFields);
}
}
}
},
'dbfindtrigger[name=pd_orderdetno]': {
focus: function(t){
t.setHideTrigger(false);
t.setReadOnly(false);//用disable()可以,但enable()无效
var record = Ext.getCmp('grid').selModel.lastSelected;
var code = record.data['pd_ordercode'];
if(code == null || code == ''){
showError("请先选择关联单号!");
t.setHideTrigger(true);
t.setReadOnly(true);
} else {
var field = me.getBaseCondition();
if(field){
t.dbBaseCondition = field + "='" + code + "'";
}
}
}
},
'dbfindtrigger[name=pd_whcode]':{
aftertrigger: function(t){
if(caller=='ProdInOut!AppropriationOut'||caller=='ProdInOut!Sale'||caller=='ProdInOut!AppropriationIn'){
var inwhcode=t.value;
var record = Ext.getCmp('grid').selModel.lastSelected;
var prodcode=record.data['pd_prodcode'];
if(prodcode&&inwhcode){
var obj = {tablename:'productWH',fields:'pw_onhand'};
me.FormUtil.getFieldsValue(obj.tablename, obj.fields,"pw_whcode='"+inwhcode+"' AND pw_prodcode='"+prodcode+"'" , "pd_inqty",record);
}
}
}
},
'multidbfindtrigger[name=pd_orderdetno]': {
focus: function(t){
t.setHideTrigger(false);
t.setReadOnly(false);//用disable()可以,但enable()无效
var record = Ext.getCmp('grid').selModel.lastSelected;
var code = record.data['pd_ordercode'];
if(code == null || code == ''){
showError("请先选择关联单号!");
t.setHideTrigger(true);
t.setReadOnly(true);
} else {
var field = me.getBaseCondition();
if(field){
t.dbBaseCondition = field + "='" + code + "'";
}
}
}
},
'dbfindtrigger[name=pd_batchcode]': {
focus: function(t){
t.setHideTrigger(false);
t.setReadOnly(false);//用disable()可以,但enable()无效
var record = Ext.getCmp('grid').selModel.lastSelected;
var pr = record.data['pd_prodcode'];
if(pr == null || pr == ''){
showError("请先选择料号!");
t.setHideTrigger(true);
t.setReadOnly(true);
} else {
var code = record.data['pd_whcode'];
if(code == null || code == ''){
if(Ext.getCmp('pi_whcode')) {
code = Ext.getCmp('pi_whcode').value;
if(code == null || code == ''){
showError("请先选择仓库!");
t.setHideTrigger(true);
t.setReadOnly(true);
} else {
t.dbBaseCondition = "ba_whcode='" + code + "' AND ba_prodcode='" + pr + "'";
}
} else {
t.dbBaseCondition = "ba_prodcode='" + pr + "'";
}
} else {
t.dbBaseCondition = "ba_whcode='" + code + "' AND ba_prodcode='" + pr + "'";
}
}
}
},
'field[name=pi_whcode]': {
aftertrigger: function(f){
if(f.value != null && f.value != ''){
var grid = Ext.getCmp('grid');
var whname = Ext.getCmp('pi_whname');
Ext.Array.each(grid.store.data.items, function(item){
if(item.data['pd_whcode'] == null || item.data['pd_whcode'] == ''){
item.set('pd_whcode', f.value);
item.set('pd_whname', whname.value);
}
});
}
}
},
'field[name=pi_purpose]': {
aftertrigger: function(f){
if(f.value != null && f.value != ''){
var grid = Ext.getCmp('grid');
var posename = Ext.getCmp('pi_purposename');
Ext.Array.each(grid.store.data.items, function(item){
if(item.data['pd_inwhcode'] == null || item.data['pd_inwhcode'] == ''){
item.set('pd_inwhcode', f.value);
if(posename){
item.set('pd_inwhname', posename.value);
}
}
});
}
}
},
'dbfindtrigger[name=pi_paymentcode]': {
afterrender:function(trigger){
if(trigger.fieldConfig == 'PT') {
trigger.dbKey='pi_cardcode';
if(caller=='ProdInOut!Sale' || caller=='ProdInOut!SaleReturn' || caller=='ProdInOut!SaleBorrow'){
trigger.mappingKey='cu_code';
trigger.dbMessage='请先选客户编号!';
}
}
}
},
'dbfindtrigger[name=pi_custcode2]': {
afterrender:function(trigger){
trigger.dbKey='pi_cardcode';
trigger.mappingKey='cu_code';
trigger.dbMessage='请先选客户编号!';
}
},
'dbfindtrigger[name=pi_invoiceremark]': {
afterrender:function(trigger){
trigger.dbKey='pi_cardcode';
trigger.mappingKey='cu_code';
trigger.dbMessage='请先选客户编号!';
}
},
'dbfindtrigger[name=pi_packingremark]': {
afterrender:function(trigger){
trigger.dbKey='pi_cardcode';
trigger.mappingKey='cu_code';
trigger.dbMessage='请先选客户编号!';
}
},
/* 'dbfindtrigger[name=pi_receivecode]': {
afterrender:function(trigger){
if (caller == 'ProdInOut!Sale') {
trigger.dbKey='pi_cardcode';
trigger.mappingKey='cu_code';
trigger.dbMessage='请先选客户编号!';
}
}
},*/ //万利达收货客户可以随意改成其他客户
'erpGetPriceButton': {
click: function(){
}
},
'erpTurnMrbButton':{
afterrender: function(btn){
var status = Ext.getCmp("pi_statuscode");
if(status && status.value != 'POSTED'){
btn.hide();
}
},
click: function(btn){
me.batchdeal('ProdIO!ToMRB!Deal', 'pd_piid=' + Ext.getCmp('pi_id').value + ' AND nvl(pd_yqty,0) 0) {
bool = true;return;
}
});
}
return bool;
},
isAllowUpdateQty: function(record) {
var bool = true;
switch(caller) {
case 'ProdInOut!PurcCheckin': //采购验收单
if(record.get('pd_qcid') != null && record.get('pd_qcid') > 0)
bool = false;
break;
case 'ProdInOut!OutsideCheckIn': //委外验收单
if(record.get('pd_qcid') != null && record.get('pd_qcid') > 0)
bool = false;
break;
case 'ProdInOut!DefectIn': //不良品入库单
if(record.get('pd_qcid') != null && record.get('pd_qcid') > 0)
bool = false;
break;
case 'ProdInOut!Make!In': //完工入库单
if(record.get('pd_qcid') != null && record.get('pd_qcid') > 0)
bool = false;
break;
}
return bool;
},
onPrint : function() {
var me = this, whichKind = Ext.getCmp('pi_class').value;
var reportName = '';
if(whichKind=="出货单"){
reportName="sendlist_yessale";
}else if(whichKind=="无订单出货单"){
reportName="sendlist_nosale";
}
else if(whichKind=="不良品入库单"){
//console.log("fds");
reportName="pio_notokin";
}else if(whichKind=="不良品出库单"){
reportName="pio_notokout";
}else if(whichKind=="其它采购入库单"){
reportName="piolist_opin";
}else if(whichKind=="其它采购出库单"){
reportName="piolist_opout";
}else if(whichKind=="拨入单"){
reportName="piolist_br";
}else if(whichKind=="拨出单"){
reportName="piolist_bc";
}else if(whichKind=="其它入库单"){
reportName="piolist_in";
}else if(whichKind=="其它出库单"){
reportName="piolist_out";
}else if(whichKind=="报废单"){
reportName="piolist_bf";
}else if(whichKind=="换货入库单"){
reportName="pio_changein";
}else if(whichKind=="换货出库单"){
reportName="pio_changeout";
}else if(whichKind=="销售退货单"){
reportName="retulist";
}else if(whichKind=="采购验收单"){
reportName="acclist";
}else if(whichKind=="采购验退单"){
reportName="piolist_yt";
}else if(whichKind=="销售拨入单"){
reportName="piolist";
}else if(whichKind=="销售拨出单"){
reportName="piolist_salebc";
}else if(whichKind=="生产领料单"){
reportName="PIOLISTM";
}else if(whichKind=="生产退料单"){
reportName="PIOLISTM_Back";
}else if(whichKind=="完工入库单"){
reportName="finish";
}else if(whichKind=="结余退料单"){
reportName="PIOLISTM_JY";
}else if(whichKind=="拆件入库单"){
reportName="chaijian";
}else if(whichKind=="生产补料单"){
reportName="PIOLIST_bl";
}else if(whichKind=="生产耗料单"){
reportName="PIOLISTM_HL";
}else if(whichKind=="委外领料单"){
reportName="Expiolist";
}else if(whichKind=="委外退料单"){
reportName="PIOLIST_wwtl";
}else if(whichKind=="委外验收单"){
reportName="EXPLIST_ys";
}else if(whichKind=="委外验退单"){
reportName="EXPLIST_yt";
}else if(whichKind=="生产报废单"){
reportName="MakeScrap";
}else if(whichKind=="无订单退货单"){
reportName="retulist_nosale";
}else if(whichKind=="委外补料单"){
reportName="Expiolist";
}else if(whichKind=="盘盈调整单"){
reportName="piolist_tz";
}else if(whichKind=="盘亏调整单"){
reportName="piolist_tz";
}else if(whichKind=="辅料入库单"){
reportName="piolist_flr";
}else if(whichKind=="辅料出库单"){
reportName="piolist_flc";
}else if(whichKind=="研发领料单"){
reportName="piolist_yfll";
}else if(whichKind=="研发退料单"){
reportName="piolist_yftl";
}else if(whichKind=="借货出货单"){
reportName="sendlist_jh";
}else if(whichKind=="借货归还单"){
reportName="sendlist_jhgh";
}
var condition = '{prodinout.pi_id}=' + Ext.getCmp('pi_id').value + '';
var id = Ext.getCmp('pi_id').value;
me.FormUtil.onwindowsPrint(id, reportName, condition);
},
/**
*编辑分装明细
**/
EditSubpackage:function(record){
var width = Ext.isIE ? screen.width*0.7*0.9 : '80%',
height = Ext.isIE ? screen.height*0.75 : '100%';
var pd_id = record.get('pd_id');
Ext.create('Ext.Window', {
width: width,
height: height,
autoShow: true,
layout: 'anchor',
items: [{
tag : 'iframe',
frame : true,
anchor : '100% 100%',
layout : 'fit',
html : ''
}]
});
},
loadOnHandQty: function(grid, id) {
Ext.Ajax.request({
url: basePath + 'scm/reserve/loadOnHandQty.action',
params: {
caller: caller,
id: id
},
callback: function(opt, s, r) {
var rs = Ext.decode(r.responseText);
if (rs.exceptionInfo) {
showMessage('提示', rs.exceptionInfo.replace('AFTERSUCCESS', ''));
} else {
var data = [];
if (!rs.data || rs.data.length == 2) {
grid.GridUtil.add10EmptyData(grid.detno, data);
grid.GridUtil.add10EmptyData(grid.detno, data);
} else {
data = Ext.decode(rs.data.replace(/,}/g, '}').replace(/,]/g, ']'));
}
grid.store.loadData(data);
}
}
});
},
Updatebgxh:function(record){
var win = this.bgxhwindow;
if (!win) {
win = this.getBgxhWindow();
}
win.show();
},
getBgxhWindow : function() {
var me = this;
return Ext.create('Ext.window.Window',{
width: 330,
height: 180,
closeAction: 'hide',
cls: 'custom-blue',
title:'更改报关型号
',
layout: {
type: 'vbox'
},
items:[{
margin: '5 0 0 5',
xtype:'textfield',
fieldLabel:'报关型号',
name:'pd_bgxh',
id:'pd_bgxh'
},{
margin: '5 0 0 5',
xtype: 'fieldcontainer',
fieldLabel: '全部更新',
combineErrors: false,
defaults: {
hideLabel: true
},
layout: {
type: 'column',
defaultMargins: {top: 0, right: 5, bottom: 0, left: 0}
},
items: [{
xtype:'checkbox',
columnidth: 0.4,
fieldLabel:'全部更新',
name:'allupdate',
id:'allupdate'
},{
xtype:'displayfield',
fieldStyle:'color:red',
columnidth: 0.6,
value:' *更改当前所有明细'
}]
}],
buttonAlign:'center',
buttons:[{
xtype:'button',
text:'保存',
width:60,
iconCls: 'x-button-icon-save',
handler:function(btn){
var w = btn.up('window');
me.saveBgxh(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();
}
}]
});
},
saveBgxh: function(w) {
var pd_bgxh = w.down('field[name=pd_bgxh]').getValue(),
grid = Ext.getCmp('grid'),
record = grid.getSelectionModel().getLastSelected();
if(!pd_bgxh) {
showError('请先设置报关型号.') ;
return;
} else {
var allupdate = w.down('field[name=allupdate]').getValue();
var dd = {
pd_id : record.data.pd_id,
pd_piid : record.data.pd_piid,
pd_bgxh : pd_bgxh ? pd_bgxh : null,
allupdate : allupdate ? 1 : 0,
caller: caller
};
Ext.Ajax.request({
url : basePath +'scm/reserve/updatebgxh.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);
} else if(r.exceptionInfo){
showError(r.exceptionInfo);
} else{
saveFailure();
}
}
});
}
},
batchdeal: function(nCaller, condition, url){
console.log('url: '+url);
var win = new Ext.window.Window({
id : 'win',
height: "100%",
width: "80%",
maximizable : true,
buttonAlign : 'center',
layout : 'anchor',
items: [{
tag : 'iframe',
frame : true,
anchor : '100% 100%',
layout : 'fit',
html : ''
}],
buttons : [{
name: 'confirm',
text : $I18N.common.button.erpConfirmButton,
iconCls: 'x-button-icon-confirm',
cls: 'x-btn-gray',
listeners: {
buffer: 500,
click: function(btn) {
var grid = Ext.getCmp('win').items.items[0].body.dom.getElementsByTagName('iframe')[0].contentWindow.Ext.getCmp("editorColumnGridPanel");
btn.setDisabled(true);
grid.updateAction(url);
win.close();
//window.location.reload();
}
}
}, {
text : $I18N.common.button.erpCloseButton,
iconCls: 'x-button-icon-close',
cls: 'x-btn-gray',
handler : function(){
Ext.getCmp('win').close();
}
}]
});
win.show();
}
});