瀏覽代碼

收款 项目 修改

xu 7 月之前
父節點
當前提交
304cb49949

+ 74 - 0
server/api/v1/admin/file.go

@@ -8,6 +8,7 @@ import (
 	"server/dao"
 	"server/global"
 	"server/model/common/response"
+	"strconv"
 	"strings"
 )
 
@@ -40,6 +41,45 @@ func (fa *FileApi) CreateFileGenre(c *gin.Context) {
 	response.OkWithMessage("新增成功", c)
 }
 
+func (fa *FileApi) QueryNecessaryDocuments(c *gin.Context) {
+	necessaryDocument, err := fileService.QueryNecessaryDocuments()
+	if err != nil {
+		response.FailWithMessage("失败", c)
+		global.GVA_LOG.Error("QueryNecessaryDocument ======= " + err.Error())
+		return
+	}
+	response.OkWithData(necessaryDocument, c)
+}
+
+func (fa *FileApi) QueryNecessaryDocumentByGenreId(c *gin.Context) {
+	genreId := c.Query("genre_id")
+	id, _ := strconv.Atoi(genreId)
+	necessaryDocument, err := fileService.QueryNecessaryDocumentByGenreId(id)
+	if err != nil {
+		response.FailWithMessage("失败", c)
+		global.GVA_LOG.Error("QueryNecessaryDocumentByGenreId ======= " + err.Error())
+		return
+	}
+	response.OkWithData(necessaryDocument, c)
+}
+
+func (fa *FileApi) CreateNecessaryDocument(c *gin.Context) {
+	var necessaryDocument dao.NecessaryDocument
+	err := c.ShouldBindJSON(&necessaryDocument)
+	if err != nil {
+		response.FailWithMessage("失败", c)
+		global.GVA_LOG.Error("CreateNecessaryDocument ====== " + err.Error())
+		return
+	}
+	err = fileService.CreateNecessaryDocument(necessaryDocument)
+	if err != nil {
+		response.FailWithMessage("失败", c)
+		global.GVA_LOG.Error("CreateNecessaryDocument ====== " + err.Error())
+		return
+	}
+	response.OkWithMessage("新增成功", c)
+}
+
 func (fa *FileApi) UpdateFileGenre(c *gin.Context) {
 	var fileGenre dao.FileGenre
 	err := c.ShouldBindJSON(&fileGenre)
@@ -57,6 +97,23 @@ func (fa *FileApi) UpdateFileGenre(c *gin.Context) {
 	response.OkWithMessage("修改成功", c)
 }
 
+func (fa *FileApi) UpdateNecessaryDocument(c *gin.Context) {
+	var necessaryDocument dao.NecessaryDocument
+	err := c.ShouldBindJSON(&necessaryDocument)
+	if err != nil {
+		response.FailWithMessage("失败", c)
+		global.GVA_LOG.Error("UpdateNecessaryDocument ====== " + err.Error())
+		return
+	}
+	err = fileService.UpdateNecessaryDocument(necessaryDocument)
+	if err != nil {
+		response.FailWithMessage("失败", c)
+		global.GVA_LOG.Error("UpdateNecessaryDocument ====== " + err.Error())
+		return
+	}
+	response.OkWithMessage("修改成功", c)
+}
+
 func (fa *FileApi) DeleteFileGenre(c *gin.Context) {
 	var fileGenre dao.FileGenre
 	err := c.ShouldBindJSON(&fileGenre)
@@ -74,6 +131,23 @@ func (fa *FileApi) DeleteFileGenre(c *gin.Context) {
 	response.OkWithMessage("删除成功", c)
 }
 
+func (fa *FileApi) DeleteNecessaryDocument(c *gin.Context) {
+	var necessaryDocument dao.NecessaryDocument
+	err := c.ShouldBindJSON(&necessaryDocument)
+	if err != nil {
+		response.FailWithMessage("失败", c)
+		global.GVA_LOG.Error("DeleteNecessaryDocument ====== " + err.Error())
+		return
+	}
+	err = fileService.DeleteNecessaryDocument(necessaryDocument)
+	if err != nil {
+		response.FailWithMessage("失败", c)
+		global.GVA_LOG.Error("DeleteNecessaryDocument ====== " + err.Error())
+		return
+	}
+	response.OkWithMessage("删除成功", c)
+}
+
 func (fa *FileApi) FileDownload(c *gin.Context) {
 	path := c.Query("path")
 	name := c.Query("name")

+ 7 - 2
server/api/v1/admin/project.go

@@ -6,6 +6,7 @@ import (
 	"encoding/json"
 	"fmt"
 	"github.com/gin-gonic/gin"
+	"github.com/google/uuid"
 	"io"
 	"net/http"
 	"os"
@@ -251,10 +252,12 @@ func (pa *ProjectApi) CreateProject(c *gin.Context) {
 	}
 	for _, file := range files {
 		dst := file.Filename
-		var path = "./uploads/file/" + project.Code + "/立项" + "/" + dst
+		newdst := uuid.New().String() + filepath.Ext(file.Filename)
+		var path = "./uploads/file/项目/" + project.Code + "/项目前期文件" + "/" + newdst
 		projectFile := dao.ProjectFile{
 			ProjectCode: project.Code,
 			Name:        dst,
+			Key:         newdst,
 			Path:        path,
 			Genre:       1,
 		}
@@ -306,11 +309,13 @@ func (pa *ProjectApi) CreateProjectFile(c *gin.Context) {
 	}
 	for _, file := range files {
 		dst := file.Filename
-		var path = "./uploads/file/" + code + "/" + fileGenre.Name + "/" + dst
+		newdst := uuid.New().String() + filepath.Ext(file.Filename)
+		var path = "./uploads/file/项目/" + code + "/" + fileGenre.Name + "/" + newdst
 		projectFile := dao.ProjectFile{
 			ProjectCode: code,
 			Name:        dst,
 			Path:        path,
+			Key:         newdst,
 			Genre:       genreId,
 		}
 

+ 1 - 0
server/dao/collection.go

@@ -11,6 +11,7 @@ type Collection struct {
 	CollectionPrice decimal.Decimal `json:"collectionPrice" from:"collectionPrice" gorm:"type:decimal(10,2);not null;comment:收款金额"`
 	Remarks         string          `json:"remarks" from:"remarks" gorm:"comment:备注"`
 	CollectionTime  string          `json:"collectionTime" from:"collectionTime" gorm:"comment:收款日期;type:datetime"`
+	SerialNumber    string          `json:"serialNumber" from:"serialNumber" gorm:"comment:银行流水单号"`
 }
 
 func (Collection) TableName() string {

+ 3 - 2
server/dao/fileGenre.go

@@ -6,8 +6,9 @@ import (
 
 type FileGenre struct {
 	global.GVA_MODEL
-	Name    string `json:"name" form:"name" gorm:"comment:文件类型名称"`
-	Remarks string `json:"remarks" form:"remarks" gorm:"comment:备注"`
+	Name              string              `json:"name" form:"name" gorm:"comment:文件类型名称"`
+	Remarks           string              `json:"remarks" form:"remarks" gorm:"comment:备注"`
+	NecessaryDocument []NecessaryDocument `json:"necessaryDocument" form:"necessaryDocument" gorm:"-"`
 }
 
 func (FileGenre) TableName() string {

+ 38 - 0
server/dao/necessaryDocument.go

@@ -0,0 +1,38 @@
+package dao
+
+import "server/global"
+
+type NecessaryDocument struct {
+	global.GVA_MODEL
+	FileGenreId int    `json:"fileGenreId" form:"fileGenreId" gorm:"comment:所属文件类型"`
+	Name        string `json:"name" form:"name" gorm:"comment:必要文件名"`
+}
+
+func (NecessaryDocument) TableName() string {
+	return "necessary_document"
+}
+
+func QueryNecessaryDocuments() (necessaryDocuments []NecessaryDocument, err error) {
+	err = global.GVA_DB.Find(&necessaryDocuments).Error
+	return necessaryDocuments, err
+}
+
+func QueryNecessaryDocumentByGenreId(id int) (necessaryDocuments []NecessaryDocument, err error) {
+	err = global.GVA_DB.Model(&NecessaryDocument{}).Where("file_genre_id =?", id).Find(&necessaryDocuments).Error
+	return necessaryDocuments, err
+}
+
+func (n NecessaryDocument) CreateNecessaryDocument() error {
+	err := global.GVA_DB.Create(&n).Error
+	return err
+}
+
+func (n NecessaryDocument) UpdateNecessaryDocument() error {
+	err := global.GVA_DB.Save(&n).Error
+	return err
+}
+
+func (n NecessaryDocument) DeleteNecessaryDocument() error {
+	err := global.GVA_DB.Unscoped().Delete(&n).Error
+	return err
+}

+ 25 - 19
server/dao/project.go

@@ -1,31 +1,37 @@
 package dao
 
 import (
-	"github.com/shopspring/decimal"
 	"gorm.io/gorm"
 	"server/global"
 )
 
 type Project struct {
 	global.GVA_MODEL
-	Code               string                `json:"code" form:"code" gorm:"comment:项目编号"`
-	Name               string                `json:"name" form:"name" gorm:"comment:项目名称"`
-	Principal          string                `json:"principal" form:"principal" gorm:"comment:负责人"`
-	Price              decimal.Decimal       `json:"price" form:"price" gorm:"type:decimal(10,2);not null"`
-	Level              int                   `json:"level" form:"level" gorm:"级别"`
-	Customer           string                `json:"customer" form:"customer" gorm:"相关客户"`
-	Illustrate         string                `json:"illustrate" form:"illustrate" gorm:"comment:说明;type:varchar(200)"`
-	State              int                   `json:"state" form:"state" gorm:"comment:状态"`
-	ProjectState       ProjectState          `json:"projectState" form:"projectState" gorm:"foreignKey:State;references:id;"`
-	CollectionTime     string                `json:"collectionTime" form:"collectionTime" gorm:"comment:收款时间"`
-	EndTime            string                `json:"endTime" form:"endTime" gorm:"comment:结束时间"`
-	Files              []ProjectFile         `json:"files" form:"files" gorm:"-"`
-	WorkingHours       []ProjectWorkingHours `json:"workingHours" form:"workingHours" gorm:"-"`
-	WorkingHoursTotal  int64                 `json:"workingHoursTotal" form:"workingHoursTotal" gorm:"-"`
-	Collection         []Collection          `json:"collection" form:"collection" gorm:"-"`
-	CollectionTotal    int64                 `json:"collectionTotal" form:"collectionTotal" gorm:"-"`
-	Reimbursement      []Reimbursement       `json:"reimbursement" form:"reimbursement" gorm:"-"`
-	ReimbursementTotal int64                 `json:"reimbursementTotal" form:"reimbursementTotal" gorm:"-"`
+	Code                 string                `json:"code" form:"code" gorm:"comment:项目编号"`
+	Name                 string                `json:"name" form:"name" gorm:"comment:项目名称"`
+	Address              string                `json:"address" form:"address" gorm:"comment:项目地址"`
+	FirstPrincipal       string                `json:"firstPrincipal" form:"firstPrincipal" gorm:"comment:甲方负责人"`
+	FirstPhone           string                `json:"firstPhone" form:"firstPhone" gorm:"comment:甲方电话"`
+	ProjectPrice         float64               `json:"projectPrice" form:"projectPrice" gorm:"type:decimal(10,2);comment:合同金额"`
+	SecondPrincipal      string                `json:"secondPrincipal" form:"secondPrincipal" gorm:"comment:乙方负责人"`
+	SignTime             string                `json:"signTime" form:"signTime" gorm:"comment:合同签订日期"`
+	IntoConstructionTime string                `json:"intoConstructionTime" form:"intoConstructionTime" gorm:"comment:进场施工时间"`
+	CompletedTime        string                `json:"completedTime" form:"completedTime" gorm:"comment:竣工时间"`
+	SupervisorUint       string                `json:"supervisorUint" form:"supervisorUint" gorm:"comment:监理单位"`
+	SupervisorName       string                `json:"supervisorName" form:"supervisorName" gorm:"comment:监理姓名"`
+	SupervisorPhone      string                `json:"supervisorPhone" form:"supervisorPhone" gorm:"comment:监理电话"`
+	Illustrate           string                `json:"illustrate" form:"illustrate" gorm:"comment:说明;type:varchar(200)"`
+	State                int                   `json:"state" form:"state" gorm:"comment:状态"`
+	ProjectState         ProjectState          `json:"projectState" form:"projectState" gorm:"foreignKey:State;references:id;"`
+	CollectionTime       string                `json:"collectionTime" form:"collectionTime" gorm:"comment:收款时间"`
+	EndTime              string                `json:"endTime" form:"endTime" gorm:"comment:结束时间"`
+	Files                []ProjectFile         `json:"files" form:"files" gorm:"-"`
+	WorkingHours         []ProjectWorkingHours `json:"workingHours" form:"workingHours" gorm:"-"`
+	WorkingHoursTotal    int64                 `json:"workingHoursTotal" form:"workingHoursTotal" gorm:"-"`
+	Collection           []Collection          `json:"collection" form:"collection" gorm:"-"`
+	CollectionTotal      int64                 `json:"collectionTotal" form:"collectionTotal" gorm:"-"`
+	Reimbursement        []Reimbursement       `json:"reimbursement" form:"reimbursement" gorm:"-"`
+	ReimbursementTotal   int64                 `json:"reimbursementTotal" form:"reimbursementTotal" gorm:"-"`
 }
 
 func (Project) TableName() string {

+ 1 - 0
server/dao/projectFile.go

@@ -8,6 +8,7 @@ type ProjectFile struct {
 	global.GVA_MODEL
 	ProjectCode string    `json:"projectCode" from:"projectCode" gorm:"comment:项目编号"`
 	Name        string    `json:"name" from:"name" gorm:"comment:文件名称"`
+	Key         string    `json:"key" from:"key" gorm:"comment:key"`
 	Genre       int       `json:"genre" form:"genre" gorm:"comment:项目类型"`
 	FileGenre   FileGenre `json:"fileGenre" form:"fileGenre" gorm:"foreignKey:genre;references:id;"`
 	Path        string    `json:"path" from:"path" gorm:"comment:路径"`

+ 1 - 0
server/initialize/gorm.go

@@ -51,6 +51,7 @@ func RegisterTables() {
 		dao.ProjectState{},
 		dao.ProjectFile{},
 		dao.FileGenre{},
+		dao.NecessaryDocument{},
 		dao.ProjectWorkingHours{},
 		dao.Collection{},
 		dao.Borrowing{},

+ 5 - 0
server/router/admin/file.go

@@ -14,11 +14,16 @@ func (s *ProjectRouter) InitFileRouter(Router *gin.RouterGroup) {
 	fileApi := v1.ApiGroupApp.AdminApiGroup.FileApi
 	{
 		fileRouter.POST("createFileGenre", fileApi.CreateFileGenre)
+		fileRouter.POST("createNecessaryDocument", fileApi.CreateNecessaryDocument)
 		fileRouter.PUT("updateFileGenre", fileApi.UpdateFileGenre)
+		fileRouter.PUT("updateNecessaryDocument", fileApi.UpdateNecessaryDocument)
 		fileRouter.DELETE("deleteFileGenre", fileApi.DeleteFileGenre)
+		fileRouter.DELETE("deleteNecessaryDocument", fileApi.DeleteNecessaryDocument)
 	}
 	{
 		fileRouterWithoutRecord.GET("queryFileGenre", fileApi.QueryFileGenre)
+		fileRouterWithoutRecord.GET("queryNecessaryDocuments", fileApi.QueryNecessaryDocuments)
+		fileRouterWithoutRecord.GET("queryNecessaryDocumentByGenreId", fileApi.QueryNecessaryDocumentByGenreId)
 		fileRouterWithoutRecord.GET("fileDownload", fileApi.FileDownload)
 	}
 }

+ 32 - 1
server/service/admin/file.go

@@ -5,22 +5,53 @@ import "server/dao"
 type FileService struct{}
 
 func (fs *FileService) QueryFileGenre() ([]dao.FileGenre, error) {
-	return dao.QueryFileGenre()
+	genres, err := dao.QueryFileGenre()
+	if err != nil {
+		return nil, err
+	}
+	for i, genre := range genres {
+		documents, err := dao.QueryNecessaryDocumentByGenreId(int(genre.ID))
+		if err != nil {
+			return nil, err
+		}
+		genres[i].NecessaryDocument = documents
+	}
+	return genres, err
 }
 
 func (fs *FileService) QueryFileGenreById(id int) (dao.FileGenre, error) {
 	return dao.QueryFileGenreById(id)
 }
 
+func (fs *FileService) QueryNecessaryDocuments() ([]dao.NecessaryDocument, error) {
+	return dao.QueryNecessaryDocuments()
+}
+
+func (fs *FileService) QueryNecessaryDocumentByGenreId(id int) ([]dao.NecessaryDocument, error) {
+	return dao.QueryNecessaryDocumentByGenreId(id)
+}
+
 func (fs *FileService) CreateFileGenre(fileGenre dao.FileGenre) error {
 	return fileGenre.CreateFileGenre()
 }
 
+func (fs *FileService) CreateNecessaryDocument(document dao.NecessaryDocument) error {
+	return document.CreateNecessaryDocument()
+}
+
 func (fs *FileService) UpdateFileGenre(fileGenre dao.FileGenre) error {
 	return fileGenre.UpdateFileGenre()
 }
 
+func (fs *FileService) UpdateNecessaryDocument(document dao.NecessaryDocument) error {
+	return document.UpdateNecessaryDocument()
+}
+
 func (fs *FileService) DeleteFileGenre(fileGenre dao.FileGenre) error {
 
 	return fileGenre.DeleteFileGenre()
 }
+
+func (fs *FileService) DeleteNecessaryDocument(document dao.NecessaryDocument) error {
+	return document.DeleteNecessaryDocument()
+}

+ 2 - 3
server/service/admin/project.go

@@ -2,7 +2,6 @@ package admin
 
 import (
 	"fmt"
-	"github.com/shopspring/decimal"
 	"server/dao"
 	"server/model/common/request"
 	"time"
@@ -54,7 +53,7 @@ func (ps *ProjectService) QueryAllProject() ([]dao.Project, error) {
 	return dao.QueryAllProject()
 }
 
-func (ps *ProjectService) QueryProjectsInfo() (sum decimal.Decimal, totalProject, completeProject, unCompleteProject int, err error) {
+func (ps *ProjectService) QueryProjectsInfo() (sum float64, totalProject, completeProject, unCompleteProject int, err error) {
 	projects, err := dao.QueryAllProject()
 	if err != nil {
 		return
@@ -64,7 +63,7 @@ func (ps *ProjectService) QueryProjectsInfo() (sum decimal.Decimal, totalProject
 		if project.State == 3 {
 			completeProject++
 		}
-		sum = sum.Add(project.Price)
+		sum = sum + project.ProjectPrice
 	}
 	unCompleteProject = totalProject - completeProject
 	return

+ 3 - 3
web/.env.development

@@ -4,12 +4,12 @@ VITE_CLI_PORT = 8080
 VITE_SERVER_PORT = 8220
 VITE_BASE_API = /api
 VITE_FILE_API = /api
-VITE_BASE_PATH = http://192.168.110.116
-VITE_POSITION = closef
+VITE_BASE_PATH = http://127.0.0.1
+VITE_POSITION = close
 VITE_EDITOR = webstorm
 
 
 // VITE_EDITOR = webstorm 如果使用webstorm开发且要使用dom定位到代码行功能 请先自定添加 webstorm到环境变量 再将VITE_EDITOR值修改为webstorm
 // 如果使用docker-compose开发模式,设置为下面的地址或本机主机IP
-//VITE_BASE_PATH = http://110.40.223.170
+ //VITE_BASE_PATH = http://110.40.223.170