📄 erp2supplier.js
字号:
name : name.getValue(),
type : type.getValue(),
linkman : linkman.getValue(),
no : no.getValue()
};
});
dataStore.load({
params:{start:0, limit:paging.pageSize}
});
});
Supplier = {
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 supplierValue = Supplier.form.getValues();
Supplier.grid.stopEditing();
var productValues = new Array();
var ds = Supplier.grid.dataSource;
for (var i = 0; i < ds.getCount(); i++) {
var record = ds.getAt(i);
var item = {};
item.id = record.data.id;
item.name = record.data.name;
item.type = record.data.type;
item.material = record.data.material;
item.factory = record.data.factory;
item.price = record.data.price;
item.unit = record.data.unit;
productValues.push(item);
}
var json = {supplierValue:supplierValue,products:productValues}
Ext.lib.Ajax.request(
'POST',
'./insert.htm',
{success:function(){
form.el.unmask();
Ext.MessageBox.confirm('提示', '保存添加成功,是否继续添加' , function(btn){
if (btn == 'yes') {
form.reset();
form.findField("typeId2").clearValue("");
form.findField("rankId").clearValue("");
Supplier.grid.dataSource.removeAll();
} else {
closeTagHandler();
}
});
},failure:function(){
form.el.unmask();
}},
'data=' + encodeURIComponent(Ext.encode(json))
);
}
});
form.addButton({
text:'重置',
handler:function(){
Supplier.form.reset();
form.findField("typeId2").clearValue("");
form.findField("rankId").clearValue("");
Supplier.grid.dataSource.removeAll();
}
});
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});
// 初始化地区的省市县信息
Ext.lib.Ajax.request(
'GET',
'./getRegion.htm?id=' + this.id,
{success:function(response){
var region = Ext.decode(response.responseText);
Supplier.form.findField("town").setValue(region.id);
Supplier.form.findField("townId").setRawValue(region.name);
Supplier.form.findField("city").setValue(region.parent.id);
Supplier.form.findField("cityId").setRawValue(region.parent.name);
Supplier.form.findField("province").setValue(region.parent.parent.id);
Supplier.form.findField("provinceId").setRawValue(region.parent.parent.name);
},failure:function(){}}
);
form.addButton({
text:'提交',
handler:function(){
if (!form.isValid()) {
return;
}
form.el.mask('提交数据,请稍候...', 'x-mask-loading');
var hide = function() {
form.el.unmask();
};
var supplierValue = Supplier.form.getValues();
supplierValue.id = Supplier.id;
Supplier.grid.stopEditing();
var productValues = new Array();
var ds = Supplier.grid.dataSource;
for (var i = 0; i < ds.getCount(); i++) {
var record = ds.getAt(i);
var item = {};
item.id = record.data.id;
item.name = record.data.name;
item.type = record.data.type;
item.material = record.data.material;
item.factory = record.data.factory;
item.price = record.data.price;
item.unit = record.data.unit;
productValues.push(item);
}
var json = {supplierValue:supplierValue,products:productValues}
Ext.lib.Ajax.request(
'POST',
'./update.htm',
{success:function(){
form.el.unmask();
Ext.MessageBox.confirm('提示', '修改成功,是否返回' , function(btn){
if (btn == 'yes') {
closeTagHandler();
} else {
form.reset();
Supplier.grid.dataSource.load({params:{id:Supplier.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;
},
createForm : function(url, waitMsgTarget) {
var form = new Ext.form.Form({
labelAlign:'right',
labelWidth:80,
url:url,
method: 'POST',
waitMsgTarget:waitMsgTarget,
reader : new Ext.data.JsonReader({}, [
{name:'name'},
{name:'code'},
{name:'homepage'},
{name:'type'},
{name:'area'},
{name:'linkman'},
{name:'lead'},
{name:'tel'},
{name:'fax'},
{name:'address'},
{name:'zip'},
{name:'email'},
{name:'rank'},
{name:'descn'}
])
});
form.fieldset(
{legend:'供应商信息', hideLabels:false}
);
form.column(
{width:320},
new Ext.form.TextField({
fieldLabel: '供应商名称',
name: 'name',
width:200
}),
new Ext.form.ComboBox({
id:'typeId2',
name:'type',
readOnly:true,
fieldLabel:'类别',
hiddenName:'type',
store: new Ext.data.SimpleStore({
fields: ['id', 'name'],
data : [[0,'染料供应商'],[1,'助剂供应商'],[2,'设备供应商'],[3,'综合供应商']]
}),
valueField:'id',
displayField:'name',
typeAhead: true,
mode: 'local',
triggerAction: 'all',
emptyText:'请选择',
selectOnFocus:true,
width:200,
allowBlank:false
}),
new Ext.form.TextField({
fieldLabel: '联系人',
name: 'linkman',
width:200
}),
new Ext.form.TextField({
fieldLabel: '负责人',
name: 'lead',
width:200
}),
new Ext.form.TextField({
fieldLabel: '电话',
name: 'tel',
width:200
}),
new Ext.form.ComboBox({
id:'rankId',
name:'rank',
readOnly:true,
fieldLabel: '信用等级',
hiddenName:'rank',
store: new Ext.data.SimpleStore({
fields: ['id', 'name'],
data : [[0,'优秀'],[1,'良好'],[2,'一般'],[3,'差']]
}),
valueField:'id',
displayField:'name',
typeAhead: true,
mode: 'local',
triggerAction: 'all',
emptyText:'请选择',
selectOnFocus:true,
width:200,
allowBlank:false
})
);
form.column(
{width:320, clear:true},
new Ext.form.TextField({
fieldLabel: '供应商编号',
name: 'code',
width:200
}),
new Ext.form.TextField({
fieldLabel: '邮编',
name: 'zip',
width:200
}),
new Ext.form.TextField({
fieldLabel: '传真',
name: 'fax',
width:200
}),
new Ext.form.TextField({
fieldLabel: 'Email',
name: 'email',
width:200
}),
new Ext.form.TextField({
fieldLabel: '主页',
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -