Browse Source

解决了总金额的bug

Lljy-ai 4 years ago
parent
commit
7ead8f988a

+ 0 - 8
fhKeeper/formulahousekeeper/timesheet/config/index.js

@@ -1,15 +1,7 @@
 var path = require('path')
 
-
-<<<<<<< HEAD
 //  var ip = '192.168.2.21'
  var ip = '47.100.37.243'
-=======
- //var ip = '192.168.2.21'
-
- var ip = '47.100.37.243'
-
->>>>>>> 61a8c174a9cdbcafd0f49f7ec68b9c9de601d8c1
 //  47.100.37.243
 // var os = require('os'), ip = '', ifaces = os.networkInterfaces() // 获取本机ip
 // for (var i in ifaces) {

+ 26 - 2
fhKeeper/formulahousekeeper/timesheet/src/views/expense/expense.vue

@@ -87,13 +87,15 @@
               <el-input type="textarea" v-model="addForm.remark"></el-input>
             </el-form-item>
             <!-- 总成本 -->
-            <div style="float: left; line-height: 55px;margin-left:20px">总成本 <el-link disabled v-model="addForm.totalAmount">{{addForm.totalAmount}}</el-link> 元</div>
+            <!-- <div style="float: left; line-height: 55px;margin-left:20px">总成本 <el-link disabled v-model="addForm.totalAmount">{{addForm.totalAmount}}</el-link> 元</div> -->
           </el-form>
         </div>
         <!-- 按钮 -->
         <div class="pu_button">
           <!-- <el-button type="primary" @click="addxz">新增</el-button> -->
           <span class="pu_bu_x" @click="addxz"> <i class="el-icon-circle-plus-outline"></i> 新增填报</span>
+          <span v-if="this.addForm.totalAmount <= 0">总成本 {{this.addForm.totalAmount}} 元</span>
+          <span v-else>总成本 ¥{{this.addForm.totalAmount | numberToCurrency}} 元</span>
           <!-- <span class="pu_bu_t" @click="submits"> <i class="el-icon-circle-check"></i> 提交</span> -->
         </div>
 
@@ -127,7 +129,7 @@
             </el-table-column>
             <el-table-column label="费用金额" width="135px">
               <template slot-scope="scope">
-                <el-input v-model.number="scope.row.amount"></el-input>
+                <el-input v-model.number="scope.row.amount" @blur="shiqu(scope.row.amount)"></el-input>
               </template>
             </el-table-column>
             <el-table-column prop="invoiceNo" label="发票号" width="135px">
@@ -388,6 +390,21 @@ export default {
     this.getList() // 获取单据列表
     this.getProjectList()
   },
+  filters: {
+      numberToCurrency(value) {
+          if (!value) return '0.00'
+          value = value.toFixed(2)
+          const intPart = Math.trunc(value)
+          const intPartFormat = intPart.toString().replace(/(\d)(?=(?:\d{3})+$)/g, '$1,')
+          let floatPart = '.00'
+          const valueArray = value.toString().split('.')
+          if (valueArray.length === 2) { // 有小数部分
+          floatPart = valueArray[1].toString() // 取得小数部分
+          return intPartFormat + '.' + floatPart
+          }
+          return intPartFormat + floatPart
+      }
+  },
   methods: {
     // 单据查看
     downloadByA(val) {
@@ -706,6 +723,13 @@ export default {
         this.$refs.xiaomian.style.width = '85%'
       }
     },
+    // 费用金额失去焦点时触发
+    shiqu(val){
+      console.log(this.addForm);
+      if(val == null || val == undefined) val = 0
+      this.addForm.totalAmount = this.addForm.totalAmount += val
+      console.log(this.addForm.totalAmount);
+    }
   },
 };
 </script>