erp2buyorder.js
来自「anewssystem新闻发布系统集成使用了spring hibernate f」· JavaScript 代码 · 共 919 行 · 第 1/3 页
JS
919 行
width:200,
allowBlank:false
}),
new Ext.form.TextField({
fieldLabel:'订单签订人员',
name:'username',
width:200
})
);
form.end();
form.fieldset(
{id:'insert-grid', legend:'订单详情', hideLabels:true}
);
//
this.form = form;
},
createGrid : function() {
// 选择产品的combo
var productDataStore = new Ext.data.Store({
proxy: new Ext.data.HttpProxy({url:'../erp2product/pagedQuery.htm'}),
reader: new Ext.data.JsonReader({
root : "result",
totalProperty : "totalCount",
id : "id"
},['id','name','material','factory','type','price','unit'])
});
var productCombo = new Ext.form.ComboBox({
id:'productId2',
name:'productName',
readOnly:true,
fieldLabel:'产品名称',
hiddenName:'productName',
store:productDataStore,
valueField:'id',
displayField:'name',
typeAhead:true,
mode:'remote',
triggerAction:'all',
emptyText:'请选择',
selectOnFocus:true,
width:200,
allowBlank:false,
pageSize:10
});
// 列模型
var cm = new Ext.grid.ColumnModel([{
header:"序号",
dataIndex:"id",
width:40
},{
header:"编号",
dataIndex:"code",
editor:new Ext.grid.GridEditor(new Ext.form.TextField({allowBlank:false})),
width:40
},{
header:"商品名称",
dataIndex:"productName",
editor:new Ext.grid.GridEditor(productCombo),
width:100,
renderer:function(value, cellmeta, record, RowIndex, ColumnIndex, store){
try {
var productId = productCombo.getValue();
var productRecord = productDataStore.getById(productId);
return productRecord.data.name;
} catch(e) {
return value;
}
}
},{
header:"类别",
dataIndex:"productType",
width:40,
renderer:function(value){
if (value == 0) {
return "<span style='color:green;'>染料</span>";
} else if (value == 1) {
return "<span style='color:black;'>助剂</span>";
} else if (value == 2) {
return "<span style='color:blue;'>设备</span>";
}
}
},{
header:"型号",
dataIndex:"material",
width:40
},{
header:"生产厂家",
dataIndex:"factory",
width:70
},{
header:"技术参数",
dataIndex:"parameter",
editor:new Ext.grid.GridEditor(new Ext.form.TextField({allowBlank:false})),
width:70
},{
header:'数量',
dataIndex:'num',
editor:new Ext.grid.GridEditor(new Ext.form.NumberField({allowBlank:false})),
width:50
},{
header:'计量单位',
dataIndex:'unit',
width:70,
renderer:function(value){
if (value == 0) {
return '千克';
} else if (value == 1) {
return '克';
} else if (value == 2) {
return '升';
} else if (value == 3) {
return '毫升';
} else if (value == 4) {
return '台';
}
},
editor:new Ext.grid.GridEditor(new Ext.form.ComboBox({
id:'unitId',
name:'unit',
readOnly:true,
fieldLabel: '计量单位',
hiddenName:'unit',
store: new Ext.data.SimpleStore({
fields: ['id', 'name'],
data : [['0','千克'],['1','克'],['2','升'],['3','毫升'],['4','台']]
}),
valueField:'id',
displayField:'name',
typeAhead: true,
mode: 'local',
triggerAction: 'all',
emptyText:'请选择',
selectOnFocus:true
}))
},{
header:'单价(元)',
dataIndex:'price',
editor:new Ext.grid.GridEditor(new Ext.form.NumberField({allowBlank:false})),
width:70
},{
header:'金额(元)',
dataIndex:'totalPrice',
width:70
},{
header:'备注',
dataIndex:'descn',
editor:new Ext.grid.GridEditor(new Ext.form.TextField({allowBlank:false})),
width:70
}]);
cm.defaultSortable = true;//排序
// 数据存储器
var ds = new Ext.data.Store({
proxy:new Ext.data.HttpProxy({url:'getBuyOrderInfosByBuyOrder.htm'}),
reader:new Ext.data.JsonReader({}, this.RecordBuyOrderInfo),
remoteSort:false
});
productCombo.on('select', function(){
// 取得产品信息
var productId = productCombo.getValue();
var productRecord = productDataStore.getById(productId);
// 取得选中这行的record
var cell = grid.getSelectionModel().getSelectedCell();
var record = ds.getAt(cell[0]);
record.data.productId = productRecord.data.id;
if (productRecord.data.type == 0) {
record.data.code = 'RL' + new Date().format("Ymd") + "xxxx";
} else if (productRecord.data.type == 1) {
record.data.code = 'ZJ' + new Date().format("Ymd") + "xxxx";
} else if (productRecord.data.type == 2) {
record.data.code = 'SB' + new Date().format("Ymd") + "xxxx";
}
record.data.productName = productRecord.data.name;
record.data.productType = productRecord.data.type;
record.data.material = productRecord.data.material;
record.data.factory = productRecord.data.factory;
record.data.unit = productRecord.data.unit;
record.data.price = productRecord.data.price;
return false;
});
var gridDiv = Ext.get('insert-grid');
gridDiv.createChild({
tag:'div',
id:'insert-grid2-container',
cn:[{
tag:'div',
id:'insert-grid2',
style:'border:1px solid #6FA0DF;'
},{
tag:'div',
style:'margin-top:5px;margin-bottom:5px;',
cn:[{
tag:'span',
html:'金额合计:'
},{
tag:'span',
id:'amount1',
html:'0'
},{
tag:'span',
html:'元 (大写) '
},{
tag:'span',
id:'amount2',
html:'零'
}]
}]
});
/*
insertGrid.createChild({
tag:'div',
id:'insert-grid2-resize'
});
*/
var grid = new Ext.grid.EditorGrid('insert-grid2', {ds: ds, cm: cm, enableColLock: false});
ds.on("update", function() {
var amount = 0;
for(var i = 0, len = ds.getCount(); i < len; i++){
var record = ds.getAt(i);
var num = record.data.num;
var price = record.data.price;
record.data.totalPrice = num * price;
amount += record.data.totalPrice;
}
document.getElementById("amount1").innerHTML = amount;
document.getElementById("amount2").innerHTML = convertCurrency(amount);
});
/*
var rz = new Ext.Resizable('insert-grid2-resize', {
wrap:true,
minHeight:100,
pinned:true,
handles:'s'
});
rz.on('resize', insertGrid.autoSize, insertGrid);
*/
grid.render();
// 页头
var gridHead = grid.getView().getHeaderPanel(true);
var tb = new Ext.Toolbar(gridHead, [{
text: '添加',
handler : function(){
var entity = new EditForm.RecordBuyOrderInfo({
id:-1,
code:'',
productId:-1,
productName:'',
productType:'',
material:'',
parameter:'',
factory:'',
num:0,
unit:'',
price:'',
totalPrice:'',
descn:''
});
grid.stopEditing();
ds.insert(0, entity);
grid.startEditing(0, 1);
}
}, {
text: '删除',
handler: function() {
if(grid.getSelectionModel().hasSelection()) {
Ext.MessageBox.confirm('提示', '是否确定删除' , function(btn){
if(btn == 'yes') {
var cell = grid.getSelectionModel().getSelectedCell();
var record = ds.getAt(cell[0]);
var id = record.get("id");
ds.remove(record);
if (id != -1) {
Ext.Ajax.request({
url : '../erp2buyorderinfo/remove.htm?ids=' + id,
success : function() {
Ext.MessageBox.alert('提示', '删除成功!');
},
failure : function(){
Ext.MessageBox.alert('提示', '删除失败!');
}
});
}
}
});
} else {
Ext.MessageBox.alert('警告', '至少要选择一条记录');
}
}
}]);
this.grid = grid;
}
};
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?