Knowledge Base
Asynchronous binding
Since the amount of data in the knowledge base is usually large, the default method is to initialize the main directory asynchronously, click the directory to expand the node, and then load the data asynchronously.
Typical configuration examples for asynchronous loading are as follows:
let option = {
...
dictionary: [ //Knowledge base
{name: 'Signs', isParent:true, treeUrl:'/dict?category=10'},
{name: 'Symptom', isParent:true, treeUrl:'/dict?category=20'},
{name: 'Health Information Data Element', isParent:true, treeUrl:'/dict?category=40'},
{name: 'Electronic Medical Record Dataset', isParent:true, treeUrl:'/dict?category=50'},
{name: 'National Medical Insurance Standard', isParent:true, treeUrl:'/dict?category=80'},
{name: 'Provincial Data Platform Standard', isParent:true, treeUrl:'/dict?category=90'},
],
dictSetting:{ //Knowledge base configuration
simpleData: true, //Whether to use a simple list data structure [{id, pid, ....}, {}, ...]
itemUrl:'/dictitem'//Dictionary option URL
}
...
}
name:'Signs'
node display nameisParent:true
node directory, set to false and cannot expand subdirectories`treeUrl:'/dict?category=10'' The data interface address after the node directory is expanded
itemUrl:'/dictitem'
Click the node with detailed options to get the interface address of the detailed optionsitemUrl can be configured in dictSetting or dictionary. The option interface path can be defined for a specific directory. For example:
[{name: 'Signs', isParent:true, treeUrl:'/dict?category=10'}]
simpleData: true
Knowledge base node data can be provided in the array format of[{id, pid, ....}]
, without the need to provide assigned multi-level structure data in the background[{id, pid, children: [ ....]}]
, reduce the complexity of background data
*The data format returned by the treeUrl interface: id, pid, style, name must be provided
- style types are
text, num, date, time, list, check, radio
[
{
"id": 695,
"pid": 0,
"category": "20",
"style": null,
"code": null,
"name": "pediatrics",
"en_name": null,
"domain": null,
"len": null
},
{
"id": 696,
"pid": 695,
"category": "20",
"style": "list",
"code": "675",
"name": "fever",
"en_name": null,
"domain": null,
"len": null
},
{
"id": 697,
"pid": 695,
"category": "20",
"style": "list",
"code": "676",
"name": "Incentive",
"en_name": null,
"domain": null,
"len": null
}
]
- itemUrl interface returns data format: text, value must be provided
[
{
"text": "Steady gait",
"value": "1"
},
{
"text": "Unsteady gait",
"value": "2"
},
{
"text": "Spastic hemiplegia",
"value": "3"
},
{
"text": "Intermittent claudication",
"value": "4"
}
]
Synchronous binding
- Set an empty array in the option configuration
let option = {
...
dictionary: [], //Set an empty array
dictSetting:{ //Knowledge base configuration
simpleData: true, //Whether to use a simple list data structure [{id, pid, ....}, {}, ...]
itemUrl:'/dictitem'//Dictionary option URL
}
...
}
- Obtain the editor object after the editor initialization is completed
//Get node data
let dictionary =
[
{
"id": 1,
"pid": 0,
"category": "20",
"style": null,
"code": null,
"name": "pediatrics",
"en_name": null,
"domain": null,
"len": null
},
{
"id": 2,
"pid": 1,
"category": "20",
"style": "list",
"code": "675",
"name": "Fever",
"en_name": null,
"domain": null,
"len": null
},
{
"id": 3,
"pid": 1,
"category": "20",
"style": "list",
"code": "676",
"name": "Incentive",
"en_name": null,
"domain": null,
"len": null
}
...
]
//Initialize knowledge base tree nodes
editor.initDict(dictionary)
Since the knowledge base uses the zTree plug-in, you can further refer to zTree API Documentation