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/MsOpCtnFeeReportIn/MsOpCtnFeeReportEdit.js

746 lines
24 KiB
JavaScript

3 years ago
Ext.namespace('Shipping');
Shipping.MsOpCtnFeeModelEdit = function (config) {
Ext.applyIf(this, config);
this.initUIComponents();
window.Shipping.MsOpCtnFeeModelEdit.superclass.constructor.call(this);
};
var MBLNO = '';
var XIANGHAO = '';
var GID = '';
var FeeNo = '';
Ext.extend(Shipping.MsOpCtnFeeModelEdit, Ext.Panel, {
ParentWin: null,
OpStatus: 'add',
StoreList: null,
EditRecord: null,
CTN: '',
initUIComponents: function () {
this.serialNo = 0;
this.workSerialNo = 0;
this.detailsDel = [];
//#region 编辑form
//枚举参照相关(编辑form)
//表参照相关(编辑form)
Ext.regModel('IsCustOnly', {
fields: [{ name: 'value' }, { name: 'text'}]
})
var IsCustOnlyStore = new Ext.data.Store({
model: 'IsCustOnly',
data: [{ 'value': '0', 'text': '否' },
{ 'value': '1', 'text': '是'}]
});
var cbIsCustOnly = Ext.create('Ext.form.ComboBox', {
name: 'IsCustOnly',
queryMode: 'local',
id: 'IsCustOnly',
triggerAction: 'all',
forceSelection: true,
allowBlank: false,
flex: 1,
valueField: 'value',
displayField: 'text',
store: IsCustOnlyStore,
fieldLabel: '是否客户专有',
hidden: true,
listeners: {
afterRender: function (combo) {
combo.setValue('1'); //同时下拉框会将与name为firstValue值对应的 text显示
}
}
});
cbIsCustOnly.on('load', function () { Ext.getCmp("IsCustOnly").setValue('1'); });
this.storeCodeDisport = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.CodeDisportModel',
proxy: { url: '/CommMng/BasicDataRef/GetCodeDisportListRm' }
});
this.comboxPORTDISCHARGE = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '港口', //'卸货港',
store: this.storeCodeDisport,
id: 'comboxPORTDISCHARGE',
name: 'PortAndYardName',
//forceSelection: true,
valueField: 'CodeAndName',
queryMode: 'remote',
minChars: 1,
queryParam: 'PORT',
displayField: 'CodeAndName'
});
//客户加载_对账客户
this.storePayCust = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.CustomRefModel',
proxy: { url: '/CommMng/BasicDataRef/GetCustomRefList' }
});
this.storePayCust.load();
//
this.comboxPayCust = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '对账客户', //'场站',
store: this.storePayCust,
queryMode: 'remote',
minChars: 0,
queryParam: 'CODENAME',
name: 'PayCust',
valueField: 'CodeAndName',
displayField: 'CodeAndName'
});
var _this = this;
//编辑form
this.formEdit = Ext.widget('form', {
region: 'north',
frame: true,
bodyPadding: 5,
autoScroll: true,
fieldDefaults: {
margins: '2 2 2 2',
labelAlign: 'right',
flex: 1,
labelWidth: 90,
msgTarget: 'qtip'
},
items: [
{//fieldset 1
xtype: 'fieldset',
defaultType: 'textfield',
layout: 'anchor',
defaults: {
anchor: '100%'
},
items: [{
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: 'GID',
name: 'GID', flex: 0, hidden: true, margins: '0'
}, {
fieldLabel: '对账编号',
readOnly: true,
name: 'FeeNo'
}, this.comboxPayCust,
{
fieldLabel: '对账日期(从)',
readOnly: true,
name: 'DuiZhangRiQiFrom'
}, {
fieldLabel: '对账日期(到)',
readOnly: true,
name: 'DuiZhangRiQiTo'
}
]
}
]//end items(fieldset 1)
}//end fieldset 1
]//end root items
}); //end this.formEdit
//#endregion
//检索form
this.formSearch = Ext.widget('form', {
region: 'north',
frame: true,
bodyPadding: 5,
autoScroll: true,
fieldDefaults: {
margins: '2 2 2 2',
labelAlign: 'right',
flex: 1,
labelWidth: 90,
msgTarget: 'qtip'
},
items: [
{//fieldset 1
xtype: 'fieldset',
defaultType: 'textfield',
layout: 'anchor',
defaults: {
anchor: '100%'
},
items: [{
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '对账日期(从)',
format: 'Y-m-d',
xtype: 'datefield',
flex: 1,
name: 'DuiZhangRiQiFrom'
}, {
fieldLabel: '对账日期(到)',
format: 'Y-m-d',
xtype: 'datefield',
flex: 1,
name: 'DuiZhangRiQiTo'
}, {
xtype: 'button',
text: "查询",
flex: 0.2,
id: "btnSearch",
name: "btnSearch",
handler: function () {
_this.onSearchClick();
}
}, {
xtype: 'label',
name: 'holdp1',
flex: 1
}, {
xtype: 'label',
name: 'holdp1',
flex: 1
}
]
}
]//end items(fieldset 1)
}//end fieldset 1
]//end root items
}); //end this.formEdit
//#region 按钮Toolbar
this.panelBtn = new Ext.Panel({
region: "north",
tbar: [
{
text: "保存",
iconCls: "btnsave",
handler: function (button, event) {
this.Save('0');
},
scope: this
},
{
text: "保存并关闭",
handler: function (button, event) {
this.Save('1');
},
scope: this
},
'-',
{
text: "保存并新建",
handler: function (button, event) {
this.Save('2');
},
scope: this
},
'-',
{
text: "对账",
handler: function (button, event) {
this.DuiZhang();
},
scope: this
}
]
}); //end 按钮Toolbar
//#endregion
//#region 明细表
//明细表表格相关
//明细表-数据集
this.storeCtnList = Ext.create('Ext.data.Store', {
model: 'MsOpCtnFeeSearch',
remoteSort: true,
proxy: {
type: 'ajax',
url: '/MvcShipping/MsOpCtnFeeSearch/GetCtnDataList',
reader: {
root: 'data',
totalProperty: 'totalCount'
}
}
});
this.CheckBoxModel = Ext.create('Ext.selection.CheckboxModel');
this.gridList = new Ext.grid.GridPanel({
store: this.storeCtnList,
enableHdMenu: false,
region: 'center',
loadMask: { msg: "数据加载中,请稍等..." },
trackMouseOver: true,
selModel: this.CheckBoxModel,
selType: 'cellmodel',
disableSelection: false,
columns: [{
sortable: false,
dataIndex: 'MBLNO',
header: '提单号',
width: 140
}, {
sortable: false,
dataIndex: 'XiangHao',
header: '箱号',
width: 140
}, {
sortable: false,
dataIndex: 'DuiZhangKeHu',
header: '对账客户',
width: 140
},
{
sortable: false,
dataIndex: 'Amount',
header: '总费用',
width: 140
}
]
});
this.gridList.addListener('cellclick', function (dataview, record, item, data, e, b) {
MBLNO = data.data.MBLNO;
XIANGHAO = data.data.XiangHao;
this.storeDetailsList.load({ params: { mblno: MBLNO, xianghao: XIANGHAO} });
}, this);
this.storeFangXiang = Ext.create('Ext.data.Store', {
fields: ['ID', 'TYPE']
});
this.storeFangXiang.add({ "ID": "1", "TYPE": "收" });
this.storeFangXiang.add({ "ID": "2", "TYPE": "付" });
this.comboxFangXiang = Ext.create('DsExt.ux.RefTableCombox', {
store: this.storeFangXiang,
valueField: 'ID',
displayField: 'TYPE',
forceSelection: true,
name: 'SortType'
});
this.storeDetailsList = Ext.create('Ext.data.Store', {
model: 'MsOpCtnFeeSearchDetails',
remoteSort: false,
pruneModifiedRecords: true,
proxy: {
type: 'ajax',
url: '/MvcShipping/MsOpCtnFeeSearch/GetDetailsWithMBLNOAndXiangHao',
reader: {
id: 'gid',
root: 'data',
totalProperty: 'totalCount'
}
}
});
//明细表表格
this.gridDetailsList = new Ext.grid.GridPanel({
store: this.storeDetailsList,
enableHdMenu: false,
region: 'north',
loadMask: { msg: "数据加载中,请稍等..." },
trackMouseOver: true,
disableSelection: false,
selType: 'cellmodel',
columns: [{
sortable: true,
dataIndex: 'ZhuangTai',
header: '状态',
width: 100
}, {
sortable: true,
dataIndex: 'DiDian',
header: '地点',
width: 160
}, {
sortable: true,
dataIndex: 'Time',
header: '时间',
width: 100
}, {
sortable: true,
dataIndex: 'FeiYong',
header: '费用',
width: 60
}, {
sortable: true,
dataIndex: 'YongXiangTianShu',
header: '用箱天数',
width: 60
}, {
sortable: true,
dataIndex: 'DuiZhangRiQi',
header: '对账日期',
width: 120
}
]
});
this.panelService = new Ext.Panel({
title: '提单号-箱号',
layout: "border",
region: 'center',
height: 190,
frame: true,
split: true,
items: [this.gridList]
});
this.panelwork = new Ext.Panel({
title: '费用明细',
layout: "border",
region: 'south',
height: 300,
items: [this.gridDetailsList]
});
this.paneldetail = new Ext.Panel({
layout: "border",
region: "center",
items: [
this.panelService, this.panelwork
]
});
//#endregion 明细表
//#region 费用信息
this.panelFee = new Shipping.FeeEditGrid({
region: 'center',
layout: 'border'
});
this.panelFee.panelDrChFee.anchor = '100% 40%';
this.panelFee.panelCrChFee.anchor = '100% 60%';
this.panelFee.stroplb = 'op_other';
this.panelFee.StoreCustType.add({ "SCUSTTYPE": "WTDW-委托单位", "CUSTTYPE": "委托单位", "CUSTNAME": "CUSTOMERNAME" });
this.panelFee.StoreCustType.add({ "SCUSTTYPE": "CD-车队", "CUSTTYPE": "车队", "CUSTNAME": "TRUCKNAME" });
this.panelFee.StoreCustType.add({ "SCUSTTYPE": "MDGDL-目的港代理", "CUSTTYPE": "目的港代理", "CUSTNAME": "AGENTNAME" });
this.panelFee.StoreCustType.add({ "SCUSTTYPE": "DCGS-订舱公司", "CUSTTYPE": "订舱公司", "CUSTNAME": "AGENTNAME" });
this.panelFee.StoreDrOpRange.load({ params: { optype: "modOtherRecvFeeManagement"} });
this.panelFee.StoreCrOpRange.load({ params: { optype: "modOtherPayFeeManagement"} });
this.panelFee.storeFeeNameRef.load({ params: { condition: ""} });
this.panelDrCrFee = new Ext.Panel({
layout: "border",
region: 'center',
animate: true,
// autoScroll: true,
// containerScroll: true,
frame: false,
items: [this.panelFee]
});
//#endregion
//#region 布局
//控件布局
parentWin = window.parent.opener;
if (parentWin) {
var ret = parentWin.OprationSwap();
this.OpStatus = ret[0]; //edit
this.StoreList = ret[1];
this.EditRecord = ret[2]; //SelectedRecord
this.parentRecord = ret[3];
this.OPLBNAME = ret[4];
}
if (this.OpStatus == "add") {
this.panelTop = new Ext.Panel({
layout: "border",
region: "north",
height: 177,
items: [this.panelBtn, this.formEdit, this.formSearch]
});
} else {
this.panelTop = new Ext.Panel({
region: "north",
height: 100,
items: [this.panelBtn, this.formEdit]
});
}
this.page_1 = new Ext.Panel({
id: "page_1",
title: "查询明细",
autoScroll: true,
layout: "border",
region: 'center',
closable: true,
items: [this.paneldetail]
});
this.page_2 = new Ext.Panel({
id: "page_2",
title: "费用信息",
autoScroll: true,
layout: "border",
region: 'center',
closable: true,
items: [this.panelDrCrFee]
});
this.MainTab = new Ext.tab.Panel({
layout: "border",
height: 500,
region: "north", split: true,
items: [
this.page_1
, this.page_2
]
});
Ext.apply(this, {
items: [this.panelTop, this.MainTab]
});
//#endregion
//绑定查询窗体
this.ParentWin = window.parent.opener;
//初始化数据
this.InitData();
if (this.opStatus == 'edit') {
} else {
}
//绑定事件
this.gridList.on('edit', function (editor, e, eOpts) {
this.gridAfterEdit(editor, e, eOpts);
}, this);
}, //end initUIComponents
InitData: function () {
this.opStatus = 'add';
var condition = '';
if (this.ParentWin) {
var ret = this.ParentWin.OprationSwap();
this.opStatus = ret[0];
this.StoreList = ret[1];
this.editRecord = ret[2];
}
if (this.opStatus == 'edit') {
FeeNo = this.editRecord.get('FeeNo');
// condition = "blno in (select MBLNO from Op_Ctn_FeeDetails where FeeNo = '" + FeeNo + "') AND box_no IN (select xianghao from Op_Ctn_FeeDetails where FeeNo = '" + FeeNo + "') ";
GID = this.editRecord.get('GID');
condition = "GID = '" + GID + "'";
}
this.LoadData(this.opStatus, condition);
}, //end InitData
LoadData: function (opstatus, condition) {
this.serialNo = 0;
this.workSerialNo = 0;
this.bodyDel = [];
this.opStatus = opstatus;
Ext.Ajax.request({
waitMsg: '正在查询主表数据...',
url: '/MvcShipping/MsOpCtnFeeSearch/GetData',
params: {
handle: opstatus,
condition: condition
},
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 data = result.data;
GID = data.GID;
if (this.opStatus == 'edit') {
this.formEdit.getForm().reset();
this.formEdit.getForm().setValues(data);
Ext.getCmp("comboxPORTDISCHARGE").setValue(data.PortAndYardName);
}
} else {
Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
}
},
scope: this
});
var billno = '*';
var modelid = 0;
if (this.opStatus == 'edit') {
modelid = this.editRecord.get('GID');
}
var condition = " and blno in (select MBLNO from Op_Ctn_FeeDetails where FGID = '" + GID + "') AND box_no IN (select xianghao from Op_Ctn_FeeDetails where FGID = '" + GID + "') ";
this.storeCtnList.load({ params: { condition: condition} });
// this.storeDetailsList.load({ params: { condition: " GID='" + modelid + "'"} });
}, // end LoadDate
onSearchClick: function () {
if (this.opStatus == 'add') {
var form = this.formSearch.getForm();
var DuiZhangRiQiFrom = form.findField('DuiZhangRiQiFrom').rawValue;
var DuiZhangRiQiTo = form.findField('DuiZhangRiQiTo').rawValue;
var sqltime = " and (duizhangriqi IS NULL";
if (DuiZhangRiQiFrom != "") {
sqltime += ' and (jcyy=\'空箱出场\' and cctime >= \'' + DuiZhangRiQiFrom + '\')';
}
if (DuiZhangRiQiTo != "") {
sqltime += ' and (jcyy=\'空箱出场\' and cctime <= \'' + DuiZhangRiQiTo + '\')';
}
sqltime += ")";
this.storeCtnList.load({ params: { condition: sqltime
+ "OR (jcyy='空箱还场' AND duizhangriqi IS NULL)"
}
});
} else {
}
},
Save: function (type) {
var basicForm = this.formEdit.getForm();
if (!basicForm.isValid()) {
return;
}
var data = basicForm.getValues();
data.Oper = SHOWNAME;
if (this.opStatus == 'add') {
data.GID = "*";
}
var detailsArr = [];
var selArr = this.gridList.getSelectionModel().getSelection();
for (var i = 0; i < selArr.length; i++) {
var member = selArr[i];
detailsArr.push(member);
}
var details = ConvertRecordsToJsonAll(detailsArr);
var serachData = this.formSearch.getForm().getValues();
var duizhangriqi = serachData.DuiZhangRiQiTo;
Ext.Msg.wait('正在保存数据, 请稍侯..');
Ext.Ajax.request({
waitMsg: '正在保存数据...',
url: '/MvcShipping/MsOpCtnFeeSearch/Save',
scope: this,
params: {
opstatus: this.opStatus,
data: Ext.JSON.encode(data),
details: details,
duizhangriqi: duizhangriqi
},
callback: function (options, success, response) {
if (success) {
Ext.MessageBox.hide();
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
this.opStatus == 'edit'
var returnData = jsonresult.Data;
MBLNO = returnData.MBLNO;
XIANGHAO = returnData.XiangHao;
this.formEdit.getForm().setValues(returnData);
if (type == '0') {
this.opStatus = 'edit';
this.LoadData('edit', " GID='" + GID + "'");
var condition = "";
if (this.opStatus == 'edit') {
this.storeDetailsList.load({ params: { mblno: MBLNO, xianghao: XIANGHAO} });
}
} else if (type == '1') {
window.close();
} else {
this.LoadData('add', '');
}
Ext.Msg.show({ title: '提示', msg: jsonresult.Message, icon: Ext.Msg.OK, buttons: Ext.Msg.OK });
} 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
});
}
}
});
},
DuiZhang: function () {
var basicForm = this.formEdit.getForm();
if (!basicForm.isValid()) {
return;
}
var data = basicForm.getValues();
data.Oper = SHOWNAME;
if (this.opStatus == 'add') {
data.GID = "*";
}
var detailsArr = [];
var selArr = this.gridList.getSelectionModel().getSelection();
for (var i = 0; i < selArr.length; i++) {
var member = selArr[i];
detailsArr.push(member);
}
var details = ConvertRecordsToJsonAll(detailsArr);
var serachData = this.formSearch.getForm().getValues();
var duizhangriqi = serachData.DuiZhangRiQiTo;
Ext.Msg.wait('正在保存数据, 请稍侯..');
Ext.Ajax.request({
waitMsg: '正在保存数据...',
url: '/MvcShipping/MsOpCtnFeeSearch/GetDuiZhangFee',
scope: this,
params: {
details: details
},
callback: function (options, success, response) {
if (success) {
Ext.MessageBox.hide();
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
Ext.Msg.show({ title: '提示', msg: jsonresult.data, icon: Ext.Msg.OK, buttons: Ext.Msg.OK });
} 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
});
}
}
});
}
});