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/TruckMng/Viewsjs/MsWlDriver/MsWlDriverSalary.js

1176 lines
40 KiB
JavaScript

3 years ago
//集运管理-路单查询
Ext.namespace('DsTruck');
DsTruck.MsWlDriverSalary = function (config) {
Ext.applyIf(this, config);
this.initUIComponents();
window.DsTruck.MsWlDriverSalary.superclass.constructor.call(this);
};
Ext.extend(DsTruck.MsWlDriverSalary, Ext.Panel, {
PageSize: 500,
OprationStatus: null, //仅当弹出界面时使用
SelectedRecord: null,
initUIComponents: function () {
this.formname = "MsWlDriver_Salary";
Ext.define('MsWlDriver_Salarymb', {
extend: 'Ext.data.Model',
idProperty: '',
fields: [
{ name: 'GID', type: 'string' },
{ name: 'DRVCODE', type: 'string' },
{ name: 'ACCDATE', type: 'date' },
{ name: 'EXPDATEBGN', type: 'date' },
{ name: 'EXPDATEEND', type: 'date' },
{ name: 'BASESALARY', type: 'number' },
{ name: 'BONUS', type: 'number' },
{ name: 'RKF', type: 'number' },
{ name: 'AMOUNT_0', type: 'number' },
{ name: 'AMOUNT', type: 'number' },
{ name: 'PAYDATE', type: 'date' },
{ name: 'SETTLEMENT', type: 'number' },
{ name: 'REMARK', type: 'string' },
{ name: 'ISLOCK', type: 'string' },
{ name: 'DRVNAME', type: 'string' },
{ name: 'STLSTATUS', type: 'string' }
]
});
//#region 定义数据集
_this = this;
this.storeDrvName = Ext.create('DsExt.ux.RefTableStore', {
model: 'MsWlBsHeadRefMsWlDriver',
proxy: { url: '/TruckMng/MsWlPc/GetDrvNameList' }
});
this.storeDrvName2 = Ext.create('DsExt.ux.RefTableStore', {
model: 'MsWlBsHeadRefMsWlDriver',
proxy: { url: '/TruckMng/MsWlPc/GetDrvNameList' }
});
this.storeDrvName.load({ params: { condition: "" },
callback: function (r, options, success) {
if (success) {
this.storeDrvName2.removeAll();
this.storeDrvName2.add(r);
}
},
scope: this
});
this.comboxDrvName = Ext.create('DsExt.ux.RefTableCombox', {
//fieldLabel: '司机',
store: this.storeDrvName,
name: 'DRVCODE',
valueField: 'DrvCode',
displayField: 'CodeAndName'
});
this.comboxDrvName2 = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '司机姓名',
store: this.storeDrvName,
name: 'DrvCode',
valueField: 'DrvCode',
displayField: 'CodeAndName'
});
//#endregion
/////////////////////////////////////////
//#region 列表界面
this.storeList = Ext.create('Ext.data.Store', {
pageSize: this.PageSize,
model: 'MsWlDriver_Salarymb',
remoteSort: true,
groupField: 'ACCDATE',
proxy: {
type: 'ajax',
//url: '/TruckMng/MsRptPcHeadOperate/QryData_ADL',
url: '/TruckMng/MsWlDriver/GetDataList_Salary',
//this.storeList.proxy.url = '/TruckMng/MsRptPcHeadOperate/QryData_ADL';
reader: {
id: 'GID',
root: 'data',
totalProperty: 'totalCount'
}
}
});
this.column = [
{
sortable: true, hidden: true,
dataIndex: 'GID',
header: 'GID',
width: 130
}, {
sortable: true,
dataIndex: 'DRVCODE',
header: '司机姓名',
width: 80,
editor: this.comboxDrvName,
renderer: function (value, p, record) {
if (value == null || value == '') return '';
else return record.data.DRVNAME;
}
},
{
sortable: true,
dataIndex: 'ACCDATE',
header: '工资月份',
width: 70,
renderer: Ext.util.Format.dateRenderer('Y-m'),
editor: {
xtype: 'monthfield',
format: 'Y-m',
selectOnFocus: true
}
},
{
sortable: true,
dataIndex: 'EXPDATEBGN',
header: '开始日期',
width: 80,
renderer: Ext.util.Format.dateRenderer('Y-m-d'),
editor: {
xtype: 'datefield',
selectOnFocus: true
}
},
{
sortable: true,
dataIndex: 'EXPDATEEND',
header: '结束日期',
width: 80,
renderer: Ext.util.Format.dateRenderer('Y-m-d'),
editor: {
xtype: 'datefield',
selectOnFocus: true
}
},
{
sortable: true,
dataIndex: 'BASESALARY',
header: '基本工资',
width: 80,
editor: {
xtype: 'numberfield',
selectOnFocus: true
},
summaryType: 'sum', align: 'right',
summaryRenderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
value = usMoney(value, 2, '', true);
return value;
}
},
{
sortable: true, hidden: true,
dataIndex: 'AMOUNT_0',
header: '包干费*89%-背箱费',
width: 80,
summaryType: 'sum', align: 'right',
summaryRenderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
value = usMoney(value, 2, '', true);
return value;
}
},
{
sortable: true,
dataIndex: 'BONUS',
header: '提成',
width: 80,
editor: {
xtype: 'numberfield',
selectOnFocus: true
},
summaryType: 'sum', align: 'right',
summaryRenderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
value = usMoney(value, 2, '', true);
return value;
}
},
{
sortable: true,
dataIndex: 'RKF',
header: '入库费',
width: 80,
editor: {
xtype: 'numberfield',
selectOnFocus: true
},
summaryType: 'sum', align: 'right',
summaryRenderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
value = usMoney(value, 2, '', true);
return value;
}
},
{
sortable: true,
dataIndex: 'AMOUNT',
header: '总应发工资',
width: 80,
editor: {
xtype: 'numberfield',
selectOnFocus: true
},
summaryType: 'sum', align: 'right',
summaryRenderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
value = usMoney(value, 2, '', true);
return value;
}
},
{
sortable: true,
dataIndex: 'PAYDATE',
header: '发放日期',
width: 80,
renderer: Ext.util.Format.dateRenderer('Y-m-d'),
editor: {
xtype: 'datefield',
selectOnFocus: true
}
},
{
sortable: true,
dataIndex: 'SETTLEMENT',
header: '实发工资',
width: 80,
editor: {
xtype: 'numberfield',
selectOnFocus: true
},
summaryType: 'sum', align: 'right',
summaryRenderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
value = usMoney(value, 2, '', true);
return value;
}
},
{
sortable: true,
dataIndex: 'REMARK',
header: '备注',
width: 200,
editor: {
xtype: 'textfield',
selectOnFocus: true
}
},
{
sortable: true,
hidden: true,
dataIndex: 'ISLOCK',
header: '锁定',
width: 80
},
{
sortable: true,
hidden: true,
dataIndex: 'DRVNAME',
header: 'DRVNAME',
width: 80
},
{
sortable: true,
dataIndex: 'STLSTATUS',
header: '发放状态',
width: 80,
renderer: function (value) {
if (value == "已发") {
return "<a><font color='#333333'>" + value + "</font></a>";
} else if (value == "未发") {
return "<a><font color='#0000FF'>" + value + "</font></a>";
} else if (value == "部分发放") {
return "<a><font color='#AA0033'>" + value + "</font></a>";
}
}
}
];
this.cellEditing = Ext.create('Ext.grid.plugin.CellEditing', {
clicksToEdit: 1
});
this.MainCB = Ext.create('Ext.selection.CheckboxModel', { checkOnly: true });
Ext.grid.RowNumberer = Ext.extend(Ext.grid.RowNumberer, {
width: 40
});
this.gridList = new Ext.grid.GridPanel({
store: this.storeList,
enableHdMenu: false,
region: 'center',
loadMask: { msg: "数据加载中,请稍等..." },
trackMouseOver: true,
disableSelection: false,
selModel: this.MainCB,
columns: this.column,
plugins: [this.cellEditing],
viewConfig: {
enableTextSelection: true,
autoFill: true,
getRowClass: function (record, rowIndex, rowParams, store) {
if (record.get('ISLOCK') == "1") {
return 'feestatus_settle';
}
}
},
features: [{
id: 'group',
ftype: 'groupingsummary',
groupHeaderTpl: '{name}',
hideGroupedHeader: false,
enableGroupingMenu: true
}],
bbar: Ext.create('Ext.PagingToolbar', {
store: this.storeList,
displayInfo: true,
displayMsg: '当前显示 {0} - {1}条记录 /共 {2}条记录',
emptyMsg: "没有数据"
})
});
/////////////以下部分为获取存储的gridpanel显示样式
this.column = DsTruck.GetGridPanel(USERID, this.formname, this.column);
//使用者id表名 中间column数组
this.column.unshift(new Ext.grid.RowNumberer());
this.gridList.reconfigure(this.storeList, this.column);
////////////////////////////
//#endregion
//#region formSearch
//#region formSearch枚举参照相关
Ext.define('PCSTATUSmd', {
extend: 'Ext.data.Model',
fields: [
{ name: 'ID', type: 'string' },
{ name: 'STATUSNAME', type: 'string' }
]
});
var PCSTATUSData = [{ "ID": "0", "STATUSNAME": "已发" },
{ "ID": "1", "STATUSNAME": "未发" },
{ "ID": "2", "STATUSNAME": "部分发放"}];
this.storePCSTATUS = Ext.create('Ext.data.Store', {
model: 'PCSTATUSmd',
data: PCSTATUSData
});
this.comboxPCSTATUS = Ext.create('Ext.ux.form.field.BoxSelect', {
fieldLabel: '状态',
autosize: true,
bodyPadding: 5,
flex: 2,
//width: 500,
labelWidth: 85,
store: this.storePCSTATUS,
queryMode: 'local',
triggerOnClick: false,
valueField: 'ID',
displayField: 'STATUSNAME',
listeners: {
specialkey: function (field, e) {
if (e.getKey() == e.ENTER) {
_this.onRefreshClick();
}
}
}
});
//#endregion
this.formSearch = Ext.widget('form', {
frame: true,
region: 'center',
bodyPadding: 5,
fieldDefaults: {
margins: '2 2 2 2',
labelAlign: 'right',
flex: 1,
labelWidth: 85,
msgTarget: 'qtip'
},
items: [
{//fieldset 1
xtype: 'container',
defaultType: 'textfield',
layout: 'anchor',
defaults: {
anchor: '100%'
},
items: [{
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [
this.comboxDrvName2,
{
fieldLabel: '工资月份',
format: 'Y-m',
xtype: 'monthfield',
name: 'ACCDATE',
listeners: {
specialkey: function (field, e) {
if (e.getKey() == e.ENTER) {
_this.onRefreshClick();
}
}
}
}, {
fieldLabel: '从..发放日期',
format: 'Y-m-d',
xtype: 'datefield',
name: 'PAYDATEBGN',
listeners: {
specialkey: function (field, e) {
if (e.getKey() == e.ENTER) {
_this.onRefreshClick();
}
}
}
}, {
fieldLabel: '到..发放日期',
format: 'Y-m-d',
xtype: 'datefield',
name: 'PAYDATEEND',
listeners: {
specialkey: function (field, e) {
if (e.getKey() == e.ENTER) {
_this.onRefreshClick();
}
}
}
}
, this.comboxPCSTATUS
]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [
]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [
]
}
]//end items(fieldset 1)
}//end fieldset 1
]//end root items
});
//#endregion formSearch
var menu1 = new Ext.menu.Menu({
id: 'basicMenu',
items: [{
text: '批量锁定',
handler: clickEnd
}, {
text: '批量解锁',
handler: clickNotEnd
}]
});
function clickEnd() {
panelTest.PayandLock("1");
};
function clickNotEnd() {
panelTest.PayandLock("0");
};
var menu2 = new Ext.menu.Menu({
id: 'basicMenu',
items: [{
text: '打印工资单',
handler: clickHandler_GZ
}]
});
function clickHandler_GZ() {
panelTest.Print_GZ();
};
this.panelBtn = new Ext.Panel({
region: "north",
tbar: [
{
text: "新建", id: "btnadd", //hidden: true,
iconCls: "btnadd",
handler: function (button, event) {
//this.OprationStatus = 'add';
//DsOpenEditWin("/TruckMng/MsWlPc/Edit_ADL", "", "700", "1000");
this.onAddPCClick();
},
scope: this
}, {
text: "删除", id: "btndelete", //hidden: true,
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
}, {
text: "导出Excel",
id: "btnExportExcel",
iconCls: 'btnexportexcel',
handler: function (button, event) {
this.onExportClick(button, event);
},
scope: this
},
{
text: "保存列表样式",
id: "btntest",
handler: function (button, event) {
var formname = this.formname;
var tempcolumns = this.gridList.columns;
DsTruck.SaveGridPanel(USERID, formname, tempcolumns, this.column, 0, false);
},
scope: this
}, '-',
{ text: "批量发放/取消", menu: menu1, scope: this }, {
text: "保存修改", id: "SaveBtn",
iconCls: "btnsave",
handler: function (button, event) {
this.onSaveClick(button, event);
},
scope: this
}, '-',
{ text: "打印报表", menu: menu1, scope: this }, '-', {
text: '生成整月工资信息',
tooltip: '输入月份、起止日期,然后生成整月的工资单。\n注意生成后需要输入入库费以计算实际应发金额。',
iconCls: "", id: "MakeMonthSalary",
handler: function (button, event) {
//var formHead = this.formHead.getForm();
this.winSTORAGEShow.show();
},
scope: this
}, {
text: '重新计算选中行工资',
tooltip: '重新计算选中行的工资、奖金、提成,用于少量维护。可以先分别录入入库费。',
iconCls: "", id: "MakeMonthSalaryList",
handler: function (button, event) {
this.MAKESalaryList();
},
scope: this
}
//,this.CB_EditMode
]
});
this.panelTop = new Ext.Panel({
layout: "border",
region: "north",
height: 75,
items: [this.formSearch, this.panelBtn]
});
Ext.apply(this, {
items: [this.panelTop, this.gridList, this.gridList_edit]
});
///以下集中绑定事件
this.storeList.on('beforeload', function (store) {
if (!this.checkSearchCondition())
return;
var sql = this.getCondition();
Ext.apply(store.proxy.extraParams, { condition: sql });
}, this);
this.gridList.on('edit', function (editor, e, eOpts) {
this.PCAfterEdit(editor, e, eOpts);
}, this);
this.cellEditing.on('beforeedit', function (editor, e) {
//alert("beforeedit");
return this.PCBeforeEdit(editor, e);
}, this);
this.formSTORAGE = 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: "label",
height: 20,
text: "请选择月份和日期:"
},
{
fieldLabel: '工资月份', id: "ACCDATE",
format: 'Y-m',
xtype: 'monthfield',
renderer: Ext.util.Format.dateRenderer('Y-m'),
name: 'ACCDATE',
listeners: {
change: function (field, eOpts) {
if (field.lastValue != "") {
}
},
scope: this
}
}
,
{
fieldLabel: '从..派车日期', id: "EXPDATEBGN",
format: 'Y-m-d',
xtype: 'datefield',
renderer: Ext.util.Format.dateRenderer('Y-m-d'),
name: 'EXPDATEBGN',
listeners: {
change: function (field, eOpts) {
if (field.lastValue != "") {
//this.formHead.getForm().findField('STOCKDATE_1').setValue(field.rawValue);
}
},
scope: this
}
},
{
fieldLabel: '到..派车日期', id: "EXPDATEEND",
format: 'Y-m-d',
xtype: 'datefield',
renderer: Ext.util.Format.dateRenderer('Y-m-d'),
name: 'EXPDATEEND',
listeners: {
change: function (field, eOpts) {
if (field.lastValue != "") {
//this.formHead.getForm().findField('STOCKDATE_1').setValue(field.rawValue);
}
},
scope: this
}
}]
});
me = this;
this.winSTORAGEShow = Ext.create('Ext.window.Window', {
title: "生成工资单",
width: 450,
//height : 120,
//plain : true,
iconCls: "addicon",
resizable: false,
// 是否可以拖动
// draggable:false,
collapsible: true, // 允许缩放条
closeAction: 'close',
closable: true,
modal: 'true',
buttonAlign: "center",
bodyStyle: "padding:0 0 0 0",
items: [this.formSTORAGE],
buttons: [
{
text: "确定",
minWidth: 70,
handler: function () {
_this.MAKESalary(
Ext.getCmp("ACCDATE").getRawValue()
, Ext.getCmp("EXPDATEBGN").getRawValue()
, Ext.getCmp("EXPDATEEND").getRawValue());
}
}, {
text: "取消",
minWidth: 70,
handler: function () {
me.winSTORAGEShow.close();
}
}]
});
this.LoadInitData();
}, //end initUIComponents
LoadInitData: function () {
//this.storeTruckNo.load({ params: { condition: " A.truckno not in (select DISTINCT truckno from tMsWlPcHead where isnull(isend,0)=0 ) "} });
},
onRefreshClick: function (button, event) {
if (!this.checkSearchCondition())
return;
var sql = this.getCondition();
this.storeList.load({
params: { start: 0, limit: this.PageSize, condition: sql },
waitMsg: "正在查询数据...",
scope: this
});
//}
},
onDeleteClick: function (button, event) {
var selectedRecords = this.gridList.getSelectionModel().getSelection();
if (selectedRecords.length == 0) {
Ext.Msg.show({ title: '提示', msg: '请先选择至少一条工资!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK
});
return;
}
var feeGidSql = '';
_this = this;
Ext.MessageBox.confirm('提示', '确定要删除选中的工资记录吗?', function (btn) {
if (btn == 'yes') {
if (selectedRecords.length > 0) {
for (var i = 0; i < selectedRecords.length; i++) {
var rec = selectedRecords[i];
if (rec.data.GID == "") //如果是新增但没有保存的数据,没有必要提交到后台
{
this.storeList.remove(selectedRecords[i]);
} else {
if (rec.data.ISLOCK != "1") {
var feeGId = "'" + rec.data.GID + "'";
if (feeGidSql == '') {
feeGidSql = feeGId;
} else {
feeGidSql = feeGidSql + "," + feeGId;
}
}
}
}
}
_thisfee = this;
Ext.Msg.wait('正在删除数据...');
if (feeGidSql != '') {
Ext.Ajax.request({
waitMsg: '正在删除数据...',
url: '/TruckMng/MsWlDriver/DeleteSalary',
params: {
data: feeGidSql
},
callback: function (options, success, response) {
if (success) {
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 });
}
}
},
failure: function (response, options) {
Ext.Msg.show({ title: '警告', msg: '服务器响应出错,请重试', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
},
success: function (response, options) {
},
scope: this
}); //end Ext.Ajax.request
Ext.Msg.hide();
} else {
Ext.Msg.show({ title: '提示', msg: "删除成功!", icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
}
}
}, this);
}, //onDeleteClick
getCondition: function () {
var form = this.formSearch.getForm();
var sql = '';
var DrvCode = form.findField('DrvCode').getValue();
sql = sql + getAndConSql(sql, DrvCode, " DrvCode like '%" + DrvCode + "%' ");
var ACCDATE = form.findField('ACCDATE').getRawValue();
sql = sql + getAndConSql(sql, ACCDATE, " ACCDATE = '" + ACCDATE + "' ");
var PAYDATEBGN = form.findField('PAYDATEBGN').getRawValue();
sql = sql + getAndConSql(sql, PAYDATEBGN, " PAYDATE>='" + PAYDATEBGN + "'");
var PAYDATEEND = form.findField('PAYDATEEND').getRawValue();
sql = sql + getAndConSql(sql, PAYDATEEND, " PAYDATE<='" + PAYDATEEND + " 23:59:59'");
var PCSTATUS = this.comboxPCSTATUS.getValue();
if (PCSTATUS != "") {
//sql = sql + getAndConSql(sql, Mainstate, "m.Mainstate in (" + Mainstate + ")");
//alert(PCSTATUS);
if (PCSTATUS == "0") {
sql = sql + getAndConSql(sql, PCSTATUS, " (settlement>=Amount and settlement>0) ");
}
if (PCSTATUS == "1") {
sql = sql + getAndConSql(sql, PCSTATUS, " settlement=0 ");
}
if (PCSTATUS == "2") {
sql = sql + getAndConSql(sql, PCSTATUS, "( settlement>=0 and settlement<Amount ) ");
}
if (PCSTATUS == "0,1") {
sql = sql + getAndConSql(sql, PCSTATUS, "( (settlement>=Amount and settlement>0) or settlement=0 )");
}
if (PCSTATUS == "1,2") {
sql = sql + getAndConSql(sql, PCSTATUS, "( settlement=0 or (settlement>=0 and settlement<Amount) )");
}
if (PCSTATUS == "0,2") {
sql = sql + getAndConSql(sql, PCSTATUS, "( (settlement>=Amount and settlement>0) or (settlement>=0 and settlement<Amount) )");
}
}
return sql;
},
checkSearchCondition: function () {
var form = this.formSearch.getForm();
if (!form.isValid()) {
Ext.Msg.alert('提示', '查询条件赋值错误,请检查。');
return false;
}
return true;
},
OprationSwap: function () {
var ret = new Array();
ret[0] = this.OprationStatus;
ret[1] = this.storeList;
ret[2] = this.SelectedRecord;
if (this.OprationStatus == "add") {
ret[3] = "";
} else {
ret[3] = this.SelectedRecord.data.REFBILLNO;
}
ret[4] = "MsRptPcHeadQryIndex";
ret[5] = formtype;
return ret;
},
onExportClick: function (button, event) {
GridExportExcelPage(this.gridList);
},
PayandLock: function (PAYTYPE) {
//批量发放
var selectedRecords = this.gridList.getSelectionModel().getSelection();
if (selectedRecords.length == 0) {
Ext.Msg.show({ title: '提示', msg: '请先选择至少一条工资!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK
});
return;
}
var bodyList = [];
for (i = 0; i < selectedRecords.length; i += 1) {
var member = selectedRecords[i];
bodyList.push(member);
};
var jsonBody = ConvertRecordsToJsonAll(bodyList);
Ext.Ajax.request({
waitMsg: '正在查询毛利数据...',
url: '/TruckMng/MsWlDriver/PayandLock',
async: false,
params: {
PAYTYPE: PAYTYPE,
data: jsonBody
},
callback: function (options, success, response) {
if (success) {
var result = Ext.JSON.decode(response.responseText);
if (!result.Success) {
Ext.Msg.show({
title: '提示',
msg: result.Message,
icon: Ext.MessageBox.ERROR,
buttons: Ext.Msg.OK
});
return;
}
var _count = result.data;
this.onRefreshClick();
} else {
Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
}
},
scope: this
}); //request over
}
,
onSaveClick: function () {
var bodyList = [];
for (i = 0; i < this.storeList.getCount(); i += 1) {
var member = this.storeList.getAt(i);
bodyList.push(member);
};
var jsonBody = ConvertRecordsToJson(bodyList);
if (jsonBody == '') {
return;
}
Ext.Msg.wait('正在保存数据, 请稍侯..');
Ext.Ajax.request({
waitMsg: '正在保存数据...',
url: '/TruckMng/MsWlDriver/SaveList_Salary',
scope: this,
params: {
data: jsonBody
},
callback: function (options, success, response) {
if (success) {
Ext.MessageBox.hide();
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
//this.storeList.commitChanges();
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
});
}
//alert('03');
}
});
}
,
onAddPCClick: function (button, event) {
var record = Ext.create('MsWlDriver_Salarymb', {
'GID': '',
'DRVCODE': '',
'ACCDATE': '',
'EXPDATEBGN': '',
'EXPDATEEND': '',
'BASESALARY': '0',
'BONUS': '0',
'RKF': '0',
'AMOUNT': '0',
'PAYDATE': '',
'SETTLEMENT': '0',
'REMARK': '',
'ISLOCK': '0',
'DRVNAME': '',
'STLSTATUS': '未发'
});
this.storeList.add(record);
var n = this.storeList.getCount();
this.cellEditing.startEditByPosition({ row: n - 1, column: 1 });
//this.storeTruckNo.load({ params: { condition: " A.truckno not in (select DISTINCT truckno from tMsWlPcHead where isnull(isend,0)=0 ) "} });
}
,
PCAfterEdit: function (editor, e, eOpts) {
//if (e.value == e.originalValue) { return; }
if (e.field == 'DRVCODE') {
var Yardrecords = DsStoreQueryBy(this.storeDrvName, 'DrvCode', e.value);
if (Yardrecords.getCount() > 0) {
var Yarddata = Yardrecords.getAt(0).data;
e.record.set('DRVNAME', Yarddata.DrvName);
} else {
e.record.set('DRVNAME', '');
}
}
if (e.field == 'RKF') {
var AMOUNT_0 = e.record.get('AMOUNT_0');
var BASESALARY = e.record.get('BASESALARY');
var RKF = e.record.get('RKF');
var BONUS = Mul(Cut(AMOUNT_0, RKF), 0.1);
var AMOUNT = Add(BASESALARY, BONUS);
e.record.set('BONUS', BONUS);
e.record.set('AMOUNT', AMOUNT);
e.record.set('SETTLEMENT', AMOUNT);
}
}
,
PCBeforeEdit: function (editor, e, eOpts) {
var _r = true;
if (e.record.get('ISLOCK') != "0") {
_r = false;
}
return _r;
}
, MAKESalary: function (ACCDATE, EXPDATEBGN, EXPDATEEND) { //生成入库信息
//20160707 修改
//如无对应销售信息,货主为操作者的“本公司”
//如有对应销售信息,则首先判断销售重量是否大于等于实际入库重量。
//如剩余重量小于等于1kg则全部按销售重量和销售客户按比例生成。
//如剩余重量大于1kg则剩余部分按货主为操作者的“本公司”处理。
var _this = this;
Ext.Msg.wait('正在保存数据, 请稍侯..');
Ext.Ajax.request({
waitMsg: '正在保存数据...',
url: '/TruckMng/MsWlDriver/MakeSalary',
scope: this,
params: {
ACCDATE: ACCDATE,
EXPDATEBGN: EXPDATEBGN,
EXPDATEEND: EXPDATEEND
},
callback: function (options, success, response) {
if (success) {
Ext.MessageBox.hide();
_this.winSTORAGEShow.close();
_this.onRefreshClick();
} else {
Ext.Msg.show({ title: '请重试',
msg: '服务器响应出错',
icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK
});
}
//alert('03');
}
});
}
, MAKESalaryList: function (ACCDATE, EXPDATEBGN, EXPDATEEND) { //生成入库信息
var selectedRecords = this.gridList.getSelectionModel().getSelection();
if (selectedRecords.length == 0) {
Ext.Msg.show({ title: '提示', msg: '请先选择至少一条工资!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK
});
return;
}
var bodyList = [];
for (i = 0; i < selectedRecords.length; i += 1) {
var member = selectedRecords[i];
bodyList.push(member);
};
var jsonBody = ConvertRecordsToJsonAll(bodyList);
var _this = this;
Ext.Msg.wait('正在保存数据, 请稍侯..');
Ext.Ajax.request({
waitMsg: '正在保存数据...',
url: '/TruckMng/MsWlDriver/MakeSalary_List',
scope: this,
params: {
data: jsonBody
},
callback: function (options, success, response) {
if (success) {
Ext.MessageBox.hide();
_this.onRefreshClick();
} else {
Ext.Msg.show({ title: '请重试',
msg: '服务器响应出错',
icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK
});
}
//alert('03');
}
});
}
,
Print_GZ: function () {
//alert("print");
var selectedRecords = this.gridList.selModel.getSelection();
var FEEGID = "";
for (var i = 0; i < selectedRecords.length; i++) {
var rec = selectedRecords[i];
if (FEEGID == "") {
FEEGID = FEEGID + "'" + rec.get('GId') + "'";
} else {
FEEGID = FEEGID + ",'" + rec.get('GId') + "'";
}
}
function GetDateStr(AddDayCount) {
var dd = new Date();
dd.setDate(dd.getDate() + AddDayCount); //获取AddDayCount天后的日期
var y = dd.getFullYear();
var m = dd.getMonth() + 1; //获取当前月份的日期
var d = dd.getDate();
return y + "-" + m + "-" + d;
}
//alert(GetDateStr(+5));
var madedate = GetDateStr(0);
var printType = 'MsWlDriver_GZ'; //收款通知单
var sql1 = " Select GID,DRVCODE,ACCDATE,dbo.trimdate(EXPDATEBGN) EXPDATEBGN ";
sql1 = sql1 + " ,dbo.trimdate(EXPDATEEND) EXPDATEEND,BASESALARY,BONUS,RKF,AMOUNT,AMOUNT_0 ";
sql1 = sql1 + " ,dbo.trimdate(PAYDATE) PAYDATE,SETTLEMENT,REMARK,ISLOCK ";
sql1 = sql1 + " ,(select Drvname from tmswldriver where drvcode=tMsWlDriver_Salary.drvcode) DRVNAME ";
sql1 = sql1 + " ,(case when ISLOCK=0 then '未发' when (islock=1 and settlement>0 and settlement <amount) then '部分发放' ";
sql1 = sql1 + " when (ISLOCK=1 and settlement>=amount) then '已发' end) STLSTATUS ";
sql1 = sql1 + " from tMsWlDriver_Salary ";
sql1 = sql1 + " where gid in( " + FEEGID + ")";
//var sql1 = sql1 + T;
//var sql1 = sql1 + " go ";
var sql2 = "";
var sql3 = "select '" + madedate + "' as madedate,'" + CUSTOMERNAME[0] + "' as CUSTOMERNAME,'" + SHOWNAME + "' as SHOWNAME";
var sql4 = "";
var sql5 = "";
var sql6 = "";
PrintComm(printType, sql1, sql2, sql3, sql4, sql5, sql6);
}
});