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 } });
|
}
|