Parcourir la source

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

2545307760@qq.com il y a 8 mois
Parent
commit
5170e6dfb6

+ 38 - 0
server/api/v1/admin/project.go

@@ -4,6 +4,7 @@ import (
 	"archive/zip"
 	"bytes"
 	"encoding/json"
+	"fmt"
 	"github.com/gin-gonic/gin"
 	"io"
 	"net/http"
@@ -189,6 +190,7 @@ func (pa *ProjectApi) CreateProject(c *gin.Context) {
 			ProjectCode: project.Code,
 			Name:        dst,
 			Path:        path,
+			Genre:       1,
 		}
 
 		project.Files = append(project.Files, projectFile)
@@ -243,6 +245,7 @@ func (pa *ProjectApi) CreateProjectFile(c *gin.Context) {
 			ProjectCode: code,
 			Name:        dst,
 			Path:        path,
+			Genre:       genreId,
 		}
 
 		// gin 简单做了封装,拷贝了文件流
@@ -445,6 +448,41 @@ func (pa *ProjectApi) DeleteProjectFile(c *gin.Context) {
 	response.OkWithMessage("删除成功", c)
 }
 
+func (pa *ProjectApi) DeleteProjectFiles(c *gin.Context) {
+	var info request.SearchProjectFileList
+	err := c.ShouldBindJSON(&info)
+	fmt.Println(info)
+	if err != nil {
+		response.FailWithMessage(err.Error(), c)
+		return
+	}
+	files, err := projectService.QueryFilesByNameOrGenre(info)
+	if err != nil {
+		response.FailWithMessage("错误", c)
+		global.GVA_LOG.Error("ProjectFilesDownload ====== " + err.Error())
+		return
+	}
+
+	fmt.Println(files)
+	for _, file := range files {
+		err = os.Remove(file.Path)
+		if err != nil {
+			// 如果发生错误,打印错误信息
+			response.FailWithMessage("删除文件时发生错误", c)
+			global.GVA_LOG.Error("删除文件时发生错误: " + err.Error())
+			return
+		}
+
+		err = projectService.DeleteProjectFile(file.ID)
+		if err != nil {
+			response.FailWithMessage(err.Error(), c)
+			return
+		}
+	}
+
+	response.OkWithMessage("删除成功", c)
+}
+
 func (pa *ProjectApi) DeleteProjectState(c *gin.Context) {
 	var projectState dao.ProjectState
 	err := c.ShouldBindJSON(&projectState)

+ 1 - 0
server/router/admin/project.go

@@ -28,6 +28,7 @@ func (s *ProjectRouter) InitProjectRouter(Router *gin.RouterGroup) {
 
 		projectRouter.DELETE("deleteProject", projectApi.DeleteProject)
 		projectRouter.DELETE("deleteProjectFile", projectApi.DeleteProjectFile)
+		projectRouter.DELETE("deleteProjectFiles", projectApi.DeleteProjectFiles)
 		projectRouter.DELETE("deleteWorkingHours", projectApi.DeleteWorkingHours)
 		projectRouter.DELETE("deleteCollection", projectApi.DeleteCollection)
 		projectRouter.DELETE("deleteReimbursement", projectApi.DeleteReimbursement)

+ 11 - 2
web/src/api/file.js

@@ -51,9 +51,17 @@ export const createProjectFile = (data) => {
 // 删除项目文件
 export const deleteProjectFile = (data) => {
   return service({
-    url: '/project/deleteProjectFile',
+    url: '/project/deleteProjectFile?id=' + data.ID + '&path=' + data.path,
+    method: 'delete'
+  })
+}
+
+// 删除多个项目文件
+export const deleteProjectFiles = (data) => {
+  return service({
+    url: '/project/deleteProjectFiles',
     method: 'delete',
-    data: data
+    data
   })
 }
 
@@ -62,6 +70,7 @@ export const downloadProjectFile = (data) => {
   return service({
     url: '/project/projectFilesDownload',
     method: 'post',
+    responseType: 'blob',
     data: data
   })
 }

+ 1 - 1
web/src/view/dashboard/dashboardCharts/echartsLine.vue

@@ -128,7 +128,7 @@ onUnmounted(() => {
   .dashboard-line {
     background-color: #fff;
     height: 360px;
-    width: 100%;
+    width: 90%;
   }
   .dashboard-line-title {
     font-weight: 600;

+ 3 - 3
web/src/view/dashboard/index.vue

@@ -13,7 +13,7 @@
         >
       </div>
     </div>
-    
+
     <div class="gva-card-box">
       <div class="gva-card">
         <div class="gva-card-title">数据统计</div>
@@ -21,13 +21,13 @@
           <el-row :gutter="20">
             <el-col
               :xs="24"
-              :sm="18"
+              :sm="14"
             >
               <echarts-line />
             </el-col>
             <el-col
               :xs="24"
-              :sm="6"
+              :sm="10"
             >
               <dashboard-table />
             </el-col>

+ 151 - 32
web/src/view/projectManage/projectDetails/projectDetails.vue

@@ -136,8 +136,8 @@
               <el-select
                 v-model="fileType"
                 clearable
-                @change="changeFileType"
                 placeholder="文件类型"
+                @change="changeFileType"
               >
                 <el-option
                   v-for="item in editor.typeList"
@@ -164,6 +164,7 @@
               <el-button
                 type="primary"
                 :icon="RefreshLeft"
+                @click="resetData"
               >
                 重置
               </el-button>
@@ -171,27 +172,46 @@
             <el-col
               :span="3"
             >
-              <el-button
+              <el-dropdown
+                split-button
                 type="primary"
-                :icon="Upload"
-                @click="fileDialog = true"
               >
-                上传
-              </el-button>
-            </el-col>
-            <el-col
-              :span="3"
-            >
-              <el-button
-                type="primary"
-                :icon="Download"
-                @click="downloadTips"
-              >
-                下载
-              </el-button>
+                菜单
+                <template #dropdown>
+                  <el-dropdown-menu>
+                    <el-dropdown-item>
+                      <el-button
+                        type="primary"
+                        :icon="Upload"
+                        @click="fileDialog = true"
+                      >
+                        上传
+                      </el-button>
+                    </el-dropdown-item>
+                    <el-dropdown-item>
+                      <el-button
+                        type="primary"
+                        :icon="Download"
+                        @click="downloadTips"
+                      >
+                        下载
+                      </el-button>
+                    </el-dropdown-item>
+                    <el-dropdown-item>
+                      <el-button
+                        type="primary"
+                        :icon="Download"
+                        @click="projectDeletes"
+                      >
+                        删除
+                      </el-button>
+                    </el-dropdown-item>
+                  </el-dropdown-menu>
+                </template>
+              </el-dropdown>
             </el-col>
           </el-row>
-          <el-row style="margin-top: 20px" >
+          <el-row style="margin-top: 20px">
             <el-col :span="24">
               <el-table
                 :data="fileList"
@@ -223,7 +243,7 @@
                       type="primary"
                       :icon="Download"
                       size="large"
-                      @click="projectEdit(scope.$index, scope.row)"
+                      @click="oneDownload(scope.row)"
                     >
                       下载
                     </el-button>
@@ -232,7 +252,7 @@
                       type="primary"
                       :icon="Delete"
                       size="large"
-                      @click="projectDelete(scope.$index, scope.row)"
+                      @click="projectDelete(scope.row)"
                     >
                       删除
                     </el-button>
@@ -243,11 +263,11 @@
           </el-row>
           <el-row justify="end">
             <el-pagination
-                :page-size="10"
-                background
-                layout="prev, pager, next"
-                :total="fileTotal"
-                @change="changeFilePage"
+              :page-size="10"
+              background
+              layout="prev, pager, next"
+              :total="fileTotal"
+              @change="changeFilePage"
             />
           </el-row>
         </el-card>
@@ -424,11 +444,11 @@
       </template>
     </el-dialog>
     <el-dialog
-        v-model="stateTypeShow"
-        title="状态和类型编辑"
-        width="40%"
+      v-model="stateTypeShow"
+      title="状态和类型编辑"
+      width="40%"
     >
-      <option-edit/>
+      <option-edit />
     </el-dialog>
   </div>
 </template>
@@ -437,11 +457,12 @@
 import { getProjectMessage, editProject } from '@/api/project'
 import { onMounted, reactive, ref, computed } from 'vue'
 import { getAllUsers } from '@/api/user'
-import { queryFileList, createProjectFile, downloadProjectFile } from '@/api/file'
+import {queryFileList, createProjectFile, downloadProjectFile, deleteProjectFile, deleteProjectFiles} from '@/api/file'
 import { Download, Upload, Delete, Search, RefreshLeft, Edit } from '@element-plus/icons-vue'
 import { ElMessage, ElMessageBox } from 'element-plus'
 import OptionEdit from './components/optionEdit.vue'
 import { editorData } from '@/pinia/project/project'
+import { deleteDailyFile, fileDownload } from '@/api/dailyFile'
 
 defineOptions({
   name: 'ProjectDetails'
@@ -530,6 +551,18 @@ const projectMessage = (code) => {
   })
 }
 
+// 重置
+const resetData = () => {
+  fileCondition.code = 'LCZM202407161229'
+  fileCondition.name = ''
+  fileCondition.genre = 0
+  fileCondition.pageInfo = {
+    page: 1,
+    pageSize: 9
+  }
+  queryFile()
+}
+
 const changeFileType = (value) => {
   if (typeof value === 'number') {
     fileTypeList.forEach(item => {
@@ -656,14 +689,21 @@ const downloadTips = () => {
   )
     .then(() => {
       const type = fileType.value === '' ? 0 : fileType.value
-      console.log(type)
       const data = {
         code: 'LCZM202407161229',
         genre: type,
         name: fileCondition.name
       }
       downloadProjectFile(data).then(res => {
-        console.log(res.data)
+        console.log(res)
+        const link = document.createElement('a')
+        const href = window.URL.createObjectURL(res) // 创建下载的链接
+        link.href = href
+        link.download = 'LCZM202407161229.zip' // 下载后文件名
+        document.body.appendChild(link)
+        link.click() // 点击下载
+        document.body.removeChild(link) // 下载完成移除元素
+        window.URL.revokeObjectURL(href) // 释放掉blob对象
       })
     })
     .catch(() => {
@@ -673,6 +713,85 @@ const downloadTips = () => {
       })
     })
 }
+
+// 单文件下载
+const oneDownload = async(val) => {
+  console.log(val)
+  await fileDownload(val).then(res => {
+    console.log(res)
+    const link = document.createElement('a')
+    const href = window.URL.createObjectURL(res) // 创建下载的链接
+    link.href = href
+    link.download = val.name // 下载后文件名
+    document.body.appendChild(link)
+    link.click() // 点击下载
+    document.body.removeChild(link) // 下载完成移除元素
+    window.URL.revokeObjectURL(href) // 释放掉blob对象
+  })
+}
+
+// 单文件删除
+const projectDelete = async(val) => {
+  ElMessageBox.confirm(
+    '你确定进行删除操作吗?',
+    '删除',
+    {
+      confirmButtonText: '确定',
+      cancelButtonText: '取消',
+      type: 'warning',
+    }
+  )
+    .then(async() => {
+      await deleteProjectFile(val).then(res => {
+        if (res.code === 0) {
+          ElMessage.success('删除成功')
+        }
+      })
+      queryFile()
+    })
+    .catch(() => {
+      ElMessage({
+        type: 'info',
+        message: '取消删除',
+      })
+    })
+}
+
+// 多文件删除
+const projectDeletes = async() => {
+  ElMessageBox.confirm(
+    '你确定进行删除操作吗?',
+    '删除',
+    {
+      confirmButtonText: '确定',
+      cancelButtonText: '取消',
+      type: 'warning',
+    }
+  )
+    .then(async() => {
+      const type = fileType.value === '' ? 0 : fileType.value
+      const data = {
+        code: 'LCZM202407161229',
+        genre: type,
+        name: fileCondition.name
+      }
+      console.log(data)
+      await deleteProjectFiles(data).then(res => {
+        console.log(res)
+        if (res.code === 0) {
+          ElMessage.success('删除成功')
+        }
+      })
+      queryFile()
+    })
+    .catch(() => {
+      ElMessage({
+        type: 'info',
+        message: '取消删除',
+      })
+    })
+}
+
 // 日期格式化
 const formatDate = (dateString, locale = 'en-US', timezone = 'Asia/Shanghai') => {
   // 使用 Date 构造函数解析日期字符串