Ver Fonte

功能优化

songxy há 4 meses atrás
pai
commit
7e804fabe3

+ 1 - 0
ais_search/web/package.json

@@ -36,6 +36,7 @@
     "jspdf": "^2.5.2",
     "leaflet": "^1.9.4",
     "lodash": "^4.17.21",
+    "lodash-es": "^4.17.21",
     "pdfjs-dist": "^2.16.105",
     "pinia": "^2.1.3",
     "pinia-plugin-persist": "^1.0.0",

+ 8 - 3
ais_search/web/src/views/document/TitleHeader.vue

@@ -4,9 +4,9 @@
       <div
         class="t-item"
         :class="{ checked: t.checked }"
-        v-for="(t, i) in props.items"
+        v-for="(t, i) in items"
         :key="i"
-        @click="t.onClick && t.onClick()"
+        @click="clickHandle(t)"
       >
         <span v-if="i > 0"> <RightOutlined class="icon" /></span>
         {{ t.name }}
@@ -27,6 +27,10 @@ const props = defineProps({
       }
     ],
 });
+const emits = defineEmits(['tabClick']) 
+const clickHandle = (item) => {
+  emits('tabClick', item)
+}
 </script>
 <style lang="scss" scoped>
 .title-container {
@@ -40,11 +44,12 @@ const props = defineProps({
   .left-box {
     display: flex;
     align-items: center;
+    user-select: none;
     .t-item {
       font-family: PingFang SC, PingFang SC;
       font-weight: 400;
       font-size: 15px;
-      color: #82889b;
+      color: #82889B;
       cursor: pointer;
       .icon {
         width: 14px;

+ 10 - 6
ais_search/web/src/views/document/config.ts

@@ -13,28 +13,32 @@ export const columns = [
     title: "文档名称",
     dataIndex: "fileName",
     key: "fileName",
+    width: 560
   },
   {
-    title: "知识领域",
+    title: "文档类型",
     dataIndex: "fileBizline",
     key: "fileBizline",
   },
   {
-    title: "文章体裁",
+    title: "文档大小",
     dataIndex: "fileFormat",
     key: "fileFormat",
+    sorter: {
+      compare: (a, b) => a.math - b.math,
+      multiple: 2,
+    },
   },
   {
-    title: "收藏时间",
+    title: "创建时间",
     dataIndex: "createTime",
     key: "createTime",
-    width: 200,
     align: "center",
   },
   {
     title: "操作",
     key: "action",
-    width: 150,
+    width: 250,
     align: "center",
   },
-];
+];

+ 13 - 1
ais_search/web/src/views/document/index.scss

@@ -1,6 +1,5 @@
 
 .page-doc {
-  border: 1px solid #f00;
   height: 100%;
   >.header {
     width: 100%;
@@ -45,4 +44,17 @@
       }
     }
   }
+  ::v-deep {
+    th.ant-table-cell {
+      &::before {
+        width: 0px !important;
+      }
+    }
+    .ant-table-column-sorters {
+      justify-content: flex-start;
+    }
+    .ant-table-column-title {
+      flex: none;
+    }
+  }
 }

+ 76 - 18
ais_search/web/src/views/document/index.vue

@@ -1,10 +1,10 @@
 <template>
   <div class="page-doc">
     <div class="header">
-      <home-header @login="emits('login')" />
+      <home-header @login="emits('login')" sub-title="知识库管理" />
     </div>
     <div class="my-doc-container">
-      <TitleHeader :items="menuList" />
+      <TitleHeader :items="menuList"  @tabClick="tabClickHandle" />
       <FileDetail
         v-if="clickFileDetail && clickFileDetail.sign == 'file'"
         :fileDetail="clickFileDetail"
@@ -69,18 +69,25 @@
             :pagination="false"
           >
             <template #bodyCell="{ column, record }">
-              <template v-if="column.key === 'fileName'">
-                <div
-                  v-if="record.sign == 'dir'"
-                  class="name-box"
-                  @click="jumpToFile(record)"
-                >
-                  <MyIcon :icon="iconTypeName.dir" size="18" />
-                  <span>{{ record.fileName }}</span>
-                </div>
-                <div v-else class="name-box" @click="showFileDetail(record)">
-                  <MyIcon :icon="iconTypeName[record.fileType]" size="18" />
-                  <span>{{ record.fileName }}</span>
+              <template v-if="column.dataIndex === 'fileName'">
+                <div class="editable-cell">
+                  <div v-if="editableData[record.key]">
+                    <a-input v-model:value="editableData[record.key].fileName" @pressEnter="save(record.key)" />
+                  </div>
+                  <div v-else class="editable-cell-text-wrapper">
+                    <div
+                      v-if="record.sign == 'dir'"
+                      class="name-box"
+                      @click="jumpToFile(record)"
+                    >
+                      <MyIcon :icon="iconTypeName.dir" size="18" />
+                      <span>{{ record.fileName }}</span>
+                    </div>
+                    <div v-else class="name-box" @click="showFileDetail(record)">
+                      <MyIcon :icon="iconTypeName[record.fileType]" size="18" />
+                      <span>{{ record.fileName }}</span>
+                    </div>
+                  </div>
                 </div>
               </template>
               <template v-if="column.key === 'createTime'">
@@ -107,7 +114,16 @@
                   </a>
                   <template #overlay>
                     <a-menu>
-                      <a-menu-item v-if="record.sign !== 'dir'">
+                      <a-menu-item>
+                        <a-button
+                          type="link"
+                          :icon="h(DeleteOutlined)"
+                          style="color: #000"
+                          @click="moveFiles([record.id])"
+                          >刪除</a-button
+                        >
+                      </a-menu-item>
+                      <a-menu-item>
                         <a-button
                           type="link"
                           :icon="h(DeliveredProcedureOutlined)"
@@ -125,6 +141,15 @@
                           >置顶</a-button
                         >
                       </a-menu-item>
+                      <a-menu-item>
+                        <a-button
+                          type="link"
+                          :icon="h(FormOutlined)"
+                          style="color: #000"
+                          @click="editFolderName(record.key)"
+                          >编辑</a-button
+                        >
+                      </a-menu-item>
                     </a-menu>
                   </template>
                 </a-dropdown>
@@ -153,8 +178,11 @@
 /**
  * @description 我的文档
  */
+import { cloneDeep } from 'lodash-es';
 import { h, ref, reactive, onMounted } from "vue";
 import {
+  FormOutlined,
+  DeleteOutlined,
   CloudUploadOutlined,
   SearchOutlined,
   DownloadOutlined,
@@ -189,11 +217,27 @@ const menuList = ref<{
   checked: boolean
 }[]>([
   {
-    name: "我的收藏",
-    id: '',
+    name: "全部",
+    id: '-1',
     checked: true
   }
 ])
+const currentTabId = ref('-1')
+const tabClickHandle = (item) => {
+  if (currentTabId.value === item['id']) return;
+  if (item['id'] === '-1') {
+    menuList.value = [{
+      name: "全部",
+      id: '-1',
+      checked: true
+    }]
+    getDataSource();
+  } else {
+    getDataSource({
+      id: item.id,
+    });
+  }
+}
 // 切换目录
 const changeMenu = (fileName: any = null) => {
   // 切换目录时重置搜索内容和选中的文件
@@ -250,6 +294,7 @@ const onSelectChange = (selectedRowKeys: any[]) => {
 const clickFileDetail = ref<null | any>(null);
 const jumpToFile = (data: any) => {
   clickFileDetail.value = data;
+  currentTabId.value = data.id;
   // 触发目录切换的回调
   changeMenu(data.fileName);
   getDataSource({
@@ -309,6 +354,20 @@ const downloadFiles = async (ids: any[] = []) => {
     message.error("下载失败,请稍后重试!");
   }
 };
+const editableData = reactive({});
+const save = (key: string) => {
+  const item = dataSource.value.filter(item => key === item.key)[0];
+  Object.assign(item, editableData[key]);
+  delete editableData[key];
+};
+//编辑文件夹名称
+const editFolderName = (key) => {
+  editableData[key] = cloneDeep(dataSource.value.filter(item => key === item.key)[0]);
+}
+//刪除
+const deleteFiles = () => {
+  
+}
 // 移动:最外层文件禁止多选移动,文件夹类型禁止移动
 const moveFileModel = ref(false);
 const moveFileIds = ref<any[]>([]);
@@ -352,7 +411,6 @@ const topFile = async (id: string) => {
 
 // 跳到文件详情页面
 const showFileDetail = (data: any) => {
-  console.log("跳到文件详情页面", data);
   clickFileDetail.value = {
     ...data,
     id: data.fileId,

+ 25 - 2
ais_search/web/src/views/home/components/HomeHeader.vue

@@ -2,6 +2,7 @@
   <div class="home-header">
     <div class="left">
       <div class="sys-icon" @click="linkToHome"></div>
+      <div v-if="subTitle" class="sub_title">{{ subTitle }}</div>
     </div>
     <div class="right user-panel" v-if="false">
       <user-avatar />
@@ -12,7 +13,12 @@
 import UserAvatar from '@/views/components/UserNewAvatar.vue';
 import { linkToHome } from '@/utils/external-links';
 
-
+const props = defineProps({
+  subTitle: {
+    type: String,
+    default: ''
+  }
+})
 </script>
 <style scoped lang="scss">
 .home-header {
@@ -24,7 +30,6 @@ import { linkToHome } from '@/utils/external-links';
   justify-content: space-between;
   .left {
     height: 100%;
-    width: 280px;
     display: flex;
     justify-content: flex-start;
     align-items: center;
@@ -35,6 +40,24 @@ import { linkToHome } from '@/utils/external-links';
       background-size: 100% 100%;
       margin-right: 11px;
     }
+    >.sub_title {
+      color: #2089F0;
+      position: relative;
+      padding-left: 11px;
+      font-size: 22px;
+      font-weight: bolder;
+      &::before {
+        position: absolute;
+        left: 0px;
+        top: 3px;
+        bottom: 3px;
+        margin: auto;
+        content: "";
+        display: block;
+        background: #E5E6E6;
+        width: 1px;
+      }
+    }
   }
 
   .right {