-
+
-
+
diff --git a/io.sc.platform.core.frontend/src/platform/components/grid/css/grid.css b/io.sc.platform.core.frontend/src/platform/components/grid/css/grid.css
index 891a9171..23014c57 100644
--- a/io.sc.platform.core.frontend/src/platform/components/grid/css/grid.css
+++ b/io.sc.platform.core.frontend/src/platform/components/grid/css/grid.css
@@ -4,6 +4,9 @@
.w-grid .cellHover:hover {
background-color: rgba(0, 0, 0, .03);
}
+.w-grid .mouseDisabled {
+ cursor: not-allowed; /* 将鼠标指针变为禁用图标 */
+}
.w-grid .q-table__top {
padding: var(--tableTopPadding) var(--tableTopPadding);
}
diff --git a/io.sc.platform.core.frontend/src/platform/components/grid/ts/GridTools.ts b/io.sc.platform.core.frontend/src/platform/components/grid/ts/GridTools.ts
index fd5bd1e5..a4d7c0d5 100644
--- a/io.sc.platform.core.frontend/src/platform/components/grid/ts/GridTools.ts
+++ b/io.sc.platform.core.frontend/src/platform/components/grid/ts/GridTools.ts
@@ -266,6 +266,9 @@ export class GridTools {
if (Tools.hasOwnProperty(target, Constant.FIELD_NAMES.LAZYLOAD_NO_CHILDREN)) {
delete target[Constant.FIELD_NAMES.LAZYLOAD_NO_CHILDREN];
}
+ if (Tools.hasOwnProperty(target, Constant.FIELD_NAMES.SELECTABLE)) {
+ delete target[Constant.FIELD_NAMES.SELECTABLE];
+ }
}
/**
diff --git a/io.sc.platform.core.frontend/src/platform/components/grid/ts/constant/src/FieldNames.ts b/io.sc.platform.core.frontend/src/platform/components/grid/ts/constant/src/FieldNames.ts
index 55c6a2eb..9e340b18 100644
--- a/io.sc.platform.core.frontend/src/platform/components/grid/ts/constant/src/FieldNames.ts
+++ b/io.sc.platform.core.frontend/src/platform/components/grid/ts/constant/src/FieldNames.ts
@@ -42,6 +42,11 @@ export class FieldNames {
*/
public static LAZYLOAD_NO_CHILDREN = '_lazyloadNoChildren';
+ /**
+ * 数据是否允许选择
+ */
+ public static SELECTABLE = '_selectable';
+
/**
* 获得行数据中拓展的字段属性名
* @param props
@@ -58,6 +63,7 @@ export class FieldNames {
rowOldValue: FieldNames.ROW_OLD_VALUE,
rowIndex: FieldNames.ROW_INDEX,
lazyloadNoChildren: FieldNames.LAZYLOAD_NO_CHILDREN,
+ selectable: FieldNames.SELECTABLE,
};
}
}
diff --git a/io.sc.platform.core.frontend/src/platform/components/grid/ts/event/EventManager.ts b/io.sc.platform.core.frontend/src/platform/components/grid/ts/event/EventManager.ts
index 6833a6bc..5a76e615 100644
--- a/io.sc.platform.core.frontend/src/platform/components/grid/ts/event/EventManager.ts
+++ b/io.sc.platform.core.frontend/src/platform/components/grid/ts/event/EventManager.ts
@@ -1,5 +1,3 @@
-import type { PropsType } from '../types/PropsType';
-
import { RowClick } from './src/RowClick';
import { RowDbClick } from './src/RowDbClick';
import { AfterDragAndDrop } from './src/AfterDragAndDrop';
@@ -14,6 +12,7 @@ import { AfterRemove } from './src/AfterRemove';
import { AfterEditorOpen } from './src/AfterEditorOpen';
import { GridTools } from '../GridTools';
import { TableType } from '../types/TableType';
+import { Constant, PropsType } from '../../ts/index';
/**
* w-grid 表格事件管理器
@@ -54,7 +53,9 @@ export class EventManager {
* @param index 行下标
*/
public rowClick(evt: any, row: any, index: number) {
- this._rowClick.execute(evt, row, index);
+ if (row[Constant.FIELD_NAMES.SELECTABLE]) {
+ this._rowClick.execute(evt, row, index);
+ }
}
/**
@@ -64,7 +65,9 @@ export class EventManager {
* @param index 行下标
*/
public rowDbClick(evt: any, row: any, index: number) {
- this._rowDbClick.execute(evt, row, index);
+ if (row[Constant.FIELD_NAMES.SELECTABLE]) {
+ this._rowDbClick.execute(evt, row, index);
+ }
}
/**
diff --git a/io.sc.platform.core.frontend/src/platform/components/grid/ts/event/src/UpdateTickeds.ts b/io.sc.platform.core.frontend/src/platform/components/grid/ts/event/src/UpdateTickeds.ts
index c18e350e..fc20636a 100644
--- a/io.sc.platform.core.frontend/src/platform/components/grid/ts/event/src/UpdateTickeds.ts
+++ b/io.sc.platform.core.frontend/src/platform/components/grid/ts/event/src/UpdateTickeds.ts
@@ -17,17 +17,12 @@ export class UpdateTickeds extends Base {
const selectedField = this.props.selectedField;
const tickedField = this.props.tickedField;
if (this.table?.store.inlineEditStatus === Constant.EDIT_STATUS.NONE) {
- if (value) {
- this.table.rows.forEach((item) => {
- item[tickedField] = true;
- item[selectedField] = true;
- });
- } else {
- this.table.rows.forEach((item) => {
- item[tickedField] = false;
- item[selectedField] = false;
- });
- }
+ this.table.rows.forEach((item) => {
+ if (item[Constant.FIELD_NAMES.SELECTABLE]) {
+ item[tickedField] = value;
+ item[selectedField] = value;
+ }
+ });
} else if (this.table?.store.inlineEditStatus === Constant.EDIT_STATUS.ROW || this.table?.store.inlineEditStatus === Constant.EDIT_STATUS.CELL) {
this.table.store.headerTicked = null;
} else if (this.table?.store.inlineEditStatus === Constant.EDIT_STATUS.ROWS) {
diff --git a/io.sc.platform.core.frontend/src/platform/components/grid/ts/function/Operator.ts b/io.sc.platform.core.frontend/src/platform/components/grid/ts/function/Operator.ts
index a63bcb32..9ae6f15e 100644
--- a/io.sc.platform.core.frontend/src/platform/components/grid/ts/function/Operator.ts
+++ b/io.sc.platform.core.frontend/src/platform/components/grid/ts/function/Operator.ts
@@ -7,6 +7,8 @@ import { Constant, PropsType, TableType } from '../index';
* w-grid 表格操作函数
*/
export class Operator extends Base {
+ private topResizeFlag = false;
+
constructor(props: PropsType, table: TableType) {
super(props, table);
this.tableFullscreen = this.tableFullscreen.bind(this);
@@ -102,17 +104,16 @@ export class Operator extends Base {
* 表格大小变化触发函数
* @returns
*/
- resize() {
- if (!this || !this.table) {
- return;
- }
+ resize(location: string) {
const tableElement = this.instance?.getHtmlElement();
if (!tableElement) {
return;
}
this.table.store.resizeFlag = !this.table.store.resizeFlag;
- this.table.componentRef.getTopRef()?.handleQueryFormShowField();
- this.table.componentRef.getTopRef()?.handleToolbarActions();
+ if (location === 'top') {
+ this.table.componentRef.getTopRef()?.handleQueryFormShowField();
+ this.table.componentRef.getTopRef()?.handleToolbarActions();
+ }
if (tableElement) {
this.table.store.location.yLocation = tableElement.getBoundingClientRect().y;
if (tableElement.getElementsByClassName('noDataTr').length > 0) {
diff --git a/io.sc.platform.core.frontend/src/platform/components/grid/ts/function/RowData.ts b/io.sc.platform.core.frontend/src/platform/components/grid/ts/function/RowData.ts
index 26956663..afd38985 100644
--- a/io.sc.platform.core.frontend/src/platform/components/grid/ts/function/RowData.ts
+++ b/io.sc.platform.core.frontend/src/platform/components/grid/ts/function/RowData.ts
@@ -365,6 +365,7 @@ export class RowData extends Base {
rowData[this.props.tickedField] = this.getInitRowTicked(rowData);
rowData[this.props.selectedField] = this.getInitRowSelected(rowData);
rowData[Constant.FIELD_NAMES.ROW_OLD_VALUE] = {};
+ rowData[Constant.FIELD_NAMES.SELECTABLE] = this.getSelectable(rowData);
this.setOldValue(rowData);
if (this.props.tree) {
if (this.table.store.expandDatas.length > 0 && this.table.store.expandDatas.includes(rowData[this.props.primaryKey])) {
@@ -378,6 +379,22 @@ export class RowData extends Base {
}
}
+ /**
+ * 获取行是否可选
+ * @param rowData
+ * @returns
+ */
+ private getSelectable(rowData: any): boolean {
+ let selectable = true;
+ if (this.props.selectableIf && typeof this.props.selectableIf === 'function') {
+ const result = this.props.selectableIf({ grid: this.instance, data: rowData });
+ if (!result) {
+ selectable = false;
+ }
+ }
+ return selectable;
+ }
+
/**
* 获取初始化行的ticked状态
* @param rowData
diff --git a/io.sc.platform.core.frontend/src/platform/components/grid/ts/types/PropsType.ts b/io.sc.platform.core.frontend/src/platform/components/grid/ts/types/PropsType.ts
index cd1061b0..3fa2f12b 100644
--- a/io.sc.platform.core.frontend/src/platform/components/grid/ts/types/PropsType.ts
+++ b/io.sc.platform.core.frontend/src/platform/components/grid/ts/types/PropsType.ts
@@ -207,6 +207,10 @@ export type PropsType = {
* toolbar 属性
*/
toolbarConfigure: any,
+ /**
+ * 数据行可选规则配置函数
+ */
+ selectableIf?: Function,
/**
* 分页大小,后台初始页码等配置
*/
diff --git a/io.sc.platform.core.frontend/src/platform/components/toolbar/WToolbar.vue b/io.sc.platform.core.frontend/src/platform/components/toolbar/WToolbar.vue
index 9119fb33..05a2cfd9 100644
--- a/io.sc.platform.core.frontend/src/platform/components/toolbar/WToolbar.vue
+++ b/io.sc.platform.core.frontend/src/platform/components/toolbar/WToolbar.vue
@@ -75,8 +75,8 @@
>
- {{ getLabel(childrenBtn.label) }}
+ {{ getLabel(childrenBtn?.label) }}
@@ -204,7 +204,11 @@ const localFlag = ref(false);
watch(
() => modelValue.value,
(newVal, oldVal) => {
- handleButtons();
+ // handleButtons();
+ // if (containerRef.value) {
+ // isActionWidthInitializedRef.value = false;
+ // onResize(containerRef.value.clientWidth);
+ // }
},
);
@@ -284,11 +288,12 @@ const onResize = (size) => {
if (!isActionWidthInitializedRef.value) {
const nodes = containerRef.value.getElementsByClassName('class-action-item');
for (let i = 0; i < buttons_.length; i++) {
- buttons_[i].width = nodes[i].clientWidth;
+ if (nodes[i]) {
+ buttons_[i].width = nodes[i].clientWidth;
+ }
}
isActionWidthInitializedRef.value = true;
}
-
reset(size.width);
};
@@ -425,6 +430,7 @@ const buttonClick = async (button) => {
selectedColName: props.grid.getSelectedCell()['colName'],
};
if (button.enableIf && !button.enableIf(args)) {
+ console.warn('[w-toolbar] The function `enableIf` returns false, causing the `click` not to trigger.' + ' button name is `' + button['name'] + '`');
return;
}
let beforeResult = true;