Browse Source

修复云端结算:使用押金结算的值有问题第一的问题

zweizhao 7 years ago
parent
commit
c255b5642d
2 changed files with 37 additions and 34 deletions
  1. 2 12
      pages/main/index/wage_details.vue
  2. 35 22
      pages/main/index/wage_settlement.vue

+ 2 - 12
pages/main/index/wage_details.vue

@@ -1,7 +1,7 @@
 <template>
   <div class="ui inline form" id="wage-details">
     <h3>工资账单明细</h3>
-    <div class="center1" style="padding:0 10px" v-if="item.id">
+    <div class="center1" style="padding:0 10px" v-if="item">
       <h4>
         <a href="#" @click="goDetail">{{item.job.title_count}}</a>
@@ -182,17 +182,7 @@ export default {
     return {
       job_id: '',
       period_id: '',
-      item: {
-        developer_info: {},
-        developer: {},
-        work_hour: {},
-        time: {},
-        job: {},
-        rate: {},
-        salary: {},
-        company_info: {},
-        company: {}
-      }
+      item: null,
     }
   },
   filters: {

+ 35 - 22
pages/main/index/wage_settlement.vue

@@ -80,7 +80,7 @@
         =(({{salary.normal_salary}}+{{salary.probation_salary}})-{{baseSalary}})*(1+{{rate.company_service_fee_rate}}%)
         <span
           v-if="payable"
-        >*(1+{{detail.is_invoice ? rate.company_tax_rate : 0}}%)</span>元
+        >*(1+{{this.isInvoice ? rate.company_tax_rate : 0}}%)</span>元
       </section>
       <section class="container">
         <span class="title">备注说明:</span>
@@ -113,7 +113,12 @@
           </section>
         </section>
       </section>
-      <el-pagination layout="prev, pager, next" :total="total" :page-size="20" @current-change="changePagination"></el-pagination>
+      <el-pagination
+        layout="prev, pager, next"
+        :total="total"
+        :page-size="20"
+        @current-change="changePagination"
+      ></el-pagination>
     </section>
   </section>
 </template>
@@ -156,7 +161,7 @@ export default {
      */
     devServiceRate() {
       let rate = this.rate
-      let result = Number(rate.origin_person_service_fee_rate) - Number(rate.person_service_fee_rate_reduce)
+      let result = +rate.origin_person_service_fee_rate - +rate.person_service_fee_rate_reduce
       return result < 0 ? 0 : result
     },
     /**
@@ -164,7 +169,7 @@ export default {
      */
     devRate() {
       let rate = this.rate
-      return Number(rate.person_tax_rate) + Number(rate.person_tax_service_fee_rate)
+      return +rate.person_tax_rate + +rate.person_tax_service_fee_rate
     },
     /**
      * 薪资
@@ -191,14 +196,14 @@ export default {
      */
     shouldRate() {
       let rate = this.rate
-      return this.keepDecimal(Number(this.baseSalary) * (1 - Number(rate.origin_person_service_fee_rate) / 100 + Number(rate.person_service_fee_rate_reduce) / 100) * this.devRate / 100)
+      return this.keepDecimal(+this.baseSalary * (1 - +rate.origin_person_service_fee_rate / 100 + +rate.person_service_fee_rate_reduce / 100) * this.devRate / 100)
     },
     /**
      * 本月工资
      */
     baseSalary() {
       let salary = this.salary
-      return this.keepDecimal((Number(salary.normal_salary) + Number(salary.probation_salary)) * Number(this.detail.work_hour.work_rate) / 100 - Number(salary.deduction_fee))
+      return this.keepDecimal((+salary.normal_salary + +salary.probation_salary) * +this.detail.work_hour.work_rate / 100 - +salary.deduction_fee)
     },
     /**
      * 退还金额
@@ -207,9 +212,9 @@ export default {
       if(this.is_use_deposit) return 0
 
       let salary = this.salary
-      let isPay = Number(this.detail.company.company_pay) > 0 ? 1 : 0
-      let hasTax = this.payable ? (1 + Number(this.detail.rate.company_tax_rate) / 100) : 1
-      return this.keepDecimal((Number(salary.normal_salary) + Number(salary.probation_salary) - Number(this.baseSalary)) * (1 + Number(this.detail.rate.company_service_fee_rate) / 100) * hasTax) * isPay
+      let isPay = +this.detail.company.company_pay > 0 ? 1 : 0
+      let hasTax = this.payable ? (1 + +this.detail.rate.company_tax_rate / 100) : 1
+      return this.keepDecimal((+salary.normal_salary + +salary.probation_salary - +this.baseSalary) * (1 + +this.detail.rate.company_service_fee_rate / 100) * hasTax) * isPay
     },
     /**
      * 实际工资
@@ -219,7 +224,7 @@ export default {
       let rate = this.detail.rate
       let work_hour = this.detail.work_hour
       let isPayable = this.payable ? (1 - rate.person_tax_rate / 100 - rate.person_tax_service_fee_rate / 100) : 1
-      let personPrice = (((salary.normal_salary - 0) + (salary.probation_salary - 0)) * work_hour.work_rate / 100 - Number(salary.deduction_fee)) * (1 - rate.person_service_fee_rate / 100) * isPayable
+      let personPrice = (((salary.normal_salary - 0) + (salary.probation_salary - 0)) * work_hour.work_rate / 100 - +salary.deduction_fee) * (1 - rate.person_service_fee_rate / 100) * isPayable
 
       return this.keepDecimal(personPrice)
     },
@@ -231,16 +236,22 @@ export default {
       let rate = this.detail.rate
       let work_hour = this.detail.work_hour
       let isPayable = this.payable ? (1 + rate.company_tax_rate / 100) : 1
-      let companyPrice = (((salary.normal_salary - 0) + (salary.probation_salary - 0)) * work_hour.work_rate / 100 - Number(salary.deduction_fee)) * (1 + rate.company_service_fee_rate / 100) * isPayable
+      let companyPrice = (((salary.normal_salary - 0) + (salary.probation_salary - 0)) * work_hour.work_rate / 100 - +salary.deduction_fee) * (1 + rate.company_service_fee_rate / 100) * isPayable
       return this.keepDecimal(companyPrice)
     },
+    /**
+     * is_invoice根据身份取值
+     */
+    isInvoice() {
+      return this.detail[this.isDev ? 'dev_is_invoice' : 'is_invoice']
+    }
   },
   filters: {
     /**
      * 格式化日期
      */
     dateFormat(val) {
-      return new Date(Number(val) * 1000).toLocaleDateString()
+      return new Date(+val * 1000).toLocaleDateString()
     }
   },
   mounted() {
@@ -258,7 +269,7 @@ export default {
     },
     async getReminds(page = currentPage) {
       this.reminds = []
-      let {status, data} = await this.$post('/api/admin/job/getPeriodNote', { period_id: this.period_id, page })
+      let { status, data } = await this.$post('/api/admin/job/getPeriodNote', { period_id: this.period_id, page })
       currentPage = page
       console.log(data)
       if(status) {
@@ -306,14 +317,14 @@ export default {
      * 点击保存或支付
      */
     async jobPeriodSettle(action) {
-      if (this.returnMoney < 0 || this.detail.work_hour.work_rate > 100) {
+      if(this.returnMoney < 0 || this.detail.work_hour.work_rate > 100) {
         this.$message({
           message: '退还金额不能小于0 且 结算比例不能大于100',
           type: 'error'
         })
         return;
       }
-      let res = await this.$post('/api/admin/job/job_period_settle', {
+      let body = {
         // 云端工作周期id(int)
         period_id: this.period_id,
         // 云端工作id(int)
@@ -324,8 +335,6 @@ export default {
         work_rate: this.detail.work_hour.work_rate,
         // 扣减工资(数值,两位小数)
         deduction_fee: this.salary.deduction_fee,
-        // 是否要发票(0-不需要  1-需要)
-        is_invoice: this.payable ? 1 : 0,
         // 退还金额(数值,两位小数)
         return_money: this.returnMoney,
         // 结算工资时的备注(可选)
@@ -333,9 +342,12 @@ export default {
         // 结算时是否使用押金
         is_use_deposit: this.is_use_deposit ? 1 : 0,
         person_service_fee_rate: this.detail.rate.origin_person_service_fee_rate,
-      })
+      }
+      if(this.isDev) body.dev_is_invoice = this.payable ? 1 : 0
+      else body.is_invoice = this.payable ? 1 : 0
+      let res = await this.$post('/api/admin/job/job_period_settle', body)
       if(!res) return
-      if (res.status > 0) {
+      if(res.status > 0) {
         this.$message({
           message: res.info,
           type: 'success'
@@ -344,7 +356,7 @@ export default {
           location.reload()
         }, 1000)
       } else {
-        if (!res.info) {
+        if(!res.info) {
           console.log(res)
         }
         this.$message({
@@ -366,7 +378,8 @@ export default {
       let data = res.data
       env = data.current_env
       this.detail = data
-      this.payable = data.is_invoice === '1'
+      this.isDev = data.is_dev
+      this.payable = this.isInvoice === '1'
       this.is_use_deposit = data.can_use_deposit === '1'
     },
   }
@@ -432,7 +445,7 @@ textarea {
   width: var(--width);
   height: var(--width);
   border-radius: 50%;
-  margin-right: 10px;;
+  margin-right: 10px;
 }
 .remind-right {
   display: flex;