Home > DMT_Schematic > reorderSchematicPages
DMT_Schematic.reorderSchematicPages() method
此 API 当前处于 BETA 预览状态,希望得到开发者的反馈。它的任何功能都可能在接下来的开发进程中被修改,请不要将它用于任何正式环境。
重新排序原理图图页
签名
typescript
function reorderSchematicPages(
schematicUuid: string,
schematicPageItemsArray: Array<IDMT_SchematicPageItem>,
): Promise<boolean>;1
2
3
4
2
3
4
参数名
参数 | 类型 | 描述 |
|---|---|---|
schematicUuid | string | 执行排序的图页所关联的原理图 UUID |
schematicPageItemsArray | Array<IDMT_SchematicPageItem> | 所有原理图图页属性的数组 |
返回值
Promise<boolean>
排序操作是否成功
备注
此处源原理图图页属性的数组需要通过 DMT_Schematic.getAllSchematicPagesInfo() 或其它上游方法取得,完成数组排序后传入
示例
javascript
// 1. 创建专用测试原理图(自带图页 p1)并再追加两页,凑出可排序的页序列
const schematicUuid = await eda.dmt_Schematic.createSchematic();
await new Promise(r => setTimeout(r, 1500));
await eda.dmt_Schematic.createSchematicPage(schematicUuid);
await new Promise(r => setTimeout(r, 1500));
await eda.dmt_Schematic.createSchematicPage(schematicUuid);
await new Promise(r => setTimeout(r, 1500));
// 2. 从上游接口取得该原理图的全部图页,输出当前顺序
const allPages = await eda.dmt_Schematic.getAllSchematicPagesInfo();
const myPages = allPages.filter(p => p.parentSchematicUuid === schematicUuid);
console.log('orderBefore:', myPages.map(p => p.name).join(' -> '));
// 3. 反转页序列后传入,执行重排
const reversed = [...myPages].reverse();
const reorderOk = await eda.dmt_Schematic.reorderSchematicPages(schematicUuid, reversed);
console.log('reorderOk:', reorderOk);
// 4. 等 1.5s 同步,回读当前页顺序
await new Promise(r => setTimeout(r, 1500));
const after = await eda.dmt_Schematic.getSchematicInfo(schematicUuid);
console.log('orderAfter:', (after?.page || []).map(p => p.name).join(' -> '));
// 5. 清理测试原理图,保持工程整洁
await new Promise(r => setTimeout(r, 1000));
const deleted = await eda.dmt_Schematic.deleteSchematic(schematicUuid);
console.log('deleted:', deleted);1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27