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.

671 lines
28 KiB
JavaScript

12 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 });
}
}
});
}
}
});
this.gridList.getSelectionModel().on('select', function (model, record, index) {
var GID = record.data.GID;
var sql = "";
sql = " AND LINKGID='" + GID + "' ";
this.storeListDetail.load({
params: { strCondition: sql },
callback: function (r, options, success) {
if (success) {
isloadfee = true;
}
}
});
// this.onSelectFee(button, event);
}, this);
//#region 主列表_定义数据集
this.storeListDetail = Ext.create('Ext.data.Store', {
pageSize: this.PageSize,
fields: [
{ name: 'BSNO', type: 'string' }, //编号
{ name: 'ISSALEFEE', type: 'string' }, //提成发放
{ name: 'SALE', type: 'string' }, //业务员
{ name: 'CUSTOMERNAME', type: 'string' }, //委托单位
{ name: 'OPLBNAME', type: 'string' }, //业务类型
{ name: 'OPTYPE', type: 'string' }, //更改单
{ name: 'FEESTATUSREF', type: 'string' }, //费用锁定
{ name: 'CUSTNO', type: 'string' }, //委托编号
{ name: 'MBLNO', type: 'string' }, //主提单号
{ name: 'ETD', type: 'string' }, //开船日期
{ name: 'ACCDATE', type: 'string' }, //会计期间
{ name: 'RMBDR', type: 'number' }, //RMB应收
{ name: 'RMBCR', type: 'number' }, //RMB应付
{ name: 'USDDR', type: 'number' }, //USD应收
{ name: 'USDCR', type: 'number' }, //USD应付
{ name: 'OTDR', type: 'number' }, //其他币别应收
{ name: 'OTCR', type: 'number' }, //其他币别应付
{ name: 'TTLDR', type: 'number' }, //合计应收
{ name: 'TTLCR', type: 'number' }, //合计应付
{ name: 'TTLPROFIT', type: 'number' }, //合计毛利润
{ name: 'ShuiFei', type: 'number' }, //税费
{ name: 'YeWuFeiYong', type: 'number' }, //业务费用
{ name: 'JingLiRun', type: 'number' }, //净利润
{ name: 'TiChengJiShu', type: 'number' }, //提成基数
{ name: 'GeRenFeiYong', type: 'number' }, //个人费用
{ name: 'TiChengBiLi', type: 'number' }, //提成比例
{ name: 'TiCheng', type: 'number' }, //提成
{ name: 'ShiFa', type: 'number' }, //提成
{ name: 'YingJieRiQi', type: 'string' }, //应结日期
{ name: 'ShiJieRiQi', type: 'string' }, //实结日期
{ name: 'CORPID', type: 'string' } //公司GID
],
remoteSort: true,
proxy: {
type: 'ajax',
url: '/MvcShipping/MsRptSaleLiRunTiCheng/GetCwUserTiChengDetailList',
reader: {
id: '',
root: 'data',
totalProperty: 'totalCount'
}
}
});
//#endregion
//#region 主列表_定义Grid列名
this.initgirdcolums = [{
sortable: false,
dataIndex: 'BSNO',
header: '编号',
hidden: true,
width: 130
}, {
sortable: false,
dataIndex: 'SALE',
header: '业务员',
width: 80
}, {
sortable: false,
dataIndex: 'CUSTOMERNAME',
header: '委托单位',
width: 120
}, {
sortable: false,
dataIndex: 'CUSTNO',
header: '委托编号',
width: 136
}, {
sortable: false,
dataIndex: 'MBLNO',
header: '主提单号',
width: 136
}, {
sortable: false,
dataIndex: 'ETD',
header: '开船日期',
width: 86
}, {
sortable: true,
dataIndex: 'ACCDATE',
header: '会计期间',
width: 70
}
, {
sortable: false,
dataIndex: 'RMBDR',
header: 'RMB应收',
renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) { try { var lsValue = usMoney(value, 2, '', false); if (lsValue != "NaN") { value = lsValue; if (parseFloat(lsValue) < 0) { return '<SPAN style="COLOR: red">' + lsValue + '</SPAN>'; } } else { return value; } } catch (e) { return value; } return value; },
align: 'right',
width: 80,
renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
value = usMoney(value, 2, '', true);
return value;
}
}, {
sortable: false,
dataIndex: 'RMBCR',
header: 'RMB应付',
renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) { try { var lsValue = usMoney(value, 2, '', false); if (lsValue != "NaN") { value = lsValue; if (parseFloat(lsValue) < 0) { return '<SPAN style="COLOR: red">' + lsValue + '</SPAN>'; } } else { return value; } } catch (e) { return value; } return value; },
align: 'right',
width: 80,
renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
value = usMoney(value, 2, '', true);
return value;
}
}
, {
sortable: false,
dataIndex: 'USDDR',
header: 'USD应收',
renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) { try { var lsValue = usMoney(value, 2, '', false); if (lsValue != "NaN") { value = lsValue; if (parseFloat(lsValue) < 0) { return '<SPAN style="COLOR: red">' + lsValue + '</SPAN>'; } } else { return value; } } catch (e) { return value; } return value; },
align: 'right',
width: 80,
renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
value = usMoney(value, 2, '', true);
return value;
}
}, {
sortable: false,
dataIndex: 'USDCR',
header: 'USD应付',
renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) { try { var lsValue = usMoney(value, 2, '', false); if (lsValue != "NaN") { value = lsValue; if (parseFloat(lsValue) < 0) { return '<SPAN style="COLOR: red">' + lsValue + '</SPAN>'; } } else { return value; } } catch (e) { return value; } return value; },
align: 'right',
width: 80,
renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
value = usMoney(value, 2, '', true);
return value;
}
}
, {
sortable: false,
dataIndex: 'OTDR',
header: '其他币别应收',
renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) { try { var lsValue = usMoney(value, 2, '', false); if (lsValue != "NaN") { value = lsValue; if (parseFloat(lsValue) < 0) { return '<SPAN style="COLOR: red">' + lsValue + '</SPAN>'; } } else { return value; } } catch (e) { return value; } return value; },
align: 'right',
width: 80,
renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
value = usMoney(value, 2, '', true);
return value;
}
}, {
sortable: false,
dataIndex: 'OTCR',
header: '其他币别应付',
renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) { try { var lsValue = usMoney(value, 2, '', false); if (lsValue != "NaN") { value = lsValue; if (parseFloat(lsValue) < 0) { return '<SPAN style="COLOR: red">' + lsValue + '</SPAN>'; } } else { return value; } } catch (e) { return value; } return value; },
align: 'right',
width: 80,
renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
value = usMoney(value, 2, '', true);
return value;
}
}
, {
sortable: false,
dataIndex: 'TTLDR',
header: '合计应收',
renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) { try { var lsValue = usMoney(value, 2, '', false); if (lsValue != "NaN") { value = lsValue; if (parseFloat(lsValue) < 0) { return '<SPAN style="COLOR: red">' + lsValue + '</SPAN>'; } } else { return value; } } catch (e) { return value; } return value; },
align: 'right',
width: 80,
renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
value = usMoney(value, 2, '', true);
return value;
}
}, {
sortable: false,
dataIndex: 'TTLCR',
header: '合计应付',
renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) { try { var lsValue = usMoney(value, 2, '', false); if (lsValue != "NaN") { value = lsValue; if (parseFloat(lsValue) < 0) { return '<SPAN style="COLOR: red">' + lsValue + '</SPAN>'; } } else { return value; } } catch (e) { return value; } return value; },
align: 'right',
width: 80,
renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
value = usMoney(value, 2, '', true);
return value;
}
}, {
sortable: false,
dataIndex: 'TTLPROFIT',
header: '合计毛利润', //账单毛利润
renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) { try { var lsValue = usMoney(value, 2, '', false); if (lsValue != "NaN") { value = lsValue; if (parseFloat(lsValue) < 0) { return '<SPAN style="COLOR: red">' + lsValue + '</SPAN>'; } } else { return value; } } catch (e) { return value; } return value; },
align: 'right',
width: 80,
renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
value = usMoney(value, 2, '', true);
return value;
}
}, {
sortable: false,
dataIndex: 'ShuiFei',
header: '税费', //毛利*税率
renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) { try { var lsValue = usMoney(value, 2, '', false); if (lsValue != "NaN") { value = lsValue; if (parseFloat(lsValue) < 0) { return '<SPAN style="COLOR: red">' + lsValue + '</SPAN>'; } } else { return value; } } catch (e) { return value; } return value; },
align: 'right',
width: 80,
renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
if (value == 0) {
return "/";
}
else {
value = usMoney(value, 2, '', true);
return value;
}
}
}, {
sortable: false,
dataIndex: 'YeWuFeiYong',
header: '业务费用', //其他费用模块中部分费用科目
renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) { try { var lsValue = usMoney(value, 2, '', false); if (lsValue != "NaN") { value = lsValue; if (parseFloat(lsValue) < 0) { return '<SPAN style="COLOR: red">' + lsValue + '</SPAN>'; } } else { return value; } } catch (e) { return value; } return value; },
align: 'right',
width: 80,
renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
if (value == 0) {
return "/";
}
else {
value = usMoney(value, 2, '', true);
return value;
}
}
}, {
sortable: false,
dataIndex: 'JingLiRun',
header: '净利润', //毛利-税费-业务费用
renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) { try { var lsValue = usMoney(value, 2, '', false); if (lsValue != "NaN") { value = lsValue; if (parseFloat(lsValue) < 0) { return '<SPAN style="COLOR: red">' + lsValue + '</SPAN>'; } } else { return value; } } catch (e) { return value; } return value; },
align: 'right',
width: 80,
renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
if (value == 0) {
return "/";
}
else {
value = usMoney(value, 2, '', true);
return value;
}
}
}
//, {
// sortable: false,
// dataIndex: 'TiChengJiShu',
// header: '提成基数', //“部门1=净利-底数1”“部门2=净利-底数2”“其他部门=净利”
// renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) { try { var lsValue = usMoney(value, 2, '', false); if (lsValue != "NaN") { value = lsValue; if (parseFloat(lsValue) < 0) { return '<SPAN style="COLOR: red">' + lsValue + '</SPAN>'; } } else { return value; } } catch (e) { return value; } return value; },
// align: 'right',
// width: 80
//}
, {
sortable: false,
dataIndex: 'GeRenFeiYong',
header: '个人费用', //其他费用模块中部分费用科目(只提取用于出报表,不参与提成统计)
renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) { try { var lsValue = usMoney(value, 2, '', false); if (lsValue != "NaN") { value = lsValue; if (parseFloat(lsValue) < 0) { return '<SPAN style="COLOR: red">' + lsValue + '</SPAN>'; } } else { return value; } } catch (e) { return value; } return value; },
align: 'right',
width: 80,
renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
if (value == 0) {
return "/";
}
else {
value = usMoney(value, 2, '', true);
return value;
}
}
}
//, {
// sortable: false,
// dataIndex: 'TiChengBiLi',
// header: '提成比例',//按提成设置分段提取因有多个默认为0暂不显示
// width: 80
//}
, {
sortable: false,
dataIndex: 'TiCheng',
header: '提成', //提成基数*提成比例
renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) { try { var lsValue = usMoney(value, 2, '', false); if (lsValue != "NaN") { value = lsValue; if (parseFloat(lsValue) < 0) { return '<SPAN style="COLOR: red">' + lsValue + '</SPAN>'; } } else { return value; } } catch (e) { return value; } return value; },
align: 'right',
width: 80,
renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
if (value == 0) {
return "/";
}
else {
value = usMoney(value, 2, '', true);
return value;
}
}
}, {
sortable: false,
dataIndex: 'ShiFa',
header: '实发提成', //提成基数*提成比例
renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) { try { var lsValue = usMoney(value, 2, '', false); if (lsValue != "NaN") { value = lsValue; if (parseFloat(lsValue) < 0) { return '<SPAN style="COLOR: red">' + lsValue + '</SPAN>'; } } else { return value; } } catch (e) { return value; } return value; },
align: 'right',
width: 80,
renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
if (value == 0) {
return "/";
}
else {
value = usMoney(value, 2, '', true);
return value;
}
}
}, {
sortable: false,
dataIndex: 'YingJieRiQi',
header: '应结日期',
width: 86
}, {
sortable: false,
dataIndex: 'ShiJieRiQi',
header: '实结日期',
width: 86
}, {
sortable: false,
dataIndex: 'CORPID',
header: '公司GID',
hidden: true,
width: 0
}
];
//#endregion
//#region 主列表_定义Grid
this.girdcolumsDetail = DsTruck.GetGridPanel(USERID, this.formname + 'bs', this.initgirdcolums, 1);
this.GridCheckBoxModel = Ext.create('Ext.selection.CheckboxModel');
this.gridListDetail = new Ext.grid.GridPanel({
store: this.storeListDetail,
enableHdMenu: false,
region: 'south',
height:280,
loadMask: { msg: "数据加载中,请稍等..." },
trackMouseOver: true,
selModel: this.GridCheckBoxModel,
disableSelection: false,
columns: this.girdcolumsDetail,
viewConfig: {
autoFill: true
},
bbar: Ext.create('Ext.PagingToolbar', {
store: this.storeListDetail,
displayInfo: true,
displayMsg: '当前显示 {0} - {1}条记录 /共 {2}条记录',
emptyMsg: "没有数据"
})
});
//#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, this.gridListDetail]
});
//#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 ="edit";
this.StoreList = null;
this.EditRecord =null;
this.accDate = this.ParentWin.accDate.toString();
//
this.formSearch.getForm().findField('PS_ACCDATE').setValue(this.accDate);
if (this.EditRecord == null) {
} else {
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
});