Parcourir la source

删除 判断

xuwenhao il y a 7 mois
Parent
commit
904983b786

+ 5 - 0
server/api/v1/admin/finance.go

@@ -325,6 +325,11 @@ func (fa *FinanceApi) DeleteExpensesGenre(c *gin.Context) {
 	}
 	err = financeService.DeleteExpensesGenre(expensesGenre)
 	if err != nil {
+		if err.Error() == "费用类型正在被使用" {
+			response.FailWithMessage("费用类型正在被使用", c)
+			global.GVA_LOG.Error("DeleteExpensesGenre ====== " + err.Error())
+			return
+		}
 		response.FailWithMessage("失败", c)
 		global.GVA_LOG.Error("DeleteExpensesGenre ====== " + err.Error())
 		return

+ 1 - 1
server/dao/borrowing.go

@@ -60,7 +60,7 @@ func (b Borrowing) CreateBorrowing() error {
 
 // UpdateBorrowing 更新支借
 func (b Borrowing) UpdateBorrowing() error {
-	return global.GVA_DB.Model(&b).Updates(&b).Error
+	return global.GVA_DB.Model(&b).Where("id = ?", b.ID).Updates(&b).Error
 }
 
 // TODO:支借删除

+ 1 - 1
server/dao/collection.go

@@ -52,7 +52,7 @@ func (c Collection) CreateCollection() error {
 
 // UpdateCollection 修改收款
 func (c Collection) UpdateCollection() error {
-	return global.GVA_DB.Model(&c).Updates(&c).Error
+	return global.GVA_DB.Model(&c).Where("id = ?", c.ID).Updates(&c).Error
 }
 
 // TODO:收款删除

+ 1 - 1
server/dao/constructor.go

@@ -43,7 +43,7 @@ func (c Constructor) CreateConstructor() error {
 
 // UpdateConstructor 修改施工人员
 func (c Constructor) UpdateConstructor() error {
-	return global.GVA_DB.Model(&c).Updates(&c).Error
+	return global.GVA_DB.Model(&c).Where("id = ?", c.ID).Updates(&c).Error
 }
 
 // DeleteConstructor 删除施工人员

+ 1 - 1
server/dao/dailyExpenses.go

@@ -85,7 +85,7 @@ func (de DailyExpenses) UpdateDailyExpenses() error {
 		if txErr != nil {
 			return txErr
 		}
-		txErr = tx.Model(&de).Updates(&de).Error
+		txErr = tx.Model(&de).Where("id = ?", de.ID).Updates(&de).Error
 		if txErr != nil {
 			return txErr
 		}

+ 1 - 1
server/dao/department.go

@@ -52,7 +52,7 @@ func (d Department) CreateDep() error {
 
 // UpdateDep 修改部门
 func (d Department) UpdateDep() error {
-	return global.GVA_DB.Model(&d).Updates(d).Error
+	return global.GVA_DB.Model(&d).Where("id = ?", d.Id).Updates(&d).Error
 }
 
 // UpdateDepStatus 修改部门状态

+ 12 - 2
server/dao/expenses.go

@@ -15,7 +15,7 @@ type Expenses struct {
 	ExpensesGenre     ExpensesGenre `json:"expensesGenre" form:"expensesGenre" gorm:"foreignKey:Genre;references:id;"`
 	ProjectId         int           `json:"projectId" form:"projectId" gorm:"comment:项目id"`
 	Project           Project       `json:"project" form:"project" gorm:"foreignKey:ProjectId;references:id"`
-	ExpenseDetail     string        `json:"expenseDetail" form:"expenseDetail" gorm:"comment:费用明细"`
+	ExpenseDetail     string        `json:"expenseDetail" form:"expenseDetail" gorm:"comment:费用明细;type:varchar(400)"`
 	Remarks           string        `json:"remarks" form:"remarks" gorm:"comment:备注"`
 	ThenBalance       float64       `json:"thenBalance" form:"thenBalance" gorm:"comment:当时余额;type:double(10,2)"`
 }
@@ -105,12 +105,22 @@ func QuerySurplus() (interface{}, error) {
 	return results, err
 }
 
+func QueryExpensesByGenre(genre int) (expenses []Expenses, err error) {
+	err = global.GVA_DB.Model(&Expenses{}).Where("genre = ?", genre).Find(&expenses).Error
+	return expenses, err
+}
+
+func QueryExpensesByProjectId(projectId int) (expenses []Expenses, err error) {
+	err = global.GVA_DB.Model(&Expenses{}).Where("project_id = ?", projectId).Find(&expenses).Error
+	return expenses, err
+}
+
 func (e Expenses) CreateExpenses() error {
 	return global.GVA_DB.Create(&e).Error
 }
 
 func (e Expenses) UpdateExpenses() error {
-	return global.GVA_DB.Model(&Expenses{}).Updates(&e).Error
+	return global.GVA_DB.Model(&Expenses{}).Where("id = ?", e.ID).Updates(&e).Error
 }
 
 func (e Expenses) DeleteExpenses() error {

+ 1 - 1
server/dao/expensesGenre.go

@@ -30,7 +30,7 @@ func (eg ExpensesGenre) CreateExpensesGenre() error {
 
 // UpdateExpensesGenre 修改费用类型
 func (eg ExpensesGenre) UpdateExpensesGenre() error {
-	return global.GVA_DB.Model(&eg).Updates(&eg).Error
+	return global.GVA_DB.Model(&eg).Where("id = ?", eg.ID).Updates(&eg).Error
 }
 
 // TODO:费用类型删除

+ 1 - 1
server/dao/fileGenre.go

@@ -39,7 +39,7 @@ func (fg FileGenre) CreateFileGenre() error {
 
 // UpdateFileGenre 修改文件类型
 func (fg FileGenre) UpdateFileGenre() error {
-	return global.GVA_DB.Model(&fg).Updates(&fg).Error
+	return global.GVA_DB.Model(&fg).Where("id = ?", fg.ID).Updates(&fg).Error
 }
 
 // TODO:文件类型删除

+ 1 - 1
server/dao/project.go

@@ -101,7 +101,7 @@ func (p Project) CreateProject() error {
 
 // UpdateProject 修改项目
 func (p Project) UpdateProject() error {
-	return global.GVA_DB.Model(&p).Updates(p).Error
+	return global.GVA_DB.Model(&p).Where("id = ?", p.ID).Updates(p).Error
 }
 
 // TODO:项目删除

+ 1 - 1
server/dao/projectState.go

@@ -37,7 +37,7 @@ func (ps ProjectState) CreateProjectState() error {
 
 // UpdateProjectState 修改文件类型
 func (ps ProjectState) UpdateProjectState() error {
-	return global.GVA_DB.Model(&ps).Updates(&ps).Error
+	return global.GVA_DB.Model(&ps).Where("id = ?", ps.ID).Updates(&ps).Error
 }
 
 // TODO:文件类型删除

+ 1 - 1
server/dao/purchase.go

@@ -40,7 +40,7 @@ func (p Purchase) CreatePurchase() error {
 
 // UpdatePurchase 修改采购
 func (p Purchase) UpdatePurchase() error {
-	return global.GVA_DB.Model(&p).Updates(&p).Error
+	return global.GVA_DB.Model(&p).Where("id = ?", p.ID).Updates(&p).Error
 }
 
 // TODO:采购删除

+ 1 - 1
server/dao/sys_authority.go

@@ -54,7 +54,7 @@ func (sa SysAuthority) GetAuthorityInfo() (sysAuthority SysAuthority, err error)
 
 // UpdateAuthority 修改角色
 func (sa SysAuthority) UpdateAuthority() error {
-	return global.GVA_DB.Model(&SysAuthority{}).Updates(&sa).Error
+	return global.GVA_DB.Model(&SysAuthority{}).Where("authority_id = ?", sa.AuthorityId).Updates(&sa).Error
 }
 
 // TODO:角色删除

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

@@ -21,5 +21,6 @@ func (fs *FileService) UpdateFileGenre(fileGenre dao.FileGenre) error {
 }
 
 func (fs *FileService) DeleteFileGenre(fileGenre dao.FileGenre) error {
+
 	return fileGenre.DeleteFileGenre()
 }

+ 5 - 0
server/service/admin/finance.go

@@ -1,6 +1,7 @@
 package admin
 
 import (
+	"fmt"
 	"server/dao"
 	"server/model/common/request"
 )
@@ -128,6 +129,10 @@ func (fs *FinanceService) DeleteDailyExpenses(expenses dao.DailyExpenses) error
 }
 
 func (fs *FinanceService) DeleteExpensesGenre(genre dao.ExpensesGenre) error {
+	expenses, _ := dao.QueryExpensesByGenre(int(genre.ID))
+	if len(expenses) > 0 {
+		return fmt.Errorf("费用类型正在被使用")
+	}
 	return genre.DeleteExpensesGenre()
 }
 

+ 14 - 0
server/service/admin/project.go

@@ -1,6 +1,7 @@
 package admin
 
 import (
+	"fmt"
 	"github.com/shopspring/decimal"
 	"server/dao"
 	"server/model/common/request"
@@ -180,6 +181,19 @@ func (ps *ProjectService) UpdateReimbursement(reimbursement dao.Reimbursement) e
 }
 
 func (ps *ProjectService) DeleteProject(code string) error {
+	files, _ := dao.QueryFilesByCode(code)
+	if len(files) > 0 {
+		return fmt.Errorf("项目下存在文件")
+	}
+	collection, _ := dao.QueryCollection(code)
+	if len(collection) > 0 {
+		return fmt.Errorf("项目下存在收款记录")
+	}
+	project, _ := dao.QueryProjectByCode(code)
+	expenses, _ := dao.QueryExpensesByProjectId(int(project.ID))
+	if len(expenses) > 0 {
+		return fmt.Errorf("项目下存在费用记录")
+	}
 	return dao.DeleteProject(code)
 }
 

+ 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 = close
+VITE_BASE_PATH = http://192.168.110.116
+VITE_POSITION = closef
 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
 

+ 1 - 0
web/src/components/selectImage/selectImage.vue

@@ -324,6 +324,7 @@ const getImageList = async() => {
   const res = await getFileList({ page: page.value, pageSize: pageSize.value, ...search.value })
   if (res.code === 0) {
     picList.value = res.data.list
+    console.log(picList.value)
     total.value = res.data.total
     page.value = res.data.page
     pageSize.value = res.data.pageSize

+ 5 - 4
web/src/view/finance/financeAnalysis/components/hour.vue

@@ -11,7 +11,7 @@
           <el-option
             v-for="item in peopleList"
             :key="item.ID"
-            :label="item.name"
+            :label="item.nickName"
             :value="item.ID"
           />
         </el-select>
@@ -118,7 +118,7 @@
             <el-option
               v-for="item in peopleList"
               :key="item.ID"
-              :label="item.name"
+              :label="item.nickName"
               :value="item.ID"
             />
           </el-select>
@@ -160,9 +160,10 @@
 import { reactive, onMounted, ref, defineExpose } from 'vue'
 import { hourOperate } from '@/pinia/hour/Hour'
 import { codeOperate } from '@/pinia/code/code'
-import { queryConstructor, createWorkingHours } from '@/api/finance'
+import { createWorkingHours } from '@/api/finance'
 import { Search, Plus } from '@element-plus/icons-vue'
 import { ElMessage } from 'element-plus'
+import { getAllUsers } from '@/api/user'
 defineOptions({
   name: 'Hour'
 })
@@ -189,7 +190,7 @@ const peopleId = ref('')
 const peopleList = reactive([])
 const addTimeShow = ref(false)
 onMounted(() => {
-  queryConstructor().then(res => {
+  getAllUsers().then(res => {
     if (res.code === 0) {
       peopleList.length = 0
       peopleList.push(...res.data)

+ 3 - 1
web/src/view/finance/workingHours/workingHours.vue

@@ -7,7 +7,7 @@
             <el-form-item label="项目编号">
               <el-input v-model="searchWorkingHours.code" />
             </el-form-item>
-            <el-form-item label="时间">
+            <el-form-item label="月份">
               <el-date-picker
                 v-model="searchWorkingHours.time"
                 type="month"
@@ -15,6 +15,8 @@
                 format="YYYY-MM"
                 value-format="YYYY-MM"
               />
+            </el-form-item>
+            <el-form-item label="年份">
               <el-date-picker
                 v-model="searchWorkingHours.yearTime"
                 type="year"