Index: ssts-web/src/main/webapp/disinfectsystem/deviceMaintenance/deviceMaintenanceView.js =================================================================== diff -u -r15609 -r17168 --- ssts-web/src/main/webapp/disinfectsystem/deviceMaintenance/deviceMaintenanceView.js (.../deviceMaintenanceView.js) (revision 15609) +++ ssts-web/src/main/webapp/disinfectsystem/deviceMaintenance/deviceMaintenanceView.js (.../deviceMaintenanceView.js) (revision 17168) @@ -13,6 +13,10 @@ name : 'id' },{ name : 'materialName' + },{ + name : 'amount' + },{ + name : 'price' }] }); @@ -46,8 +50,30 @@ },{ id : 'materialName', header : "耗材名称", - width:240, + width:260, dataIndex : 'materialName' + },{ + id : 'amount', + header : "数量", + width:80, + dataIndex : 'amount', + editor : new top.Ext.form.NumberField({ + id : 'amountName', + name : 'amountName', + allowBlank : false, + anchor : '90%' + }) + },{ + id : 'price', + header : "价格", + width:80, + dataIndex : 'price', + editor : new top.Ext.form.NumberField({ + id : 'priceName', + name : 'priceName', + allowBlank : false, + anchor : '90%' + }) }]); var projectNameStore = new Ext.data.SimpleStore({ @@ -200,6 +226,19 @@ } }] },{ + columnWidth : .5, + layout : 'form', + labelWidth : 70, + items : [{ + xtype : 'textfield', + fieldLabel : '总价', + id : 'totalPrice', + name : 'totalPrice', + allowBlank : true, + readOnly:true, + anchor : '95%' + }] + },{ columnWidth : 1, layout : 'form', labelWidth : 70, @@ -228,24 +267,38 @@ },{ columnWidth : 1, layout: 'form', + labelWidth : 70, items : [ - new top.Ext.grid.GridPanel({ + new top.Ext.grid.EditorGridPanel({ id : 'configGrid', store : consumptiveConfigStore, title : '耗材更换', cm : cm, sm : selectModel, - width : 240, - height: 240, + width : 430, + height: 260, frame : false, - viewConfig: { - forceFit:true - }, bodyStyle : 'border:1px solid #afd7af', - anchor : '100%', + anchor : '95%', + clicksToEdit : 1,//设置点击几次才可编辑 selModel : new top.Ext.grid.RowSelectionModel({ singleSelect : false - }) + }), + tbar : [{ + text : '计算总价', + iconCls : 'btn_ext_edit', + handler : function() { + var records = top.Ext.getCmp("configGrid").getSelectionModel().getSelections(); + var totalPrice = 0; + for ( var i = 0, len = records.length; i < len; i++) { + var amount = records[i].data['amount']; + var price = records[i].data['price']; + var temPrice = amount*price; + totalPrice += temPrice; + } + top.Ext.getCmp("totalPrice").setValue(totalPrice); + } + }] }) ] }] @@ -284,19 +337,19 @@ return false; } var records = top.Ext.getCmp("configGrid").getSelectionModel().getSelections(); - var ids = null; + var datas = null; for ( var i = 0, len = records.length; i < len; i++) { - if (ids == null) { - ids = records[i].data['id']; + if (datas == null) { + datas = records[i].data['id'] + '_' + records[i].data['amount'] + '_' + records[i].data['price']; } else { - ids = ids + ';' + records[i].data['id']; + datas = datas + ';' + records[i].data['id'] + '_' + records[i].data['amount'] + '_' + records[i].data['price']; } } formObj.form.submit({ url : WWWROOT + '/disinfectSystem/deviceMaintenanceAction!saveDeviceMaintenance.do', method : 'POST', - params:{ids : ids}, + params:{datas : datas}, waitMsg : '正在保存数据,请稍候', waitTitle : '提交表单', success : function(form, action) { @@ -368,17 +421,20 @@ success : function(form, action) { top.Ext.getCmp("maintenanceTime").setValue(Ext.util.Format.date(new Date(action.result.data.maintenanceTime.time), 'Y-m-d H:i')); top.Ext.getCmp("breakdownTime").setValue(Ext.util.Format.date(new Date(action.result.data.breakdownTime.time), 'Y-m-d H:i')); + consumptiveConfigStore.baseParams.deviceMaintenanceId = id; consumptiveConfigStore.reload(); - var consumptiveLength = action.result.data.consumptive.length; + var consumptiveInstancesLength = action.result.data.consumptiveInstances.length; //获取已经选中的数据 consumptiveConfigStore.on("load",function(store, recordArry, options){ - if(consumptiveLength > 0){ + if(consumptiveInstancesLength > 0){ var records=[]; for ( var j = 0; j < recordArry.length; j++) { var id = recordArry[j].data.id; - for ( var i = 0; i < consumptiveLength; i++) { - var tempId = action.result.data.consumptive[i].id; + for ( var i = 0; i < consumptiveInstancesLength; i++) { + var tempId = action.result.data.consumptiveInstances[i].conConfig.id; if(id == tempId){ +// store.getAt(j).set('amount',action.result.data.consumptiveInstances[i].amount); +// store.getAt(j).set('price',action.result.data.consumptiveInstances[i].price); records.push(recordArry[j]); } }