From 7b5bbc48f38c746c3358e3a35de7c153e5802a27 Mon Sep 17 00:00:00 2001 From: guy Date: Thu, 23 Mar 2017 16:49:26 +0800 Subject: [PATCH] =?UTF-8?q?=E6=95=B4=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- demo/js/base/table/demo.resizable_table.js | 57 +++++ demo/js/base/tree/demo.part_tree.js | 9 + demo/js/base/tree/demo.sync_tree.js | 9 + demo/js/base/tree/demo.tree_view.js | 52 +++++ demo/js/config/base.js | 20 +- demo/js/config/case.js | 68 ++---- demo/js/config/core.js | 4 +- demo/js/core/abstract/mvc.custom_tree.js | 245 +++++++++++++++++++++ dist/base.js | 10 +- dist/case.js | 4 +- src/base/combination/tree.button.js | 8 +- src/base/tree/treeview.js | 2 +- src/case/table/table.tree.js | 2 +- src/case/tree/tree.simple.js | 2 +- 14 files changed, 421 insertions(+), 71 deletions(-) create mode 100644 demo/js/base/table/demo.resizable_table.js create mode 100644 demo/js/base/tree/demo.part_tree.js create mode 100644 demo/js/base/tree/demo.sync_tree.js create mode 100644 demo/js/base/tree/demo.tree_view.js create mode 100644 demo/js/core/abstract/mvc.custom_tree.js diff --git a/demo/js/base/table/demo.resizable_table.js b/demo/js/base/table/demo.resizable_table.js new file mode 100644 index 000000000..f3d3540a9 --- /dev/null +++ b/demo/js/base/table/demo.resizable_table.js @@ -0,0 +1,57 @@ +Demo.Func = BI.inherit(BI.Widget, { + props: { + baseCls: "demo-func" + }, + render: function () { + var items = [], header = [], columnSize = []; + + var rowCount = 100, columnCount = 100; + for (var i = 0; i < 1; i++) { + header[i] = []; + for (var j = 0; j < columnCount; j++) { + header[i][j] = { + type: "bi.label", + text: "表头" + i + "-" + j + } + columnSize[j] = 100; + } + } + for (var i = 0; i < rowCount; i++) { + items[i] = []; + for (var j = 0; j < columnCount; j++) { + items[i][j] = { + type: "bi.label", + text: (i < 3 ? 0 : i) + "-" + j + } + } + } + + var table = BI.createWidget({ + type: "bi.resizable_table", + el: { + type: "bi.grid_table", + }, + width: 600, + height: 500, + isResizeAdapt: true, + isNeedResize: true, + isNeedFreeze: true, + freezeCols: [0, 1], + columnSize: columnSize, + items: items, + header: header + }); + BI.createWidget({ + type: "bi.absolute", + element: this, + items: [{ + el: table, + left: 10, + right: 10, + top: 10, + bottom: 10 + }] + }) + } +}); +$.shortcut("demo.resizable_table", Demo.Func); \ No newline at end of file diff --git a/demo/js/base/tree/demo.part_tree.js b/demo/js/base/tree/demo.part_tree.js new file mode 100644 index 000000000..d7741dd31 --- /dev/null +++ b/demo/js/base/tree/demo.part_tree.js @@ -0,0 +1,9 @@ +Demo.Func = BI.inherit(BI.Widget, { + props: { + baseCls: "demo-func" + }, + + render: function () { + } +}); +$.shortcut("demo.part_tree", Demo.Func); \ No newline at end of file diff --git a/demo/js/base/tree/demo.sync_tree.js b/demo/js/base/tree/demo.sync_tree.js new file mode 100644 index 000000000..a2c06ff92 --- /dev/null +++ b/demo/js/base/tree/demo.sync_tree.js @@ -0,0 +1,9 @@ +Demo.Func = BI.inherit(BI.Widget, { + props: { + baseCls: "demo-func" + }, + + render: function () { + } +}); +$.shortcut("demo.sync_tree", Demo.Func); \ No newline at end of file diff --git a/demo/js/base/tree/demo.tree_view.js b/demo/js/base/tree/demo.tree_view.js new file mode 100644 index 000000000..2255b32b7 --- /dev/null +++ b/demo/js/base/tree/demo.tree_view.js @@ -0,0 +1,52 @@ +Demo.Func = BI.inherit(BI.Widget, { + props: { + baseCls: "demo-func" + }, + + _createDefaultTree: function(){ + var tree = BI.createWidget({ + type: "bi.tree_view" + }); + tree.initTree([ + {"id":1, "pId":0, "text":"test1", open:true}, + {"id":11, "pId":1, "text":"test11"}, + {"id":12, "pId":1, "text":"test12"}, + {"id":111, "pId":11, "text":"test111"}, + {"id":2, "pId":0, "text":"test2", open:true}, + {"id":21, "pId":2, "text":"test21"}, + {"id":22, "pId":2, "text":"test22"} + ]) + return tree; + }, + + render: function () { + var self = this; + BI.createWidget({ + type: "bi.grid", + columns: 1, + rows: 1, + element: this, + items: [{ + column: 0, + row: 0, + el: { + type: "bi.vtape", + items: [ + { + el: this._createDefaultTree() + }, + { + el: { + type: "bi.label", + text: 'tree.initTree([{"id":1, "pId":0, "text":"test1", open:true},{"id":11, "pId":1, "text":"test11"},{"id":12, "pId":1, "text":"test12"},{"id":111, "pId":11, "text":"test111"}])', + whiteSpace: "normal" + }, + height: 50 + } + ] + } + }] + }) + } +}); +$.shortcut("demo.tree_view", Demo.Func); \ No newline at end of file diff --git a/demo/js/config/base.js b/demo/js/config/base.js index 8f5de28a4..54056d547 100644 --- a/demo/js/config/base.js +++ b/demo/js/config/base.js @@ -69,23 +69,23 @@ Demo.BASE_CONFIG = [{ }, { pId: 2, id: 203, - text: "树控件" + text: "tree" }, { pId: 203, - text: "bi.treeview", - value: "demo.treeview" + text: "bi.tree_view", + value: "demo.tree_view" }, { pId: 203, - text: "bi.synctree", - value: "demo.synctree" + text: "bi.sync_tree", + value: "demo.sync_tree" }, { pId: 203, - text: "bi.parttree", - value: "demo.parttree" + text: "bi.part_tree", + value: "demo.part_tree" }, { pId: 2, id: 204, - text: "表格" + text: "table" }, { pId: 204, text: "bi.table_view", @@ -98,6 +98,10 @@ Demo.BASE_CONFIG = [{ pId: 204, text: "bi.collection_table", value: "demo.collection_table" +}, { + pId: 204, + text: "bi.resizable_table", + value: "demo.resizable_table" }, { pId: 2, text: "bi.canvas", diff --git a/demo/js/config/case.js b/demo/js/config/case.js index da7cdbfb5..062049d7b 100644 --- a/demo/js/config/case.js +++ b/demo/js/config/case.js @@ -54,6 +54,22 @@ Demo.CASE_CONFIG = [{ pId: 303, text: "bi.level_tree", value: "demo.level_tree" +}, { + pId: 3, + id: 304, + text: "table" +}, { + pId: 304, + text: "bi.adaptive_table", + value: "demo.adaptive_table" +}, { + pId: 304, + text: "bi.tree_table", + value: "demo.tree_table" +}, { + pId: 304, + text: "bi.layer_tree_table", + value: "demo.layer_tree_table" }, { pId: 3, text: "bi.calendar", @@ -70,50 +86,8 @@ Demo.CASE_CONFIG = [{ pId: 3, text: "bi.color_chooser", value: "demo.color_chooser" -}, - - { - pId: 3, - text: "各种checkbox", - value: "demo.checkboxes" - }, { - pId: 3, - text: "各种tip", - value: "demo.tips" - }, { - pId: 3, - text: "bi.float_box", - value: "demo.float_box" - }, { - pId: 3, - text: "bi.float_box", - value: "demo.float_box" - }, { - pId: 3, - text: "bi.segment", - value: "demo.segment" - }, { - pId: 3, - id: 12, - text: "各种表格" - }, { - pId: 3, - id: 13, - text: "各种tree" - }, { - pId: 3, - text: "各种trigger", - value: "demo.triggers" - }, { - pId: 12, - text: "bi.adaptive_table", - value: "demo.adaptive_table" - }, { - pId: 12, - text: "bi.table_tree", - value: "demo.table_tree" - }, { - pId: 12, - text: "bi.layer_tree_table", - value: "demo.layer_tree_table" - }]; \ No newline at end of file +}, { + pId: 3, + text: "bi.segment", + value: "demo.segment" +}]; \ No newline at end of file diff --git a/demo/js/config/core.js b/demo/js/config/core.js index bd8792d5b..6d83a0f9b 100644 --- a/demo/js/config/core.js +++ b/demo/js/config/core.js @@ -151,8 +151,8 @@ Demo.CORE_CONFIG = [{ value: "demo.layer_searcher" }, { pId: 102, - text: "bi.customtree", - value: "demo.customtree" + text: "bi.custom_tree", + value: "demo.custom_tree" }, { pId: 102, text: "bi.grid_view", diff --git a/demo/js/core/abstract/mvc.custom_tree.js b/demo/js/core/abstract/mvc.custom_tree.js new file mode 100644 index 000000000..b3088af63 --- /dev/null +++ b/demo/js/core/abstract/mvc.custom_tree.js @@ -0,0 +1,245 @@ +Demo.Func = BI.inherit(BI.Widget, { + props: { + baseCls: "demo-func" + }, + + _createDefaultTree: function () { + var TREEITEMS = [{id: -1, pId: -2, value: "根目录", open: true, type: "bi.plus_group_node", height: 25}, + {id: 1, pId: -1, value: "第一级目录1", type: "bi.plus_group_node", height: 25}, + {id: 11, pId: 1, value: "第二级文件1", type: "bi.single_select_item", height: 25}, + {id: 12, pId: 1, value: "第二级目录2", type: "bi.plus_group_node", height: 25}, + {id: 121, pId: 12, value: "第三级目录1", type: "bi.plus_group_node", height: 25}, + {id: 122, pId: 12, value: "第三级文件1", type: "bi.single_select_item", height: 25}, + {id: 1211, pId: 121, value: "第四级目录1", type: "bi.plus_group_node", height: 25}, + {id: 12111, pId: 1211, value: "第五级文件1", type: "bi.single_select_item", height: 25}, + {id: 2, pId: -1, value: "第一级目录2", type: "bi.plus_group_node", height: 25}, + {id: 21, pId: 2, value: "第二级目录3", type: "bi.plus_group_node", height: 25}, + {id: 22, pId: 2, value: "第二级文件2", type: "bi.single_select_item", height: 25}, + {id: 211, pId: 21, value: "第三级目录2", type: "bi.plus_group_node", height: 25}, + {id: 212, pId: 21, value: "第三级文件2", type: "bi.single_select_item", height: 25}, + {id: 2111, pId: 211, value: "第四级文件1", type: "bi.single_select_item", height: 25}]; + this.tree = BI.createWidget({ + type: "bi.custom_tree", + el: { + type: "bi.button_tree", + chooseType: 0, + layouts: [{ + type: "bi.vertical", + hgap: 30 + }] + }, + items: BI.deepClone(TREEITEMS) + }); + return this.tree; + }, + + _createAsyncTree: function () { + this.asyncTree = BI.createWidget({ + type: "bi.custom_tree", + itemsCreator: function (op, callback) { + if (!op.node) {//根节点 + callback([{ + "id": 1, + "pId": 0, + type: "bi.plus_group_node", + text: "test1", + value: 1, + height: 25, + isParent: true + }, { + "id": 2, + "pId": 0, + type: "bi.plus_group_node", + "text": "test2", + value: 1, + isParent: true, + open: true, + height: 25 + }]) + } else { + if (op.node.id == 1) { + callback([ + { + "id": 11, + "pId": 1, + type: "bi.plus_group_node", + "text": "test11", + value: 11, + height: 25, + isParent: true + }, + { + "id": 12, + "pId": 1, + type: "bi.single_select_item", + "text": "test12", + value: 12, + height: 35 + }, + { + "id": 13, + "pId": 1, + type: "bi.single_select_item", + "text": "test13", + value: 13, + height: 35 + }, + { + "id": 14, + "pId": 1, + type: "bi.single_select_item", + "text": "test14", + value: 14, + height: 35 + }, + { + "id": 15, + "pId": 1, + type: "bi.single_select_item", + "text": "test15", + value: 15, + height: 35 + }, + { + "id": 16, + "pId": 1, + type: "bi.single_select_item", + "text": "test16", + value: 16, + height: 35 + }, + {"id": 17, "pId": 1, type: "bi.single_select_item", "text": "test17", value: 17, height: 35} + ]) + } else if (op.node.id == 2) { + callback([{ + "id": 21, + "pId": 2, + type: "bi.single_select_item", + "text": "test21", + value: 21, + height: 35 + }, + { + "id": 22, + "pId": 2, + type: "bi.single_select_item", + "text": "test22", + value: 22, + height: 35 + }]) + } else if (op.node.id == 11) { + callback([{ + "id": 111, + "pId": 11, + type: "bi.single_select_item", + "text": "test111", + value: 111, + height: 35 + }]) + } + } + }, + el: { + type: "bi.loader", + next: false, + el: { + type: "bi.button_tree", + chooseType: 0, + layouts: [{ + type: "bi.vertical", + hgap: 30, + vgap: 0 + }] + } + } + }); + return this.asyncTree; + }, + + render: function () { + var self = this; + BI.createWidget({ + type: "bi.grid", + columns: 2, + rows: 1, + element: this, + items: [{ + column: 0, + row: 0, + el: { + type: "bi.vtape", + items: [ + { + el: this._createDefaultTree() + }, + { + el: { + type: "bi.center", + hgap: 10, + items: [{ + type: "bi.text_button", + cls: "mvc-button layout-bg2", + text: "getValue", + height: 30, + handler: function () { + BI.Msg.alert("", JSON.stringify(self.tree.getValue())); + } + }, { + type: "bi.text_button", + cls: "mvc-button layout-bg2", + text: "getNodeByValue(第一级目录1)", + height: 30, + handler: function () { + BI.Msg.alert("", "节点名称为: " + self.tree.getNodeByValue("第一级目录1").getValue()); + } + }] + }, + height: 30 + } + ] + } + }, { + column: 1, + row: 0, + el: { + type: "bi.vtape", + items: [ + { + type: "bi.label", + text: "异步加载数据", + height: 30 + }, + { + el: this._createAsyncTree() + }, + { + el: { + type: "bi.center", + hgap: 10, + items: [{ + type: "bi.text_button", + cls: "mvc-button layout-bg2", + text: "getValue", + height: 30, + handler: function () { + BI.Msg.alert("", JSON.stringify(self.asyncTree.getValue())); + } + }, { + type: "bi.text_button", + cls: "mvc-button layout-bg2", + text: "getNodeById(11)", + height: 30, + handler: function () { + BI.Msg.alert("", "节点名称为: " + (self.asyncTree.getNodeById(11) && self.asyncTree.getNodeById(11).getText())); + } + }] + }, + height: 30 + } + ] + } + }] + }) + } +}); +$.shortcut("demo.custom_tree", Demo.Func); \ No newline at end of file diff --git a/dist/base.js b/dist/base.js index 4e032f162..f47bfd398 100644 --- a/dist/base.js +++ b/dist/base.js @@ -1438,13 +1438,13 @@ BI.ButtonTree = BI.inherit(BI.ButtonGroup, { var node; BI.any(this.buttons, function (i, item) { if (item.isEnabled()) { - if (item.getValue() === value) { - node = item; - return true; - } else if (BI.isFunction(item.getNodeByValue)) { + if (BI.isFunction(item.getNodeByValue)) { if (node = item.getNodeByValue(value)) { return true; } + } else if (item.attr("value") === value) { + node = item; + return true; } } }); @@ -2073,7 +2073,7 @@ BI.TreeView.EVENT_CHANGE = "EVENT_CHANGE"; BI.TreeView.EVENT_INIT = BI.Events.INIT; BI.TreeView.EVENT_AFTERINIT = BI.Events.AFTERINIT; -$.shortcut("bi.tree", BI.TreeView);/** +$.shortcut("bi.tree_view", BI.TreeView);/** * guy * 同步树 * @class BI.SyncTree diff --git a/dist/case.js b/dist/case.js index af3840251..704fdb1e5 100644 --- a/dist/case.js +++ b/dist/case.js @@ -9890,7 +9890,7 @@ BI.extend(BI.TableTree, { } }); -$.shortcut("bi.table_tree", BI.TableTree);/** +$.shortcut("bi.tree_table", BI.TableTree);/** * guy * 复选导航条 * Created by GUY on 2015/8/25. @@ -10344,7 +10344,7 @@ BI.SimpleTreeView = BI.inherit(BI.Widget, { var self = this, o = this.options; this.structure = new BI.Tree(); this.tree = BI.createWidget({ - type: "bi.tree", + type: "bi.tree_view", element: this, itemsCreator: function (op, callback) { var fn = function (items) { diff --git a/src/base/combination/tree.button.js b/src/base/combination/tree.button.js index 85afc684d..b4822e087 100644 --- a/src/base/combination/tree.button.js +++ b/src/base/combination/tree.button.js @@ -164,13 +164,13 @@ BI.ButtonTree = BI.inherit(BI.ButtonGroup, { var node; BI.any(this.buttons, function (i, item) { if (item.isEnabled()) { - if (item.getValue() === value) { - node = item; - return true; - } else if (BI.isFunction(item.getNodeByValue)) { + if (BI.isFunction(item.getNodeByValue)) { if (node = item.getNodeByValue(value)) { return true; } + } else if (item.attr("value") === value) { + node = item; + return true; } } }); diff --git a/src/base/tree/treeview.js b/src/base/tree/treeview.js index e38896200..17e84d100 100644 --- a/src/base/tree/treeview.js +++ b/src/base/tree/treeview.js @@ -504,4 +504,4 @@ BI.TreeView.EVENT_CHANGE = "EVENT_CHANGE"; BI.TreeView.EVENT_INIT = BI.Events.INIT; BI.TreeView.EVENT_AFTERINIT = BI.Events.AFTERINIT; -$.shortcut("bi.tree", BI.TreeView); \ No newline at end of file +$.shortcut("bi.tree_view", BI.TreeView); \ No newline at end of file diff --git a/src/case/table/table.tree.js b/src/case/table/table.tree.js index 4d78a07c3..a53479066 100644 --- a/src/case/table/table.tree.js +++ b/src/case/table/table.tree.js @@ -327,4 +327,4 @@ BI.extend(BI.TableTree, { } }); -$.shortcut("bi.table_tree", BI.TableTree); \ No newline at end of file +$.shortcut("bi.tree_table", BI.TableTree); \ No newline at end of file diff --git a/src/case/tree/tree.simple.js b/src/case/tree/tree.simple.js index 6b4f1c2cb..677ee6e63 100644 --- a/src/case/tree/tree.simple.js +++ b/src/case/tree/tree.simple.js @@ -18,7 +18,7 @@ BI.SimpleTreeView = BI.inherit(BI.Widget, { var self = this, o = this.options; this.structure = new BI.Tree(); this.tree = BI.createWidget({ - type: "bi.tree", + type: "bi.tree_view", element: this, itemsCreator: function (op, callback) { var fn = function (items) {