| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899 |
- Ext.QuickTips.init();
- Ext.define('erp.controller.pm.bom.Feature', {
- 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','pm.bom.Feature','core.grid.Panel2','core.toolbar.Toolbar',
- 'core.button.Save','core.button.Add','core.button.Upload','core.button.UpdateFeature',
- 'core.button.Submit','core.button.ResSubmit','core.button.Audit','core.button.ResAudit',
- 'core.button.Close','core.button.Delete','core.button.Update','core.button.DeleteDetail',
- 'core.trigger.DbfindTrigger','core.trigger.TextAreaTrigger','core.form.YnField','core.grid.YnColumn'
- ],
- init:function(){
- var me = this;
- this.control({
- 'erpGridPanel2': {
- itemclick: function(selModel, record){
- if(!Ext.getCmp('grid').readOnly){
- this.onGridItemClick(selModel, record);
- }
- }
- },
- 'erpGridPanel2[id=grid3]':{
-
- },
- 'erpUpdateFeatureButton': {
- afterrender: function(btn){
- var val = Ext.getCmp('fe_status').value;
- if(val != '已审核'){
- btn.hide();
- } else {
- Ext.getCmp('form').fename = Ext.getCmp('fe_name').value;//初始化fename
- btn.show();
- }
- },
- click: function(btn){
- // var val = Ext.getCmp('fe_name').value;
- // console.log(btn);
- // alert(Ext.getCmp('fe_name').readOnly);
- if(Ext.getCmp('fe_name').readOnly == true){
- Ext.getCmp('fe_name').setReadOnly(false);alert('可以修改特征名称了,修改完再次点击当前按钮即可保持修改');return;
- }
- // console.log(Ext.getCmp('fe_name'));
- // console.log(Ext.getCmp('form').fename + ' ' +Ext.getCmp('fe_name').value);
- if(Ext.getCmp('fe_name').value != Ext.getCmp('form').fename){
- me.updateFeature();
- } else {
- showError('特征名称未做修改哦!');return;
- }
- }
- },
- 'erpSaveButton': {
- click: function(btn){
- var form = me.getForm(btn);
- if(Ext.getCmp(form.codeField).value == null || Ext.getCmp(form.codeField).value == ''){
- me.BaseUtil.getRandomNumber('Feature',2,'fe_code');//自动添加编号
- }
- var flag = this.check();
- if(flag != 0){//更新前 业务逻辑检验
- return;
- }
- //保存之前的一些前台的逻辑判定
- this.beforeSave();
- }
- },
- 'erpCloseButton': {
- click: function(btn){
- this.FormUtil.beforeClose(this);
- }
- },
- 'erpUpdateButton': {
- click: function(btn){
- var flag = this.check();
- if(flag != 0){//更新前 业务逻辑检验
- return;
- }
- this.beforeUpdate();
- }
- },
- 'erpDeleteButton': {
- afterrender: function(btn){
- if(Ext.getCmp('fe_statuscode').value != 'ENTERING'){
- btn.hide();
- } else {
- btn.show();
- }
- },
- click: function(btn){
- me.FormUtil.onDelete(Ext.getCmp('fe_id').value);
- }
- },
- 'erpAddButton': {
- click: function(){
- me.FormUtil.onAdd('addFeature', '新增特征', 'jsps/pm/bom/Feature.jsp');
- }
- },
- 'erpSubmitButton': {
- afterrender: function(btn){
- var status = Ext.getCmp('fe_statuscode');
- if(status && status.value != 'ENTERING'){
- btn.hide();
- }
- },
- click: function(btn){
- me.FormUtil.onSubmit(Ext.getCmp('fe_id').value);
- }
- },
- 'erpResSubmitButton': {
- afterrender: function(btn){
- var status = Ext.getCmp('fe_statuscode');
- if(status && status.value != 'COMMITED'){
- btn.hide();
- }
- },
- click: function(btn){
- me.FormUtil.onResSubmit(Ext.getCmp('fe_id').value);
- }
- },
- 'erpAuditButton': {
- afterrender: function(btn){
- var status = Ext.getCmp('fe_statuscode');
- if(status && status.value != 'COMMITED'){
- btn.hide();
- }
- },
- click: function(btn){
- me.FormUtil.onAudit(Ext.getCmp('fe_id').value);
- }
- },
- 'erpResAuditButton': {
- afterrender: function(btn){
- var status = Ext.getCmp('fe_statuscode');
- if(status && status.value != 'AUDITED'){
- btn.hide();
- }
- },
- click: function(btn){
- me.FormUtil.onResAudit(Ext.getCmp('fe_id').value);
- }
- },
- 'textfield[id=fe_name]': {
- blur: function(field){
- if(field.value != null && Ext.getCmp('fe_status').value != '已审核'){
- me.checkName();
- }
- }
- },
- 'textfield[id=fe_status]': {//坑爹 用statuscode就是不行
- afterrender: function(field){
- // alert(field.value);
- if(field.value != '已审核'){
- Ext.getCmp('addDetail').setDisabled(true);
- Ext.getCmp('updateRemark').setDisabled(true);
- Ext.getCmp('updateSpec').setDisabled(true);
- Ext.getCmp('forbidden').setDisabled(true);
- Ext.getCmp('noforbidden').setDisabled(true);
- Ext.getCmp('addRelation').setDisabled(true);
- Ext.getCmp('offRelation').setDisabled(true);
- Ext.getCmp('toyf').setDisabled(true);
- Ext.getCmp('tobz').setDisabled(true);
- } else {
- Ext.getCmp('addDetail').setDisabled(false);
- Ext.getCmp('updateRemark').setDisabled(false);
- Ext.getCmp('updateSpec').setDisabled(false);
- Ext.getCmp('forbidden').setDisabled(false);
- Ext.getCmp('noforbidden').setDisabled(false);
- Ext.getCmp('addRelation').setDisabled(false);
- Ext.getCmp('offRelation').setDisabled(false);
- Ext.getCmp('toyf').setDisabled(false);
- Ext.getCmp('tobz').setDisabled(false);
- }
- }
- },
- 'button[id=addDetail]': {
- click: function(btn){
- me.addDetail();
- }
- },
- 'button[id=addRelation]': {
- click: function(btn){
- me.addRelation();
- }
- },
- 'combocolumn[dataIndex=fr_value]':{
- beforerender:function(column){
- column.editor= {
- format:'',
- xtype: 'combo',
- listConfig:{
- maxHeight:180
- },
- store: {
- fields: ['display', 'value'],
- data :[],
- },
- displayField: 'display',
- editable:false,
- valueField: 'value',
- queryMode: 'local',
- onTriggerClick:function(trigger){
- if(findData.length<1){
- Ext.Array.each(Ext.getCmp('grid').getStore().data.items,function(item){
- findData.push({
- display:item.data.fd_value,
- value:item.data.fd_value,
- code:item.data.fd_valuecode
- });
- });
- }
- var me=this;
- this.getStore().loadData(findData);
- if (!me.readOnly && !me.disabled) {
- if (me.isExpanded) {
- me.collapse();
- } else {
- me.expand();
- }
- me.inputEl.focus();
- }
- },
- listeners:{
- select:function(field,records){
- column.ownerCt.ownerCt.getSelectionModel().selected.items[0].set('fr_valuecode',records[0].data.code);
- }
- }
- };
- }
- },
- 'button[id=forbidden]': {
- click: function(btn){
- var grid = Ext.getCmp('grid');
- var record = grid.selModel.lastSelected;
- if(record.data.fd_statuscode != 'DISABLED'){
- Ext.Ajax.request({
- url : basePath + 'pm/bom/updateByCondition.action',
- params : {
- tablename:'FeatureDetail',
- condition: 'fd_id=' + record.data.fd_id,
- update: "fd_status='已禁用',fd_statuscode='DISABLE',fd_log='"+em_name + Ext.util.Format.date(new Date(), 'Y-m-d H:i:s') + "禁用'"
- },
- method : 'post',
- callback : function(options,success,response){
- me.GridUtil.getActiveTab().setLoading(false);
- var localJson = new Ext.decode(response.responseText);
- if(localJson.exceptionInfo){
- showError(localJson.exceptionInfo);return;
- }
- if(localJson.success){
- window.location.reload();
- }
- }
- });
- } else {
- showError('该明细已经被禁用');
- }
- }
- },
- 'button[id=offRelation]': {
- click: function(btn){
- var grid = Ext.getCmp('grid2');
- var record = grid.selModel.lastSelected;
-
- if(record&&(record.data.fr_status != '已禁用'||record.data.fr_status=='')){
- Ext.Ajax.request({
- url : basePath + 'pm/bom/updateByCondition.action',
- params : {
- tablename:'FeatureRelation',
- condition: 'fr_id=' +record.data.fr_id,
- update: "fr_status='已禁用',fr_log='"+em_name + Ext.util.Format.date(new Date(), 'Y-m-d H:i:s') + "禁用'"
- },
- method : 'post',
- callback : function(options,success,response){
- me.GridUtil.getActiveTab().setLoading(false);
- var localJson = new Ext.decode(response.responseText);
- if(localJson.exceptionInfo){
- showError(localJson.exceptionInfo);return;
- }
- if(localJson.success){
- me.GridUtil.loadNewStore(grid,{
- condition:'fr_feid='+record.data.fr_feid,
- caller:'FeatureRelation'
- });
- }
- }
- });
- } else {
- showError('未选择明细或该明细已经被禁用');
- }
- }
- },
- 'button[id=noforbidden]': {
- click: function(btn){
- var grid = Ext.getCmp('grid');
- var record = grid.selModel.lastSelected;
- if(record.data.fd_statuscode == 'DISABLE'){
- Ext.Ajax.request({
- url : basePath + 'pm/bom/updateByCondition.action',
- params : {
- tablename:'FeatureDetail',
- condition: 'fd_id=' + record.data.fd_id,
- update: "fd_status='可用',fd_statuscode='ABLED',fd_log='"+em_name + Ext.util.Format.date(new Date(), 'Y-m-d H:i:s') + "反禁用'"
- },
- method : 'post',
- callback : function(options,success,response){
- me.GridUtil.getActiveTab().setLoading(false);
- var localJson = new Ext.decode(response.responseText);
- if(localJson.exceptionInfo){
- showError(localJson.exceptionInfo);return;
- }
- if(localJson.success){
- window.location.reload();
- }
- }
- });
- } else {
- showError('该明细已经是可用');
- }
- }
- },
- 'button[id=toyf]': {
- click: function(btn){
- var grid = Ext.getCmp('grid');
- var record = grid.selModel.lastSelected;
- if(record.data.fd_style != '研发'){
- Ext.Ajax.request({
- url : basePath + 'pm/bom/updateByCondition.action',
- params : {
- tablename:'FeatureDetail',
- condition: 'fd_id=' + record.data.fd_id,
- update: "fd_style='研发',fd_log='"+em_name + Ext.util.Format.date(new Date(), 'Y-m-d H:i:s') + "转研发'"
- },
- method : 'post',
- callback : function(options,success,response){
- me.GridUtil.getActiveTab().setLoading(false);
- var localJson = new Ext.decode(response.responseText);
- if(localJson.exceptionInfo){
- showError(localJson.exceptionInfo);return;
- }
- if(localJson.success){
- window.location.reload();
- }
- }
- });
- } else {
- showError('该明细BOM阶段已经是研发');
- }
- }
- },
- 'button[id=tobz]': {
- click: function(btn){
- var grid = Ext.getCmp('grid');
- var record = grid.selModel.lastSelected;
- if(record.data.fd_style != '标准'){
- Ext.Ajax.request({
- url : basePath + 'pm/bom/updateByCondition.action',
- params : {
- tablename:'FeatureDetail',
- condition: 'fd_id=' + record.data.fd_id,
- update: "fd_style='标准',fd_log='"+em_name + Ext.util.Format.date(new Date(), 'Y-m-d H:i:s') + "转标准'"
- },
- method : 'post',
- callback : function(options,success,response){
- me.GridUtil.getActiveTab().setLoading(false);
- var localJson = new Ext.decode(response.responseText);
- if(localJson.exceptionInfo){
- showError(localJson.exceptionInfo);return;
- }
- if(localJson.success){
- window.location.reload();
- }
- }
- });
- } else {
- showError('该明细BOM阶段已经是标准');
- }
- }
- },
- 'button[id=updateRemark]': {
- click: function(btn){
- me.updateRemark();
- }
- },
- 'button[id=updateSpec]': {
- click: function(btn){
- me.updateSpec();
- }
- },
- 'gridcolumn[name=fr_value]': {
- afterrender: function(field){
- console.log(field);
- }
- },
- 'field[name=fd_ifdefault]': {
- change: function(field){
- if(field.value == -1){
- var grid = Ext.getCmp('grid');
- var items = grid.store.data.items;
- Ext.each(items, function(item){
- if(item.data.fd_ifdefault==-1 && item.data.fd_detno != grid.selModel.lastSelected.data.fd_detno){
- console.log(item.data.fd_detno+ " == "+item.data.fd_ifdefault);
- item.data.fd_ifdefault = 0;
- }
- });
- }
- }
- },
- });
- },
- onGridItemClick: function(selModel, record){//grid行选择
- this.GridUtil.onGridItemClick(selModel, record);
- },
- getForm: function(btn){
- return btn.ownerCt.ownerCt;
- },
- beforeSave: function(){
- var me = this;
- var form = Ext.getCmp('form');
- if(! me.FormUtil.checkForm()){
- return;
- }
- if(Ext.getCmp(form.keyField).value == null || Ext.getCmp(form.keyField).value == ''){
- me.FormUtil.getSeqId(form);
- }
- var detail = Ext.getCmp('grid');
- var relation = Ext.getCmp('grid2');
- var param1 = me.GridUtil.getGridStore(detail);
- var param2 = me.GridUtil.getGridStore(relation);
- if(detail.necessaryField.length > 0 && (param1.length == 0)){
- showError($I18N.common.grid.emptyDetail);
- return;
- } else {
- param1 = param1 == null ? [] : "[" + param1.toString().replace(/\\/g,"%") + "]";
- param2 = param2 == null ? [] : "[" + param2.toString().replace(/\\/g,"%") + "]";
- if(form.getForm().isValid()){
- Ext.each(form.items.items, function(item){
- if(item.xtype == 'numberfield'){
- if(item.value == null || item.value == ''){
- item.setValue(0);
- }
- }
- });
- var r = form.getValues();
- me.FormUtil.save(r, param1, param2);
- }else{
- me.FormUtil.checkForm();
- }
- }
- },
- beforeUpdate: function(){
- var me = this;
- var form = Ext.getCmp('form');
- if(! me.FormUtil.checkForm()){
- return;
- }
- if(Ext.getCmp(form.keyField).value == null || Ext.getCmp(form.keyField).value == ''){
- me.FormUtil.getSeqId(form);
- }
- var detail = Ext.getCmp('grid');
- var relation = Ext.getCmp('grid2');
- var param1 = me.GridUtil.getGridStore(detail);
- var param2 = me.GridUtil.getGridStore(relation);
- if(me.FormUtil.checkFormDirty() == '' && detail.necessaryField.length > 0 && (param1.length == 0) && (relation.necessaryField.length > 0 && (param2.length == 0))){
- showError($I18N.common.form.emptyData + '<br/>' + $I18N.common.grid.emptyDetail);
- return;
- } else {
- param1 = param1 == null ? [] : "[" + param1.toString().replace(/\\/g,"%") + "]";
- param2 = param2 == null ? [] : "[" + param2.toString().replace(/\\/g,"%") + "]";
- if(form.getForm().isValid()){
- Ext.each(form.items.items, function(item){
- if(item.xtype == 'numberfield'){
- if(item.value == null || item.value == ''){
- item.setValue(0);
- }
- }
- });
- var r = form.getValues();
- me.FormUtil.update(r, param1, param2);
- }else{
- me.FormUtil.checkForm();
- }
- }
- },
- check: function(){
- var flag=0;
- var grid = Ext.getCmp('grid');
- var items = grid.store.data.items;
- Ext.each(items, function(item, i){
- if(item.dirty&&flag==0){
- if(item.data.fd_value == '' || item.data.fd_value == null){
- showError("特征值不能为空");flag=1;//return;
- }else if(item.data.fd_valuecode == '' || item.data.fd_valuecode == null){
- showError("特征值码不能为空");flag=1;//return;
- }else if(item.data.fd_style == ''||item.data.fd_style == null){
- showError("BOM阶段不能为空"); flag=1;
- }
- Ext.each(items, function(t, j){
- if(i != j && item.data.fd_value == t.data.fd_value){
- showError("特征值不能重复");flag=1;//return;
- }else if(i != j && item.data.fd_valuecode == t.data.fd_valuecode){
- showError("特征值码不能重复");flag=1;//return;
- }
- });
-
- }
- });
- return flag;
- },
- checkName: function(){
- Ext.Ajax.request({//拿到grid的columns
- url : basePath + "pm/bom/checkName.action",
- params: {
- name: Ext.getCmp('fe_name').value
- },
- method : 'post',
- callback : function(options,success,response){
- var res = new Ext.decode(response.responseText);
- if(res.exceptionInfo){
- showError(res.exceptionInfo);return;
- }
- if(res.success){
- if(res.flag == 0){
- // alert('特征名称可用成功');
- // window.location.href = window.location.href;
- } else if (res.flag == 1){
- showError('特征名称已经存在,请重新修改');return;
- }
- }
- }
- });
- },
- updateFeature: function(){
- Ext.Ajax.request({//拿到grid的columns
- url : basePath + "pm/bom/updateFeatureName.action",
- params: {
- id: Ext.getCmp('fe_id').value,
- name: Ext.getCmp('fe_name').value
- },
- method : 'post',
- callback : function(options,success,response){
- var res = new Ext.decode(response.responseText);
- if(res.exceptionInfo){
- showError(res.exceptionInfo);return;
- }
- if(res.success){
- if(res.flag == 0){
- alert('更新成功');
- window.location.href = window.location.href;
- } else if (res.flag == 1){
- showError('特征名称已经存在,请重新修改');return;
- }
- }
- }
- });
- },
- addDetail: function(){
- var me = this;
- var win = new Ext.window.Window({
- id : 'win',
- title: "添加特征明细",
- height: "50%",
- width: "60%",
- maximizable : false,
- buttonAlign : 'center',
- layout : 'anchor',
- items: [{
- xtype: 'erpGridPanel2',
- anchor: '100% 100%',
- // title:'允许特征值列表',
- id:'grid3',
- condition: '1<>1',
- readOnly: false,
- caller:'FeatureDetail',
- detno: 'fd_detno',
- keyField: 'fd_id',
- mainField: 'fd_feid',
- necessaryField: 'fd_value',
- plugins: [Ext.create('Ext.grid.plugin.CellEditing', {
- clicksToEdit: 1
- })],
- }],
- bbar: ['->',{
- text:'编辑',
- handler: function(btn){
- var grid=Ext.getCmp('grid3');
- if(grid.readOnly){
- grid.readOnly=false;
- btn.hide();
- } else {
- btn.hide();
- }
-
- }
- },{
- text:'保存',
- listeners: {
- click: function(){
- var grid = Ext.getCmp('grid3');
- var detno = Ext.getCmp('grid').getStore().getCount();
- console.log(grid.store.data.items);
- var error = '';
- Ext.each(grid.store.data.items, function(item){
- if(item.dirty){
- if(item.data.fd_value == '' || item.data.fd_value == null){
- error = "特征值不能为空";return;
- }
- if(item.data.fd_valuecode == '' || item.data.fd_valuecode == null){
- error = "特征值码不能为空";return;
- }
- Ext.each(Ext.getCmp('grid').store.data.items, function(it, i){
- if(item.data.fd_value == it.data.fd_value || item.data.fd_valuecode == it.data.fd_valuecode){
- error = "特征值或特征值码已经存在,不能重复";return;
- }
- });
- }
- });
- if(error != ''){
- showError(error);return;
- }
- Ext.each(grid.store.data.items, function(item){
- if(item.dirty == true){
- item.set('fd_code', Ext.getCmp('fe_code').value);
- item.set('fd_detno', ++detno);
- item.set('fd_log', em_name + '(' + em_code + ') 于 ' + Ext.util.Format.date(new Date(), 'Y-m-d H:i:s') + " 增加特征明细");
- }
- });
- var param = me.GridUtil.getGridStore(grid);
- if(grid.necessaryField.length > 0 && (param == null || param == '')){
- showError('明细表还未添加数据');return;
- } else {
- me.GridUtil.getActiveTab().setLoading(true);//loading...
- Ext.Ajax.request({
- url : basePath + 'pm/bom/addFeatureDetail.action',
- params : {
- param: unescape(param.toString().replace(/\\/g,"%"))
- },
- method : 'post',
- callback : function(options,success,response){
- me.GridUtil.getActiveTab().setLoading(false);
- var localJson = new Ext.decode(response.responseText);
- if(localJson.exceptionInfo){
- showError(localJson.exceptionInfo);return;
- }
- if(localJson.success){
- // window.close();
- window.location.href = window.location.href;
- }
- }
- });
- }
- }
- }
- },'->']
- });
- win.show();
- },
- updateRemark: function(selModel, record){
- var me = this;
- var grid = Ext.getCmp('grid');
- var record = grid.selModel.lastSelected;
- var win = new Ext.window.Window({
- id : 'win2',
- title: "修改明细备注 (" + record.data.fd_id + ")",
- height: "200px",
- width: "400px",
- maximizable : false,
- buttonAlign : 'center',
- layout : 'anchor',
- items: [{
- xtype: 'textarea',
- anchor : '100% 100%',
- // fieldLabel:'备注',
- value: record.data.fd_remark,
- id:'remark',
- }],
- bbar: ['->',{
- iconCls: 'x-button-icon-submit',
- cls: 'x-btn-gray',
- text: '修 改',
- handler: function(){
- Ext.Ajax.request({
- url : basePath + 'pm/bom/updateRemark.action',
- params : {
- id: record.data.fd_id,
- remark: Ext.getCmp('remark').value
- },
- method : 'post',
- callback : function(options,success,response){
- me.GridUtil.getActiveTab().setLoading(false);
- var localJson = new Ext.decode(response.responseText);
- if(localJson.exceptionInfo){
- showError(localJson.exceptionInfo);return;
- }
- if(localJson.success){
- // window.close();
- window.location.href = window.location.href;
- }
- }
- });
- }
- },'->']
- });
- win.show();
- },
- updateSpec:function(selModel, record){
- var me = this;
- var grid = Ext.getCmp('grid');
- var record = grid.selModel.lastSelected;
- var win = new Ext.window.Window({
- id : 'win2',
- title: "修改规格描述 (" + record.data.fd_id + ")",
- height: "200px",
- width: "400px",
- maximizable : false,
- buttonAlign : 'center',
- layout : 'anchor',
- items: [{
- xtype: 'textarea',
- anchor : '100% 100%',
- // fieldLabel:'备注',
- value: record.data.fd_spec,
- id:'spec',
- }],
- bbar: ['->',{
- iconCls: 'x-button-icon-submit',
- cls: 'x-btn-gray',
- text: '修 改',
- handler: function(){
- Ext.Ajax.request({
- url : basePath + 'pm/bom/updateSpec.action',
- params : {
- id: record.data.fd_id,
- spec: Ext.getCmp('spec').value
- },
- method : 'post',
- callback : function(options,success,response){
- me.GridUtil.getActiveTab().setLoading(false);
- var localJson = new Ext.decode(response.responseText);
- if(localJson.exceptionInfo){
- showError(localJson.exceptionInfo);return;
- }
- if(localJson.success){
- // window.close();
- window.location.href = window.location.href;
- }
- }
- });
- }
- },'->']
- });
- win.show();
- },
- addRelation: function(){
- var me = this;
- var win = new Ext.window.Window({
- id : 'win',
- title: "添加约束",
- height: "60%",
- width: "80%",
- maximizable : false,
- buttonAlign : 'center',
- layout : 'anchor',
- items: [{
- xtype: 'erpGridPanel2',
- anchor: '100% 100%',
- // title:'允许特征值列表',
- id:'grid4',
- condition: '1<>1',
- readOnly: false,
- caller:'FeatureRelation',
- detno: 'fr_detno',
- keyField: 'fr_id',
- mainField: 'fr_feid',
- necessaryField: 'fr_value',
- bbar:{},
- listeners:{
- itemclick: function(selModel, record){
- me.GridUtil.onGridItemClick(selModel, record);
- }
- },
- plugins: [Ext.create('Ext.grid.plugin.CellEditing', {
- clicksToEdit: 1
- })],
- }],
- bbar: ['->',{
- text:'编辑',
- handler: function(btn){
- var grid=Ext.getCmp('grid4');
- if(grid.readOnly){
- grid.readOnly=false;
- var basegrid=Ext.getCmp('grid2');
- var maxdetno=0;
- Ext.Array.each(basegrid.store.data.items,function(item){
- if(item.data.fr_fecode>maxdetno){
- maxdetno=item.data.fr_detno;
- }
- });
- var gridstore=grid.store;
- var adddata=new Array();
- for(var k=0;k<20;k++){
- var o=new Object();
- o.fr_detno=k+maxdetno+1;
- adddata.push(o);
- }
- gridstore.loadData(adddata);
- btn.hide();
- } else {
- btn.hide();
- }
-
- }
- },{
- text:'保存',
- listeners: {
- click: function(){
- var grid = Ext.getCmp('grid4');
- var detno = Ext.getCmp('grid').getStore().getCount();
- var error = '';
- Ext.each(grid.store.data.items, function(item){
- if(item.dirty == true){
- if(item.data.fr_value == ''){
- error = "特征值不能为空";return;
- // showError("特征值不能为空");return;
- }
- if(item.data.fr_relacode == '' || item.data.fr_relaname == '' || item.data.fr_relavalue == ''){
- // showError("被约束特征信息不能为空");return;
- error = "被约束特征信息不能为空";return;
- }
- if(item.data.fr_relacode == item.data.fr_fecode){
- // showError("被约束特征ID不能是自己");return;
- error = "被约束特征ID不能是自己";return;
- }
- Ext.Ajax.request({
- url : basePath + 'pm/bom/getDescription.action',
- params : {
- tablename: "FeatureDetail",
- field: 'fd_id',
- condition: "fd_code='" + item.data.fr_relacode + "' and fd_value='" + item.data.fr_relavalue + "'",
- },
- method : 'post',
- callback : function(options,success,response){
- me.GridUtil.getActiveTab().setLoading(false);
- var localJson = new Ext.decode(response.responseText);
- if(localJson.exceptionInfo){
- // showError(localJson.exceptionInfo);return;
- error = localJson.exceptionInfo;return;
- }
- if(localJson.success){
- if(localJson.description == null){
- // showError("被约束特征不存在");return;
- error = "被约束特征不存在";return;
- }
- }
- }
- });
- }
- });
- if(error != ''){
- showError(error);return;
- }
- Ext.each(grid.store.data.items, function(item){
- if(item.dirty == true){
- item.set('fr_fecode', Ext.getCmp('fe_code').value);
- item.set('fr_fename', Ext.getCmp('fe_name').value);
- item.set('fr_log', em_name + '(' + em_code + ') 于 ' + Ext.util.Format.date(new Date(), 'Y-m-d H:i:s') + " 增加约束");
- }
- });
- var param = me.GridUtil.getGridStore(grid);
- if(grid.necessaryField.length > 0 && (param == null || param == '')){
- showError('明细表还未添加数据');return;
- } else {
- me.GridUtil.getActiveTab().setLoading(true);//loading...
- Ext.Ajax.request({
- url : basePath + 'pm/bom/addFeatureRelation.action',
- params : {
- param: unescape(param.toString().replace(/\\/g,"%"))
- },
- method : 'post',
- callback : function(options,success,response){
- me.GridUtil.getActiveTab().setLoading(false);
- var localJson = new Ext.decode(response.responseText);
- if(localJson.exceptionInfo){
- showError(localJson.exceptionInfo);return;
- }
- if(localJson.success){
- // window.close();
- window.location.reload();
- }
- }
- });
- }
- }
- }
- },'->']
- });
- win.show();
- },
- });
|