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.

897 lines
33 KiB
JavaScript

Ext.namespace('Shipping');
Shipping.MsOpLetterTruckFeeIndex = function (config) {
Ext.applyIf(this, config);
this.initUIComponents();
window.Shipping.MsOpLetterTruckFeeIndex.superclass.constructor.call(this);
};
Ext.extend(Shipping.MsOpLetterTruckFeeIndex, Ext.Panel, {
PageSize: 30,
OprationStatus: null, //仅当弹出界面时使用
SelectedRecord: null,
EditRecord: null,
BsNo: "",
oplb: '',
initUIComponents: function () {
//定义数据集
this.bsno = getUrlParam('bsno');
this.feetype = getUrlParam('type');
this.oplb = getUrlParam('oplb');
this.storeList = Ext.create('Ext.data.Store', {
pageSize: this.PageSize,
model: 'MsOpLetterTruck',
remoteSort: true,
proxy: {
type: 'ajax',
url: '/MvcShipping/MsOpLetter/GetTruckList',
reader: {
id: 'BsNo',
root: 'data',
totalProperty: 'totalCount'
}
}
});
this.girdcolums = [{
sortable: true,
dataIndex: 'LE_ID',
header: 'LE_ID',
hidden: true,
width: 150
}, {
sortable: true,
dataIndex: 'BSNO',
header: '业务编号',
hidden: true,
width: 150
}, {
sortable: true,
dataIndex: 'TRUCK',
header: '车队',
width: 120
}, {
sortable: true,
dataIndex: 'CTNS',
header: '集装箱',
width: 120
}, {
sortable: true,
dataIndex: 'FACTRYNAME',
header: '工厂',
width: 120
}, {
sortable: true,
dataIndex: 'FACTRYTIME',
header: '要求到达时间',
width: 120
}, {
sortable: true,
dataIndex: '吨数',
header: 'KGS',
width: 120
}, {
sortable: true,
dataIndex: '陆运费',
header: 'TRUCKFEE',
width: 120
}, {
sortable: true,
dataIndex: 'INPUTBYREF',
header: '录入人',
width: 80
}, {
sortable: true,
dataIndex: 'INPUTTIME',
header: '录入日期',
width: 80
}
];
this.CheckBoxModel = Ext.create('Ext.selection.CheckboxModel');
//定义Grid
this.gridList = new Ext.grid.GridPanel({
store: this.storeList,
enableHdMenu: false,
region: 'north',
height:120,
loadMask: { msg: "数据加载中,请稍等..." },
trackMouseOver: true,
disableSelection: false,
selModel: this.CheckBoxModel,
columns: this.girdcolums,
bbar: Ext.create('Ext.PagingToolbar', {
store: this.storeList,
displayInfo: true,
displayMsg: '当前显示 {0} - {1}条记录 /共 {2}条记录',
emptyMsg: "没有数据"
})
});
_this = this;
//this.gridList.addListener('itemdblclick', function (dataview, record, item, index, e, b) {
// _this.SelectedRecord = record;
// _this.OprationStatus = 'edit';
// if (record.data.LETTERNAME == '入货通知')
// window.open('/MvcShipping/MsOpLetter/YardEdit', "函电", "height=" + (window.screen.availHeight - 155) + ", width=900px,center:yes,help:no,toolbar=no,menubar=no,scrollbars=no,resizable=0,location=no,status=no");
// else if (record.data.LETTERNAME == '派车通知')
// window.open('/MvcShipping/MsOpLetter/TruckEdit', "函电", "height=" + (window.screen.availHeight - 155) + ", width=900px,center:yes,help:no,toolbar=no,menubar=no,scrollbars=no,resizable=0,location=no,status=no");
// else if (record.data.LETTERNAME == '电放保函')
// window.open('/MvcShipping/MsOpLetter/SurEdit', "函电", "height=" + (window.screen.availHeight - 155) + ", width=900px,center:yes,help:no,toolbar=no,menubar=no,scrollbars=no,resizable=0,location=no,status=no");
// else if (record.data.LETTERNAME == '更改通知')
// window.open('/MvcShipping/MsOpLetter/ChangeEdit', "函电", "height=" + (window.screen.availHeight - 155) + ", width=900px,center:yes,help:no,toolbar=no,menubar=no,scrollbars=no,resizable=0,location=no,status=no");
//}, this);
//查询工具条
_this;
this.panelBtn = new Ext.Panel({
region: "north",
tbar: [
{
text: "取消退出",
handler: function (button, event) {
window.close();
}
}
]
});
this.storeDrChFee = Ext.create('Ext.data.Store', {
model: 'MsChFee',
remoteSort: false,
proxy: {
type: 'ajax',
url: '/MvcShipping/MsChFee/GetDataList',
reader: {
id: 'GId',
root: 'data',
totalProperty: 'totalCount'
}
}
});
this.feeDrGridCheckBoxModel = Ext.create('Ext.selection.CheckboxModel');
_this = this;
this.gridDrChFee = new Ext.grid.GridPanel({
store: this.storeDrChFee,
enableHdMenu: false,
region: 'center',
id: 'gridDrChFee',
loadMask: { msg: "数据加载中,请稍等..." },
trackMouseOver: true,
disableSelection: false,
selModel: this.feeDrGridCheckBoxModel,
selType: 'cellmodel',
viewConfig: {
autoFill: true,
getRowClass: function (record, rowIndex, rowParams, store) {
var feeStatus = record.get('FeeStatus');
return Shipping.FeeGetRowClass(feeStatus);
}
},
tbar: [
{
text: '关联费用', //'增加明细',
tooltip: '关联费用', //'增加明细',
id: "btnadddetail",
iconCls: "btnadddetail",
handler: function (button, event) {
this.UpdateDetail();
},
scope: this
}],
columns: [{
sortable: true,
dataIndex: 'GId',
header: '惟一编号',
hidden: true,
width: 160
}, {
sortable: true,
dataIndex: 'BsNo',
header: '业务编号',
hidden: true,
width: 200
}, {
sortable: true,
dataIndex: 'FeeStatus',
header: '费用状态',
renderer: function (value, p, record) {
return record.data.FeeStatus_Ref;
},
width: 66
}, {
sortable: true,
dataIndex: 'FeeName',
header: '应收费用名称',
width: 100
}, {
sortable: true,
dataIndex: 'FeeDescription',
header: '费用英文名称',
width: 120
}, {
sortable: true,
dataIndex: 'CustomerType',
header: '客户类别',
width: 80
}, {
sortable: true,
dataIndex: 'CustomerName',
header: '结算对象',
width: 120
}, {
sortable: true,
dataIndex: 'Unit',
header: '单位标准',
width: 60
}, {
sortable: true,
dataIndex: 'UnitPrice',
header: '单价',
align: 'right',
width: 80,
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;
}
}, {
sortable: true,
dataIndex: 'Quantity',
header: '数量',
width: 60
}, {
sortable: true,
dataIndex: 'TaxRate',
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: 60
}, {
sortable: true,
dataIndex: 'NoTaxAmount',
header: '不含税金额',
align: 'right',
width: 80,
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;
}
}, {
sortable: true,
dataIndex: 'Amount',
header: '金额',
align: 'right',
width: 80,
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;
}
}, {
sortable: true,
dataIndex: 'Currency',
header: '币别',
width: 40
}, {
sortable: true,
dataIndex: 'ExChangerate',
header: '汇率',
renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) { try { var lsValue = usMoney(value, 6, '', 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: 60
}, {
sortable: true,
dataIndex: 'AccTaxRate',
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
}, {
sortable: true,
dataIndex: 'Remark',
header: '备注',
width: 150
}, {
sortable: true,
dataIndex: 'IsAdvancedpay',
header: '是否垫付',
width: 60
}, {
sortable: true,
dataIndex: 'FeeFrt',
header: 'FRT',
width: 40
}, {
sortable: true,
dataIndex: 'Commissionrate',
header: '佣金比率',
width: 60
}, {
sortable: true,
dataIndex: 'OpName',
header: '录入人',
width: 60
}, {
sortable: true,
dataIndex: 'EnterDate',
header: '录入日期',
renderer: Ext.util.Format.dateRenderer('Y-m-d'),
width: 80
}, {
sortable: true,
dataIndex: 'Settlement',
header: '结算金额',
align: 'right',
width: 80,
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;
}
}, {
sortable: true,
dataIndex: 'Invoice',
header: '已开票金额',
align: 'right',
width: 80,
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;
}
}, {
sortable: true,
dataIndex: 'InvoiceNum',
header: '发票号码',
width: 80
}
]
});
this.panelCenter = new Ext.Panel({
layout: "border",
region: "center",
// height: 180,
id: "BillHead",
items: [this.gridDrChFee]
});
this.storeBodyChFee = Ext.create('Ext.data.Store', {
model: 'MsChFee',
remoteSort: false,
proxy: {
type: 'ajax',
url: '/MvcShipping/MsChFee/GetDataList',
reader: {
id: 'GId',
root: 'data',
totalProperty: 'totalCount'
}
}
});
this.BodyChFeeDrGridCheckBoxModel = Ext.create('Ext.selection.CheckboxModel');
_this = this;
this.gridBodyChFee = new Ext.grid.GridPanel({
store: this.storeBodyChFee,
enableHdMenu: false,
region: 'center',
loadMask: { msg: "数据加载中,请稍等..." },
trackMouseOver: true,
disableSelection: false,
selModel: this.BodyChFeeDrGridCheckBoxModel,
selType: 'cellmodel',
viewConfig: {
autoFill: true,
getRowClass: function (record, rowIndex, rowParams, store) {
var feeStatus = record.get('FeeStatus');
return Shipping.FeeGetRowClass(feeStatus);
}
},
tbar: [
{
text: '取消关联', //'删除明细',
tooltip: '取消关联', //'删除明细',
id: "btndeldetail",
iconCls: "btndeletedetail",
handler: function (button, event) {
this.deleteDetail();
},
scope: this
}],
columns: [{
sortable: true,
dataIndex: 'GId',
header: '惟一编号',
hidden: true,
width: 160
}, {
sortable: true,
dataIndex: 'BsNo',
header: '业务编号',
hidden: true,
width: 200
}, {
sortable: true,
dataIndex: 'FeeStatus',
header: '费用状态',
renderer: function (value, p, record) {
return record.data.FeeStatus_Ref;
},
width: 66
}, {
sortable: true,
dataIndex: 'FeeName',
header: '应收费用名称',
width: 100
}, {
sortable: true,
dataIndex: 'FeeDescription',
header: '费用英文名称',
width: 120
}, {
sortable: true,
dataIndex: 'CustomerType',
header: '客户类别',
width: 80
}, {
sortable: true,
dataIndex: 'CustomerName',
header: '结算对象',
width: 120
}, {
sortable: true,
dataIndex: 'Unit',
header: '单位标准',
width: 60
}, {
sortable: true,
dataIndex: 'UnitPrice',
header: '单价',
align: 'right',
width: 80,
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;
}
}, {
sortable: true,
dataIndex: 'Quantity',
header: '数量',
width: 60
}, {
sortable: true,
dataIndex: 'TaxRate',
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: 60
}, {
sortable: true,
dataIndex: 'NoTaxAmount',
header: '不含税金额',
align: 'right',
width: 80,
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;
}
}, {
sortable: true,
dataIndex: 'Amount',
header: '金额',
align: 'right',
width: 80,
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;
}
}, {
sortable: true,
dataIndex: 'Currency',
header: '币别',
width: 40
}, {
sortable: true,
dataIndex: 'ExChangerate',
header: '汇率',
renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) { try { var lsValue = usMoney(value, 6, '', 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: 60
}, {
sortable: true,
dataIndex: 'AccTaxRate',
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
}, {
sortable: true,
dataIndex: 'Remark',
header: '备注',
width: 150
}, {
sortable: true,
dataIndex: 'IsAdvancedpay',
header: '是否垫付',
width: 60
}, {
sortable: true,
dataIndex: 'FeeFrt',
header: 'FRT',
width: 40
}, {
sortable: true,
dataIndex: 'Commissionrate',
header: '佣金比率',
width: 60
}, {
sortable: true,
dataIndex: 'OpName',
header: '录入人',
width: 60
}, {
sortable: true,
dataIndex: 'EnterDate',
header: '录入日期',
renderer: Ext.util.Format.dateRenderer('Y-m-d'),
width: 80
}, {
sortable: true,
dataIndex: 'Settlement',
header: '结算金额',
align: 'right',
width: 80,
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;
}
}, {
sortable: true,
dataIndex: 'Invoice',
header: '已开票金额',
align: 'right',
width: 80,
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;
}
}, {
sortable: true,
dataIndex: 'InvoiceNum',
header: '发票号码',
width: 80
}
]
});
this.panelBody = new Ext.Panel({
layout: "border",
region: "north",
height: 180,
items: [this.gridBodyChFee]
});
this.panelTop = new Ext.Panel({
layout: "border",
region: "north",
height: 30,
items: [this.panelBtn]
});
Ext.apply(this, {
items: [this.panelTop, this.gridList,this.panelBody, this.panelCenter]
});
// this.onRefreshClick();
this.storeList.on('beforeload', function (store) {
var sql = "t.BSNO='" + _this.bsno + "'";
Ext.apply(store.proxy.extraParams, { condition: sql });
}, this);
this.gridList.getSelectionModel().on('select', function (model, record, index) {
//alert(record.data.BillNo);
var bsno = record.data.BSNO;
var LE_ID = record.data.LE_ID;
var sql = "BSNO='" + _this.bsno+ "' and CARGO_GID='" + LE_ID + "'"
this.storeBodyChFee.load({ params: { condition: sql, type: _this.feetype, optype: 'op_Seae' } });
}, this);
var sql = "t.BSNO='" + _this.bsno + "'";
this.storeList.load({ params: { condition: sql } });
this.storeDrChFee.load({ params: { billno: this.bsno, type: this.feetype, optype: this.oplb } });
}, //end initUIComponents
deleteDetail: function () {
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 record = selections[0];
var LE_ID = record.data.LE_ID;
if (LE_ID == '') {
Ext.Msg.show({ title: '提示', msg: '派车信息不能为空', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
}
var selectedRecords = this.gridBodyChFee.selModel.getSelection();
if (selectedRecords.length == 0) {
Ext.Msg.show({ title:'提示', msg:'请选择要取消关联的费用', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
}
var feeGidSql = '';
if (selectedRecords.length > 0) {
for (var i = 0; i < selectedRecords.length; i++) {
var rec = selectedRecords[i];
var feeGId = "'" + rec.data.GId + "'";
if (feeGidSql == '') {
feeGidSql = feeGId;
} else {
feeGidSql = feeGidSql + "," + feeGId;
}
}
}
Ext.Msg.wait('正在操作数据');
Ext.Ajax.request({
waitMsg: '正在操作数据', //'正在删除数据...',
url: '/MvcShipping/MsOpLetter/DeleteTruckFeeLink',
params: {
bsno: _this.bsno,
le_id: LE_ID,
data: feeGidSql
},
callback: function (options, success, response) {
if (success) {
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
_this.storeBodyChFee.reload();
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
},
UpdateDetail: function () {
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 record = selections[0];
var LE_ID = record.data.LE_ID;
if (LE_ID == '') {
Ext.Msg.show({ title: '提示', msg: '派车信息不能为空', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
}
var selectedRecords = this.gridDrChFee.selModel.getSelection();
if (selectedRecords.length == 0) {
Ext.Msg.show({ title: '提示', msg: '请选择要关联的费用', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
}
var feeGidSql = '';
if (selectedRecords.length > 0) {
for (var i = 0; i < selectedRecords.length; i++) {
var rec = selectedRecords[i];
var feeGId = "'" + rec.data.GId + "'";
if (feeGidSql == '') {
feeGidSql = feeGId;
} else {
feeGidSql = feeGidSql + "," + feeGId;
}
}
}
Ext.Msg.wait('正在操作数据');
Ext.Ajax.request({
waitMsg: '正在操作数据', //'正在删除数据...',
url: '/MvcShipping/MsOpLetter/UpdateTruckFeeLink',
params: {
bsno: _this.bsno,
le_id: LE_ID,
data: feeGidSql
},
callback: function (options, success, response) {
if (success) {
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
_this.storeBodyChFee.reload();
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
},
OprationSwap: function () {
var ret = new Array();
ret[0] = this.OprationStatus;
ret[1] = this.storeList;
ret[2] = this.SelectedRecord;
ret[3] = this.EditRecord;
ret[4] = this.oplb;
return ret;
}
});