一般新增记录会手动选,可是如果查看这条记录,那创建时选择的item要是check状态。
当前的json结构有点复杂,所以用不了JSON.stringify();
[
{
"id": "0",
"text": "DDL同步设置",
"value": "NULL",
"showcheck": true,
"isexpand": true,
"checkstate": 0,
"hasChildren": true,
"ChildNodes": [
{
"id": "1",
"text": "表",
"value": "NULL",
"showcheck": true,
"isexpand": false,
"checkstate": 0,
"hasChildren": true,
"ChildNodes": [
{
"id": "101",
"text": "创建(Create Table XXX(xx type))",
"value": "CREATE TABLE",
"showcheck": true,
"isexpand": false,
"checkstate": 0,
"hasChildren": false,
"complete": true
},
{
"id": "102",
"text": "删除(Drop Table XXX)",
"value": "DROP TABLE",
"showcheck": true,
"isexpand": false,
"checkstate": 0,
"hasChildren": false,
"complete": true
},
{
"id": "103",
"text": "更新(Alter Table XXX)",
"value": "ALTER TABLE",
"showcheck": true,
"isexpand": false,
"checkstate": 0,
"hasChildren": false,
"complete": true
},
{
"id": "104",
"text": "添加列(Alter Table XXX add column xx)",
"value": "TABLE ADD",
"showcheck": true,
"isexpand": false,
"checkstate": 0,
"hasChildren": false,
"complete": true
},
{
"id": "105",
"text": "删除列(Alter Table XXX drop column xx)",
"value": "TABLE DROP",
"showcheck": true,
"isexpand": false,
"checkstate": 0,
"hasChildren": false,
"complete": true
},
{
"id": "106",
"text": "标记不可用列/列重命名(Alter Table XXX set unused(xx);Alter Table XXX rename column xx to xx)",
"value": "TABLE MODIFY",
"showcheck": true,
"isexpand": false,
"checkstate": 0,
"hasChildren": false,
"complete": true
},
{
"id": "107",
"text": "表重命名(Alter Table XXX rename to XX)",
"value": "TABLE RENAME",
"showcheck": true,
"isexpand": false,
"checkstate": 0,
"hasChildren": false,
"complete": true
},
{
"id": "108",
"text": "清空表/截断(子)分区(Truncate Table XXX / Alter Table XXX truncate [sub]partiotion xx)",
"value": "TRUNCATE TABLE",
"showcheck": true,
"isexpand": false,
"checkstate": 0,
"hasChildren": false,
"complete": true
},
{
"id": "109",
"text": "移动(子)分区表(Alter Table XXX move [sub][partition] tablespace)",
"value": "MOVE TABLE",
"showcheck": true,
"isexpand": false,
"checkstate": 0,
"hasChildren": false,
"complete": true
},
{
"id": "110",
"text": "表/列添加说明(Comment on table/column XXX is xxx)",
"value": "CREATE COMMENT",
"showcheck": true,
"isexpand": false,
"checkstate": 0,
"hasChildren": false,
"complete": true
}
],
"complete": true
},
{
"id": "2",
"text": "分区表",
"value": "NULL",
"showcheck": true,
"isexpand": false,
"checkstate": 0,
"hasChildren": true,
"ChildNodes": [
{
"id": "201",
"text": "添加分区(Alter Table XXX add partition xxx)",
"value": "ADD PARTITION",
"showcheck": true,
"isexpand": false,
"checkstate": 0,
"hasChildren": false,
"complete": true
},
{
"id": "202",
"text": "删除分区(Alter Table XXX drop [sub]partition xx)",
"value": "DROP SUBPARTITION",
"showcheck": true,
"isexpand": false,
"checkstate": 0,
"hasChildren": false,
"complete": true
},
{
"id": "203",
"text": "添加子分区(Alter Table XXX modify partition xxx add subpartition xx)",
"value": "ADD SUBPARTITION",
"showcheck": true,
"isexpand": false,
"checkstate": 0,
"hasChildren": false,
"complete": true
},
{
"id": "204",
"text": "删除子分区(Alter Table XXX modify partition xxx drop subpartition xx)",
"value": "DROP SUBPARTITION",
"showcheck": true,
"isexpand": false,
"checkstate": 0,
"hasChildren": false,
"complete": true
},
{
"id": "205",
"text": "分裂分区(Alter Table XXX split partition xxx into (partition xx1 ..,partition xx2 ..)",
"value": "SPLIT PARTITION",
"showcheck": true,
"isexpand": false,
"checkstate": 0,
"hasChildren": false,
"complete": true
},
{
"id": "206",
"text": "分裂子分区(Alter Table XXX split subpartition xxx into (subpartition xx1 ..,subpartition xx2 ..)",
"value": "SPLIT SUBPARTITION",
"showcheck": true,
"isexpand": false,
"checkstate": 0,
"hasChildren": false,
"complete": true
},
{
"id": "207",
"text": "合并子分区(Alter Table XXX merge subpartition xx1,xx2 into subpartition xxx)",
"value": "MERGE SUBPARTITION",
"showcheck": true,
"isexpand": false,
"checkstate": 0,
"hasChildren": false,
"complete": true
},
{
"id": "208",
"text": "合并分区(Alter Table XXX merge partition xx1,xx2 into partition xxx)",
"value": "MERGE PARTITION",
"showcheck": true,
"isexpand": false,
"checkstate": 0,
"hasChildren": false,
"complete": true
},
{
"id": "209",
"text": "交换(子)分区(Alter Table XXX exchange [sub]partition xx with table XXX2)",
"value": "SWAP",
"showcheck": true,
"isexpand": false,
"checkstate": 0,
"hasChildren": false,
"complete": true
},
{
"id": "210",
"text": "修改分区(Alter Table XXX modify [sub]partition values(..))",
"value": "ALTER LVAL",
"showcheck": true,
"isexpand": false,
"checkstate": 0,
"hasChildren": false,
"complete": true
},
{
"id": "211",
"text": "修改子分区模板属性(Alter Table XXX set subpartition template ...)",
"value": "SET TEMPLATE",
"showcheck": true,
"isexpand": false,
"checkstate": 0,
"hasChildren": false,
"complete": true
}
],
"complete": true
},
{
"id": "3",
"text": "索引",
"value": "NULL",
"showcheck": true,
"isexpand": false,
"checkstate": 0,
"hasChildren": true,
"ChildNodes": [
{
"id": "301",
"text": "创建(Create Index XXX)",
"value": "CREATE INDEX",
"showcheck": true,
"isexpand": false,
"checkstate": 0,
"hasChildren": false,
"complete": true
},
{
"id": "302",
"text": "删除(Drop Index XXX)",
"value": "DROP INDEX",
"showcheck": true,
"isexpand": false,
"checkstate": 0,
"hasChildren": false,
"complete": true
},
{
"id": "303",
"text": "修改(Alter Index XXX [rebuild][unusable][enable/disable][nocompress/compress]...)",
"value": "ALTER INDEX",
"showcheck": true,
"isexpand": false,
"checkstate": 0,
"hasChildren": false,
"complete": true
},
{
"id": "304",
"text": "重命名(Alter Index XXX rename to XXX2)",
"value": "RENAME INDEX",
"showcheck": true,
"isexpand": false,
"checkstate": 0,
"hasChildren": false,
"complete": true
}
],
"complete": true
},
{
"id": "4",
"text": "自定义类型",
"value": "NULL",
"showcheck": true,
"isexpand": false,
"checkstate": 0,
"hasChildren": true,
"ChildNodes": [
{
"id": "401",
"text": "创建(Create or replace type[ body] XXX)",
"value": "CREATE TYPE",
"showcheck": true,
"isexpand": false,
"checkstate": 0,
"hasChildren": false,
"complete": true
},
{
"id": "402",
"text": "删除(Drop type[ body] XXX)",
"value": "DROP TYPE",
"showcheck": true,
"isexpand": false,
"checkstate": 0,
"hasChildren": false,
"complete": true
}
],
"complete": true
},
{
"id": "5",
"text": "聚集",
"value": "NULL",
"showcheck": true,
"isexpand": false,
"checkstate": 0,
"hasChildren": true,
"ChildNodes": [
{
"id": "501",
"text": "创建(Create Cluster XXX)",
"value": "CREATE CLUSTER",
"showcheck": true,
"isexpand": false,
"checkstate": 0,
"hasChildren": false,
"complete": true
},
{
"id": "502",
"text": "删除(Drop Cluster XXX)",
"value": "DROP CLUSTER",
"showcheck": true,
"isexpand": false,
"checkstate": 0,
"hasChildren": false,
"complete": true
}
],
"complete": true
},
{
"id": "6",
"text": "视图",
"value": "NULL",
"showcheck": true,
"isexpand": false,
"checkstate": 0,
"hasChildren": true,
"ChildNodes": [
{
"id": "601",
"text": "创建(Create or replace view XXX)",
"value": "CREATE VIEW",
"showcheck": true,
"isexpand": false,
"checkstate": 0,
"hasChildren": false,
"complete": true
},
{
"id": "602",
"text": "删除(Drop view XXX)",
"value": "DROP VIEW",
"showcheck": true,
"isexpand": false,
"checkstate": 0,
"hasChildren": false,
"complete": true
}
],
"complete": true
},
{
"id": "7",
"text": "同义词",
"value": "NULL",
"showcheck": true,
"isexpand": false,
"checkstate": 0,
"hasChildren": true,
"ChildNodes": [
{
"id": "701",
"text": "创建(Create or replace [public] synonym XXX for xxx)",
"value": "CREATE SYN",
"showcheck": true,
"isexpand": false,
"checkstate": 0,
"hasChildren": false,
"complete": true
},
{
"id": "702",
"text": "删除(Drop [public] synonym XXX [force])",
"value": "DROP SYN",
"showcheck": true,
"isexpand": false,
"checkstate": 0,
"hasChildren": false,
"complete": true
}
],
"complete": true
},
{
"id": "8",
"text": "约束",
"value": "NULL",
"showcheck": true,
"isexpand": false,
"checkstate": 0,
"hasChildren": true,
"ChildNodes": [
{
"id": "801",
"text": "创建(Alter Table XXX add [xxx] primary key/unique/foregin key/check)",
"value": "ADD CONSTRAINT",
"showcheck": true,
"isexpand": false,
"checkstate": 0,
"hasChildren": false,
"complete": true
},
{
"id": "802",
"text": "删除(Alter Table drop constraint xxx/primary key/...)",
"value": "DROP CONSTRAINT",
"showcheck": true,
"isexpand": false,
"checkstate": 0,
"hasChildren": false,
"complete": true
},
{
"id": "803",
"text": "修改/重命名(Alter Table XXX modify constraint xxx/primary key.. enable/disable;Alter table XXX rename constraint xxx to xxx2)",
"value": "ALTER CONSTRAINT",
"showcheck": true,
"isexpand": false,
"checkstate": 0,
"hasChildren": false,
"complete": true
}
],
"complete": true
},
{
"id": "9",
"text": "序列",
"value": "NULL",
"showcheck": true,
"isexpand": false,
"checkstate": 0,
"hasChildren": true,
"ChildNodes": [
{
"id": "901",
"text": "创建(Create sequence xxx)",
"value": "CREATE SEQUENCE",
"showcheck": true,
"isexpand": false,
"checkstate": 0,
"hasChildren": false,
"complete": true
},
{
"id": "902",
"text": "删除(Drop sequence xxx)",
"value": "DROP SEQUENCE",
"showcheck": true,
"isexpand": false,
"checkstate": 0,
"hasChildren": false,
"complete": true
},
{
"id": "903",
"text": "修改(Alter sequence xxx ..)",
"value": "ALTER SEQUENCE",
"showcheck": true,
"isexpand": false,
"checkstate": 0,
"hasChildren": false,
"complete": true
}
],
"complete": true
},
{
"id": "10",
"text": "角色",
"value": "NULL",
"showcheck": true,
"isexpand": false,
"checkstate": 0,
"hasChildren": true,
"ChildNodes": [
{
"id": "1001",
"text": "创建(Create user/role xxx [identified by ...])",
"value": "CREATE ROLE",
"showcheck": true,
"isexpand": false,
"checkstate": 0,
"hasChildren": false,
"complete": true
},
{
"id": "1002",
"text": "删除(Drop user/role xxx)",
"value": "DROP ROLE",
"showcheck": true,
"isexpand": false,
"checkstate": 0,
"hasChildren": false,
"complete": true
},
{
"id": "1003",
"text": "修改(Alter user/role identified by ...)",
"value": "ALTER ROLE",
"showcheck": true,
"isexpand": false,
"checkstate": 0,
"hasChildren": false,
"complete": true
}
],
"complete": true
},
{
"id": "11",
"text": "授权",
"value": "NULL",
"showcheck": true,
"isexpand": false,
"checkstate": 0,
"hasChildren": true,
"ChildNodes": [
{
"id": "1101",
"text": "用户授权(Grant dba/resource... to xxx])",
"value": "GRANT SYS",
"showcheck": true,
"isexpand": false,
"checkstate": 0,
"hasChildren": false,
"complete": true
},
{
"id": "1102",
"text": "表授权(Grant select/insert/delete.. on XXX to xxx)",
"value": "GRANT OBJ",
"showcheck": true,
"isexpand": false,
"checkstate": 0,
"hasChildren": false,
"complete": true
},
{
"id": "1103",
"text": "回收用户权限(Revoke dba/resource... from xxx)",
"value": "REVOKE SYS",
"showcheck": true,
"isexpand": false,
"checkstate": 0,
"hasChildren": false,
"complete": true
},
{
"id": "1104",
"text": "回收表权限(Revoke select/insert/delete.. on XXX from xxx)",
"value": "REVOKE OBJ",
"showcheck": true,
"isexpand": false,
"checkstate": 0,
"hasChildren": false,
"complete": true
}
],
"complete": true
},
{
"id": "12",
"text": "物化视图",
"value": "NULL",
"showcheck": true,
"isexpand": false,
"checkstate": 0,
"hasChildren": true,
"ChildNodes": [
{
"id": "1201",
"text": "创建存储日志(Create materialized view log on XXX)",
"value": "CREATE MVIEW LOG",
"showcheck": true,
"isexpand": false,
"checkstate": 0,
"hasChildren": false,
"complete": true
},
{
"id": "1202",
"text": "删除实体化视图日志(Drop materialized view log on XXX)",
"value": "DROP MVIEW LOG",
"showcheck": true,
"isexpand": false,
"checkstate": 0,
"hasChildren": false,
"complete": true
},
{
"id": "1203",
"text": "创建实体化视图(Create materialized view XXX)",
"value": "CREATE MVIEW",
"showcheck": true,
"isexpand": false,
"checkstate": 0,
"hasChildren": false,
"complete": true
},
{
"id": "1204",
"text": "删除实体化视图(Drop materialized view XXX)",
"value": "DROP MVIEW",
"showcheck": true,
"isexpand": false,
"checkstate": 0,
"hasChildren": false,
"complete": true
}
],
"complete": true
},
{
"id": "13",
"text": "JAVA",
"value": "NULL",
"showcheck": true,
"isexpand": false,
"checkstate": 0,
"hasChildren": true,
"ChildNodes": [
{
"id": "1301",
"text": "创建JAVA源(Create or replace and compile java source named ... as ...)",
"value": "CREATE JAVA",
"showcheck": true,
"isexpand": false,
"checkstate": 0,
"hasChildren": false,
"complete": true
},
{
"id": "1302",
"text": "删除JAVA源(Drop java source ...)",
"value": "DROP JAVA",
"showcheck": true,
"isexpand": false,
"checkstate": 0,
"hasChildren": false,
"complete": true
},
{
"id": "1303",
"text": "创建JAVA类(Create or replace java class bfile (...))",
"value": "CREATE CLASS",
"showcheck": true,
"isexpand": false,
"checkstate": 0,
"hasChildren": false,
"complete": true
},
{
"id": "1304",
"text": "删除JAVA类(Drop java class ...)",
"value": "DROP CLASS",
"showcheck": true,
"isexpand": false,
"checkstate": 0,
"hasChildren": false,
"complete": true
},
{
"id": "1305",
"text": "创建JAVA资源(Create or replace java resource named XXX using bfile(...))",
"value": "CREATE RESOURCE",
"showcheck": true,
"isexpand": false,
"checkstate": 0,
"hasChildren": false,
"complete": true
},
{
"id": "1306",
"text": "删除JAVA资源(Drop directory ...)",
"value": "DROP RESOURCE",
"showcheck": true,
"isexpand": false,
"checkstate": 0,
"hasChildren": false,
"complete": true
}
],
"complete": true
},
{
"id": "14",
"text": "profile文件",
"value": "NULL",
"showcheck": true,
"isexpand": false,
"checkstate": 0,
"hasChildren": true,
"ChildNodes": [
{
"id": "1401",
"text": "创建(Create profile ...)",
"value": "CREATE PROFILE",
"showcheck": true,
"isexpand": false,
"checkstate": 0,
"hasChildren": false,
"complete": true
},
{
"id": "1402",
"text": "删除(Drop profile ...)",
"value": "DROP PROFILE",
"showcheck": true,
"isexpand": false,
"checkstate": 0,
"hasChildren": false,
"complete": true
},
{
"id": "1403",
"text": "修改(Alter profile ...)",
"value": "ALTER PROFILE",
"showcheck": true,
"isexpand": false,
"checkstate": 0,
"hasChildren": false,
"complete": true
}
],
"complete": true
},
{
"id": "15",
"text": "分析表",
"value": "NULL",
"showcheck": true,
"isexpand": false,
"checkstate": 0,
"hasChildren": true,
"ChildNodes": [
{
"id": "1401",
"text": "收集统计信息(Analyze Table XXX [partition xxx][subpartition xx] compute statistics)",
"value": "ANALYZE TABLE",
"showcheck": true,
"isexpand": false,
"checkstate": 0,
"hasChildren": false,
"complete": true
},
{
"id": "1402",
"text": "删除统计信息(Analyze Table XXX [partition xxx][subpartition xx] delete statistics)",
"value": "ANALYZE TABLE DELETE",
"showcheck": true,
"isexpand": false,
"checkstate": 0,
"hasChildren": false,
"complete": true
}
],
"complete": true
},
{
"id": "16",
"text": "分析索引",
"value": "NULL",
"showcheck": true,
"isexpand": false,
"checkstate": 0,
"hasChildren": true,
"ChildNodes": [
{
"id": "1601",
"text": "收集统计信息(Analyze Index XXX [partition xxx][subpartition xx] compute statistics)",
"value": "ANALYZE INDEX",
"showcheck": true,
"isexpand": false,
"checkstate": 0,
"hasChildren": false,
"complete": true
},
{
"id": "1602",
"text": "删除统计信息(Analyze Index XXX [partition xxx][subpartition xx] delete statistics)",
"value": "ANALYZE INDEX DELETE",
"showcheck": true,
"isexpand": false,
"checkstate": 0,
"hasChildren": false,
"complete": true
}
],
"complete": true
},
{
"id": "17",
"text": "存储过程",
"value": "NULL",
"showcheck": true,
"isexpand": false,
"checkstate": 0,
"hasChildren": true,
"ChildNodes": [
{
"id": "1701",
"text": "创建(Create or replace function/package[ body]/trigger/procedure/type[ body] XXX)",
"value": "CREATE PROC",
"showcheck": true,
"isexpand": false,
"checkstate": 0,
"hasChildren": false,
"complete": true
},
{
"id": "1702",
"text": "删除(Drop function/package[ body]/trigger/procedure/type[ body] XXX)",
"value": "DROP PROC",
"showcheck": true,
"isexpand": false,
"checkstate": 0,
"hasChildren": false,
"complete": true
},
{
"id": "1703",
"text": "修改(Alter function/package[ body]/trigger/procedure/type[ body] XXX compile)",
"value": "ALTER PROC",
"showcheck": true,
"isexpand": false,
"checkstate": 0,
"hasChildren": false,
"complete": true
}
],
"complete": true
}
]
}
]
======================================================================
function getCkAndHalfCk_2(items, c, fn) {
for (var i = 0, l = items.length; i < l; i++) {
(items[i].showcheck == true && (items[i].checkstate == 1 || items[i].checkstate == 2)) && c.push(fn(items[i]));
if (items[i].ChildNodes != null && items[i].ChildNodes.length > 0) {
getCkAndHalfCk(items[i], c, fn);
}
}
}
me[0].t = {
...
getSelectedTexts: function() {
var s = [];
getCkAndHalfCk_2(treenodes, s, function(item) {
if(item.hasChildren){
var obj = {};
obj['id'] = item.id;
obj['value'] = item.value;
obj['checkstate'] = item.checkstate;
obj['text'] = item.text;
obj['hasChildren'] = item.hasChildren;
obj['showcheck'] = item.showcheck;
obj['isexpand'] = item.isexpand;
obj['complete'] = item.complete;
var ChildNodes = [];
for(var i=0;i<item.ChildNodes.length;i++){
var node = {};
node['id'] = item.ChildNodes[i].id;
node['value'] = item.ChildNodes[i].value;
node['showcheck'] = item.ChildNodes[i].showcheck;
node['isexpand'] = true;
node['hasChildren'] = item.ChildNodes[i].hasChildren;
node['checkstate'] = item.ChildNodes[i].checkstate;
node['text'] = item.ChildNodes[i].text;
if(item.ChildNodes[i].hasChildren){
var node_arr = [];
for(var j=0;j<item.ChildNodes[i].ChildNodes.length;j++){
var node_child = {};
node_child['id'] = item.ChildNodes[i].ChildNodes[j].id;
node_child['value'] = item.ChildNodes[i].ChildNodes[j].value;
node_child['showcheck'] = item.ChildNodes[i].ChildNodes[j].showcheck;
node_child['isexpand'] = item.ChildNodes[i].ChildNodes[j].isexpand;
node_child['hasChildren'] = item.ChildNodes[i].ChildNodes[j].hasChildren;
node_child['complete'] = item.ChildNodes[i].ChildNodes[j].complete;
node_child['checkstate'] = item.ChildNodes[i].ChildNodes[j].checkstate;
node_child['text'] = item.ChildNodes[i].ChildNodes[j].text;
node_arr.push(node_child);
}
node['ChildNodes'] = node_arr;
}
ChildNodes.push(node);
}
obj['ChildNodes'] = ChildNodes;
}
return obj; });
return s;
}
};
return me;
};
已解决,改了点插件,for ,json,自己构造json.
插件里处理过json,所以不能JSON.stringify().
目前只有这一个插件的data的json格式适合我的需求,ztree的json不是太适合。