Browse Source

树表格支持勾选策略

main
likunming 2 months ago
parent
commit
1371ec60d9
  1. 7
      io.sc.platform.core.frontend/src/platform/components/grid/TreeGridFirstTdContent.vue
  2. 21
      io.sc.platform.core.frontend/src/platform/components/grid/ts/function/RowData.ts

7
io.sc.platform.core.frontend/src/platform/components/grid/TreeGridFirstTdContent.vue

@ -184,8 +184,11 @@ const selectedFun = (value, event) => {
} else {
row[tickedField] = false;
}
selectedChildren(row, value);
selectedParent(row, value);
if (tools.props.treeTickStrategy === 'leaf') {
//
selectedChildren(row, value);
selectedParent(row, value);
}
if (tools.props.onUpdateTicked) {
tools.props.onUpdateTicked(event, row);
}

21
io.sc.platform.core.frontend/src/platform/components/grid/ts/function/RowData.ts

@ -269,15 +269,18 @@ export class RowData extends Base {
item.children.forEach((child) => {
item[Constant.FIELD_NAMES.CHILDREN_TICKED_COUNT] += child[Constant.FIELD_NAMES.TICKED_COUNT];
});
if (item[Constant.FIELD_NAMES.CHILDREN_TICKED_COUNT] === 0) {
item[this.props.tickedField] = false;
item[Constant.FIELD_NAMES.TICKED_COUNT] = 0;
} else if (item[Constant.FIELD_NAMES.CHILDREN_TICKED_COUNT] === item.children.length) {
item[this.props.tickedField] = true;
item[Constant.FIELD_NAMES.TICKED_COUNT] = 1;
} else {
item[this.props.tickedField] = null;
item[Constant.FIELD_NAMES.TICKED_COUNT] = 0;
if (this.props.treeTickStrategy === 'leaf') {
// 树勾选策略包含子节点才重新处理其勾选状态。
if (item[Constant.FIELD_NAMES.CHILDREN_TICKED_COUNT] === 0) {
item[this.props.tickedField] = false;
item[Constant.FIELD_NAMES.TICKED_COUNT] = 0;
} else if (item[Constant.FIELD_NAMES.CHILDREN_TICKED_COUNT] === item.children.length) {
item[this.props.tickedField] = true;
item[Constant.FIELD_NAMES.TICKED_COUNT] = 1;
} else {
item[this.props.tickedField] = null;
item[Constant.FIELD_NAMES.TICKED_COUNT] = 0;
}
}
}
});

Loading…
Cancel
Save