浏览代码

修改预算报错toFixed的问题

余思翰 4 个月前
父节点
当前提交
ed846146f8

+ 10
- 8
oa-ui/src/views/flowable/form/budget/budgetInfo.vue 查看文件

@@ -2,7 +2,7 @@
2 2
  * @Author: ysh
3 3
  * @Date: 2024-04-03 16:28:09
4 4
  * @LastEditors: Please set LastEditors
5
- * @LastEditTime: 2025-04-03 16:48:33
5
+ * @LastEditTime: 2025-04-14 09:37:59
6 6
 -->
7 7
 <template>
8 8
   <div class="main">
@@ -98,12 +98,13 @@
98 98
               <td v-else>
99 99
                 {{ work.coefficient }}
100 100
               </td>
101
-              <td style="text-align:right;">{{ (work.settle).toFixed(2) }}</td>
101
+              <td style="text-align:right;">{{ work.settle ? work.settle.toFixed(2) : '0.00' }}</td>
102 102
               <td>{{ work.remark ? work.remark : '' }}</td>
103 103
             </tr>
104 104
             <tr>
105 105
               <td :colspan="7" class="head">预结算额合计</td>
106
-              <td :colspan="1" class="head" style="text-align:right;">{{ (budgetForm.settleExpense).toFixed(2) }}</td>
106
+              <td :colspan="1" class="head" style="text-align:right;">{{ budgetForm.settleExpense ?
107
+                budgetForm.settleExpense.toFixed(2) : '0.00' }}</td>
107 108
               <td></td>
108 109
             </tr>
109 110
           </table>
@@ -133,7 +134,8 @@
133 134
               </td>
134 135
               <td>
135 136
                 <span v-if="$store.getters.roles.includes('leader')">
136
-                  {{ parseFloat((user.salary.salary + 1780) / 21.75).toFixed(2) }}
137
+                  {{ parseFloat((user.salary.salary + 1780) / 21.75) ? parseFloat((user.salary.salary + 1780) /
138
+                    21.75).toFixed(2) : '0.00' }}
137 139
                 </span>
138 140
                 <span v-else>/</span>
139 141
               </td>
@@ -147,7 +149,7 @@
147 149
                 {{ user.days }}
148 150
               </td>
149 151
               <td></td>
150
-              <td style="text-align:right;">{{ (user.staffCost).toFixed(2) }}</td>
152
+              <td style="text-align:right;">{{ user.staffCost ? user.staffCost.toFixed(2) : '0.00' }}</td>
151 153
             </tr>
152 154
             <tr v-if="carLen != 1" style="background-color:#f8f8f9">
153 155
               <td :rowspan="carLen">车辆</td>
@@ -183,7 +185,7 @@
183 185
                 {{ car.days }}
184 186
               </td>
185 187
               <td> {{ car.toll }} </td>
186
-              <td style="text-align:right;">{{ (car.expense).toFixed(2) }}</td>
188
+              <td style="text-align:right;">{{ car.expense ? car.expense.toFixed(2) : '0.00' }}</td>
187 189
             </tr>
188 190
             <tr v-if="deviceLen != 1" style="background-color:#f8f8f9">
189 191
               <td :rowspan="deviceLen">设备</td>
@@ -212,7 +214,7 @@
212 214
                 {{ device.days }}
213 215
               </td>
214 216
               <td></td>
215
-              <td style="text-align:right;">{{ (device.depreciation).toFixed(2) }}</td>
217
+              <td style="text-align:right;">{{ device.depreciation ? device.depreciation.toFixed(2) : '0.00' }}</td>
216 218
             </tr>
217 219
             <tr>
218 220
               <td :colspan="9" class="head">间接成本合计</td>
@@ -298,7 +300,7 @@
298 300
         </el-descriptions-item>
299 301
         <el-descriptions-item label="利润" :span="3" v-if="$store.getters.roles.includes('leader')">
300 302
           <div class="text-center" style="font-weight:bold;font-size:18px;color:#67C23A">
301
-            {{ profit.toFixed(2) }}
303
+            {{ profit ? profit.toFixed(2) : '0.00' }}
302 304
           </div>
303 305
           <div class="text-center">
304 306
             <!-- (简写:{{ (profit / 10000).toFixed(4) + '万' }}) -->

+ 5
- 5
oa-ui/src/views/flowable/form/budget/carTable.vue 查看文件

@@ -10,7 +10,7 @@
10 10
         </span>
11 11
         <el-button type="success" plain icon="el-icon-plus" @click="openCar = true" size="mini">选择</el-button>
12 12
       </el-form-item>
13
-      <el-form-item  v-if="chooseCar.length != 0">
13
+      <el-form-item v-if="chooseCar.length != 0">
14 14
         <table border="1">
15 15
           <tr>
16 16
             <td :colspan="9" class="head">车辆成本预算</td>
@@ -53,7 +53,7 @@
53 53
           </tr>
54 54
           <tr>
55 55
             <td colspan="8">车辆成本合计</td>
56
-            <td>{{ form.carCost }}</td>
56
+            <td>{{ form.carCost ? form.carCost.toFixed(2) : '0.00' }}</td>
57 57
           </tr>
58 58
         </table>
59 59
       </el-form-item>
@@ -110,7 +110,7 @@ export default {
110 110
   methods: {
111 111
     initForm() {
112 112
       if (this.budgetId != '') {
113
-        listBudgetCar({ pageSize: 100, budgetId:this.budgetId }).then((res) => {
113
+        listBudgetCar({ pageSize: 100, budgetId: this.budgetId }).then((res) => {
114 114
           this.chooseCar = res.rows
115 115
           for (let car of this.chooseCar) {
116 116
             car.fuel = car.car.fuel
@@ -124,7 +124,7 @@ export default {
124 124
         })
125 125
       }
126 126
     },
127
-    initCarCost(){
127
+    initCarCost() {
128 128
       let carCost = 0;
129 129
       for (let car of this.chooseCar) {
130 130
         carCost = carCost + Number(car.expense);
@@ -138,7 +138,7 @@ export default {
138 138
     },
139 139
     calculateCarTotal(car) {
140 140
       let total1 = Number(car.fuel) * Number(car.distance);
141
-      let total2 = (Number(car.insurance) + Number(car.maintenance) + Number(car.dayCost) )* Number(car.days);
141
+      let total2 = (Number(car.insurance) + Number(car.maintenance) + Number(car.dayCost)) * Number(car.days);
142 142
       let sum = (total1 + total2 + Number(car.toll)).toFixed(2);
143 143
       this.$set(car, "depreciation", total2.toFixed(2));
144 144
       this.$set(car, "expense", sum);

+ 3
- 3
oa-ui/src/views/flowable/form/budget/deviceTable.vue 查看文件

@@ -37,7 +37,7 @@
37 37
           </tr>
38 38
           <tr>
39 39
             <td colspan="5">设备成本合计</td>
40
-            <td>{{ form.deviceCost }}</td>
40
+            <td>{{ form.deviceCost ? form.deviceCost.toFixed(2) : '0.00' }}</td>
41 41
           </tr>
42 42
         </table>
43 43
       </el-form-item>
@@ -94,7 +94,7 @@ export default {
94 94
   methods: {
95 95
     initForm() {
96 96
       if (this.budgetId != '') {
97
-        listBudgetDevice({ pageSize: 100, budgetId:this.budgetId }).then((res) => {
97
+        listBudgetDevice({ pageSize: 100, budgetId: this.budgetId }).then((res) => {
98 98
           this.chooseDevice = res.rows;
99 99
           for (let device of this.chooseDevice) {
100 100
             device.brand = device.device.brand
@@ -106,7 +106,7 @@ export default {
106 106
         })
107 107
       }
108 108
     },
109
-    initDeviceCost(){
109
+    initDeviceCost() {
110 110
       let deviceCost = 0;
111 111
       for (let device of this.chooseDevice) {
112 112
         deviceCost = deviceCost + Number(device.depreciation);

+ 1
- 1
oa-ui/src/views/flowable/form/budget/staffTable.vue 查看文件

@@ -37,7 +37,7 @@
37 37
           </tr>
38 38
           <tr>
39 39
             <td colspan="4">人员成本合计</td>
40
-            <td>{{ form.staffCost }}</td>
40
+            <td>{{ form.staffCost ? form.staffCost.toFixed(2) : '0.00' }}</td>
41 41
           </tr>
42 42
         </table>
43 43
       </el-form-item>

正在加载...
取消
保存