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.

668 lines
24 KiB
JavaScript

10 months ago
Ext.namespace('Shipping');
String.prototype.trim = function () { return this.replace(/(^\s*)|(\s*$)/g, ""); }
//#region 当前日期格式
Date.prototype.format = function (format) {
var o = {
"M+": this.getMonth() + 1, //month
"d+": this.getDate(), //day
"h+": this.getHours(), //hour
"m+": this.getMinutes(), //minute
"s+": this.getSeconds(), //cond
"q+": Math.floor((this.getMonth() + 3) / 3), //quarter
"S": this.getMilliseconds() //millisecond
}
if (/(y+)/.test(format)) format = format.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
for (var k in o) if (new RegExp("(" + k + ")").test(format))
format = format.replace(RegExp.$1, RegExp.$1.length == 1 ? o[k] : ("00" + o[k]).substr(("" + o[k]).length));
return format;
}
//#endregion
//#region 获取 YYYY-mm-dd 格式的日期
var xhr = new XMLHttpRequest();
var currdate = new Date();
xhr.open("HEAD", location.href, true);
xhr.onreadystatechange = function () {
if (xhr.readyState == 4 && xhr.status == 200) {
var datestr = xhr.getResponseHeader("Date");
currdate = new Date(datestr);
}
}
xhr.send(null);
//#endregion
Shipping.WMSRateIndex = function (config) {
Ext.applyIf(this, config);
this.initUIComponents();
window.Shipping.WMSRateIndex.superclass.constructor.call(this);
};
Ext.extend(Shipping.WMSRateIndex, Ext.Panel, {
OprationStatus: null, //仅当弹出界面时使用
SelectedRecord: null,
initUIComponents: function () {
this.formname = "formWMSRateIndex"; //需求编号SR2017051700006根据领导要求添加 仓储费率维护模块
//#region formSearch 下拉框信息加载
//委托单位
this.storeCustCode = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.CustomRefModel',
proxy: { url: '/CommMng/BasicDataRef/GetCustomRefList' }
});
this.storeCustCode.load();
this.comboxCustCode = Ext.create('DsExt.ux.RefTableCombox', {
//fieldLabel: '货主',
store: this.storeCustCode,
forceSelection: true,
name: 'CUSTOMERNAME',
valueField: 'CustName',
displayField: 'CodeAndName'
});
//委托单位
this.storeCustCode2 = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.CustomRefModel',
proxy: { url: '/CommMng/BasicDataRef/GetCustomRefList' }
});
this.storeCustCode2.load();
this.comboxCustCode2 = Ext.create('DsExt.ux.RefTableCombox', {
//fieldLabel: '货主',
store: this.storeCustCode2,
forceSelection: true,
name: 'CUSTOMERNAME',
valueField: 'CustName',
displayField: 'CodeAndName'
});
//费用类别
Ext.define('FEETYPEModel', {
extend: 'Ext.data.Model',
fields: [
{ name: 'Name', type: 'string' }
]
});
var dataFEETYPE = [{ "Name": "收" }, { "Name": "付"}];
var storeFEETYPE = Ext.create('Ext.data.Store', { model: 'FEETYPEModel', data: dataFEETYPE });
this.comboxFEETYPE = Ext.create('DsExt.ux.RefTableCombox', {
//fieldLabel: '费用类别',
forceSelection: true,
store: storeFEETYPE,
name: 'FEETYPENAME',
valueField: 'Name',
displayField: 'Name',
value: '收'
});
//计费单位//元/(方天/吨天/方月/吨月)
Ext.define('FEEUNITModel', {
extend: 'Ext.data.Model',
fields: [
{ name: 'Name', type: 'string' }
]
});
var dataFEEUNIT = [{ "Name": "方天" }, { "Name": "方月" }, { "Name": "吨天" }, { "Name": "吨月"}];
var storeFEEUNIT = Ext.create('Ext.data.Store', { model: 'FEEUNITModel', data: dataFEEUNIT });
this.comboxFEEUNIT = Ext.create('DsExt.ux.RefTableCombox', {
//fieldLabel: '计费单位',
forceSelection: true,
store: storeFEEUNIT,
name: 'FEEUNIT',
valueField: 'Name',
displayField: 'Name',
value: '方天'
});
//#endregion
//#region formSearch 查询面板
this.formSearch = Ext.widget('form', {
//title: '查询信息',
frame: true,
//collapsible: true, //将激活折叠功能
region: 'north',
border: false,
fieldDefaults: {
margins: '2 2 2 2',
labelAlign: 'right',
labelWidth: 60,
msgTarget: 'qtip'
},
items: [{
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [this.comboxCustCode2, {
xtype: 'button',
width: 80,
text: "执行查询",
iconCls: "btnrefresh",
handler: function (button, event) {
this.onRefreshClick(button, event);
},
scope: this
}, {
xtype: 'button',
width: 80,
text: "重置条件",
iconCls: "btnreset",
handler: function (button, event) {
this.onClearSql(button, event);
},
scope: this
}]
}]//end root items
});
//#endregion formSearch
//#region 定义数据集
this.storeList = Ext.create('Ext.data.Store', {
model: 'WMSRateModel',
remoteSort: true,
proxy: {
type: 'ajax',
url: '/MvcShipping/WMSRate/GetDataList',
reader: {
id: 'GID',
root: 'data',
totalProperty: 'totalCount'
}
}
});
//#endregion
//#region 列定义
this.girdcolums = [{
sortable: false,
dataIndex: 'GID',
header: '惟一编号',
hidden: true,
width: 0
},
{
sortable: false,
dataIndex: 'ENDBILLINGDATE',
header: '结束计费日期',
align: 'center',
width: 100,
editor: {
xtype: 'datefield',
format: 'Y-m-d',
selectOnFocus: true
},
renderer: Ext.util.Format.dateRenderer('Y-m-d')
},
{
sortable: false,
dataIndex: 'CUSTOMERNAME',
header: '客户名称',
width: 150,
editor: this.comboxCustCode
},
{
dataIndex: 'FEEPRICE',
header: '计费单价',
align: 'right',
width: 80,
editor: {
xtype: 'numberfield',
allowBlank: false,
selectOnFocus: true, //得到焦点时自动选择文本
allowDecimals: true, //允许输入小数
nanText: '请输入有效小数',
//minValue: 0,
//maxValue: 100000,
value: 0.00,
keyNavEnabled: false, //键盘导航是否可用,启用后可以通过键盘的上下箭头调整数值
hideTrigger: true, //是否隐藏上下调节按钮
mouseWheelEnabled: false, //鼠标滚轮是否可用,启用后可以通过滚动鼠标滚轮调整数值
//step: 2,//通过调节按钮、键盘、鼠标滚轮调节数值时的大小
enableKeyEvents: true, //激活键盘事件
listeners: {
scope: this,
'keyup': {
fn: function (_field, e) {
if (e.getKey() == 40) {
this.onAddClick();
}
else if (e.getKey() == 13) {
this.onNextKeyClick(7);
}
},
scope: this
}
}
},
renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
value = usMoney(value, 2, '', true);
return value;
}
},
{
sortable: false,
dataIndex: 'ADDPRICE',
header: '增值价',
align: 'right',
width: 80,
editor: {
xtype: 'numberfield',
allowBlank: false,
selectOnFocus: true, //得到焦点时自动选择文本
allowDecimals: true, //允许输入小数
nanText: '请输入有效小数',
//minValue: 0,
//maxValue: 100000,
value: 0.00,
keyNavEnabled: false, //键盘导航是否可用,启用后可以通过键盘的上下箭头调整数值
hideTrigger: true, //是否隐藏上下调节按钮
mouseWheelEnabled: false, //鼠标滚轮是否可用,启用后可以通过滚动鼠标滚轮调整数值
//step: 2,//通过调节按钮、键盘、鼠标滚轮调节数值时的大小
enableKeyEvents: true, //激活键盘事件
listeners: {
scope: this,
'keyup': {
fn: function (_field, e) {
if (e.getKey() == 40) {
this.onAddClick();
}
else if (e.getKey() == 13) {
this.onNextKeyClick(7);
}
},
scope: this
}
}
},
renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
value = usMoney(value, 2, '', true);
return value;
}
},
{
sortable: false,
dataIndex: 'CAPPRICE',
header: '封顶价',
align: 'right',
width: 80,
editor: {
xtype: 'numberfield',
allowBlank: false,
selectOnFocus: true, //得到焦点时自动选择文本
allowDecimals: true, //允许输入小数
nanText: '请输入有效小数',
//minValue: 0,
//maxValue: 100000,
value: 0.00,
keyNavEnabled: false, //键盘导航是否可用,启用后可以通过键盘的上下箭头调整数值
hideTrigger: true, //是否隐藏上下调节按钮
mouseWheelEnabled: false, //鼠标滚轮是否可用,启用后可以通过滚动鼠标滚轮调整数值
//step: 2,//通过调节按钮、键盘、鼠标滚轮调节数值时的大小
enableKeyEvents: true, //激活键盘事件
listeners: {
scope: this,
'keyup': {
fn: function (_field, e) {
if (e.getKey() == 40) {
this.onAddClick();
}
else if (e.getKey() == 13) {
this.onNextKeyClick(7);
}
},
scope: this
}
}
},
renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
value = usMoney(value, 2, '', true);
return value;
}
},
{
sortable: false,
dataIndex: 'FEEUNIT',
header: '计费单位',
align: 'center',
width: 60,
editor: this.comboxFEEUNIT
},
{
sortable: false,
dataIndex: 'FEESCALE',
header: '计费区间',
align: 'right',
width: 60,
editor: {
xtype: 'numberfield',
allowBlank: false,
selectOnFocus: true, //得到焦点时自动选择文本
allowDecimals: false, //允许输入小数
nanText: '请输入有效数值',
//minValue: 0,
//maxValue: 100000,
value: 0,
keyNavEnabled: false, //键盘导航是否可用,启用后可以通过键盘的上下箭头调整数值
hideTrigger: true, //是否隐藏上下调节按钮
mouseWheelEnabled: false, //鼠标滚轮是否可用,启用后可以通过滚动鼠标滚轮调整数值
//step: 2,//通过调节按钮、键盘、鼠标滚轮调节数值时的大小
enableKeyEvents: true, //激活键盘事件
listeners: {
scope: this,
'keyup': {
fn: function (_field, e) {
if (e.getKey() == 40) {
this.onAddClick();
}
else if (e.getKey() == 13) {
this.onNextKeyClick(7);
}
},
scope: this
}
}
}
},
{
sortable: false,
dataIndex: 'FEETYPENAME',
header: '费用类别',
align: 'center',
width: 60,
editor: this.comboxFEETYPE
},
{
sortable: false,
dataIndex: 'REMARK',
header: '备注',
width: 300,
editor: {
xtype: 'textfield',
selectOnFocus: true
}
},
{
sortable: false,
dataIndex: 'MODIFIEDUSER',
header: '最后一次操作人',
align: 'center',
width: 100
},
{
sortable: false,
dataIndex: 'MODIFIEDTIME',
header: '最后一次操作时间',
align: 'center',
value: currdate.format('yyyy-MM-dd HH:mm:ss'),
width: 140
}
//#region 隐藏列
// ,
// {
// sortable: false,
// dataIndex: 'FEEGRADE',
// header: '计费等级',
// hidden: true,
// width: 0
// }
// ,
// {
// sortable: false,
// dataIndex: 'BSNO',
// header: '关联GID',
// hidden: true,
// width: 0
// },
// {
// sortable: false,
// dataIndex: 'RATETYPE',
// header: '费率类型',
// value: '1',
// hidden: true,
// width: 0
// },
// {
// sortable: false,
// dataIndex: 'FEENAME',
// header: '费用中文名称',
// hidden: true,
// width: 0
// },
// {
// sortable: false,
// dataIndex: 'ISCHANGE',
// header: '是否是货权转移',
// value: '0',
// hidden: true,
// width: 0
// }
//#endregion
];
//#endregion
//#region gridList列表显示信息
this.gridListCellEditing = Ext.create('Ext.grid.plugin.CellEditing', {
clicksToEdit: 1 //1单击2双击
});
this.gridList = new Ext.grid.GridPanel({
region: 'center',
store: this.storeList,
enableHdMenu: false, //是否显示表格列的菜单
hideHeaders: false, //是否隐藏表头
enableColumnHide: false, ///隐藏表头列
sortableColumns: false, ///隐藏表头排序
//disableSelection: false, //是否禁止选择表格行或列默认为false
//trackMouseOver: true, //高亮显示鼠标所在的行默认为true,
//stripeRows: true, //斑马线效果
rowLines: true,
columnLines: true,
loadMask: { msg: "数据加载中,请稍等..." },
plugins: [this.gridListCellEditing],
selType: 'cellmodel',
columns: this.girdcolums
});
this.storeList.on('beforeload', function (store) { Ext.apply(store.proxy.extraParams, { condition: "" }); }, this);
this.storeList.load({ params: { condition: "" }, waitMsg: "正在查询数据...", scope: this });
//#endregion
//#region 按钮工具条/页面布局
this.panelBtn = new Ext.Panel({
border: false,
region: "north",
tbar: [{
text: '添加',
tooltip: '添加',
id: "btnadd",
iconCls: "btnadd",
handler: function (button, event) {
this.onAddClick(button, event);
},
scope: this
}, '-', {
id: 'btnESave',
text: "保存",
iconCls: "btnsave",
handler: function (button, event) {
this.Save('0');
},
scope: this
}, '-', {
text: '删除',
tooltip: '删除',
id: "btndel",
iconCls: "btndelete",
handler: function (button, event) {
this.onDelClick(button, event);
},
scope: this
}]
}); //end 按钮Toolbar
this.panelTop = new Ext.Panel({
border: false,
layout: "border",
region: "north",
height: 60,
items: [this.panelBtn, this.formSearch]
});
Ext.apply(this, {
border: false,
items: [this.panelTop, this.gridList]
});
//#endregion
}, //end initUIComponents
//#region 查询
onRefreshClick: function () {
var sql = this.getCondition();
this.sqlcontext = sql;
this.storeList.load({
params: { start: 0, limit: this.PageSize, sort: '', condition: sql },
waitMsg: "正在刷新数据...",
timeout: 6000000, //30秒
scope: this
});
},
getCondition: function () {
var sql = '';
//委托单位
var sCUSTOMERNAME = this.formSearch.getForm().findField('CUSTOMERNAME').getValue();
if (sCUSTOMERNAME != null) {
if (sCUSTOMERNAME != "") {
sql = sql + getAndConSql(sql, sCUSTOMERNAME, "CUSTOMERNAME='" + sCUSTOMERNAME.toString().trim() + "'");
}
}
return sql;
},
onClearSql: function () {
var form = this.formSearch.getForm();
form.reset();
},
//#endregion
//#region 新建
onAddClick: function () {
var n = this.storeList.getCount();
var sFEETYPENAME = "收";
var sFEEUNIT = "方天";
if (n > 0) {
sFEETYPENAME = this.storeList.getAt(n - 1).get("FEETYPENAME");
sFEEUNIT = this.storeList.getAt(n - 1).get("FEEUNIT");
}
//
var record = Ext.create('WMSRateModel', {
GID: '*', //惟一编号
CUSTOMERNAME: '', //客户名称
FEETYPENAME: sFEETYPENAME, //费用类别
ENDBILLINGDATE: '',//currdate.format('yyyy-MM-dd'), //结束计费日期
FEESCALE: '1', //计费区间
FEEUNIT: sFEEUNIT, //计费单位
FEEPRICE: '0.00', //计费单价
ADDPRICE: '0.00', //增值价
CAPPRICE: '0.00', //封顶价
REMARK: '', //备注
MODIFIEDUSER: SHOWNAME, //最后一次操作人
MODIFIEDTIME: currdate.format('yyyy-MM-dd hh:mm:ss')//最后一次操作时间
});
this.storeList.add(record);
var n = this.storeList.getCount();
this.gridListCellEditing.startEditByPosition({ row: n - 1, column: 0 });
},
//#endregion
//#region 保存
Save: function () {
var bodydatas = [];
var records = this.storeList.getUpdatedRecords(); // 获取修改的行的数据,无法获取幻影数据
var phantoms = this.storeList.getNewRecords(); //获得幻影行
records = records.concat(phantoms); //将幻影数据与真实数据合并
if (records.length != 0) {
for (var i = 0; i < records.length; i += 1) {
var member = records[i];
bodydatas.push(member);
}
}
if (bodydatas.length > 0) {
var jsonBody = ConvertRecordsToJsonAll(bodydatas);
Ext.Msg.wait('正在保存数据, 请稍侯..');
Ext.Ajax.request({
waitMsg: '正在保存数据...',
url: '/MvcShipping/WMSRate/Save',
scope: this,
params: {
body: jsonBody
},
callback: function (options, success, response) {
if (success) {
Ext.MessageBox.hide();
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
//this.storeList.load({ params: { condition: "" }, waitMsg: "正在刷新数据...", scope: this });
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 });
}
}
});
}
}, //end save
//#endregion
//#region 删除
onDelClick: function () {
var selectedRecords = this.gridList.selModel.getSelection();
var rec = selectedRecords[0];
Ext.MessageBox.confirm('提示', '确定删除该记录吗?', function (btn) {
if (btn == 'yes') {
Ext.Msg.wait('正在删除数据...');
Ext.Ajax.request({
waitMsg: '正在删除数据...',
url: '/MvcShipping/WMSRate/Delete',
params: {
dataER: Ext.JSON.encode(this.EditRecord),
data: Ext.JSON.encode(rec.data)
},
callback: function (options, success, response) {
if (success) {
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
this.storeList.remove(rec);
Ext.Msg.show({ title: '提示', msg: jsonresult.Message, icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
}
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 });
},
scope: this
}); //end Ext.Ajax.request
}
}, this);
}
//#endregion
});