Browse Source

KERNEL-14066 feat: case/tree和case/ztree

es6
zsmj 2 years ago
parent
commit
9ea65567ca
  1. 22
      src/base/single/bar/bar.loading.js
  2. 1
      src/base/single/index.js
  3. 31
      src/case/tree/tree.level.js
  4. 6
      src/case/tree/treeexpander/tree.expander.js
  5. 4
      src/case/tree/treeexpander/tree.expander.popup.js
  6. 7
      src/case/ztree/treerender.page.service.js
  7. 14
      src/case/ztree/treeview.js
  8. 2
      src/core/wrapper/index.js

22
src/base/single/bar/bar.loading.js

@ -1,12 +1,8 @@
import { shortcut, emptyFn } from "../../../core" import { shortcut, emptyFn } from "@/core";
/** import { Single } from "../0.single";
* guy
* 加载条
* @type {*|void|Object}
*/
@shortcut()
class LoadingBar extends BI.Single {
@shortcut()
class LoadingBar extends Single {
static xtype = "bi.loading_bar"; static xtype = "bi.loading_bar";
_defaultConfig() { _defaultConfig() {
@ -14,10 +10,10 @@ class LoadingBar extends BI.Single {
return { return {
...conf, ...conf,
baseCls: (conf.baseCls || "") + " bi-loading-bar bi-tips", baseCls: `${conf.baseCls || ""} bi-loading-bar bi-tips`,
height: 30, height: 30,
handler: emptyFn, handler: emptyFn,
} };
} }
render() { render() {
@ -49,13 +45,15 @@ class LoadingBar extends BI.Single {
this.cardLayout = BI.createWidget({ this.cardLayout = BI.createWidget({
type: "bi.card", type: "bi.card",
element: this, element: this,
items: [{ items: [
{
el: loaded, el: loaded,
cardName: "loaded", cardName: "loaded",
}, { }, {
el: loading, el: loading,
cardName: "loading", cardName: "loading",
}], }
],
}); });
this.invisible(); this.invisible();
} }

1
src/base/single/index.js

@ -9,6 +9,7 @@ export { Link } from "./link/link";
export { Instruction } from "./instruction/instruction"; export { Instruction } from "./instruction/instruction";
export { Img } from "./img/img"; export { Img } from "./img/img";
export { Trigger } from "./trigger/trigger"; export { Trigger } from "./trigger/trigger";
export { LoadingBar } from "./bar/bar.loading";
export * from "./tip"; export * from "./tip";
export * from "./label"; export * from "./label";
export * from "./input"; export * from "./input";

31
src/case/tree/tree.level.js

@ -1,4 +1,19 @@
import { shortcut, Widget, extend, isKey, each, UUID, defaults, isNotEmptyArray, Tree, createWidget } from "@/core"; import {
shortcut,
Widget,
extend,
isKey,
each,
UUID,
defaults,
isNotEmptyArray,
Tree,
createWidget,
VerticalLayout
} from "@/core";
import { ButtonTree, CustomTree } from "@/base";
import { TreeExpander } from "./treeexpander/tree.expander";
import { BasicTreeItem, BasicTreeNode } from "@/case";
@shortcut() @shortcut()
export class LevelTree extends Widget { export class LevelTree extends Widget {
@ -36,13 +51,13 @@ export class LevelTree extends Widget {
} }
extend.pNode = pNode; extend.pNode = pNode;
if (node.isParent === true || node.parent === true || isNotEmptyArray(node.children)) { if (node.isParent === true || node.parent === true || isNotEmptyArray(node.children)) {
extend.type = "bi.tree_node"; extend.type = BasicTreeNode.xtype;
extend.selectable = false; extend.selectable = false;
defaults(node, extend); defaults(node, extend);
self._formatItems(node.children, layer + 1, node); self._formatItems(node.children, layer + 1, node);
} else { } else {
extend.type = "bi.tree_item"; extend.type = BasicTreeItem.xtype;
defaults(node, extend); defaults(node, extend);
} }
}); });
@ -63,26 +78,26 @@ export class LevelTree extends Widget {
this.empty(); this.empty();
this._assertId(nodes); this._assertId(nodes);
this.tree = createWidget({ this.tree = createWidget({
type: "bi.custom_tree", type: CustomTree.xtype,
element: this, element: this,
expander: extend({ expander: extend({
type: "bi.tree_expander", type: TreeExpander.xtype,
el: {}, el: {},
isDefaultInit: false, isDefaultInit: false,
selectable: false, selectable: false,
popup: { popup: {
type: "bi.custom_tree", type: CustomTree.xtype,
}, },
}, o.expander), }, o.expander),
items: this._formatItems(Tree.transformToTreeFormat(nodes), 0), items: this._formatItems(Tree.transformToTreeFormat(nodes), 0),
value: o.value, value: o.value,
el: extend({ el: extend({
type: "bi.button_tree", type: ButtonTree.xtype,
chooseType: 0, chooseType: 0,
layouts: [ layouts: [
{ {
type: "bi.vertical", type: VerticalLayout.xtype,
} }
], ],
}, o.el), }, o.el),

6
src/case/tree/treeexpander/tree.expander.js

@ -1,4 +1,6 @@
import { contains, Controller, createWidget, isArray, shortcut, Widget } from "@/core"; import { contains, Controller, createWidget, isArray, shortcut, Widget } from "@/core";
import { Expander } from "@/base";
import { TreeExpanderPopup } from "./tree.expander.popup";
@shortcut() @shortcut()
export class TreeExpander extends Widget { export class TreeExpander extends Widget {
@ -25,7 +27,7 @@ export class TreeExpander extends Widget {
}); });
return { return {
type: "bi.expander", type: Expander.xtype,
ref(_ref) { ref(_ref) {
self.expander = _ref; self.expander = _ref;
}, },
@ -33,7 +35,7 @@ export class TreeExpander extends Widget {
el: this.trigger, el: this.trigger,
isDefaultInit: o.isDefaultInit, isDefaultInit: o.isDefaultInit,
popup: { popup: {
type: "bi.tree_expander.popup", type: TreeExpanderPopup.xtype,
layer: o.layer || o.el.layer, layer: o.layer || o.el.layer,
isLastNode: o.isLastNode || o.el.isLastNode, isLastNode: o.isLastNode || o.el.isLastNode,
isFirstNode: o.isFirstNode || o.el.isFirstNode, isFirstNode: o.isFirstNode || o.el.isFirstNode,

4
src/case/tree/treeexpander/tree.expander.popup.js

@ -1,4 +1,4 @@
import { Controller, createWidget, pixFormat, shortcut, Widget } from "@/core"; import { Controller, createWidget, pixFormat, shortcut, VerticalLayout, Widget } from "@/core";
@shortcut() @shortcut()
export class TreeExpanderPopup extends Widget { export class TreeExpanderPopup extends Widget {
@ -34,7 +34,7 @@ export class TreeExpanderPopup extends Widget {
} }
return { return {
type: "bi.vertical", type: VerticalLayout.xtype,
cls: (showLine && !isLastNode) ? (BI.STYLE_CONSTANTS.LINK_LINE_TYPE === "solid" ? "line solid" : "line") : "", cls: (showLine && !isLastNode) ? (BI.STYLE_CONSTANTS.LINK_LINE_TYPE === "solid" ? "line solid" : "line") : "",
scrolly: null, scrolly: null,
items: [ items: [

7
src/case/ztree/treerender.page.service.js

@ -5,14 +5,15 @@
* 提供节点分页加载方式 * 提供节点分页加载方式
*/ */
import { createWidget, debounce, has, OB, size, each } from "@/core"; import { createWidget, debounce, has, OB, size, each, VerticalLayout } from "@/core";
import { LoadingBar } from "@/base";
export class TreeRenderPageService extends OB { export class TreeRenderPageService extends OB {
nodeLists = {}; nodeLists = {};
_getLoadingBar(tId) { _getLoadingBar(tId) {
const tip = createWidget({ const tip = createWidget({
type: "bi.loading_bar", type: LoadingBar.xtype,
height: 25, height: 25,
handler: () => { handler: () => {
this.refreshNodes(tId); this.refreshNodes(tId);
@ -39,7 +40,7 @@ export class TreeRenderPageService extends OB {
this.nodeLists[tId].loadWidget = tip; this.nodeLists[tId].loadWidget = tip;
} }
createWidget({ createWidget({
type: "bi.vertical", type: VerticalLayout.xtype,
element: o.subNodeListGetter(tId), element: o.subNodeListGetter(tId),
items: [tip], items: [tip],
}); });

14
src/case/ztree/treeview.js

@ -10,9 +10,9 @@ import {
jsonEncode, jsonEncode,
delay, each, replaceAll, delay, each, replaceAll,
isUndefined, isNotEmptyArray, deepClone, map, Tree, isUndefined, isNotEmptyArray, deepClone, map, Tree,
isNull, shortcut isNull, shortcut, VerticalLayout, Layout, DefaultLayout
} from "@/core"; } from "@/core";
import { Msg, Pane } from "@/base"; import { Msg, Pane, LoadingBar, Text } from "@/base";
@shortcut() @shortcut()
export class TreeView extends Pane { export class TreeView extends Pane {
@ -43,12 +43,12 @@ export class TreeView extends Pane {
this._createTree(); this._createTree();
this.tip = createWidget({ this.tip = createWidget({
type: "bi.loading_bar", type: LoadingBar.xtype,
invisible: true, invisible: true,
handler: () => this._loadMore(), handler: () => this._loadMore(),
}); });
createWidget({ createWidget({
type: "bi.vertical", type: VerticalLayout.xtype,
scrollable: true, scrollable: true,
scrolly: false, scrolly: false,
element: this, element: this,
@ -68,11 +68,11 @@ export class TreeView extends Pane {
this.tree.destroy(); this.tree.destroy();
} }
this.tree = createWidget({ this.tree = createWidget({
type: "bi.layout", type: Layout.xtype,
element: `<ul id='${this.id}' class='ztree${BI.STYLE_CONSTANTS.LINK_LINE_TYPE === "solid" ? " solid'" : "'"}></ul>`, element: `<ul id='${this.id}' class='ztree${BI.STYLE_CONSTANTS.LINK_LINE_TYPE === "solid" ? " solid'" : "'"}></ul>`,
}); });
createWidget({ createWidget({
type: "bi.default", type: DefaultLayout.xtype,
element: this, element: this,
items: [this.tree], items: [this.tree],
}); });
@ -386,7 +386,7 @@ export class TreeView extends Pane {
root: true, root: true,
keyword: o.paras.keyword, keyword: o.paras.keyword,
}, newNode, { }, newNode, {
type: "bi.text", type: Text.xtype,
text: replaceAll(newNode.text, "\n", " "), text: replaceAll(newNode.text, "\n", " "),
})); }));
const fragment = BI.Widget._renderEngine.createElement("<div>"); const fragment = BI.Widget._renderEngine.createElement("<div>");

2
src/core/wrapper/index.js

@ -1,2 +1,2 @@
export { Layout } from "./layout"; export { Layout } from "./layout.js";
export * from "./layout/index"; export * from "./layout/index";

Loading…
Cancel
Save