Переглянути джерело

完善 工时 新增 日常费用

xuwenhao 8 місяців тому
батько
коміт
b9036ee348

+ 18 - 15
server/dao/project.go

@@ -8,21 +8,24 @@ import (
 
 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:"-"`
-	Collection     []Collection          `json:"collection" form:"collection" gorm:"-"`
-	Reimbursement  []Reimbursement       `json:"reimbursement" form:"reimbursement" gorm:"-"`
+	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:"-"`
 }
 
 func (Project) TableName() string {

+ 10 - 4
server/dao/projectWorkingHours.go

@@ -20,12 +20,12 @@ func (ProjectWorkingHours) TableName() string {
 // TODO:工时查询
 
 // QueryWorkingHoursList 查询工时详情列表
-func QueryWorkingHoursList(limit, offset, people int, code, time string) (projectWorkingHours []ProjectWorkingHours, total int64, err error) {
+func QueryWorkingHoursList(limit, offset, people int, code, time, yearTime string) (projectWorkingHours []ProjectWorkingHours, total int64, err error) {
 	// 创建db
 	db := global.GVA_DB.Model(&ProjectWorkingHours{})
 	// 如果有条件搜索 下方会自动创建搜索语句
 	if code != "" {
-		db = db.Where("project_code = ?", "%"+code+"%")
+		db = db.Where("project_code like ?", "%"+code+"%")
 	}
 	if people != 0 {
 		db = db.Where("people = ?", people)
@@ -33,6 +33,9 @@ func QueryWorkingHoursList(limit, offset, people int, code, time string) (projec
 	if time != "" {
 		db = db.Where("DATE_FORMAT(people_time, '%Y-%m') = ?", time)
 	}
+	if yearTime != "" {
+		db = db.Where("DATE_FORMAT(people_time, '%Y') = ?", yearTime)
+	}
 	err = db.Count(&total).Error
 	if err != nil {
 		return
@@ -41,7 +44,7 @@ func QueryWorkingHoursList(limit, offset, people int, code, time string) (projec
 	return projectWorkingHours, total, err
 }
 
-func QueryWorkingHoursSum(limit, offset, people int, code, time string) (list interface{}, total int64, err error) {
+func QueryWorkingHoursSum(limit, offset, people int, code, time, yearTime string) (list interface{}, total int64, err error) {
 	type Result struct {
 		People   uint
 		Name     string
@@ -63,6 +66,9 @@ func QueryWorkingHoursSum(limit, offset, people int, code, time string) (list in
 	if time != "" {
 		db = db.Where("DATE_FORMAT(people_time, '%Y-%m') = ?", time)
 	}
+	if yearTime != "" {
+		db = db.Where("DATE_FORMAT(people_time, '%Y') = ?", yearTime)
+	}
 	err = db.Group("people").Order("project_working_hours.id desc").Limit(limit).Offset(offset).Preload("Constructor").Count(&total).Scan(&results).Error
 	return results, total, err
 }
@@ -74,7 +80,7 @@ func QueryWorkingHours(code string) (workingHours []ProjectWorkingHours, err err
 }
 
 // QueryWorkingHoursByCode 查询单个工时 按id
-func QueryWorkingHoursByCode(code string, people string) (workingHours ProjectWorkingHours, err error) {
+func QueryWorkingHoursByCode(code string, people int) (workingHours ProjectWorkingHours, err error) {
 	err = global.GVA_DB.Model(&ProjectWorkingHours{}).Where("code = ? and people = ?", code, people).Preload("Constructor").First(&workingHours).Error
 	return workingHours, err
 }

+ 1 - 0
server/model/common/request/common.go

@@ -41,6 +41,7 @@ type SearchWorkingHours struct {
 	PageInfo PageInfo `json:"pageInfo" form:"pageInfo"`
 	Code     string   `json:"name" form:"name"`
 	Time     string   `json:"time" form:"time"`
+	YearTime string   `json:"yearTime" form:"yearTime"`
 	People   int      `json:"people" form:"people"`
 }
 

+ 21 - 2
server/service/admin/finance.go

@@ -11,6 +11,15 @@ func (fs *FinanceService) QueryDailyExpensesList(info request.SearchProject) (li
 	limit := info.PageInfo.PageSize
 	offset := info.PageInfo.PageSize * (info.PageInfo.Page - 1)
 	dailyExpenses, total, err := dao.QueryDailyExpensesList(limit, offset, info.State, info.Name, info.Time)
+
+	for i, expenses := range dailyExpenses {
+		feeDetails, err := dao.QueryDailyFeeDetails(int(expenses.ID))
+		if err != nil {
+			return nil, 0, err
+		}
+		dailyExpenses[i].DailyFeeDetails = feeDetails
+	}
+
 	return dailyExpenses, total, err
 }
 
@@ -54,12 +63,12 @@ func (fs *FinanceService) QueryProjectFinance(code string) (dao.Project, error)
 	if err != nil {
 		return dao.Project{}, err
 	}
-	collection, _, err := dao.QueryCollectionList(1, 5, code, "")
+	collection, collectionTotal, err := dao.QueryCollectionList(8, 0, code, "")
 	if err != nil {
 		return dao.Project{}, err
 	}
 
-	reimbursements, _, err := dao.QueryReimbursementList(1, 5, code, "", "")
+	reimbursements, reimbursementTotal, err := dao.QueryReimbursementList(8, 0, code, "", "")
 	if err != nil {
 		return dao.Project{}, err
 	}
@@ -70,8 +79,18 @@ func (fs *FinanceService) QueryProjectFinance(code string) (dao.Project, error)
 		}
 		reimbursements[i].FeeDetails = details
 	}
+
+	workingHours, workingHoursTotal, err := dao.QueryWorkingHoursList(8, 0, 0, code, "", "")
+	if err != nil {
+		return dao.Project{}, err
+	}
+
 	project.Collection = collection
 	project.Reimbursement = reimbursements
+	project.WorkingHours = workingHours
+	project.ReimbursementTotal = reimbursementTotal
+	project.CollectionTotal = collectionTotal
+	project.WorkingHoursTotal = workingHoursTotal
 
 	return project, err
 }

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

@@ -83,13 +83,13 @@ func (ps *ProjectService) QueryWorkingHours(code string) ([]dao.ProjectWorkingHo
 func (ps *ProjectService) QueryWorkingHoursList(info request.SearchWorkingHours) (list interface{}, total int64, err error) {
 	limit := info.PageInfo.PageSize
 	offset := info.PageInfo.PageSize * (info.PageInfo.Page - 1)
-	return dao.QueryWorkingHoursList(limit, offset, info.People, info.Code, info.Time)
+	return dao.QueryWorkingHoursList(limit, offset, info.People, info.Code, info.Time, info.YearTime)
 }
 
 func (ps *ProjectService) QueryWorkingHoursSum(info request.SearchWorkingHours) (list interface{}, total int64, err error) {
 	limit := info.PageInfo.PageSize
 	offset := info.PageInfo.PageSize * (info.PageInfo.Page - 1)
-	return dao.QueryWorkingHoursSum(limit, offset, info.People, info.Code, info.Time)
+	return dao.QueryWorkingHoursSum(limit, offset, info.People, info.Code, info.Time, info.YearTime)
 }
 
 func (ps *ProjectService) QueryCollections(code string) ([]dao.Collection, error) {

+ 1 - 1
web/.env.development

@@ -4,7 +4,7 @@ VITE_CLI_PORT = 8080
 VITE_SERVER_PORT = 8220
 VITE_BASE_API = /api
 VITE_FILE_API = /api
-VITE_BASE_PATH = http://106.52.134.22
+VITE_BASE_PATH = http://127.0.0.1
 VITE_POSITION = close
 VITE_EDITOR = webstorm
 

+ 0 - 1
web/src/view/superAdmin/user/user.vue

@@ -294,7 +294,6 @@ const getTableData = async() => {
   }
 }
 
-
 const initPage = async() => {
   getTableData()
   const res = await getAuthorityList({ page: 1, pageSize: 999 })