Ext.QuickTips.init();
Ext.define('erp.controller.scm.product.Product', {
extend: 'Ext.app.Controller',
FormUtil: Ext.create('erp.util.FormUtil'),
BaseUtil: Ext.create('erp.util.BaseUtil'),
views:[
'core.form.Panel','scm.product.Product','core.form.MultiField','core.form.FileField',
'core.button.Add','core.button.Submit','core.button.ResSubmit','core.button.Audit','core.button.Save','core.button.Close','core.button.Print','core.button.TurnCustomer',
'core.button.Upload','core.button.Update','core.button.FeatureDefinition','core.button.FeatureView','core.button.Delete','core.button.ResAudit','core.button.ForBidden',
'core.button.ResForBidden','core.button.Banned','core.button.ResBanned','core.button.CopyAll','core.button.ProductStatus','core.button.CreateFeatrue',
'core.trigger.TextAreaTrigger','core.trigger.DbfindTrigger','core.form.YnField','core.trigger.AutoCodeTrigger',
'core.button.Sync','core.button.SubmitStandard','core.button.ResSubmitNoStandard','core.button.UpdatePrLevel'
],
init:function(){
var me = this;
this.control({
'erpFormPanel': {
afterrender: function(){
/*var tree = parent.Ext.getCmp('tree-panel');
if(!tree.collapsed) {
parent.Ext.getCmp('tree-panel').toggleCollapse();
}*/
/*var panel = parent.Ext.getCmp('tree-tab');
if(panel && !panel.collapsed) {
panel.toggleCollapse();
}*/
}
},
'erpTurnCustomerButton':{
beforerender:function(btn){
btn.setText('转打样');
},
afterrender: function(btn){
var status = Ext.getCmp('pr_statuscode');
if(status && status.value != 'AUDITED'){
btn.hide();
}
},
click:function(btn){
warnMsg("确定要转打样吗?", function(b){//url,jsp,pageid,title
if(b == 'yes'){
me.turn(btn.ownerCt.ownerCt,'scm/product/prodturnsample.action',
'jsps/scm/product/ProductSample.jsp?formCondition=ps_idIS@@&gridCondition=pd_psidIS@@','ProductSample','打样申请单');
}
});
}
},
'combobox[name=pr_maketype]': {
change: function(m){
if(!Ext.isEmpty(m.value)) {
var f = Ext.getCmp('pr_purchasepolicy');
switch (f.value) {
case 'MRP':
if(m.value != '外购' && m.value != '客供') {
showError('计划类型为MRP时,生产类型只能为 外购 和 客供');
m.reset();
}
break;
case 'MPS':
if(m.value != '制造 ' && m.value != '委外') {
showError('计划类型为MPS时,生产类型只能为 制造 和 委外');
m.reset();
}
break;
}
}
}
},
'autocodetrigger': {
aftertrigger: function(trigger, val, path, item) {
if(path) {
if(path[0]) {
Ext.getCmp('pr_kind').setValue(path[0]);
}
if(path[1]) {
Ext.getCmp('pr_kind2').setValue(path[1]);
}
if(path[2]) {
Ext.getCmp('pr_kind3').setValue(path[2]);
}
if(path[3]) {
Ext.getCmp('pr_detail').setValue(('无' == path[3] ? '' : path[3]) +
('无' == path[2] ? '' : path[2]) + ('无' == path[1] ? '' : path[1]));
var xikind=Ext.getCmp('pr_xikind');
if(xikind){
xikind.setValue(path[3]);
}
}
var data = item.get('data') || item.raw.data, f;
if(typeof (f = Ext.getCmp('pr_namerule')) !== 'undefined')
f.setValue(data.pk_namerule);
if(typeof (f = Ext.getCmp('pr_nameeg')) !== 'undefined')
f.setValue(data.pk_nameeg);
if(typeof (f = Ext.getCmp('pr_specrule')) !== 'undefined')
f.setValue(data.pk_specrule);
if(typeof (f = Ext.getCmp('pr_speceg')) !== 'undefined')
f.setValue(data.pk_speceg);
if(typeof (f = Ext.getCmp('pr_parameterrule')) !== 'undefined')
f.setValue(data.pk_parameterrule);
if(typeof (f = Ext.getCmp('pr_parametereg')) !== 'undefined')
f.setValue(data.pk_parametereg);
}
}
},
'erpSaveButton': {
click: function(btn){
this.FormUtil.beforeSave(this);
}
},
'erpDeleteButton' : {
click: function(btn){
me.FormUtil.onDelete(Ext.getCmp('pr_id').value);
}
},
'erpUpdateButton': {
click: function(btn){
this.FormUtil.onUpdate(this);
}
},
'erpAddButton': {
click: function(){
me.FormUtil.onAdd('addProduct'+new Date().getTime(), '新增物料', 'jsps/scm/product/product.jsp');
}
},
'mfilefield':{
beforerender:function(f){
f.readOnly=false;
}
},
'htmleditor': {
beforerender: function(f){
f.height=300;
f.readOnly=true;
f.dirty=false;
f.value='1)电阻,物料具体名称(如片式电阻,固定电阻,可变电阻等),规格参数写明功率W?
2)电感,规格参数写明功率W?
3)晶振,描述中说明是否已装配
4)滤波器,注明是否电磁干扰等
5)二极管,三极管,规格参数写明功率W
6)电容,规格参数写明电容量UF
7)集成电路,描述中写明是否加密,具体用途及功能(如控制处理功能,驱动功能,触摸功能等等),存储功能的必须写明存储量G或m
8)手机用XX英寸电容式触摸屏,需写明是否含液晶,以及组成,适用于何种品牌和型号的手机,(不含触摸功能的品名直接申报为手机用液晶屏,含触摸功能的液晶屏申报品名为电容式触摸屏含液晶即可)
9)xx英寸彩色液晶屏,需写明是否有触摸功能,制造工艺,工作原理,是否含背光,驱动电路板等等
10)开关,规格参数写明工作电压V(36V以下的,需提前一天提供能证明电压是36V以下的说明书用于办理商检免3c认证,36V以上需提供3c证书)
11)继电器,接插件均需写明电压V,光耦需写明是否含一个半导体器件';
}
},
'erpCloseButton': {
click: function(btn){
me.FormUtil.beforeClose(me);
}
},
'erpSubmitButton': {
afterrender: function(btn){
var status = Ext.getCmp('pr_statuscode');
if(status && status.value != 'ENTERING'){
btn.hide();
}
},
click: function(btn){
me.FormUtil.onSubmit(Ext.getCmp('pr_id').value);
}
},
'erpResSubmitButton': {
afterrender: function(btn){
var status = Ext.getCmp('pr_statuscode');
if(status && status.value != 'COMMITED'){
btn.hide();
}
},
click: function(btn){
me.FormUtil.onResSubmit(Ext.getCmp('pr_id').value);
}
},
'erpAuditButton': {
afterrender: function(btn){
var status = Ext.getCmp('pr_statuscode');
if(status && status.value != 'COMMITED'){
btn.hide();
}
},
click: function(btn){
me.FormUtil.onAudit(Ext.getCmp('pr_id').value);
}
},
'erpResAuditButton': {
afterrender: function(btn){
var status = Ext.getCmp('pr_statuscode');
if(status && status.value != 'AUDITED'){
btn.hide();
}
},
click: function(btn){
me.FormUtil.onResAudit(Ext.getCmp('pr_id').value);
}
},
'erpBannedButton': {
afterrender: function(btn){
var status = Ext.getCmp('pr_statuscode');
if(status && (status.value == 'DELETED' || status.value == 'DISABLE')){
btn.hide();
}
},
click: function(btn){
if (!confirm('确定要禁用此物料?')){
return;
}
//me.FormUtil.onBanned(Ext.getCmp('pr_id').value);
me.toDisable();//zhongyl 2014 03 13
}
},
'erpResBannedButton': {
afterrender: function(btn){
var status = Ext.getCmp('pr_statuscode');
if(status && status.value != 'DISABLE'){
btn.hide();
}
},
click: function(btn){
if (!confirm('确定要反禁用此物料?')){
return;
}
me.FormUtil.onResBanned(Ext.getCmp('pr_id').value);
}
},
'erpFeatureViewButton':{
click: function(btn){
var code=Ext.getCmp('pr_code').value;
var id=Ext.getCmp('pr_id').value;
var name=Ext.getCmp('pr_detail').value;
if(code != null){
Ext.Ajax.request({//拿到grid的columns
url : basePath + "pm/bom/getDescription.action",
params: {
tablename: 'Product',
field: 'pr_specvalue',
condition: "pr_code='" + code + "'"
},
method : 'post',
async: false,
callback : function(options,success,response){
var res = new Ext.decode(response.responseText);
if(res.exceptionInfo){
showError(res.exceptionInfo);return;
}
if(res.success){
if(res.description != '' && res.description != null && res.description == 'SPECIFIC'){
var win = new Ext.window.Window({
id : 'win' + id,
title: '特征查看',
height: "90%",
width: "70%",
maximizable : true,
buttonAlign : 'center',
layout : 'anchor',
items: [{
tag : 'iframe',
frame : true,
anchor : '100% 100%',
layout : 'fit',
html : ''
}]
});
win.show();
} else {
showError('物料特征必须为 虚拟特征件');return;
}
}
}
});
}
}
},
'erpCreateFeatrueButton':{
afterrender: function(btn){
var status = Ext.getCmp('pr_statuscode');
if(status && status.value != 'AUDITED'){
btn.hide();
}
},
click: function(btn){
var code=Ext.getCmp('pr_code').value;
var id = Ext.getCmp('pr_id').value;
var name=Ext.getCmp('pr_detail').value;
Ext.Ajax.request({//拿到grid的columns
url : basePath + "pm/bom/getDescription.action",
params: {
tablename: 'Product',
field: 'pr_specvalue',
condition: "pr_code='" + code + "'"
},
method : 'post',
async: false,
callback : function(options,success,response){
var res = new Ext.decode(response.responseText);
if(res.exceptionInfo){
showError(res.exceptionInfo);return;
}
if(res.success){
if(res.description != '' && res.description != null && res.description == 'NOTSPECIFIC'){
var win = new Ext.window.Window({
id : 'win',
title: '生成特征料号',
height: "90%",
width: "95%",
maximizable : true,
buttonAlign : 'center',
layout : 'anchor',
items: [{
tag : 'iframe',
frame : true,
anchor : '100% 100%',
layout : 'fit',
html : ''
}]
});
win.show();
} else {
showError('物料特征必须为虚拟特征件');return;
}
}
}
});
}
},
'erpFeatureDefinitionButton':{
afterrender: function(btn){
btn.setDisabled(false);
},
click: function(btn){
var prcode=Ext.getCmp('pr_code').value;
Ext.Ajax.request({//拿到grid的columns
url : basePath + "pm/bom/getDescription.action",
params: {
tablename: 'Product',
field: 'pr_specvalue',
condition: "pr_code='" + prcode + "'"
},
method : 'post',
async: false,
callback : function(options,success,response){
var res = new Ext.decode(response.responseText);
if(res.exceptionInfo){
showError(res.exceptionInfo);return;
}
if(res.success){
if(res.description != '' && res.description != null && res.description == 'NOTSPECIFIC'){
var formCondition="pr_code='"+prcode+"'";
var gridCondition="pf_prodcode='"+prcode+"'";
var win = new Ext.window.Window({
id : 'win',
title: '物料特征项设置',
height: "90%",
width: "70%",
maximizable : true,
buttonAlign : 'center',
layout : 'anchor',
items: [{
tag : 'iframe',
frame : true,
anchor : '100% 100%',
layout : 'fit',
html : ''
}]
});
win.show();
} else {
showError('物料特征必须为虚拟特征件');return;
}
}
}
});
}
},
'erpCopyButton':{
click: function(btn){
warnMsg("确定要复制当前物料吗?", function(btn){
if(btn == 'yes'){
Ext.Ajax.request({
url : basePath + 'scm/product/copyProduct.action',
params: {
id: Ext.getCmp('pr_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/product/product.jsp?formCondition=pr_id=" + id;
me.FormUtil.onAdd('Product' + id, '物料基本资料' + id, url);
});
}
}
});
}
});
}
}
});
},
turn: function(form,url,jsp,pageid,title) {
var me = this;
form.setLoading(true);//loading...
Ext.Ajax.request({
url : basePath + url,
params: {
id: form.down('#pr_id').value
},
method : 'post',
callback : function(options,success,response){
form.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 url2 = jsp.replace(/@@/g,id);
me.FormUtil.onAdd(pageid + id, title + id, url2);
});
}
}
});
},
getForm: function(btn){
return btn.ownerCt.ownerCt;
},
toDisable:function(){
Ext.create('Ext.window.Window',{
width:350,
height:185,
id:'win',
title:'