Parcourir la source

项目立项成功 页面跳转

xuwenhao il y a 8 mois
Parent
commit
4660a0dea3

+ 1 - 2
server/dao/dailyExpenses.go

@@ -1,7 +1,6 @@
 package dao
 
 import (
-	"github.com/shopspring/decimal"
 	"gorm.io/gorm"
 	"server/global"
 )
@@ -15,7 +14,7 @@ type DailyExpenses struct {
 	ApplicationTime string            `json:"applicationTime" form:"applicationTime" gorm:"comment:申请日期"`
 	Charge          int               `json:"charge" form:"charge" gorm:"comment:负责人"`
 	User            SysUser           `json:"user" form:"user" gorm:"foreignKey:Charge;references:id;"`
-	TotalAmount     decimal.Decimal   `json:"totalAmount" form:"totalAmount" gorm:"type:decimal(10,2);comment:总金额"`
+	TotalAmount     float64           `json:"totalAmount" form:"totalAmount" gorm:"type:decimal(10,2);comment:总金额"`
 	DailyFeeDetails []DailyFeeDetails `json:"dailyFeeDetails" form:"dailyFeeDetails" gorm:"-"`
 }
 

+ 4 - 5
server/dao/dailyFeeDetails.go

@@ -1,16 +1,15 @@
 package dao
 
 import (
-	"github.com/shopspring/decimal"
 	"server/global"
 )
 
 type DailyFeeDetails struct {
 	global.GVA_MODEL
-	DailyFeeId uint            `json:"dailyFeeId" form:"dailyFeeId" gorm:"comment:日常费用id"`
-	FeeTime    string          `json:"feeTime" form:"feeTime" gorm:"comment:日常费用期"`
-	Illustrate string          `json:"illustrate" form:"illustrate" gorm:"comment:费用说明"`
-	FeePrice   decimal.Decimal `json:"feePrice" form:"feePrice" gorm:"type:decimal(10,2);comment:报销金额"`
+	DailyFeeId uint    `json:"dailyFeeId" form:"dailyFeeId" gorm:"comment:日常费用id"`
+	FeeTime    string  `json:"feeTime" form:"feeTime" gorm:"comment:日常费用期"`
+	Illustrate string  `json:"illustrate" form:"illustrate" gorm:"comment:费用说明"`
+	FeePrice   float64 `json:"feePrice" form:"feePrice" gorm:"type:decimal(10,2);comment:报销金额"`
 }
 
 func (DailyFeeDetails) TableName() string {

+ 12 - 3
server/dao/project.go

@@ -79,9 +79,18 @@ func (p Project) CreateProject() error {
 		}
 
 		for _, file := range p.Files {
-			txErr := tx.Model(&ProjectFile{}).Create(&file).Error
-			if txErr != nil {
-				return txErr
+			var isFile ProjectFile
+			tx.Model(&ProjectFile{}).Where("project_code = ? AND name = ? AND genre = ?", file.ProjectCode, file.Name, file.Genre).First(&isFile)
+			if isFile.ID != 0 {
+				txErr := tx.Model(&ProjectFile{}).Where("id = ?", isFile.ID).Updates(&file).Error
+				if txErr != nil {
+					return txErr
+				}
+			} else {
+				txErr := tx.Model(&ProjectFile{}).Create(&file).Error
+				if txErr != nil {
+					return txErr
+				}
 			}
 		}
 		return txErr

+ 14 - 1
server/dao/projectFile.go

@@ -63,7 +63,20 @@ func QueryFilesByNameOrGenre(genre int, code, name string) (files []ProjectFile,
 
 // CreateFile 新增文件
 func (pf ProjectFile) CreateFile() error {
-	return global.GVA_DB.Create(&pf).Error
+	var isFile ProjectFile
+	global.GVA_DB.Model(&ProjectFile{}).Where("project_code = ? AND name = ? AND genre = ?", pf.ProjectCode, pf.Name, pf.Genre).First(&isFile)
+	if isFile.ID != 0 {
+		err := global.GVA_DB.Model(&ProjectFile{}).Where("id = ?", isFile.ID).Updates(&pf).Error
+		if err != nil {
+			return err
+		}
+	} else {
+		err := global.GVA_DB.Model(&ProjectFile{}).Create(&pf).Error
+		if err != nil {
+			return err
+		}
+	}
+	return nil
 }
 
 // TODO:项目文件修改

+ 6 - 2
web/src/view/finance/borrowing/borrowing.vue

@@ -163,15 +163,18 @@
                 <el-table
                   :data="dailyExpensesData.dailyFeeDetails"
                   row-key="id"
+                  table-layout="auto"
                 >
                   <el-table-column
                     label="序号"
                     property="id"
                     prop="id"
+                    align="center"
                   />
                   <el-table-column
                     property="illustrate"
                     label="费用说明"
+                    align="center"
                   >
                     <template #default="scope">
                       <el-input
@@ -185,6 +188,7 @@
                   <el-table-column
                     property="feePrice"
                     label="报销金额"
+                    align="center"
                   >
                     <template #default="scope">
                       <el-input-number
@@ -198,6 +202,7 @@
                   <el-table-column
                     property="feeTime"
                     label="日期"
+                    align="center"
                   >
                     <template #default="scope">
                       <el-date-picker
@@ -210,6 +215,7 @@
                   </el-table-column>
                   <el-table-column
                     label="操作"
+                    align="center"
                   >
                     <template #default="scope">
                       <el-button
@@ -656,8 +662,6 @@ const expensesDetailsData = (val) => {
   for (let i = 1; i <= dailyExpensesData.value.dailyFeeDetails.length; i++) {
     dailyExpensesData.value.dailyFeeDetails[i - 1].id = i
   }
-  console.log(dailyExpensesData.value)
-  console.log(dailyExpensesData.value.dailyFeeDetails.id)
   openDailyExpenses.value = true
 }
 

+ 8 - 0
web/src/view/projectManage/projectApproval/projectApproval.vue

@@ -217,6 +217,10 @@ import moment from 'moment/moment'
 import { createProject } from '@/api/project'
 import { getAllUsers } from '@/api/user'
 import { ElMessage } from 'element-plus'
+import { useRouter } from 'vue-router'
+
+const router = useRouter()
+
 defineOptions({
   name: 'ProjectApproval'
 })
@@ -293,6 +297,10 @@ const approval = () => {
         message: '立项成功',
         type: 'success',
       })
+      const { href } = router.resolve({
+        path: '/layout/projectManage/projectList', // 路径
+      })
+      location.href = (href)
     } else {
       ElMessage({
         message: '立项失败',