public get gridOptions(): GridOptions {
const that = this;
return {
headerHeight: 30,// 表头高度
rowHeight: 30,// 行高
columnDefs: [//列定义
{
headerName: '规则唯一号',
field: 'RuleCode',
width: 90,
},
{
headerName: '医疗单元号',
field: 'UnitId',
width: 90,
},
{
headerName: '系统分类',
field: 'SysType',
width: 80,
},
{
headerName: '子系统分类',
field: 'SubsysType',
width: 90,
},
{
headerName: '序列号中文名称',
field: 'KeyName',
width: 120,
},
{
headerName: '前缀',
field: 'KeyPrechar',
width: 80,
},
{
headerName: '格式化编号类型',
field: 'KeyFmtcodeType',
width: 120,
cellRenderer: (params) => {
for (const item of this.fmtcodeTypeArr) {
if (item.value === params.data.KeyFmtcodeType) {
return '' + item.label + '';
}
}
},
},
{
headerName: '顺序号长度',
field: 'KeySeqnumLen',
width: 90,
},
{
headerName: '顺序号的开始数字',
field: 'KeySeqnumBgn',
width: 130,
},
{
headerName: '是否加医疗单元号',
field: 'CanAddUnitid',
width: 130,
valueGetter(params) {
return params.data.CanAddUnitid === 0 ? false : true;
},
valueFormatter(params) {
return params.value ? '√' : '';
},
},
{
headerName: '数据库连接名',
field: 'CnName',
width: 110,
},
{
headerName: '注册方式',
field: 'RegWay',
width: 80,
valueFormatter(params) {
return params.data.RegWay === 1 ? '预注册' : '运行时注册';
},
},
{
headerName: '停用标志',
field: 'StopMark',
width: 80,
valueFormatter(params) {
return params.data.StopMark === 0 ? '' : '√';
},
},
],
showToolPanel: false, // 显示工具栏
enableSorting: true,//允许排序
enableColResize: true,//允许调整列宽
suppressLoadingOverlay: true,// 去掉表格加载数据提示
suppressNoRowsOverlay: true,// 去掉表格无数据提示
suppressDragLeaveHidesColumns: true,//防止拖动的时候隐藏表格列
suppressContextMenu: true,// 阻止表格的右键菜单
defaultColDef: {
suppressMenu: true,//隐藏表头菜单
},
onRowSelected: this.RowSelected,//行选中回调
rowSelection: 'single',//只允许单行选中
isExternalFilterPresent: () => this.filterStart,//是否允许外部筛选
doesExternalFilterPass: this.IfNodeVisible,//外部筛选条件
onFilterChanged() {//筛选条件改变回调
this.api.deselectAll();
that.selectedRow = false;
},
navigateToNextCell: (params) => {// 键盘操作选中行
let previousCell = params.previousCellDef;
const suggestedNextCell = params.nextCellDef;
const KEY_UP = 38;
const KEY_DOWN = 40;
const KEY_LEFT = 37;
const KEY_RIGHT = 39;
switch (params.key) {
case KEY_DOWN:
previousCell = params.previousCellDef;
this.gridOptions.api.forEachNode((node) => {
if (previousCell.rowIndex + 1 === node.rowIndex) {
node.setSelected(true);
}
});
return suggestedNextCell;
case KEY_UP:
previousCell = params.previousCellDef;
this.gridOptions.api.forEachNode((node) => {
if (previousCell.rowIndex - 1 === node.rowIndex) {
node.setSelected(true);
}
});
return suggestedNextCell;
case KEY_LEFT:
case KEY_RIGHT:
return suggestedNextCell;
default:
break;
}
},
};
}