From 3d20c2d291e632a89be456f864330116c2c3c756 Mon Sep 17 00:00:00 2001 From: haha Date: Fri, 19 Apr 2024 00:21:14 +0800 Subject: [PATCH] update code --- .../views/project/costOutput/costContract.vue | 22 ++- .../views/project/costOutput/costMonth.vue | 2 +- .../project/costOutput/costOutputDrawer.vue | 140 ++++++++++-------- .../src/views/project/costOutput/costYear.vue | 2 +- 4 files changed, 98 insertions(+), 68 deletions(-) diff --git a/ruoyi-ui/src/views/project/costOutput/costContract.vue b/ruoyi-ui/src/views/project/costOutput/costContract.vue index 9f4a32b6..b7b91497 100644 --- a/ruoyi-ui/src/views/project/costOutput/costContract.vue +++ b/ruoyi-ui/src/views/project/costOutput/costContract.vue @@ -36,8 +36,8 @@ - - + + 万元 @@ -100,7 +100,22 @@ export default { } }, checkData(){ - return this.dataList.filter(d=>d.isErr).length==0; + let flag1= this.dataList.filter(d=>d.isErr).length==0; + if(!flag1){ + this.$message.error("请填写数据!"); + return false; + } + flag1=this.dataList.filter(d=>d.money*1<0).length==0; + if(!flag1){ + this.$message.error("金额不能为负数!"); + return false; + } + flag1=this.dataList.filter(d=>d.money3*1<0).length==0; + if(!flag1){ + this.$message.error("挂账金额不能为负数!"); + return false; + } + return true; } }, }; @@ -125,6 +140,7 @@ export default { } } } + } } diff --git a/ruoyi-ui/src/views/project/costOutput/costMonth.vue b/ruoyi-ui/src/views/project/costOutput/costMonth.vue index 694cb4e5..fc404470 100644 --- a/ruoyi-ui/src/views/project/costOutput/costMonth.vue +++ b/ruoyi-ui/src/views/project/costOutput/costMonth.vue @@ -15,7 +15,7 @@ - + 万元 diff --git a/ruoyi-ui/src/views/project/costOutput/costOutputDrawer.vue b/ruoyi-ui/src/views/project/costOutput/costOutputDrawer.vue index cc36e111..0f8be85a 100644 --- a/ruoyi-ui/src/views/project/costOutput/costOutputDrawer.vue +++ b/ruoyi-ui/src/views/project/costOutput/costOutputDrawer.vue @@ -11,7 +11,7 @@ - + 万元 @@ -23,10 +23,11 @@ - + - + @@ -34,21 +35,23 @@ - - + 万元 - + - + - + - + @@ -56,7 +59,8 @@ - + @@ -64,7 +68,8 @@ - + @@ -99,7 +104,7 @@ import costMonth from './costMonth.vue' import costContract from './costContract.vue' export default { components: { - costYear, costMonth,costContract + costYear, costMonth, costContract }, data() { return { @@ -119,76 +124,79 @@ export default { yearInv: [],//年度投资 monthInv: [],//月度产值 oldData: [], - contract:[],//合同金额明细 - safety:[],//安措支付明细 - loading:false, + contract: [],//合同金额明细 + safety: [],//安措支付明细 + loading: false, }; }, - methods: { - doQuery(){ - this.$confirm('确定刷新数据?', '提示', { type: 'warning' }).then(()=>{ + methods: { + doQuery() { + this.$confirm('确定刷新数据?', '提示', { type: 'warning' }).then(() => { this.loadData(); }); }, - costSafetyChange(datas){ - let m2sum=0; - let m3sum=0; - datas.forEach(d=>{ - m2sum+=d.money2; - m3sum+=d.money3; + costSafetyChange(datas) { + let m2sum = 0; + let m3sum = 0; + datas.forEach(d => { + m2sum += d.money2; + m3sum += d.money3; }); - this.form.safety2.money=m2sum; - this.form.safety3.money=m3sum; + this.form.safety2.money = m2sum; + this.form.safety3.money = m3sum; }, handleClick(tab, event) { }, - checkData(){ - if(!this.$refs.costContract.checkData()){ - this.activeName="second"; + checkData() { + if (!this.$refs.costContract.checkData()) { + this.activeName = "second"; return false; } - if(!this.$refs.costSafety.checkData()){ - this.activeName="third"; - return false; + if (!this.$refs.costSafety.checkData()) { + this.activeName = "third"; + return false; } - return true; + return true; }, doSave() { - if(!this.checkData()){ - this.$message.error("请填写数据!"); + if (!this.checkData()) { return; - } - - let objs = this.oldData.filter(d=>d.costType!=11 && d.costType!=12).map(it => { + } + + let objs = this.oldData.filter(d => d.costType != 11 && d.costType != 12).map(it => { let obj = { ...it }; obj.money = obj.money ? obj.money * 10000 : 0; return obj; }); - let contractObjs=this.$refs.costContract.dataList.map(it=>{ - let obj={...it}; + if (objs.filter(d => d.money * 1 < 0).length > 0) { + this.$message.error("请检查,金额不能为负数!"); + return; + } + let contractObjs = this.$refs.costContract.dataList.map(it => { + let obj = { ...it }; obj.money = obj.money ? obj.money * 10000 : 0; - obj.money2=obj.money2?obj.money2*10000:0; - obj.date1=this.$dt(obj.date1).format("YYYY-MM-DD"); + obj.money2 = obj.money2 ? obj.money2 * 10000 : 0; + obj.date1 = this.$dt(obj.date1).format("YYYY-MM-DD"); return obj; }); - let safetyObjs=this.$refs.costSafety.dataList.map(it=>{ - let obj={...it}; + let safetyObjs = this.$refs.costSafety.dataList.map(it => { + let obj = { ...it }; obj.money = obj.money ? obj.money * 10000 : 0; - obj.money2=obj.money2?obj.money2*10000:0; - obj.date1=this.$dt(obj.date1).format("YYYY-MM-DD"); + obj.money2 = obj.money2 ? obj.money2 * 10000 : 0; + obj.date1 = this.$dt(obj.date1).format("YYYY-MM-DD"); return obj; }); - this.loading=true; - batchUpdate([...objs,...contractObjs,...safetyObjs]).then(d => { - this.loading=false; + this.loading = true; + batchUpdate([...objs, ...contractObjs, ...safetyObjs]).then(d => { + this.loading = false; if (d.code != 200) { this.loadData(); } else { this.$modal.msgSuccess("保存成功"); this.loadData(); } - }); + }); }, doAddYearSuccess() { this.loadData(); @@ -210,21 +218,21 @@ export default { let tmps = (d.data || []).map(it => { it.money = it.money ? it.money / 10000.0 : 0; it.money2 = it.money2 ? it.money2 / 10000.0 : 0; - it.money3=it.money-it.money2; - it.isErr=false; - it.date1=this.$dt(it.date1) + it.money3 = it.money - it.money2; + it.isErr = false; + it.date1 = this.$dt(it.date1) return it; }); this.resetData(tmps); this.oldData = tmps; this.form.totalInv = this.getValue(tmps, 1); this.yearInv = tmps.filter(it => it.costType == 2); - this.contract=tmps.filter(it=>it.costType==11); - this.safety=tmps.filter(it=>it.costType==12); + this.contract = tmps.filter(it => it.costType == 11); + this.safety = tmps.filter(it => it.costType == 12); this.form.contract1 = this.getValue(tmps, 3); this.form.contract2 = this.getValue(tmps, 10); - + this.form.safety1 = this.getValue(tmps, 6); this.form.safety2 = this.getValue(tmps, 7); this.form.safety3 = this.getValue(tmps, 8); @@ -246,20 +254,20 @@ export default { setTimeout(() => { this.$refs.costYear.init(this.yearInv, this.prj); this.$refs.costMonth.init(this.monthInv, this.prj); - this.$refs.costContract.init(this.contract,this.prj,11); - this.$refs.costSafety.init(this.safety,this.prj,12); + this.$refs.costContract.init(this.contract, this.prj, 11); + this.$refs.costSafety.init(this.safety, this.prj, 12); }, 400) }); }, getValue(tmps, type) { let objs = tmps.filter(d => d.costType == type); - if(objs.length>0){ + if (objs.length > 0) { return objs[0]; } - let obj={ - money:0, - costType:type, - projectId:this.prj.id + let obj = { + money: 0, + costType: type, + projectId: this.prj.id }; tmps.push(obj); return obj; @@ -287,6 +295,12 @@ export default { ::v-deep .el-drawer__body { padding: 0px 24px; + .el-form-item.txt-error { + .el-input__inner { + border: solid 1px red; + } + } + .el-popover__reference-wrapper { position: absolute; right: 0px; diff --git a/ruoyi-ui/src/views/project/costOutput/costYear.vue b/ruoyi-ui/src/views/project/costOutput/costYear.vue index be9b2b71..f5d3120d 100644 --- a/ruoyi-ui/src/views/project/costOutput/costYear.vue +++ b/ruoyi-ui/src/views/project/costOutput/costYear.vue @@ -17,7 +17,7 @@ - + 万元