zj-plugin-intelligent 1.2.26-beta.6 → 1.2.26-beta.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1000,7 +1000,7 @@ eval("\n\nvar _interopRequireWildcard = __webpack_require__(/*! ./node_modules/@
|
|
|
1000
1000
|
/***/ (function(module, exports, __webpack_require__) {
|
|
1001
1001
|
|
|
1002
1002
|
"use strict";
|
|
1003
|
-
eval("\n\nvar _interopRequireWildcard = __webpack_require__(/*! ./node_modules/@babel/runtime/helpers/interopRequireWildcard */ \"./node_modules/@babel/runtime/helpers/interopRequireWildcard.js\").default;\n\nvar _interopRequireDefault = __webpack_require__(/*! ./node_modules/@babel/runtime/helpers/interopRequireDefault */ \"./node_modules/@babel/runtime/helpers/interopRequireDefault.js\").default;\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.default = void 0;\n\nvar _asyncToGenerator2 = _interopRequireDefault(__webpack_require__(/*! ./node_modules/@babel/runtime/helpers/asyncToGenerator */ \"./node_modules/@babel/runtime/helpers/asyncToGenerator.js\"));\n\nvar _objectSpread2 = _interopRequireDefault(__webpack_require__(/*! ./node_modules/@babel/runtime/helpers/objectSpread2 */ \"./node_modules/@babel/runtime/helpers/objectSpread2.js\"));\n\nvar _marked = __webpack_require__(/*! marked */ \"./node_modules/marked/lib/marked.esm.js\");\n\nvar XLSX = _interopRequireWildcard(__webpack_require__(/*! xlsx */ \"./node_modules/xlsx/xlsx.mjs\"));\n\nvar _mammoth = _interopRequireDefault(__webpack_require__(/*! mammoth */ \"./node_modules/mammoth/lib/index.js\"));\n\nvar _knowledgeBase = __webpack_require__(/*! ./api/knowledgeBase */ \"./src/lib/knowledgeBase/api/knowledgeBase.js\");\n\nvar _fileType = __webpack_require__(/*! @lib/utils/fileType */ \"./src/lib/utils/fileType.js\");\n\nvar _DocumentForm = _interopRequireDefault(__webpack_require__(/*! ./DocumentForm */ \"./src/lib/knowledgeBase/DocumentForm.vue\"));\n\nvar _MobileDialog = _interopRequireDefault(__webpack_require__(/*! ./MobileDialog.vue */ \"./src/lib/knowledgeBase/MobileDialog.vue\"));\n\nvar _native = __webpack_require__(/*! ./native.js */ \"./src/lib/knowledgeBase/native.js\");\n\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n// 预览最多显示的行数(防止大文件卡死)\nvar MAX_PREVIEW_ROWS = 500;\nvar _default2 = {\n name: 'DocumentList',\n components: {\n DocumentForm: _DocumentForm.default,\n MobileDialog: _MobileDialog.default\n },\n props: {\n selectedCategory: {\n type: Object,\n default: null\n },\n categoryList: {\n type: Array,\n default: function _default() {\n return [];\n }\n },\n companyId: {\n type: String,\n default: ''\n },\n // 是否移动端(由父组件根据宽度传入;未传时按窗口宽度自动判断)\n isMobile: {\n type: Boolean,\n default: null\n },\n // 是否管理员:false(普通成员)时隐藏新增/编辑/索引/删除/批量操作与勾选列,仅保留预览\n isAdmin: {\n type: Boolean,\n default: true\n }\n },\n data: function data() {\n return {\n list: [],\n loading: false,\n total: 0,\n page: 1,\n pageSize: 10,\n searchKeyword: '',\n // 批量删除选中的文件\n selectedRows: [],\n // 批量移动\n moveVisible: false,\n moveFolderId: null,\n moving: false,\n folderList: [],\n folderTreeProps: {\n children: 'children',\n label: 'name'\n },\n // 在线预览\n previewVisible: false,\n previewFile: null,\n previewType: 'none',\n previewText: '',\n // PDF 预览(Blob URL 避免下载)\n pdfBlobUrl: '',\n // Excel 预览\n xlsxLoading: false,\n xlsxWorkbook: null,\n xlsxSheetNames: [],\n xlsxCurrentSheet: '',\n xlsxCols: [],\n xlsxTableData: [],\n hasMoreRows: false,\n // Word 预览\n docxLoading: false,\n docxHtml: '',\n // 窗口宽度(横屏判断:isMobile 且宽>768 时操作按钮与搜索同行)\n innerWidth: typeof window !== 'undefined' ? window.innerWidth : 0\n };\n },\n computed: {\n /**\n * 移动端横屏(宽>768,如平板横屏):空间充足,操作按钮与搜索同行\n */\n isLandscape: function isLandscape() {\n return !!this.isMobile && this.innerWidth > 768;\n },\n\n /**\n * 总页数(横屏自绘分页用)\n */\n totalPages: function totalPages() {\n return Math.max(1, Math.ceil((this.total || 0) / this.pageSize));\n },\n\n /**\n * 横屏表格:当前页可勾选的行(索引中的文件不可勾选)\n */\n selectableRows: function selectableRows() {\n var _this = this;\n\n return (this.list || []).filter(function (row) {\n return _this.rowSelectable(row);\n });\n },\n\n /**\n * 横屏表格:表头全选是否为选中态\n */\n isAllSelected: function isAllSelected() {\n var _this2 = this;\n\n return this.selectableRows.length > 0 && this.selectableRows.every(function (row) {\n return _this2.docMSelected(row);\n });\n },\n\n /**\n * 横屏表格:表头全选是否为半选态\n */\n isIndeterminate: function isIndeterminate() {\n var _this3 = this;\n\n var checked = this.selectableRows.filter(function (row) {\n return _this3.docMSelected(row);\n }).length;\n return checked > 0 && checked < this.selectableRows.length;\n },\n\n /**\n * Markdown 渲染后的 HTML(使用 marked)\n */\n previewHtml: function previewHtml() {\n if (!this.previewText) return '';\n return _marked.marked.parse(this.previewText, {\n breaks: true,\n gfm: true\n });\n },\n maxPreviewRows: function maxPreviewRows() {\n return MAX_PREVIEW_ROWS;\n },\n\n /**\n * 批量移动的文件夹树(由平铺列表组装)\n */\n moveFolderTree: function moveFolderTree() {\n var nodes = this.folderList.map(function (f) {\n return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, f), {}, {\n children: []\n });\n });\n var map = {};\n nodes.forEach(function (n) {\n map[n.id] = n;\n });\n var roots = [];\n nodes.forEach(function (n) {\n var pid = n.parentId || 0;\n if (map[pid]) map[pid].children.push(n);else roots.push(n);\n });\n return roots;\n },\n\n /**\n * 批量移动的文件夹扁平列表(移动端自绘列表用)\n */\n moveFolderFlat: function moveFolderFlat() {\n return (0, _native.flattenFolderTree)(this.moveFolderTree);\n },\n\n /**\n * 目标文件夹名称\n */\n moveTargetName: function moveTargetName() {\n var _this4 = this;\n\n if (!this.moveFolderId) return '';\n var f = this.folderList.find(function (x) {\n return x.id === _this4.moveFolderId;\n });\n return f ? f.name : '';\n }\n },\n watch: {\n selectedCategory: function selectedCategory() {\n this.page = 1;\n this.loadList();\n },\n companyId: function companyId() {\n this.page = 1;\n this.searchKeyword = '';\n this.list = [];\n this.total = 0;\n this.loadList();\n },\n\n /**\n * 预览弹窗关闭时清理 PDF Blob URL\n */\n previewVisible: function previewVisible(val) {\n if (!val && this.pdfBlobUrl) {\n URL.revokeObjectURL(this.pdfBlobUrl);\n this.pdfBlobUrl = '';\n }\n }\n },\n created: function created() {\n this.loadList(); // 跟踪窗口宽度用于横屏判断(旋转屏幕时按钮行内/换行切换)\n\n if (typeof window !== 'undefined') {\n this.innerWidth = window.innerWidth;\n window.addEventListener('resize', this.handleWinResize);\n }\n },\n beforeDestroy: function beforeDestroy() {\n if (typeof window !== 'undefined') {\n window.removeEventListener('resize', this.handleWinResize);\n }\n },\n methods: {\n handleWinResize: function handleWinResize() {\n if (typeof window !== 'undefined') {\n this.innerWidth = window.innerWidth;\n }\n },\n loadList: function loadList() {\n var _this5 = this;\n\n var append = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;\n if (!this.companyId) return;\n this.loading = true;\n var params = {\n companyId: this.companyId,\n pageNum: this.page,\n pageSize: this.pageSize\n }; // 选中具体文件夹时按文件夹过滤(\"显示全部文件\"时 id 为空串,不传)\n\n if (this.selectedCategory && this.selectedCategory.id) {\n params.folderId = this.selectedCategory.id;\n }\n\n if (this.searchKeyword) {\n params.keyword = this.searchKeyword;\n }\n\n (0, _knowledgeBase.getFileList)(params).then(function (data) {\n // append:移动端「加载更多」追加到列表尾部\n if (append) {\n _this5.list = (_this5.list || []).concat(data.records || []);\n } else {\n _this5.list = data.records || []; // 列表刷新后清空勾选\n\n _this5.selectedRows = [];\n\n _this5.$nextTick(function () {\n // 移动端 el-table 不渲染,$refs.tableRef 可能不存在或非 el-table 实例\n if (_this5.$refs.tableRef && typeof _this5.$refs.tableRef.clearSelection === 'function') {\n _this5.$refs.tableRef.clearSelection();\n }\n });\n }\n\n _this5.total = data.total || 0;\n }).catch(function () {}).finally(function () {\n _this5.loading = false;\n });\n },\n\n /**\n * 移动端:加载更多(追加下一页)\n */\n loadMore: function loadMore() {\n if (this.loading) return;\n this.page += 1;\n this.loadList(true);\n },\n\n /**\n * 移动端:当前是否已勾选该文件\n */\n docMSelected: function docMSelected(row) {\n return (this.selectedRows || []).some(function (x) {\n return x && x.id === row.id;\n });\n },\n\n /**\n * 移动端:切换勾选(索引中的文件不可勾选)\n */\n toggleMSelected: function toggleMSelected(row) {\n if (row.indexStatus === 2) return;\n var i = (this.selectedRows || []).findIndex(function (x) {\n return x && x.id === row.id;\n });\n if (i >= 0) this.selectedRows.splice(i, 1);else this.selectedRows.push(row);\n },\n\n /**\n * 移动端横屏表格:表头全选/取消全选(仅作用于当前页可选行)\n */\n toggleSelectAll: function toggleSelectAll(e) {\n var _this6 = this;\n\n var checked = e && e.target ? e.target.checked : !this.isAllSelected;\n var selectable = this.selectableRows;\n\n if (checked) {\n selectable.forEach(function (row) {\n if (!_this6.docMSelected(row)) _this6.selectedRows.push(row);\n });\n } else {\n var ids = selectable.map(function (row) {\n return row.id;\n });\n this.selectedRows = (this.selectedRows || []).filter(function (row) {\n return !row || ids.indexOf(row.id) === -1;\n });\n }\n },\n handleSearch: function handleSearch() {\n this.page = 1;\n this.loadList();\n },\n handleSizeChange: function handleSizeChange(size) {\n this.pageSize = size;\n this.page = 1;\n this.loadList();\n },\n handleCurrentChange: function handleCurrentChange(page) {\n this.page = page;\n this.loadList();\n },\n\n /**\n * 删除文件后刷新列表:若当前页因删除而超出最大页数(如某页只剩 1 条被删掉),\n * 自动回退到最后一页(即上一页),避免停留在空白页。\n */\n handleDeleted: function handleDeleted() {\n var count = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;\n var newTotal = Math.max(0, this.total - count);\n var maxPage = Math.max(1, Math.ceil(newTotal / this.pageSize));\n\n if (this.page > maxPage) {\n this.page = maxPage;\n }\n\n this.loadList();\n },\n handleAdd: function handleAdd() {\n var _this7 = this;\n\n if (!this.companyId) {\n this.$message.warning('公司数据未加载,请稍后刷新');\n return;\n }\n\n if (!this.categoryList || this.categoryList.length === 0) {\n this.$message.warning('暂无根目录,请先创建文件夹再新增文档');\n return;\n }\n\n var folderId = this.selectedCategory && this.selectedCategory.id ? this.selectedCategory.id : '';\n this.$refs.docFormRef.openAdd(folderId).then(function (res) {\n if (res) _this7.loadList();\n });\n },\n handleEdit: function handleEdit(row) {\n var _this8 = this;\n\n this.$refs.docFormRef.openEdit(row).then(function (res) {\n if (res) _this8.loadList();\n });\n },\n\n /**\n * 在线预览:图片 / PDF / Excel / Word / 文本\n */\n handlePreview: function handlePreview(row) {\n var _this9 = this;\n\n this.previewFile = row;\n this.previewText = '';\n this.docxHtml = '';\n this.xlsxWorkbook = null;\n this.xlsxSheetNames = [];\n this.xlsxCurrentSheet = '';\n this.xlsxCols = [];\n this.xlsxTableData = []; // 清理上一次的 PDF Blob URL\n\n if (this.pdfBlobUrl) {\n URL.revokeObjectURL(this.pdfBlobUrl);\n this.pdfBlobUrl = '';\n }\n\n var t = (row.fileType || '').toLowerCase();\n\n if (['png', 'jpg', 'jpeg', 'gif', 'webp', 'bmp'].includes(t)) {\n this.previewType = 'image';\n } else if (t === 'pdf') {\n this.previewType = 'pdf';\n this.loadPdfPreview(row);\n } else if (t === 'xlsx' || t === 'xls') {\n this.previewType = 'xlsx';\n this.loadXlsxPreview(row);\n } else if (t === 'docx' || t === 'doc') {\n this.previewType = 'docx';\n this.loadDocxPreview(row);\n } else if (['txt', 'md', 'markdown', 'html', 'htm'].includes(t)) {\n this.previewType = 'text';\n (0, _knowledgeBase.getFileDetail)(row.id).then(function (d) {\n _this9.previewText = d.content || '(该文件暂无可预览的文本内容)';\n }).catch(function () {\n _this9.previewText = '(文本内容加载失败)';\n });\n } else {\n this.previewType = 'none';\n }\n\n this.previewVisible = true;\n },\n // ==================== Excel 预览 ====================\n loadXlsxPreview: function loadXlsxPreview(file) {\n var _this10 = this;\n\n return (0, _asyncToGenerator2.default)( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {\n var detail, fileUrl, response, ab, workbook;\n return regeneratorRuntime.wrap(function _callee$(_context) {\n while (1) {\n switch (_context.prev = _context.next) {\n case 0:\n _this10.xlsxLoading = true;\n _context.prev = 1;\n _context.next = 4;\n return (0, _knowledgeBase.getFileDetail)(file.id);\n\n case 4:\n detail = _context.sent;\n fileUrl = detail.fileUrl || file.fileUrl;\n\n if (fileUrl) {\n _context.next = 9;\n break;\n }\n\n _this10.$message.warning('无法获取文件下载地址');\n\n return _context.abrupt(\"return\");\n\n case 9:\n _context.next = 11;\n return fetch(fileUrl);\n\n case 11:\n response = _context.sent;\n\n if (response.ok) {\n _context.next = 14;\n break;\n }\n\n throw new Error('下载文件失败');\n\n case 14:\n _context.next = 16;\n return response.arrayBuffer();\n\n case 16:\n ab = _context.sent;\n _context.next = 19;\n return new Promise(function (r) {\n return setTimeout(r, 0);\n });\n\n case 19:\n workbook = XLSX.read(ab, {\n type: 'array'\n });\n _this10.xlsxWorkbook = workbook;\n _this10.xlsxSheetNames = workbook.SheetNames;\n\n if (workbook.SheetNames.length > 0) {\n _this10.xlsxCurrentSheet = workbook.SheetNames[0];\n\n _this10.renderXlsxSheet();\n }\n\n _context.next = 29;\n break;\n\n case 25:\n _context.prev = 25;\n _context.t0 = _context[\"catch\"](1);\n console.error('加载 Excel 文件失败', _context.t0);\n\n _this10.$message.error('Excel 文件加载失败');\n\n case 29:\n _context.prev = 29;\n _this10.xlsxLoading = false;\n return _context.finish(29);\n\n case 32:\n case \"end\":\n return _context.stop();\n }\n }\n }, _callee, null, [[1, 25, 29, 32]]);\n }))();\n },\n renderXlsxSheet: function renderXlsxSheet() {\n var workbook = this.xlsxWorkbook;\n var sheetName = this.xlsxCurrentSheet;\n if (!workbook || !sheetName) return;\n var sheet = workbook.Sheets[sheetName];\n\n if (!sheet) {\n this.xlsxCols = [];\n this.xlsxTableData = [];\n return;\n } // 让出主线程,防止 sheet_to_json 阻塞 UI\n\n\n var data = XLSX.utils.sheet_to_json(sheet, {\n header: 1,\n defval: ''\n });\n\n if (data.length === 0) {\n this.xlsxCols = [];\n this.xlsxTableData = [];\n return;\n } // 列数以「所有行的最大宽度」为准:表头行可能只填了第一格,若直接按第一行长度定列会丢失后续列\n\n\n var maxCols = Math.max.apply(null, data.map(function (row) {\n return row && row.length || 0;\n }));\n this.xlsxCols = Array.from({\n length: maxCols\n }, function (_, i) {\n var v = data[0] && data[0][i];\n return v != null && String(v).trim() !== '' ? String(v) : \"\\u5217\".concat(i + 1);\n }); // 限制预览行数,防止渲染过多 DOM 卡死;同时过滤全空行\n\n var allRows = data.slice(1).filter(function (row) {\n return row && row.some(function (c) {\n return c != null && String(c).trim() !== '';\n });\n });\n this.hasMoreRows = allRows.length > MAX_PREVIEW_ROWS;\n this.xlsxTableData = allRows.slice(0, MAX_PREVIEW_ROWS).map(function (row) {\n var obj = {};\n\n for (var ci = 0; ci < maxCols; ci++) {\n obj[ci] = row[ci] != null ? String(row[ci]) : '';\n }\n\n return obj;\n });\n },\n // ==================== Word 预览 ====================\n loadDocxPreview: function loadDocxPreview(file) {\n var _this11 = this;\n\n return (0, _asyncToGenerator2.default)( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() {\n var detail, fileUrl, response, ab, result;\n return regeneratorRuntime.wrap(function _callee2$(_context2) {\n while (1) {\n switch (_context2.prev = _context2.next) {\n case 0:\n _this11.docxLoading = true;\n _context2.prev = 1;\n _context2.next = 4;\n return (0, _knowledgeBase.getFileDetail)(file.id);\n\n case 4:\n detail = _context2.sent;\n fileUrl = detail.fileUrl || file.fileUrl;\n\n if (fileUrl) {\n _context2.next = 9;\n break;\n }\n\n _this11.$message.warning('无法获取文件下载地址');\n\n return _context2.abrupt(\"return\");\n\n case 9:\n _context2.next = 11;\n return fetch(fileUrl);\n\n case 11:\n response = _context2.sent;\n\n if (response.ok) {\n _context2.next = 14;\n break;\n }\n\n throw new Error('下载文件失败');\n\n case 14:\n _context2.next = 16;\n return response.arrayBuffer();\n\n case 16:\n ab = _context2.sent;\n\n if (ab.byteLength) {\n _context2.next = 20;\n break;\n }\n\n _this11.docxHtml = '<p>(空文档)</p>';\n return _context2.abrupt(\"return\");\n\n case 20:\n _context2.next = 22;\n return _mammoth.default.convertToHtml({\n arrayBuffer: ab\n });\n\n case 22:\n result = _context2.sent;\n _this11.docxHtml = result.value || '<p>(空文档)</p>';\n _context2.next = 30;\n break;\n\n case 26:\n _context2.prev = 26;\n _context2.t0 = _context2[\"catch\"](1);\n console.error('加载 Word 文件失败', _context2.t0);\n\n _this11.$message.error('Word 文件加载失败');\n\n case 30:\n _context2.prev = 30;\n _this11.docxLoading = false;\n return _context2.finish(30);\n\n case 33:\n case \"end\":\n return _context2.stop();\n }\n }\n }, _callee2, null, [[1, 26, 30, 33]]);\n }))();\n },\n // ==================== PDF 预览 ====================\n loadPdfPreview: function loadPdfPreview(file) {\n var _this12 = this;\n\n return (0, _asyncToGenerator2.default)( /*#__PURE__*/regeneratorRuntime.mark(function _callee3() {\n var detail, fileUrl, response, blob;\n return regeneratorRuntime.wrap(function _callee3$(_context3) {\n while (1) {\n switch (_context3.prev = _context3.next) {\n case 0:\n _context3.prev = 0;\n _context3.next = 3;\n return (0, _knowledgeBase.getFileDetail)(file.id);\n\n case 3:\n detail = _context3.sent;\n fileUrl = detail.fileUrl || file.fileUrl;\n\n if (fileUrl) {\n _context3.next = 8;\n break;\n }\n\n _this12.$message.warning('无法获取文件下载地址');\n\n return _context3.abrupt(\"return\");\n\n case 8:\n _context3.next = 10;\n return fetch(fileUrl);\n\n case 10:\n response = _context3.sent;\n\n if (response.ok) {\n _context3.next = 13;\n break;\n }\n\n throw new Error('下载文件失败');\n\n case 13:\n _context3.next = 15;\n return response.blob();\n\n case 15:\n blob = _context3.sent;\n _this12.pdfBlobUrl = URL.createObjectURL(blob);\n _context3.next = 23;\n break;\n\n case 19:\n _context3.prev = 19;\n _context3.t0 = _context3[\"catch\"](0);\n console.error('加载 PDF 文件失败', _context3.t0);\n\n _this12.$message.error('PDF 文件加载失败');\n\n case 23:\n case \"end\":\n return _context3.stop();\n }\n }\n }, _callee3, null, [[0, 19]]);\n }))();\n },\n\n /**\n * 索引 / 重建索引(二次确认)\n */\n handleIndex: function handleIndex(row) {\n var _this13 = this;\n\n var isRebuild = row.indexStatus === 1;\n console.log('[DocumentList] 索引文件:', row.id, row.title, 'companyId:', this.companyId);\n this.$confirm(\"\\u786E\\u8BA4\\u5BF9\\u6587\\u4EF6\\u300C\".concat(row.title || row.fileName, \"\\u300D\").concat(isRebuild ? '重建' : '创建', \"\\u7D22\\u5F15\\uFF1F\"), '提示', {\n type: 'warning',\n confirmButtonText: '确定',\n cancelButtonText: '取消'\n }).then(function () {\n var request = isRebuild ? (0, _knowledgeBase.reindexFile)(row.id) : (0, _knowledgeBase.indexFile)(row.id);\n request.then(function () {\n _this13.$message.success(isRebuild ? '已开始重建索引' : '已开始索引');\n\n _this13.loadList();\n }).catch(function () {});\n }).catch(function () {});\n },\n\n /**\n * 删除索引(二次确认)\n */\n handleDeleteIndex: function handleDeleteIndex(row) {\n var _this14 = this;\n\n this.$confirm(\"\\u786E\\u8BA4\\u5220\\u9664\\u6587\\u4EF6\\u300C\".concat(row.title || row.fileName, \"\\u300D\\u7684\\u7D22\\u5F15\\uFF1F\\u5220\\u9664\\u540E\\u65E0\\u6CD5\\u6062\\u590D\\u3002\"), '提示', {\n type: 'warning',\n confirmButtonText: '确定删除',\n cancelButtonText: '取消'\n }).then(function () {\n (0, _knowledgeBase.deleteFileIndex)(row.id).then(function () {\n _this14.$message.success('索引已删除');\n\n _this14.loadList();\n }).catch(function () {});\n }).catch(function () {});\n },\n handleDelete: function handleDelete(row) {\n var _this15 = this;\n\n // 索引中的文件不允许删除\n if (row.indexStatus === 2) {\n this.$message.warning('该文件正在索引中,无法删除');\n return;\n }\n\n var hasIndex = row.indexStatus === 1;\n this.$confirm(\"\\u786E\\u8BA4\\u5220\\u9664\\u6587\\u4EF6\\u300C\".concat(row.title || row.fileName, \"\\u300D\\uFF1F\").concat(hasIndex ? '删除文件前会先删除该文件的索引。' : '', \"\\u5220\\u9664\\u540E\\u65E0\\u6CD5\\u6062\\u590D\\u3002\"), '提示', {\n type: 'warning',\n confirmButtonText: '确定删除',\n cancelButtonText: '取消'\n }).then( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/regeneratorRuntime.mark(function _callee4() {\n return regeneratorRuntime.wrap(function _callee4$(_context4) {\n while (1) {\n switch (_context4.prev = _context4.next) {\n case 0:\n _context4.prev = 0;\n\n if (!hasIndex) {\n _context4.next = 4;\n break;\n }\n\n _context4.next = 4;\n return (0, _knowledgeBase.deleteFileIndex)(row.id);\n\n case 4:\n _context4.next = 6;\n return (0, _knowledgeBase.deleteFile)(row.id);\n\n case 6:\n _this15.$message.success('文件已删除');\n\n _this15.handleDeleted(1);\n\n _context4.next = 12;\n break;\n\n case 10:\n _context4.prev = 10;\n _context4.t0 = _context4[\"catch\"](0);\n\n case 12:\n case \"end\":\n return _context4.stop();\n }\n }\n }, _callee4, null, [[0, 10]]);\n }))).catch(function () {});\n },\n\n /**\n * 表格勾选变化\n */\n handleSelectionChange: function handleSelectionChange(rows) {\n this.selectedRows = rows || [];\n },\n\n /**\n * 索引中的文件不可勾选删除\n */\n rowSelectable: function rowSelectable(row) {\n return row.indexStatus !== 2;\n },\n\n /**\n * 批量删除勾选的文件\n */\n handleBatchDelete: function handleBatchDelete() {\n var _this16 = this;\n\n var selected = this.selectedRows || [];\n\n if (!selected.length) {\n this.$message.warning('请先勾选要删除的文件');\n return;\n } // 索引中的文件不允许删除\n\n\n var indexingFiles = selected.filter(function (f) {\n return f.indexStatus === 2;\n });\n var deletable = selected.filter(function (f) {\n return f.indexStatus !== 2;\n });\n\n if (!deletable.length) {\n this.$message.warning('所选文件均正在索引中,无法删除');\n return;\n }\n\n if (indexingFiles.length) {\n this.$message.warning(\"\\u6709 \".concat(indexingFiles.length, \" \\u4E2A\\u6587\\u4EF6\\u6B63\\u5728\\u7D22\\u5F15\\u4E2D\\uFF0C\\u672C\\u6B21\\u5C06\\u8DF3\\u8FC7\"));\n } // 已索引的文件需先删除索引,再删除文件\n\n\n var indexed = deletable.filter(function (f) {\n return f.indexStatus === 1;\n });\n var ids = deletable.map(function (f) {\n return f.id;\n });\n this.$confirm(\"\\u786E\\u8BA4\\u5220\\u9664\\u9009\\u4E2D\\u7684 \".concat(deletable.length, \" \\u4E2A\\u6587\\u4EF6\\uFF1F\").concat(indexed.length ? '删除前会先删除这些文件的索引。' : '', \"\\u5220\\u9664\\u540E\\u65E0\\u6CD5\\u6062\\u590D\\u3002\"), '提示', {\n type: 'warning',\n confirmButtonText: '确定删除',\n cancelButtonText: '取消',\n customClass: 'kb-message-box'\n }).then( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/regeneratorRuntime.mark(function _callee5() {\n return regeneratorRuntime.wrap(function _callee5$(_context5) {\n while (1) {\n switch (_context5.prev = _context5.next) {\n case 0:\n _context5.prev = 0;\n\n if (!indexed.length) {\n _context5.next = 4;\n break;\n }\n\n _context5.next = 4;\n return Promise.all(indexed.map(function (f) {\n return (0, _knowledgeBase.deleteFileIndex)(f.id);\n }));\n\n case 4:\n _context5.next = 6;\n return (0, _knowledgeBase.deleteFiles)(ids);\n\n case 6:\n _this16.$message.success('批量删除成功');\n\n _this16.handleDeleted(deletable.length);\n\n _context5.next = 12;\n break;\n\n case 10:\n _context5.prev = 10;\n _context5.t0 = _context5[\"catch\"](0);\n\n case 12:\n case \"end\":\n return _context5.stop();\n }\n }\n }, _callee5, null, [[0, 10]]);\n }))).catch(function () {});\n },\n\n /**\n * 批量移动:打开目标文件夹选择弹窗\n */\n handleBatchMove: function handleBatchMove() {\n var _this17 = this;\n\n return (0, _asyncToGenerator2.default)( /*#__PURE__*/regeneratorRuntime.mark(function _callee6() {\n var selected, folders;\n return regeneratorRuntime.wrap(function _callee6$(_context6) {\n while (1) {\n switch (_context6.prev = _context6.next) {\n case 0:\n selected = _this17.selectedRows || [];\n\n if (selected.length) {\n _context6.next = 4;\n break;\n }\n\n _this17.$message.warning('请先勾选要移动的文件');\n\n return _context6.abrupt(\"return\");\n\n case 4:\n if (_this17.companyId) {\n _context6.next = 7;\n break;\n }\n\n _this17.$message.warning('公司数据未加载');\n\n return _context6.abrupt(\"return\");\n\n case 7:\n _this17.moveFolderId = null;\n _this17.moveVisible = true; // 每次打开都重新加载文件夹列表,确保新建/重命名/删除文件夹后看到最新目录\n\n _context6.prev = 9;\n _context6.next = 12;\n return (0, _knowledgeBase.getFolderList)(_this17.companyId);\n\n case 12:\n folders = _context6.sent;\n _this17.folderList = folders || [];\n _context6.next = 18;\n break;\n\n case 16:\n _context6.prev = 16;\n _context6.t0 = _context6[\"catch\"](9);\n\n case 18:\n _this17.$nextTick(function () {\n if (_this17.$refs.moveTreeRef) _this17.$refs.moveTreeRef.setCurrentKey(null);\n });\n\n case 19:\n case \"end\":\n return _context6.stop();\n }\n }\n }, _callee6, null, [[9, 16]]);\n }))();\n },\n\n /**\n * 选择目标文件夹\n */\n handleMoveFolderSelect: function handleMoveFolderSelect(data) {\n this.moveFolderId = data.id;\n },\n\n /**\n * 确认批量移动\n */\n handleMoveConfirm: function handleMoveConfirm() {\n var _this18 = this;\n\n return (0, _asyncToGenerator2.default)( /*#__PURE__*/regeneratorRuntime.mark(function _callee7() {\n var ids, targetFolder;\n return regeneratorRuntime.wrap(function _callee7$(_context7) {\n while (1) {\n switch (_context7.prev = _context7.next) {\n case 0:\n if (_this18.moveFolderId) {\n _context7.next = 3;\n break;\n }\n\n _this18.$message.warning('请选择目标文件夹');\n\n return _context7.abrupt(\"return\");\n\n case 3:\n ids = _this18.selectedRows.map(function (f) {\n return f.id;\n });\n _this18.moving = true;\n _context7.prev = 5;\n _context7.next = 8;\n return (0, _knowledgeBase.moveFiles)(ids, _this18.moveFolderId);\n\n case 8:\n _this18.$message.success('批量移动成功');\n\n _this18.moveVisible = false; // 移动成功后,通知父级定位并高亮左侧树到目标文件夹\n\n targetFolder = _this18.folderList.find(function (f) {\n return String(f.id) === String(_this18.moveFolderId);\n }) || null;\n if (targetFolder) _this18.$emit('move-target', targetFolder);else _this18.$emit('move-target', {\n id: _this18.moveFolderId,\n name: _this18.moveTargetName\n });\n\n _this18.loadList();\n\n _context7.next = 17;\n break;\n\n case 15:\n _context7.prev = 15;\n _context7.t0 = _context7[\"catch\"](5);\n\n case 17:\n _context7.prev = 17;\n _this18.moving = false;\n return _context7.finish(17);\n\n case 20:\n case \"end\":\n return _context7.stop();\n }\n }\n }, _callee7, null, [[5, 15, 17, 20]]);\n }))();\n },\n\n /**\n * 通过 folderId 映射文件夹名称\n */\n folderName: function folderName(folderId) {\n if (!folderId) return '根目录';\n var found = this.categoryList.find(function (f) {\n return String(f.id) === String(folderId);\n });\n return found ? found.name : '-';\n },\n\n /**\n * 根据文件类型返回对应图标\n */\n getFileIcon: function getFileIcon(fileType) {\n var type = (fileType || '').toLowerCase();\n var iconMap = {\n pdf: 'el-icon-document',\n doc: 'el-icon-document',\n docx: 'el-icon-document',\n xls: 'el-icon-tickets',\n xlsx: 'el-icon-tickets',\n ppt: 'el-icon-data-line',\n pptx: 'el-icon-data-line',\n txt: 'el-icon-document',\n md: 'el-icon-edit-outline',\n png: 'el-icon-picture',\n jpg: 'el-icon-picture',\n jpeg: 'el-icon-picture',\n gif: 'el-icon-picture',\n zip: 'el-icon-folder-opened',\n rar: 'el-icon-folder-opened'\n };\n return iconMap[type] || 'el-icon-document';\n },\n\n /**\n * 根据文件类型返回对应的图标 URL\n * 映射统一维护在 @lib/utils/fileType.js(与聊天附件共用)\n */\n getFileIconUrl: function getFileIconUrl(fileType) {\n return (0, _fileType.getFileIconUrl)(fileType);\n },\n\n /**\n * 文件大小格式化(字节 → B/KB/MB/GB)\n */\n formatSize: function formatSize(bytes) {\n if (!bytes && bytes !== 0) return '-';\n if (bytes === 0) return '0 B';\n var units = ['B', 'KB', 'MB', 'GB', 'TB'];\n var size = bytes;\n var idx = 0;\n\n while (size >= 1024 && idx < units.length - 1) {\n size /= 1024;\n idx++;\n }\n\n return \"\".concat(idx === 0 ? size : size.toFixed(2), \" \").concat(units[idx]);\n },\n\n /**\n * 时间展示:ISO 本地时间去掉 T 分隔符\n */\n formatTime: function formatTime(time) {\n if (!time) return '-';\n return String(time).replace('T', ' ').replace(/\\+08:00$/, '').replace(/\\.\\d{3}/, '');\n },\n\n /**\n * 索引状态标签:0 未索引 / 1 已索引 / 2 索引中 / 3 失败\n */\n indexTagType: function indexTagType(status) {\n var map = {\n 0: 'info',\n 1: 'success',\n 2: 'warning',\n 3: 'danger'\n };\n return map[status] || 'info';\n },\n indexTagText: function indexTagText(status) {\n var map = {\n 0: '未索引',\n 1: '已索引',\n 2: '索引中',\n 3: '索引失败'\n };\n return map[status] || '未知';\n }\n }\n};\nexports.default = _default2;\n\n//# sourceURL=webpack://ZjPluginIntelligent/./src/lib/knowledgeBase/DocumentList.vue?./node_modules/cache-loader/dist/cjs.js??ref--12-0!./node_modules/babel-loader/lib!./node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/vue-loader/lib??vue-loader-options");
|
|
1003
|
+
eval("\n\nvar _interopRequireWildcard = __webpack_require__(/*! ./node_modules/@babel/runtime/helpers/interopRequireWildcard */ \"./node_modules/@babel/runtime/helpers/interopRequireWildcard.js\").default;\n\nvar _interopRequireDefault = __webpack_require__(/*! ./node_modules/@babel/runtime/helpers/interopRequireDefault */ \"./node_modules/@babel/runtime/helpers/interopRequireDefault.js\").default;\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.default = void 0;\n\nvar _asyncToGenerator2 = _interopRequireDefault(__webpack_require__(/*! ./node_modules/@babel/runtime/helpers/asyncToGenerator */ \"./node_modules/@babel/runtime/helpers/asyncToGenerator.js\"));\n\nvar _objectSpread2 = _interopRequireDefault(__webpack_require__(/*! ./node_modules/@babel/runtime/helpers/objectSpread2 */ \"./node_modules/@babel/runtime/helpers/objectSpread2.js\"));\n\nvar _marked = __webpack_require__(/*! marked */ \"./node_modules/marked/lib/marked.esm.js\");\n\nvar XLSX = _interopRequireWildcard(__webpack_require__(/*! xlsx */ \"./node_modules/xlsx/xlsx.mjs\"));\n\nvar _mammoth = _interopRequireDefault(__webpack_require__(/*! mammoth */ \"./node_modules/mammoth/lib/index.js\"));\n\nvar _knowledgeBase = __webpack_require__(/*! ./api/knowledgeBase */ \"./src/lib/knowledgeBase/api/knowledgeBase.js\");\n\nvar _fileType = __webpack_require__(/*! @lib/utils/fileType */ \"./src/lib/utils/fileType.js\");\n\nvar _DocumentForm = _interopRequireDefault(__webpack_require__(/*! ./DocumentForm */ \"./src/lib/knowledgeBase/DocumentForm.vue\"));\n\nvar _MobileDialog = _interopRequireDefault(__webpack_require__(/*! ./MobileDialog.vue */ \"./src/lib/knowledgeBase/MobileDialog.vue\"));\n\nvar _native = __webpack_require__(/*! ./native.js */ \"./src/lib/knowledgeBase/native.js\");\n\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n// 预览最多显示的行数(防止大文件卡死)\nvar MAX_PREVIEW_ROWS = 500;\nvar _default2 = {\n name: 'DocumentList',\n components: {\n DocumentForm: _DocumentForm.default,\n MobileDialog: _MobileDialog.default\n },\n props: {\n selectedCategory: {\n type: Object,\n default: null\n },\n categoryList: {\n type: Array,\n default: function _default() {\n return [];\n }\n },\n companyId: {\n type: String,\n default: ''\n },\n // 是否移动端(由父组件根据宽度传入;未传时按窗口宽度自动判断)\n isMobile: {\n type: Boolean,\n default: null\n },\n // 是否管理员:false(普通成员)时隐藏新增/编辑/索引/删除/批量操作与勾选列,仅保留预览\n isAdmin: {\n type: Boolean,\n default: true\n }\n },\n data: function data() {\n return {\n list: [],\n loading: false,\n total: 0,\n page: 1,\n pageSize: 10,\n searchKeyword: '',\n // 批量删除选中的文件\n selectedRows: [],\n // 批量移动\n moveVisible: false,\n moveFolderId: null,\n moving: false,\n folderList: [],\n folderTreeProps: {\n children: 'children',\n label: 'name'\n },\n // 在线预览\n previewVisible: false,\n previewFile: null,\n previewType: 'none',\n previewText: '',\n // 移动端预览:是否已向宿主历史栈压入一条记录(用于拦截侧滑返回)\n previewHistoryPushed: false,\n // PDF 预览(Blob URL 避免下载)\n pdfBlobUrl: '',\n // Excel 预览\n xlsxLoading: false,\n xlsxWorkbook: null,\n xlsxSheetNames: [],\n xlsxCurrentSheet: '',\n xlsxCols: [],\n xlsxTableData: [],\n hasMoreRows: false,\n // Word 预览\n docxLoading: false,\n docxHtml: '',\n // 窗口宽度(横屏判断:isMobile 且宽>768 时操作按钮与搜索同行)\n innerWidth: typeof window !== 'undefined' ? window.innerWidth : 0\n };\n },\n computed: {\n /**\n * 移动端横屏(宽>768,如平板横屏):空间充足,操作按钮与搜索同行\n */\n isLandscape: function isLandscape() {\n return !!this.isMobile && this.innerWidth > 768;\n },\n\n /**\n * 总页数(横屏自绘分页用)\n */\n totalPages: function totalPages() {\n return Math.max(1, Math.ceil((this.total || 0) / this.pageSize));\n },\n\n /**\n * 横屏表格:当前页可勾选的行(索引中的文件不可勾选)\n */\n selectableRows: function selectableRows() {\n var _this = this;\n\n return (this.list || []).filter(function (row) {\n return _this.rowSelectable(row);\n });\n },\n\n /**\n * 横屏表格:表头全选是否为选中态\n */\n isAllSelected: function isAllSelected() {\n var _this2 = this;\n\n return this.selectableRows.length > 0 && this.selectableRows.every(function (row) {\n return _this2.docMSelected(row);\n });\n },\n\n /**\n * 横屏表格:表头全选是否为半选态\n */\n isIndeterminate: function isIndeterminate() {\n var _this3 = this;\n\n var checked = this.selectableRows.filter(function (row) {\n return _this3.docMSelected(row);\n }).length;\n return checked > 0 && checked < this.selectableRows.length;\n },\n\n /**\n * Markdown 渲染后的 HTML(使用 marked)\n */\n previewHtml: function previewHtml() {\n if (!this.previewText) return '';\n return _marked.marked.parse(this.previewText, {\n breaks: true,\n gfm: true\n });\n },\n maxPreviewRows: function maxPreviewRows() {\n return MAX_PREVIEW_ROWS;\n },\n\n /**\n * 批量移动的文件夹树(由平铺列表组装)\n */\n moveFolderTree: function moveFolderTree() {\n var nodes = this.folderList.map(function (f) {\n return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, f), {}, {\n children: []\n });\n });\n var map = {};\n nodes.forEach(function (n) {\n map[n.id] = n;\n });\n var roots = [];\n nodes.forEach(function (n) {\n var pid = n.parentId || 0;\n if (map[pid]) map[pid].children.push(n);else roots.push(n);\n });\n return roots;\n },\n\n /**\n * 批量移动的文件夹扁平列表(移动端自绘列表用)\n */\n moveFolderFlat: function moveFolderFlat() {\n return (0, _native.flattenFolderTree)(this.moveFolderTree);\n },\n\n /**\n * 目标文件夹名称\n */\n moveTargetName: function moveTargetName() {\n var _this4 = this;\n\n if (!this.moveFolderId) return '';\n var f = this.folderList.find(function (x) {\n return x.id === _this4.moveFolderId;\n });\n return f ? f.name : '';\n }\n },\n watch: {\n selectedCategory: function selectedCategory() {\n this.page = 1;\n this.loadList();\n },\n companyId: function companyId() {\n this.page = 1;\n this.searchKeyword = '';\n this.list = [];\n this.total = 0;\n this.loadList();\n },\n\n /**\n * 预览弹窗关闭时清理 PDF Blob URL\n */\n previewVisible: function previewVisible(val) {\n if (!val) {\n if (this.pdfBlobUrl) {\n URL.revokeObjectURL(this.pdfBlobUrl);\n this.pdfBlobUrl = '';\n } // 页面内关闭预览时,回退掉预览时压入的历史记录,避免多一条返回\n\n\n if (this.previewHistoryPushed) {\n this.previewHistoryPushed = false;\n\n if (typeof window !== 'undefined' && window.history && window.history.back) {\n window.history.back();\n }\n }\n }\n }\n },\n created: function created() {\n this.loadList(); // 跟踪窗口宽度用于横屏判断(旋转屏幕时按钮行内/换行切换)\n\n if (typeof window !== 'undefined') {\n this.innerWidth = window.innerWidth;\n window.addEventListener('resize', this.handleWinResize);\n window.addEventListener('popstate', this.handlePreviewPopState);\n }\n },\n beforeDestroy: function beforeDestroy() {\n if (typeof window !== 'undefined') {\n window.removeEventListener('resize', this.handleWinResize);\n window.removeEventListener('popstate', this.handlePreviewPopState);\n }\n },\n methods: {\n /**\n * 移动端预览:拦截系统侧滑/返回键,先关闭预览而不是退出页面\n */\n handlePreviewPopState: function handlePreviewPopState() {\n if (this.previewVisible && this.previewHistoryPushed) {\n this.previewHistoryPushed = false;\n this.previewVisible = false;\n }\n },\n handleWinResize: function handleWinResize() {\n if (typeof window !== 'undefined') {\n this.innerWidth = window.innerWidth;\n }\n },\n loadList: function loadList() {\n var _this5 = this;\n\n var append = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;\n if (!this.companyId) return;\n this.loading = true;\n var params = {\n companyId: this.companyId,\n pageNum: this.page,\n pageSize: this.pageSize\n }; // 选中具体文件夹时按文件夹过滤(\"显示全部文件\"时 id 为空串,不传)\n\n if (this.selectedCategory && this.selectedCategory.id) {\n params.folderId = this.selectedCategory.id;\n }\n\n if (this.searchKeyword) {\n params.keyword = this.searchKeyword;\n }\n\n (0, _knowledgeBase.getFileList)(params).then(function (data) {\n // append:移动端「加载更多」追加到列表尾部\n if (append) {\n _this5.list = (_this5.list || []).concat(data.records || []);\n } else {\n _this5.list = data.records || []; // 列表刷新后清空勾选\n\n _this5.selectedRows = [];\n\n _this5.$nextTick(function () {\n // 移动端 el-table 不渲染,$refs.tableRef 可能不存在或非 el-table 实例\n if (_this5.$refs.tableRef && typeof _this5.$refs.tableRef.clearSelection === 'function') {\n _this5.$refs.tableRef.clearSelection();\n }\n });\n }\n\n _this5.total = data.total || 0;\n }).catch(function () {}).finally(function () {\n _this5.loading = false;\n });\n },\n\n /**\n * 移动端:加载更多(追加下一页)\n */\n loadMore: function loadMore() {\n if (this.loading) return;\n this.page += 1;\n this.loadList(true);\n },\n\n /**\n * 移动端:当前是否已勾选该文件\n */\n docMSelected: function docMSelected(row) {\n return (this.selectedRows || []).some(function (x) {\n return x && x.id === row.id;\n });\n },\n\n /**\n * 移动端:切换勾选(索引中的文件不可勾选)\n */\n toggleMSelected: function toggleMSelected(row) {\n if (row.indexStatus === 2) return;\n var i = (this.selectedRows || []).findIndex(function (x) {\n return x && x.id === row.id;\n });\n if (i >= 0) this.selectedRows.splice(i, 1);else this.selectedRows.push(row);\n },\n\n /**\n * 移动端横屏表格:表头全选/取消全选(仅作用于当前页可选行)\n */\n toggleSelectAll: function toggleSelectAll(e) {\n var _this6 = this;\n\n var checked = e && e.target ? e.target.checked : !this.isAllSelected;\n var selectable = this.selectableRows;\n\n if (checked) {\n selectable.forEach(function (row) {\n if (!_this6.docMSelected(row)) _this6.selectedRows.push(row);\n });\n } else {\n var ids = selectable.map(function (row) {\n return row.id;\n });\n this.selectedRows = (this.selectedRows || []).filter(function (row) {\n return !row || ids.indexOf(row.id) === -1;\n });\n }\n },\n handleSearch: function handleSearch() {\n this.page = 1;\n this.loadList();\n },\n handleSizeChange: function handleSizeChange(size) {\n this.pageSize = size;\n this.page = 1;\n this.loadList();\n },\n handleCurrentChange: function handleCurrentChange(page) {\n this.page = page;\n this.loadList();\n },\n\n /**\n * 删除文件后刷新列表:若当前页因删除而超出最大页数(如某页只剩 1 条被删掉),\n * 自动回退到最后一页(即上一页),避免停留在空白页。\n */\n handleDeleted: function handleDeleted() {\n var count = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;\n var newTotal = Math.max(0, this.total - count);\n var maxPage = Math.max(1, Math.ceil(newTotal / this.pageSize));\n\n if (this.page > maxPage) {\n this.page = maxPage;\n }\n\n this.loadList();\n },\n handleAdd: function handleAdd() {\n var _this7 = this;\n\n if (!this.companyId) {\n this.$message.warning('公司数据未加载,请稍后刷新');\n return;\n }\n\n if (!this.categoryList || this.categoryList.length === 0) {\n this.$message.warning('暂无根目录,请先创建文件夹再新增文档');\n return;\n }\n\n var folderId = this.selectedCategory && this.selectedCategory.id ? this.selectedCategory.id : '';\n this.$refs.docFormRef.openAdd(folderId).then(function (res) {\n if (res) _this7.loadList();\n });\n },\n handleEdit: function handleEdit(row) {\n var _this8 = this;\n\n this.$refs.docFormRef.openEdit(row).then(function (res) {\n if (res) _this8.loadList();\n });\n },\n\n /**\n * 在线预览:图片 / PDF / Excel / Word / 文本\n */\n handlePreview: function handlePreview(row) {\n var _this9 = this;\n\n this.previewFile = row;\n this.previewText = '';\n this.docxHtml = '';\n this.xlsxWorkbook = null;\n this.xlsxSheetNames = [];\n this.xlsxCurrentSheet = '';\n this.xlsxCols = [];\n this.xlsxTableData = []; // 清理上一次的 PDF Blob URL\n\n if (this.pdfBlobUrl) {\n URL.revokeObjectURL(this.pdfBlobUrl);\n this.pdfBlobUrl = '';\n }\n\n var t = (row.fileType || '').toLowerCase();\n\n if (['png', 'jpg', 'jpeg', 'gif', 'webp', 'bmp'].includes(t)) {\n this.previewType = 'image';\n } else if (t === 'pdf') {\n this.previewType = 'pdf';\n this.loadPdfPreview(row);\n } else if (t === 'xlsx' || t === 'xls') {\n this.previewType = 'xlsx';\n this.loadXlsxPreview(row);\n } else if (t === 'docx' || t === 'doc') {\n this.previewType = 'docx';\n this.loadDocxPreview(row);\n } else if (['txt', 'md', 'markdown', 'html', 'htm'].includes(t)) {\n this.previewType = 'text';\n (0, _knowledgeBase.getFileDetail)(row.id).then(function (d) {\n _this9.previewText = d.content || '(该文件暂无可预览的文本内容)';\n }).catch(function () {\n _this9.previewText = '(文本内容加载失败)';\n });\n } else {\n this.previewType = 'none';\n }\n\n this.previewVisible = true; // 移动端:压入一条历史记录,侧滑/返回键先关闭预览,而不是退出到主页面\n\n if (this.isMobile && typeof window !== 'undefined' && window.history && window.history.pushState) {\n window.history.pushState({\n kbFilePreview: true\n }, '');\n this.previewHistoryPushed = true;\n }\n },\n // ==================== Excel 预览 ====================\n loadXlsxPreview: function loadXlsxPreview(file) {\n var _this10 = this;\n\n return (0, _asyncToGenerator2.default)( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {\n var detail, fileUrl, response, ab, workbook;\n return regeneratorRuntime.wrap(function _callee$(_context) {\n while (1) {\n switch (_context.prev = _context.next) {\n case 0:\n _this10.xlsxLoading = true;\n _context.prev = 1;\n _context.next = 4;\n return (0, _knowledgeBase.getFileDetail)(file.id);\n\n case 4:\n detail = _context.sent;\n fileUrl = detail.fileUrl || file.fileUrl;\n\n if (fileUrl) {\n _context.next = 9;\n break;\n }\n\n _this10.$message.warning('无法获取文件下载地址');\n\n return _context.abrupt(\"return\");\n\n case 9:\n _context.next = 11;\n return fetch(fileUrl);\n\n case 11:\n response = _context.sent;\n\n if (response.ok) {\n _context.next = 14;\n break;\n }\n\n throw new Error('下载文件失败');\n\n case 14:\n _context.next = 16;\n return response.arrayBuffer();\n\n case 16:\n ab = _context.sent;\n _context.next = 19;\n return new Promise(function (r) {\n return setTimeout(r, 0);\n });\n\n case 19:\n workbook = XLSX.read(ab, {\n type: 'array'\n });\n _this10.xlsxWorkbook = workbook;\n _this10.xlsxSheetNames = workbook.SheetNames;\n\n if (workbook.SheetNames.length > 0) {\n _this10.xlsxCurrentSheet = workbook.SheetNames[0];\n\n _this10.renderXlsxSheet();\n }\n\n _context.next = 29;\n break;\n\n case 25:\n _context.prev = 25;\n _context.t0 = _context[\"catch\"](1);\n console.error('加载 Excel 文件失败', _context.t0);\n\n _this10.$message.error('Excel 文件加载失败');\n\n case 29:\n _context.prev = 29;\n _this10.xlsxLoading = false;\n return _context.finish(29);\n\n case 32:\n case \"end\":\n return _context.stop();\n }\n }\n }, _callee, null, [[1, 25, 29, 32]]);\n }))();\n },\n renderXlsxSheet: function renderXlsxSheet() {\n var workbook = this.xlsxWorkbook;\n var sheetName = this.xlsxCurrentSheet;\n if (!workbook || !sheetName) return;\n var sheet = workbook.Sheets[sheetName];\n\n if (!sheet) {\n this.xlsxCols = [];\n this.xlsxTableData = [];\n return;\n } // 让出主线程,防止 sheet_to_json 阻塞 UI\n\n\n var data = XLSX.utils.sheet_to_json(sheet, {\n header: 1,\n defval: ''\n });\n\n if (data.length === 0) {\n this.xlsxCols = [];\n this.xlsxTableData = [];\n return;\n } // 列数以「所有行的最大宽度」为准:表头行可能只填了第一格,若直接按第一行长度定列会丢失后续列\n\n\n var maxCols = Math.max.apply(null, data.map(function (row) {\n return row && row.length || 0;\n }));\n this.xlsxCols = Array.from({\n length: maxCols\n }, function (_, i) {\n var v = data[0] && data[0][i];\n return v != null && String(v).trim() !== '' ? String(v) : \"\\u5217\".concat(i + 1);\n }); // 限制预览行数,防止渲染过多 DOM 卡死;同时过滤全空行\n\n var allRows = data.slice(1).filter(function (row) {\n return row && row.some(function (c) {\n return c != null && String(c).trim() !== '';\n });\n });\n this.hasMoreRows = allRows.length > MAX_PREVIEW_ROWS;\n this.xlsxTableData = allRows.slice(0, MAX_PREVIEW_ROWS).map(function (row) {\n var obj = {};\n\n for (var ci = 0; ci < maxCols; ci++) {\n obj[ci] = row[ci] != null ? String(row[ci]) : '';\n }\n\n return obj;\n });\n },\n // ==================== Word 预览 ====================\n loadDocxPreview: function loadDocxPreview(file) {\n var _this11 = this;\n\n return (0, _asyncToGenerator2.default)( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() {\n var detail, fileUrl, response, ab, result;\n return regeneratorRuntime.wrap(function _callee2$(_context2) {\n while (1) {\n switch (_context2.prev = _context2.next) {\n case 0:\n _this11.docxLoading = true;\n _context2.prev = 1;\n _context2.next = 4;\n return (0, _knowledgeBase.getFileDetail)(file.id);\n\n case 4:\n detail = _context2.sent;\n fileUrl = detail.fileUrl || file.fileUrl;\n\n if (fileUrl) {\n _context2.next = 9;\n break;\n }\n\n _this11.$message.warning('无法获取文件下载地址');\n\n return _context2.abrupt(\"return\");\n\n case 9:\n _context2.next = 11;\n return fetch(fileUrl);\n\n case 11:\n response = _context2.sent;\n\n if (response.ok) {\n _context2.next = 14;\n break;\n }\n\n throw new Error('下载文件失败');\n\n case 14:\n _context2.next = 16;\n return response.arrayBuffer();\n\n case 16:\n ab = _context2.sent;\n\n if (ab.byteLength) {\n _context2.next = 20;\n break;\n }\n\n _this11.docxHtml = '<p>(空文档)</p>';\n return _context2.abrupt(\"return\");\n\n case 20:\n _context2.next = 22;\n return _mammoth.default.convertToHtml({\n arrayBuffer: ab\n });\n\n case 22:\n result = _context2.sent;\n _this11.docxHtml = result.value || '<p>(空文档)</p>';\n _context2.next = 30;\n break;\n\n case 26:\n _context2.prev = 26;\n _context2.t0 = _context2[\"catch\"](1);\n console.error('加载 Word 文件失败', _context2.t0);\n\n _this11.$message.error('Word 文件加载失败');\n\n case 30:\n _context2.prev = 30;\n _this11.docxLoading = false;\n return _context2.finish(30);\n\n case 33:\n case \"end\":\n return _context2.stop();\n }\n }\n }, _callee2, null, [[1, 26, 30, 33]]);\n }))();\n },\n // ==================== PDF 预览 ====================\n loadPdfPreview: function loadPdfPreview(file) {\n var _this12 = this;\n\n return (0, _asyncToGenerator2.default)( /*#__PURE__*/regeneratorRuntime.mark(function _callee3() {\n var detail, fileUrl, response, blob;\n return regeneratorRuntime.wrap(function _callee3$(_context3) {\n while (1) {\n switch (_context3.prev = _context3.next) {\n case 0:\n _context3.prev = 0;\n _context3.next = 3;\n return (0, _knowledgeBase.getFileDetail)(file.id);\n\n case 3:\n detail = _context3.sent;\n fileUrl = detail.fileUrl || file.fileUrl;\n\n if (fileUrl) {\n _context3.next = 8;\n break;\n }\n\n _this12.$message.warning('无法获取文件下载地址');\n\n return _context3.abrupt(\"return\");\n\n case 8:\n _context3.next = 10;\n return fetch(fileUrl);\n\n case 10:\n response = _context3.sent;\n\n if (response.ok) {\n _context3.next = 13;\n break;\n }\n\n throw new Error('下载文件失败');\n\n case 13:\n _context3.next = 15;\n return response.blob();\n\n case 15:\n blob = _context3.sent;\n _this12.pdfBlobUrl = URL.createObjectURL(blob);\n _context3.next = 23;\n break;\n\n case 19:\n _context3.prev = 19;\n _context3.t0 = _context3[\"catch\"](0);\n console.error('加载 PDF 文件失败', _context3.t0);\n\n _this12.$message.error('PDF 文件加载失败');\n\n case 23:\n case \"end\":\n return _context3.stop();\n }\n }\n }, _callee3, null, [[0, 19]]);\n }))();\n },\n\n /**\n * 索引 / 重建索引(二次确认)\n */\n handleIndex: function handleIndex(row) {\n var _this13 = this;\n\n var isRebuild = row.indexStatus === 1;\n console.log('[DocumentList] 索引文件:', row.id, row.title, 'companyId:', this.companyId);\n this.$confirm(\"\\u786E\\u8BA4\\u5BF9\\u6587\\u4EF6\\u300C\".concat(row.title || row.fileName, \"\\u300D\").concat(isRebuild ? '重建' : '创建', \"\\u7D22\\u5F15\\uFF1F\"), '提示', {\n type: 'warning',\n confirmButtonText: '确定',\n cancelButtonText: '取消'\n }).then(function () {\n var request = isRebuild ? (0, _knowledgeBase.reindexFile)(row.id) : (0, _knowledgeBase.indexFile)(row.id);\n request.then(function () {\n _this13.$message.success(isRebuild ? '已开始重建索引' : '已开始索引');\n\n _this13.loadList();\n }).catch(function () {});\n }).catch(function () {});\n },\n\n /**\n * 删除索引(二次确认)\n */\n handleDeleteIndex: function handleDeleteIndex(row) {\n var _this14 = this;\n\n this.$confirm(\"\\u786E\\u8BA4\\u5220\\u9664\\u6587\\u4EF6\\u300C\".concat(row.title || row.fileName, \"\\u300D\\u7684\\u7D22\\u5F15\\uFF1F\\u5220\\u9664\\u540E\\u65E0\\u6CD5\\u6062\\u590D\\u3002\"), '提示', {\n type: 'warning',\n confirmButtonText: '确定删除',\n cancelButtonText: '取消'\n }).then(function () {\n (0, _knowledgeBase.deleteFileIndex)(row.id).then(function () {\n _this14.$message.success('索引已删除');\n\n _this14.loadList();\n }).catch(function () {});\n }).catch(function () {});\n },\n handleDelete: function handleDelete(row) {\n var _this15 = this;\n\n // 索引中的文件不允许删除\n if (row.indexStatus === 2) {\n this.$message.warning('该文件正在索引中,无法删除');\n return;\n }\n\n var hasIndex = row.indexStatus === 1;\n this.$confirm(\"\\u786E\\u8BA4\\u5220\\u9664\\u6587\\u4EF6\\u300C\".concat(row.title || row.fileName, \"\\u300D\\uFF1F\").concat(hasIndex ? '删除文件前会先删除该文件的索引。' : '', \"\\u5220\\u9664\\u540E\\u65E0\\u6CD5\\u6062\\u590D\\u3002\"), '提示', {\n type: 'warning',\n confirmButtonText: '确定删除',\n cancelButtonText: '取消'\n }).then( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/regeneratorRuntime.mark(function _callee4() {\n return regeneratorRuntime.wrap(function _callee4$(_context4) {\n while (1) {\n switch (_context4.prev = _context4.next) {\n case 0:\n _context4.prev = 0;\n\n if (!hasIndex) {\n _context4.next = 4;\n break;\n }\n\n _context4.next = 4;\n return (0, _knowledgeBase.deleteFileIndex)(row.id);\n\n case 4:\n _context4.next = 6;\n return (0, _knowledgeBase.deleteFile)(row.id);\n\n case 6:\n _this15.$message.success('文件已删除');\n\n _this15.handleDeleted(1);\n\n _context4.next = 12;\n break;\n\n case 10:\n _context4.prev = 10;\n _context4.t0 = _context4[\"catch\"](0);\n\n case 12:\n case \"end\":\n return _context4.stop();\n }\n }\n }, _callee4, null, [[0, 10]]);\n }))).catch(function () {});\n },\n\n /**\n * 表格勾选变化\n */\n handleSelectionChange: function handleSelectionChange(rows) {\n this.selectedRows = rows || [];\n },\n\n /**\n * 索引中的文件不可勾选删除\n */\n rowSelectable: function rowSelectable(row) {\n return row.indexStatus !== 2;\n },\n\n /**\n * 批量删除勾选的文件\n */\n handleBatchDelete: function handleBatchDelete() {\n var _this16 = this;\n\n var selected = this.selectedRows || [];\n\n if (!selected.length) {\n this.$message.warning('请先勾选要删除的文件');\n return;\n } // 索引中的文件不允许删除\n\n\n var indexingFiles = selected.filter(function (f) {\n return f.indexStatus === 2;\n });\n var deletable = selected.filter(function (f) {\n return f.indexStatus !== 2;\n });\n\n if (!deletable.length) {\n this.$message.warning('所选文件均正在索引中,无法删除');\n return;\n }\n\n if (indexingFiles.length) {\n this.$message.warning(\"\\u6709 \".concat(indexingFiles.length, \" \\u4E2A\\u6587\\u4EF6\\u6B63\\u5728\\u7D22\\u5F15\\u4E2D\\uFF0C\\u672C\\u6B21\\u5C06\\u8DF3\\u8FC7\"));\n } // 已索引的文件需先删除索引,再删除文件\n\n\n var indexed = deletable.filter(function (f) {\n return f.indexStatus === 1;\n });\n var ids = deletable.map(function (f) {\n return f.id;\n });\n this.$confirm(\"\\u786E\\u8BA4\\u5220\\u9664\\u9009\\u4E2D\\u7684 \".concat(deletable.length, \" \\u4E2A\\u6587\\u4EF6\\uFF1F\").concat(indexed.length ? '删除前会先删除这些文件的索引。' : '', \"\\u5220\\u9664\\u540E\\u65E0\\u6CD5\\u6062\\u590D\\u3002\"), '提示', {\n type: 'warning',\n confirmButtonText: '确定删除',\n cancelButtonText: '取消',\n customClass: 'kb-message-box'\n }).then( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/regeneratorRuntime.mark(function _callee5() {\n return regeneratorRuntime.wrap(function _callee5$(_context5) {\n while (1) {\n switch (_context5.prev = _context5.next) {\n case 0:\n _context5.prev = 0;\n\n if (!indexed.length) {\n _context5.next = 4;\n break;\n }\n\n _context5.next = 4;\n return Promise.all(indexed.map(function (f) {\n return (0, _knowledgeBase.deleteFileIndex)(f.id);\n }));\n\n case 4:\n _context5.next = 6;\n return (0, _knowledgeBase.deleteFiles)(ids);\n\n case 6:\n _this16.$message.success('批量删除成功');\n\n _this16.handleDeleted(deletable.length);\n\n _context5.next = 12;\n break;\n\n case 10:\n _context5.prev = 10;\n _context5.t0 = _context5[\"catch\"](0);\n\n case 12:\n case \"end\":\n return _context5.stop();\n }\n }\n }, _callee5, null, [[0, 10]]);\n }))).catch(function () {});\n },\n\n /**\n * 批量移动:打开目标文件夹选择弹窗\n */\n handleBatchMove: function handleBatchMove() {\n var _this17 = this;\n\n return (0, _asyncToGenerator2.default)( /*#__PURE__*/regeneratorRuntime.mark(function _callee6() {\n var selected, folders;\n return regeneratorRuntime.wrap(function _callee6$(_context6) {\n while (1) {\n switch (_context6.prev = _context6.next) {\n case 0:\n selected = _this17.selectedRows || [];\n\n if (selected.length) {\n _context6.next = 4;\n break;\n }\n\n _this17.$message.warning('请先勾选要移动的文件');\n\n return _context6.abrupt(\"return\");\n\n case 4:\n if (_this17.companyId) {\n _context6.next = 7;\n break;\n }\n\n _this17.$message.warning('公司数据未加载');\n\n return _context6.abrupt(\"return\");\n\n case 7:\n _this17.moveFolderId = null;\n _this17.moveVisible = true; // 每次打开都重新加载文件夹列表,确保新建/重命名/删除文件夹后看到最新目录\n\n _context6.prev = 9;\n _context6.next = 12;\n return (0, _knowledgeBase.getFolderList)(_this17.companyId);\n\n case 12:\n folders = _context6.sent;\n _this17.folderList = folders || [];\n _context6.next = 18;\n break;\n\n case 16:\n _context6.prev = 16;\n _context6.t0 = _context6[\"catch\"](9);\n\n case 18:\n _this17.$nextTick(function () {\n if (_this17.$refs.moveTreeRef) _this17.$refs.moveTreeRef.setCurrentKey(null);\n });\n\n case 19:\n case \"end\":\n return _context6.stop();\n }\n }\n }, _callee6, null, [[9, 16]]);\n }))();\n },\n\n /**\n * 选择目标文件夹\n */\n handleMoveFolderSelect: function handleMoveFolderSelect(data) {\n this.moveFolderId = data.id;\n },\n\n /**\n * 确认批量移动\n */\n handleMoveConfirm: function handleMoveConfirm() {\n var _this18 = this;\n\n return (0, _asyncToGenerator2.default)( /*#__PURE__*/regeneratorRuntime.mark(function _callee7() {\n var ids, targetFolder;\n return regeneratorRuntime.wrap(function _callee7$(_context7) {\n while (1) {\n switch (_context7.prev = _context7.next) {\n case 0:\n if (_this18.moveFolderId) {\n _context7.next = 3;\n break;\n }\n\n _this18.$message.warning('请选择目标文件夹');\n\n return _context7.abrupt(\"return\");\n\n case 3:\n ids = _this18.selectedRows.map(function (f) {\n return f.id;\n });\n _this18.moving = true;\n _context7.prev = 5;\n _context7.next = 8;\n return (0, _knowledgeBase.moveFiles)(ids, _this18.moveFolderId);\n\n case 8:\n _this18.$message.success('批量移动成功');\n\n _this18.moveVisible = false; // 移动成功后,通知父级定位并高亮左侧树到目标文件夹\n\n targetFolder = _this18.folderList.find(function (f) {\n return String(f.id) === String(_this18.moveFolderId);\n }) || null;\n if (targetFolder) _this18.$emit('move-target', targetFolder);else _this18.$emit('move-target', {\n id: _this18.moveFolderId,\n name: _this18.moveTargetName\n });\n\n _this18.loadList();\n\n _context7.next = 17;\n break;\n\n case 15:\n _context7.prev = 15;\n _context7.t0 = _context7[\"catch\"](5);\n\n case 17:\n _context7.prev = 17;\n _this18.moving = false;\n return _context7.finish(17);\n\n case 20:\n case \"end\":\n return _context7.stop();\n }\n }\n }, _callee7, null, [[5, 15, 17, 20]]);\n }))();\n },\n\n /**\n * 通过 folderId 映射文件夹名称\n */\n folderName: function folderName(folderId) {\n if (!folderId) return '根目录';\n var found = this.categoryList.find(function (f) {\n return String(f.id) === String(folderId);\n });\n return found ? found.name : '-';\n },\n\n /**\n * 根据文件类型返回对应图标\n */\n getFileIcon: function getFileIcon(fileType) {\n var type = (fileType || '').toLowerCase();\n var iconMap = {\n pdf: 'el-icon-document',\n doc: 'el-icon-document',\n docx: 'el-icon-document',\n xls: 'el-icon-tickets',\n xlsx: 'el-icon-tickets',\n ppt: 'el-icon-data-line',\n pptx: 'el-icon-data-line',\n txt: 'el-icon-document',\n md: 'el-icon-edit-outline',\n png: 'el-icon-picture',\n jpg: 'el-icon-picture',\n jpeg: 'el-icon-picture',\n gif: 'el-icon-picture',\n zip: 'el-icon-folder-opened',\n rar: 'el-icon-folder-opened'\n };\n return iconMap[type] || 'el-icon-document';\n },\n\n /**\n * 根据文件类型返回对应的图标 URL\n * 映射统一维护在 @lib/utils/fileType.js(与聊天附件共用)\n */\n getFileIconUrl: function getFileIconUrl(fileType) {\n return (0, _fileType.getFileIconUrl)(fileType);\n },\n\n /**\n * 文件大小格式化(字节 → B/KB/MB/GB)\n */\n formatSize: function formatSize(bytes) {\n if (!bytes && bytes !== 0) return '-';\n if (bytes === 0) return '0 B';\n var units = ['B', 'KB', 'MB', 'GB', 'TB'];\n var size = bytes;\n var idx = 0;\n\n while (size >= 1024 && idx < units.length - 1) {\n size /= 1024;\n idx++;\n }\n\n return \"\".concat(idx === 0 ? size : size.toFixed(2), \" \").concat(units[idx]);\n },\n\n /**\n * 时间展示:ISO 本地时间去掉 T 分隔符\n */\n formatTime: function formatTime(time) {\n if (!time) return '-';\n return String(time).replace('T', ' ').replace(/\\+08:00$/, '').replace(/\\.\\d{3}/, '');\n },\n\n /**\n * 索引状态标签:0 未索引 / 1 已索引 / 2 索引中 / 3 失败\n */\n indexTagType: function indexTagType(status) {\n var map = {\n 0: 'info',\n 1: 'success',\n 2: 'warning',\n 3: 'danger'\n };\n return map[status] || 'info';\n },\n indexTagText: function indexTagText(status) {\n var map = {\n 0: '未索引',\n 1: '已索引',\n 2: '索引中',\n 3: '索引失败'\n };\n return map[status] || '未知';\n }\n }\n};\nexports.default = _default2;\n\n//# sourceURL=webpack://ZjPluginIntelligent/./src/lib/knowledgeBase/DocumentList.vue?./node_modules/cache-loader/dist/cjs.js??ref--12-0!./node_modules/babel-loader/lib!./node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/vue-loader/lib??vue-loader-options");
|
|
1004
1004
|
|
|
1005
1005
|
/***/ }),
|
|
1006
1006
|
|
|
@@ -14747,7 +14747,7 @@ eval("// Generated by CoffeeScript 1.12.7\n(function() {\n var XMLDocument, XML
|
|
|
14747
14747
|
/*! exports provided: name, version, main, private, scripts, dependencies, devDependencies, browserslist, directories, keywords, license, files, default */
|
|
14748
14748
|
/***/ (function(module) {
|
|
14749
14749
|
|
|
14750
|
-
eval("module.exports = JSON.parse(\"{\\\"name\\\":\\\"zj-plugin-intelligent\\\",\\\"version\\\":\\\"1.2.26-beta.
|
|
14750
|
+
eval("module.exports = JSON.parse(\"{\\\"name\\\":\\\"zj-plugin-intelligent\\\",\\\"version\\\":\\\"1.2.26-beta.7\\\",\\\"main\\\":\\\"lib/ZjPluginIntelligent.umd.min.js\\\",\\\"private\\\":false,\\\"scripts\\\":{\\\"serve\\\":\\\"set NODE_OPTIONS=--openssl-legacy-provider && vue-cli-service serve\\\",\\\"build\\\":\\\"set NODE_OPTIONS=--openssl-legacy-provider && vue-cli-service build\\\",\\\"lib\\\":\\\"node scripts/build-lib.js\\\",\\\"lib:test\\\":\\\"node scripts/build-lib.js test\\\"},\\\"dependencies\\\":{\\\"@jboltai/tokui\\\":\\\"^0.1.6\\\",\\\"crypto-js\\\":\\\"^4.2.0\\\",\\\"docx\\\":\\\"^8.5.0\\\",\\\"html2canvas\\\":\\\"^1.4.1\\\",\\\"mammoth\\\":\\\"^1.6.0\\\",\\\"markdown-it\\\":\\\"^13.0.2\\\",\\\"marked\\\":\\\"^4.3.0\\\",\\\"xlsx\\\":\\\"^0.18.5\\\"},\\\"devDependencies\\\":{\\\"@babel/preset-env\\\":\\\"^7.14.9\\\",\\\"@vue/cli-plugin-babel\\\":\\\"~4.5.0\\\",\\\"@vue/cli-plugin-eslint\\\":\\\"~4.5.0\\\",\\\"@vue/cli-plugin-vuex\\\":\\\"~4.5.0\\\",\\\"@vue/cli-service\\\":\\\"~4.5.0\\\",\\\"axios\\\":\\\"^0.27.2\\\",\\\"babel-eslint\\\":\\\"^10.1.0\\\",\\\"babel-plugin-component\\\":\\\"^1.1.1\\\",\\\"compression-webpack-plugin\\\":\\\"^6.0.3\\\",\\\"core-js\\\":\\\"^3.6.5\\\",\\\"element-ui\\\":\\\"^2.15.4\\\",\\\"eslint\\\":\\\"^6.8.0\\\",\\\"eslint-plugin-vue\\\":\\\"^7.13.0\\\",\\\"js-cookie\\\":\\\"^2.2.1\\\",\\\"obs-upload\\\":\\\"^1.0.4\\\",\\\"pako\\\":\\\"^2.1.0\\\",\\\"reconnecting-websocket\\\":\\\"^4.4.0\\\",\\\"sass\\\":\\\"^1.71.0\\\",\\\"sass-loader\\\":\\\"^8.0.2\\\",\\\"snowflake-id\\\":\\\"^1.1.0\\\",\\\"vue\\\":\\\"^2.6.11\\\",\\\"vue-template-compiler\\\":\\\"^2.6.11\\\",\\\"vuex\\\":\\\"^3.4.0\\\",\\\"webpack-bundle-analyzer\\\":\\\"^4.4.2\\\"},\\\"browserslist\\\":[\\\"> 1%\\\",\\\"last 2 versions\\\",\\\"not dead\\\"],\\\"directories\\\":{\\\"lib\\\":\\\"lib\\\"},\\\"keywords\\\":[],\\\"license\\\":\\\"ISC\\\",\\\"files\\\":[\\\"lib\\\"]}\");\n\n//# sourceURL=webpack://ZjPluginIntelligent/./package.json?");
|
|
14751
14751
|
|
|
14752
14752
|
/***/ }),
|
|
14753
14753
|
|
|
@@ -1009,7 +1009,7 @@ eval("\n\nvar _interopRequireWildcard = __webpack_require__(/*! ./node_modules/@
|
|
|
1009
1009
|
/***/ (function(module, exports, __webpack_require__) {
|
|
1010
1010
|
|
|
1011
1011
|
"use strict";
|
|
1012
|
-
eval("\n\nvar _interopRequireWildcard = __webpack_require__(/*! ./node_modules/@babel/runtime/helpers/interopRequireWildcard */ \"./node_modules/@babel/runtime/helpers/interopRequireWildcard.js\").default;\n\nvar _interopRequireDefault = __webpack_require__(/*! ./node_modules/@babel/runtime/helpers/interopRequireDefault */ \"./node_modules/@babel/runtime/helpers/interopRequireDefault.js\").default;\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.default = void 0;\n\nvar _asyncToGenerator2 = _interopRequireDefault(__webpack_require__(/*! ./node_modules/@babel/runtime/helpers/asyncToGenerator */ \"./node_modules/@babel/runtime/helpers/asyncToGenerator.js\"));\n\nvar _objectSpread2 = _interopRequireDefault(__webpack_require__(/*! ./node_modules/@babel/runtime/helpers/objectSpread2 */ \"./node_modules/@babel/runtime/helpers/objectSpread2.js\"));\n\nvar _marked = __webpack_require__(/*! marked */ \"./node_modules/marked/lib/marked.esm.js\");\n\nvar XLSX = _interopRequireWildcard(__webpack_require__(/*! xlsx */ \"./node_modules/xlsx/xlsx.mjs\"));\n\nvar _mammoth = _interopRequireDefault(__webpack_require__(/*! mammoth */ \"./node_modules/mammoth/lib/index.js\"));\n\nvar _knowledgeBase = __webpack_require__(/*! ./api/knowledgeBase */ \"./src/lib/knowledgeBase/api/knowledgeBase.js\");\n\nvar _fileType = __webpack_require__(/*! @lib/utils/fileType */ \"./src/lib/utils/fileType.js\");\n\nvar _DocumentForm = _interopRequireDefault(__webpack_require__(/*! ./DocumentForm */ \"./src/lib/knowledgeBase/DocumentForm.vue\"));\n\nvar _MobileDialog = _interopRequireDefault(__webpack_require__(/*! ./MobileDialog.vue */ \"./src/lib/knowledgeBase/MobileDialog.vue\"));\n\nvar _native = __webpack_require__(/*! ./native.js */ \"./src/lib/knowledgeBase/native.js\");\n\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n// 预览最多显示的行数(防止大文件卡死)\nvar MAX_PREVIEW_ROWS = 500;\nvar _default2 = {\n name: 'DocumentList',\n components: {\n DocumentForm: _DocumentForm.default,\n MobileDialog: _MobileDialog.default\n },\n props: {\n selectedCategory: {\n type: Object,\n default: null\n },\n categoryList: {\n type: Array,\n default: function _default() {\n return [];\n }\n },\n companyId: {\n type: String,\n default: ''\n },\n // 是否移动端(由父组件根据宽度传入;未传时按窗口宽度自动判断)\n isMobile: {\n type: Boolean,\n default: null\n },\n // 是否管理员:false(普通成员)时隐藏新增/编辑/索引/删除/批量操作与勾选列,仅保留预览\n isAdmin: {\n type: Boolean,\n default: true\n }\n },\n data: function data() {\n return {\n list: [],\n loading: false,\n total: 0,\n page: 1,\n pageSize: 10,\n searchKeyword: '',\n // 批量删除选中的文件\n selectedRows: [],\n // 批量移动\n moveVisible: false,\n moveFolderId: null,\n moving: false,\n folderList: [],\n folderTreeProps: {\n children: 'children',\n label: 'name'\n },\n // 在线预览\n previewVisible: false,\n previewFile: null,\n previewType: 'none',\n previewText: '',\n // PDF 预览(Blob URL 避免下载)\n pdfBlobUrl: '',\n // Excel 预览\n xlsxLoading: false,\n xlsxWorkbook: null,\n xlsxSheetNames: [],\n xlsxCurrentSheet: '',\n xlsxCols: [],\n xlsxTableData: [],\n hasMoreRows: false,\n // Word 预览\n docxLoading: false,\n docxHtml: '',\n // 窗口宽度(横屏判断:isMobile 且宽>768 时操作按钮与搜索同行)\n innerWidth: typeof window !== 'undefined' ? window.innerWidth : 0\n };\n },\n computed: {\n /**\n * 移动端横屏(宽>768,如平板横屏):空间充足,操作按钮与搜索同行\n */\n isLandscape: function isLandscape() {\n return !!this.isMobile && this.innerWidth > 768;\n },\n\n /**\n * 总页数(横屏自绘分页用)\n */\n totalPages: function totalPages() {\n return Math.max(1, Math.ceil((this.total || 0) / this.pageSize));\n },\n\n /**\n * 横屏表格:当前页可勾选的行(索引中的文件不可勾选)\n */\n selectableRows: function selectableRows() {\n var _this = this;\n\n return (this.list || []).filter(function (row) {\n return _this.rowSelectable(row);\n });\n },\n\n /**\n * 横屏表格:表头全选是否为选中态\n */\n isAllSelected: function isAllSelected() {\n var _this2 = this;\n\n return this.selectableRows.length > 0 && this.selectableRows.every(function (row) {\n return _this2.docMSelected(row);\n });\n },\n\n /**\n * 横屏表格:表头全选是否为半选态\n */\n isIndeterminate: function isIndeterminate() {\n var _this3 = this;\n\n var checked = this.selectableRows.filter(function (row) {\n return _this3.docMSelected(row);\n }).length;\n return checked > 0 && checked < this.selectableRows.length;\n },\n\n /**\n * Markdown 渲染后的 HTML(使用 marked)\n */\n previewHtml: function previewHtml() {\n if (!this.previewText) return '';\n return _marked.marked.parse(this.previewText, {\n breaks: true,\n gfm: true\n });\n },\n maxPreviewRows: function maxPreviewRows() {\n return MAX_PREVIEW_ROWS;\n },\n\n /**\n * 批量移动的文件夹树(由平铺列表组装)\n */\n moveFolderTree: function moveFolderTree() {\n var nodes = this.folderList.map(function (f) {\n return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, f), {}, {\n children: []\n });\n });\n var map = {};\n nodes.forEach(function (n) {\n map[n.id] = n;\n });\n var roots = [];\n nodes.forEach(function (n) {\n var pid = n.parentId || 0;\n if (map[pid]) map[pid].children.push(n);else roots.push(n);\n });\n return roots;\n },\n\n /**\n * 批量移动的文件夹扁平列表(移动端自绘列表用)\n */\n moveFolderFlat: function moveFolderFlat() {\n return (0, _native.flattenFolderTree)(this.moveFolderTree);\n },\n\n /**\n * 目标文件夹名称\n */\n moveTargetName: function moveTargetName() {\n var _this4 = this;\n\n if (!this.moveFolderId) return '';\n var f = this.folderList.find(function (x) {\n return x.id === _this4.moveFolderId;\n });\n return f ? f.name : '';\n }\n },\n watch: {\n selectedCategory: function selectedCategory() {\n this.page = 1;\n this.loadList();\n },\n companyId: function companyId() {\n this.page = 1;\n this.searchKeyword = '';\n this.list = [];\n this.total = 0;\n this.loadList();\n },\n\n /**\n * 预览弹窗关闭时清理 PDF Blob URL\n */\n previewVisible: function previewVisible(val) {\n if (!val && this.pdfBlobUrl) {\n URL.revokeObjectURL(this.pdfBlobUrl);\n this.pdfBlobUrl = '';\n }\n }\n },\n created: function created() {\n this.loadList(); // 跟踪窗口宽度用于横屏判断(旋转屏幕时按钮行内/换行切换)\n\n if (typeof window !== 'undefined') {\n this.innerWidth = window.innerWidth;\n window.addEventListener('resize', this.handleWinResize);\n }\n },\n beforeDestroy: function beforeDestroy() {\n if (typeof window !== 'undefined') {\n window.removeEventListener('resize', this.handleWinResize);\n }\n },\n methods: {\n handleWinResize: function handleWinResize() {\n if (typeof window !== 'undefined') {\n this.innerWidth = window.innerWidth;\n }\n },\n loadList: function loadList() {\n var _this5 = this;\n\n var append = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;\n if (!this.companyId) return;\n this.loading = true;\n var params = {\n companyId: this.companyId,\n pageNum: this.page,\n pageSize: this.pageSize\n }; // 选中具体文件夹时按文件夹过滤(\"显示全部文件\"时 id 为空串,不传)\n\n if (this.selectedCategory && this.selectedCategory.id) {\n params.folderId = this.selectedCategory.id;\n }\n\n if (this.searchKeyword) {\n params.keyword = this.searchKeyword;\n }\n\n (0, _knowledgeBase.getFileList)(params).then(function (data) {\n // append:移动端「加载更多」追加到列表尾部\n if (append) {\n _this5.list = (_this5.list || []).concat(data.records || []);\n } else {\n _this5.list = data.records || []; // 列表刷新后清空勾选\n\n _this5.selectedRows = [];\n\n _this5.$nextTick(function () {\n // 移动端 el-table 不渲染,$refs.tableRef 可能不存在或非 el-table 实例\n if (_this5.$refs.tableRef && typeof _this5.$refs.tableRef.clearSelection === 'function') {\n _this5.$refs.tableRef.clearSelection();\n }\n });\n }\n\n _this5.total = data.total || 0;\n }).catch(function () {}).finally(function () {\n _this5.loading = false;\n });\n },\n\n /**\n * 移动端:加载更多(追加下一页)\n */\n loadMore: function loadMore() {\n if (this.loading) return;\n this.page += 1;\n this.loadList(true);\n },\n\n /**\n * 移动端:当前是否已勾选该文件\n */\n docMSelected: function docMSelected(row) {\n return (this.selectedRows || []).some(function (x) {\n return x && x.id === row.id;\n });\n },\n\n /**\n * 移动端:切换勾选(索引中的文件不可勾选)\n */\n toggleMSelected: function toggleMSelected(row) {\n if (row.indexStatus === 2) return;\n var i = (this.selectedRows || []).findIndex(function (x) {\n return x && x.id === row.id;\n });\n if (i >= 0) this.selectedRows.splice(i, 1);else this.selectedRows.push(row);\n },\n\n /**\n * 移动端横屏表格:表头全选/取消全选(仅作用于当前页可选行)\n */\n toggleSelectAll: function toggleSelectAll(e) {\n var _this6 = this;\n\n var checked = e && e.target ? e.target.checked : !this.isAllSelected;\n var selectable = this.selectableRows;\n\n if (checked) {\n selectable.forEach(function (row) {\n if (!_this6.docMSelected(row)) _this6.selectedRows.push(row);\n });\n } else {\n var ids = selectable.map(function (row) {\n return row.id;\n });\n this.selectedRows = (this.selectedRows || []).filter(function (row) {\n return !row || ids.indexOf(row.id) === -1;\n });\n }\n },\n handleSearch: function handleSearch() {\n this.page = 1;\n this.loadList();\n },\n handleSizeChange: function handleSizeChange(size) {\n this.pageSize = size;\n this.page = 1;\n this.loadList();\n },\n handleCurrentChange: function handleCurrentChange(page) {\n this.page = page;\n this.loadList();\n },\n\n /**\n * 删除文件后刷新列表:若当前页因删除而超出最大页数(如某页只剩 1 条被删掉),\n * 自动回退到最后一页(即上一页),避免停留在空白页。\n */\n handleDeleted: function handleDeleted() {\n var count = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;\n var newTotal = Math.max(0, this.total - count);\n var maxPage = Math.max(1, Math.ceil(newTotal / this.pageSize));\n\n if (this.page > maxPage) {\n this.page = maxPage;\n }\n\n this.loadList();\n },\n handleAdd: function handleAdd() {\n var _this7 = this;\n\n if (!this.companyId) {\n this.$message.warning('公司数据未加载,请稍后刷新');\n return;\n }\n\n if (!this.categoryList || this.categoryList.length === 0) {\n this.$message.warning('暂无根目录,请先创建文件夹再新增文档');\n return;\n }\n\n var folderId = this.selectedCategory && this.selectedCategory.id ? this.selectedCategory.id : '';\n this.$refs.docFormRef.openAdd(folderId).then(function (res) {\n if (res) _this7.loadList();\n });\n },\n handleEdit: function handleEdit(row) {\n var _this8 = this;\n\n this.$refs.docFormRef.openEdit(row).then(function (res) {\n if (res) _this8.loadList();\n });\n },\n\n /**\n * 在线预览:图片 / PDF / Excel / Word / 文本\n */\n handlePreview: function handlePreview(row) {\n var _this9 = this;\n\n this.previewFile = row;\n this.previewText = '';\n this.docxHtml = '';\n this.xlsxWorkbook = null;\n this.xlsxSheetNames = [];\n this.xlsxCurrentSheet = '';\n this.xlsxCols = [];\n this.xlsxTableData = []; // 清理上一次的 PDF Blob URL\n\n if (this.pdfBlobUrl) {\n URL.revokeObjectURL(this.pdfBlobUrl);\n this.pdfBlobUrl = '';\n }\n\n var t = (row.fileType || '').toLowerCase();\n\n if (['png', 'jpg', 'jpeg', 'gif', 'webp', 'bmp'].includes(t)) {\n this.previewType = 'image';\n } else if (t === 'pdf') {\n this.previewType = 'pdf';\n this.loadPdfPreview(row);\n } else if (t === 'xlsx' || t === 'xls') {\n this.previewType = 'xlsx';\n this.loadXlsxPreview(row);\n } else if (t === 'docx' || t === 'doc') {\n this.previewType = 'docx';\n this.loadDocxPreview(row);\n } else if (['txt', 'md', 'markdown', 'html', 'htm'].includes(t)) {\n this.previewType = 'text';\n (0, _knowledgeBase.getFileDetail)(row.id).then(function (d) {\n _this9.previewText = d.content || '(该文件暂无可预览的文本内容)';\n }).catch(function () {\n _this9.previewText = '(文本内容加载失败)';\n });\n } else {\n this.previewType = 'none';\n }\n\n this.previewVisible = true;\n },\n // ==================== Excel 预览 ====================\n loadXlsxPreview: function loadXlsxPreview(file) {\n var _this10 = this;\n\n return (0, _asyncToGenerator2.default)( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {\n var detail, fileUrl, response, ab, workbook;\n return regeneratorRuntime.wrap(function _callee$(_context) {\n while (1) {\n switch (_context.prev = _context.next) {\n case 0:\n _this10.xlsxLoading = true;\n _context.prev = 1;\n _context.next = 4;\n return (0, _knowledgeBase.getFileDetail)(file.id);\n\n case 4:\n detail = _context.sent;\n fileUrl = detail.fileUrl || file.fileUrl;\n\n if (fileUrl) {\n _context.next = 9;\n break;\n }\n\n _this10.$message.warning('无法获取文件下载地址');\n\n return _context.abrupt(\"return\");\n\n case 9:\n _context.next = 11;\n return fetch(fileUrl);\n\n case 11:\n response = _context.sent;\n\n if (response.ok) {\n _context.next = 14;\n break;\n }\n\n throw new Error('下载文件失败');\n\n case 14:\n _context.next = 16;\n return response.arrayBuffer();\n\n case 16:\n ab = _context.sent;\n _context.next = 19;\n return new Promise(function (r) {\n return setTimeout(r, 0);\n });\n\n case 19:\n workbook = XLSX.read(ab, {\n type: 'array'\n });\n _this10.xlsxWorkbook = workbook;\n _this10.xlsxSheetNames = workbook.SheetNames;\n\n if (workbook.SheetNames.length > 0) {\n _this10.xlsxCurrentSheet = workbook.SheetNames[0];\n\n _this10.renderXlsxSheet();\n }\n\n _context.next = 29;\n break;\n\n case 25:\n _context.prev = 25;\n _context.t0 = _context[\"catch\"](1);\n console.error('加载 Excel 文件失败', _context.t0);\n\n _this10.$message.error('Excel 文件加载失败');\n\n case 29:\n _context.prev = 29;\n _this10.xlsxLoading = false;\n return _context.finish(29);\n\n case 32:\n case \"end\":\n return _context.stop();\n }\n }\n }, _callee, null, [[1, 25, 29, 32]]);\n }))();\n },\n renderXlsxSheet: function renderXlsxSheet() {\n var workbook = this.xlsxWorkbook;\n var sheetName = this.xlsxCurrentSheet;\n if (!workbook || !sheetName) return;\n var sheet = workbook.Sheets[sheetName];\n\n if (!sheet) {\n this.xlsxCols = [];\n this.xlsxTableData = [];\n return;\n } // 让出主线程,防止 sheet_to_json 阻塞 UI\n\n\n var data = XLSX.utils.sheet_to_json(sheet, {\n header: 1,\n defval: ''\n });\n\n if (data.length === 0) {\n this.xlsxCols = [];\n this.xlsxTableData = [];\n return;\n } // 列数以「所有行的最大宽度」为准:表头行可能只填了第一格,若直接按第一行长度定列会丢失后续列\n\n\n var maxCols = Math.max.apply(null, data.map(function (row) {\n return row && row.length || 0;\n }));\n this.xlsxCols = Array.from({\n length: maxCols\n }, function (_, i) {\n var v = data[0] && data[0][i];\n return v != null && String(v).trim() !== '' ? String(v) : \"\\u5217\".concat(i + 1);\n }); // 限制预览行数,防止渲染过多 DOM 卡死;同时过滤全空行\n\n var allRows = data.slice(1).filter(function (row) {\n return row && row.some(function (c) {\n return c != null && String(c).trim() !== '';\n });\n });\n this.hasMoreRows = allRows.length > MAX_PREVIEW_ROWS;\n this.xlsxTableData = allRows.slice(0, MAX_PREVIEW_ROWS).map(function (row) {\n var obj = {};\n\n for (var ci = 0; ci < maxCols; ci++) {\n obj[ci] = row[ci] != null ? String(row[ci]) : '';\n }\n\n return obj;\n });\n },\n // ==================== Word 预览 ====================\n loadDocxPreview: function loadDocxPreview(file) {\n var _this11 = this;\n\n return (0, _asyncToGenerator2.default)( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() {\n var detail, fileUrl, response, ab, result;\n return regeneratorRuntime.wrap(function _callee2$(_context2) {\n while (1) {\n switch (_context2.prev = _context2.next) {\n case 0:\n _this11.docxLoading = true;\n _context2.prev = 1;\n _context2.next = 4;\n return (0, _knowledgeBase.getFileDetail)(file.id);\n\n case 4:\n detail = _context2.sent;\n fileUrl = detail.fileUrl || file.fileUrl;\n\n if (fileUrl) {\n _context2.next = 9;\n break;\n }\n\n _this11.$message.warning('无法获取文件下载地址');\n\n return _context2.abrupt(\"return\");\n\n case 9:\n _context2.next = 11;\n return fetch(fileUrl);\n\n case 11:\n response = _context2.sent;\n\n if (response.ok) {\n _context2.next = 14;\n break;\n }\n\n throw new Error('下载文件失败');\n\n case 14:\n _context2.next = 16;\n return response.arrayBuffer();\n\n case 16:\n ab = _context2.sent;\n\n if (ab.byteLength) {\n _context2.next = 20;\n break;\n }\n\n _this11.docxHtml = '<p>(空文档)</p>';\n return _context2.abrupt(\"return\");\n\n case 20:\n _context2.next = 22;\n return _mammoth.default.convertToHtml({\n arrayBuffer: ab\n });\n\n case 22:\n result = _context2.sent;\n _this11.docxHtml = result.value || '<p>(空文档)</p>';\n _context2.next = 30;\n break;\n\n case 26:\n _context2.prev = 26;\n _context2.t0 = _context2[\"catch\"](1);\n console.error('加载 Word 文件失败', _context2.t0);\n\n _this11.$message.error('Word 文件加载失败');\n\n case 30:\n _context2.prev = 30;\n _this11.docxLoading = false;\n return _context2.finish(30);\n\n case 33:\n case \"end\":\n return _context2.stop();\n }\n }\n }, _callee2, null, [[1, 26, 30, 33]]);\n }))();\n },\n // ==================== PDF 预览 ====================\n loadPdfPreview: function loadPdfPreview(file) {\n var _this12 = this;\n\n return (0, _asyncToGenerator2.default)( /*#__PURE__*/regeneratorRuntime.mark(function _callee3() {\n var detail, fileUrl, response, blob;\n return regeneratorRuntime.wrap(function _callee3$(_context3) {\n while (1) {\n switch (_context3.prev = _context3.next) {\n case 0:\n _context3.prev = 0;\n _context3.next = 3;\n return (0, _knowledgeBase.getFileDetail)(file.id);\n\n case 3:\n detail = _context3.sent;\n fileUrl = detail.fileUrl || file.fileUrl;\n\n if (fileUrl) {\n _context3.next = 8;\n break;\n }\n\n _this12.$message.warning('无法获取文件下载地址');\n\n return _context3.abrupt(\"return\");\n\n case 8:\n _context3.next = 10;\n return fetch(fileUrl);\n\n case 10:\n response = _context3.sent;\n\n if (response.ok) {\n _context3.next = 13;\n break;\n }\n\n throw new Error('下载文件失败');\n\n case 13:\n _context3.next = 15;\n return response.blob();\n\n case 15:\n blob = _context3.sent;\n _this12.pdfBlobUrl = URL.createObjectURL(blob);\n _context3.next = 23;\n break;\n\n case 19:\n _context3.prev = 19;\n _context3.t0 = _context3[\"catch\"](0);\n console.error('加载 PDF 文件失败', _context3.t0);\n\n _this12.$message.error('PDF 文件加载失败');\n\n case 23:\n case \"end\":\n return _context3.stop();\n }\n }\n }, _callee3, null, [[0, 19]]);\n }))();\n },\n\n /**\n * 索引 / 重建索引(二次确认)\n */\n handleIndex: function handleIndex(row) {\n var _this13 = this;\n\n var isRebuild = row.indexStatus === 1;\n console.log('[DocumentList] 索引文件:', row.id, row.title, 'companyId:', this.companyId);\n this.$confirm(\"\\u786E\\u8BA4\\u5BF9\\u6587\\u4EF6\\u300C\".concat(row.title || row.fileName, \"\\u300D\").concat(isRebuild ? '重建' : '创建', \"\\u7D22\\u5F15\\uFF1F\"), '提示', {\n type: 'warning',\n confirmButtonText: '确定',\n cancelButtonText: '取消'\n }).then(function () {\n var request = isRebuild ? (0, _knowledgeBase.reindexFile)(row.id) : (0, _knowledgeBase.indexFile)(row.id);\n request.then(function () {\n _this13.$message.success(isRebuild ? '已开始重建索引' : '已开始索引');\n\n _this13.loadList();\n }).catch(function () {});\n }).catch(function () {});\n },\n\n /**\n * 删除索引(二次确认)\n */\n handleDeleteIndex: function handleDeleteIndex(row) {\n var _this14 = this;\n\n this.$confirm(\"\\u786E\\u8BA4\\u5220\\u9664\\u6587\\u4EF6\\u300C\".concat(row.title || row.fileName, \"\\u300D\\u7684\\u7D22\\u5F15\\uFF1F\\u5220\\u9664\\u540E\\u65E0\\u6CD5\\u6062\\u590D\\u3002\"), '提示', {\n type: 'warning',\n confirmButtonText: '确定删除',\n cancelButtonText: '取消'\n }).then(function () {\n (0, _knowledgeBase.deleteFileIndex)(row.id).then(function () {\n _this14.$message.success('索引已删除');\n\n _this14.loadList();\n }).catch(function () {});\n }).catch(function () {});\n },\n handleDelete: function handleDelete(row) {\n var _this15 = this;\n\n // 索引中的文件不允许删除\n if (row.indexStatus === 2) {\n this.$message.warning('该文件正在索引中,无法删除');\n return;\n }\n\n var hasIndex = row.indexStatus === 1;\n this.$confirm(\"\\u786E\\u8BA4\\u5220\\u9664\\u6587\\u4EF6\\u300C\".concat(row.title || row.fileName, \"\\u300D\\uFF1F\").concat(hasIndex ? '删除文件前会先删除该文件的索引。' : '', \"\\u5220\\u9664\\u540E\\u65E0\\u6CD5\\u6062\\u590D\\u3002\"), '提示', {\n type: 'warning',\n confirmButtonText: '确定删除',\n cancelButtonText: '取消'\n }).then( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/regeneratorRuntime.mark(function _callee4() {\n return regeneratorRuntime.wrap(function _callee4$(_context4) {\n while (1) {\n switch (_context4.prev = _context4.next) {\n case 0:\n _context4.prev = 0;\n\n if (!hasIndex) {\n _context4.next = 4;\n break;\n }\n\n _context4.next = 4;\n return (0, _knowledgeBase.deleteFileIndex)(row.id);\n\n case 4:\n _context4.next = 6;\n return (0, _knowledgeBase.deleteFile)(row.id);\n\n case 6:\n _this15.$message.success('文件已删除');\n\n _this15.handleDeleted(1);\n\n _context4.next = 12;\n break;\n\n case 10:\n _context4.prev = 10;\n _context4.t0 = _context4[\"catch\"](0);\n\n case 12:\n case \"end\":\n return _context4.stop();\n }\n }\n }, _callee4, null, [[0, 10]]);\n }))).catch(function () {});\n },\n\n /**\n * 表格勾选变化\n */\n handleSelectionChange: function handleSelectionChange(rows) {\n this.selectedRows = rows || [];\n },\n\n /**\n * 索引中的文件不可勾选删除\n */\n rowSelectable: function rowSelectable(row) {\n return row.indexStatus !== 2;\n },\n\n /**\n * 批量删除勾选的文件\n */\n handleBatchDelete: function handleBatchDelete() {\n var _this16 = this;\n\n var selected = this.selectedRows || [];\n\n if (!selected.length) {\n this.$message.warning('请先勾选要删除的文件');\n return;\n } // 索引中的文件不允许删除\n\n\n var indexingFiles = selected.filter(function (f) {\n return f.indexStatus === 2;\n });\n var deletable = selected.filter(function (f) {\n return f.indexStatus !== 2;\n });\n\n if (!deletable.length) {\n this.$message.warning('所选文件均正在索引中,无法删除');\n return;\n }\n\n if (indexingFiles.length) {\n this.$message.warning(\"\\u6709 \".concat(indexingFiles.length, \" \\u4E2A\\u6587\\u4EF6\\u6B63\\u5728\\u7D22\\u5F15\\u4E2D\\uFF0C\\u672C\\u6B21\\u5C06\\u8DF3\\u8FC7\"));\n } // 已索引的文件需先删除索引,再删除文件\n\n\n var indexed = deletable.filter(function (f) {\n return f.indexStatus === 1;\n });\n var ids = deletable.map(function (f) {\n return f.id;\n });\n this.$confirm(\"\\u786E\\u8BA4\\u5220\\u9664\\u9009\\u4E2D\\u7684 \".concat(deletable.length, \" \\u4E2A\\u6587\\u4EF6\\uFF1F\").concat(indexed.length ? '删除前会先删除这些文件的索引。' : '', \"\\u5220\\u9664\\u540E\\u65E0\\u6CD5\\u6062\\u590D\\u3002\"), '提示', {\n type: 'warning',\n confirmButtonText: '确定删除',\n cancelButtonText: '取消',\n customClass: 'kb-message-box'\n }).then( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/regeneratorRuntime.mark(function _callee5() {\n return regeneratorRuntime.wrap(function _callee5$(_context5) {\n while (1) {\n switch (_context5.prev = _context5.next) {\n case 0:\n _context5.prev = 0;\n\n if (!indexed.length) {\n _context5.next = 4;\n break;\n }\n\n _context5.next = 4;\n return Promise.all(indexed.map(function (f) {\n return (0, _knowledgeBase.deleteFileIndex)(f.id);\n }));\n\n case 4:\n _context5.next = 6;\n return (0, _knowledgeBase.deleteFiles)(ids);\n\n case 6:\n _this16.$message.success('批量删除成功');\n\n _this16.handleDeleted(deletable.length);\n\n _context5.next = 12;\n break;\n\n case 10:\n _context5.prev = 10;\n _context5.t0 = _context5[\"catch\"](0);\n\n case 12:\n case \"end\":\n return _context5.stop();\n }\n }\n }, _callee5, null, [[0, 10]]);\n }))).catch(function () {});\n },\n\n /**\n * 批量移动:打开目标文件夹选择弹窗\n */\n handleBatchMove: function handleBatchMove() {\n var _this17 = this;\n\n return (0, _asyncToGenerator2.default)( /*#__PURE__*/regeneratorRuntime.mark(function _callee6() {\n var selected, folders;\n return regeneratorRuntime.wrap(function _callee6$(_context6) {\n while (1) {\n switch (_context6.prev = _context6.next) {\n case 0:\n selected = _this17.selectedRows || [];\n\n if (selected.length) {\n _context6.next = 4;\n break;\n }\n\n _this17.$message.warning('请先勾选要移动的文件');\n\n return _context6.abrupt(\"return\");\n\n case 4:\n if (_this17.companyId) {\n _context6.next = 7;\n break;\n }\n\n _this17.$message.warning('公司数据未加载');\n\n return _context6.abrupt(\"return\");\n\n case 7:\n _this17.moveFolderId = null;\n _this17.moveVisible = true; // 每次打开都重新加载文件夹列表,确保新建/重命名/删除文件夹后看到最新目录\n\n _context6.prev = 9;\n _context6.next = 12;\n return (0, _knowledgeBase.getFolderList)(_this17.companyId);\n\n case 12:\n folders = _context6.sent;\n _this17.folderList = folders || [];\n _context6.next = 18;\n break;\n\n case 16:\n _context6.prev = 16;\n _context6.t0 = _context6[\"catch\"](9);\n\n case 18:\n _this17.$nextTick(function () {\n if (_this17.$refs.moveTreeRef) _this17.$refs.moveTreeRef.setCurrentKey(null);\n });\n\n case 19:\n case \"end\":\n return _context6.stop();\n }\n }\n }, _callee6, null, [[9, 16]]);\n }))();\n },\n\n /**\n * 选择目标文件夹\n */\n handleMoveFolderSelect: function handleMoveFolderSelect(data) {\n this.moveFolderId = data.id;\n },\n\n /**\n * 确认批量移动\n */\n handleMoveConfirm: function handleMoveConfirm() {\n var _this18 = this;\n\n return (0, _asyncToGenerator2.default)( /*#__PURE__*/regeneratorRuntime.mark(function _callee7() {\n var ids, targetFolder;\n return regeneratorRuntime.wrap(function _callee7$(_context7) {\n while (1) {\n switch (_context7.prev = _context7.next) {\n case 0:\n if (_this18.moveFolderId) {\n _context7.next = 3;\n break;\n }\n\n _this18.$message.warning('请选择目标文件夹');\n\n return _context7.abrupt(\"return\");\n\n case 3:\n ids = _this18.selectedRows.map(function (f) {\n return f.id;\n });\n _this18.moving = true;\n _context7.prev = 5;\n _context7.next = 8;\n return (0, _knowledgeBase.moveFiles)(ids, _this18.moveFolderId);\n\n case 8:\n _this18.$message.success('批量移动成功');\n\n _this18.moveVisible = false; // 移动成功后,通知父级定位并高亮左侧树到目标文件夹\n\n targetFolder = _this18.folderList.find(function (f) {\n return String(f.id) === String(_this18.moveFolderId);\n }) || null;\n if (targetFolder) _this18.$emit('move-target', targetFolder);else _this18.$emit('move-target', {\n id: _this18.moveFolderId,\n name: _this18.moveTargetName\n });\n\n _this18.loadList();\n\n _context7.next = 17;\n break;\n\n case 15:\n _context7.prev = 15;\n _context7.t0 = _context7[\"catch\"](5);\n\n case 17:\n _context7.prev = 17;\n _this18.moving = false;\n return _context7.finish(17);\n\n case 20:\n case \"end\":\n return _context7.stop();\n }\n }\n }, _callee7, null, [[5, 15, 17, 20]]);\n }))();\n },\n\n /**\n * 通过 folderId 映射文件夹名称\n */\n folderName: function folderName(folderId) {\n if (!folderId) return '根目录';\n var found = this.categoryList.find(function (f) {\n return String(f.id) === String(folderId);\n });\n return found ? found.name : '-';\n },\n\n /**\n * 根据文件类型返回对应图标\n */\n getFileIcon: function getFileIcon(fileType) {\n var type = (fileType || '').toLowerCase();\n var iconMap = {\n pdf: 'el-icon-document',\n doc: 'el-icon-document',\n docx: 'el-icon-document',\n xls: 'el-icon-tickets',\n xlsx: 'el-icon-tickets',\n ppt: 'el-icon-data-line',\n pptx: 'el-icon-data-line',\n txt: 'el-icon-document',\n md: 'el-icon-edit-outline',\n png: 'el-icon-picture',\n jpg: 'el-icon-picture',\n jpeg: 'el-icon-picture',\n gif: 'el-icon-picture',\n zip: 'el-icon-folder-opened',\n rar: 'el-icon-folder-opened'\n };\n return iconMap[type] || 'el-icon-document';\n },\n\n /**\n * 根据文件类型返回对应的图标 URL\n * 映射统一维护在 @lib/utils/fileType.js(与聊天附件共用)\n */\n getFileIconUrl: function getFileIconUrl(fileType) {\n return (0, _fileType.getFileIconUrl)(fileType);\n },\n\n /**\n * 文件大小格式化(字节 → B/KB/MB/GB)\n */\n formatSize: function formatSize(bytes) {\n if (!bytes && bytes !== 0) return '-';\n if (bytes === 0) return '0 B';\n var units = ['B', 'KB', 'MB', 'GB', 'TB'];\n var size = bytes;\n var idx = 0;\n\n while (size >= 1024 && idx < units.length - 1) {\n size /= 1024;\n idx++;\n }\n\n return \"\".concat(idx === 0 ? size : size.toFixed(2), \" \").concat(units[idx]);\n },\n\n /**\n * 时间展示:ISO 本地时间去掉 T 分隔符\n */\n formatTime: function formatTime(time) {\n if (!time) return '-';\n return String(time).replace('T', ' ').replace(/\\+08:00$/, '').replace(/\\.\\d{3}/, '');\n },\n\n /**\n * 索引状态标签:0 未索引 / 1 已索引 / 2 索引中 / 3 失败\n */\n indexTagType: function indexTagType(status) {\n var map = {\n 0: 'info',\n 1: 'success',\n 2: 'warning',\n 3: 'danger'\n };\n return map[status] || 'info';\n },\n indexTagText: function indexTagText(status) {\n var map = {\n 0: '未索引',\n 1: '已索引',\n 2: '索引中',\n 3: '索引失败'\n };\n return map[status] || '未知';\n }\n }\n};\nexports.default = _default2;\n\n//# sourceURL=webpack://ZjPluginIntelligent/./src/lib/knowledgeBase/DocumentList.vue?./node_modules/cache-loader/dist/cjs.js??ref--12-0!./node_modules/babel-loader/lib!./node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/vue-loader/lib??vue-loader-options");
|
|
1012
|
+
eval("\n\nvar _interopRequireWildcard = __webpack_require__(/*! ./node_modules/@babel/runtime/helpers/interopRequireWildcard */ \"./node_modules/@babel/runtime/helpers/interopRequireWildcard.js\").default;\n\nvar _interopRequireDefault = __webpack_require__(/*! ./node_modules/@babel/runtime/helpers/interopRequireDefault */ \"./node_modules/@babel/runtime/helpers/interopRequireDefault.js\").default;\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.default = void 0;\n\nvar _asyncToGenerator2 = _interopRequireDefault(__webpack_require__(/*! ./node_modules/@babel/runtime/helpers/asyncToGenerator */ \"./node_modules/@babel/runtime/helpers/asyncToGenerator.js\"));\n\nvar _objectSpread2 = _interopRequireDefault(__webpack_require__(/*! ./node_modules/@babel/runtime/helpers/objectSpread2 */ \"./node_modules/@babel/runtime/helpers/objectSpread2.js\"));\n\nvar _marked = __webpack_require__(/*! marked */ \"./node_modules/marked/lib/marked.esm.js\");\n\nvar XLSX = _interopRequireWildcard(__webpack_require__(/*! xlsx */ \"./node_modules/xlsx/xlsx.mjs\"));\n\nvar _mammoth = _interopRequireDefault(__webpack_require__(/*! mammoth */ \"./node_modules/mammoth/lib/index.js\"));\n\nvar _knowledgeBase = __webpack_require__(/*! ./api/knowledgeBase */ \"./src/lib/knowledgeBase/api/knowledgeBase.js\");\n\nvar _fileType = __webpack_require__(/*! @lib/utils/fileType */ \"./src/lib/utils/fileType.js\");\n\nvar _DocumentForm = _interopRequireDefault(__webpack_require__(/*! ./DocumentForm */ \"./src/lib/knowledgeBase/DocumentForm.vue\"));\n\nvar _MobileDialog = _interopRequireDefault(__webpack_require__(/*! ./MobileDialog.vue */ \"./src/lib/knowledgeBase/MobileDialog.vue\"));\n\nvar _native = __webpack_require__(/*! ./native.js */ \"./src/lib/knowledgeBase/native.js\");\n\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n// 预览最多显示的行数(防止大文件卡死)\nvar MAX_PREVIEW_ROWS = 500;\nvar _default2 = {\n name: 'DocumentList',\n components: {\n DocumentForm: _DocumentForm.default,\n MobileDialog: _MobileDialog.default\n },\n props: {\n selectedCategory: {\n type: Object,\n default: null\n },\n categoryList: {\n type: Array,\n default: function _default() {\n return [];\n }\n },\n companyId: {\n type: String,\n default: ''\n },\n // 是否移动端(由父组件根据宽度传入;未传时按窗口宽度自动判断)\n isMobile: {\n type: Boolean,\n default: null\n },\n // 是否管理员:false(普通成员)时隐藏新增/编辑/索引/删除/批量操作与勾选列,仅保留预览\n isAdmin: {\n type: Boolean,\n default: true\n }\n },\n data: function data() {\n return {\n list: [],\n loading: false,\n total: 0,\n page: 1,\n pageSize: 10,\n searchKeyword: '',\n // 批量删除选中的文件\n selectedRows: [],\n // 批量移动\n moveVisible: false,\n moveFolderId: null,\n moving: false,\n folderList: [],\n folderTreeProps: {\n children: 'children',\n label: 'name'\n },\n // 在线预览\n previewVisible: false,\n previewFile: null,\n previewType: 'none',\n previewText: '',\n // 移动端预览:是否已向宿主历史栈压入一条记录(用于拦截侧滑返回)\n previewHistoryPushed: false,\n // PDF 预览(Blob URL 避免下载)\n pdfBlobUrl: '',\n // Excel 预览\n xlsxLoading: false,\n xlsxWorkbook: null,\n xlsxSheetNames: [],\n xlsxCurrentSheet: '',\n xlsxCols: [],\n xlsxTableData: [],\n hasMoreRows: false,\n // Word 预览\n docxLoading: false,\n docxHtml: '',\n // 窗口宽度(横屏判断:isMobile 且宽>768 时操作按钮与搜索同行)\n innerWidth: typeof window !== 'undefined' ? window.innerWidth : 0\n };\n },\n computed: {\n /**\n * 移动端横屏(宽>768,如平板横屏):空间充足,操作按钮与搜索同行\n */\n isLandscape: function isLandscape() {\n return !!this.isMobile && this.innerWidth > 768;\n },\n\n /**\n * 总页数(横屏自绘分页用)\n */\n totalPages: function totalPages() {\n return Math.max(1, Math.ceil((this.total || 0) / this.pageSize));\n },\n\n /**\n * 横屏表格:当前页可勾选的行(索引中的文件不可勾选)\n */\n selectableRows: function selectableRows() {\n var _this = this;\n\n return (this.list || []).filter(function (row) {\n return _this.rowSelectable(row);\n });\n },\n\n /**\n * 横屏表格:表头全选是否为选中态\n */\n isAllSelected: function isAllSelected() {\n var _this2 = this;\n\n return this.selectableRows.length > 0 && this.selectableRows.every(function (row) {\n return _this2.docMSelected(row);\n });\n },\n\n /**\n * 横屏表格:表头全选是否为半选态\n */\n isIndeterminate: function isIndeterminate() {\n var _this3 = this;\n\n var checked = this.selectableRows.filter(function (row) {\n return _this3.docMSelected(row);\n }).length;\n return checked > 0 && checked < this.selectableRows.length;\n },\n\n /**\n * Markdown 渲染后的 HTML(使用 marked)\n */\n previewHtml: function previewHtml() {\n if (!this.previewText) return '';\n return _marked.marked.parse(this.previewText, {\n breaks: true,\n gfm: true\n });\n },\n maxPreviewRows: function maxPreviewRows() {\n return MAX_PREVIEW_ROWS;\n },\n\n /**\n * 批量移动的文件夹树(由平铺列表组装)\n */\n moveFolderTree: function moveFolderTree() {\n var nodes = this.folderList.map(function (f) {\n return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, f), {}, {\n children: []\n });\n });\n var map = {};\n nodes.forEach(function (n) {\n map[n.id] = n;\n });\n var roots = [];\n nodes.forEach(function (n) {\n var pid = n.parentId || 0;\n if (map[pid]) map[pid].children.push(n);else roots.push(n);\n });\n return roots;\n },\n\n /**\n * 批量移动的文件夹扁平列表(移动端自绘列表用)\n */\n moveFolderFlat: function moveFolderFlat() {\n return (0, _native.flattenFolderTree)(this.moveFolderTree);\n },\n\n /**\n * 目标文件夹名称\n */\n moveTargetName: function moveTargetName() {\n var _this4 = this;\n\n if (!this.moveFolderId) return '';\n var f = this.folderList.find(function (x) {\n return x.id === _this4.moveFolderId;\n });\n return f ? f.name : '';\n }\n },\n watch: {\n selectedCategory: function selectedCategory() {\n this.page = 1;\n this.loadList();\n },\n companyId: function companyId() {\n this.page = 1;\n this.searchKeyword = '';\n this.list = [];\n this.total = 0;\n this.loadList();\n },\n\n /**\n * 预览弹窗关闭时清理 PDF Blob URL\n */\n previewVisible: function previewVisible(val) {\n if (!val) {\n if (this.pdfBlobUrl) {\n URL.revokeObjectURL(this.pdfBlobUrl);\n this.pdfBlobUrl = '';\n } // 页面内关闭预览时,回退掉预览时压入的历史记录,避免多一条返回\n\n\n if (this.previewHistoryPushed) {\n this.previewHistoryPushed = false;\n\n if (typeof window !== 'undefined' && window.history && window.history.back) {\n window.history.back();\n }\n }\n }\n }\n },\n created: function created() {\n this.loadList(); // 跟踪窗口宽度用于横屏判断(旋转屏幕时按钮行内/换行切换)\n\n if (typeof window !== 'undefined') {\n this.innerWidth = window.innerWidth;\n window.addEventListener('resize', this.handleWinResize);\n window.addEventListener('popstate', this.handlePreviewPopState);\n }\n },\n beforeDestroy: function beforeDestroy() {\n if (typeof window !== 'undefined') {\n window.removeEventListener('resize', this.handleWinResize);\n window.removeEventListener('popstate', this.handlePreviewPopState);\n }\n },\n methods: {\n /**\n * 移动端预览:拦截系统侧滑/返回键,先关闭预览而不是退出页面\n */\n handlePreviewPopState: function handlePreviewPopState() {\n if (this.previewVisible && this.previewHistoryPushed) {\n this.previewHistoryPushed = false;\n this.previewVisible = false;\n }\n },\n handleWinResize: function handleWinResize() {\n if (typeof window !== 'undefined') {\n this.innerWidth = window.innerWidth;\n }\n },\n loadList: function loadList() {\n var _this5 = this;\n\n var append = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;\n if (!this.companyId) return;\n this.loading = true;\n var params = {\n companyId: this.companyId,\n pageNum: this.page,\n pageSize: this.pageSize\n }; // 选中具体文件夹时按文件夹过滤(\"显示全部文件\"时 id 为空串,不传)\n\n if (this.selectedCategory && this.selectedCategory.id) {\n params.folderId = this.selectedCategory.id;\n }\n\n if (this.searchKeyword) {\n params.keyword = this.searchKeyword;\n }\n\n (0, _knowledgeBase.getFileList)(params).then(function (data) {\n // append:移动端「加载更多」追加到列表尾部\n if (append) {\n _this5.list = (_this5.list || []).concat(data.records || []);\n } else {\n _this5.list = data.records || []; // 列表刷新后清空勾选\n\n _this5.selectedRows = [];\n\n _this5.$nextTick(function () {\n // 移动端 el-table 不渲染,$refs.tableRef 可能不存在或非 el-table 实例\n if (_this5.$refs.tableRef && typeof _this5.$refs.tableRef.clearSelection === 'function') {\n _this5.$refs.tableRef.clearSelection();\n }\n });\n }\n\n _this5.total = data.total || 0;\n }).catch(function () {}).finally(function () {\n _this5.loading = false;\n });\n },\n\n /**\n * 移动端:加载更多(追加下一页)\n */\n loadMore: function loadMore() {\n if (this.loading) return;\n this.page += 1;\n this.loadList(true);\n },\n\n /**\n * 移动端:当前是否已勾选该文件\n */\n docMSelected: function docMSelected(row) {\n return (this.selectedRows || []).some(function (x) {\n return x && x.id === row.id;\n });\n },\n\n /**\n * 移动端:切换勾选(索引中的文件不可勾选)\n */\n toggleMSelected: function toggleMSelected(row) {\n if (row.indexStatus === 2) return;\n var i = (this.selectedRows || []).findIndex(function (x) {\n return x && x.id === row.id;\n });\n if (i >= 0) this.selectedRows.splice(i, 1);else this.selectedRows.push(row);\n },\n\n /**\n * 移动端横屏表格:表头全选/取消全选(仅作用于当前页可选行)\n */\n toggleSelectAll: function toggleSelectAll(e) {\n var _this6 = this;\n\n var checked = e && e.target ? e.target.checked : !this.isAllSelected;\n var selectable = this.selectableRows;\n\n if (checked) {\n selectable.forEach(function (row) {\n if (!_this6.docMSelected(row)) _this6.selectedRows.push(row);\n });\n } else {\n var ids = selectable.map(function (row) {\n return row.id;\n });\n this.selectedRows = (this.selectedRows || []).filter(function (row) {\n return !row || ids.indexOf(row.id) === -1;\n });\n }\n },\n handleSearch: function handleSearch() {\n this.page = 1;\n this.loadList();\n },\n handleSizeChange: function handleSizeChange(size) {\n this.pageSize = size;\n this.page = 1;\n this.loadList();\n },\n handleCurrentChange: function handleCurrentChange(page) {\n this.page = page;\n this.loadList();\n },\n\n /**\n * 删除文件后刷新列表:若当前页因删除而超出最大页数(如某页只剩 1 条被删掉),\n * 自动回退到最后一页(即上一页),避免停留在空白页。\n */\n handleDeleted: function handleDeleted() {\n var count = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;\n var newTotal = Math.max(0, this.total - count);\n var maxPage = Math.max(1, Math.ceil(newTotal / this.pageSize));\n\n if (this.page > maxPage) {\n this.page = maxPage;\n }\n\n this.loadList();\n },\n handleAdd: function handleAdd() {\n var _this7 = this;\n\n if (!this.companyId) {\n this.$message.warning('公司数据未加载,请稍后刷新');\n return;\n }\n\n if (!this.categoryList || this.categoryList.length === 0) {\n this.$message.warning('暂无根目录,请先创建文件夹再新增文档');\n return;\n }\n\n var folderId = this.selectedCategory && this.selectedCategory.id ? this.selectedCategory.id : '';\n this.$refs.docFormRef.openAdd(folderId).then(function (res) {\n if (res) _this7.loadList();\n });\n },\n handleEdit: function handleEdit(row) {\n var _this8 = this;\n\n this.$refs.docFormRef.openEdit(row).then(function (res) {\n if (res) _this8.loadList();\n });\n },\n\n /**\n * 在线预览:图片 / PDF / Excel / Word / 文本\n */\n handlePreview: function handlePreview(row) {\n var _this9 = this;\n\n this.previewFile = row;\n this.previewText = '';\n this.docxHtml = '';\n this.xlsxWorkbook = null;\n this.xlsxSheetNames = [];\n this.xlsxCurrentSheet = '';\n this.xlsxCols = [];\n this.xlsxTableData = []; // 清理上一次的 PDF Blob URL\n\n if (this.pdfBlobUrl) {\n URL.revokeObjectURL(this.pdfBlobUrl);\n this.pdfBlobUrl = '';\n }\n\n var t = (row.fileType || '').toLowerCase();\n\n if (['png', 'jpg', 'jpeg', 'gif', 'webp', 'bmp'].includes(t)) {\n this.previewType = 'image';\n } else if (t === 'pdf') {\n this.previewType = 'pdf';\n this.loadPdfPreview(row);\n } else if (t === 'xlsx' || t === 'xls') {\n this.previewType = 'xlsx';\n this.loadXlsxPreview(row);\n } else if (t === 'docx' || t === 'doc') {\n this.previewType = 'docx';\n this.loadDocxPreview(row);\n } else if (['txt', 'md', 'markdown', 'html', 'htm'].includes(t)) {\n this.previewType = 'text';\n (0, _knowledgeBase.getFileDetail)(row.id).then(function (d) {\n _this9.previewText = d.content || '(该文件暂无可预览的文本内容)';\n }).catch(function () {\n _this9.previewText = '(文本内容加载失败)';\n });\n } else {\n this.previewType = 'none';\n }\n\n this.previewVisible = true; // 移动端:压入一条历史记录,侧滑/返回键先关闭预览,而不是退出到主页面\n\n if (this.isMobile && typeof window !== 'undefined' && window.history && window.history.pushState) {\n window.history.pushState({\n kbFilePreview: true\n }, '');\n this.previewHistoryPushed = true;\n }\n },\n // ==================== Excel 预览 ====================\n loadXlsxPreview: function loadXlsxPreview(file) {\n var _this10 = this;\n\n return (0, _asyncToGenerator2.default)( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {\n var detail, fileUrl, response, ab, workbook;\n return regeneratorRuntime.wrap(function _callee$(_context) {\n while (1) {\n switch (_context.prev = _context.next) {\n case 0:\n _this10.xlsxLoading = true;\n _context.prev = 1;\n _context.next = 4;\n return (0, _knowledgeBase.getFileDetail)(file.id);\n\n case 4:\n detail = _context.sent;\n fileUrl = detail.fileUrl || file.fileUrl;\n\n if (fileUrl) {\n _context.next = 9;\n break;\n }\n\n _this10.$message.warning('无法获取文件下载地址');\n\n return _context.abrupt(\"return\");\n\n case 9:\n _context.next = 11;\n return fetch(fileUrl);\n\n case 11:\n response = _context.sent;\n\n if (response.ok) {\n _context.next = 14;\n break;\n }\n\n throw new Error('下载文件失败');\n\n case 14:\n _context.next = 16;\n return response.arrayBuffer();\n\n case 16:\n ab = _context.sent;\n _context.next = 19;\n return new Promise(function (r) {\n return setTimeout(r, 0);\n });\n\n case 19:\n workbook = XLSX.read(ab, {\n type: 'array'\n });\n _this10.xlsxWorkbook = workbook;\n _this10.xlsxSheetNames = workbook.SheetNames;\n\n if (workbook.SheetNames.length > 0) {\n _this10.xlsxCurrentSheet = workbook.SheetNames[0];\n\n _this10.renderXlsxSheet();\n }\n\n _context.next = 29;\n break;\n\n case 25:\n _context.prev = 25;\n _context.t0 = _context[\"catch\"](1);\n console.error('加载 Excel 文件失败', _context.t0);\n\n _this10.$message.error('Excel 文件加载失败');\n\n case 29:\n _context.prev = 29;\n _this10.xlsxLoading = false;\n return _context.finish(29);\n\n case 32:\n case \"end\":\n return _context.stop();\n }\n }\n }, _callee, null, [[1, 25, 29, 32]]);\n }))();\n },\n renderXlsxSheet: function renderXlsxSheet() {\n var workbook = this.xlsxWorkbook;\n var sheetName = this.xlsxCurrentSheet;\n if (!workbook || !sheetName) return;\n var sheet = workbook.Sheets[sheetName];\n\n if (!sheet) {\n this.xlsxCols = [];\n this.xlsxTableData = [];\n return;\n } // 让出主线程,防止 sheet_to_json 阻塞 UI\n\n\n var data = XLSX.utils.sheet_to_json(sheet, {\n header: 1,\n defval: ''\n });\n\n if (data.length === 0) {\n this.xlsxCols = [];\n this.xlsxTableData = [];\n return;\n } // 列数以「所有行的最大宽度」为准:表头行可能只填了第一格,若直接按第一行长度定列会丢失后续列\n\n\n var maxCols = Math.max.apply(null, data.map(function (row) {\n return row && row.length || 0;\n }));\n this.xlsxCols = Array.from({\n length: maxCols\n }, function (_, i) {\n var v = data[0] && data[0][i];\n return v != null && String(v).trim() !== '' ? String(v) : \"\\u5217\".concat(i + 1);\n }); // 限制预览行数,防止渲染过多 DOM 卡死;同时过滤全空行\n\n var allRows = data.slice(1).filter(function (row) {\n return row && row.some(function (c) {\n return c != null && String(c).trim() !== '';\n });\n });\n this.hasMoreRows = allRows.length > MAX_PREVIEW_ROWS;\n this.xlsxTableData = allRows.slice(0, MAX_PREVIEW_ROWS).map(function (row) {\n var obj = {};\n\n for (var ci = 0; ci < maxCols; ci++) {\n obj[ci] = row[ci] != null ? String(row[ci]) : '';\n }\n\n return obj;\n });\n },\n // ==================== Word 预览 ====================\n loadDocxPreview: function loadDocxPreview(file) {\n var _this11 = this;\n\n return (0, _asyncToGenerator2.default)( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() {\n var detail, fileUrl, response, ab, result;\n return regeneratorRuntime.wrap(function _callee2$(_context2) {\n while (1) {\n switch (_context2.prev = _context2.next) {\n case 0:\n _this11.docxLoading = true;\n _context2.prev = 1;\n _context2.next = 4;\n return (0, _knowledgeBase.getFileDetail)(file.id);\n\n case 4:\n detail = _context2.sent;\n fileUrl = detail.fileUrl || file.fileUrl;\n\n if (fileUrl) {\n _context2.next = 9;\n break;\n }\n\n _this11.$message.warning('无法获取文件下载地址');\n\n return _context2.abrupt(\"return\");\n\n case 9:\n _context2.next = 11;\n return fetch(fileUrl);\n\n case 11:\n response = _context2.sent;\n\n if (response.ok) {\n _context2.next = 14;\n break;\n }\n\n throw new Error('下载文件失败');\n\n case 14:\n _context2.next = 16;\n return response.arrayBuffer();\n\n case 16:\n ab = _context2.sent;\n\n if (ab.byteLength) {\n _context2.next = 20;\n break;\n }\n\n _this11.docxHtml = '<p>(空文档)</p>';\n return _context2.abrupt(\"return\");\n\n case 20:\n _context2.next = 22;\n return _mammoth.default.convertToHtml({\n arrayBuffer: ab\n });\n\n case 22:\n result = _context2.sent;\n _this11.docxHtml = result.value || '<p>(空文档)</p>';\n _context2.next = 30;\n break;\n\n case 26:\n _context2.prev = 26;\n _context2.t0 = _context2[\"catch\"](1);\n console.error('加载 Word 文件失败', _context2.t0);\n\n _this11.$message.error('Word 文件加载失败');\n\n case 30:\n _context2.prev = 30;\n _this11.docxLoading = false;\n return _context2.finish(30);\n\n case 33:\n case \"end\":\n return _context2.stop();\n }\n }\n }, _callee2, null, [[1, 26, 30, 33]]);\n }))();\n },\n // ==================== PDF 预览 ====================\n loadPdfPreview: function loadPdfPreview(file) {\n var _this12 = this;\n\n return (0, _asyncToGenerator2.default)( /*#__PURE__*/regeneratorRuntime.mark(function _callee3() {\n var detail, fileUrl, response, blob;\n return regeneratorRuntime.wrap(function _callee3$(_context3) {\n while (1) {\n switch (_context3.prev = _context3.next) {\n case 0:\n _context3.prev = 0;\n _context3.next = 3;\n return (0, _knowledgeBase.getFileDetail)(file.id);\n\n case 3:\n detail = _context3.sent;\n fileUrl = detail.fileUrl || file.fileUrl;\n\n if (fileUrl) {\n _context3.next = 8;\n break;\n }\n\n _this12.$message.warning('无法获取文件下载地址');\n\n return _context3.abrupt(\"return\");\n\n case 8:\n _context3.next = 10;\n return fetch(fileUrl);\n\n case 10:\n response = _context3.sent;\n\n if (response.ok) {\n _context3.next = 13;\n break;\n }\n\n throw new Error('下载文件失败');\n\n case 13:\n _context3.next = 15;\n return response.blob();\n\n case 15:\n blob = _context3.sent;\n _this12.pdfBlobUrl = URL.createObjectURL(blob);\n _context3.next = 23;\n break;\n\n case 19:\n _context3.prev = 19;\n _context3.t0 = _context3[\"catch\"](0);\n console.error('加载 PDF 文件失败', _context3.t0);\n\n _this12.$message.error('PDF 文件加载失败');\n\n case 23:\n case \"end\":\n return _context3.stop();\n }\n }\n }, _callee3, null, [[0, 19]]);\n }))();\n },\n\n /**\n * 索引 / 重建索引(二次确认)\n */\n handleIndex: function handleIndex(row) {\n var _this13 = this;\n\n var isRebuild = row.indexStatus === 1;\n console.log('[DocumentList] 索引文件:', row.id, row.title, 'companyId:', this.companyId);\n this.$confirm(\"\\u786E\\u8BA4\\u5BF9\\u6587\\u4EF6\\u300C\".concat(row.title || row.fileName, \"\\u300D\").concat(isRebuild ? '重建' : '创建', \"\\u7D22\\u5F15\\uFF1F\"), '提示', {\n type: 'warning',\n confirmButtonText: '确定',\n cancelButtonText: '取消'\n }).then(function () {\n var request = isRebuild ? (0, _knowledgeBase.reindexFile)(row.id) : (0, _knowledgeBase.indexFile)(row.id);\n request.then(function () {\n _this13.$message.success(isRebuild ? '已开始重建索引' : '已开始索引');\n\n _this13.loadList();\n }).catch(function () {});\n }).catch(function () {});\n },\n\n /**\n * 删除索引(二次确认)\n */\n handleDeleteIndex: function handleDeleteIndex(row) {\n var _this14 = this;\n\n this.$confirm(\"\\u786E\\u8BA4\\u5220\\u9664\\u6587\\u4EF6\\u300C\".concat(row.title || row.fileName, \"\\u300D\\u7684\\u7D22\\u5F15\\uFF1F\\u5220\\u9664\\u540E\\u65E0\\u6CD5\\u6062\\u590D\\u3002\"), '提示', {\n type: 'warning',\n confirmButtonText: '确定删除',\n cancelButtonText: '取消'\n }).then(function () {\n (0, _knowledgeBase.deleteFileIndex)(row.id).then(function () {\n _this14.$message.success('索引已删除');\n\n _this14.loadList();\n }).catch(function () {});\n }).catch(function () {});\n },\n handleDelete: function handleDelete(row) {\n var _this15 = this;\n\n // 索引中的文件不允许删除\n if (row.indexStatus === 2) {\n this.$message.warning('该文件正在索引中,无法删除');\n return;\n }\n\n var hasIndex = row.indexStatus === 1;\n this.$confirm(\"\\u786E\\u8BA4\\u5220\\u9664\\u6587\\u4EF6\\u300C\".concat(row.title || row.fileName, \"\\u300D\\uFF1F\").concat(hasIndex ? '删除文件前会先删除该文件的索引。' : '', \"\\u5220\\u9664\\u540E\\u65E0\\u6CD5\\u6062\\u590D\\u3002\"), '提示', {\n type: 'warning',\n confirmButtonText: '确定删除',\n cancelButtonText: '取消'\n }).then( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/regeneratorRuntime.mark(function _callee4() {\n return regeneratorRuntime.wrap(function _callee4$(_context4) {\n while (1) {\n switch (_context4.prev = _context4.next) {\n case 0:\n _context4.prev = 0;\n\n if (!hasIndex) {\n _context4.next = 4;\n break;\n }\n\n _context4.next = 4;\n return (0, _knowledgeBase.deleteFileIndex)(row.id);\n\n case 4:\n _context4.next = 6;\n return (0, _knowledgeBase.deleteFile)(row.id);\n\n case 6:\n _this15.$message.success('文件已删除');\n\n _this15.handleDeleted(1);\n\n _context4.next = 12;\n break;\n\n case 10:\n _context4.prev = 10;\n _context4.t0 = _context4[\"catch\"](0);\n\n case 12:\n case \"end\":\n return _context4.stop();\n }\n }\n }, _callee4, null, [[0, 10]]);\n }))).catch(function () {});\n },\n\n /**\n * 表格勾选变化\n */\n handleSelectionChange: function handleSelectionChange(rows) {\n this.selectedRows = rows || [];\n },\n\n /**\n * 索引中的文件不可勾选删除\n */\n rowSelectable: function rowSelectable(row) {\n return row.indexStatus !== 2;\n },\n\n /**\n * 批量删除勾选的文件\n */\n handleBatchDelete: function handleBatchDelete() {\n var _this16 = this;\n\n var selected = this.selectedRows || [];\n\n if (!selected.length) {\n this.$message.warning('请先勾选要删除的文件');\n return;\n } // 索引中的文件不允许删除\n\n\n var indexingFiles = selected.filter(function (f) {\n return f.indexStatus === 2;\n });\n var deletable = selected.filter(function (f) {\n return f.indexStatus !== 2;\n });\n\n if (!deletable.length) {\n this.$message.warning('所选文件均正在索引中,无法删除');\n return;\n }\n\n if (indexingFiles.length) {\n this.$message.warning(\"\\u6709 \".concat(indexingFiles.length, \" \\u4E2A\\u6587\\u4EF6\\u6B63\\u5728\\u7D22\\u5F15\\u4E2D\\uFF0C\\u672C\\u6B21\\u5C06\\u8DF3\\u8FC7\"));\n } // 已索引的文件需先删除索引,再删除文件\n\n\n var indexed = deletable.filter(function (f) {\n return f.indexStatus === 1;\n });\n var ids = deletable.map(function (f) {\n return f.id;\n });\n this.$confirm(\"\\u786E\\u8BA4\\u5220\\u9664\\u9009\\u4E2D\\u7684 \".concat(deletable.length, \" \\u4E2A\\u6587\\u4EF6\\uFF1F\").concat(indexed.length ? '删除前会先删除这些文件的索引。' : '', \"\\u5220\\u9664\\u540E\\u65E0\\u6CD5\\u6062\\u590D\\u3002\"), '提示', {\n type: 'warning',\n confirmButtonText: '确定删除',\n cancelButtonText: '取消',\n customClass: 'kb-message-box'\n }).then( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/regeneratorRuntime.mark(function _callee5() {\n return regeneratorRuntime.wrap(function _callee5$(_context5) {\n while (1) {\n switch (_context5.prev = _context5.next) {\n case 0:\n _context5.prev = 0;\n\n if (!indexed.length) {\n _context5.next = 4;\n break;\n }\n\n _context5.next = 4;\n return Promise.all(indexed.map(function (f) {\n return (0, _knowledgeBase.deleteFileIndex)(f.id);\n }));\n\n case 4:\n _context5.next = 6;\n return (0, _knowledgeBase.deleteFiles)(ids);\n\n case 6:\n _this16.$message.success('批量删除成功');\n\n _this16.handleDeleted(deletable.length);\n\n _context5.next = 12;\n break;\n\n case 10:\n _context5.prev = 10;\n _context5.t0 = _context5[\"catch\"](0);\n\n case 12:\n case \"end\":\n return _context5.stop();\n }\n }\n }, _callee5, null, [[0, 10]]);\n }))).catch(function () {});\n },\n\n /**\n * 批量移动:打开目标文件夹选择弹窗\n */\n handleBatchMove: function handleBatchMove() {\n var _this17 = this;\n\n return (0, _asyncToGenerator2.default)( /*#__PURE__*/regeneratorRuntime.mark(function _callee6() {\n var selected, folders;\n return regeneratorRuntime.wrap(function _callee6$(_context6) {\n while (1) {\n switch (_context6.prev = _context6.next) {\n case 0:\n selected = _this17.selectedRows || [];\n\n if (selected.length) {\n _context6.next = 4;\n break;\n }\n\n _this17.$message.warning('请先勾选要移动的文件');\n\n return _context6.abrupt(\"return\");\n\n case 4:\n if (_this17.companyId) {\n _context6.next = 7;\n break;\n }\n\n _this17.$message.warning('公司数据未加载');\n\n return _context6.abrupt(\"return\");\n\n case 7:\n _this17.moveFolderId = null;\n _this17.moveVisible = true; // 每次打开都重新加载文件夹列表,确保新建/重命名/删除文件夹后看到最新目录\n\n _context6.prev = 9;\n _context6.next = 12;\n return (0, _knowledgeBase.getFolderList)(_this17.companyId);\n\n case 12:\n folders = _context6.sent;\n _this17.folderList = folders || [];\n _context6.next = 18;\n break;\n\n case 16:\n _context6.prev = 16;\n _context6.t0 = _context6[\"catch\"](9);\n\n case 18:\n _this17.$nextTick(function () {\n if (_this17.$refs.moveTreeRef) _this17.$refs.moveTreeRef.setCurrentKey(null);\n });\n\n case 19:\n case \"end\":\n return _context6.stop();\n }\n }\n }, _callee6, null, [[9, 16]]);\n }))();\n },\n\n /**\n * 选择目标文件夹\n */\n handleMoveFolderSelect: function handleMoveFolderSelect(data) {\n this.moveFolderId = data.id;\n },\n\n /**\n * 确认批量移动\n */\n handleMoveConfirm: function handleMoveConfirm() {\n var _this18 = this;\n\n return (0, _asyncToGenerator2.default)( /*#__PURE__*/regeneratorRuntime.mark(function _callee7() {\n var ids, targetFolder;\n return regeneratorRuntime.wrap(function _callee7$(_context7) {\n while (1) {\n switch (_context7.prev = _context7.next) {\n case 0:\n if (_this18.moveFolderId) {\n _context7.next = 3;\n break;\n }\n\n _this18.$message.warning('请选择目标文件夹');\n\n return _context7.abrupt(\"return\");\n\n case 3:\n ids = _this18.selectedRows.map(function (f) {\n return f.id;\n });\n _this18.moving = true;\n _context7.prev = 5;\n _context7.next = 8;\n return (0, _knowledgeBase.moveFiles)(ids, _this18.moveFolderId);\n\n case 8:\n _this18.$message.success('批量移动成功');\n\n _this18.moveVisible = false; // 移动成功后,通知父级定位并高亮左侧树到目标文件夹\n\n targetFolder = _this18.folderList.find(function (f) {\n return String(f.id) === String(_this18.moveFolderId);\n }) || null;\n if (targetFolder) _this18.$emit('move-target', targetFolder);else _this18.$emit('move-target', {\n id: _this18.moveFolderId,\n name: _this18.moveTargetName\n });\n\n _this18.loadList();\n\n _context7.next = 17;\n break;\n\n case 15:\n _context7.prev = 15;\n _context7.t0 = _context7[\"catch\"](5);\n\n case 17:\n _context7.prev = 17;\n _this18.moving = false;\n return _context7.finish(17);\n\n case 20:\n case \"end\":\n return _context7.stop();\n }\n }\n }, _callee7, null, [[5, 15, 17, 20]]);\n }))();\n },\n\n /**\n * 通过 folderId 映射文件夹名称\n */\n folderName: function folderName(folderId) {\n if (!folderId) return '根目录';\n var found = this.categoryList.find(function (f) {\n return String(f.id) === String(folderId);\n });\n return found ? found.name : '-';\n },\n\n /**\n * 根据文件类型返回对应图标\n */\n getFileIcon: function getFileIcon(fileType) {\n var type = (fileType || '').toLowerCase();\n var iconMap = {\n pdf: 'el-icon-document',\n doc: 'el-icon-document',\n docx: 'el-icon-document',\n xls: 'el-icon-tickets',\n xlsx: 'el-icon-tickets',\n ppt: 'el-icon-data-line',\n pptx: 'el-icon-data-line',\n txt: 'el-icon-document',\n md: 'el-icon-edit-outline',\n png: 'el-icon-picture',\n jpg: 'el-icon-picture',\n jpeg: 'el-icon-picture',\n gif: 'el-icon-picture',\n zip: 'el-icon-folder-opened',\n rar: 'el-icon-folder-opened'\n };\n return iconMap[type] || 'el-icon-document';\n },\n\n /**\n * 根据文件类型返回对应的图标 URL\n * 映射统一维护在 @lib/utils/fileType.js(与聊天附件共用)\n */\n getFileIconUrl: function getFileIconUrl(fileType) {\n return (0, _fileType.getFileIconUrl)(fileType);\n },\n\n /**\n * 文件大小格式化(字节 → B/KB/MB/GB)\n */\n formatSize: function formatSize(bytes) {\n if (!bytes && bytes !== 0) return '-';\n if (bytes === 0) return '0 B';\n var units = ['B', 'KB', 'MB', 'GB', 'TB'];\n var size = bytes;\n var idx = 0;\n\n while (size >= 1024 && idx < units.length - 1) {\n size /= 1024;\n idx++;\n }\n\n return \"\".concat(idx === 0 ? size : size.toFixed(2), \" \").concat(units[idx]);\n },\n\n /**\n * 时间展示:ISO 本地时间去掉 T 分隔符\n */\n formatTime: function formatTime(time) {\n if (!time) return '-';\n return String(time).replace('T', ' ').replace(/\\+08:00$/, '').replace(/\\.\\d{3}/, '');\n },\n\n /**\n * 索引状态标签:0 未索引 / 1 已索引 / 2 索引中 / 3 失败\n */\n indexTagType: function indexTagType(status) {\n var map = {\n 0: 'info',\n 1: 'success',\n 2: 'warning',\n 3: 'danger'\n };\n return map[status] || 'info';\n },\n indexTagText: function indexTagText(status) {\n var map = {\n 0: '未索引',\n 1: '已索引',\n 2: '索引中',\n 3: '索引失败'\n };\n return map[status] || '未知';\n }\n }\n};\nexports.default = _default2;\n\n//# sourceURL=webpack://ZjPluginIntelligent/./src/lib/knowledgeBase/DocumentList.vue?./node_modules/cache-loader/dist/cjs.js??ref--12-0!./node_modules/babel-loader/lib!./node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/vue-loader/lib??vue-loader-options");
|
|
1013
1013
|
|
|
1014
1014
|
/***/ }),
|
|
1015
1015
|
|
|
@@ -14756,7 +14756,7 @@ eval("// Generated by CoffeeScript 1.12.7\n(function() {\n var XMLDocument, XML
|
|
|
14756
14756
|
/*! exports provided: name, version, main, private, scripts, dependencies, devDependencies, browserslist, directories, keywords, license, files, default */
|
|
14757
14757
|
/***/ (function(module) {
|
|
14758
14758
|
|
|
14759
|
-
eval("module.exports = JSON.parse(\"{\\\"name\\\":\\\"zj-plugin-intelligent\\\",\\\"version\\\":\\\"1.2.26-beta.
|
|
14759
|
+
eval("module.exports = JSON.parse(\"{\\\"name\\\":\\\"zj-plugin-intelligent\\\",\\\"version\\\":\\\"1.2.26-beta.7\\\",\\\"main\\\":\\\"lib/ZjPluginIntelligent.umd.min.js\\\",\\\"private\\\":false,\\\"scripts\\\":{\\\"serve\\\":\\\"set NODE_OPTIONS=--openssl-legacy-provider && vue-cli-service serve\\\",\\\"build\\\":\\\"set NODE_OPTIONS=--openssl-legacy-provider && vue-cli-service build\\\",\\\"lib\\\":\\\"node scripts/build-lib.js\\\",\\\"lib:test\\\":\\\"node scripts/build-lib.js test\\\"},\\\"dependencies\\\":{\\\"@jboltai/tokui\\\":\\\"^0.1.6\\\",\\\"crypto-js\\\":\\\"^4.2.0\\\",\\\"docx\\\":\\\"^8.5.0\\\",\\\"html2canvas\\\":\\\"^1.4.1\\\",\\\"mammoth\\\":\\\"^1.6.0\\\",\\\"markdown-it\\\":\\\"^13.0.2\\\",\\\"marked\\\":\\\"^4.3.0\\\",\\\"xlsx\\\":\\\"^0.18.5\\\"},\\\"devDependencies\\\":{\\\"@babel/preset-env\\\":\\\"^7.14.9\\\",\\\"@vue/cli-plugin-babel\\\":\\\"~4.5.0\\\",\\\"@vue/cli-plugin-eslint\\\":\\\"~4.5.0\\\",\\\"@vue/cli-plugin-vuex\\\":\\\"~4.5.0\\\",\\\"@vue/cli-service\\\":\\\"~4.5.0\\\",\\\"axios\\\":\\\"^0.27.2\\\",\\\"babel-eslint\\\":\\\"^10.1.0\\\",\\\"babel-plugin-component\\\":\\\"^1.1.1\\\",\\\"compression-webpack-plugin\\\":\\\"^6.0.3\\\",\\\"core-js\\\":\\\"^3.6.5\\\",\\\"element-ui\\\":\\\"^2.15.4\\\",\\\"eslint\\\":\\\"^6.8.0\\\",\\\"eslint-plugin-vue\\\":\\\"^7.13.0\\\",\\\"js-cookie\\\":\\\"^2.2.1\\\",\\\"obs-upload\\\":\\\"^1.0.4\\\",\\\"pako\\\":\\\"^2.1.0\\\",\\\"reconnecting-websocket\\\":\\\"^4.4.0\\\",\\\"sass\\\":\\\"^1.71.0\\\",\\\"sass-loader\\\":\\\"^8.0.2\\\",\\\"snowflake-id\\\":\\\"^1.1.0\\\",\\\"vue\\\":\\\"^2.6.11\\\",\\\"vue-template-compiler\\\":\\\"^2.6.11\\\",\\\"vuex\\\":\\\"^3.4.0\\\",\\\"webpack-bundle-analyzer\\\":\\\"^4.4.2\\\"},\\\"browserslist\\\":[\\\"> 1%\\\",\\\"last 2 versions\\\",\\\"not dead\\\"],\\\"directories\\\":{\\\"lib\\\":\\\"lib\\\"},\\\"keywords\\\":[],\\\"license\\\":\\\"ISC\\\",\\\"files\\\":[\\\"lib\\\"]}\");\n\n//# sourceURL=webpack://ZjPluginIntelligent/./package.json?");
|
|
14760
14760
|
|
|
14761
14761
|
/***/ }),
|
|
14762
14762
|
|
|
@@ -1009,7 +1009,7 @@ eval("\n\nvar _interopRequireWildcard = __webpack_require__(/*! ./node_modules/@
|
|
|
1009
1009
|
/***/ (function(module, exports, __webpack_require__) {
|
|
1010
1010
|
|
|
1011
1011
|
"use strict";
|
|
1012
|
-
eval("\n\nvar _interopRequireWildcard = __webpack_require__(/*! ./node_modules/@babel/runtime/helpers/interopRequireWildcard */ \"./node_modules/@babel/runtime/helpers/interopRequireWildcard.js\").default;\n\nvar _interopRequireDefault = __webpack_require__(/*! ./node_modules/@babel/runtime/helpers/interopRequireDefault */ \"./node_modules/@babel/runtime/helpers/interopRequireDefault.js\").default;\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.default = void 0;\n\nvar _asyncToGenerator2 = _interopRequireDefault(__webpack_require__(/*! ./node_modules/@babel/runtime/helpers/asyncToGenerator */ \"./node_modules/@babel/runtime/helpers/asyncToGenerator.js\"));\n\nvar _objectSpread2 = _interopRequireDefault(__webpack_require__(/*! ./node_modules/@babel/runtime/helpers/objectSpread2 */ \"./node_modules/@babel/runtime/helpers/objectSpread2.js\"));\n\nvar _marked = __webpack_require__(/*! marked */ \"./node_modules/marked/lib/marked.esm.js\");\n\nvar XLSX = _interopRequireWildcard(__webpack_require__(/*! xlsx */ \"./node_modules/xlsx/xlsx.mjs\"));\n\nvar _mammoth = _interopRequireDefault(__webpack_require__(/*! mammoth */ \"./node_modules/mammoth/lib/index.js\"));\n\nvar _knowledgeBase = __webpack_require__(/*! ./api/knowledgeBase */ \"./src/lib/knowledgeBase/api/knowledgeBase.js\");\n\nvar _fileType = __webpack_require__(/*! @lib/utils/fileType */ \"./src/lib/utils/fileType.js\");\n\nvar _DocumentForm = _interopRequireDefault(__webpack_require__(/*! ./DocumentForm */ \"./src/lib/knowledgeBase/DocumentForm.vue\"));\n\nvar _MobileDialog = _interopRequireDefault(__webpack_require__(/*! ./MobileDialog.vue */ \"./src/lib/knowledgeBase/MobileDialog.vue\"));\n\nvar _native = __webpack_require__(/*! ./native.js */ \"./src/lib/knowledgeBase/native.js\");\n\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n// 预览最多显示的行数(防止大文件卡死)\nvar MAX_PREVIEW_ROWS = 500;\nvar _default2 = {\n name: 'DocumentList',\n components: {\n DocumentForm: _DocumentForm.default,\n MobileDialog: _MobileDialog.default\n },\n props: {\n selectedCategory: {\n type: Object,\n default: null\n },\n categoryList: {\n type: Array,\n default: function _default() {\n return [];\n }\n },\n companyId: {\n type: String,\n default: ''\n },\n // 是否移动端(由父组件根据宽度传入;未传时按窗口宽度自动判断)\n isMobile: {\n type: Boolean,\n default: null\n },\n // 是否管理员:false(普通成员)时隐藏新增/编辑/索引/删除/批量操作与勾选列,仅保留预览\n isAdmin: {\n type: Boolean,\n default: true\n }\n },\n data: function data() {\n return {\n list: [],\n loading: false,\n total: 0,\n page: 1,\n pageSize: 10,\n searchKeyword: '',\n // 批量删除选中的文件\n selectedRows: [],\n // 批量移动\n moveVisible: false,\n moveFolderId: null,\n moving: false,\n folderList: [],\n folderTreeProps: {\n children: 'children',\n label: 'name'\n },\n // 在线预览\n previewVisible: false,\n previewFile: null,\n previewType: 'none',\n previewText: '',\n // PDF 预览(Blob URL 避免下载)\n pdfBlobUrl: '',\n // Excel 预览\n xlsxLoading: false,\n xlsxWorkbook: null,\n xlsxSheetNames: [],\n xlsxCurrentSheet: '',\n xlsxCols: [],\n xlsxTableData: [],\n hasMoreRows: false,\n // Word 预览\n docxLoading: false,\n docxHtml: '',\n // 窗口宽度(横屏判断:isMobile 且宽>768 时操作按钮与搜索同行)\n innerWidth: typeof window !== 'undefined' ? window.innerWidth : 0\n };\n },\n computed: {\n /**\n * 移动端横屏(宽>768,如平板横屏):空间充足,操作按钮与搜索同行\n */\n isLandscape: function isLandscape() {\n return !!this.isMobile && this.innerWidth > 768;\n },\n\n /**\n * 总页数(横屏自绘分页用)\n */\n totalPages: function totalPages() {\n return Math.max(1, Math.ceil((this.total || 0) / this.pageSize));\n },\n\n /**\n * 横屏表格:当前页可勾选的行(索引中的文件不可勾选)\n */\n selectableRows: function selectableRows() {\n var _this = this;\n\n return (this.list || []).filter(function (row) {\n return _this.rowSelectable(row);\n });\n },\n\n /**\n * 横屏表格:表头全选是否为选中态\n */\n isAllSelected: function isAllSelected() {\n var _this2 = this;\n\n return this.selectableRows.length > 0 && this.selectableRows.every(function (row) {\n return _this2.docMSelected(row);\n });\n },\n\n /**\n * 横屏表格:表头全选是否为半选态\n */\n isIndeterminate: function isIndeterminate() {\n var _this3 = this;\n\n var checked = this.selectableRows.filter(function (row) {\n return _this3.docMSelected(row);\n }).length;\n return checked > 0 && checked < this.selectableRows.length;\n },\n\n /**\n * Markdown 渲染后的 HTML(使用 marked)\n */\n previewHtml: function previewHtml() {\n if (!this.previewText) return '';\n return _marked.marked.parse(this.previewText, {\n breaks: true,\n gfm: true\n });\n },\n maxPreviewRows: function maxPreviewRows() {\n return MAX_PREVIEW_ROWS;\n },\n\n /**\n * 批量移动的文件夹树(由平铺列表组装)\n */\n moveFolderTree: function moveFolderTree() {\n var nodes = this.folderList.map(function (f) {\n return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, f), {}, {\n children: []\n });\n });\n var map = {};\n nodes.forEach(function (n) {\n map[n.id] = n;\n });\n var roots = [];\n nodes.forEach(function (n) {\n var pid = n.parentId || 0;\n if (map[pid]) map[pid].children.push(n);else roots.push(n);\n });\n return roots;\n },\n\n /**\n * 批量移动的文件夹扁平列表(移动端自绘列表用)\n */\n moveFolderFlat: function moveFolderFlat() {\n return (0, _native.flattenFolderTree)(this.moveFolderTree);\n },\n\n /**\n * 目标文件夹名称\n */\n moveTargetName: function moveTargetName() {\n var _this4 = this;\n\n if (!this.moveFolderId) return '';\n var f = this.folderList.find(function (x) {\n return x.id === _this4.moveFolderId;\n });\n return f ? f.name : '';\n }\n },\n watch: {\n selectedCategory: function selectedCategory() {\n this.page = 1;\n this.loadList();\n },\n companyId: function companyId() {\n this.page = 1;\n this.searchKeyword = '';\n this.list = [];\n this.total = 0;\n this.loadList();\n },\n\n /**\n * 预览弹窗关闭时清理 PDF Blob URL\n */\n previewVisible: function previewVisible(val) {\n if (!val && this.pdfBlobUrl) {\n URL.revokeObjectURL(this.pdfBlobUrl);\n this.pdfBlobUrl = '';\n }\n }\n },\n created: function created() {\n this.loadList(); // 跟踪窗口宽度用于横屏判断(旋转屏幕时按钮行内/换行切换)\n\n if (typeof window !== 'undefined') {\n this.innerWidth = window.innerWidth;\n window.addEventListener('resize', this.handleWinResize);\n }\n },\n beforeDestroy: function beforeDestroy() {\n if (typeof window !== 'undefined') {\n window.removeEventListener('resize', this.handleWinResize);\n }\n },\n methods: {\n handleWinResize: function handleWinResize() {\n if (typeof window !== 'undefined') {\n this.innerWidth = window.innerWidth;\n }\n },\n loadList: function loadList() {\n var _this5 = this;\n\n var append = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;\n if (!this.companyId) return;\n this.loading = true;\n var params = {\n companyId: this.companyId,\n pageNum: this.page,\n pageSize: this.pageSize\n }; // 选中具体文件夹时按文件夹过滤(\"显示全部文件\"时 id 为空串,不传)\n\n if (this.selectedCategory && this.selectedCategory.id) {\n params.folderId = this.selectedCategory.id;\n }\n\n if (this.searchKeyword) {\n params.keyword = this.searchKeyword;\n }\n\n (0, _knowledgeBase.getFileList)(params).then(function (data) {\n // append:移动端「加载更多」追加到列表尾部\n if (append) {\n _this5.list = (_this5.list || []).concat(data.records || []);\n } else {\n _this5.list = data.records || []; // 列表刷新后清空勾选\n\n _this5.selectedRows = [];\n\n _this5.$nextTick(function () {\n // 移动端 el-table 不渲染,$refs.tableRef 可能不存在或非 el-table 实例\n if (_this5.$refs.tableRef && typeof _this5.$refs.tableRef.clearSelection === 'function') {\n _this5.$refs.tableRef.clearSelection();\n }\n });\n }\n\n _this5.total = data.total || 0;\n }).catch(function () {}).finally(function () {\n _this5.loading = false;\n });\n },\n\n /**\n * 移动端:加载更多(追加下一页)\n */\n loadMore: function loadMore() {\n if (this.loading) return;\n this.page += 1;\n this.loadList(true);\n },\n\n /**\n * 移动端:当前是否已勾选该文件\n */\n docMSelected: function docMSelected(row) {\n return (this.selectedRows || []).some(function (x) {\n return x && x.id === row.id;\n });\n },\n\n /**\n * 移动端:切换勾选(索引中的文件不可勾选)\n */\n toggleMSelected: function toggleMSelected(row) {\n if (row.indexStatus === 2) return;\n var i = (this.selectedRows || []).findIndex(function (x) {\n return x && x.id === row.id;\n });\n if (i >= 0) this.selectedRows.splice(i, 1);else this.selectedRows.push(row);\n },\n\n /**\n * 移动端横屏表格:表头全选/取消全选(仅作用于当前页可选行)\n */\n toggleSelectAll: function toggleSelectAll(e) {\n var _this6 = this;\n\n var checked = e && e.target ? e.target.checked : !this.isAllSelected;\n var selectable = this.selectableRows;\n\n if (checked) {\n selectable.forEach(function (row) {\n if (!_this6.docMSelected(row)) _this6.selectedRows.push(row);\n });\n } else {\n var ids = selectable.map(function (row) {\n return row.id;\n });\n this.selectedRows = (this.selectedRows || []).filter(function (row) {\n return !row || ids.indexOf(row.id) === -1;\n });\n }\n },\n handleSearch: function handleSearch() {\n this.page = 1;\n this.loadList();\n },\n handleSizeChange: function handleSizeChange(size) {\n this.pageSize = size;\n this.page = 1;\n this.loadList();\n },\n handleCurrentChange: function handleCurrentChange(page) {\n this.page = page;\n this.loadList();\n },\n\n /**\n * 删除文件后刷新列表:若当前页因删除而超出最大页数(如某页只剩 1 条被删掉),\n * 自动回退到最后一页(即上一页),避免停留在空白页。\n */\n handleDeleted: function handleDeleted() {\n var count = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;\n var newTotal = Math.max(0, this.total - count);\n var maxPage = Math.max(1, Math.ceil(newTotal / this.pageSize));\n\n if (this.page > maxPage) {\n this.page = maxPage;\n }\n\n this.loadList();\n },\n handleAdd: function handleAdd() {\n var _this7 = this;\n\n if (!this.companyId) {\n this.$message.warning('公司数据未加载,请稍后刷新');\n return;\n }\n\n if (!this.categoryList || this.categoryList.length === 0) {\n this.$message.warning('暂无根目录,请先创建文件夹再新增文档');\n return;\n }\n\n var folderId = this.selectedCategory && this.selectedCategory.id ? this.selectedCategory.id : '';\n this.$refs.docFormRef.openAdd(folderId).then(function (res) {\n if (res) _this7.loadList();\n });\n },\n handleEdit: function handleEdit(row) {\n var _this8 = this;\n\n this.$refs.docFormRef.openEdit(row).then(function (res) {\n if (res) _this8.loadList();\n });\n },\n\n /**\n * 在线预览:图片 / PDF / Excel / Word / 文本\n */\n handlePreview: function handlePreview(row) {\n var _this9 = this;\n\n this.previewFile = row;\n this.previewText = '';\n this.docxHtml = '';\n this.xlsxWorkbook = null;\n this.xlsxSheetNames = [];\n this.xlsxCurrentSheet = '';\n this.xlsxCols = [];\n this.xlsxTableData = []; // 清理上一次的 PDF Blob URL\n\n if (this.pdfBlobUrl) {\n URL.revokeObjectURL(this.pdfBlobUrl);\n this.pdfBlobUrl = '';\n }\n\n var t = (row.fileType || '').toLowerCase();\n\n if (['png', 'jpg', 'jpeg', 'gif', 'webp', 'bmp'].includes(t)) {\n this.previewType = 'image';\n } else if (t === 'pdf') {\n this.previewType = 'pdf';\n this.loadPdfPreview(row);\n } else if (t === 'xlsx' || t === 'xls') {\n this.previewType = 'xlsx';\n this.loadXlsxPreview(row);\n } else if (t === 'docx' || t === 'doc') {\n this.previewType = 'docx';\n this.loadDocxPreview(row);\n } else if (['txt', 'md', 'markdown', 'html', 'htm'].includes(t)) {\n this.previewType = 'text';\n (0, _knowledgeBase.getFileDetail)(row.id).then(function (d) {\n _this9.previewText = d.content || '(该文件暂无可预览的文本内容)';\n }).catch(function () {\n _this9.previewText = '(文本内容加载失败)';\n });\n } else {\n this.previewType = 'none';\n }\n\n this.previewVisible = true;\n },\n // ==================== Excel 预览 ====================\n loadXlsxPreview: function loadXlsxPreview(file) {\n var _this10 = this;\n\n return (0, _asyncToGenerator2.default)( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {\n var detail, fileUrl, response, ab, workbook;\n return regeneratorRuntime.wrap(function _callee$(_context) {\n while (1) {\n switch (_context.prev = _context.next) {\n case 0:\n _this10.xlsxLoading = true;\n _context.prev = 1;\n _context.next = 4;\n return (0, _knowledgeBase.getFileDetail)(file.id);\n\n case 4:\n detail = _context.sent;\n fileUrl = detail.fileUrl || file.fileUrl;\n\n if (fileUrl) {\n _context.next = 9;\n break;\n }\n\n _this10.$message.warning('无法获取文件下载地址');\n\n return _context.abrupt(\"return\");\n\n case 9:\n _context.next = 11;\n return fetch(fileUrl);\n\n case 11:\n response = _context.sent;\n\n if (response.ok) {\n _context.next = 14;\n break;\n }\n\n throw new Error('下载文件失败');\n\n case 14:\n _context.next = 16;\n return response.arrayBuffer();\n\n case 16:\n ab = _context.sent;\n _context.next = 19;\n return new Promise(function (r) {\n return setTimeout(r, 0);\n });\n\n case 19:\n workbook = XLSX.read(ab, {\n type: 'array'\n });\n _this10.xlsxWorkbook = workbook;\n _this10.xlsxSheetNames = workbook.SheetNames;\n\n if (workbook.SheetNames.length > 0) {\n _this10.xlsxCurrentSheet = workbook.SheetNames[0];\n\n _this10.renderXlsxSheet();\n }\n\n _context.next = 29;\n break;\n\n case 25:\n _context.prev = 25;\n _context.t0 = _context[\"catch\"](1);\n console.error('加载 Excel 文件失败', _context.t0);\n\n _this10.$message.error('Excel 文件加载失败');\n\n case 29:\n _context.prev = 29;\n _this10.xlsxLoading = false;\n return _context.finish(29);\n\n case 32:\n case \"end\":\n return _context.stop();\n }\n }\n }, _callee, null, [[1, 25, 29, 32]]);\n }))();\n },\n renderXlsxSheet: function renderXlsxSheet() {\n var workbook = this.xlsxWorkbook;\n var sheetName = this.xlsxCurrentSheet;\n if (!workbook || !sheetName) return;\n var sheet = workbook.Sheets[sheetName];\n\n if (!sheet) {\n this.xlsxCols = [];\n this.xlsxTableData = [];\n return;\n } // 让出主线程,防止 sheet_to_json 阻塞 UI\n\n\n var data = XLSX.utils.sheet_to_json(sheet, {\n header: 1,\n defval: ''\n });\n\n if (data.length === 0) {\n this.xlsxCols = [];\n this.xlsxTableData = [];\n return;\n } // 列数以「所有行的最大宽度」为准:表头行可能只填了第一格,若直接按第一行长度定列会丢失后续列\n\n\n var maxCols = Math.max.apply(null, data.map(function (row) {\n return row && row.length || 0;\n }));\n this.xlsxCols = Array.from({\n length: maxCols\n }, function (_, i) {\n var v = data[0] && data[0][i];\n return v != null && String(v).trim() !== '' ? String(v) : \"\\u5217\".concat(i + 1);\n }); // 限制预览行数,防止渲染过多 DOM 卡死;同时过滤全空行\n\n var allRows = data.slice(1).filter(function (row) {\n return row && row.some(function (c) {\n return c != null && String(c).trim() !== '';\n });\n });\n this.hasMoreRows = allRows.length > MAX_PREVIEW_ROWS;\n this.xlsxTableData = allRows.slice(0, MAX_PREVIEW_ROWS).map(function (row) {\n var obj = {};\n\n for (var ci = 0; ci < maxCols; ci++) {\n obj[ci] = row[ci] != null ? String(row[ci]) : '';\n }\n\n return obj;\n });\n },\n // ==================== Word 预览 ====================\n loadDocxPreview: function loadDocxPreview(file) {\n var _this11 = this;\n\n return (0, _asyncToGenerator2.default)( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() {\n var detail, fileUrl, response, ab, result;\n return regeneratorRuntime.wrap(function _callee2$(_context2) {\n while (1) {\n switch (_context2.prev = _context2.next) {\n case 0:\n _this11.docxLoading = true;\n _context2.prev = 1;\n _context2.next = 4;\n return (0, _knowledgeBase.getFileDetail)(file.id);\n\n case 4:\n detail = _context2.sent;\n fileUrl = detail.fileUrl || file.fileUrl;\n\n if (fileUrl) {\n _context2.next = 9;\n break;\n }\n\n _this11.$message.warning('无法获取文件下载地址');\n\n return _context2.abrupt(\"return\");\n\n case 9:\n _context2.next = 11;\n return fetch(fileUrl);\n\n case 11:\n response = _context2.sent;\n\n if (response.ok) {\n _context2.next = 14;\n break;\n }\n\n throw new Error('下载文件失败');\n\n case 14:\n _context2.next = 16;\n return response.arrayBuffer();\n\n case 16:\n ab = _context2.sent;\n\n if (ab.byteLength) {\n _context2.next = 20;\n break;\n }\n\n _this11.docxHtml = '<p>(空文档)</p>';\n return _context2.abrupt(\"return\");\n\n case 20:\n _context2.next = 22;\n return _mammoth.default.convertToHtml({\n arrayBuffer: ab\n });\n\n case 22:\n result = _context2.sent;\n _this11.docxHtml = result.value || '<p>(空文档)</p>';\n _context2.next = 30;\n break;\n\n case 26:\n _context2.prev = 26;\n _context2.t0 = _context2[\"catch\"](1);\n console.error('加载 Word 文件失败', _context2.t0);\n\n _this11.$message.error('Word 文件加载失败');\n\n case 30:\n _context2.prev = 30;\n _this11.docxLoading = false;\n return _context2.finish(30);\n\n case 33:\n case \"end\":\n return _context2.stop();\n }\n }\n }, _callee2, null, [[1, 26, 30, 33]]);\n }))();\n },\n // ==================== PDF 预览 ====================\n loadPdfPreview: function loadPdfPreview(file) {\n var _this12 = this;\n\n return (0, _asyncToGenerator2.default)( /*#__PURE__*/regeneratorRuntime.mark(function _callee3() {\n var detail, fileUrl, response, blob;\n return regeneratorRuntime.wrap(function _callee3$(_context3) {\n while (1) {\n switch (_context3.prev = _context3.next) {\n case 0:\n _context3.prev = 0;\n _context3.next = 3;\n return (0, _knowledgeBase.getFileDetail)(file.id);\n\n case 3:\n detail = _context3.sent;\n fileUrl = detail.fileUrl || file.fileUrl;\n\n if (fileUrl) {\n _context3.next = 8;\n break;\n }\n\n _this12.$message.warning('无法获取文件下载地址');\n\n return _context3.abrupt(\"return\");\n\n case 8:\n _context3.next = 10;\n return fetch(fileUrl);\n\n case 10:\n response = _context3.sent;\n\n if (response.ok) {\n _context3.next = 13;\n break;\n }\n\n throw new Error('下载文件失败');\n\n case 13:\n _context3.next = 15;\n return response.blob();\n\n case 15:\n blob = _context3.sent;\n _this12.pdfBlobUrl = URL.createObjectURL(blob);\n _context3.next = 23;\n break;\n\n case 19:\n _context3.prev = 19;\n _context3.t0 = _context3[\"catch\"](0);\n console.error('加载 PDF 文件失败', _context3.t0);\n\n _this12.$message.error('PDF 文件加载失败');\n\n case 23:\n case \"end\":\n return _context3.stop();\n }\n }\n }, _callee3, null, [[0, 19]]);\n }))();\n },\n\n /**\n * 索引 / 重建索引(二次确认)\n */\n handleIndex: function handleIndex(row) {\n var _this13 = this;\n\n var isRebuild = row.indexStatus === 1;\n console.log('[DocumentList] 索引文件:', row.id, row.title, 'companyId:', this.companyId);\n this.$confirm(\"\\u786E\\u8BA4\\u5BF9\\u6587\\u4EF6\\u300C\".concat(row.title || row.fileName, \"\\u300D\").concat(isRebuild ? '重建' : '创建', \"\\u7D22\\u5F15\\uFF1F\"), '提示', {\n type: 'warning',\n confirmButtonText: '确定',\n cancelButtonText: '取消'\n }).then(function () {\n var request = isRebuild ? (0, _knowledgeBase.reindexFile)(row.id) : (0, _knowledgeBase.indexFile)(row.id);\n request.then(function () {\n _this13.$message.success(isRebuild ? '已开始重建索引' : '已开始索引');\n\n _this13.loadList();\n }).catch(function () {});\n }).catch(function () {});\n },\n\n /**\n * 删除索引(二次确认)\n */\n handleDeleteIndex: function handleDeleteIndex(row) {\n var _this14 = this;\n\n this.$confirm(\"\\u786E\\u8BA4\\u5220\\u9664\\u6587\\u4EF6\\u300C\".concat(row.title || row.fileName, \"\\u300D\\u7684\\u7D22\\u5F15\\uFF1F\\u5220\\u9664\\u540E\\u65E0\\u6CD5\\u6062\\u590D\\u3002\"), '提示', {\n type: 'warning',\n confirmButtonText: '确定删除',\n cancelButtonText: '取消'\n }).then(function () {\n (0, _knowledgeBase.deleteFileIndex)(row.id).then(function () {\n _this14.$message.success('索引已删除');\n\n _this14.loadList();\n }).catch(function () {});\n }).catch(function () {});\n },\n handleDelete: function handleDelete(row) {\n var _this15 = this;\n\n // 索引中的文件不允许删除\n if (row.indexStatus === 2) {\n this.$message.warning('该文件正在索引中,无法删除');\n return;\n }\n\n var hasIndex = row.indexStatus === 1;\n this.$confirm(\"\\u786E\\u8BA4\\u5220\\u9664\\u6587\\u4EF6\\u300C\".concat(row.title || row.fileName, \"\\u300D\\uFF1F\").concat(hasIndex ? '删除文件前会先删除该文件的索引。' : '', \"\\u5220\\u9664\\u540E\\u65E0\\u6CD5\\u6062\\u590D\\u3002\"), '提示', {\n type: 'warning',\n confirmButtonText: '确定删除',\n cancelButtonText: '取消'\n }).then( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/regeneratorRuntime.mark(function _callee4() {\n return regeneratorRuntime.wrap(function _callee4$(_context4) {\n while (1) {\n switch (_context4.prev = _context4.next) {\n case 0:\n _context4.prev = 0;\n\n if (!hasIndex) {\n _context4.next = 4;\n break;\n }\n\n _context4.next = 4;\n return (0, _knowledgeBase.deleteFileIndex)(row.id);\n\n case 4:\n _context4.next = 6;\n return (0, _knowledgeBase.deleteFile)(row.id);\n\n case 6:\n _this15.$message.success('文件已删除');\n\n _this15.handleDeleted(1);\n\n _context4.next = 12;\n break;\n\n case 10:\n _context4.prev = 10;\n _context4.t0 = _context4[\"catch\"](0);\n\n case 12:\n case \"end\":\n return _context4.stop();\n }\n }\n }, _callee4, null, [[0, 10]]);\n }))).catch(function () {});\n },\n\n /**\n * 表格勾选变化\n */\n handleSelectionChange: function handleSelectionChange(rows) {\n this.selectedRows = rows || [];\n },\n\n /**\n * 索引中的文件不可勾选删除\n */\n rowSelectable: function rowSelectable(row) {\n return row.indexStatus !== 2;\n },\n\n /**\n * 批量删除勾选的文件\n */\n handleBatchDelete: function handleBatchDelete() {\n var _this16 = this;\n\n var selected = this.selectedRows || [];\n\n if (!selected.length) {\n this.$message.warning('请先勾选要删除的文件');\n return;\n } // 索引中的文件不允许删除\n\n\n var indexingFiles = selected.filter(function (f) {\n return f.indexStatus === 2;\n });\n var deletable = selected.filter(function (f) {\n return f.indexStatus !== 2;\n });\n\n if (!deletable.length) {\n this.$message.warning('所选文件均正在索引中,无法删除');\n return;\n }\n\n if (indexingFiles.length) {\n this.$message.warning(\"\\u6709 \".concat(indexingFiles.length, \" \\u4E2A\\u6587\\u4EF6\\u6B63\\u5728\\u7D22\\u5F15\\u4E2D\\uFF0C\\u672C\\u6B21\\u5C06\\u8DF3\\u8FC7\"));\n } // 已索引的文件需先删除索引,再删除文件\n\n\n var indexed = deletable.filter(function (f) {\n return f.indexStatus === 1;\n });\n var ids = deletable.map(function (f) {\n return f.id;\n });\n this.$confirm(\"\\u786E\\u8BA4\\u5220\\u9664\\u9009\\u4E2D\\u7684 \".concat(deletable.length, \" \\u4E2A\\u6587\\u4EF6\\uFF1F\").concat(indexed.length ? '删除前会先删除这些文件的索引。' : '', \"\\u5220\\u9664\\u540E\\u65E0\\u6CD5\\u6062\\u590D\\u3002\"), '提示', {\n type: 'warning',\n confirmButtonText: '确定删除',\n cancelButtonText: '取消',\n customClass: 'kb-message-box'\n }).then( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/regeneratorRuntime.mark(function _callee5() {\n return regeneratorRuntime.wrap(function _callee5$(_context5) {\n while (1) {\n switch (_context5.prev = _context5.next) {\n case 0:\n _context5.prev = 0;\n\n if (!indexed.length) {\n _context5.next = 4;\n break;\n }\n\n _context5.next = 4;\n return Promise.all(indexed.map(function (f) {\n return (0, _knowledgeBase.deleteFileIndex)(f.id);\n }));\n\n case 4:\n _context5.next = 6;\n return (0, _knowledgeBase.deleteFiles)(ids);\n\n case 6:\n _this16.$message.success('批量删除成功');\n\n _this16.handleDeleted(deletable.length);\n\n _context5.next = 12;\n break;\n\n case 10:\n _context5.prev = 10;\n _context5.t0 = _context5[\"catch\"](0);\n\n case 12:\n case \"end\":\n return _context5.stop();\n }\n }\n }, _callee5, null, [[0, 10]]);\n }))).catch(function () {});\n },\n\n /**\n * 批量移动:打开目标文件夹选择弹窗\n */\n handleBatchMove: function handleBatchMove() {\n var _this17 = this;\n\n return (0, _asyncToGenerator2.default)( /*#__PURE__*/regeneratorRuntime.mark(function _callee6() {\n var selected, folders;\n return regeneratorRuntime.wrap(function _callee6$(_context6) {\n while (1) {\n switch (_context6.prev = _context6.next) {\n case 0:\n selected = _this17.selectedRows || [];\n\n if (selected.length) {\n _context6.next = 4;\n break;\n }\n\n _this17.$message.warning('请先勾选要移动的文件');\n\n return _context6.abrupt(\"return\");\n\n case 4:\n if (_this17.companyId) {\n _context6.next = 7;\n break;\n }\n\n _this17.$message.warning('公司数据未加载');\n\n return _context6.abrupt(\"return\");\n\n case 7:\n _this17.moveFolderId = null;\n _this17.moveVisible = true; // 每次打开都重新加载文件夹列表,确保新建/重命名/删除文件夹后看到最新目录\n\n _context6.prev = 9;\n _context6.next = 12;\n return (0, _knowledgeBase.getFolderList)(_this17.companyId);\n\n case 12:\n folders = _context6.sent;\n _this17.folderList = folders || [];\n _context6.next = 18;\n break;\n\n case 16:\n _context6.prev = 16;\n _context6.t0 = _context6[\"catch\"](9);\n\n case 18:\n _this17.$nextTick(function () {\n if (_this17.$refs.moveTreeRef) _this17.$refs.moveTreeRef.setCurrentKey(null);\n });\n\n case 19:\n case \"end\":\n return _context6.stop();\n }\n }\n }, _callee6, null, [[9, 16]]);\n }))();\n },\n\n /**\n * 选择目标文件夹\n */\n handleMoveFolderSelect: function handleMoveFolderSelect(data) {\n this.moveFolderId = data.id;\n },\n\n /**\n * 确认批量移动\n */\n handleMoveConfirm: function handleMoveConfirm() {\n var _this18 = this;\n\n return (0, _asyncToGenerator2.default)( /*#__PURE__*/regeneratorRuntime.mark(function _callee7() {\n var ids, targetFolder;\n return regeneratorRuntime.wrap(function _callee7$(_context7) {\n while (1) {\n switch (_context7.prev = _context7.next) {\n case 0:\n if (_this18.moveFolderId) {\n _context7.next = 3;\n break;\n }\n\n _this18.$message.warning('请选择目标文件夹');\n\n return _context7.abrupt(\"return\");\n\n case 3:\n ids = _this18.selectedRows.map(function (f) {\n return f.id;\n });\n _this18.moving = true;\n _context7.prev = 5;\n _context7.next = 8;\n return (0, _knowledgeBase.moveFiles)(ids, _this18.moveFolderId);\n\n case 8:\n _this18.$message.success('批量移动成功');\n\n _this18.moveVisible = false; // 移动成功后,通知父级定位并高亮左侧树到目标文件夹\n\n targetFolder = _this18.folderList.find(function (f) {\n return String(f.id) === String(_this18.moveFolderId);\n }) || null;\n if (targetFolder) _this18.$emit('move-target', targetFolder);else _this18.$emit('move-target', {\n id: _this18.moveFolderId,\n name: _this18.moveTargetName\n });\n\n _this18.loadList();\n\n _context7.next = 17;\n break;\n\n case 15:\n _context7.prev = 15;\n _context7.t0 = _context7[\"catch\"](5);\n\n case 17:\n _context7.prev = 17;\n _this18.moving = false;\n return _context7.finish(17);\n\n case 20:\n case \"end\":\n return _context7.stop();\n }\n }\n }, _callee7, null, [[5, 15, 17, 20]]);\n }))();\n },\n\n /**\n * 通过 folderId 映射文件夹名称\n */\n folderName: function folderName(folderId) {\n if (!folderId) return '根目录';\n var found = this.categoryList.find(function (f) {\n return String(f.id) === String(folderId);\n });\n return found ? found.name : '-';\n },\n\n /**\n * 根据文件类型返回对应图标\n */\n getFileIcon: function getFileIcon(fileType) {\n var type = (fileType || '').toLowerCase();\n var iconMap = {\n pdf: 'el-icon-document',\n doc: 'el-icon-document',\n docx: 'el-icon-document',\n xls: 'el-icon-tickets',\n xlsx: 'el-icon-tickets',\n ppt: 'el-icon-data-line',\n pptx: 'el-icon-data-line',\n txt: 'el-icon-document',\n md: 'el-icon-edit-outline',\n png: 'el-icon-picture',\n jpg: 'el-icon-picture',\n jpeg: 'el-icon-picture',\n gif: 'el-icon-picture',\n zip: 'el-icon-folder-opened',\n rar: 'el-icon-folder-opened'\n };\n return iconMap[type] || 'el-icon-document';\n },\n\n /**\n * 根据文件类型返回对应的图标 URL\n * 映射统一维护在 @lib/utils/fileType.js(与聊天附件共用)\n */\n getFileIconUrl: function getFileIconUrl(fileType) {\n return (0, _fileType.getFileIconUrl)(fileType);\n },\n\n /**\n * 文件大小格式化(字节 → B/KB/MB/GB)\n */\n formatSize: function formatSize(bytes) {\n if (!bytes && bytes !== 0) return '-';\n if (bytes === 0) return '0 B';\n var units = ['B', 'KB', 'MB', 'GB', 'TB'];\n var size = bytes;\n var idx = 0;\n\n while (size >= 1024 && idx < units.length - 1) {\n size /= 1024;\n idx++;\n }\n\n return \"\".concat(idx === 0 ? size : size.toFixed(2), \" \").concat(units[idx]);\n },\n\n /**\n * 时间展示:ISO 本地时间去掉 T 分隔符\n */\n formatTime: function formatTime(time) {\n if (!time) return '-';\n return String(time).replace('T', ' ').replace(/\\+08:00$/, '').replace(/\\.\\d{3}/, '');\n },\n\n /**\n * 索引状态标签:0 未索引 / 1 已索引 / 2 索引中 / 3 失败\n */\n indexTagType: function indexTagType(status) {\n var map = {\n 0: 'info',\n 1: 'success',\n 2: 'warning',\n 3: 'danger'\n };\n return map[status] || 'info';\n },\n indexTagText: function indexTagText(status) {\n var map = {\n 0: '未索引',\n 1: '已索引',\n 2: '索引中',\n 3: '索引失败'\n };\n return map[status] || '未知';\n }\n }\n};\nexports.default = _default2;\n\n//# sourceURL=webpack://ZjPluginIntelligent/./src/lib/knowledgeBase/DocumentList.vue?./node_modules/cache-loader/dist/cjs.js??ref--12-0!./node_modules/babel-loader/lib!./node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/vue-loader/lib??vue-loader-options");
|
|
1012
|
+
eval("\n\nvar _interopRequireWildcard = __webpack_require__(/*! ./node_modules/@babel/runtime/helpers/interopRequireWildcard */ \"./node_modules/@babel/runtime/helpers/interopRequireWildcard.js\").default;\n\nvar _interopRequireDefault = __webpack_require__(/*! ./node_modules/@babel/runtime/helpers/interopRequireDefault */ \"./node_modules/@babel/runtime/helpers/interopRequireDefault.js\").default;\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.default = void 0;\n\nvar _asyncToGenerator2 = _interopRequireDefault(__webpack_require__(/*! ./node_modules/@babel/runtime/helpers/asyncToGenerator */ \"./node_modules/@babel/runtime/helpers/asyncToGenerator.js\"));\n\nvar _objectSpread2 = _interopRequireDefault(__webpack_require__(/*! ./node_modules/@babel/runtime/helpers/objectSpread2 */ \"./node_modules/@babel/runtime/helpers/objectSpread2.js\"));\n\nvar _marked = __webpack_require__(/*! marked */ \"./node_modules/marked/lib/marked.esm.js\");\n\nvar XLSX = _interopRequireWildcard(__webpack_require__(/*! xlsx */ \"./node_modules/xlsx/xlsx.mjs\"));\n\nvar _mammoth = _interopRequireDefault(__webpack_require__(/*! mammoth */ \"./node_modules/mammoth/lib/index.js\"));\n\nvar _knowledgeBase = __webpack_require__(/*! ./api/knowledgeBase */ \"./src/lib/knowledgeBase/api/knowledgeBase.js\");\n\nvar _fileType = __webpack_require__(/*! @lib/utils/fileType */ \"./src/lib/utils/fileType.js\");\n\nvar _DocumentForm = _interopRequireDefault(__webpack_require__(/*! ./DocumentForm */ \"./src/lib/knowledgeBase/DocumentForm.vue\"));\n\nvar _MobileDialog = _interopRequireDefault(__webpack_require__(/*! ./MobileDialog.vue */ \"./src/lib/knowledgeBase/MobileDialog.vue\"));\n\nvar _native = __webpack_require__(/*! ./native.js */ \"./src/lib/knowledgeBase/native.js\");\n\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n// 预览最多显示的行数(防止大文件卡死)\nvar MAX_PREVIEW_ROWS = 500;\nvar _default2 = {\n name: 'DocumentList',\n components: {\n DocumentForm: _DocumentForm.default,\n MobileDialog: _MobileDialog.default\n },\n props: {\n selectedCategory: {\n type: Object,\n default: null\n },\n categoryList: {\n type: Array,\n default: function _default() {\n return [];\n }\n },\n companyId: {\n type: String,\n default: ''\n },\n // 是否移动端(由父组件根据宽度传入;未传时按窗口宽度自动判断)\n isMobile: {\n type: Boolean,\n default: null\n },\n // 是否管理员:false(普通成员)时隐藏新增/编辑/索引/删除/批量操作与勾选列,仅保留预览\n isAdmin: {\n type: Boolean,\n default: true\n }\n },\n data: function data() {\n return {\n list: [],\n loading: false,\n total: 0,\n page: 1,\n pageSize: 10,\n searchKeyword: '',\n // 批量删除选中的文件\n selectedRows: [],\n // 批量移动\n moveVisible: false,\n moveFolderId: null,\n moving: false,\n folderList: [],\n folderTreeProps: {\n children: 'children',\n label: 'name'\n },\n // 在线预览\n previewVisible: false,\n previewFile: null,\n previewType: 'none',\n previewText: '',\n // 移动端预览:是否已向宿主历史栈压入一条记录(用于拦截侧滑返回)\n previewHistoryPushed: false,\n // PDF 预览(Blob URL 避免下载)\n pdfBlobUrl: '',\n // Excel 预览\n xlsxLoading: false,\n xlsxWorkbook: null,\n xlsxSheetNames: [],\n xlsxCurrentSheet: '',\n xlsxCols: [],\n xlsxTableData: [],\n hasMoreRows: false,\n // Word 预览\n docxLoading: false,\n docxHtml: '',\n // 窗口宽度(横屏判断:isMobile 且宽>768 时操作按钮与搜索同行)\n innerWidth: typeof window !== 'undefined' ? window.innerWidth : 0\n };\n },\n computed: {\n /**\n * 移动端横屏(宽>768,如平板横屏):空间充足,操作按钮与搜索同行\n */\n isLandscape: function isLandscape() {\n return !!this.isMobile && this.innerWidth > 768;\n },\n\n /**\n * 总页数(横屏自绘分页用)\n */\n totalPages: function totalPages() {\n return Math.max(1, Math.ceil((this.total || 0) / this.pageSize));\n },\n\n /**\n * 横屏表格:当前页可勾选的行(索引中的文件不可勾选)\n */\n selectableRows: function selectableRows() {\n var _this = this;\n\n return (this.list || []).filter(function (row) {\n return _this.rowSelectable(row);\n });\n },\n\n /**\n * 横屏表格:表头全选是否为选中态\n */\n isAllSelected: function isAllSelected() {\n var _this2 = this;\n\n return this.selectableRows.length > 0 && this.selectableRows.every(function (row) {\n return _this2.docMSelected(row);\n });\n },\n\n /**\n * 横屏表格:表头全选是否为半选态\n */\n isIndeterminate: function isIndeterminate() {\n var _this3 = this;\n\n var checked = this.selectableRows.filter(function (row) {\n return _this3.docMSelected(row);\n }).length;\n return checked > 0 && checked < this.selectableRows.length;\n },\n\n /**\n * Markdown 渲染后的 HTML(使用 marked)\n */\n previewHtml: function previewHtml() {\n if (!this.previewText) return '';\n return _marked.marked.parse(this.previewText, {\n breaks: true,\n gfm: true\n });\n },\n maxPreviewRows: function maxPreviewRows() {\n return MAX_PREVIEW_ROWS;\n },\n\n /**\n * 批量移动的文件夹树(由平铺列表组装)\n */\n moveFolderTree: function moveFolderTree() {\n var nodes = this.folderList.map(function (f) {\n return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, f), {}, {\n children: []\n });\n });\n var map = {};\n nodes.forEach(function (n) {\n map[n.id] = n;\n });\n var roots = [];\n nodes.forEach(function (n) {\n var pid = n.parentId || 0;\n if (map[pid]) map[pid].children.push(n);else roots.push(n);\n });\n return roots;\n },\n\n /**\n * 批量移动的文件夹扁平列表(移动端自绘列表用)\n */\n moveFolderFlat: function moveFolderFlat() {\n return (0, _native.flattenFolderTree)(this.moveFolderTree);\n },\n\n /**\n * 目标文件夹名称\n */\n moveTargetName: function moveTargetName() {\n var _this4 = this;\n\n if (!this.moveFolderId) return '';\n var f = this.folderList.find(function (x) {\n return x.id === _this4.moveFolderId;\n });\n return f ? f.name : '';\n }\n },\n watch: {\n selectedCategory: function selectedCategory() {\n this.page = 1;\n this.loadList();\n },\n companyId: function companyId() {\n this.page = 1;\n this.searchKeyword = '';\n this.list = [];\n this.total = 0;\n this.loadList();\n },\n\n /**\n * 预览弹窗关闭时清理 PDF Blob URL\n */\n previewVisible: function previewVisible(val) {\n if (!val) {\n if (this.pdfBlobUrl) {\n URL.revokeObjectURL(this.pdfBlobUrl);\n this.pdfBlobUrl = '';\n } // 页面内关闭预览时,回退掉预览时压入的历史记录,避免多一条返回\n\n\n if (this.previewHistoryPushed) {\n this.previewHistoryPushed = false;\n\n if (typeof window !== 'undefined' && window.history && window.history.back) {\n window.history.back();\n }\n }\n }\n }\n },\n created: function created() {\n this.loadList(); // 跟踪窗口宽度用于横屏判断(旋转屏幕时按钮行内/换行切换)\n\n if (typeof window !== 'undefined') {\n this.innerWidth = window.innerWidth;\n window.addEventListener('resize', this.handleWinResize);\n window.addEventListener('popstate', this.handlePreviewPopState);\n }\n },\n beforeDestroy: function beforeDestroy() {\n if (typeof window !== 'undefined') {\n window.removeEventListener('resize', this.handleWinResize);\n window.removeEventListener('popstate', this.handlePreviewPopState);\n }\n },\n methods: {\n /**\n * 移动端预览:拦截系统侧滑/返回键,先关闭预览而不是退出页面\n */\n handlePreviewPopState: function handlePreviewPopState() {\n if (this.previewVisible && this.previewHistoryPushed) {\n this.previewHistoryPushed = false;\n this.previewVisible = false;\n }\n },\n handleWinResize: function handleWinResize() {\n if (typeof window !== 'undefined') {\n this.innerWidth = window.innerWidth;\n }\n },\n loadList: function loadList() {\n var _this5 = this;\n\n var append = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;\n if (!this.companyId) return;\n this.loading = true;\n var params = {\n companyId: this.companyId,\n pageNum: this.page,\n pageSize: this.pageSize\n }; // 选中具体文件夹时按文件夹过滤(\"显示全部文件\"时 id 为空串,不传)\n\n if (this.selectedCategory && this.selectedCategory.id) {\n params.folderId = this.selectedCategory.id;\n }\n\n if (this.searchKeyword) {\n params.keyword = this.searchKeyword;\n }\n\n (0, _knowledgeBase.getFileList)(params).then(function (data) {\n // append:移动端「加载更多」追加到列表尾部\n if (append) {\n _this5.list = (_this5.list || []).concat(data.records || []);\n } else {\n _this5.list = data.records || []; // 列表刷新后清空勾选\n\n _this5.selectedRows = [];\n\n _this5.$nextTick(function () {\n // 移动端 el-table 不渲染,$refs.tableRef 可能不存在或非 el-table 实例\n if (_this5.$refs.tableRef && typeof _this5.$refs.tableRef.clearSelection === 'function') {\n _this5.$refs.tableRef.clearSelection();\n }\n });\n }\n\n _this5.total = data.total || 0;\n }).catch(function () {}).finally(function () {\n _this5.loading = false;\n });\n },\n\n /**\n * 移动端:加载更多(追加下一页)\n */\n loadMore: function loadMore() {\n if (this.loading) return;\n this.page += 1;\n this.loadList(true);\n },\n\n /**\n * 移动端:当前是否已勾选该文件\n */\n docMSelected: function docMSelected(row) {\n return (this.selectedRows || []).some(function (x) {\n return x && x.id === row.id;\n });\n },\n\n /**\n * 移动端:切换勾选(索引中的文件不可勾选)\n */\n toggleMSelected: function toggleMSelected(row) {\n if (row.indexStatus === 2) return;\n var i = (this.selectedRows || []).findIndex(function (x) {\n return x && x.id === row.id;\n });\n if (i >= 0) this.selectedRows.splice(i, 1);else this.selectedRows.push(row);\n },\n\n /**\n * 移动端横屏表格:表头全选/取消全选(仅作用于当前页可选行)\n */\n toggleSelectAll: function toggleSelectAll(e) {\n var _this6 = this;\n\n var checked = e && e.target ? e.target.checked : !this.isAllSelected;\n var selectable = this.selectableRows;\n\n if (checked) {\n selectable.forEach(function (row) {\n if (!_this6.docMSelected(row)) _this6.selectedRows.push(row);\n });\n } else {\n var ids = selectable.map(function (row) {\n return row.id;\n });\n this.selectedRows = (this.selectedRows || []).filter(function (row) {\n return !row || ids.indexOf(row.id) === -1;\n });\n }\n },\n handleSearch: function handleSearch() {\n this.page = 1;\n this.loadList();\n },\n handleSizeChange: function handleSizeChange(size) {\n this.pageSize = size;\n this.page = 1;\n this.loadList();\n },\n handleCurrentChange: function handleCurrentChange(page) {\n this.page = page;\n this.loadList();\n },\n\n /**\n * 删除文件后刷新列表:若当前页因删除而超出最大页数(如某页只剩 1 条被删掉),\n * 自动回退到最后一页(即上一页),避免停留在空白页。\n */\n handleDeleted: function handleDeleted() {\n var count = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;\n var newTotal = Math.max(0, this.total - count);\n var maxPage = Math.max(1, Math.ceil(newTotal / this.pageSize));\n\n if (this.page > maxPage) {\n this.page = maxPage;\n }\n\n this.loadList();\n },\n handleAdd: function handleAdd() {\n var _this7 = this;\n\n if (!this.companyId) {\n this.$message.warning('公司数据未加载,请稍后刷新');\n return;\n }\n\n if (!this.categoryList || this.categoryList.length === 0) {\n this.$message.warning('暂无根目录,请先创建文件夹再新增文档');\n return;\n }\n\n var folderId = this.selectedCategory && this.selectedCategory.id ? this.selectedCategory.id : '';\n this.$refs.docFormRef.openAdd(folderId).then(function (res) {\n if (res) _this7.loadList();\n });\n },\n handleEdit: function handleEdit(row) {\n var _this8 = this;\n\n this.$refs.docFormRef.openEdit(row).then(function (res) {\n if (res) _this8.loadList();\n });\n },\n\n /**\n * 在线预览:图片 / PDF / Excel / Word / 文本\n */\n handlePreview: function handlePreview(row) {\n var _this9 = this;\n\n this.previewFile = row;\n this.previewText = '';\n this.docxHtml = '';\n this.xlsxWorkbook = null;\n this.xlsxSheetNames = [];\n this.xlsxCurrentSheet = '';\n this.xlsxCols = [];\n this.xlsxTableData = []; // 清理上一次的 PDF Blob URL\n\n if (this.pdfBlobUrl) {\n URL.revokeObjectURL(this.pdfBlobUrl);\n this.pdfBlobUrl = '';\n }\n\n var t = (row.fileType || '').toLowerCase();\n\n if (['png', 'jpg', 'jpeg', 'gif', 'webp', 'bmp'].includes(t)) {\n this.previewType = 'image';\n } else if (t === 'pdf') {\n this.previewType = 'pdf';\n this.loadPdfPreview(row);\n } else if (t === 'xlsx' || t === 'xls') {\n this.previewType = 'xlsx';\n this.loadXlsxPreview(row);\n } else if (t === 'docx' || t === 'doc') {\n this.previewType = 'docx';\n this.loadDocxPreview(row);\n } else if (['txt', 'md', 'markdown', 'html', 'htm'].includes(t)) {\n this.previewType = 'text';\n (0, _knowledgeBase.getFileDetail)(row.id).then(function (d) {\n _this9.previewText = d.content || '(该文件暂无可预览的文本内容)';\n }).catch(function () {\n _this9.previewText = '(文本内容加载失败)';\n });\n } else {\n this.previewType = 'none';\n }\n\n this.previewVisible = true; // 移动端:压入一条历史记录,侧滑/返回键先关闭预览,而不是退出到主页面\n\n if (this.isMobile && typeof window !== 'undefined' && window.history && window.history.pushState) {\n window.history.pushState({\n kbFilePreview: true\n }, '');\n this.previewHistoryPushed = true;\n }\n },\n // ==================== Excel 预览 ====================\n loadXlsxPreview: function loadXlsxPreview(file) {\n var _this10 = this;\n\n return (0, _asyncToGenerator2.default)( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {\n var detail, fileUrl, response, ab, workbook;\n return regeneratorRuntime.wrap(function _callee$(_context) {\n while (1) {\n switch (_context.prev = _context.next) {\n case 0:\n _this10.xlsxLoading = true;\n _context.prev = 1;\n _context.next = 4;\n return (0, _knowledgeBase.getFileDetail)(file.id);\n\n case 4:\n detail = _context.sent;\n fileUrl = detail.fileUrl || file.fileUrl;\n\n if (fileUrl) {\n _context.next = 9;\n break;\n }\n\n _this10.$message.warning('无法获取文件下载地址');\n\n return _context.abrupt(\"return\");\n\n case 9:\n _context.next = 11;\n return fetch(fileUrl);\n\n case 11:\n response = _context.sent;\n\n if (response.ok) {\n _context.next = 14;\n break;\n }\n\n throw new Error('下载文件失败');\n\n case 14:\n _context.next = 16;\n return response.arrayBuffer();\n\n case 16:\n ab = _context.sent;\n _context.next = 19;\n return new Promise(function (r) {\n return setTimeout(r, 0);\n });\n\n case 19:\n workbook = XLSX.read(ab, {\n type: 'array'\n });\n _this10.xlsxWorkbook = workbook;\n _this10.xlsxSheetNames = workbook.SheetNames;\n\n if (workbook.SheetNames.length > 0) {\n _this10.xlsxCurrentSheet = workbook.SheetNames[0];\n\n _this10.renderXlsxSheet();\n }\n\n _context.next = 29;\n break;\n\n case 25:\n _context.prev = 25;\n _context.t0 = _context[\"catch\"](1);\n console.error('加载 Excel 文件失败', _context.t0);\n\n _this10.$message.error('Excel 文件加载失败');\n\n case 29:\n _context.prev = 29;\n _this10.xlsxLoading = false;\n return _context.finish(29);\n\n case 32:\n case \"end\":\n return _context.stop();\n }\n }\n }, _callee, null, [[1, 25, 29, 32]]);\n }))();\n },\n renderXlsxSheet: function renderXlsxSheet() {\n var workbook = this.xlsxWorkbook;\n var sheetName = this.xlsxCurrentSheet;\n if (!workbook || !sheetName) return;\n var sheet = workbook.Sheets[sheetName];\n\n if (!sheet) {\n this.xlsxCols = [];\n this.xlsxTableData = [];\n return;\n } // 让出主线程,防止 sheet_to_json 阻塞 UI\n\n\n var data = XLSX.utils.sheet_to_json(sheet, {\n header: 1,\n defval: ''\n });\n\n if (data.length === 0) {\n this.xlsxCols = [];\n this.xlsxTableData = [];\n return;\n } // 列数以「所有行的最大宽度」为准:表头行可能只填了第一格,若直接按第一行长度定列会丢失后续列\n\n\n var maxCols = Math.max.apply(null, data.map(function (row) {\n return row && row.length || 0;\n }));\n this.xlsxCols = Array.from({\n length: maxCols\n }, function (_, i) {\n var v = data[0] && data[0][i];\n return v != null && String(v).trim() !== '' ? String(v) : \"\\u5217\".concat(i + 1);\n }); // 限制预览行数,防止渲染过多 DOM 卡死;同时过滤全空行\n\n var allRows = data.slice(1).filter(function (row) {\n return row && row.some(function (c) {\n return c != null && String(c).trim() !== '';\n });\n });\n this.hasMoreRows = allRows.length > MAX_PREVIEW_ROWS;\n this.xlsxTableData = allRows.slice(0, MAX_PREVIEW_ROWS).map(function (row) {\n var obj = {};\n\n for (var ci = 0; ci < maxCols; ci++) {\n obj[ci] = row[ci] != null ? String(row[ci]) : '';\n }\n\n return obj;\n });\n },\n // ==================== Word 预览 ====================\n loadDocxPreview: function loadDocxPreview(file) {\n var _this11 = this;\n\n return (0, _asyncToGenerator2.default)( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() {\n var detail, fileUrl, response, ab, result;\n return regeneratorRuntime.wrap(function _callee2$(_context2) {\n while (1) {\n switch (_context2.prev = _context2.next) {\n case 0:\n _this11.docxLoading = true;\n _context2.prev = 1;\n _context2.next = 4;\n return (0, _knowledgeBase.getFileDetail)(file.id);\n\n case 4:\n detail = _context2.sent;\n fileUrl = detail.fileUrl || file.fileUrl;\n\n if (fileUrl) {\n _context2.next = 9;\n break;\n }\n\n _this11.$message.warning('无法获取文件下载地址');\n\n return _context2.abrupt(\"return\");\n\n case 9:\n _context2.next = 11;\n return fetch(fileUrl);\n\n case 11:\n response = _context2.sent;\n\n if (response.ok) {\n _context2.next = 14;\n break;\n }\n\n throw new Error('下载文件失败');\n\n case 14:\n _context2.next = 16;\n return response.arrayBuffer();\n\n case 16:\n ab = _context2.sent;\n\n if (ab.byteLength) {\n _context2.next = 20;\n break;\n }\n\n _this11.docxHtml = '<p>(空文档)</p>';\n return _context2.abrupt(\"return\");\n\n case 20:\n _context2.next = 22;\n return _mammoth.default.convertToHtml({\n arrayBuffer: ab\n });\n\n case 22:\n result = _context2.sent;\n _this11.docxHtml = result.value || '<p>(空文档)</p>';\n _context2.next = 30;\n break;\n\n case 26:\n _context2.prev = 26;\n _context2.t0 = _context2[\"catch\"](1);\n console.error('加载 Word 文件失败', _context2.t0);\n\n _this11.$message.error('Word 文件加载失败');\n\n case 30:\n _context2.prev = 30;\n _this11.docxLoading = false;\n return _context2.finish(30);\n\n case 33:\n case \"end\":\n return _context2.stop();\n }\n }\n }, _callee2, null, [[1, 26, 30, 33]]);\n }))();\n },\n // ==================== PDF 预览 ====================\n loadPdfPreview: function loadPdfPreview(file) {\n var _this12 = this;\n\n return (0, _asyncToGenerator2.default)( /*#__PURE__*/regeneratorRuntime.mark(function _callee3() {\n var detail, fileUrl, response, blob;\n return regeneratorRuntime.wrap(function _callee3$(_context3) {\n while (1) {\n switch (_context3.prev = _context3.next) {\n case 0:\n _context3.prev = 0;\n _context3.next = 3;\n return (0, _knowledgeBase.getFileDetail)(file.id);\n\n case 3:\n detail = _context3.sent;\n fileUrl = detail.fileUrl || file.fileUrl;\n\n if (fileUrl) {\n _context3.next = 8;\n break;\n }\n\n _this12.$message.warning('无法获取文件下载地址');\n\n return _context3.abrupt(\"return\");\n\n case 8:\n _context3.next = 10;\n return fetch(fileUrl);\n\n case 10:\n response = _context3.sent;\n\n if (response.ok) {\n _context3.next = 13;\n break;\n }\n\n throw new Error('下载文件失败');\n\n case 13:\n _context3.next = 15;\n return response.blob();\n\n case 15:\n blob = _context3.sent;\n _this12.pdfBlobUrl = URL.createObjectURL(blob);\n _context3.next = 23;\n break;\n\n case 19:\n _context3.prev = 19;\n _context3.t0 = _context3[\"catch\"](0);\n console.error('加载 PDF 文件失败', _context3.t0);\n\n _this12.$message.error('PDF 文件加载失败');\n\n case 23:\n case \"end\":\n return _context3.stop();\n }\n }\n }, _callee3, null, [[0, 19]]);\n }))();\n },\n\n /**\n * 索引 / 重建索引(二次确认)\n */\n handleIndex: function handleIndex(row) {\n var _this13 = this;\n\n var isRebuild = row.indexStatus === 1;\n console.log('[DocumentList] 索引文件:', row.id, row.title, 'companyId:', this.companyId);\n this.$confirm(\"\\u786E\\u8BA4\\u5BF9\\u6587\\u4EF6\\u300C\".concat(row.title || row.fileName, \"\\u300D\").concat(isRebuild ? '重建' : '创建', \"\\u7D22\\u5F15\\uFF1F\"), '提示', {\n type: 'warning',\n confirmButtonText: '确定',\n cancelButtonText: '取消'\n }).then(function () {\n var request = isRebuild ? (0, _knowledgeBase.reindexFile)(row.id) : (0, _knowledgeBase.indexFile)(row.id);\n request.then(function () {\n _this13.$message.success(isRebuild ? '已开始重建索引' : '已开始索引');\n\n _this13.loadList();\n }).catch(function () {});\n }).catch(function () {});\n },\n\n /**\n * 删除索引(二次确认)\n */\n handleDeleteIndex: function handleDeleteIndex(row) {\n var _this14 = this;\n\n this.$confirm(\"\\u786E\\u8BA4\\u5220\\u9664\\u6587\\u4EF6\\u300C\".concat(row.title || row.fileName, \"\\u300D\\u7684\\u7D22\\u5F15\\uFF1F\\u5220\\u9664\\u540E\\u65E0\\u6CD5\\u6062\\u590D\\u3002\"), '提示', {\n type: 'warning',\n confirmButtonText: '确定删除',\n cancelButtonText: '取消'\n }).then(function () {\n (0, _knowledgeBase.deleteFileIndex)(row.id).then(function () {\n _this14.$message.success('索引已删除');\n\n _this14.loadList();\n }).catch(function () {});\n }).catch(function () {});\n },\n handleDelete: function handleDelete(row) {\n var _this15 = this;\n\n // 索引中的文件不允许删除\n if (row.indexStatus === 2) {\n this.$message.warning('该文件正在索引中,无法删除');\n return;\n }\n\n var hasIndex = row.indexStatus === 1;\n this.$confirm(\"\\u786E\\u8BA4\\u5220\\u9664\\u6587\\u4EF6\\u300C\".concat(row.title || row.fileName, \"\\u300D\\uFF1F\").concat(hasIndex ? '删除文件前会先删除该文件的索引。' : '', \"\\u5220\\u9664\\u540E\\u65E0\\u6CD5\\u6062\\u590D\\u3002\"), '提示', {\n type: 'warning',\n confirmButtonText: '确定删除',\n cancelButtonText: '取消'\n }).then( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/regeneratorRuntime.mark(function _callee4() {\n return regeneratorRuntime.wrap(function _callee4$(_context4) {\n while (1) {\n switch (_context4.prev = _context4.next) {\n case 0:\n _context4.prev = 0;\n\n if (!hasIndex) {\n _context4.next = 4;\n break;\n }\n\n _context4.next = 4;\n return (0, _knowledgeBase.deleteFileIndex)(row.id);\n\n case 4:\n _context4.next = 6;\n return (0, _knowledgeBase.deleteFile)(row.id);\n\n case 6:\n _this15.$message.success('文件已删除');\n\n _this15.handleDeleted(1);\n\n _context4.next = 12;\n break;\n\n case 10:\n _context4.prev = 10;\n _context4.t0 = _context4[\"catch\"](0);\n\n case 12:\n case \"end\":\n return _context4.stop();\n }\n }\n }, _callee4, null, [[0, 10]]);\n }))).catch(function () {});\n },\n\n /**\n * 表格勾选变化\n */\n handleSelectionChange: function handleSelectionChange(rows) {\n this.selectedRows = rows || [];\n },\n\n /**\n * 索引中的文件不可勾选删除\n */\n rowSelectable: function rowSelectable(row) {\n return row.indexStatus !== 2;\n },\n\n /**\n * 批量删除勾选的文件\n */\n handleBatchDelete: function handleBatchDelete() {\n var _this16 = this;\n\n var selected = this.selectedRows || [];\n\n if (!selected.length) {\n this.$message.warning('请先勾选要删除的文件');\n return;\n } // 索引中的文件不允许删除\n\n\n var indexingFiles = selected.filter(function (f) {\n return f.indexStatus === 2;\n });\n var deletable = selected.filter(function (f) {\n return f.indexStatus !== 2;\n });\n\n if (!deletable.length) {\n this.$message.warning('所选文件均正在索引中,无法删除');\n return;\n }\n\n if (indexingFiles.length) {\n this.$message.warning(\"\\u6709 \".concat(indexingFiles.length, \" \\u4E2A\\u6587\\u4EF6\\u6B63\\u5728\\u7D22\\u5F15\\u4E2D\\uFF0C\\u672C\\u6B21\\u5C06\\u8DF3\\u8FC7\"));\n } // 已索引的文件需先删除索引,再删除文件\n\n\n var indexed = deletable.filter(function (f) {\n return f.indexStatus === 1;\n });\n var ids = deletable.map(function (f) {\n return f.id;\n });\n this.$confirm(\"\\u786E\\u8BA4\\u5220\\u9664\\u9009\\u4E2D\\u7684 \".concat(deletable.length, \" \\u4E2A\\u6587\\u4EF6\\uFF1F\").concat(indexed.length ? '删除前会先删除这些文件的索引。' : '', \"\\u5220\\u9664\\u540E\\u65E0\\u6CD5\\u6062\\u590D\\u3002\"), '提示', {\n type: 'warning',\n confirmButtonText: '确定删除',\n cancelButtonText: '取消',\n customClass: 'kb-message-box'\n }).then( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/regeneratorRuntime.mark(function _callee5() {\n return regeneratorRuntime.wrap(function _callee5$(_context5) {\n while (1) {\n switch (_context5.prev = _context5.next) {\n case 0:\n _context5.prev = 0;\n\n if (!indexed.length) {\n _context5.next = 4;\n break;\n }\n\n _context5.next = 4;\n return Promise.all(indexed.map(function (f) {\n return (0, _knowledgeBase.deleteFileIndex)(f.id);\n }));\n\n case 4:\n _context5.next = 6;\n return (0, _knowledgeBase.deleteFiles)(ids);\n\n case 6:\n _this16.$message.success('批量删除成功');\n\n _this16.handleDeleted(deletable.length);\n\n _context5.next = 12;\n break;\n\n case 10:\n _context5.prev = 10;\n _context5.t0 = _context5[\"catch\"](0);\n\n case 12:\n case \"end\":\n return _context5.stop();\n }\n }\n }, _callee5, null, [[0, 10]]);\n }))).catch(function () {});\n },\n\n /**\n * 批量移动:打开目标文件夹选择弹窗\n */\n handleBatchMove: function handleBatchMove() {\n var _this17 = this;\n\n return (0, _asyncToGenerator2.default)( /*#__PURE__*/regeneratorRuntime.mark(function _callee6() {\n var selected, folders;\n return regeneratorRuntime.wrap(function _callee6$(_context6) {\n while (1) {\n switch (_context6.prev = _context6.next) {\n case 0:\n selected = _this17.selectedRows || [];\n\n if (selected.length) {\n _context6.next = 4;\n break;\n }\n\n _this17.$message.warning('请先勾选要移动的文件');\n\n return _context6.abrupt(\"return\");\n\n case 4:\n if (_this17.companyId) {\n _context6.next = 7;\n break;\n }\n\n _this17.$message.warning('公司数据未加载');\n\n return _context6.abrupt(\"return\");\n\n case 7:\n _this17.moveFolderId = null;\n _this17.moveVisible = true; // 每次打开都重新加载文件夹列表,确保新建/重命名/删除文件夹后看到最新目录\n\n _context6.prev = 9;\n _context6.next = 12;\n return (0, _knowledgeBase.getFolderList)(_this17.companyId);\n\n case 12:\n folders = _context6.sent;\n _this17.folderList = folders || [];\n _context6.next = 18;\n break;\n\n case 16:\n _context6.prev = 16;\n _context6.t0 = _context6[\"catch\"](9);\n\n case 18:\n _this17.$nextTick(function () {\n if (_this17.$refs.moveTreeRef) _this17.$refs.moveTreeRef.setCurrentKey(null);\n });\n\n case 19:\n case \"end\":\n return _context6.stop();\n }\n }\n }, _callee6, null, [[9, 16]]);\n }))();\n },\n\n /**\n * 选择目标文件夹\n */\n handleMoveFolderSelect: function handleMoveFolderSelect(data) {\n this.moveFolderId = data.id;\n },\n\n /**\n * 确认批量移动\n */\n handleMoveConfirm: function handleMoveConfirm() {\n var _this18 = this;\n\n return (0, _asyncToGenerator2.default)( /*#__PURE__*/regeneratorRuntime.mark(function _callee7() {\n var ids, targetFolder;\n return regeneratorRuntime.wrap(function _callee7$(_context7) {\n while (1) {\n switch (_context7.prev = _context7.next) {\n case 0:\n if (_this18.moveFolderId) {\n _context7.next = 3;\n break;\n }\n\n _this18.$message.warning('请选择目标文件夹');\n\n return _context7.abrupt(\"return\");\n\n case 3:\n ids = _this18.selectedRows.map(function (f) {\n return f.id;\n });\n _this18.moving = true;\n _context7.prev = 5;\n _context7.next = 8;\n return (0, _knowledgeBase.moveFiles)(ids, _this18.moveFolderId);\n\n case 8:\n _this18.$message.success('批量移动成功');\n\n _this18.moveVisible = false; // 移动成功后,通知父级定位并高亮左侧树到目标文件夹\n\n targetFolder = _this18.folderList.find(function (f) {\n return String(f.id) === String(_this18.moveFolderId);\n }) || null;\n if (targetFolder) _this18.$emit('move-target', targetFolder);else _this18.$emit('move-target', {\n id: _this18.moveFolderId,\n name: _this18.moveTargetName\n });\n\n _this18.loadList();\n\n _context7.next = 17;\n break;\n\n case 15:\n _context7.prev = 15;\n _context7.t0 = _context7[\"catch\"](5);\n\n case 17:\n _context7.prev = 17;\n _this18.moving = false;\n return _context7.finish(17);\n\n case 20:\n case \"end\":\n return _context7.stop();\n }\n }\n }, _callee7, null, [[5, 15, 17, 20]]);\n }))();\n },\n\n /**\n * 通过 folderId 映射文件夹名称\n */\n folderName: function folderName(folderId) {\n if (!folderId) return '根目录';\n var found = this.categoryList.find(function (f) {\n return String(f.id) === String(folderId);\n });\n return found ? found.name : '-';\n },\n\n /**\n * 根据文件类型返回对应图标\n */\n getFileIcon: function getFileIcon(fileType) {\n var type = (fileType || '').toLowerCase();\n var iconMap = {\n pdf: 'el-icon-document',\n doc: 'el-icon-document',\n docx: 'el-icon-document',\n xls: 'el-icon-tickets',\n xlsx: 'el-icon-tickets',\n ppt: 'el-icon-data-line',\n pptx: 'el-icon-data-line',\n txt: 'el-icon-document',\n md: 'el-icon-edit-outline',\n png: 'el-icon-picture',\n jpg: 'el-icon-picture',\n jpeg: 'el-icon-picture',\n gif: 'el-icon-picture',\n zip: 'el-icon-folder-opened',\n rar: 'el-icon-folder-opened'\n };\n return iconMap[type] || 'el-icon-document';\n },\n\n /**\n * 根据文件类型返回对应的图标 URL\n * 映射统一维护在 @lib/utils/fileType.js(与聊天附件共用)\n */\n getFileIconUrl: function getFileIconUrl(fileType) {\n return (0, _fileType.getFileIconUrl)(fileType);\n },\n\n /**\n * 文件大小格式化(字节 → B/KB/MB/GB)\n */\n formatSize: function formatSize(bytes) {\n if (!bytes && bytes !== 0) return '-';\n if (bytes === 0) return '0 B';\n var units = ['B', 'KB', 'MB', 'GB', 'TB'];\n var size = bytes;\n var idx = 0;\n\n while (size >= 1024 && idx < units.length - 1) {\n size /= 1024;\n idx++;\n }\n\n return \"\".concat(idx === 0 ? size : size.toFixed(2), \" \").concat(units[idx]);\n },\n\n /**\n * 时间展示:ISO 本地时间去掉 T 分隔符\n */\n formatTime: function formatTime(time) {\n if (!time) return '-';\n return String(time).replace('T', ' ').replace(/\\+08:00$/, '').replace(/\\.\\d{3}/, '');\n },\n\n /**\n * 索引状态标签:0 未索引 / 1 已索引 / 2 索引中 / 3 失败\n */\n indexTagType: function indexTagType(status) {\n var map = {\n 0: 'info',\n 1: 'success',\n 2: 'warning',\n 3: 'danger'\n };\n return map[status] || 'info';\n },\n indexTagText: function indexTagText(status) {\n var map = {\n 0: '未索引',\n 1: '已索引',\n 2: '索引中',\n 3: '索引失败'\n };\n return map[status] || '未知';\n }\n }\n};\nexports.default = _default2;\n\n//# sourceURL=webpack://ZjPluginIntelligent/./src/lib/knowledgeBase/DocumentList.vue?./node_modules/cache-loader/dist/cjs.js??ref--12-0!./node_modules/babel-loader/lib!./node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/vue-loader/lib??vue-loader-options");
|
|
1013
1013
|
|
|
1014
1014
|
/***/ }),
|
|
1015
1015
|
|
|
@@ -14756,7 +14756,7 @@ eval("// Generated by CoffeeScript 1.12.7\n(function() {\n var XMLDocument, XML
|
|
|
14756
14756
|
/*! exports provided: name, version, main, private, scripts, dependencies, devDependencies, browserslist, directories, keywords, license, files, default */
|
|
14757
14757
|
/***/ (function(module) {
|
|
14758
14758
|
|
|
14759
|
-
eval("module.exports = JSON.parse(\"{\\\"name\\\":\\\"zj-plugin-intelligent\\\",\\\"version\\\":\\\"1.2.26-beta.
|
|
14759
|
+
eval("module.exports = JSON.parse(\"{\\\"name\\\":\\\"zj-plugin-intelligent\\\",\\\"version\\\":\\\"1.2.26-beta.7\\\",\\\"main\\\":\\\"lib/ZjPluginIntelligent.umd.min.js\\\",\\\"private\\\":false,\\\"scripts\\\":{\\\"serve\\\":\\\"set NODE_OPTIONS=--openssl-legacy-provider && vue-cli-service serve\\\",\\\"build\\\":\\\"set NODE_OPTIONS=--openssl-legacy-provider && vue-cli-service build\\\",\\\"lib\\\":\\\"node scripts/build-lib.js\\\",\\\"lib:test\\\":\\\"node scripts/build-lib.js test\\\"},\\\"dependencies\\\":{\\\"@jboltai/tokui\\\":\\\"^0.1.6\\\",\\\"crypto-js\\\":\\\"^4.2.0\\\",\\\"docx\\\":\\\"^8.5.0\\\",\\\"html2canvas\\\":\\\"^1.4.1\\\",\\\"mammoth\\\":\\\"^1.6.0\\\",\\\"markdown-it\\\":\\\"^13.0.2\\\",\\\"marked\\\":\\\"^4.3.0\\\",\\\"xlsx\\\":\\\"^0.18.5\\\"},\\\"devDependencies\\\":{\\\"@babel/preset-env\\\":\\\"^7.14.9\\\",\\\"@vue/cli-plugin-babel\\\":\\\"~4.5.0\\\",\\\"@vue/cli-plugin-eslint\\\":\\\"~4.5.0\\\",\\\"@vue/cli-plugin-vuex\\\":\\\"~4.5.0\\\",\\\"@vue/cli-service\\\":\\\"~4.5.0\\\",\\\"axios\\\":\\\"^0.27.2\\\",\\\"babel-eslint\\\":\\\"^10.1.0\\\",\\\"babel-plugin-component\\\":\\\"^1.1.1\\\",\\\"compression-webpack-plugin\\\":\\\"^6.0.3\\\",\\\"core-js\\\":\\\"^3.6.5\\\",\\\"element-ui\\\":\\\"^2.15.4\\\",\\\"eslint\\\":\\\"^6.8.0\\\",\\\"eslint-plugin-vue\\\":\\\"^7.13.0\\\",\\\"js-cookie\\\":\\\"^2.2.1\\\",\\\"obs-upload\\\":\\\"^1.0.4\\\",\\\"pako\\\":\\\"^2.1.0\\\",\\\"reconnecting-websocket\\\":\\\"^4.4.0\\\",\\\"sass\\\":\\\"^1.71.0\\\",\\\"sass-loader\\\":\\\"^8.0.2\\\",\\\"snowflake-id\\\":\\\"^1.1.0\\\",\\\"vue\\\":\\\"^2.6.11\\\",\\\"vue-template-compiler\\\":\\\"^2.6.11\\\",\\\"vuex\\\":\\\"^3.4.0\\\",\\\"webpack-bundle-analyzer\\\":\\\"^4.4.2\\\"},\\\"browserslist\\\":[\\\"> 1%\\\",\\\"last 2 versions\\\",\\\"not dead\\\"],\\\"directories\\\":{\\\"lib\\\":\\\"lib\\\"},\\\"keywords\\\":[],\\\"license\\\":\\\"ISC\\\",\\\"files\\\":[\\\"lib\\\"]}\");\n\n//# sourceURL=webpack://ZjPluginIntelligent/./package.json?");
|
|
14760
14760
|
|
|
14761
14761
|
/***/ }),
|
|
14762
14762
|
|