刘光辉
5 小时以前 cf11e63b659afcc9792ab3e395f1b45d844431a8
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import type { OfficeDocumentFile } from '#/components/GlobalOfficeDocumentModal/types';
 
import { defHttp } from '#/api/request';
 
enum Api {
  Prefix = '/api/biz/onlyoffice',
}
 
export interface OnlyOfficeConfigQuery {
  /** 业务归属记录 id,与 bizModule 一起用于权限判定与回调时反查上下文 */
  bizDataId?: string;
  /** 业务归属模块 */
  bizModule?: string;
  /** ONLYOFFICE 插件业务场景;为空时后端强制只读 */
  bizScene?: string;
  /** jnpf-file 的文件标识,annex 类型下即磁盘文件名 */
  fileId: string;
  /** 原始文件名,后端靠扩展名推导 documentType 并判断能否编辑 */
  fileName: string;
  /** 期望模式;qianpiye 是无插件的签批页编辑模式,后端最终仍会签发 edit/view */
  mode?: 'edit' | 'qianpiye' | 'review' | 'view' | 'viewComments';
  /** 模板体检定位的内容控件 Tag,仅 ELN 标注场景使用 */
  locateControlTag?: string;
  /** 模板体检修复入口指定的绑定,仅在 ELN 模板标注场景透传 */
  repairBindingId?: string;
  /** 文件存储类型,默认 annex */
  fileType?: string;
  /** DMS READ 裁决成功后签发的短期预览票据 */
  dmsAccessTicket?: string;
}
 
/**
 * 取编辑器配置。返回值直接喂 `new DocsAPI.DocEditor(id, config)`,不要在前端拼装或改写——
 * 其中的 token 是后端对整份 config 的 HS256 签名,DS 会验签,改任何一个字段都会被拒。
 * 前端只能追加 `events`(函数不参与序列化,不在签名范围内)。
 */
export function getOnlyOfficeConfig(data: OnlyOfficeConfigQuery, options?: { errorMessageMode: 'none' }) {
  return defHttp.get({ url: `${Api.Prefix}/config`, data }, options);
}
 
export interface OnlyOfficeSaveStatus {
  /** 仅签批页另存为成功后返回;可直接写回上传组件字段。 */
  file?: OfficeDocumentFile;
  lastSaveTime: null | number;
  sessionStatus: 'EDITING' | 'IDLE' | 'PUBLISHING' | 'RECORD_HISTORICAL' | 'RECORD_RETIRING' | 'SAVE_FAILED' | 'SAVING' | 'UNKNOWN';
  version: number;
}
 
export function getOnlyOfficeSaveStatus(fileId: string, fileType: string) {
  return defHttp.get<OnlyOfficeSaveStatus>({ url: `${Api.Prefix}/save-status`, data: { fileId, fileType } });
}