?? erp2buyorder.js
字號:
EditForm = {
getInsertForm : function(closeTagHandler) {
this.createForm('./insert.htm', 'insert-box');
var form = this.form;
form.addButton({
text:'提交',
handler:function(){
if (!form.isValid()){
return;
}
form.el.mask('提交數據,請稍候...', 'x-mask-loading');
var hide = function(){
form.el.unmask();
};
var buyOrderValue = EditForm.form.getValues();
buyOrderValue.totalPrice = document.getElementById("amount1").innerHTML;
EditForm.grid.stopEditing();
var infoValues = new Array();
var ds = EditForm.grid.dataSource;
for (var i = 0; i < ds.getCount(); i++) {
var record = ds.getAt(i);
var item = {};
item.id = record.data.id;
item.productId = record.data.productId;
item.code = record.data.code;
item.parameter = record.data.parameter;
item.num = record.data.num;
item.unit = record.data.unit;
item.price = record.data.price;
item.totalPrice = record.data.totalPrice;
item.descn = record.data.descn;
infoValues.push(item);
}
var json = {buyOrderValue:buyOrderValue,infos:infoValues}
Ext.lib.Ajax.request(
'POST',
'./insert.htm',
{success:function(){
form.el.unmask();
Ext.MessageBox.confirm('提示', '保存添加成功,是否繼續添加', function(btn){
if (btn == 'yes') {
form.reset();
EditForm.grid.dataSource.removeAll();
EditForm.form.findField("statusId2").clearValue("");
EditForm.form.findField("supplierNameId2").clearValue("");
EditForm.form.findField("auditId2").clearValue("");
} else {
closeTagHandler();
}
});
},failure:function(){
form.el.unmask();
}},
'data=' + encodeURIComponent(Ext.encode(json))
);
}
});
form.addButton({
text:'重置',
handler:function(){
form.reset();
EditForm.grid.dataSource.removeAll();
EditForm.form.findField("statusId2").clearValue("");
EditForm.form.findField("supplierNameId2").clearValue("");
EditForm.form.findField("auditId2").clearValue("");
}
});
form.addButton({
text:'取消',
handler:closeTagHandler
});
form.render("insert-form");
this.createGrid();
var grid = this.grid;
return form;
},
getUpdateForm : function(closeTagHandler, id) {
this.createForm('./update.htm', 'update-box');
this.id = id;
var form = this.form;
form.load({url:'./loadData.htm?id=' + id});
form.addButton({
text:'提交',
handler:function(){
if (!form.isValid()) {
return;
}
form.el.mask('提交數據,請稍候...', 'x-mask-loading');
var hide = function() {
form.el.unmask();
};
var buyOrderValue = EditForm.form.getValues();
buyOrderValue.totalPrice = document.getElementById("amount1").innerHTML;
buyOrderValue.id = EditForm.id;
EditForm.grid.stopEditing();
var infoValues = new Array();
var ds = EditForm.grid.dataSource;
for (var i = 0; i < ds.getCount(); i++) {
var record = ds.getAt(i);
var item = {};
item.id = record.data.id;
item.productId = record.data.productId;
item.code = record.data.code;
item.parameter = record.data.parameter;
item.num = record.data.num;
item.unit = record.data.unit;
item.price = record.data.price;
item.totalPrice = record.data.totalPrice;
item.descn = record.data.descn;
infoValues.push(item);
}
var json = {buyOrderValue:buyOrderValue,infos:infoValues}
Ext.lib.Ajax.request(
'POST',
'./update.htm',
{success:function(){
form.el.unmask();
Ext.MessageBox.confirm('提示', '修改成功,是否返回' , function(btn){
if (btn == 'yes') {
closeTagHandler();
} else {
form.reset();
EditForm.grid.dataSource.load({params:{id:EditForm.id}});
}
});
},failure:function(){
form.el.unmask();
}},
'data=' + encodeURIComponent(Ext.encode(json))
);
}
});
form.addButton({
text:'重置',
handler:function(){
form.load({url:'./loadData.htm?id=' + this.id});
}
});
form.addButton({
text:'取消',
handler:closeTagHandler
});
form.render("update-form");
this.createGrid();
var grid = this.grid;
grid.dataSource.load({params:{id:id}});
return form;
},
getRecordBuyOrderInfo : function() {
// 數據模型
this.RecordBuyOrderInfo = Ext.data.Record.create([
{name:"id"},
{name:"code"},
{name:'productId',mapping:'erp2Product.id'},
{name:"productName",mapping:'erp2Product.name'},
{name:"productType",mapping:'erp2Product.type'},
{name:"material",mapping:'erp2Product.material'},
{name:'parameter'},
{name:"factory",mapping:'erp2Product.factory'},
{name:"num"},
{name:"unit"},
{name:"price"},
{name:"totalPrice"},
{name:"descn"}
]);
},
createForm : function(url, waitMsgTarget) {
this.getRecordBuyOrderInfo();
var form = new Ext.form.Form({
labelAlign:'right',
labelWidth:80,
url:url,
method: 'POST',
waitMsgTarget:waitMsgTarget,
reader : new Ext.data.JsonReader({}, [
'code',
'status',
'name',
{name:'supplierName',mapping:'erp2Supplier.name'},
'linkman',
'provideDate',
'orderDate',
'audit',
'username'
])
});
form.fieldset(
{legend:'采購訂單', hideLabels:false}
);
var supplierDataStore = new Ext.data.Store({
proxy: new Ext.data.HttpProxy({url:'../erp2supplier/pagedQueryForCombo.htm'}),
reader: new Ext.data.JsonReader({
root : "result",
totalProperty : "totalCount",
id : "id"
},['id','name'])
})
var supplierName = new Ext.form.ComboBox({
id:'supplierNameId2',
name:'supplierName',
readOnly:true,
fieldLabel:'供應商名稱',
hiddenName:'supplierName',
store: supplierDataStore,
valueField:'id',
displayField:'name',
typeAhead:true,
mode:'remove',
triggerAction:'all',
emptyText:'請選擇',
selectOnFocus:true,
width:200,
allowBlank:false,
pageSize:10
});
form.column(
{width:320},
new Ext.form.TextField({
fieldLabel:'采購訂單編號',
name:'code',
width:200
}),
new Ext.form.ComboBox({
id:'statusId2',
name:'status',
readOnly:true,
fieldLabel:'訂單狀態',
hiddenName:'status',
store: new Ext.data.SimpleStore({
fields:['id', 'name'],
data:[[0,'待審'],[1,'審核'],[2,'完成']]
}),
valueField:'id',
displayField:'name',
typeAhead:true,
mode:'local',
triggerAction:'all',
emptyText:'請選擇',
selectOnFocus:true,
width:200,
allowBlank:false
}),
new Ext.form.TextField({
fieldLabel:'訂單名稱',
name:'name',
width:200
}),
supplierName,
new Ext.form.TextField({
fieldLabel:'聯系人',
name:'linkman',
width:200
})
);
form.column(
{width:320, clear:true},
new Ext.form.DateField({
fieldLabel:'要求供貨日期',
name:'provideDate',
width:200,
format:'Y-m-d'
}),
new Ext.form.DateField({
fieldLabel:'簽訂日期',
name:'orderDate',
width:200,
format:'Y-m-d'
}),
new Ext.form.ComboBox({
id:'auditId2',
name:'audit',
readOnly:true,
fieldLabel:'審核受理',
hiddenName:'audit',
store: new Ext.data.SimpleStore({
fields:['id', 'name'],
data:[[0,'立即審核'],[1,'常規審核']]
}),
valueField:'id',
displayField:'name',
typeAhead:true,
mode:'local',
triggerAction:'all',
emptyText:'請選擇',
selectOnFocus:true,
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -