|
@@ -8,13 +8,15 @@ import (
|
|
|
|
|
|
type Reimbursement struct {
|
|
|
global.GVA_MODEL
|
|
|
- ProjectCode string `json:"projectCode" form:"projectCode" gorm:"comment:项目编号"`
|
|
|
- Name string `json:"name" form:"name" gorm:"comment:项目名称"`
|
|
|
- Applicant string `json:"applicant" form:"applicant" gorm:"comment:报销申请人"`
|
|
|
- Approval string `json:"approval" form:"approval" gorm:"comment:报销审批人"`
|
|
|
- Price decimal.Decimal `json:"price" form:"price" gorm:"comment:项目金额"`
|
|
|
- Genre string `json:"genre" form:"genre" gorm:"comment:项目类型"`
|
|
|
- FeeDetails []FeeDetails `json:"feeDetails" form:"feeDetails" gorm:"-"`
|
|
|
+ ProjectCode string `json:"projectCode" form:"projectCode" gorm:"comment:项目编号"`
|
|
|
+ Name string `json:"name" form:"name" gorm:"comment:项目名称"`
|
|
|
+ Applicant string `json:"applicant" form:"applicant" gorm:"comment:报销申请人"`
|
|
|
+ ApplicationTime string `json:"applicationTime" form:"applicationTime" gorm:"comment:申请日期"`
|
|
|
+ Approval int `json:"approval" form:"approval" gorm:"comment:报销审批人"`
|
|
|
+ User SysUser `json:"user" form:"user" gorm:"foreignKey:Approval;references:id;"`
|
|
|
+ Price decimal.Decimal `json:"price" form:"price" gorm:"comment:项目金额;type:decimal(10,2)"`
|
|
|
+ Genre string `json:"genre" form:"genre" gorm:"comment:费用类型"`
|
|
|
+ FeeDetails []FeeDetails `json:"feeDetails" form:"feeDetails" gorm:"-"`
|
|
|
}
|
|
|
|
|
|
func (Reimbursement) TableName() string {
|
|
@@ -23,24 +25,27 @@ func (Reimbursement) TableName() string {
|
|
|
|
|
|
// TODO:报销查询
|
|
|
|
|
|
-// QueryReimbursementList 查询报销
|
|
|
-func QueryReimbursementList(limit, offset int, code, name string) (reimbursement []Reimbursement, total int64, err error) {
|
|
|
+// QueryReimbursementList 查询报销列表
|
|
|
+func QueryReimbursementList(limit, offset int, code, name, time string) (reimbursement []Reimbursement, total int64, err error) {
|
|
|
// 创建db
|
|
|
- db := global.GVA_DB.Model(&Project{}).Where("project_code = ?", code)
|
|
|
+ db := global.GVA_DB.Model(&Reimbursement{}).Where("project_code = ?", code)
|
|
|
// 如果有条件搜索 下方会自动创建搜索语句
|
|
|
if name != "" {
|
|
|
db = db.Where("name LIKE ?", "%"+name+"%")
|
|
|
}
|
|
|
+ if time != "" {
|
|
|
+ db = db.Where("DATE_FORMAT(application_time, '%Y-%m') = ?", time)
|
|
|
+ }
|
|
|
err = db.Count(&total).Error
|
|
|
if err != nil {
|
|
|
return
|
|
|
}
|
|
|
- err = db.Order("id desc").Limit(limit).Offset(offset).Find(&reimbursement).Error
|
|
|
+ err = db.Order("id desc").Limit(limit).Offset(offset).Preload("User").Find(&reimbursement).Error
|
|
|
return reimbursement, total, err
|
|
|
}
|
|
|
|
|
|
func QueryReimbursement(code string) (reimbursement []Reimbursement, err error) {
|
|
|
- err = global.GVA_DB.Model(&Reimbursement{}).Where("project_code = ?", code).Find(&reimbursement).Error
|
|
|
+ err = global.GVA_DB.Model(&Reimbursement{}).Where("project_code = ?", code).Preload("User").Find(&reimbursement).Error
|
|
|
return reimbursement, err
|
|
|
}
|
|
|
|