| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484 |
- 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?<br> 2)电感,规格参数写明功率W?<br>3)晶振,描述中说明是否已装配 <br>4)滤波器,注明是否电磁干扰等<br> 5)二极管,三极管,规格参数写明功率W <br>6)电容,规格参数写明电容量UF<br> 7)集成电路,描述中写明是否加密,具体用途及功能(如控制处理功能,驱动功能,触摸功能等等),存储功能的必须写明存储量G或m<br>8)手机用XX英寸电容式触摸屏,需写明是否含液晶,以及组成,适用于何种品牌和型号的手机,(不含触摸功能的品名直接申报为手机用液晶屏,含触摸功能的液晶屏申报品名为电容式触摸屏含液晶即可)<br> 9)xx英寸彩色液晶屏,需写明是否有触摸功能,制造工艺,工作原理,是否含背光,驱动电路板等等<br> 10)开关,规格参数写明工作电压V(36V以下的,需提前一天提供能证明电压是36V以下的说明书用于办理商检免3c认证,36V以上需提供3c证书)<br> 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 : '<iframe id="iframe_' + id + '" src="' + basePath +
- "jsps/pm/bom/FeatureValueView.jsp?fromwhere=SaleDetail&formid=" + id + '&pr_code=' + code +'" height="100%" width="100%" frameborder="0" scrolling="yes"></iframe>'
- }]
- });
- 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 : '<iframe id="iframe_' + id + '" src="' + basePath +
- "jsps/pm/bom/FeatureValueSet.jsp?fromwhere=SaleDetail&condition=formidIS" + id + ' AND pr_codeIS' + code + ' AND pr_nameIS' + name +'" height="100%" width="100%" frameborder="0" scrolling="yes"></iframe>'
- }]
- });
- 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 : '<iframe id="iframe_' + prcode + '" src="' + basePath +
- 'jsps/pm/bom/ProdFeature.jsp?formCondition='+formCondition+'&&gridCondition='+gridCondition+'" height="100%" width="100%" frameborder="0" scrolling="yes"></iframe>'
- }]
- });
- 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:'<h1>禁用物料</h1>',
- layout:'column',
- items:[{
- margin: '10 0 0 0',
- xtype: 'textfield',
- fieldLabel: '禁用备注',
- name:'disremark',
- value: '',
- }],
- buttonAlign:'center',
- buttons:[{
- xtype:'button',
- columnWidth:0.12,
- text:'确定',
- width:60,
- iconCls: 'x-button-icon-save',
- handler:function(btn){
- var remark=btn.ownerCt.ownerCt.down('textfield[name=disremark]').value;
- if (remark==null || remark==''){
- showError('禁用备注必须填写');
- }
- Ext.Ajax.request({
- url : basePath + 'scm/product/bannedProduct.action',
- params: {
- id:Ext.getCmp('pr_id').value,
- remark: remark
- },
- method : 'post',
- callback: function(opt, s, r) {
- var rs = Ext.decode(r.responseText);
- if(rs.exceptionInfo) {
- showError(rs.exceptionInfo);
- } else {
- alert('更新成功!');
- window.location.reload();
- }
- }
- });
- }
- },{
- xtype:'button',
- columnWidth:0.1,
- text:'取消',
- width:60,
- iconCls: 'x-button-icon-close',
- margin:'0 0 0 10',
- handler:function(btn){
- Ext.getCmp('win').close();
- }
- }]
- }).show();
- }
- });
|