From 572747de6cea0ae0ceee923f28775dbed545eb6d Mon Sep 17 00:00:00 2001 From: zhc077 <565291854@qq.com> Date: Wed, 30 Oct 2024 11:45:04 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A2=84=E7=AE=97=E4=B9=A6-=E7=BB=8F=E8=B4=B9?= =?UTF-8?q?=E9=A2=84=E7=AE=97=E8=A1=A8=20=E5=8A=9F=E8=83=BD=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=2010.30?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../demo/mock/vxe/json/projectFeeBudget.json | 1 - .../ProjectFeeBudgetController.java | 24 ++++++++-- .../yusuanshu/ProjectFeeBudgetDemo.vue | 48 +++++++++++++++---- 3 files changed, 58 insertions(+), 15 deletions(-) diff --git a/jeecg-boot/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/mock/vxe/json/projectFeeBudget.json b/jeecg-boot/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/mock/vxe/json/projectFeeBudget.json index e9936b2..b1d2e61 100644 --- a/jeecg-boot/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/mock/vxe/json/projectFeeBudget.json +++ b/jeecg-boot/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/mock/vxe/json/projectFeeBudget.json @@ -9,7 +9,6 @@ {"budgetSubject":"专家咨询费","totalFee":0.00,"specialFee":0.00,"selfFee":0.00,"specialFeeMark":""} {"budgetSubject":"其他支出","totalFee":0.00,"specialFee":0.00,"selfFee":0.00,"specialFeeMark":""} {"budgetSubject":"本次申请省财政经费支持","totalFee":0.00,"specialFee":0.00,"selfFee":0.00,"specialFeeMark":""} -{"budgetSubject":"本次申请省财政经费支持","totalFee":0.00,"specialFee":0.00,"selfFee":0.00,"specialFeeMark":""} {"budgetSubject":"其他财政拨款","totalFee":0.00,"specialFee":0.00,"selfFee":0.00,"specialFeeMark":""} {"budgetSubject":"单位自有货币资金","totalFee":0.00,"specialFee":0.00,"selfFee":0.00,"specialFeeMark":""} {"budgetSubject":"其他资金","totalFee":0.00,"specialFee":0.00,"selfFee":0.00,"specialFeeMark":""} diff --git a/jeecg-boot/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/projectFeeBudget/controller/ProjectFeeBudgetController.java b/jeecg-boot/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/projectFeeBudget/controller/ProjectFeeBudgetController.java index c0f9f5f..dca9601 100644 --- a/jeecg-boot/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/projectFeeBudget/controller/ProjectFeeBudgetController.java +++ b/jeecg-boot/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/projectFeeBudget/controller/ProjectFeeBudgetController.java @@ -4,7 +4,6 @@ import com.alibaba.fastjson.JSONArray; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; -import com.baomidou.mybatisplus.extension.ddl.history.IDdlGenerator; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; @@ -12,9 +11,12 @@ import lombok.extern.slf4j.Slf4j; import org.apache.shiro.authz.annotation.RequiresPermissions; import org.jeecg.common.api.vo.Result; import org.jeecg.common.aspect.annotation.AutoLog; +import org.jeecg.common.exception.JeecgBootException; import org.jeecg.common.system.base.controller.JeecgController; import org.jeecg.common.system.query.QueryGenerator; import org.jeecg.common.util.UUIDGenerator; +import org.jeecg.modules.demo.project.entity.Project; +import org.jeecg.modules.demo.project.service.IProjectService; import org.jeecg.modules.demo.projectFeeBudget.entity.ProjectFeeBudget; import org.jeecg.modules.demo.projectFeeBudget.service.IProjectFeeBudgetService; import org.springframework.beans.factory.annotation.Autowired; @@ -23,8 +25,11 @@ import org.springframework.web.servlet.ModelAndView; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import java.math.BigDecimal; import java.util.Arrays; +import java.util.LinkedList; import java.util.List; +import java.util.Optional; /** * @Description: 项目经费预算 @@ -40,6 +45,9 @@ public class ProjectFeeBudgetController extends JeecgController().eq(ProjectFeeBudget::getProjectId,projectId)); + public Result saveAll(@PathVariable("projectId") String projectId, @RequestBody JSONArray tableData) { + Project project = iProjectService.getById(projectId); + Optional.ofNullable(project).orElseThrow(() -> new JeecgBootException("项目不存在")); + List list = JSONArray.parseArray(tableData.toJSONString(), ProjectFeeBudget.class); - list.forEach(obj->{ + list.forEach(obj -> { obj.setProjectId(projectId); obj.setId(UUIDGenerator.generate()); }); + BigDecimal sumFee = Optional.ofNullable(list).orElse(new LinkedList<>()).stream().map(ProjectFeeBudget::getTotalFee).reduce(BigDecimal.ZERO, BigDecimal::add); + //申请财政拨款与经费明细总各比较,不相等 异常退出 + /*if(project.getApplyFund().compareTo(sumFee) != 0){ + throw new JeecgBootException("申请财政拨款与项目经费预算表合计金额不等,请核对!"); + }*/ + projectFeeBudgetService.remove(new LambdaQueryWrapper().eq(ProjectFeeBudget::getProjectId, projectId)); projectFeeBudgetService.saveBatch(list); return Result.ok(); } diff --git a/jeecgboot-vue3/src/views/projectApplication/kejigongguan/yusuanshu/ProjectFeeBudgetDemo.vue b/jeecgboot-vue3/src/views/projectApplication/kejigongguan/yusuanshu/ProjectFeeBudgetDemo.vue index d2bb459..0ee5015 100644 --- a/jeecgboot-vue3/src/views/projectApplication/kejigongguan/yusuanshu/ProjectFeeBudgetDemo.vue +++ b/jeecgboot-vue3/src/views/projectApplication/kejigongguan/yusuanshu/ProjectFeeBudgetDemo.vue @@ -15,6 +15,7 @@ :loading="loading" :columns="columns" :dataSource="dataSource" + @valueChange="handleValueChange" @save="handleTableSave" /> @@ -68,11 +69,11 @@ const columns = ref([ // 列的宽度 width: 260, // 如果加上了该属性,就代表当前单元格是可编辑的,type就是表单的类型,input就是简单的输入框 - type: JVxeTypes.inputNumber, + type: JVxeTypes.normal, }, { key: 'specialFee', title: '专项经费', width: 260, type: JVxeTypes.inputNumber }, - { key: 'selfFee', title: '自筹经费', width: 260, type: JVxeTypes.inputNumber }, - { key: 'specialFeeMark', title: '专项经费说明', width: 260, type: JVxeTypes.textarea }, + { key: 'selfFee', title: '自筹经费', width: 130, type: JVxeTypes.inputNumber }, + { key: 'specialFeeMark', title: '专项经费说明', width: 380, type: JVxeTypes.textarea }, ]); // 查询url地址 @@ -88,6 +89,31 @@ enum Api { loadData(); + +// 当选择的行变化时触发的事件 +function handleSelectRowChange(event) { + /*console.log("handleSelectRowChange") + selectedRows.value = event.selectedRows; + console.log("handleSelectRowChange-event:", event) + const {type, row, column, value, target, $table} = event + // row.totalFee = event.value; + console.log('--------------------') + console.log('selfFee',row.selfFee) + console.log('totalFee',row.totalFee)*/ + // target.$refs.vxe.columns[4].options = this.stationIdList; + // target.$refs.vxe.columns[17].options = this.userIdList; +}; + +function handleValueChange(event) { + console.log('handleValueChange.event: ', event); + const {type, row, column, value, target, $table} = event + /*console.log('selfFee',row.specialFee) + console.log('selfFee',row.selfFee) + console.log('--------------------')*/ + row.totalFee = row.selfFee + row.specialFee; + console.log('the new totalFee',row.totalFee) +} + // 加载数据 async function loadData() { loading.value = true; @@ -140,6 +166,7 @@ function handleTableSave({ $table, target }) { }) .then(() => { createMessage.success(`保存成功!`); + loadData(); }) .finally(() => { loading.value = false; @@ -170,6 +197,7 @@ function handleTableSave({ $table, target }) { function handleEditClosed(event) { let { $table, row, column } = event; let field = column.property; + // console.log('field',field); // 判断单元格值是否被修改 if ($table.isUpdateByRow(row, field)) { // 校验当前行 @@ -177,9 +205,9 @@ function handleEditClosed(event) { // 校验通过 if (!errMap) { // 【模拟保存】 - let hideLoading = createMessage.loading(`正在保存"${column.title}"`, 0); - console.log('即时保存数据:', row); - defHttp + // let hideLoading = createMessage.loading(`正在保存"${column.title}"`, 0); + console.log('-----handleEditClosed()--即时保存行row数据:', JSON.stringify(row)); + /*defHttp .put({ url: Api.saveRow, params: row, @@ -191,7 +219,7 @@ function handleEditClosed(event) { }) .finally(() => { hideLoading(); - }); + });*/ } }); } @@ -207,9 +235,9 @@ function handlePageChange(event) { }*/ // 当选择的行变化时触发的事件 -function handleSelectRowChange(event) { - selectedRows.value = event.selectedRows; -} +// function handleSelectRowChange(event) { +// selectedRows.value = event.selectedRows; +// }