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_QuotationIndex.js

709 lines
24 KiB
JavaScript

2 years ago
//押箱管理
Ext.namespace('Shipping');
Shipping.MsPrice_QuotationIndex = function (config) {
Ext.applyIf(this, config);
this.initUIComponents();
window.Shipping.MsPrice_QuotationIndex.superclass.constructor.call(this);
};
Ext.extend(Shipping.MsPrice_QuotationIndex, Ext.Panel, {
PageSize: 50,
OprationStatus: null, //仅当弹出界面时使用
SelectedRecord: null,
sqlcontext: '',
ChangeListData: null,
initUIComponents: function () {
this.formname = "MsPrice_QuotationIndex";
this.sqlcontext = '';
parentWin = window.parent;
mainWin = getMainForm(parentWin);
/////////////////////////////////////////
//#region 主列表
this.storeList = Ext.create('Ext.data.Store', {
pageSize: this.PageSize,
model: 'MsPrice_QuotationIndexmb',
remoteSort: false,
proxy: {
type: 'ajax',
//url: '/TruckMng/MsRptPcHeadOperate/QryData_ADL',
url: '/MvcShipping/MsPrice/GetQuotationList',
//this.storeList.proxy.url = '/TruckMng/MsRptPcHeadOperate/QryData_ADL';
reader: {
id: 'BSNO',
root: 'data',
totalProperty: 'totalCount'
}
}
});
this.column = [
{
sortable: true,
dataIndex: 'BSNO',
header: '报价序列号',
width: 80
},
{
sortable: true,
dataIndex: 'CUSTOMERNAME',
header: '报价单位',
width: 80
},
{
sortable: true,
dataIndex: 'EFFECTIVEDATE',
header: '生效时间',
width: 80
},
{
sortable: true,
dataIndex: 'VALIDDATE',
header: '失效时间',
width: 80
},
{
sortable: true,
dataIndex: 'CREATOR',
header: '报价人',
width: 80
},
{
sortable: true,
dataIndex: 'CREATETIME',
header: '报价时间',
width: 80
},
{
sortable: true,
dataIndex: 'PDFURL',
header: 'PDF文件',
width: 80,
renderer: function (value, p, record) {
if (value == '') {
//return '<input type="button" value="上传" onClick="javascript:this.UpLoadFile('+record.data.BillNo+')"';
return '';
} else
return '<a href="' + value + '" style=' + '"text-decoration:none" target="_blank"' + ' > 下载 </a>';
}
},
{
sortable: true, hidden:true,
dataIndex: 'TIMEMARK',
header: 'TIMEMARK',
width: 80
},
{
sortable: true,
dataIndex: 'REMARK',
header: '备注',
width: 80
}
];
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,
viewConfig: {
enableTextSelection: true, //允许复制数据
autoFill: true,
getRowClass: function (record, rowIndex, rowParams, store) {
}
},
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/QuotationEdit', 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/GetCustomRefList' }
//});
//this.storeCustCode.loadData(window.parent.GetPubStore("INFOCLIENT_ALL").data.items);
mainWin = window.parent;
this.storeCustCode = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.CustomRefModel',
proxy: { url: '/CommMng/BasicDataRef/GetCustomRefListController' }
});
//this.storeCustCode.loadData(mainWin.GetPubStore("OPSEAE_CUST_ISCONTROLLER").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: 'CUSTOMERNAME',
valueField: 'CustName',
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
}
}
});
this.storeCodeLoadport = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.CodeLoadportModel',
proxy: { url: '/CommMng/BasicDataRef/GetCodeLoadportList' }
});
this.storeCodeLoadport.load();
this.storeCodePort = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.CodeDisportModel',
proxy: { url: '/CommMng/BasicDataRef/GetCodeDisportList' }
});
this.storeCodePort.load();
this.storeCARRIER = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.CustomRefModel',
proxy: { url: '/CommMng/BasicDataRef/GetCustomRefListCARRIER' }
});
this.storeCARRIER.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.comboxCustCode,
this.comboxCTNTYPE,
{
fieldLabel: '报价单序列号',
//labelWidth: 110,
name: 'BSNO',
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();
}
}
}
}]
}, {
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/QuotationEdit', "新建运价合约");
},
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",hidden:true,
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
});
//}
},
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/DeleteQuotation',
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 = '';
var CUSTOMERNAME = form.findField('CUSTOMERNAME').getValue();
sql = sql + getAndConSql(sql, CUSTOMERNAME, " CUSTOMERNAME like '%" + CUSTOMERNAME + "%' ");
var BSNO = form.findField('BSNO').getValue();
sql = sql + getAndConSql(sql, BSNO, " BSNO like '%" + BSNO + "%' ");
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'");
}
var CTNTYPE = form.findField('CTNTYPE').getValue();
sql = sql + getAndConSql(sql, CTNTYPE, " exists (select 1 from Op_SeaPrice_Quotation_Detail where bsno=Op_SeaPrice_Quotation.BSNO and isnull(" + CTNTYPE + "2,0)>0) ");
// ((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.storeCodePort;
ret[8] = this.storeCARRIER;
return ret;
},
onAddClick: function (button, event) {
this.OprationStatus = 'add';
DsOpenEditWin("/MvcShipping/MsPrice/QuotationEdit", "新建报价信息");
}, //onDeleteClick
onExportClick: function (button, event) {
GridExportExcelPage(this.gridList);
},
//#region 打印
Print: function () {
var selectedRecords = this.gridList.selModel.getSelection();
var YXNOList = "";
for (var i = 0; i < selectedRecords.length; i++) {
var rec = selectedRecords[i];
if (!isNullorEmpty(YXNOList)) YXNOList += "','";
YXNOList += rec.get("YXNO");
}
var printType = 'MSOP_YAXIANG';
var sql1 = "";
var sql2 = "";
var sql3 = "";
var sql4 = "";
var sql5 = "";
var sql6 = "";
Ext.Ajax.request({
waitMsg: '正在查询主表数据...',
url: '/MvcShipping/MsOp_YAXIANG/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) {
if (isNullorEmpty(str)) return '';
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, "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 //可以允许被拖动
});
});
}
});