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.

650 lines
22 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.MsRptOpCtnTkFitingsCtnKcSumIndex = function (config) {
Ext.applyIf(this, config);
this.initUIComponents();
window.Shipping.MsRptOpCtnTkFitingsCtnKcSumIndex.superclass.constructor.call(this);
};
Ext.extend(Shipping.MsRptOpCtnTkFitingsCtnKcSumIndex, Ext.Panel, {
OprationStatus: null, //仅当弹出界面时使用
SelectedRecord: null,
sqlcontext: '',
PageSize: 100,
sortfield: '',
sortdire: '',
strLINKGID: '',
initUIComponents: function () {
this.formname = "MsRptOpCtnTkFitingsCtnKcSumIndex" ; //页面名称
this.initsumgirdcolums = [{
sortable: true,
dataIndex: 'FITINGCODE',
header: '配件代码',
width: 110
}, {
sortable: true,
dataIndex: 'FITINGNAME',
header: '配件名称',
width: 110
}, {
sortable: true,
dataIndex: 'MODEL',
header: '规格型号',
width: 110
}, {
sortable: true,
dataIndex: 'PKGS',
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: 100
}
];
this.girdsumcolums = this.initsumgirdcolums;
_thisCtnKcSumIndex = this;
//定义数据集
this.storeSumList = Ext.create('Ext.data.Store', {
pageSize: this.PageSize,
model: 'MsOpCtnTkFitingsDetail',
remoteSort: true,
proxy: {
type: 'ajax',
url: '/MvcContainer/MsOpCtnTkFitings/GetFitingsCtnKcSumList',
reader: {
root: 'data',
totalProperty: 'totalCount'
}
}
});
Ext.grid.RowNumberer = Ext.extend(Ext.grid.RowNumberer, {
width: 30
});
this.SumGridCheckBoxModel = Ext.create('Ext.selection.CheckboxModel');
_thisCtnKcSumIndex = this;
//定义Grid
this.gridSumList = new Ext.grid.GridPanel({
store: this.storeSumList,
enableHdMenu: false,
region: 'north',
height:300,
loadMask: { msg: "数据加载中,请稍等..." },
trackMouseOver: true,
disableSelection: false,
selModel: this.SumGridCheckBoxModel,
columns: this.girdsumcolums
,
// paging bar on the bottom
bbar: Ext.create('Ext.PagingToolbar', {
store: this.storeSumList,
displayInfo: true,
displayMsg: '当前显示 {0} - {1}条记录 /共 {2}条记录',
emptyMsg: "没有数据"
})
});
this.girdsumcolums = DsTruck.GetGridPanel(USERID, this.formname+'sum', this.girdsumcolums, 1); //使用者id表名中间column数组跳过一开始的几列
// this.InitGrid(this.girdcolums, '');
this.gridSumList.addListener('itemdblclick', function (dataview, record, item, index, e, b) {
//this.SelectedRecord = record;
//this.OprationStatus = 'edit';
//var openSet = "height=500, width=1024, toolbar=no, menubar=no,scrollbars=1, resizable=1,location=no, status=no,Top= " + (screen.height - 500) / 2 + ",Left= " + (screen.width - 600) / 2
//var openType = record.data.GID;
//var openUrl = "/MvcContainer/MsOpPrice/YardEdit";
//window.open(openUrl, openType, openSet);
}, this);
this.gridSumList.addListener('sortchange', function (ct, column, direction, eOpts) {
this.sortfield = column.dataIndex;
this.sortdire = direction;
}, this);
//this.gridSumList.columns[1] = new Ext.grid.RowNumberer();
this.gridSumList.getSelectionModel().on('select', function (model, record, index) {
var FITINGGID = record.data.FITINGGID;
_thisCtnKcSumIndex.sqlcontext = "F.FITINGGID='" + FITINGGID + "'";
var sql = _thisCtnKcSumIndex.sqlcontext;
_thisCtnKcSumIndex.storeList.load({
params: { start: 0, limit: this.PageSize, sort: '', condition: sql },
waitMsg: "正在查询数据...",
scope: this
});
}, this);
this.initgirdcolums = [{
sortable: true,
dataIndex: 'FITINGCODE',
header: '配件代码',
width: 110
}, {
sortable: true,
dataIndex: 'FITINGNAME',
header: '配件名称',
width: 110
}, {
sortable: true,
dataIndex: 'MODEL',
header: '规格型号',
width: 110
}, {
sortable: true,
dataIndex: 'CTNNO',
header: '罐号',
width: 110
}, {
sortable: true,
dataIndex: 'PKGS',
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: 100
}
];
this.girdcolums = this.initgirdcolums;
_thisCtnKcSumIndex = this;
//定义数据集
this.storeList = Ext.create('Ext.data.Store', {
pageSize: this.PageSize,
model: 'MsOpCtnTkFitingsDetail',
remoteSort: true,
proxy: {
type: 'ajax',
url: '/MvcContainer/MsOpCtnTkFitings/GetFitingsCtnKcList',
reader: {
root: 'data',
totalProperty: 'totalCount'
}
}
});
Ext.grid.RowNumberer = Ext.extend(Ext.grid.RowNumberer, {
width: 30
});
this.GridCheckBoxModel = Ext.create('Ext.selection.CheckboxModel');
_thisCtnKcSumIndex = this;
//定义Grid
this.gridList = new Ext.grid.GridPanel({
store: this.storeList,
enableHdMenu: false,
region: 'center',
loadMask: { msg: "数据加载中,请稍等..." },
trackMouseOver: true,
disableSelection: false,
selModel: this.GridCheckBoxModel,
columns: this.girdcolums
,
// paging bar on the bottom
bbar: Ext.create('Ext.PagingToolbar', {
store: this.storeList,
displayInfo: true,
displayMsg: '当前显示 {0} - {1}条记录 /共 {2}条记录',
emptyMsg: "没有数据"
})
});
this.girdcolums = DsTruck.GetGridPanel(USERID, this.formname, this.girdcolums, 1); //使用者id表名中间column数组跳过一开始的几列
// this.InitGrid(this.girdcolums, '');
this.gridList.addListener('itemdblclick', function (dataview, record, item, index, e, b) {
//this.SelectedRecord = record;
//this.OprationStatus = 'edit';
//var openSet = "height=500, width=1024, toolbar=no, menubar=no,scrollbars=1, resizable=1,location=no, status=no,Top= " + (screen.height - 500) / 2 + ",Left= " + (screen.width - 600) / 2
//var openType = record.data.GID;
//var openUrl = "/MvcContainer/MsOpPrice/YardEdit";
//window.open(openUrl, openType, openSet);
}, this);
this.gridList.addListener('sortchange', function (ct, column, direction, eOpts) {
this.sortfield = column.dataIndex;
this.sortdire = direction;
}, this);
this.gridList.columns[1] = new Ext.grid.RowNumberer();
//#region formSearch 查询面板
this.storeCodeCtnTkFitings = Ext.create('DsExt.ux.RefTableStore', {
model: 'MsCodeCtnTkFitings',
proxy: { url: '/MvcContainer/MsCodeCtnTkFitings/GetDataList' }
});
this.storeCodeCtnTkFitings.load();
this.comboxCodeCtnTkFitings = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '配件名称',
labelWidth: 80,
store: this.storeCodeCtnTkFitings,
name: 'FITINGGID',
valueField: 'FITINGGID',
queryMode: 'local',
displayField: 'FITINGNAME',
enableKeyEvents: true,
listeners: {
specialkey: function (field, e) {
if (e.getKey() == e.ENTER) {
_thisCtnKcSumIndex.onRefreshClick();
}
}
}
});
_thisCtnKcSumIndex = this;
this.formSearch = Ext.widget('form', {
frame: true,
region: 'center',
bodyPadding: 5,
fieldDefaults: {
margins: '2 2 2 2',
labelAlign: 'right',
flex: 1,
labelWidth: 40,
msgTarget: 'qtip'
},
items: [{//fieldset 1
xtype: 'container',
defaultType: 'textfield',
layout: 'anchor',
defaults: {
anchor: '100%'
},
items: [{
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '箱号',
name: 'CTNNO',
enableKeyEvents: true,
listeners: {
specialkey: function (field, e) {
if (e.getKey() == e.ENTER) {
_thisCtnKcSumIndex.onRefreshClick();
}
}
}
},this.comboxCodeCtnTkFitings, {
xtype: 'button',
width: 90,
text: "执行查询",
iconCls: "btnrefresh",
handler: function (button, event) {
this.onRefreshClick(button, event);
},
scope: this
}, {
xtype: 'button',
width: 90,
text: "高级查询",
iconCls: "btnmore",
handler: function (button, event) {
var sql = this.getCondition();
var winAccess = new Shipping.DsQuery({
});
winAccess.StoreList = this.storeList;
winAccess.formname = this.formname;
winAccess.condition = sql;
winAccess.show();
return;
},
scope: this
}]
}
]//end items(fieldset 1)
}]//end root items
});
//#endregion formSearch
//查询工具条
this.panelBtn = new Ext.Panel({
region: "north",
tbar: [
{
text: "重置条件",
iconCls: "btnreset",
handler: function (button, event) {
this.onClearSql(button, event);
},
scope: this
}, '-',
{
text: "打印",
iconCls: 'btnprint',
menu: [
{ text: "全部",
handler: function (menu, event) {
_thisCtnKcSumIndex.Print();
}
}, { text: "选择打印",
handler: function (menu, event) {
_thisCtnKcSumIndex.PrintSelect();
}
}],
scope: this
}, {
text: "导出Excel",
iconCls: 'btnexportexcel',
handler: function (button, event) {
this.onExportClick(button, event);
},
scope: this
}, '-', {
text: "保存列表样式",
menu: [
{ text: "保存",
handler: function (button, event) {
this.girdcolums = DsTruck.SaveGridPanel(USERID, _thisCtnKcSumIndex.formname, _thisCtnKcSumIndex.gridList.columns, _thisCtnKcSumIndex.girdcolums, 1, true);
}
}, { text: "初始化",
handler: function (menu, event) {
// _this.InitGrid(_this.initgirdcolums);
_thisCtnKcSumIndex.girdcolums = DsTruck.SaveGridPanel(USERID, _thisCtnKcSumIndex.formname, _thisCtnKcSumIndex.gridList.columns, _thisCtnKcSumIndex.initgirdcolums, 1, true);
}
}],
scope: this
}
]
});
this.panelTop = new Ext.Panel({
layout: "border",
region: "north",
height: 75,
items: [this.formSearch, this.panelBtn]
});
Ext.apply(this, {
items: [this.panelTop, this.gridSumList, this.gridList]
});
this.storeList.on('beforeload', function (store) {
Ext.apply(store.proxy.extraParams, { condition: _thisCtnKcSumIndex.sqlcontext });
}, this);
this.sqlcontext = '';
this.gridList.reconfigure(this.storeList, this.girdcolums);
// this.onRefreshClick();
// this.InitGrid(this.girdcolums,this.sqlcontext);
}, //end initUIComponents
onRefreshClick: function (button, event) {
var sql = this.getCondition();
this.sqlcontext = sql;
this.storeSumList.load({
params: { start: 0, limit: this.PageSize, sort: '', condition: sql},
waitMsg: "正在查询数据...",
scope: this
});
// this.InitGrid(sql);
},
onDsQuery: function () {
var sql = this.sqlcontext;
this.storeSumList.load({
params: { start: 0, limit: this.PageSize, sort: '', condition: sql },
waitMsg: "正在查询数据...",
scope: this
});
},
onExportClick: function () {
_thisCtnKcSumIndex = this;
if (this.storeList.getCount() == 0) {
return;
}
var bsno = '11111';
var selections = this.gridList.getSelectionModel().getSelection();
if (selections.length != 0) {
var record = selections[0];
bsno = record.data.GID;
}
var sortstr = '';
if (this.sortfield != '' && this.sortdire != '') {
sortstr = this.sortfield + ' ' + this.sortdire;
}
Ext.Msg.wait('正在组织数据, 请稍侯..');
Ext.Ajax.request({
waitMsg: '正在组织数据...',
url: '/MvcContainer/MsCodeCtnTkFitings/GetFitingsDetailList',
scope: this,
params: {
start: 0, limit: this.PageSize,
condition: _thisCtnKcSumIndex.sqlcontext
},
callback: function (options, success, response) {
if (success) {
Ext.MessageBox.hide();
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
var returnstr = jsonresult.Data;
var sql1 = returnstr;
sql1 = sql1.replace(/\+/g, "@@@")
if (sql1 != '') {
GridExportBySql(sql1, this.formname, '配件台账.xls');
}
} 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
});
}
}
});
},
getCondition: function () {
var form = this.formSearch.getForm();
if (!form.isValid()) {
Ext.Msg.alert('提示', '查询条件赋值错误,请检查。');
return '';
}
var sql = "";
//if (_thisCtnKcIndex.strLINKGID != '') sql = " CTNGID in ('" + _thisCtnKcIndex.strLINKGID + "')";
var FITINGGID = form.findField('FITINGGID').getValue();
sql = sql + getAndConSql(sql, FITINGGID, " F.FITINGGID='" + FITINGGID + "' ");
var CTNNO = form.findField('CTNNO').getValue();
sql = sql + getAndConSql(sql, CTNNO, " (c.CTNNO like '%" + CTNNO + "%' OR c.PCTNNO like '%" + CTNNO + "%')");
//var CTNNO = form.findField('CTNNO').getValue();
//sql = sql + getAndConSql(sql, CTNNO, " CTNNO='" + CTNNO + "'");
//var expDateBgn = form.findField('ETDbgn').getRawValue();
//sql = sql + getAndConSql(sql, expDateBgn, "OPDATE >='" + expDateBgn + "'");
//var expDateEnd = form.findField('ETDend').getRawValue();
//sql = sql + getAndConSql(sql, expDateEnd, "OPDATE <='" + expDateEnd + " 23:59:59'");
return sql;
},
OprationSwap: function () {
var ret = new Array();
ret[0] = this.OprationStatus;
ret[1] = this.storeList;
ret[2] = this.SelectedRecord;
ret[3] ="Items";
return ret;
},
Print: function () {
_this = this;
if (this.storeList.getCount() == 0) {
return;
}
var bsno = '11111';
var selections = this.gridList.getSelectionModel().getSelection();
if (selections.length != 0) {
var record = selections[0];
bsno = record.data.GID;
}
var sortstr = '';
if (this.sortfield != '' && this.sortdire != '') {
sortstr = this.sortfield + ' ' + this.sortdire;
}
Ext.Msg.wait('正在组织数据, 请稍侯..');
Ext.Ajax.request({
waitMsg: '正在组织数据...',
url: '/MvcContainer/MsOpCtnTkFitings/GetFitingsCtnKcListStr',
scope: this,
params: {
condition: _this.sqlcontext
},
callback: function (options, success, response) {
if (success) {
Ext.MessageBox.hide();
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
var returnstr = jsonresult.data;
var printType = 'FitingsDetailList';
var sql1 = returnstr;
var sql2 = "";
var sql3 = "";
var sql4 = "";
var sql5 = "";
var sql6 = "";
PrintComm(printType, sql1, sql2, sql3, sql4, sql5, sql6);
} 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
});
}
}
});
},
PrintSelect: function () {
_this = this;
if (this.storeList.getCount() == 0) {
return;
}
var selectedRecords = [];
var storeadd = null;
selectedRecords = this.GridCheckBoxModel.selected.items;
if (selectedRecords.length == 0) {
Ext.Msg.show({ title: '提示', msg: '请先选择要打印的业务!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
}
var sortstr = ' F.CTNGID,F.FITINGNAME ';
if (this.sortfield != '' && this.sortdire != '') {
sortstr = this.sortfield + ' ' + this.sortdire;
}
var feeGidSql = '';
for (var i = 0; i < selectedRecords.length; i++) {
var record = selectedRecords[i];
var feeGId = "'" + record.get('GID') + "'";
if (feeGidSql == '') {
feeGidSql = feeGId;
} else {
feeGidSql = feeGidSql + "," + feeGId;
}
};
var bsno = '11111';
var selections = this.gridList.getSelectionModel().getSelection();
if (selections.length != 0) {
var record = selections[0];
bsno = record.data.GID;
}
var printType = 'MSOPCTNKCSELECT';
var sql1 = " select f.* from op_ctntkFiting_Ctnkc F left join code_ctntk c on (c.GID=F.CTNGID) WHERE f.GID IN (" + feeGidSql + ") order by " + sortstr;
var sql2 = "";
var sql3 = "";
var sql4 = "";
var sql5 = "";
var sql6 = "";
PrintComm(printType, sql1, sql2, sql3, sql4, sql5, sql6);
}
});