/** * 统一目录操作配置注册(全部 Tab 单树,IARDirOpsColumns) */ (function (global) { 'use strict'; if (!global.IARDirOpsColumns) { console.error('iar_dir_ops_columns_registry.js 需要先加载 iar_dir_ops_columns.js'); return; } function colCfg(opts) { const p = opts.prefix; return Object.assign({ dragOverClass: p + '-dir-drag-over', dirItemClass: p + '-dir-item', fileItemClass: p + '-file-item', toastClass: 'copy-success-toast', apiParamKey: 'subdir', legacy: opts.legacy || {}, }, opts); } function tabsColCfg(opsId, opts) { const p = opts.prefix; const fileListId = opts.fileListId; const subdirTabsId = opts.subdirTabsId; const subdirDefs = opts.subdirDefs || (opts.columns || []).map(function (c) { return { key: c.key, label: c.label || c.key }; }); const columns = subdirDefs.map(function (s) { return { key: s.key, label: s.label || s.key, listId: fileListId }; }); let cfg = colCfg(Object.assign({}, opts, { tabsMode: true, fileListId: fileListId, subdirTabsId: subdirTabsId, subdirTabClass: p + '-subdir-tab', subdirDropzoneClass: p + '-subdir-dropzone', subdirDataAttr: 'data-' + p + '-subdir', columns: columns, })); if (opts.enableDirSource !== false) { cfg = withDirSource(opsId, cfg); } return cfg; } function registerDirSource(opsId, modalId, extra) { if (!global.IARDirOpsDirSource || !modalId) return; IARDirOpsDirSource.register(opsId, Object.assign({ modalId: modalId, radioName: modalId + 'DirSource', hintId: modalId + 'DirSourceHint', progressWrapId: modalId + 'BackupProgressWrap', progressTextId: modalId + 'BackupProgressText', backupBtnSelector: '#' + modalId + ' .dir-ops-backup-btn', mainOnlyAttr: 'data-dir-main-only', }, extra || {})); } function withDirSource(opsId, cfg) { const apiFiles = cfg.apiFiles; if (apiFiles) { cfg.apiListUrl = function (id) { var url = apiFiles(id); if (!global.IARDirOpsDirSource) return url; var sep = url.indexOf('?') >= 0 ? '&' : '?'; return url + sep + 'root=' + encodeURIComponent(IARDirOpsDirSource.getRoot(opsId)); }; } cfg.apiBodyExtra = function () { return global.IARDirOpsDirSource ? IARDirOpsDirSource.apiRootExtra(opsId) : {}; }; const prevGuard = cfg.guardWrite; cfg.guardWrite = function () { if (global.IARDirOpsDirSource && IARDirOpsDirSource.guardWrite(opsId) === false) return false; if (typeof prevGuard === 'function') return prevGuard(); return true; }; const prevAfter = cfg.onAfterFetch; cfg.onAfterFetch = function (data) { if (global.IARDirOpsDirSource) IARDirOpsDirSource.updateMainOnlyButtons(opsId); if (typeof prevAfter === 'function') prevAfter(data); }; registerDirSource(opsId, cfg.modalId, cfg.dirSourceRegister); return cfg; } IARDirOpsColumns.register('newproj', tabsColCfg('newproj', { prefix: 'proj', modalId: 'projectDirectoryModal', fileListId: 'projectDirectoryFileList', subdirTabsId: 'projectDirectorySubdirTabs', getEntityId: function () { return global.currentEditProjectId; }, subdirDefs: [ { key: 'materials', label: '材料' }, { key: 'notices', label: '通知' }, ], wpsInputId: 'wpsOpenPathInputNewProj', wpsRadioName: 'projDirOpenWith', apiFiles: function (id) { return '/api/newproj/' + encodeURIComponent(id) + '/files'; }, apiParamKey: 'type', columnClipboardField: 'from_type', crossEntityField: 'from_newproj_id', clipScope: 'newproj', structureScope: 'newproj', presetRenameKind: 'newproj', subdirRootsKey: 'newProjSubdirRoots', filesCacheKey: 'newProjDirectoryFilesCache', dragStateKey: '_projDirDrag', entityLabel: '课题', copyToPageLabel: '课题申报', dirSourceRegister: { hintMain: '当前显示主目录。备份目录为 E:\\IntelliX\\personal\\personal_用户ID\\Bkup\\Rsch,与主目录在 Rsch 下的相对路径一致;备份视图下仅支持浏览、下载与在资源管理器中打开。', hintBackup: '正在查看备份目录 E:\\IntelliX\\personal\\personal_用户ID\\Bkup\\Rsch。修改文件请切换回「主目录」。', }, legacy: { openModal: 'openNewProjDirectoryModal', openRootDirectory: 'openNewProjRootDirectory', refresh: 'refreshProjDirectory', copyPath: 'copyProjPath', cutPath: 'cutProjPath', pastePath: 'pasteProjPath', copyFileName: 'copyProjFileName', browseFile: 'browseFile', downloadFile: 'downloadFile', addFile: 'addFile', addFileToRoot: 'addFileToRoot', deleteFile: 'deleteFile', backupFile: 'backupFile', renameFile: 'renameFile', renameFileWithTimestamp: 'renameFileWithTimestamp', openFileDirectory: 'openFileDirectory', openFile: 'openFile', createDirectory: 'createProjDirectory', copyDirectoryStructure: 'copyNewProjDirectoryStructure', pasteDirectoryStructure: 'pasteNewProjDirectoryStructure', openPresetRenameModal: 'openPresetRenameModalForNewProj', saveWpsOpenPath: 'saveWpsOpenPathFromInputNewProj', copyViewRelPath: 'copyProjSubdirColumnRelPath', copyViewAbsPath: 'copyProjSubdirColumnAbsPath', }, })); IARDirOpsColumns.register('personal_task', tabsColCfg('personal_task', { prefix: 'task', modalId: 'taskDirectoryModal', entityIdInputId: 'taskDirectoryModalTaskId', fileListId: 'taskDirectoryFileList', subdirTabsId: 'taskDirectorySubdirTabs', subdirDefs: [ { key: 'materials', label: '资料' }, { key: 'notices', label: '通知' }, ], wpsInputId: 'wpsOpenPathInputPersonalTask', wpsRadioName: 'taskDirOpenWith', apiFiles: function (id) { return '/api/task-assistant/personal-tasks/' + encodeURIComponent(id) + '/files'; }, apiParamKey: 'subdir', columnClipboardField: 'from_subdir', crossEntityField: 'from_task_id', clipScope: 'task', structureScope: 'personal_task', presetRenameKind: 'personal_task', subdirRootsKey: 'taskSubdirRoots', dragStateKey: '_taskDirDrag', entityLabel: '任务', copyToPageLabel: '个人任务', legacy: { openModal: 'openTaskDirectoryModal', openRootDirectory: 'openPersonalTaskRootDirectory', refresh: 'refreshTaskDirectory', copyPath: 'copyTaskPath', cutPath: 'cutTaskPath', pastePath: 'pasteTaskPath', copyFileName: 'copyTaskFileName', browseFile: 'browseTaskFile', downloadFile: 'downloadTaskFile', addFile: 'addFileToTask', addFileToRoot: 'addFileToTaskRoot', deleteFile: 'deleteTaskFile', backupFile: 'backupTaskFile', renameFile: 'renameTaskFile', renameFileWithTimestamp: 'renameTaskFileWithTimestamp', openFileDirectory: 'openTaskFileDirectory', openFile: 'openTaskFile', createDirectory: 'mkdirTaskDirectory', copyDirectoryStructure: 'copyPersonalTaskDirectoryStructure', pasteDirectoryStructure: 'pastePersonalTaskDirectoryStructure', openPresetRenameModal: 'openPresetRenameModalForTask', saveWpsOpenPath: 'saveWpsOpenPathFromInputPersonalTask', copyViewRelPath: 'copyTaskSubdirColumnRelPath', copyViewAbsPath: 'copyTaskSubdirColumnAbsPath', }, })); IARDirOpsColumns.register('organization_task', tabsColCfg('organization_task', { prefix: 'orgTask', modalId: 'taskDirectoryModal', entityIdInputId: 'taskDirectoryModalTaskId', fileListId: 'taskDirectoryFileList', subdirTabsId: 'taskDirectorySubdirTabs', subdirDefs: [ { key: 'materials', label: '资料' }, { key: 'notices', label: '通知' }, ], wpsInputId: 'wpsOpenPathInputOrgTask', wpsRadioName: 'orgTaskDirOpenWith', apiFiles: function (id) { return '/api/task-assistant/organization-tasks/' + encodeURIComponent(id) + '/files'; }, apiParamKey: 'subdir', columnClipboardField: 'from_subdir', crossEntityField: 'from_task_id', clipScope: 'organization_task', structureScope: 'organization_task', presetRenameKind: 'organization_task', subdirRootsKey: 'orgTaskSubdirRoots', dragStateKey: '_orgTaskDirDrag', entityLabel: '机构任务', copyToPageLabel: '机构任务', legacy: { openModal: 'openOrgTaskDirectoryModal', refresh: 'refreshOrgTaskDirectory', copyPath: 'copyOrgTaskPath', cutPath: 'cutOrgTaskPath', pastePath: 'pasteOrgTaskPath', copyFileName: 'copyOrgTaskFileName', browseFile: 'browseOrgTaskFile', downloadFile: 'downloadOrgTaskFile', addFile: 'addFileToOrgTask', addFileToRoot: 'addFileToOrgTaskRoot', deleteFile: 'deleteOrgTaskFile', backupFile: 'backupOrgTaskFile', renameFile: 'renameOrgTaskFile', renameFileWithTimestamp: 'renameOrgTaskFileWithTimestamp', openFileDirectory: 'openOrgTaskFileDirectory', openFile: 'openOrgTaskFile', createDirectory: 'mkdirOrgTaskDirectory', copyDirectoryStructure: 'copyOrgTaskDirectoryStructure', pasteDirectoryStructure: 'pasteOrgTaskDirectoryStructure', openPresetRenameModal: 'openPresetRenameModalForOrgTask', saveWpsOpenPath: 'saveWpsOpenPathFromInputOrgTask', copyViewRelPath: 'copyOrgTaskSubdirColumnRelPath', copyViewAbsPath: 'copyOrgTaskSubdirColumnAbsPath', }, })); IARDirOpsColumns.register('invoice', tabsColCfg('invoice', { prefix: 'invoice', modalId: 'invoiceDirectoryModal', entityIdInputId: 'invoiceDirectoryModalInvId', fileListId: 'invoiceDirectoryFileList', subdirTabsId: 'invoiceDirectorySubdirTabs', subdirDefs: [ { key: '发票附件', label: '发票附件' }, { key: '归档', label: '归档' }, { key: '其他', label: '其他' }, ], apiFiles: function (id) { return '/api/invoices/' + encodeURIComponent(id) + '/files'; }, clipScope: 'invoice', structureScope: 'invoice', presetRenameKind: 'invoice', subdirRootsKey: 'invoiceSubdirRoots', dragStateKey: '_invoiceDirDrag', entityLabel: '发票', copyToPageLabel: '发票开具与管理', features: { wps: false, backup: true, dirStructure: false, presetRename: true }, legacy: { openModal: 'openInvoiceDirectoryModal', refresh: 'refreshInvoiceDirectory', browseFile: 'browseInvoiceFile', downloadFile: 'downloadInvoiceFile', addFile: 'addInvoiceFile', addFileToRoot: 'addInvoiceFileToRoot', deleteFile: 'deleteInvoiceFile', backupFile: 'backupInvoiceFile', renameFile: 'renameInvoiceFile', renameFileWithTimestamp: 'renameInvoiceFileWithTimestamp', openFileDirectory: 'openInvoiceFileDirectory', createDirectory: 'createInvoiceDirectory', openPresetRenameModal: 'openPresetRenameModalForInvoice', copyViewRelPath: 'copyInvoiceSubdirColumnRelPath', copyViewAbsPath: 'copyInvoiceSubdirColumnAbsPath', }, })); IARDirOpsColumns.register('document', tabsColCfg('document', { prefix: 'document', modalId: 'documentDirectoryModal', entityIdInputId: 'documentDirectoryModalDocId', fileListId: 'documentDirectoryFileList', subdirTabsId: 'documentDirectorySubdirTabs', subdirDefs: [ { key: 'Code', label: 'Code' }, { key: 'Document', label: 'Document' }, { key: 'Other', label: 'Other' }, ], apiFiles: function (id) { return '/api/documents/' + encodeURIComponent(id) + '/files'; }, clipScope: 'document', structureScope: 'document', presetRenameKind: 'document', subdirRootsKey: 'documentSubdirRoots', dragStateKey: '_documentDirDrag', entityLabel: '文档', copyToPageLabel: '公文起草', features: { wps: false, backup: true, dirStructure: false, presetRename: true }, legacy: { openModal: 'openDocumentDirectoryModal', refresh: 'refreshDocumentDirectory', browseFile: 'browseDocumentFile', downloadFile: 'downloadDocumentFile', addFile: 'addDocumentFile', addFileToRoot: 'addDocumentFileToRoot', deleteFile: 'deleteDocumentFile', backupFile: 'backupDocumentFile', renameFile: 'renameDocumentFile', renameFileWithTimestamp: 'renameDocumentFileWithTimestamp', openFileDirectory: 'openDocumentDirectory', openFile: 'openDocumentFile', createDirectory: 'createDocumentDirectory', openPresetRenameModal: 'openPresetRenameModalForDocument', copyViewRelPath: 'copyDocumentSubdirColumnRelPath', copyViewAbsPath: 'copyDocumentSubdirColumnAbsPath', }, })); var PAPER_SUBDIR_DEFS = [ { key: '撰写版本', label: '撰写版本' }, { key: '投稿版本', label: '投稿版本' }, { key: '返修版本', label: '返修版本' }, { key: '录用版本', label: '录用版本' }, { key: '校对版本', label: '校对版本' }, { key: '核对版本', label: '核对版本' }, { key: '在线版本', label: '在线版本' }, { key: '正式版本', label: '正式版本' }, { key: '图表', label: '图表' }, { key: '其他', label: '其他' }, { key: 'Experiment', label: 'Experiment' }, ]; IARDirOpsColumns.register('paper', tabsColCfg('paper', { prefix: 'paper', modalId: 'paperDirectoryModal', fileListId: 'paperDirectoryFileList', subdirTabsId: 'paperDirectorySubdirTabs', getEntityId: function () { return global.currentEditPaperId; }, subdirDefs: PAPER_SUBDIR_DEFS, wpsInputId: 'wpsOpenPathInputPaper', wpsRadioName: 'paperDirOpenWith', apiFiles: function (id) { return '/api/newpaper/' + encodeURIComponent(id) + '/files'; }, crossEntityField: 'from_paper_id', clipScope: 'paper', structureScope: 'paper', presetRenameKind: 'paper', subdirRootsKey: 'paperSubdirRoots', filesCacheKey: 'paperDirectoryFilesCache', dragStateKey: '_paperDirDrag', entityLabel: '论文', copyToPageLabel: '论文写作', dirSourceRegister: { hintMain: '当前显示主目录。备份目录为 E:\\IntelliX\\personal\\personal_用户ID\\Bkup\\Rsch,与主目录在 Rsch 下的相对路径一致;备份视图下仅支持浏览、下载与在资源管理器中打开。', hintBackup: '正在查看备份目录 E:\\IntelliX\\personal\\personal_用户ID\\Bkup\\Rsch。修改文件请切换回「主目录」。', }, legacy: { openModal: 'openPaperDirectoryModal', openRootDirectory: 'openPaperRootDirectory', refresh: 'refreshPaperDirectory', copyPath: 'copyPaperPath', cutPath: 'cutPaperPath', pastePath: 'pastePaperPath', copyFileName: 'copyPaperFileName', browseFile: 'browsePaperFile', downloadFile: 'downloadPaperFile', addFile: 'addPaperFile', addFileToRoot: 'addPaperFileToRoot', deleteFile: 'deletePaperFile', backupFile: 'backupPaperFile', renameFile: 'renamePaperFile', renameFileWithTimestamp: 'renamePaperFileWithTimestamp', openFileDirectory: 'openPaperFileDirectory', openFile: 'openPaperFile', createDirectory: 'createPaperDirectory', copyDirectoryStructure: 'copyPaperDirectoryStructure', pasteDirectoryStructure: 'pastePaperDirectoryStructure', openPresetRenameModal: 'openPresetRenameModalForPaper', saveWpsOpenPath: 'saveWpsOpenPathFromInputPaper', copyViewRelPath: 'copyPaperSubdirColumnRelPath', copyViewAbsPath: 'copyPaperSubdirColumnAbsPath', }, })); IARDirOpsColumns.register('approval', tabsColCfg('approval', { prefix: 'project', modalId: 'projectDirectoryModal', entityIdInputId: 'projectDirectoryModalProjectId', fileListId: 'projectDirectoryFileList', subdirTabsId: 'projectDirectorySubdirTabs', subdirDefs: [ { key: 'Code', label: 'Code' }, { key: 'Document', label: 'Document' }, { key: 'Other', label: 'Other' }, { key: 'Experiment', label: 'Experiment' }, ], wpsInputId: 'wpsOpenPathInputApproval', wpsRadioName: 'approvalDirOpenWith', apiFiles: function (id) { return '/api/projects/' + encodeURIComponent(id) + '/files'; }, permissionCheck: function (perm, fn) { if (Array.isArray(perm) && typeof global.withProjectDirectoryPermissionsAnd === 'function') { return global.withProjectDirectoryPermissionsAnd(perm[0], perm[1], fn); } if (typeof global.withProjectDirectoryPermission === 'function') { return global.withProjectDirectoryPermission(perm, fn); } return fn(); }, permissions: { refresh: 'dir_browse', openRootDirectory: 'dir_browse', browseFile: 'dir_browse', downloadFile: 'dir_download', addFile: 'dir_add', addFileToRoot: 'dir_add', takePhoto: 'dir_add', deleteFile: 'dir_delete', renameFile: 'dir_add', renameFileWithTimestamp: 'dir_add', openFileDirectory: 'dir_open_dir', openFile: 'dir_open_file', createDirectory: 'dir_add', copyDirectoryStructure: 'dir_browse', pasteDirectoryStructure: 'dir_add', openPresetRenameModal: 'dir_add', pastePath: function () { if (!global.IARDirClipboard) return 'dir_add'; const clip = IARDirClipboard.load('project'); return (clip && clip.type === 'cut') ? ['dir_delete', 'dir_add'] : 'dir_add'; }, }, crossEntityField: 'from_project_id', clipScope: 'project', structureScope: 'project', presetRenameKind: 'project', subdirRootsKey: 'projectSubdirRoots', dragStateKey: '_approvalProjectDirDrag', entityLabel: '项目', copyToPageLabel: '项目审批', dirSourceRegister: { progressWrapId: 'projectDirectoryBackupProgressWrap', progressTextId: 'projectDirectoryBackupProgressText', hintMain: '当前显示主项目目录。备份目录为 E:\\IntelliX\\personal\\personal_用户ID\\Bkup\\Prj,与主目录在 Prj 下的相对路径一致;备份视图下仅支持浏览、下载与在资源管理器中打开。', hintBackup: '正在查看备份目录 E:\\IntelliX\\personal\\personal_用户ID\\Bkup\\Prj。修改文件请切换回「主项目目录」。', }, onAfterFetch: function (data) { var el = document.getElementById('projectDirectoryDirBase'); if (el) el.textContent = (data && data.listing_base) ? data.listing_base : '-'; }, legacy: { refresh: 'refreshProjectDirectory', }, })); var UNITGEN_TASK_SUBDIRS = [ 'Project', '预处理', '待测代码解析', '静态分析', '测试上下文构建', '检索增强(RAG)_向量构建', '检索增强(RAG)_向量检索', 'Prompt构建', '测试用例与断言生成', '后处理', '测试执行', '测试修复', '结果预览与导出', ]; var CURSIVE_DATASET_SUBDIRS = [ '原始数据集', '数据标注', '图像分割', '数据集重组', '数据预处理', '数据边缘平滑处理', '数据增强', '数据清洗', '数据标准化', ]; function parseTreeBySubdirs(data, subdirNames, opts) { function childrenOfSubdir(allRootItems, subdir, altKeys) { // 主目录名优先,再回退 altKeys;勿用 altKeys 覆盖主名(否则新「检索增强(RAG)_向量构建」永远匹配不到) const keys = [subdir]; (altKeys || []).forEach(function (k) { if (k && keys.indexOf(k) < 0) keys.push(k); }); if (subdir === 'Project' && keys.indexOf('项目') < 0) keys.push('项目'); let foundEmpty = null; for (let i = 0; i < keys.length; i++) { const key = keys[i]; const it = (allRootItems || []).find(function (x) { return x && x.type === 'directory' && (x.path === key || x.name === key); }); if (!it) continue; const kids = it.children || []; // 优先返回有内容的匹配(ensure 可能先建出空的新目录,旧数据仍在 alt 路径) if (kids.length) return kids; if (foundEmpty === null) foundEmpty = kids; } return foundEmpty; } const tree = (data && data.tree) || {}; const items = tree.items || []; const out = {}; (subdirNames || []).forEach(function (name) { const kids = childrenOfSubdir(items, name, opts && opts.altKeys && opts.altKeys[name]); out[name] = kids === null ? null : kids; }); if (opts && opts.dirBaseKey) { const el = document.getElementById(opts.dirBaseElId); const base = tree.listing_base || tree[opts.dirBaseKey] || ''; if (el && base) el.textContent = base; } return out; } IARDirOpsColumns.register('unitgen', tabsColCfg('unitgen', { prefix: 'unitgen', modalId: 'taskDirModal', entityIdInputId: 'dirTaskId', fileListId: 'taskDirFileList', subdirTabsId: 'taskDirSubdirTabs', subdirDefs: UNITGEN_TASK_SUBDIRS.map(function (n) { return { key: n, label: n }; }), apiFiles: function (id) { return '/api/unitgen/cases/tasks/' + encodeURIComponent(id) + '/files'; }, apiParamKey: 'path', openRootUsesPath: true, dirBaseElId: 'dirBase', selectedPathElId: 'dirSelectedPath', clipScope: 'unitgen', crossEntityField: 'from_task_id', structureScope: 'unitgen', presetRenameKind: 'unitgen', dragStateKey: '_unitgenDirDrag', entityLabel: '任务', copyToPageLabel: '单元测试案例', features: { wps: false, backup: true, dirStructure: true, presetRename: true }, onBeforeOpen: function (entityId) { return fetch('/api/unitgen/cases/tasks/' + encodeURIComponent(entityId) + '/directories/ensure', { method: 'POST' }) .then(function (r) { return r.json(); }) .catch(function () { return null; }); }, parseFilesData: function (data) { return parseTreeBySubdirs(data, UNITGEN_TASK_SUBDIRS, { dirBaseKey: 'task_dir', dirBaseElId: 'dirBase', altKeys: { // 旧任务曾用半角括号目录名;须作为回退,不能替换新目录名 '检索增强(RAG)_向量构建': ['检索增强(RAG)'], }, }); }, legacy: { refresh: 'unitgenRefreshDirs', openRootDirectory: 'openTaskRootDirectory', }, })); var DOCPROC_TASK_SUBDIRS = ['初始文档', '按行拆分', 'Excel转图片', 'Excel去重']; IARDirOpsColumns.register('docproc', tabsColCfg('docproc', { prefix: 'docproc', modalId: 'docprocTaskDirModal', entityIdInputId: 'docprocDirTaskId', fileListId: 'docprocTaskDirFileList', subdirTabsId: 'docprocTaskDirSubdirTabs', subdirDefs: DOCPROC_TASK_SUBDIRS.map(function (n) { return { key: n, label: n }; }), apiFiles: function (id) { return '/api/docproc/tasks/' + encodeURIComponent(id) + '/files'; }, apiParamKey: 'path', openRootUsesPath: true, dirBaseElId: 'docprocDirBase', selectedPathElId: 'docprocDirSelectedPath', clipScope: 'docproc', crossEntityField: 'from_task_id', structureScope: 'docproc', presetRenameKind: 'docproc', dragStateKey: '_docprocDirDrag', entityLabel: '文档处理任务', copyToPageLabel: '文档处理', features: { wps: false, backup: true, dirStructure: true, presetRename: true }, onBeforeOpen: function (entityId) { return fetch('/api/docproc/tasks/' + encodeURIComponent(entityId) + '/directories/ensure', { method: 'POST' }) .then(function (r) { return r.json(); }) .catch(function () { return null; }); }, parseFilesData: function (data) { return parseTreeBySubdirs(data, DOCPROC_TASK_SUBDIRS, { dirBaseKey: 'task_dir', dirBaseElId: 'docprocDirBase', }); }, legacy: { refresh: 'docprocRefreshDirs', }, })); IARDirOpsColumns.register('cursive', tabsColCfg('cursive', { prefix: 'cursive', modalId: 'datasetDirModal', entityIdInputId: 'dirDatasetId', fileListId: 'datasetDirFileList', subdirTabsId: 'datasetDirSubdirTabs', subdirDefs: CURSIVE_DATASET_SUBDIRS.map(function (n) { return { key: n, label: n }; }), apiFiles: function (id) { var base = String(global.CURSIVE_DIR_API_BASE || '/api/project/demo/cursive-recognition').replace(/\/+$/, ''); return base + '/datasets/' + encodeURIComponent(id) + '/files'; }, apiParamKey: 'path', openRootUsesPath: true, dirBaseElId: 'dirBase', selectedPathElId: 'dirSelectedPath', clipScope: 'cursive_dataset', crossEntityField: 'from_dataset_id', structureScope: 'cursive_dataset', presetRenameKind: 'cursive', dragStateKey: '_cursiveDirDrag', entityLabel: '数据集', copyToPageLabel: '草书识别', features: { wps: false, backup: true, dirStructure: true, presetRename: true }, onBeforeOpen: function (entityId) { var base = String(global.CURSIVE_DIR_API_BASE || '/api/project/demo/cursive-recognition').replace(/\/+$/, ''); return fetch(base + '/datasets/' + encodeURIComponent(entityId) + '/directories/ensure', { method: 'POST' }) .then(function (r) { return r.json(); }) .catch(function () { return null; }); }, parseFilesData: function (data) { return parseTreeBySubdirs(data, CURSIVE_DATASET_SUBDIRS, { dirBaseKey: 'dataset_dir', dirBaseElId: 'dirBase', }); }, legacy: { refresh: 'cursiveRefreshDatasetDirectory', openRootDirectory: 'openCursiveDatasetRootDirectory', }, })); var CATALOG_SUBDIRS = ['板书', 'PPT', '成绩单', '教案', '大纲和教学日历', '名单', '实验和作业', '试题', '真题', '其他']; var THESIS_SUBDIRS = ['过程材料', '初稿版本', '查重版本', '校内评审版本', '盲审版本', '答辩版本', '最终版本', '图表', '其他']; var OFFERING_SUBDIRS = ['实验档案', '试卷档案', '中期检查资料']; IARDirOpsColumns.register('catalog', tabsColCfg('catalog', { prefix: 'catalog', modalId: 'catalogDirectoryModal', entityIdInputId: 'catalogDirectoryModalCatalogId', fileListId: 'catalogDirectoryFileList', subdirTabsId: 'catalogDirectorySubdirTabs', subdirDefs: CATALOG_SUBDIRS.map(function (n) { return { key: n, label: n }; }), defaultSubdir: '板书', wpsInputId: 'wpsOpenPathInputCatalog', wpsRadioName: 'catalogDirOpenWith', apiFiles: function (id) { return '/api/course-catalog/' + encodeURIComponent(id) + '/files'; }, clipScope: 'course_catalog', structureScope: 'course_catalog', crossEntityField: 'from_catalog_id', presetRenameKind: 'course_catalog', subdirRootsKey: 'catalogSubdirRoots', dragStateKey: '_catalogDirDrag', entityLabel: '课程目录', copyToPageLabel: '课程目录管理', legacy: { openModal: 'openCatalogDirectoryModal', openRootDirectory: 'openCatalogRootDirectory', refresh: 'refreshCatalogDirectory', switchSubdir: 'switchCatalogDirectorySubdir', copyPath: 'copyCatalogPath', cutPath: 'cutCatalogPath', pastePath: 'pasteCatalogPath', copyFileName: 'copyCatalogFileName', copyViewRelPath: 'copyCatalogViewRelPath', copyViewAbsPath: 'copyCatalogViewAbsPath', browseFile: 'catalogBrowseFile', downloadFile: 'catalogDownloadFile', addFile: 'catalogAddFile', addFileToRoot: 'catalogAddFileToRoot', deleteFile: 'catalogDeleteFile', backupFile: 'catalogBackupFile', renameFile: 'renameCatalogFile', renameFileWithTimestamp: 'renameCatalogFileWithTimestamp', openFileDirectory: 'catalogOpenFileDirectory', createDirectory: 'createCatalogDirectory', copyDirectoryStructure: 'copyCatalogDirectoryStructure', pasteDirectoryStructure: 'pasteCatalogDirectoryStructure', openFile: 'catalogOpenFile', saveWpsOpenPath: 'saveWpsOpenPathFromInputCatalog', openPresetRenameModal: 'openPresetRenameModalForCatalog', }, })); IARDirOpsColumns.register('thesis', tabsColCfg('thesis', { prefix: 'thesis', modalId: 'thesisDirectoryModal', entityIdInputId: 'thesisDirectoryModalThesisId', fileListId: 'thesisDirectoryFileList', subdirTabsId: 'thesisDirectorySubdirTabs', subdirDefs: THESIS_SUBDIRS.map(function (n) { return { key: n, label: n }; }), defaultSubdir: '过程材料', wpsInputId: 'wpsOpenPathInputThesis', wpsRadioName: 'thesisDirOpenWith', apiFiles: function (id) { return '/api/theses/' + encodeURIComponent(id) + '/files'; }, clipScope: 'thesis', structureScope: 'thesis', crossEntityField: 'from_thesis_id', presetRenameKind: 'thesis', subdirRootsKey: 'thesisSubdirRoots', dragStateKey: '_thesisDirDrag', entityLabel: '学位论文', copyToPageLabel: '学位论文管理', legacy: { openModal: 'openThesisDirectoryModal', openRootDirectory: 'openThesisRootDirectory', refresh: 'refreshThesisDirectory', switchSubdir: 'loadThesisDirectorySubdir', copyPath: 'copyThesisPath', cutPath: 'cutThesisPath', pastePath: 'pasteThesisPath', copyFileName: 'copyThesisFileName', copyViewRelPath: 'copyThesisViewRelPath', copyViewAbsPath: 'copyThesisViewAbsPath', browseFile: 'thesisBrowseFile', downloadFile: 'thesisDownloadFile', addFile: 'thesisAddFile', addFileToRoot: 'thesisAddFileToRoot', deleteFile: 'thesisDeleteFile', backupFile: 'thesisBackupFile', renameFile: 'renameThesisFile', renameFileWithTimestamp: 'renameThesisFileWithTimestamp', openFileDirectory: 'thesisOpenFileDirectory', createDirectory: 'createThesisDirectory', copyDirectoryStructure: 'copyThesisDirectoryStructure', pasteDirectoryStructure: 'pasteThesisDirectoryStructure', openFile: 'thesisOpenFile', saveWpsOpenPath: 'saveWpsOpenPathFromInputThesis', openPresetRenameModal: 'openPresetRenameModalForThesis', }, })); IARDirOpsColumns.register('offering', tabsColCfg('offering', { prefix: 'offering', modalId: 'offeringDirectoryModal', entityIdInputId: 'offeringDirectoryModalOfferingId', fileListId: 'offeringDirectoryFileList', subdirTabsId: 'offeringDirectorySubdirTabs', subdirDefs: OFFERING_SUBDIRS.map(function (n) { return { key: n, label: n }; }), defaultSubdir: '实验档案', wpsInputId: 'wpsOpenPathInputOffering', wpsRadioName: 'offeringDirOpenWith', apiFiles: function (id) { return '/api/course-offering/' + encodeURIComponent(id) + '/files'; }, clipScope: 'course_offering', structureScope: 'course_offering', crossEntityField: 'from_offering_id', presetRenameKind: 'course_offering', subdirRootsKey: 'offeringSubdirRoots', dragStateKey: '_offeringDirDrag', entityLabel: '开课实例', copyToPageLabel: '开课档案管理', legacy: { openModal: 'openOfferingDirectoryModal', openRootDirectory: 'openOfferingRootDirectory', refresh: 'refreshOfferingDirectory', switchSubdir: 'switchOfferingDirectorySubdir', copyPath: 'copyOfferingPath', cutPath: 'cutOfferingPath', pastePath: 'pasteOfferingPath', copyFileName: 'copyOfferingFileName', copyViewRelPath: 'copyOfferingViewRelPath', copyViewAbsPath: 'copyOfferingViewAbsPath', browseFile: 'offeringBrowseFile', downloadFile: 'offeringDownloadFile', addFile: 'offeringAddFile', addFileToRoot: 'offeringAddFileToRoot', deleteFile: 'offeringDeleteFile', backupFile: 'offeringBackupFile', renameFile: 'renameOfferingFile', renameFileWithTimestamp: 'renameOfferingFileWithTimestamp', openFileDirectory: 'offeringOpenFileDirectory', createDirectory: 'createOfferingDirectory', copyDirectoryStructure: 'copyOfferingDirectoryStructure', pasteDirectoryStructure: 'pasteOfferingDirectoryStructure', openFile: 'offeringOpenFile', saveWpsOpenPath: 'saveWpsOpenPathFromInputOffering', openPresetRenameModal: 'openPresetRenameModalForOffering', }, })); IARDirOpsColumns.register('tutorial', tabsColCfg('tutorial', { prefix: 'tutorial', modalId: 'tutorialDirectoryModal', entityIdInputId: 'tutorialDirectoryEntityId', fileListId: 'tutorialDirectoryFileList', subdirTabsId: 'tutorialDirectorySubdirTabs', subdirDefs: [ { key: '正文', label: '正文' }, { key: '图表', label: '图表' }, { key: '其他', label: '其他' }, ], defaultSubdir: '正文', crossEntityField: 'from_tutorial_id', wpsInputId: 'wpsOpenPathInputTutorial', wpsRadioName: 'tutorialDirOpenWith', apiFiles: function (id) { return '/api/tutorials/' + encodeURIComponent(id) + '/files'; }, clipScope: 'tutorial', structureScope: 'tutorial', presetRenameKind: 'tutorial', subdirRootsKey: 'tutorialSubdirRoots', dragStateKey: '_tutorialDirDrag', entityLabel: '教程', copyToPageLabel: '教程管理', selectedPathElId: 'tutorialDirectorySelectedPath', onAfterFetch: function (data) { var el = document.getElementById('tutorialDirectoryBasePath'); var roots = (data && data.subdir_roots) || {}; if (el) el.textContent = (data && (data.listing_base || roots['正文'])) || '-'; }, dirSourceRegister: { hintMain: '当前显示该教程目录。个人为 E:\\IntelliX\\personal\\personal_用户ID\\Res\\Tutorials\\教程编号,团队为 E:\\IntelliX\\team\\team_团队ID\\Res\\Tutorials\\教程编号,机构为 E:\\IntelliX\\organization\\organization_机构ID\\Res\\Tutorials\\教程编号。其下为正文、图表、其他。', hintBackup: '正在查看该教程目录的备份镜像。修改文件请切换回「主目录」。', }, legacy: { openModal: 'openTutorialDirectoryModal', }, })); IARDirOpsColumns.register('other_resource', tabsColCfg('other_resource', { prefix: 'otherResource', modalId: 'otherResourceDirectoryModal', entityIdInputId: 'otherResourceDirectoryEntityId', fileListId: 'otherResourceDirectoryFileList', subdirTabsId: 'otherResourceDirectorySubdirTabs', subdirDefs: [ { key: '文档', label: '文档' }, { key: '媒体(图 + 音视频)', label: '媒体(图 + 音视频)' }, { key: '表格与数据', label: '表格与数据' }, { key: '其他', label: '其他' }, ], defaultSubdir: '文档', crossEntityField: 'from_resource_id', wpsInputId: 'wpsOpenPathInputOtherResource', wpsRadioName: 'otherResourceDirOpenWith', apiFiles: function (id) { return '/api/other-resources/' + encodeURIComponent(id) + '/files'; }, clipScope: 'other_resource', structureScope: 'other_resource', presetRenameKind: 'other_resource', subdirRootsKey: 'otherResourceSubdirRoots', dragStateKey: '_otherResourceDirDrag', entityLabel: '其他资源', copyToPageLabel: '其他资源管理', selectedPathElId: 'otherResourceDirectorySelectedPath', onAfterFetch: function (data) { var el = document.getElementById('otherResourceDirectoryBasePath'); var roots = (data && data.subdir_roots) || {}; if (el) el.textContent = (data && (data.listing_base || roots['文档'])) || '-'; }, dirSourceRegister: { hintMain: '当前显示该其他资源目录。个人为 E:\\IntelliX\\personal\\personal_用户ID\\Res\\OtherResources\\资源编号,团队为 E:\\IntelliX\\team\\team_团队ID\\Res\\OtherResources\\资源编号,机构为 E:\\IntelliX\\organization\\organization_机构ID\\Res\\OtherResources\\资源编号。其下为文档、媒体(图 + 音视频)、表格与数据、其他。', hintBackup: '正在查看该其他资源目录的备份镜像。修改文件请切换回「主目录」。', }, legacy: { openModal: 'openOtherResourceDirectoryModal', }, })); global.PAPER_DIR_COLUMNS = PAPER_SUBDIR_DEFS; global.UNITGEN_TASK_SUBDIRS = UNITGEN_TASK_SUBDIRS; global.CURSIVE_DATASET_SUBDIRS = CURSIVE_DATASET_SUBDIRS; global.COURSE_CATALOG_SUBDIRS = CATALOG_SUBDIRS; global.openPresetRenameModalForNewProj = function () { IARDirOpsColumns.invoke('newproj', 'openPresetRenameModal'); }; global.saveWpsOpenPathFromInputNewProj = function () { IARDirOpsColumns.invoke('newproj', 'saveWpsOpenPath'); }; global.openPresetRenameModalForTask = function () { IARDirOpsColumns.invoke('personal_task', 'openPresetRenameModal'); }; global.saveWpsOpenPathFromInputPersonalTask = function () { IARDirOpsColumns.invoke('personal_task', 'saveWpsOpenPath'); }; global.openPresetRenameModalForDocument = function () { IARDirOpsColumns.invoke('document', 'openPresetRenameModal'); }; global.openPresetRenameModalForPaper = function () { IARDirOpsColumns.invoke('paper', 'openPresetRenameModal'); }; global.saveWpsOpenPathFromInputPaper = function () { IARDirOpsColumns.invoke('paper', 'saveWpsOpenPath'); }; global.openPresetRenameModalForCatalog = function () { IARDirOpsColumns.invoke('catalog', 'openPresetRenameModal'); }; global.openPresetRenameModalForOffering = function () { IARDirOpsColumns.invoke('offering', 'openPresetRenameModal'); }; global.saveWpsOpenPathFromInputCatalog = function () { IARDirOpsColumns.invoke('catalog', 'saveWpsOpenPath'); }; global.saveWpsOpenPathFromInputOffering = function () { IARDirOpsColumns.invoke('offering', 'saveWpsOpenPath'); }; global.openPresetRenameModalForThesis = function () { IARDirOpsColumns.invoke('thesis', 'openPresetRenameModal'); }; global.saveWpsOpenPathFromInputThesis = function () { IARDirOpsColumns.invoke('thesis', 'saveWpsOpenPath'); }; global.loadThesisDirectorySubdir = function (subdir) { IARDirOpsColumns.invoke('thesis', 'switchSubdir', subdir || undefined); }; })(typeof window !== 'undefined' ? window : this);