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/MsChFeeAutoDui/MsChFeeAutoDuiIndex.js

873 lines
30 KiB
JavaScript

//集运管理-路单查询
Ext.namespace('DsTruck');
DsTruck.MsChFeeAutoDuiIndex = function (config) {
Ext.applyIf(this, config);
this.initUIComponents();
window.DsTruck.MsChFeeAutoDuiIndex.superclass.constructor.call(this);
};
//#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(), //second
"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;
}
var xhr = new XMLHttpRequest();
var currdate = new Date();
if (!xhr) {
//...其他生成xmlhttprequest方法
}
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);
// alert(currdate.format('yyyy-MM-dd'));
}
}
xhr.send(null);
//#endregion
Ext.extend(DsTruck.MsChFeeAutoDuiIndex, Ext.Panel, {
PageSize: 100,
OprationStatus: null, //仅当弹出界面时使用
SelectedRecord: null,
initUIComponents: function () {
//定义数据集
this.storeList = Ext.create('Ext.data.Store', {
pageSize: this.PageSize,
model: 'MsChFeeAutoDuimb',
remoteSort: false,
proxy: {
type: 'ajax',
url: '/MvcShipping/MsChFeeAutoDui/GetDataList',
reader: {
id: 'GID',
root: 'data',
totalProperty: 'totalCount'
}
}
});
this.formname = "MsChFeeAutoDui";
parentWin = window.parent;
mainWin = getMainForm(parentWin);
//#region 表参照
//#endregion
this.column = [
{
sortable: true, style: 'text-align:center;', align: 'right',
dataIndex: 'GID',
header: '自动对账编号',
width: 110
},
{
sortable: true, style: 'text-align:center;', align: 'right',
dataIndex: 'CUSTOMERNAME',
header: '结算对象',
width: 80
},
{
sortable: true, style: 'text-align:center;', align: 'right',
dataIndex: 'FEETYPE',
header: '收付方向',
width: 80,
renderer: function (value) {
if (value == "0") {
return "";
} else if (value == "1") {
return "应收";
} else if (value == "2") {
return "应付";
} else if (value == "3") {
return "全部应收付";
}
}
},
{
sortable: true, style: 'text-align:center;', align: 'right',
dataIndex: 'DUISTATUS',
header: '对账状态',
width: 80
},
{
sortable: true, style: 'text-align:center;', align: 'right',
dataIndex: 'STARTDATE',
header: '开始日期',
width: 80
},
{
sortable: true, style: 'text-align:center;', align: 'right',
dataIndex: 'ENDDATE',
header: '结束日期',
width: 80
},
{
sortable: true, style: 'text-align:center;', align: 'right',
dataIndex: 'OP',
header: '操作人',
width: 80
},
{
sortable: true, style: 'text-align:center;', align: 'right',
dataIndex: 'OPDATE',
header: '操作日期',
width: 80
},
{
sortable: true, style: 'text-align:center;', align: 'right',
dataIndex: 'REMARK',
header: '备注',
width: 80
},
{
sortable: true, hidden: true,
dataIndex: 'REMARK2',
header: 'REMARK2',
width: 80
},
{
sortable: true, style: 'text-align:center;', align: 'right',
dataIndex: 'STATUS',
header: '对账情况',
width: 80
},
{
sortable: true,hidden:true,
dataIndex: 'STATUS_REF',
header: 'STATUS_REF',
width: 80
},
{
sortable: true, style: 'text-align:center;', align: 'right',
dataIndex: 'HAVEDEBIT',
header: '是否包含已对账',
width: 110,
renderer: function (value) {
if (value == "0") {
return "";
} else if (value == "1") {
return "包含已对账";
}
}
},
{
sortable: true, style: 'text-align:center;', align: 'right',
dataIndex: 'FSTATUS',
header: '费用状态',
width: 80,
renderer: function (value) {
if (value == "0") {
return "全部";
} else if (value == "1") {
return "仅已审核";
} else if (value == "2") {
return "仅未审核";
}
}
},
{
sortable: true, style: 'text-align:center;', align: 'right',
dataIndex: 'DUINO',
header: '对账单编号',
width: 110
},
{
sortable: true, align: 'right',
dataIndex: 'RMBAMOUNT',
header: 'RMB对账金额',
width: 80,
renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
value = usMoney(value, 2, '', true);
return value;
},
summaryType: 'sum', align: 'right',
summaryRenderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
value = usMoney(value, 2, '', true);
return value;
}
},
{
sortable: true, align: 'right',
dataIndex: 'USDAMOUNT',
header: 'USD对账金额',
width: 80,
renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
value = usMoney(value, 2, '', true);
return value;
},
summaryType: 'sum', align: 'right',
summaryRenderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
value = usMoney(value, 2, '', true);
return value;
}
},
{
sortable: true, align: 'right',
dataIndex: 'L_RMBAMOUNT',
header: 'RMB本地金额',
width: 80,
renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
value = usMoney(value, 2, '', true);
return value;
},
summaryType: 'sum', align: 'right',
summaryRenderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
value = usMoney(value, 2, '', true);
return value;
}
},
{
sortable: true, align: 'right',
dataIndex: 'L_USDAMOUNT',
header: 'USD本地金额',
width: 80,
renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
value = usMoney(value, 2, '', true);
return value;
},
summaryType: 'sum', align: 'right',
summaryRenderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
value = usMoney(value, 2, '', true);
return value;
}
}
];
this.cellEditing = Ext.create('Ext.grid.plugin.CellEditing', {
clicksToEdit: 1
});
this.PCCB = Ext.create('Ext.selection.CheckboxModel', { checkOnly: true });
Ext.grid.RowNumberer = Ext.extend(Ext.grid.RowNumberer, {
width: 45
});
//定义Grid
this.gridList = new Ext.grid.GridPanel({
store: this.storeList,
enableHdMenu: false,
region: 'center',
loadMask: { msg: "数据加载中,请稍等..." },
trackMouseOver: true,
disableSelection: false,
/*features: [{
ftype: 'summary'//Ext.grid.feature.Summary表格汇总特性
}],*/
selModel: this.PCCB,
plugins: [this.cellEditing],
viewConfig: {
enableTextSelection: true, //允许复制数据
autoFill: true
},
columns: [new Ext.grid.RowNumberer(),
],
// paging bar on the bottom
bbar: Ext.create('Ext.PagingToolbar', {
store: this.storeList,
displayInfo: true,
displayMsg: '当前显示 {0} - {1}条记录 /共 {2}条记录',
emptyMsg: "没有数据"
})
});
/////////////以下部分为获取存储的gridpanel显示样式
this.column = DsTruck.GetGridPanel(GID, this.formname, this.column);
this.column.unshift(new Ext.grid.RowNumberer());
this.gridList.reconfigure(this.storeList, this.column);
////////////////////////////
this.gridList.addListener('itemdblclick', function (dataview, record, item, index, e, b) {
this.SelectedRecord = record;
this.OprationStatus = 'edit';
DsOpenEditWin('/MvcShipping/MsChFeeAutoDui/Edit', "自动对账明细");
}, this);
//#region formSearch
//#region formSearch枚举参照相关
var _this = this;
this.storeCustCode = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.CustomInvRefModel',
proxy: { url: '/CommMng/BasicDataRef/GetCustomInvRefList' }
});
this.storeCustCode.loadData(mainWin.GetPubStore("PubStore_CustomerAll").data.items);
this.comboxCUSTOMERNAME = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '结算对象',
forceSelection: true,
store: this.storeCustCode,
matchFieldWidth: false,
queryMode: 'remote',
minChars: 1,
queryParam: 'CODENAME',
lazyRender: false,
name: 'CUSTOMERNAME',
valueField: 'CustName',
displayField: 'CodeAndName',
listeners: {
specialkey: function (field, e) {
if (e.getKey() == e.ENTER) {
_this.onRefreshClick();
}
}
}
});
this.storeUser = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsTruckMng.ux.UserRefModel',
proxy: { url: '/CommMng/BasicDataRef/GetUserRefList' }
});
this.storeUser.load({ params: { condition: "" } });
this.comboxOP = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '操作人',
forceSelection: true,
store: this.storeUser,
matchFieldWidth: false,
name: 'OP',
valueField: 'UserName',
displayField: 'CodeAndName',
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: 90,
msgTarget: 'qtip'
},
items: [
{//fieldset 1
xtype: 'container',
defaultType: 'textfield',
layout: 'anchor',
defaults: {
anchor: '100%'
},
items: [{
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [
this.comboxCUSTOMERNAME
, {
fieldLabel: '自动对账编号',
name: 'GID',
listeners: {
specialkey: function (field, e) {
if (e.getKey() == e.ENTER) {
_this.onRefreshClick();
}
}
}
}, { fieldLabel: '提单号',
name: 'MBLNO',
listeners: {
specialkey: function (field, e) {
if (e.getKey() == e.ENTER) {
_this.onRefreshClick();
}
}
}
}
, {
fieldLabel: '从..开船日期',
format: 'Y-m-d',
xtype: 'datefield',
name: 'ETDbgn',
enableKeyEvents: true,
listeners: {
specialkey: function (field, e) {
if (e.getKey() == e.ENTER) {
_this.onRefreshClick();
}
}
}
}, {
fieldLabel: '到..开船日期',
format: 'Y-m-d',
xtype: 'datefield',
name: 'ETDend',
enableKeyEvents: true,
listeners: {
specialkey: function (field, e) {
if (e.getKey() == e.ENTER) {
_this.onRefreshClick();
}
}
}
}
, this.comboxOP
//, { xtype: 'hiddenfield', flex: 1 }
]
}, {
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 menu_SetFee = new Ext.menu.Menu({
id: 'PriceMenu',
items: [{
text: '设定超重费用',
handler: clickHandler_1
}, {
text: '超重费用取消',
handler: clickHandler_2
}, {
text: '设定重回额外费用',
handler: clickHandler_3
}, {
text: '重回额外费用取消',
handler: clickHandler_4
}]
});
me = this;
function clickHandler_1() {
me.SetFee("超重费", "150", "1");
};
function clickHandler_2() {
me.SetFee("超重费", "150", "0");
};
function clickHandler_3() {
me.SetFee("双背附加费", "600", "1");
};
function clickHandler_4() {
me.SetFee("双背附加费", "600", "0");
};
//查询工具条
this.panelBtn = new Ext.Panel({
region: "north",
tbar: [
{
text: "执行查询",
iconCls: "btnrefresh",
handler: function (button, event) {
this.onRefreshClick(button, event);
},
scope: this
}, '-', {
text: "新建",
iconCls: "btnadd",
handler: function (button, event) {
this.OprationStatus = 'add';
DsOpenEditWin("/MvcShipping/MsChFeeAutoDui/Edit", "自动对账");
},
scope: this
}, {
text: '删除',
tooltip: '删除',
iconCls: "btndeletedetail",
handler: function (button, event) {
this.onDelPCClick(button, event);
},
scope: this
}, {
text: "保存修改",
iconCls: "btnsave",
handler: function (button, event) {
this.onSaveClick(button, event);
},
scope: this
}, '-', {
text: '复制添加',
tooltip: '复制添加选中的方案',
iconCls: "btncopy",
handler: function (button, event) {
this.onCOPYNEW(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) {
DsTruck.SaveGridPanel(GID, this.formname, this.gridList.columns, this.column, 1, false);
},
scope: this
}
]
});
//#region 布局
this.panelTop = new Ext.Panel({
layout: "border",
region: "north",
height: 70,
items: [this.formSearch, this.panelBtn]
});
Ext.apply(this, {
items: [this.panelTop, this.gridList]
});
this.storeList.on('beforeload', function (store) {
if (!this.checkSearchCondition())
return;
var sql = this.getCondition();
Ext.apply(store.proxy.extraParams, { condition: sql });
}, this);
//#endregion
}, //end initUIComponents
onAuditRefuseClick: function (button, event) {
var sql = " A.GID in (select bsno from ch_fee where FEESTATUS=6)";
this.storeList.load({
params: { start: 0, limit: this.PageSize, sort: "", condition: sql },
waitMsg: "正在查询数据...",
scope: this
});
},
onRefreshClick: function (button, event) {
if (!this.checkSearchCondition())
return;
var sql = this.getCondition();
this.storeList.load({
//GetDataList(int start, int limit, string sort, string condition)
params: { start: 0, limit: this.PageSize, sort: "", condition: sql },
waitMsg: "正在查询数据...",
scope: this
});
},
getCondition: function () {
var form = this.formSearch.getForm();
var sql = "";
var CUSTOMERNAME = form.findField('CUSTOMERNAME').getValue();
sql = sql + getAndConSql(sql, CUSTOMERNAME, " CUSTOMERNAME like '" + CUSTOMERNAME + "'");
var MBLNO = form.findField('MBLNO').getValue();
sql = sql + getAndConSql(sql, MBLNO, " GID in(select BSNO from CH_FEE_AutoDuiDetail where MBLNO like '%" + MBLNO + "%') ");
var ETDbgn = form.findField('ETDbgn').getRawValue();
sql = sql + getAndConSql(sql, ETDbgn, " GID in(select BSNO from CH_FEE_AutoDuiDetail where MBLNO in(select MBLNO from v_op_bill where ETD>='" + ETDbgn + "'))");
var ETDend = form.findField('ETDend').getRawValue();
sql = sql + getAndConSql(sql, ETDend, " GID in(select BSNO from CH_FEE_AutoDuiDetail where MBLNO in(select MBLNO from v_op_bill where ETD<='" + ETDend + " 23:59:59'))");
var OP = form.findField('OP').getValue();
sql = sql + getAndConSql(sql, OP, " OP='" + OP + "'");
var GID = form.findField('GID').getValue();
sql = sql + getAndConSql(sql, GID, " GID like '%" + GID + "%'");
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;
//ret[3] = this.SelectedRecord.data.REFBILLNO;
//ret[4] = "MsRptPcHeadQryIndex";
return ret;
},
onExportClick: function (button, event) {
GridExportExcelPage(this.gridList);
},
SetFee: function (FeeName, Amount, Type) {
var _condition = this.getCondition();
var GIDList = [];
var selectedRecords = this.gridList.selModel.getSelection();
for (var i = 0; i < selectedRecords.length; i++) {
var rec = selectedRecords[i];
GIDList.push(rec.get('GID'));
}
var _GIDList = ConvertStringListToJson(GIDList);
Ext.Ajax.request({//
waitMsg: '正在初始化库存数据...',
url: '/TruckMng/MsRptPcHeadQry/SetFee',
params: {
GIDList: _GIDList,
FeeName: FeeName,
Amount: Amount,
Type: Type
},
callback: function (_count) {
//alert('初始化完成');
//重新load库存表的store
this.storeList.load({ params: { condition: _condition} });
},
scope: this
}); //request over
},
onAddPCClick: function (button, event, type) {
var store = null;
store = this.storeList;
//var truckno = Ext.getCmp('S_TRUCKNO').getValue();
record = Ext.create('PCmb', {
TRUCKNO: "",
DRVCODE: "",
DRVNAME: "",
GId: newGuid(),
BillNo: "",
DdCode: usercode,
DdCode_Ref: SHOWNAME,
DDNAME: "",
ArriveDate: currdate.format('yyyy-MM-dd'),
CustCode: "QDHE",
CustName: "海尔",
TRUCKNO: "",
MBLNO: "",
DRVNAME: "",
DRVNAME_REF: "",
MOBILE: "",
CONTAINERTYPE: "",
CONTAINERTYPE_REF: "",
CONTAINERQTY: "",
YARDCODE_REF: "",
VOYVEG_REF: "",
DSTAREA: "",
NOLOADMIL: "",
OVERLOADMIL: "",
RATEDFUEL: "",
REALFUEL: "",
LRDATE: "",
USERCODE: "",
USERNAME: "",
REFBILLNO: "",
DETINATION: "",
CONTAINERNO: "",
SEALNO: "",
Ton: "",
ActualWeight: "",
IsDoubleREF: "",
IsDoubleREF: "",
TimeMark: 0
});
var _this = this;
var data = record.data;
Ext.Msg.wait('正在保存数据, 请稍侯..');
Ext.Ajax.request({
waitMsg: '正在保存数据...',
url: '/TruckMng/MsWl_Haier/CreatePC',
scope: this,
async: true,
params: {
data: Ext.JSON.encode(data)
},
callback: function (options, success, response) {
if (success) {
Ext.MessageBox.hide();
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
record = jsonresult.Data;
store.add(record);
cellediting = this.cellEditing;
var n = store.getCount();
cellediting.startEditByPosition({ row: n - 1, column: 2 });
} 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');
}
});
},
onDelPCClick: 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 selectedRecords = [];
selectedRecords = this.gridList.selModel.getSelection();
/*
var candelete = DsTruck.CheckBaoxiaoDelete(selectedRecords);
if (candelete == false) {
return;
}*/
var record = selections[0];
Ext.MessageBox.confirm('提示', '确定删除该记录吗?', function (btn) {
if (btn == 'yes') {
Ext.Msg.wait('正在删除数据...');
Ext.Ajax.request({
waitMsg: '正在删除数据...',
url: '/MvcShipping/MsChFeeAutoDui/Delete',
params: {
data: Ext.JSON.encode(record.data)
},
callback: function (options, success, response) {
if (success) {
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
this.storeList.remove(record);
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 });
},
success: function (response, options) {
},
scope: this
}); //end Ext.Ajax.request
}
}, this);
//InitData();
} //onDeleteClick
,
onSaveClick: function (button, event) {
for (var i = 0; i < this.storeList.getCount(); i += 1) {
var record = this.storeList.getAt(i);
if (record.dirty) {
Ext.Ajax.request({
waitMsg: '正在保存数据...',
url: '/TruckMng/MsWl_Haier/SaveYDHZ',
scope: this,
async: false,
params: {
data: Ext.JSON.encode(record.data)
},
callback: function (options, success, response) {
if (success) {
//Ext.MessageBox.hide();
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
var returnData = jsonresult.Data;
var editp = Ext.create('PCmb', returnData);
this.storeList.getAt(i).fields.each(function (field) {
if (field.persist) {
name = field.name;
//alert(name + ' -- ' + editp.get(name));
if (name != 'BillNo')
this.storeList.getAt(i).set(name, editp.get(name));
}
}, this);
this.storeList.getAt(i).commit();
} 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
});
}
}
});
}
}
}
});