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.

475 lines
15 KiB
JavaScript

Ext.namespace('Shipping');
Shipping.DBTableConnIndex = function (config) {
Ext.applyIf(this, config);
this.initUIComponents();
window.Shipping.DBTableConnIndex.superclass.constructor.call(this);
};
Ext.extend(Shipping.DBTableConnIndex, Ext.Panel, {
PageSize: 500,
OprationStatus: null, //仅当弹出界面时使用
SelectedRecord: null,
initUIComponents: function () {
//定义数据集
this.storeList = Ext.create('Ext.data.Store', {
model: 'SYS_TABLECONNmb',
remoteSort: true,
pageSize: this.PageSize,
proxy: {
type: 'ajax',
url: '/SysMng/DBTableConn/GetDataList',
reader: {
idProperty: 'GID',
root: 'data',
totalProperty: 'totalCount'
}
}
});
this.formname = "modDBTableConn";
Ext.grid.RowNumberer = Ext.extend(Ext.grid.RowNumberer, {
width: 50
});
this.column = [{
sortable: true,hidden:true,
dataIndex: 'ID',
header: 'ID',
width: 80
},
{
sortable: true,
dataIndex: 'NAME',
header: '名称',
width: 120
},
{
sortable: true,
dataIndex: 'SYNCTIME',
header: '最近同步完成时间',
width: 80
},
{
sortable: true,
dataIndex: 'SYNCSTARTTIME',
header: '最近同步开始时间',
width: 80
},
{
sortable: true,
dataIndex: 'SYNCTYPE',
header: '同步类型',
width: 80
},
{
sortable: true,
dataIndex: 'SYNCSTATES',
header: '同步状态',
width: 80
},
{
sortable: true,
dataIndex: 'FROMDB',
header: '来源库',
width: 120
},
{
sortable: true,
dataIndex: 'FROMTABLE',
header: '来源表',
width: 120
},
{
sortable: true,
dataIndex: 'FROMPKEY',
header: '来源主键',
width: 80
},
{
sortable: true,
dataIndex: 'TODB',
header: '目标库',
width: 120
},
{
sortable: true,
dataIndex: 'TOTABLE',
header: '目标表',
width: 120
},
{
sortable: true,
dataIndex: 'TOPKEY',
header: '目标主键',
width: 80
},
{
sortable: true,
dataIndex: 'DESCRPTION',
header: '说明',
width: 80
},
{
sortable: true,
dataIndex: 'CONDITION',
header: '其他条件',
width: 80
},
{
sortable: true,hidden:true,
dataIndex: 'TIMEMARK',
header: 'TIMEMARK',
width: 80
}];
//#region 定义Grid
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.MainCB = Ext.create('Ext.selection.CheckboxModel', { checkOnly: true });
this.gridList = new Ext.grid.GridPanel({
store: this.storeList,
enableHdMenu: false,
region: 'center',
loadMask: { msg: "数据加载中,请稍等..." },
trackMouseOver: true,
disableSelection: false,
stripeRows: true,
selModel: this.MainCB,
viewConfig: {
enableTextSelection: true
},
//viewConfig: {
// enableTextSelection: true,
// autoFill: true,
// getRowClass: function (record, rowIndex, rowParams, store) {
// var feeStatus = record.get('一个什么数');
// return Shipping.AppUsedGetRowClass(这个数作为参数);//在Comm的StatusColor翻译成css
// }
//}
columns: [new Ext.grid.RowNumberer()],
bbar: [Ext.create('Ext.PagingToolbar', {
store: this.storeList,
displayInfo: true,
displayMsg: '当前显示 {0} - {1}条记录 /共 {2}条记录',
emptyMsg: "没有数据"
}), this.Pagenum]
});
/////////////以下部分为获取存储的gridpanel显示样式
this.column = DsTruck.GetGridPanel(GID, this.formname, this.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';
DsOpenMultiEditWin('/SysMng/DBTableConn/Edit', record.data.ContractNo, "700", "1100");
}, this);
/* this.gridList.addListener('itemdblclick', function (dataview, record, item, index, e, b) {
alert(record.get("ContractNo"))
}, this);*/
//#region formSearch
//#region formSearch枚举参照相关
//#endregion
var _this = this;
this.formSearch = Ext.widget('form', {
frame: true,
region: 'center',
bodyPadding: 5,
//collapsed: false,
//collapsible: true,
fieldDefaults: {
margins: '2 2 2 2',
labelAlign: 'right',
flex: 1,
labelWidth: 90,
msgTarget: 'qtip'
},
items: [
{//fieldset 1
xtype: 'container',
defaultType: 'textfield',
layout: 'anchor',
defaults: {
anchor: '100%'
},
items: [{
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '名称',
name: 'NAME',
listeners: {
specialkey: function (field, e) {
if (e.getKey() == e.ENTER) {
_this.onRefreshClick();
}
}
}
}, {
fieldLabel: '表名',
name: 'TABLENAME',
listeners: {
specialkey: function (field, e) {
if (e.getKey() == e.ENTER) {
_this.onRefreshClick();
}
}
}
}]
}]
} //end items(fieldset 1)
]//end root items
});
//#endregion formSearch
//查询工具条
var _this = this;
this.panelBtn = new Ext.Panel({
region: "north",
tbar: [
{
text: "新建",
iconCls: "btnadd",
handler: function (button, event) {
this.OprationStatus = 'add';
this.SelectedRecord = null;
DsOpenEditWin('/SysMng/DBTableConn/Edit', '0', "700", "1100");
},
scope: this
},
{
text: "删除",
iconCls: "btndelete",
handler: function (button, event) {
this.onDeleteClick(button, event);
},
scope: this
},
'-',
{
text: "执行查询",
iconCls: "btnrefresh",
handler: function (button, event) {
this.onRefreshClick(button, event);
},
scope: this
},
{
text: "重置条件",
iconCls: "btnreset",
handler: function (button, event) {
this.onResetClick(button, event);
},
scope: this
},
{
text: "保存列表样式",
id: "btntest",
handler: function (button, event) {
var tempcolumns = this.gridList.columns;
DsTruck.SaveGridPanel(GID, this.formname, tempcolumns, this.column, 1, false);
},
scope: this
}, '-'
]
});
//布局
this.panelTop = new Ext.Panel({
layout: "border",
region: "north",
collapsed: false,
collapsible: true,
height: 80,
items: [this.formSearch]
});
Ext.apply(this, {
items: [this.panelBtn, this.panelTop, this.gridList]
});
this.storeList.on('beforeload', function (store) {
var sql = this.getCondition();
Ext.apply(store.proxy.extraParams, { condition: sql });
}, this);
this.onRefreshClick();
//this.gridList.addListener('itemcontextmenu', this.itemcontextmenu);
}, //end initUIComponents
onRefreshClick: function (button, event) {
var sql = this.getCondition();
this.PageSize = this.Pagenum.getValue();
this.storeList.pageSize = this.PageSize;
this.storeList.load({
params: { start: 0, limit: this.PageSize, sort: '', condition: sql },
waitMsg: "正在查询数据...",
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];
Ext.MessageBox.confirm('提示', '确定删除该记录吗?', function (btn) {
if (btn == 'yes') {
Ext.Msg.wait('正在删除数据...');
Ext.Ajax.request({
waitMsg: '正在删除数据...',
url: '/Sysmng/DBTableConn/Delete',
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
onResetClick: function (button, event) {
this.formSearch.getForm().reset();
},
getCondition: function () {
var form = this.formSearch.getForm();
if (!form.isValid()) {
Ext.Msg.alert('提示', '查询条件赋值错误,请检查。');
return '';
}
var sql = '';
var NAME = form.findField('NAME').getValue();
sql = sql + getAndConSql(sql, NAME, "NAME like '%" + NAME + "'%");
var TABLENAME = form.findField('TABLENAME').getValue();
sql = sql + getAndConSql(sql, TABLENAME, "TABLENAME like '%" + TABLENAME + "%'");
return sql;
},
onGetremind: function (field, newValue, oldValue) {
if (newValue != null) {
this.storeList.load({
params: { start: 0, limit: this.PageSize, sort: '', condition: newValue },
waitMsg: "正在查询数据...",
scope: this
});
}
},
OprationSwap: function () {
var ret = new Array();
ret[0] = this.OprationStatus;
ret[1] = this.storeList;
ret[2] = this.SelectedRecord;
return ret;
},
// alert(this.OprationStatus.ToString());
// alert(this.storeList.toString());
// alert(this.SelectedRecord.toString());
PrintClassList: function () {//
var MainList = "";
var selectedRecords = [];
selectedRecords = this.gridList.selModel.getSelection();
for (var i = 0; i < selectedRecords.length; i++) {
var rec = selectedRecords[i];
if (MainList == "") { MainList = "'" + rec.get('GID') + "'"; }
else {
MainList = MainList + ",'" + rec.get('GID') + "'";
}
}
var printType = 'DEMO_XSGL_ClassList'; //
//var T = this.getCondition();
//if (T != "") { T = " where " + T; };
var sql1 = " select YEAR 年份,BJNAME 班级名,TEXT 备注 ";
sql1 = sql1 + " from Demo_XSGL_BJ ";
//sql1 = sql1 + T;
if (MainList != "") {
sql1 = sql1 + " WHERE GID in( " + MainList + " ) "; //and isnull(dbo.trimdate(m.inspection_date),'')=''
}
sql1 = sql1 + " order by YEAR,BJNAME ";
var sql2 = "select '456456'";
var sql3 = "";
var sql4 = "";
var sql5 = "";
var sql6 = "";
PrintComm(printType, sql1, sql2, sql3, sql4, sql5, sql6);
}
});