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.

303 lines
10 KiB
JavaScript

11 months ago
Ext.namespace('Shipping');
String.prototype.trim = function () { return this.replace(/(^\s*)|(\s*$)/g, ""); }
Shipping.MsRptSaleLiRunTiChengEdit = function (config) {
Ext.applyIf(this, config);
this.initUIComponents();
window.Shipping.MsRptSaleLiRunTiChengEdit.superclass.constructor.call(this);
};
Ext.extend(Shipping.MsRptSaleLiRunTiChengEdit, Ext.Panel, {
ParentWin: null,
OpStatus: 'edit',
StoreList: null,
EditRecord: null,
accDate: '',
initUIComponents: function () {
this.formname = 'MsRptSaleLiRunTiChengEdit';
//#region formSearch 下拉框信息加载
//揽货人
this.storeSalesCode = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.UserRefModel',
proxy: { url: '/CommMng/BasicDataRef/GetUserRefList' }
});
this.storeSalesCode.load();
this.comboxSalesCode = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '揽货人',
store: this.storeSalesCode,
forceSelection: true,
allowBlank: false,
name: 'PS_SALE',
valueField: 'UserName',
displayField: 'CodeAndName',
enableKeyEvents: true,
listeners: {
keyup: function (field, e) {
if (e.getKey() == e.ENTER) {
_this.onRefreshClick();
}
}
}
});
//#endregion
//#region formSearch
this.formSearch = Ext.widget('form', {
frame: true,
region: 'center',
bodyPadding: 5,
fieldDefaults: {
margins: '2 2 2 2',
labelAlign: 'right',
flex: 1,
labelWidth: 60,
msgTarget: 'qtip'
},
items: [{
xtype: 'container',
defaultType: 'textfield',
layout: 'anchor',
defaults: {
anchor: '100%'
},
items: [{
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [this.comboxSalesCode, {
fieldLabel: '会计期间',
xtype: 'monthfield',
name: 'PS_ACCDATE',
allowBlank: false,
enableKeyEvents: true,
listeners: {
specialkey: function (field, e) {
if (e.getKey() == e.ENTER) {
_this.onRefreshClick();
}
}
}
}]
}]//end items(fieldset 1)
}]//end root items
});
//#endregion formSearch
//#region 定义数据集
//列表加载
this.storeDetailList = Ext.create('Ext.data.Store', {
model: 'MsRptSaleLiRunTiChengModel',
remoteSort: true,
proxy: {
type: 'ajax',
url: '/MvcShipping/MsRptSaleLiRunTiCheng/GetCwUserTiChengList',
reader: {
id: 'GID',
root: 'data',
totalProperty: 'totalCount'
}
}
});
//#endregion
//#region 列定义
this.girdcolums = [{
sortable: true,
dataIndex: 'GID',
header: '', //唯一编码
hidden: true,
width: 0
},
{
sortable: false,
dataIndex: 'USERNAME',
header: '名称',
align: 'center',
width: 100
}, {
sortable: false,
dataIndex: 'ACCDATE',
align: 'center',
format: 'Y-m',
header: '会计期间',
renderer: Ext.util.Format.dateRenderer('Y-m'),
width: 100
},
{
sortable: false,
dataIndex: 'KouFeiLv',
header: '扣费率',
align: 'right',
width: 60,
renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
value = usMoney(value, 2, '', true);
return value;
}
},
{
sortable: false,
dataIndex: 'TiCheng',
header: '提成',
align: 'right',
width: 80,
renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
value = usMoney(value, 2, '', true);
return value;
}
},
{
sortable: false,
dataIndex: 'ShiFa',
header: '实发金额',
align: 'right',
width: 120,
editor: {
xtype: 'numberfield',
allowBlank: false,
selectOnFocus: true, //得到焦点时自动选择文本
allowDecimals: true, //允许输入小数
nanText: '请输入有效小数',
value: 0.00
},
renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
value = usMoney(value, 2, '', true);
return value;
}
},
{
sortable: false,
dataIndex: 'REMARK',
header: '备注',
width: 300,
editor: {
xtype: 'textfield',
selectOnFocus: true
}
}, {
sortable: true,
dataIndex: 'USERGID',
header: '',
hidden: true,
width: 0
}];
//#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.storeDetailList,
enableHdMenu: false, //是否显示表格列的菜单
hideHeaders: false, //是否隐藏表头
enableColumnHide: false, ///隐藏表头列
sortableColumns: false, ///隐藏表头排序
rowLines: true,
columnLines: true,
loadMask: { msg: "数据加载中,请稍等..." },
plugins: [this.gridListCellEditing],
selType: 'cellmodel',
columns: this.girdcolums,
listeners: {
scope: this,
'edit': function (editor, e, eOpts) {
if (e.value == e.originalValue) { return; }
Ext.Msg.wait('正在保存数据, 请稍侯..');
Ext.Ajax.request({
waitMsg: '正在保存数据...',
url: '/MvcShipping/MsRptSaleLiRunTiCheng/SaveRow',
scope: this,
params: {
data: Ext.JSON.encode(e.record.data)
},
callback: function (options, success, response) {
if (success) {
Ext.MessageBox.hide();
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
this.InitData();
} 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 });
}
}
});
}
}
});
//#endregion
//#region 按钮Toolbar/框架/加载
this.panelBtn = new Ext.Panel({
region: "north",
tbar: [{
text: "关闭",
handler: function (button, event) {
window.close();
},
scope: this
}]
}); //end 按钮Toolbar
this.panelTop = new Ext.Panel({
layout: "border",
region: "north",
height: 80,
items: [this.panelBtn, this.formSearch]
});
Ext.apply(this, {
items: [this.panelTop, this.gridList]
});
//#endregion
this.ParentWin = window.parent.opener._this; //绑定查询窗体
this.InitData(); //初始化数据
}, //end initUIComponents
//#region 加载事件
InitData: function () {
this.OpStatus = 'edit';
var strCondition = "";
var sSALE = "";
if (this.ParentWin) {
this.OpStatus = this.ParentWin.OprationStatus.toString();
this.StoreList = this.ParentWin.storeList;
this.EditRecord = this.ParentWin.SelectedRecord;
this.accDate = this.ParentWin.accDate.toString();
//
this.formSearch.getForm().findField('PS_ACCDATE').setValue(this.accDate);
if (this.EditRecord.length == 1) {
var rec = this.EditRecord[0];
sSALE = rec.data.SALE;
this.formSearch.getForm().findField('PS_SALE').setValue(rec.data.SALE);
}
else {
var strSALE = "";
for (var i = 0; i < this.EditRecord.length; i++) {
var rec = this.EditRecord[i];
if (i == 0) {
strSALE = "'" + rec.data.SALE + "'";
}
else {
strSALE += ",'" + rec.data.SALE + "'";
}
}
strCondition = " and u.SHOWNAME in(" + strSALE + ")";
}
}
//
if (this.OpStatus == 'edit') {
this.storeDetailList.load({ params: { strCondition: strCondition, sSALE: sSALE, accDate: this.accDate }, waitMsg: "正在查询数据...", scope: this });
}
}
//#endregion
});