Kaynağa Gözat

Merge remote-tracking branch 'origin/feature' into feature

# Conflicts:
#	src/api/resource/index.js
#	src/views/resource/component/xtable.vue
scorpioyq 2 yıl önce
ebeveyn
işleme
539c239849

+ 7 - 0
src/api/resource/index.js

@@ -76,5 +76,12 @@ export default {
       'post',
       'json'
     )
+  },
+  /**
+   * 移动文件
+   * @param params
+   */
+  fileMove(params) {
+    return fetch('/blade-project-manage-v2/folder/v2/moveFile', params, 'post')
   }
 }

+ 18 - 14
src/components/file-way/index.vue

@@ -29,20 +29,24 @@ export default {
   watch: {
     next: {
       handler(val) {
-        const item = {
-          id: val.id,
-          title: val.title,
-          projectId: val.projectId,
-          stageId: val.stageId,
-          parentId: val.parentId,
-          type: val.type
-        }
-        const tmp = this.list.find(ele => ele.id === item.id)
-        if (tmp === undefined || tmp === null) {
-          console.log(item.type)
-          if (item.type === 2) {
-            this.data = item
-            this.list.push(item)
+        console.log(val)
+        if (Object.hasOwn(val, 'projectId')) {
+          const item = {
+            id: val.id,
+            title: val.title,
+            projectId: val.projectId,
+            stageId: val.stageId,
+            parentId: val.parentId,
+            type: val.type,
+            isAccess: val.isAccess
+          }
+          const tmp = this.list.find(ele => ele.id === item.id)
+          if (tmp === undefined || tmp === null) {
+            console.log(item.type)
+            if (item.type === 2) {
+              this.data = item
+              this.list.push(item)
+            }
           }
         }
       },

+ 2 - 2
src/components/filepicker/index.vue

@@ -85,7 +85,7 @@
                 :data="list"
                 :option="option"
                 :loading="loading"
-                :total="page.total"
+                :page="page"
                 :max="max"
                 @selected="selected"
                 @row-click="rowClick"
@@ -348,7 +348,7 @@ export default {
 
 <style lang="scss" scoped>
 .area {
-  height: 630px;
+  height: 680px;
   width: 88%;
 }
 

+ 33 - 9
src/views/resource/component/floder.vue

@@ -7,6 +7,7 @@
       prefix-icon="EditPen"
     />
     <div class="mt-20 flex flex-justify-end full-width">
+      {{ rename }}
       <el-button type="primary" @click="folderAdd">确 定</el-button>
     </div>
   </div>
@@ -18,6 +19,20 @@ export default {
     info: {
       type: Object,
       default: null
+    },
+    rename: {
+      type: Boolean,
+      default: false
+    }
+  },
+  watch: {
+    rename: {
+      handler(val) {
+        if (val) {
+          this.title = this.info.title
+        }
+      },
+      immediate: true
     }
   },
   data() {
@@ -37,18 +52,27 @@ export default {
         title: this.title,
         parentId: this.info.id
       }
-      if (this.info.stageId === '') {
+      const renameData = {
+        id: this.info.id,
+        title: this.title,
+        projectId: this.info.projectId,
+        stageId: this.info.stageId
+      }
+      if (this.info.stageId === '' && this.rename === false) {
         this.$message.error('请先选择相关项目阶段!')
         this.$emit('close')
       }
-      this.$api.resource.folderAddUpdate(data).then(res => {
-        if (res.code === 200) {
-          this.$message.success(res.msg)
-          this.$emit('close')
-        } else {
-          this.$message.error(res.msg)
-        }
-      })
+      this.$api.resource
+        .folderAddUpdate(this.rename ? renameData : data)
+        .then(res => {
+          if (res.code === 200) {
+            this.$message.success(res.msg)
+            this.title = ''
+            this.$emit('close')
+          } else {
+            this.$message.error(res.msg)
+          }
+        })
     }
   }
 }

+ 224 - 7
src/views/resource/component/move.vue

@@ -1,23 +1,226 @@
 <template>
   <div>
     <el-button type="primary" text @click="show = true">移动</el-button>
-    <el-dialog v-model="show" width="800">
-      <div class="full-width content">
-        <div v-for="i in 20" class="padding light-green-bg mb-5">333</div>
+    <el-dialog v-model="show" width="800" :show-close="false">
+      <template #header>
+        <div class="full-width flex flex-center flex-justify-between">
+          <h4>移动文件</h4>
+          <div class="flex flex-center flex-justify-end">
+            <div class="flex flex-center">
+              <span class="mr-10">项目阶段:</span>
+              <el-select
+                v-model="stageId"
+                remote
+                filterable
+                clearable
+                placeholder="筛选项目阶段"
+                style="width: 200px"
+              >
+                <el-option
+                  v-for="item in stageList"
+                  :key="item.id"
+                  :label="item.name"
+                  :value="item.id"
+                >
+                </el-option>
+              </el-select>
+            </div>
+            <el-button
+              type="info"
+              class="ml-10"
+              circle
+              icon="Close"
+              @click="show = false"
+            >
+            </el-button>
+          </div>
+        </div>
+      </template>
+      <div>
+        <file-way
+          class="mb-10"
+          :next="currentFolder"
+          @before="goBefore"
+          @goHome="getFolderList"
+        />
+        <div class="mt-20 border-top flex flex-center flex-col">
+          <div
+            v-if="data.length === 0"
+            class="flex flex-center content flex-col full-height"
+          >
+            <el-empty
+              :description="loading ? '加载中...' : '暂无数据'"
+            ></el-empty>
+          </div>
+          <div v-else class="full-width content border-top">
+            <div
+              v-for="i in data"
+              class="padding light-green-bg row"
+              :key="i.id"
+              @click="getFileList(i)"
+            >
+              <div class="flex flex-center flex-justify-start">
+                <img
+                  v-if="i.isAccess === 1"
+                  src="../../../assets/svg/folder/see.svg"
+                />
+                <img
+                  v-if="i.isAccess === 2"
+                  src="../../../assets/svg/folder/edit.svg"
+                />
+                <img
+                  v-if="i.isAccess === 3"
+                  src="../../../assets/svg/folder/invisible.svg"
+                />
+                {{ i.title }}
+              </div>
+            </div>
+          </div>
+        </div>
       </div>
       <div class="full-width flex flex-justify-end flex-center mt-20">
-        <el-button type="primary" plain>取 消</el-button>
-        <el-button type="primary">移动到此</el-button>
+        <el-button type="primary" plain @click="show = false">取 消</el-button>
+        <el-button type="primary" @click="move">移动到此</el-button>
       </div>
     </el-dialog>
   </div>
 </template>
 
 <script>
+import fileWay from '@/components/file-way/index.vue'
+
 export default {
+  components: {
+    fileWay
+  },
+  props: {
+    projectId: {
+      required: true,
+      type: String,
+      default: ''
+    },
+    fileId: {
+      required: true,
+      type: String,
+      default: ''
+    }
+  },
+  watch: {
+    show: {
+      handler(val) {
+        if (val) {
+          this.getStage()
+        }
+      },
+      immediate: true
+    }
+  },
   data() {
     return {
-      show: false
+      loading: false,
+      show: false,
+      currentFolder: null,
+      stageId: '',
+      topFolder: true,
+      data: [],
+      stageList: [],
+      page: {
+        current: 1,
+        size: 10
+      }
+    }
+  },
+  methods: {
+    /**
+     * 获取项目阶段
+     */
+    getStage() {
+      this.$api.project
+        .includeStage({ projectId: this.projectId })
+        .then(res => {
+          if (res.code === 200) {
+            this.stageList = res.data
+            const tmp = this.stageList.find(ele => ele.isLastSelect === 1)
+            if (tmp) {
+              this.stageId = tmp.id
+            } else {
+              this.stageId = this.stageList[0].id
+            }
+            this.getFolderList()
+          }
+        })
+    },
+    /**
+     * 获取阶段对应的一级文件夹
+     */
+    getFolderList() {
+      this.loading = true
+      this.topFolder = true
+      const data = {
+        stageId: this.stageId,
+        dictKey: 1,
+        current: this.page.current,
+        size: this.page.size
+      }
+      this.data.length = 0
+      this.loading = true
+      this.top = true
+      this.$api.resource.folderList(data).then(res => {
+        this.loading = false
+        this.loading = false
+        if (res.code === 200) {
+          this.data = res.data.records
+          this.page.total = res.data.total
+        }
+      })
+    },
+    /**
+     * 获取文件夹下面的文件及文件夹
+     * @param row
+     */
+    getFileList(row) {
+      if (row.isAccess !== 2) {
+        this.$message.error('您暂无权限访问此文件夹,如需访问请主动申请授权')
+        return
+      }
+      this.loading = true
+      this.topFolder = false
+      this.currentFolder = row
+      const item = {
+        id: row.id,
+        current: this.page.current,
+        size: this.page.size,
+        type: 2
+      }
+      this.loading = true
+      this.data.length = 0
+      this.$api.resource.fileList(item).then(res => {
+        this.loading = false
+        if (res.code === 200) {
+          this.data = res.data.records
+          this.page.total = res.data.total
+        } else {
+          this.$message.error(res.msg)
+        }
+      })
+    },
+    goBefore(res) {
+      if (!this.topFolder) {
+        this.getFileList(res)
+      } else {
+        this.getFolderList()
+      }
+    },
+    move() {
+      this.$api.resource
+        .fileMove({ fileId: this.fileId, folderId: this.currentFolder.id })
+        .then(res => {
+          if (res.code === 200) {
+            this.$message.success(res.msg)
+            this.show = false
+            this.$emit('on-success')
+          }
+        })
     }
   }
 }
@@ -27,6 +230,20 @@ export default {
 .content {
   height: 500px;
   overflow-y: scroll;
-  background-color: red;
+}
+
+.row {
+  border-bottom: #eeeeee solid 1px;
+  background-color: white;
+
+  img {
+    width: 30px;
+    height: auto;
+    margin-right: 10px;
+  }
+}
+
+.row:hover {
+  background-color: #f7f9fc;
 }
 </style>

+ 35 - 6
src/views/resource/component/row1.vue

@@ -2,7 +2,7 @@
   <div class="row full-width">
     <div
       v-if="index === 0"
-      class="flex flex-align-center flex-justify-start full-height padding-left"
+      class="flex flex-align-center flex-justify-start full-height padding-left cell"
     >
       <el-checkbox
         v-if="showCheckBox"
@@ -11,11 +11,35 @@
         class="padding-right"
         @change="rowChecked(row)"
       />
-      <img
-        v-if="info.type === 2"
-        src="../../../assets/svg/folder/invisible.svg"
-      />
-      <img v-else src="../../../assets/svg/folder/pdf.svg" />
+      <div v-if="info.type === 2">
+        <img
+          v-if="info.isAccess === 1"
+          src="../../../assets/svg/folder/see.svg"
+        />
+        <img
+          v-if="info.isAccess === 2"
+          src="../../../assets/svg/folder/edit.svg"
+        />
+        <img
+          v-if="info.isAccess === 3"
+          src="../../../assets/svg/folder/invisible.svg"
+        />
+      </div>
+      <div v-else>
+        <img
+          v-if="info.suffix === 'pdf'"
+          src="../../../assets/svg/folder/pdf.svg"
+        />
+        <img
+          v-else-if="info.suffix === 'doc'"
+          src="../../../assets/svg/folder/doc.svg"
+        />
+        <img
+          v-else-if="info.suffix === 'xls'"
+          src="../../../assets/svg/folder/xls.svg"
+        />
+        <img v-else src="../../../assets/svg/folder/other.svg" />
+      </div>
       {{ info[column.prop] }}
     </div>
     <div
@@ -72,6 +96,11 @@ export default {
 .row {
   height: 55px;
   border-bottom: #f7f8fa solid 1px;
+  .cell {
+    width: 100%;
+    word-break: break-word;
+    text-align: left;
+  }
   img {
     width: 40px;
     height: auto;

+ 23 - 13
src/views/resource/component/xtable.vue

@@ -35,13 +35,15 @@
               class="nowrap menu flex flex-center"
               style="width: 280px"
             >
-              <el-button type="primary" size="small" text>查看</el-button>
-              <el-button v-if="row.type === 2" type="primary" size="small" text
-                >重命名
-              </el-button>
-              <archives v-if="row.type === 2" :folderId="row.id" />
-              <move v-if="row.type === 1" />
-              <slot name="menu"></slot>
+              <el-button type="primary" text>查看</el-button>
+              <archives v-if="row.type === 2" />
+              <move
+                v-if="row.type === 1"
+                :project-id="row.projectId"
+                :file-id="row.id"
+                @on-success="refresh"
+              />
+              <slot name="menu" :row="row"></slot>
             </div>
             <div
               v-else
@@ -62,9 +64,10 @@
         </div>
         <div class="full-width flex flex-center flex-justify-end">
           <el-pagination
-            layout="prev, pager, next"
-            class="mt-10 bottom"
-            :total="total"
+            layout="total, prev, pager, next"
+            class="mt-10"
+            v-model:current-page="page.current"
+            :total="page.total"
             @current-change="currentChange"
           />
         </div>
@@ -89,9 +92,13 @@ export default {
     archives
   },
   props: {
-    total: {
-      type: Number,
-      default: 0
+    page: {
+      type: Object,
+      default: {
+        current: 1,
+        size: 10,
+        total: 0
+      }
     },
     data: {
       type: Array,
@@ -145,6 +152,9 @@ export default {
     currentChange(current) {
       this.$emit('current-change', current)
     },
+    refresh() {
+      this.$emit('refresh')
+    },
     rowClick(row) {
       if (this.selectedList.length === this.max) {
         this.$message.error('可选择文件数量最大为' + this.max)

+ 66 - 28
src/views/resource/index.vue

@@ -8,9 +8,10 @@
             v-model="folderInfo.stageId"
             remote
             filterable
+            style="width: 200px"
             clearable
             placeholder="筛选项目阶段"
-            style="width: 100%"
+            :disabled="!top"
             @change="folderResult"
           >
             <el-option
@@ -60,27 +61,44 @@
             />
           </div>
         </div>
-        <el-breadcrumb separator-icon="ArrowRight" class="mt-20 main-color">
-          <el-breadcrumb-item>
-            <div class="pointer" @click="getFolderList">全部文件</div>
-          </el-breadcrumb-item>
-        </el-breadcrumb>
+        <file-way
+          :next="currentFolder"
+          @before="goBefore"
+          @goHome="getFolderList"
+          class="mt-20"
+        />
         <xtable
           :data="data"
-          :option="top ? option : option2"
+          :option="option"
           :loading="loading"
-          :total="page.total"
+          :page="page"
           @row-click="getFileList"
           @current-change="currentChange"
+          @refresh="refreshData"
         >
+          <template #menu="{ row }">
+            <el-button
+              v-if="row.type === 2"
+              type="primary"
+              text
+              @click="renameFolder(row)"
+              >重命名
+            </el-button>
+          </template>
         </xtable>
       </div>
     </el-card>
 
-    <el-dialog v-model="show" :title="title" :width="width">
+    <el-dialog
+      v-model="show"
+      :title="title"
+      :width="width"
+      @close="closeDialog"
+    >
       <floder
         v-if="showType === 1"
         :info="folderInfo"
+        :rename="rename"
         @close="closeDialog"
       ></floder>
     </el-dialog>
@@ -100,6 +118,7 @@ import xtable from '@/views/resource/component/xtable.vue'
 import floder from '@/views/resource/component/floder.vue'
 import uploadFile from '@/components/upload-file/index.vue'
 import filepicker from '@/components/filepicker/index.vue'
+import fileWay from '@/components/file-way/index.vue'
 
 export default {
   components: {
@@ -107,7 +126,8 @@ export default {
     xtable,
     floder,
     uploadFile,
-    filepicker
+    filepicker,
+    fileWay
   },
 
   data() {
@@ -116,6 +136,7 @@ export default {
       showType: 1,
       width: 380,
       title: '新建文件夹',
+      rename: false,
       top: true,
       loading: false,
       currentFolder: null,
@@ -129,20 +150,12 @@ export default {
             width: 270
           },
           {
-            label: '所属阶段',
-            prop: 'stageName'
+            label: '上传人',
+            prop: 'createUserName'
           },
           {
-            label: '创建时间',
+            label: '上传时间',
             prop: 'createTime'
-          },
-          {
-            label: '归档位置',
-            prop: 'roleName'
-          },
-          {
-            label: '创建人',
-            prop: 'createUserName'
           }
         ]
       },
@@ -180,11 +193,12 @@ export default {
     showDialog(type) {
       this.showType = type
       this.show = true
+      this.title = '新建文件夹'
     },
     folderAdd() {
       this.$api.resource.folderAddUpdate().then(res => {
         if (res.code === 200) {
-          console.log(res)
+          this.refreshData()
         }
       })
     },
@@ -193,9 +207,12 @@ export default {
       if (this.top) {
         this.getFolderList()
       } else {
-        this.getFileList()
+        this.getFileList(this.currentFolder)
       }
     },
+    /**
+     * 获取阶段对应的一级文件夹
+     */
     getFolderList() {
       const data = {
         stageId: this.folderInfo.stageId,
@@ -210,13 +227,18 @@ export default {
         if (res.code === 200) {
           this.data = res.data.records
           this.page.total = res.data.total
-          this.total = res.data.total
         }
       })
     },
+    /**
+     * 获取二级文件
+     * @param row
+     */
     getFileList(row) {
+      this.data.length = 0
+      this.currentFolder = row
       this.folderInfo = Object.assign(this.folderInfo, row)
-      this.top = !this.top
+      this.top = false
       const data = {
         id: row.id,
         current: this.page.current,
@@ -227,6 +249,7 @@ export default {
         this.loading = false
         if (res.code === 200) {
           this.data = res.data.records
+          this.page.total = res.data.total
         } else {
           this.$message.error(res.msg)
         }
@@ -257,19 +280,34 @@ export default {
       this.stageId = res
       this.getFolderList()
     },
+    /**
+     * 文件上传成功侯刷新文件列表,上传文件的按钮,不出现在顶级目录,所以刷新下级就行
+     * @param files
+     */
     uploadSuccess(files) {
-      console.log('refresh')
+      this.getFileList(this.currentFolder)
     },
     refreshData() {
       if (this.top) {
         this.getFolderList()
       } else {
-        this.getFileList()
+        this.getFileList(this.currentFolder)
       }
     },
     currentChange(current) {
       this.page.current = current
       this.refreshData()
+    },
+    goBefore(res) {
+      this.currentFolder = res
+      this.refreshData()
+    },
+    renameFolder(res) {
+      this.rename = true
+      this.title = '重命名文件夹'
+      this.show = true
+      this.showType = 1
+      this.folderInfo = res
     }
   }
 }
@@ -277,6 +315,6 @@ export default {
 
 <style lang="scss" scoped>
 .content {
-  height: calc(100vh - 180px);
+  height: auth;
 }
 </style>