元数据
大约 2 分钟
获取元数据
获取文档中每个数据域元数据对象,包含:数据元编码,值,文本等结构化元数据。
getBindObject(id, true)
//使用以下方法获取单个控件的编码及值
let data = editor.getBindObject('maindiag', true)
//返回结果
data = {
    "maindiag": {
      "code": "HDSD00.02.049",
      "value": "M81410/6",
      "text": "转移性硬腺癌"
    }
}
//使用以下方法获取所有控件的编码及值
let data = editor.getBindObject(undefined, true)
//返回结果
{
    "maindiag": {
      "code": "HDSD00.02.049",
      "value": "M81410/6",
      "text": "转移性硬腺癌"
    },
    "datetime": {
      "code": "",
      "value": "2024-01-10",
      "text": "2024年01月10日"
    },
    ....
}
设置元数据
使用JSON对象设置每个数据域的元数据,包含:域(数据集),编码(数据元编码),值,文本等数据。
setBindObject(data, id, true)
let oneObject =  {
    "maindiag": {
      "code": "HDSD00.02.049",
      "value": "M81410/6",
      "text": "转移性硬腺癌"
    }
}
//使用以下方法设置单个控件的编码及值
editor.setBindObject(oneObject, 'maindiag', true)
let allObject =
{
    "maindiag": {
      "code": "HDSD00.02.049",
      "value": "M81410/6",
      "text": "转移性硬腺癌"
    },
    "datetime": {
      "code": "",
      "value": "2024-01-10",
      "text": "2024年01月10日"
    },
    ....
}
//使用以下方法设置所有控件的编码及值
editor.setBindObject(allObject, undefined, true)
表格数据
bindDataList()
- 插入表格控件
- 表格属性中设置标识 list
- 表格属性设置字段NUM name idNUM为保留属性名,会自动设置行号
- 使用 editor.setDataList() 方法绑定JSON对象(对象数组)到表格控件
//编辑器初始化
editor.init(option)
//加载病历文档
editor.loadUrl('/doc/100.html','100').then(function(){
    /** list 数据格式示例
        [
            {id '1111', name: 'aaa'},
            {id '2222', name: 'bbb'},
            {id '3333', name: 'ccc'}
        ]
    **/
    //表格绑定数据
    if(editor.$('#list').length > 0){
        $.get('/doc/list.json', (list)=>{
        editor.bindDataList('list',list)
        })
    }
}
修订内容
getRevision()
返回修订内容的JSON数组对象
editor.getRevision()
//返回对象
[
    {
        author:"修订者",
        date:"修订时间",
        orgin: "原始文本",
        text: "当前文本",
        diff: "文本比较后的HTML内容"
    }
]