|
@@ -18,8 +18,13 @@
|
|
<i class="el-icon-folder"></i>
|
|
<i class="el-icon-folder"></i>
|
|
{{ node.label }}
|
|
{{ node.label }}
|
|
</span>
|
|
</span>
|
|
- <span class="file-count">{{ data.document_count }} files</span>
|
|
|
|
- <span class="folder-actions" v-if="data.id !== 0">
|
|
|
|
|
|
+ <span v-if="data.id !== '001'" :class="getFileCountClass(data.id)"
|
|
|
|
+ >{{ data.document_count }} files</span
|
|
|
|
+ >
|
|
|
|
+ <span
|
|
|
|
+ class="folder-actions"
|
|
|
|
+ v-if="data.id !== 0 && data.id !== '001'"
|
|
|
|
+ >
|
|
<el-tooltip
|
|
<el-tooltip
|
|
class="item"
|
|
class="item"
|
|
effect="dark"
|
|
effect="dark"
|
|
@@ -61,6 +66,7 @@
|
|
>
|
|
>
|
|
<el-button
|
|
<el-button
|
|
type="primary"
|
|
type="primary"
|
|
|
|
+ @click="batchModifyFolder"
|
|
:disabled="!selectedRows.length"
|
|
:disabled="!selectedRows.length"
|
|
>批量修改目录</el-button
|
|
>批量修改目录</el-button
|
|
>
|
|
>
|
|
@@ -70,7 +76,7 @@
|
|
:data="dataList"
|
|
:data="dataList"
|
|
style="width: 100%"
|
|
style="width: 100%"
|
|
header-row-class-name="headerBg"
|
|
header-row-class-name="headerBg"
|
|
- empty-text="没有模板信息"
|
|
|
|
|
|
+ empty-text="暂无数据"
|
|
@selection-change="handleSelectionChange"
|
|
@selection-change="handleSelectionChange"
|
|
@sort-change="handleSortChange"
|
|
@sort-change="handleSortChange"
|
|
>
|
|
>
|
|
@@ -229,7 +235,7 @@
|
|
:page-count="pageTotal"
|
|
:page-count="pageTotal"
|
|
:page-sizes="[10, 20, 50, 100]"
|
|
:page-sizes="[10, 20, 50, 100]"
|
|
background
|
|
background
|
|
- layout="sizes, prev, pager, next"
|
|
|
|
|
|
+ layout="total,sizes, prev, pager, next"
|
|
@current-change="ChangePage"
|
|
@current-change="ChangePage"
|
|
@size-change="handleSizeChange"
|
|
@size-change="handleSizeChange"
|
|
>
|
|
>
|
|
@@ -312,6 +318,41 @@
|
|
<el-button type="primary" @click="submitNewFolder">确 定</el-button>
|
|
<el-button type="primary" @click="submitNewFolder">确 定</el-button>
|
|
</span>
|
|
</span>
|
|
</el-dialog>
|
|
</el-dialog>
|
|
|
|
+ <!-- 批量修改目录 -->
|
|
|
|
+ <el-dialog
|
|
|
|
+ title="批量修改目录"
|
|
|
|
+ :visible.sync="batchModifyFolderDialogVisible"
|
|
|
|
+ width="30%"
|
|
|
|
+ >
|
|
|
|
+ <el-form
|
|
|
|
+ :model="batchModifyFolderForm"
|
|
|
|
+ :rules="batchModifyFolderRules"
|
|
|
|
+ ref="batchModifyFolderFormRef"
|
|
|
|
+ >
|
|
|
|
+ <el-form-item label="选择目录" prop="folderId">
|
|
|
|
+ <el-select
|
|
|
|
+ v-model="batchModifyFolderForm.folderId"
|
|
|
|
+ placeholder="请选择目录"
|
|
|
|
+ >
|
|
|
|
+ <el-option
|
|
|
|
+ v-for="folder in folders.filter((f) => f.id !== 0)"
|
|
|
|
+ :key="folder.id"
|
|
|
|
+ :label="folder.name"
|
|
|
|
+ :value="folder.id"
|
|
|
|
+ >
|
|
|
|
+ </el-option>
|
|
|
|
+ </el-select>
|
|
|
|
+ </el-form-item>
|
|
|
|
+ </el-form>
|
|
|
|
+ <span slot="footer" class="dialog-footer">
|
|
|
|
+ <el-button @click="batchModifyFolderDialogVisible = false"
|
|
|
|
+ >取 消</el-button
|
|
|
|
+ >
|
|
|
|
+ <el-button type="primary" @click="submitBatchModifyFolder"
|
|
|
|
+ >确 定</el-button
|
|
|
|
+ >
|
|
|
|
+ </span>
|
|
|
|
+ </el-dialog>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
@@ -333,6 +374,7 @@ import {
|
|
selectTypeList,
|
|
selectTypeList,
|
|
deleteType,
|
|
deleteType,
|
|
Info,
|
|
Info,
|
|
|
|
+ batchMove,
|
|
} from "@/api/knowledge";
|
|
} from "@/api/knowledge";
|
|
export default {
|
|
export default {
|
|
components: {
|
|
components: {
|
|
@@ -349,14 +391,14 @@ export default {
|
|
page: 1,
|
|
page: 1,
|
|
pageSize: 10,
|
|
pageSize: 10,
|
|
bucket_id: "",
|
|
bucket_id: "",
|
|
- folder: 0,
|
|
|
|
|
|
+ doc_type_id: 0,
|
|
},
|
|
},
|
|
typeForm: {
|
|
typeForm: {
|
|
page: 1,
|
|
page: 1,
|
|
- pageSize: 10,
|
|
|
|
|
|
+ pageSize: 9999,
|
|
kb_id: "",
|
|
kb_id: "",
|
|
},
|
|
},
|
|
- folders: [{ id: 0, name: "All", document_count: 0 }],
|
|
|
|
|
|
+ folders: [{ id: "001", name: "全部", document_count: 0 }],
|
|
defaultProps: {
|
|
defaultProps: {
|
|
children: "children",
|
|
children: "children",
|
|
label: "name",
|
|
label: "name",
|
|
@@ -401,6 +443,16 @@ export default {
|
|
{ required: true, message: "请输入文件夹名称", trigger: "blur" },
|
|
{ required: true, message: "请输入文件夹名称", trigger: "blur" },
|
|
],
|
|
],
|
|
},
|
|
},
|
|
|
|
+ /* 批量修改目录 */
|
|
|
|
+ batchModifyFolderDialogVisible: false,
|
|
|
|
+ batchModifyFolderForm: {
|
|
|
|
+ folderId: null,
|
|
|
|
+ },
|
|
|
|
+ batchModifyFolderRules: {
|
|
|
|
+ folderId: [
|
|
|
|
+ { required: true, message: "请选择目标目录", trigger: "change" },
|
|
|
|
+ ],
|
|
|
|
+ },
|
|
};
|
|
};
|
|
},
|
|
},
|
|
mounted() {
|
|
mounted() {
|
|
@@ -416,6 +468,51 @@ export default {
|
|
Object.values(this.analysisStatusCheckers).forEach(clearTimeout);
|
|
Object.values(this.analysisStatusCheckers).forEach(clearTimeout);
|
|
},
|
|
},
|
|
methods: {
|
|
methods: {
|
|
|
|
+ /* 判断类名 */
|
|
|
|
+ getFileCountClass(id) {
|
|
|
|
+ const isSpecialFolder = id === 0 || id === "001";
|
|
|
|
+ console.log(
|
|
|
|
+ `ID: ${id}, Class: ${isSpecialFolder ? "file-counts" : "file-count"}`
|
|
|
|
+ );
|
|
|
|
+ return isSpecialFolder ? "file-counts" : "file-count";
|
|
|
|
+ },
|
|
|
|
+ /* 批量修改目录 */
|
|
|
|
+ batchModifyFolder() {
|
|
|
|
+ if (this.selectedRows.length === 0) {
|
|
|
|
+ this.$message.warning("请选择要修改目录的文件");
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ this.batchModifyFolderDialogVisible = true;
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ submitBatchModifyFolder() {
|
|
|
|
+ this.$refs.batchModifyFolderFormRef.validate((valid) => {
|
|
|
|
+ if (valid) {
|
|
|
|
+ const selectedIds = this.selectedRows.map((row) => row.id);
|
|
|
|
+ console.log(selectedIds);
|
|
|
|
+ batchMove({
|
|
|
|
+ ids: JSON.stringify(selectedIds),
|
|
|
|
+ doc_type_id: this.batchModifyFolderForm.folderId,
|
|
|
|
+ })
|
|
|
|
+ .then((res) => {
|
|
|
|
+ if (res.status === 200) {
|
|
|
|
+ this.$message.success("批量修改目录成功");
|
|
|
|
+ this.batchModifyFolderDialogVisible = false;
|
|
|
|
+ this.search(); // Refresh the document list
|
|
|
|
+ this.typeList(); // Refresh the folder list
|
|
|
|
+ this.clearSelection();
|
|
|
|
+ } else {
|
|
|
|
+ this.$message.error("批量修改目录失败");
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ .catch((error) => {
|
|
|
|
+ console.error("批量修改目录时出错:", error);
|
|
|
|
+ this.$message.error("批量修改目录时出错");
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ },
|
|
|
|
+
|
|
editFolder(folder) {
|
|
editFolder(folder) {
|
|
this.$prompt("请输入新的文件夹名称", "编辑文件夹", {
|
|
this.$prompt("请输入新的文件夹名称", "编辑文件夹", {
|
|
confirmButtonText: "确定",
|
|
confirmButtonText: "确定",
|
|
@@ -484,19 +581,25 @@ export default {
|
|
if (res.status === 200) {
|
|
if (res.status === 200) {
|
|
const folderList = res.data.dataList.map((folder) => ({
|
|
const folderList = res.data.dataList.map((folder) => ({
|
|
...folder,
|
|
...folder,
|
|
- document_count: folder.file_count || 0,
|
|
|
|
|
|
+ id: folder.id === 0 ? "001" : folder.id.toString(),
|
|
|
|
+ document_count: folder.document_count || 0,
|
|
}));
|
|
}));
|
|
|
|
|
|
this.folders = [
|
|
this.folders = [
|
|
{
|
|
{
|
|
- id: 0,
|
|
|
|
- name: "All",
|
|
|
|
|
|
+ id: "001",
|
|
|
|
+ name: "全部",
|
|
document_count: folderList.reduce(
|
|
document_count: folderList.reduce(
|
|
(sum, folder) => sum + folder.document_count,
|
|
(sum, folder) => sum + folder.document_count,
|
|
0
|
|
0
|
|
),
|
|
),
|
|
},
|
|
},
|
|
- ...folderList.filter((folder) => folder.id !== 0),
|
|
|
|
|
|
+ ...folderList.filter((folder) => folder.id !== "001"),
|
|
|
|
+ {
|
|
|
|
+ id: 0, // 给"其他"文件夹一个不同的 id
|
|
|
|
+ name: "其他",
|
|
|
|
+ document_count: 0, // 这个值会在 search 方法中更新
|
|
|
|
+ },
|
|
];
|
|
];
|
|
this.$nextTick(() => {
|
|
this.$nextTick(() => {
|
|
this.initializeTree();
|
|
this.initializeTree();
|
|
@@ -546,8 +649,12 @@ export default {
|
|
},
|
|
},
|
|
|
|
|
|
initializeTree() {
|
|
initializeTree() {
|
|
- this.$refs.folderTree.setCurrentKey("0");
|
|
|
|
- this.handleNodeClick(this.folders[0]); // Trigger initial search for "All"
|
|
|
|
|
|
+ this.$nextTick(() => {
|
|
|
|
+ if (this.$refs.folderTree) {
|
|
|
|
+ this.$refs.folderTree.setCurrentKey("001");
|
|
|
|
+ this.handleNodeClick(this.folders[0]);
|
|
|
|
+ }
|
|
|
|
+ });
|
|
},
|
|
},
|
|
checkAuth(path) {
|
|
checkAuth(path) {
|
|
if (this.roleInfo.is_admin === 1) {
|
|
if (this.roleInfo.is_admin === 1) {
|
|
@@ -559,10 +666,11 @@ export default {
|
|
},
|
|
},
|
|
|
|
|
|
setQuery(e) {
|
|
setQuery(e) {
|
|
- this.queryForm = e;
|
|
|
|
|
|
+ this.queryForm = { ...this.queryForm, ...e };
|
|
|
|
+ this.search();
|
|
},
|
|
},
|
|
handleNodeClick(data) {
|
|
handleNodeClick(data) {
|
|
- this.queryForm.folder = data.id;
|
|
|
|
|
|
+ this.queryForm.doc_type_id = data.id === "001" ? "" : data.id;
|
|
this.queryForm.page = 1; // Reset to first page when changing folder
|
|
this.queryForm.page = 1; // Reset to first page when changing folder
|
|
this.search();
|
|
this.search();
|
|
},
|
|
},
|
|
@@ -892,13 +1000,24 @@ export default {
|
|
_this.queryForm.pageSize = res.data.pagination.total_size;
|
|
_this.queryForm.pageSize = res.data.pagination.total_size;
|
|
_this.loading = false;
|
|
_this.loading = false;
|
|
|
|
|
|
- // Update file count for the selected folder
|
|
|
|
- if (_this.queryForm.folder === "0") {
|
|
|
|
- // If "All" is selected, update its document_count
|
|
|
|
- _this.folders[0].document_count = _this.recordCount;
|
|
|
|
- } else {
|
|
|
|
|
|
+ // Count documents with doc_type_id === 0 or null
|
|
|
|
+ const unclassifiedCount = res.data.documents.filter(
|
|
|
|
+ (doc) => !doc.doc_type_id || doc.doc_type_id === 0
|
|
|
|
+ ).length;
|
|
|
|
+
|
|
|
|
+ // Update "其他" folder count
|
|
|
|
+ const otherFolder = _this.folders.find((f) => f.id === 0);
|
|
|
|
+ if (otherFolder) {
|
|
|
|
+ otherFolder.document_count = unclassifiedCount;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // Update the selected folder count if it's not "全部" or "其他"
|
|
|
|
+ if (
|
|
|
|
+ _this.queryForm.doc_type_id &&
|
|
|
|
+ _this.queryForm.doc_type_id !== 0
|
|
|
|
+ ) {
|
|
const selectedFolder = _this.folders.find(
|
|
const selectedFolder = _this.folders.find(
|
|
- (f) => f.id === _this.queryForm.folder
|
|
|
|
|
|
+ (f) => f.id === _this.queryForm.doc_type_id
|
|
);
|
|
);
|
|
if (selectedFolder) {
|
|
if (selectedFolder) {
|
|
selectedFolder.document_count = _this.recordCount;
|
|
selectedFolder.document_count = _this.recordCount;
|
|
@@ -916,6 +1035,7 @@ export default {
|
|
_this.loading = false;
|
|
_this.loading = false;
|
|
});
|
|
});
|
|
},
|
|
},
|
|
|
|
+
|
|
//修改分页
|
|
//修改分页
|
|
ChangePage(e) {
|
|
ChangePage(e) {
|
|
let _this = this;
|
|
let _this = this;
|
|
@@ -952,7 +1072,13 @@ export default {
|
|
.file-count {
|
|
.file-count {
|
|
color: #909399;
|
|
color: #909399;
|
|
font-size: 12px;
|
|
font-size: 12px;
|
|
-
|
|
|
|
|
|
+ padding: 2px 6px;
|
|
|
|
+ border-radius: 10px;
|
|
|
|
+ transition: opacity 0.3s;
|
|
|
|
+ }
|
|
|
|
+ .file-counts {
|
|
|
|
+ color: #909399;
|
|
|
|
+ font-size: 12px;
|
|
padding: 2px 6px;
|
|
padding: 2px 6px;
|
|
border-radius: 10px;
|
|
border-radius: 10px;
|
|
transition: opacity 0.3s;
|
|
transition: opacity 0.3s;
|