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/MsPrice/MsPrice_ContractIndex.js

876 lines
30 KiB
JavaScript

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

//押箱管理
Ext.namespace('Shipping');
Shipping.MsPrice_ContractIndex = function (config) {
Ext.applyIf(this, config);
this.initUIComponents();
window.Shipping.MsPrice_ContractIndex.superclass.constructor.call(this);
};
Ext.extend(Shipping.MsPrice_ContractIndex, Ext.Panel, {
PageSize: 50,
OprationStatus: null, //仅当弹出界面时使用
SelectedRecord: null,
sqlcontext: '',
ChangeListData:null,
initUIComponents: function () {
this.formname = "MsPrice_ContractIndex";
this.sqlcontext = '';
parentWin = window.parent;
mainWin = getMainForm(parentWin);
/////////////////////////////////////////
//#region 主列表
this.storeList = Ext.create('Ext.data.Store', {
pageSize: this.PageSize,
model: 'MsPrice_ContractIndexmb',
remoteSort: false,
proxy: {
type: 'ajax',
//url: '/TruckMng/MsRptPcHeadOperate/QryData_ADL',
url: '/MvcShipping/MsPrice/GetContractList',
//this.storeList.proxy.url = '/TruckMng/MsRptPcHeadOperate/QryData_ADL';
reader: {
id: 'BSNO',
root: 'data',
totalProperty: 'totalCount'
}
}
});
this.column = [
{
sortable: true, align: 'right',
dataIndex: 'BSNO',
header: '合约序列号',
width: 80
},
{
sortable: true, align: 'right',
dataIndex: 'CONTRACTNO',
header: '合约编号',
width: 80
},
{
sortable: true, align: 'right',
dataIndex: 'CARRIER',
header: '船公司',
width: 80,
id:'CARRIER'
},
{
sortable: true, align: 'right',
dataIndex: 'EFFECTIVEDATE',
header: '生效时间',
width: 80
},
{
sortable: true, align: 'right',
dataIndex: 'VALIDDATE',
header: '失效时间',
width: 80
},
{
sortable: true, hidden:true,
dataIndex: 'CSTATUS',
header: 'CSTATUS',
width: 80
},
{
sortable: true, align: 'center',
dataIndex: 'CSTATUSREF',
header: '状态',
width: 80,
renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
if (value != "锁定") return "";
else return value;
}
},
{
sortable: true, align: 'center',
dataIndex: 'MadePrice',
header: '是否已生成运价',
width: 90,
renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
if (value == "0") return "";
else {
cellmeta.tdCls = 'feestatus_pass';
return "是";
}
}
},
{
sortable: true, align: 'right',
dataIndex: 'PORTLOADCOMMASTR',
header: '装货港',
width: 80,
renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
return '<div id="PORTLOAD' + record.data.BSNO + '" class="TipDiv">' + value + '</div>';
}
},
{
sortable: true, align: 'right',
dataIndex: 'PORTDISCHARGECOMMASTR',
header: '卸货港',
width: 80,
renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
return '<div id="PORTDISCHARGE' + record.data.BSNO + '" class="TipDiv">' + value + '</div>';
}
},
{
sortable: true, align: 'right',
dataIndex: 'VIACOMMASTR',
header: '中转港',
width: 80,
renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
return '<div id="VIA' + record.data.BSNO + '" class="TipDiv">' + value + '</div>';
}
},
{
sortable: true, align: 'right',
dataIndex: 'CREATOR',
header: '建立人',
width: 80
},
{
sortable: true, align: 'right',
dataIndex: 'CREATETIME',
header: '建立日期',
width: 80
},
{
sortable: true, align: 'left', hidden: true,
dataIndex: 'REMARK',
header: '备注',
width: 80
},
{
sortable: true,hidden:true,
dataIndex: 'TIMEMARK',
header: 'TIMEMARK',
width: 80
}
];
this.cellEditing = Ext.create('Ext.grid.plugin.CellEditing', {
clicksToEdit: 1
});
Ext.grid.RowNumberer = Ext.extend(Ext.grid.RowNumberer, {
width: 40
});
this.GridCheckBoxModel = Ext.create('Ext.selection.CheckboxModel');
this.Pagenum = Ext.create('Ext.form.field.Number', {
name: 'bottles',
fieldLabel: '每页记录数',
labelAlign: 'right',
value: this.PageSize,
maxValue: 100000,
width: 180,
minValue: 0,
listeners: {
specialkey: function (field, e) {
if (e.getKey() == e.ENTER) {
_this.onRefreshClick();
}
}
}
});
this.gridList = new Ext.grid.GridPanel({
store: this.storeList,
enableHdMenu: false,
region: 'center',
loadMask: { msg: "数据加载中,请稍等..." },
trackMouseOver: true,
disableSelection: false,
selModel: this.GridCheckBoxModel,
//selModel: this.MainCB,
columns: this.column,
plugins: [
//this.cellEditing
],
features: [{
ftype: 'summary'//Ext.grid.feature.Summary表格汇总特性
}],
/*features: [{
id: 'group',
ftype: 'grouping',
groupHeaderTpl: '{name}',
hideGroupedHeader: true,
enableGroupingMenu: true
}],*/
viewConfig: {
enableTextSelection: true, //允许复制数据
autoFill: true,
getRowClass: function (record, rowIndex, rowParams, store) {
var sVALIDDATE = record.get('VALIDDATE');
var rq = currdate.format('yyyy-MM-dd');
if (rq > sVALIDDATE) {
return Shipping.GetXGridRowClass(1);
}
}
},
bbar: [Ext.create('Ext.PagingToolbar', {
store: this.storeList,
displayInfo: true,
displayMsg: '当前显示 {0} - {1}条记录 /共 {2}条记录',
emptyMsg: "没有数据"
}), this.Pagenum]
});
/////////////以下部分为获取存储的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);
////////////////////////////
this.gridList.addListener('itemdblclick', function (dataview, record, item, index, e, b) {
// alert('0....' + dataview.toString() + ',' + record.toString() + ',' + item.toString() + ',' + index.toString() + ',' + e.toString() + ',' + b.toString());
this.SelectedRecord = record;
this.OprationStatus = 'edit';
DsOpenEditWin('/MvcShipping/MsPrice/ContractEdit', record.data.BSNO);
}, this);
//#endregion
//////////////////////////////////////////////////////////////
//#region formSearch
//#region formSearch枚举参照相关
parentWin = window.parent.opener;
this.storeCustCode = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.CustomRefModel',
proxy: { url: '/CommMng/BasicDataRef/GetCustomRefListCARRIER' }
});
//this.storeCustCode.loadData(window.parent.GetPubStore("INFOCLIENT_CARRIER").data.items);
this.storeCustCode.load();
this.comboxCustCode = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '船公司',
store: this.storeCustCode,
//queryMode: 'remote',
minChars: 1,
//queryParam: 'CODENAME',
matchFieldWidth: false,
name: 'CARRIER',
valueField: 'CustName',
displayField: 'CodeAndName',
queryMode: 'remote',
listeners: {
scope: this,
'beforequery': function (e) {
return FilterCombox(e);//在beforequery使用此方法
}
}
});
this.storeUser = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.UserRefModel',
proxy: { url: '/CommMng/BasicDataRef/GetUserRefList' }
});
this.storeUser.load({ params: { condition: "" } });
//所属部门
this.storeDept = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.DeptModel',
proxy: { url: '/CommMng/BasicDataRef/GetDeptList' }
});
this.storeDept.load();
this.comboxDept = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: Zi.LAN.SALEDEPT2, //'所属部门',
store: this.storeDept,
flex: 1,
labelWidth: 55,
forceSelection: true,
name: 'SALEDEPT',
valueField: 'DeptName',
displayField: 'DeptName',
listeners: {
scope: this,
'beforequery': function (e) {
return FilterCombox(e);//在beforequery使用此方法
}
}
});
//起运港
this.storeCodeLoadport = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.CodeLoadportModel',
proxy: { url: '/CommMng/BasicDataRef/GetCodeLoadportList' }
});
this.storeCodeLoadport.load();
this.comboxPORTLOAD = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '起运港',
store: this.storeCodeLoadport,
name: 'PORTLOAD',
valueField: 'PORT',
displayField: 'CodeAndName',
listeners: {
scope: this,
'beforequery': function (e) {
return FilterCombox(e);//在beforequery使用此方法
}
}
});
this.storePORTDISCHARGE = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.CodeDisportModel',
proxy: { url: '/CommMng/BasicDataRef/GetCodeDisportList' }
});
this.storePORTDISCHARGE.load();
this.comboxPORTDISCHARGEID = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '目的港',
hidden: true,
store: this.storePORTDISCHARGE,
name: 'PORTLOAD',
valueField: 'PORT',
displayField: 'CodeAndName',
listeners: {
scope: this,
'beforequery': function (e) {
return FilterCombox(e);//在beforequery使用此方法
}
}
});
this.storeCT = getPriceCtnTypeStore();
this.comboxCTNTYPE = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '箱型',
store: this.storeCT,
name: 'CTNTYPE',
valueField: 'ID',
displayField: 'NAME',
enableKeyEvents: true, //激活键盘事件
listeners: {
scope: this,
'keyup': {
fn: function (_field, e) {
if (e.getKey() == 13) {
this.onRefreshClick();
}
},
scope: this
}
}
});
//#endregion
//#region 用于子窗口的提前载入的store
this.storeFeeNameRef = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.FeeTypeRefModel',
proxy: { url: '/MvcShipping/MsChFee/GetFeeTypeRefListNew' }
});
this.storeFeeNameRef.load();
//#endregion
_this = this;
this.formSearch = Ext.widget('form', {
frame: true,
region: 'center',
bodyPadding: 5,
fieldDefaults: {
margins: '1 1 1 1',
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.comboxPORTDISCHARGEID,
this.comboxCustCode,
this.comboxCTNTYPE,
{
fieldLabel: '合约号/序列号',
//labelWidth: 110,
name: 'CONTRACTNO',
listeners: {
specialkey: function (field, e) {
if (e.getKey() == e.ENTER) {
_this.onRefreshClick();
}
}
}
},
{
fieldLabel: '从..有效期',
format: 'Y-m-d',
xtype: 'datefield',
name: 'ETD_BGN',
listeners: {
specialkey: function (field, e) {
if (e.getKey() == e.ENTER) {
_this.onRefreshClick();
}
}
}
}, {
fieldLabel: '到..有效期',
format: 'Y-m-d',
xtype: 'datefield',
name: 'ETD_END',
listeners: {
specialkey: function (field, e) {
if (e.getKey() == e.ENTER) {
_this.onRefreshClick();
}
}
}
},this.comboxCompany]
}, {
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
this.panelBtn = new Ext.Panel({
region: "north",
tbar: [
{
text: "执行查询",
iconCls: "btnrefresh",
handler: function (button, event) {
this.onRefreshClick(button, event);
saveQuerySetting(this.formname, this.formSearch, true, true);
},
scope: this
}, '-', {
text: "新建", id: "btnadd",
iconCls: "btnadd",
handler: function (button, event) {
this.OprationStatus = 'add';
DsOpenEditWin('/MvcShipping/MsPrice/ContractEdit', "新建运价合约");
},
scope: this
}, {
text: "删除", id: "btndelete",
iconCls: "btndelete",
handler: function (button, event) {
this.onDeleteClick(button, event);
},
scope: this
}, '-', {
text: "导出Excel",
id: "btnExportExcel",
iconCls: 'btnexportexcel',
handler: function (button, event) {
this.onExportClick(button, event);
},
scope: this
}, {
text: "打印", id: "print",
tooltip: 'print',
handler: function (button, event) {
//this.PushState("30011");
this.Print();
},
scope: this
}, /*{
id: "btnFeeAuditReject",
text: '驳回提交费用业务',
tooltip: '驳回提交费用业务',
iconCls: "btnrefuse",
handler: function (button, event) {
this.onAuditRefuseClick(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
}
//,this.CB_EditMode
]
});
//#region 布局
this.panelTop = new Ext.Panel({
layout: "border",
region: "north",
height: 75,
items: [this.formSearch, this.panelBtn]
});
this.panelMain = new Ext.Panel({
//title: '',
layout: "border",
region: 'center',
height: 600,
margin: '1 2',
split: true,
items: [this.gridList]
});
Ext.apply(this, {
items: [this.panelTop, this.panelMain]
});
//#endregion
//#region 以下集中绑定事件
this.storeList.on('beforeload', function (store) {
Ext.apply(store.proxy.extraParams, { condition: this.sqlcontext });
}, this);
//#endregion
this.LoadInitData();
}, //end initUIComponents
LoadInitData: function () {
if (this.sqlcontext == '') {
this.sqlcontext = "VALIDDATE>='" + currdate.format('yyyy-MM') + "-01'";
}
this.storeList.load({
params: { start: 0, limit: this.PageSize, condition: this.sqlcontext },
waitMsg: "正在查询数据...",
callback: function (options, success, response) {
_this.DoSetGridTip();
},
scope: this
});
},
onRefreshClick: function (button, event) {
this.PageSize = this.Pagenum.getValue();
_this = this;
var sql = this.getCondition();
this.sqlcontext = sql;
this.storeList.load({
params: { start: 0, limit: this.PageSize, condition: sql },
waitMsg: "正在查询数据...",
callback: function (options, success, response) {
_this.DoSetGridTip();
},
scope: this
});
//}
},
onDsQuery: function (button, event) {
var sql = this.sqlcontext;
this.storeList.load({
params: { start: 0, limit: this.PageSize, condition: sql },
waitMsg: "正在查询数据...",
callback: function (options, success, response) {
_this.DoSetGridTip();
},
scope: this
});
//}
},
onRefreshClick_Add: function (button, event) {
if (!this.checkSearchCondition())
return;
var sql = this.getCondition_Add();
this.storeList.load({
params: { start: 0, limit: this.PageSize, condition: sql },
waitMsg: "正在查询数据...",
callback: function (options, success, response) {
_this.DoSetGridTip();
},
scope: this
});
//}
},
onDeleteClick: 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 record = selections[0];
var delmessage = '确定删除该记录吗?';
if (record.data.MadePrice == "1") {
delmessage = '已经通过该合约生成过运价,' + delmessage;
}
Ext.MessageBox.confirm('提示', delmessage, function (btn) {
if (btn == 'yes') {
Ext.Msg.wait('正在删除数据...');
Ext.Ajax.request({
waitMsg: '正在删除数据...',
url: '/MvcShipping/MsPrice/DeleteContract',
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);
}, //onDeleteClick
getCondition: function () {
var form = this.formSearch.getForm();
var sql = '';
//20170309 增加逻辑
//
//只能看到“”
//var MBLNO = form.findField('MBLNO').getValue();
//sql = sql + getAndConSql(sql, MBLNO, " ( exists (select 1 from MsOp_YAXIANG_detail where yxno=MsOp_YAXIANG.YXNO and bsno in(select bsno from v_op_bill where mblno like '%" + MBLNO + "%')) ) ");
//var CUSTOMERNAME = form.findField('CUSTOMERNAME').getValue();
//sql = sql + getAndConSql(sql, CUSTOMERNAME, " CUSTOMERNAME like '%" + CUSTOMERNAME + "%' ");
//var CUSTNO = form.findField('CUSTNO').getValue();
//sql = sql + getAndConSql(sql, CUSTNO, " CUSTNO like '%" + CUSTNO + "%' ");
var CARRIER = form.findField('CARRIER').getValue();
sql = sql + getAndConSql(sql, CARRIER, " CARRIER='" + CARRIER + "'");
var CTNTYPE = form.findField('CTNTYPE').getValue();
sql = sql + getAndConSql(sql, CTNTYPE, " exists (select 1 from Op_SeaPrice_Contract_Detail where bsno=Op_SeaPrice_Contract.BSNO and isnull(" + CTNTYPE+",0)>0) ");
var CONTRACTNO = form.findField('CONTRACTNO').getValue();
sql = sql + getAndConSql(sql, CONTRACTNO, " (CONTRACTNO like '%" + CONTRACTNO + "%' or BSNO like '%" + CONTRACTNO + "%')");
var ETD_BGN = form.findField('ETD_BGN').getRawValue();
var ETD_END = form.findField('ETD_END').getRawValue();
if (!isNullorEmpty(ETD_BGN) && !isNullorEmpty(ETD_END)) {
dataA = "'" + ETD_BGN + "'";
dataB = "'" + ETD_END + "'";
sql = sql + getAndConSql(sql, ETD_BGN, "((" + dataA + " >=EFFECTIVEDATE and " + dataA + " <=VALIDDATE)or(" + dataB + " >=EFFECTIVEDATE and " + dataB + " <=VALIDDATE)or(" + dataA + " <=EFFECTIVEDATE and " + dataB + " >=VALIDDATE))");
} else {
sql = sql + getAndConSql(sql, ETD_BGN, " VALIDDATE>='" + ETD_BGN + "'");
sql = sql + getAndConSql(sql, ETD_END, " EFFECTIVEDATE<='" + ETD_END + " 23:59:59'");
}
// ((endTime < begin) OR (startTime > end))
return sql;
},
OprationSwap: function () {
var ret = new Array();
ret[0] = this.OprationStatus;
ret[1] = this.storeList;
ret[2] = this.SelectedRecord;
ret[3] = this.storeFeeNameRef;
ret[4] = this.onRefreshClick;
ret[5] = this.storeCustCode;
ret[6] = this.storeCodeLoadport;
ret[7] = this.storePORTDISCHARGE;
return ret;
},
onAddClick: function (button, event) {
this.OprationStatus = 'add';
DsOpenEditWin("/MvcShipping/MsPrice/ContractEdit", "新建合约信息");
}, //onDeleteClick
//#region 导出Excel
onExportClick: function (button, event) {
GridExportExcelPage(this.gridList);
},
//#endregion
//#region 打印
Print: function () {
var selectedRecords = this.gridList.selModel.getSelection();
var BSNOList = "";
for (var i = 0; i < selectedRecords.length; i++) {
var rec = selectedRecords[i];
if (!isNullorEmpty(BSNOList)) BSNOList += "','";
BSNOList += rec.get("BSNO");
}
var printType = 'MsPrice_Contract';
var sql1 = "";
var sql2 = "";
var sql3 = "";
var sql4 = "";
var sql5 = "";
var sql6 = "";
Ext.Ajax.request({
waitMsg: '正在查询主表数据...',
url: '/MvcShipping/MsPrice/GetPrintSql',
params: {
printname: "Print1",
YXNOList: "'" + YXNOList + "'"
},
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;
}
//this.Editdata = result.data;
//this.LoadInit(data);
sql1 = result.Data.sql1;
sql2 = result.Data.sql2;
PrintComm(printType, sql1, sql2, sql3, sql4, sql5, sql6);
} else {
Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
}
},
scope: this
});
}
//#endregion
,
truntohtml: function (str) {
var arr = str.split(';');
var result = "";
if (arr.length > 0)
for (_i = 0; _i < arr.length;_i++)
{
if (!isNullorEmpty(arr[_i]))
result += arr[_i] + '<br />';
}
return result;
}
,
DoSetGridTip: function () {
this.SetGridTip(this.storeList, "PORTLOAD", "PORTLOADCOMMASTR");
this.SetGridTip(this.storeList, "PORTDISCHARGE", "PORTDISCHARGECOMMASTR");
this.SetGridTip(this.storeList, "VIA", "VIACOMMASTR");
//this.SetGridTip(this.storeList, "CTN0", "CTN0PRICESTR");
//this.SetGridTip(this.storeList, "CTN1", "CTN1PRICESTR");
//this.SetGridTip(this.storeList, "CTN2", "CTN2PRICESTR");
//this.SetGridTip(this.storeList, "CTN3", "CTN3PRICESTR");
//this.SetGridTip(this.storeList, "CTN4", "CTN4PRICESTR");
}
,
SetGridTip: function (store, idname, columnname) {
store.each(function (record) {
_id = idname + record.get('BSNO');
_html = _this.truntohtml(record.get(columnname));
Ext.create('Ext.tip.ToolTip', {
target: _id,
html: _html,
title: '',
//autoHide: false,
dismissDelay: 4000
//closable: true,
//draggable: true //可以允许被拖动
});
});
}
});