DDeiFile
DDeiFile是代表一个设计文件,一个文件含有多个DDeiSheet(页签)。 DDeiFile实例包含了一个文件的所有数据,在获取后可以通过它访问其他内容。DDeiEditor中的files属性记录了当前打开的文件列表。
一个DDeiEditor实例至少包含一个DDeiFile实例。
本篇最后提供的示例可以在文档中直接预览。
属性
| 属性名 | 说明 | 数据类型 | 静态 | 默认值 | 备注 |
|---|---|---|---|---|---|
| id | 文件ID | string | 否 | ||
| unicode | 唯一编号 | string | 否 | 系统生成 | 自动编码 |
| name | 文件的名称,不包含扩展名 | string | 否 | ||
| desc | 文件的描述 | string | 否 | [] | |
| extData | 额外数据,存储额外的业务关键信息 | object | 否 | ||
| state | 状态 | DDeiFileState | 否 | NONE | |
| active | 激活 | DDeiActiveType | 否 | NONE | |
| publish | 发布 | string | 否 | 0 | 0否/1是 |
| lastUpdateTime | 最后修改时间 | number | 否 | 当前时间 | 毫秒数字 |
| path | 文件的完整路径 | string | 否 | 0 | 包含了目录的路径 |
| sheets | 页签集合 | DDeiSheet[] | 否 | ||
| currentSheetIndex | 当前所在页签 | number | 否 | -1 | |
| histroy | 操作日志 | object[] | 否 | [] | 用于保存、撤销和恢复 |
| modelNumber | 模型数量 | number | 否 | 0 | |
| modelType | 模型类型 | string | 否 | DDeiFile |
方法
static loadFromJSON
将JSON转换为一个DDeiFile实例
参数
| 参数名 | 类型 | 范围 | 默认值 | 备注 |
|---|---|---|---|---|
| json | object | 文件JSON数据 | ||
| tempData | object | 用于初始化的数据: |
返回值
| 类型 | 备注 |
|---|---|
| DDeiFile | DDeiFile实例 |
toJSON
将DDeiFile实例转换为JSON对象
参数
无
返回值
| 类型 | 备注 |
|---|---|
| JSON | 包含了DDeiFile所有信息的JSON对象 |
calModelNumber
计算并返回当前文件的模型总数量
参数
无
返回值
| 类型 | 备注 |
|---|---|
| number | 模型总数量 |
changeSheet
切换页签
参数
| 参数名 | 类型 | 范围 | 默认值 | 备注 |
|---|---|---|---|---|
| index | number | 页签下标 |
返回值
无
addHistroy
记录操作日志
参数
| 参数名 | 类型 | 范围 | 默认值 | 备注 |
|---|---|---|---|---|
| data | object | 文件数据 |
返回值
无
revokeHistroyData
根据日志撤销数据到上一步操作
参数
无
返回值
无
searchModels
根据属性搜索控件
参数
| 参数名 | 类型 | 范围 | 默认值 | 备注 |
|---|---|---|---|---|
| keywords | string | 搜索关键字 | ||
| attr | string | 属性名称 | ||
| isReg | boolean | false | 是否正则表达式 | |
| area | number | 1 | 搜索范围1本页/2本文档/3所有打开文件 | |
| matchCase | boolean | false | 区分大小写 | |
| matchAll | boolean | false | 全字匹配 |
返回值
| 类型 | 备注 |
|---|---|
| Array | 搜索结果,包含了满足所有条件的控件以及位置列表 |
示例
代码
vue
<script setup lang="ts">
import DDeiEditorView from "ddei-editor";
import {DDeiEditor,DDeiFile,DDeiCoreStandLayout,DDeiAbstractShape} from "ddei-editor";
import { defineComponent, markRaw,getCurrentInstance,ref } from "vue";
//获取主对象实例,代替this获取$refs
const {proxy} = getCurrentInstance()
const jsontext = ref("无JSON")
const options = markRaw({
config: {
"grid": 0, //网格线
"background": { color: "blue", opacity: 0.1 }, //背景色
initData: {
controls: [
{
model: "102010",
text: "初始化图形"
},
]
}
},
//配置扩展插件
extensions: [
//布局的配置
DDeiCoreStandLayout.configuration({
//配置插件
'top': [],
'middle': ['ddei-core-panel-canvasview'],
'bottom': [],
'left': [],
'right': []
}),
],
})
const getData = () => {
//获取编辑器
let editor = proxy.$refs["ddei_editor_api_2"].editor;
//获取JSON
let file:DDeiFile = editor.files[0]
jsontext.value = JSON.stringify(file.toJSON());
};
</script>
<template>
<button @click="getData" style="border:1px solid grey;margin-left:5px;padding:5px">获取JSON</button>
<div style="width:400px;height:400px;margin:100px auto;">
<DDeiEditorView :options="options" ref="ddei_editor_api_2" id="ddei_editor_api_2"></DDeiEditorView>
</div>
</template>效果预览
## 技术支持 QQ:3697355039 

微信公众号:ddei757 
