You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
DS7/DSWeb/Areas/MvcShipping/Viewsjs/MsCodeCtnSet/MsCodeCtnSetIndex.js

426 lines
16 KiB
JavaScript

2 years ago
Ext.namespace('Shipping');//创建用于范围变量和类的命名空间,指定的最后一个节点的命名空间隐式创建的所有其他节点
Shipping.MsCodeCtnSetIndex = function (config) {
Ext.applyIf(this, config);
this.initUIComponents();
window.Shipping.MsCodeCtnSetIndex.superclass.constructor.call(this);
};
var _this;//当前实例
Ext.extend(Shipping.MsCodeCtnSetIndex, Ext.Panel, {
OprationStatus: null, //仅当弹出界面时使用
SelectedRecord: null,
initUIComponents: function () {
this.GridCheckBoxModel = Ext.create('Ext.selection.CheckboxModel');
this.storeCtn = Ext.create('DsExt.ux.RefTableStore',
{
model: 'DsShipping.ux.CodeCtnModel',
proxy: { url: '/CommMng/BasicDataRef/GetCodeCtnList' }
}); //实例化类
this.storeCtn.load();
this.comboxCTN = Ext.create('DsExt.ux.RefTableCombox',
{
store: this.storeCtn,
forceSelection: true,
name: 'CTN',
valueField: 'CTN',
displayField: 'CTN'
});
this.storeList = Ext.create('Ext.data.Store',
{
model: 'MsCodeCtnSet',
remoteSort: true,
proxy: {
type: 'ajax',
url: '/MvcShipping/MsCodeCtnSet/GetList',
reader: {
id: 'CTNID',
root: 'data',
totalProperty: 'totalCount'
}
}
});
this.gridListCellEditing = Ext.create('Ext.grid.plugin.CellEditing',
{
clicksToEdit: 1
});
//自定义分页大小
this.Pagenum = Ext.create('Ext.form.field.Number',
{
name: 'bottles',
fieldLabel: Zi.LAN.NumberOfpage, //每页记录数
labelAlign: 'right',
value: 15,
maxValue: 100000,
width: 180,
minValue: 0,
listeners: {
specialkey: function(field, e) {
if (e.getKey() === e.ENTER) {
_this.storeList.pageSize = field.value;
_this.onRefreshClick();
}
}
}
});
this.gridList = new Ext.grid.GridPanel({
store: this.storeList,
enableHdMenu: false,
region: 'center',
loadMask: { msg: "数据加载中,请稍等..." },
trackMouseOver: true,
disableSelection: false,
plugins: [this.gridListCellEditing],
selType: 'cellmodel',
selModel: this.GridCheckBoxModel,
bbar: [
Ext.create('Ext.PagingToolbar',
{
store: this.storeList,
displayInfo: true,
displayMsg: Zi.LAN.FenYe, //当前显示 {0} - {1}条记录 /共 {2}条记录
emptyMsg: Zi.LAN.Nodata, //没有数据
listeners: {
beforechange: function(obj, page, eOpts) { // Ext.toolbar.Paging,Number,Object
_this.storeList.pageSize = _this.Pagenum.value;
}
}
}), this.Pagenum, this.TtlSel
],
columns: [
{
sortable: true,
dataIndex: 'CTNID',
header: '代码',
hidden: true,
width: 120
}, {
sortable: true,
dataIndex: 'CTNSIZE',
header: '尺寸',
width: 160,
editor: {
xtype: 'textfield',
selectOnFocus: true
}
}, {
sortable: true,
dataIndex: 'CTNTYPE',
header: '类型',
width: 100,
editor: {
xtype: 'textfield',
selectOnFocus: true
}
}, {
sortable: true,
dataIndex: 'CTN',
header: '箱型',
width: 160,
editor: {
xtype: 'textfield',
selectOnFocus: true
}
}, {
sortable: true,
dataIndex: 'EDICODE',
header: 'EDI代码',
width: 160,
editor: {
xtype: 'textfield',
selectOnFocus: true
}
}, {
sortable: true,
dataIndex: 'CTNWEIGHT',
header: '箱皮重',
width: 160,
editor: {
xtype: 'numberfield',
selectOnFocus: true,
allowDecimals: true,
decimalPrecision: 3
},
xtype: 'numbercolumn',
renderer: function(value) {
return Ext.util.Format.number(value, '0.000');;
}
}, {
sortable: true,
dataIndex: 'EEXPLAIN',
header: '英文说明',
width: 160,
editor: {
xtype: 'textfield',
selectOnFocus: true
}
}, {
sortable: true,
dataIndex: 'CEXPLAIN',
header: '中文说明',
width: 160,
editor: {
xtype: 'textfield',
selectOnFocus: true
}
}, {
sortable: true,
dataIndex: 'DLIKGS',
header: '默认限重',
width: 160,
editor: {
xtype: 'numberfield',
selectOnFocus: true,
allowDecimals: true,
decimalPrecision: 3
},
xtype: 'numbercolumn',
renderer: function (value) {
return Ext.util.Format.number(value, '0.000');;
}
}
]
});
this.formSearch = Ext.widget('form',
{
frame: true,
region: 'center',
bodyPadding: 5,
fieldDefaults: {
margins: '2 2 2 2',
labelAlign: 'right',
flex: 1,
labelWidth: 90,
msgTarget: 'qtip'
},
items: [
{
xtype: 'container',
defaultType: 'textfield',
layout: 'anchor',
defaults: {
anchor: '40%'
},
items: [
{
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [
{
fieldLabel: '尺寸',
name: 'CTNSIZE',
enableKeyEvents: true,
listeners: {
specialkey: function(field, e) {
if (e.getKey() == e.ENTER) {
_this.onRefreshClick();
}
}
}
},
{
fieldLabel: '类型',
name: 'CTNTYPE',
enableKeyEvents: true,
listeners: {
specialkey: function (field, e) {
if (e.getKey() == e.ENTER) {
_this.onRefreshClick();
}
}
}
}
]
}
]
}
]
});
this.panelBtn = new Ext.Panel({
region: "north",
tbar: [
{
text: "新增",
iconCls: "btnadd",
handler: function(button, event) {
this.addDetail();
},
scope: this
}, {
text: "保存",
iconCls: "btnsave",
handler: function(button, event) {
this.onPostDetailClick(button, event);
},
scope: this
}, '-', {
text: "删除",
iconCls: "btndelete",
handler: function(button, event) {
this.onDeleteClick(button, event);
},
scope: this
}, '-', {
text: "执行查询",
iconCls: "btnrefresh",
handler: function(button, event) {
this.onRefreshClick(button, event);
},
scope: this
}
]
});
this.panelTop = new Ext.Panel({
layout: "border",
region: "north",
height: 80,
items: [this.formSearch, this.panelBtn]
});
this.panelCtn = new Ext.Panel({
layout: "border",
title: '集装箱信息设置',
id: 'pnlctn',
region: "center",
items: [this.gridList]
});
this.MainCenter = new Ext.TabPanel({
activeTab: 0,
autoWidth: true,
border: true,
frame: false,
region: 'center',
enableTabScroll: true,
items:
[
this.panelCtn
]
});
Ext.apply(this,
{
items: [this.panelTop, this.MainCenter]
});
this.storeList.on('beforeload',
function(store) {
var sql = this.getCondition();
Ext.apply(store.proxy.extraParams, { condition: sql,sort:'' });
},
this);
this.onRefreshClick();
_this = this;
},
onRefreshClick: function(button, event) {
var sql = this.getCondition();
this.storeList.load({
params: { start: 0, limit: this.Pagenum.value, sort: '', condition: sql },
waitMsg: "正在查询数据...",
scope: this
});
}, //查询
getCondition: function() { //拼sql语句 查询条件
var form = this.formSearch.getForm();
var sSize = form.findField('CTNSIZE').getValue();
var sType = form.findField('CTNTYPE').getValue();
var sqlstr = "";
sqlstr += getAndConSql(sqlstr, sSize, " CTNSIZE = '" + sSize + "'");
sqlstr += getAndConSql(sqlstr, sType, " CTNTYPE = '" + sType + "'");
return sqlstr;
}, //拼sql语句
addDetail: function () {
var record = Ext.create('MsCodeCtnSet', {
CTNID: '',
CTNSIZE: '',
CTNTYPE: '',
CTN: '',
EDICODE: '',
CTNWEIGHT: '0.000',
EEXPLAIN: '',
CEXPLAIN: '',
AFRCODE: '',
TEU: '0.00',
DLIKGS:'0.000'
});
this.storeList.add(record);
var n = this.storeList.getCount();
this.gridListCellEditing.startEditByPosition({ row: n - 1, column: 1 });
},//新增
onPostDetailClick: function (button, event) {
var bodyDrChFeeDatas = [];
for (var i = 0; i < this.storeList.getCount(); i += 1) {
var memberyf = this.storeList.getAt(i);
bodyDrChFeeDatas.push(memberyf);
};
var jsonChFeeBody = ConvertGIDRecordsToJson(bodyDrChFeeDatas);
Ext.Msg.wait('正在保存数据, 请稍侯..');
Ext.Ajax.request({
waitMsg: '正在保存数据...',
url: '/MvcShipping/MsCodeCtnSet/Save',
scope: this,
params: {
body: jsonChFeeBody
},
callback: function (options, success, response) {
if (success) {
Ext.MessageBox.hide();
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
this.onRefreshClick();
} else {
Ext.Msg.show({ title: '错误', msg: jsonresult.Message, icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });
}
} else {
Ext.Msg.show({
title: '请重试',
msg: '服务器响应出错',
icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK
});
}
}
});
},//保存
onDeleteClick: function (button, event) {
var selections = this.gridList.getSelectionModel().getSelection();
if (selections.length == 0) {
Ext.Msg.show({ title: '提示', msg: '请先选择单据!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
}
var record = [];
for (var item in selections) if (selections.hasOwnProperty(item)) record.push(selections[item].data);
Ext.MessageBox.confirm('提示', '确定删除该记录吗?', function (btn) {
if (btn == 'yes') {
Ext.Msg.wait('正在删除数据...');
Ext.Ajax.request({
waitMsg: '正在删除数据...',
url: '/MvcShipping/MsCodeCtnSet/Delete',
params: {
data: Ext.JSON.encode(record)
},
callback: function (options, success, response) {
if (success) {
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
this.storeList.remove(selections);
Ext.Msg.hide();
}
else {
Ext.Msg.show({ title: '错误', msg: jsonresult.Message, icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });
}
}
},
failure: function (response, options) {
Ext.Msg.show({ title: '警告', msg: '服务器响应出错,请重试', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
},
success: function (response, options) {
},
scope: this
});
}
}, this);
},//删除
OprationSwap: function () {
var ret = new Array();
ret[0] = this.OprationStatus;
ret[1] = this.storeList;
ret[2] = this.SelectedRecord;
return ret;
}
});