zhengnaiwen_citu преди 6 месеца
родител
ревизия
f1259c8c75
променени са 3 файла, в които са добавени 52 реда и са изтрити 39 реда
  1. 5 0
      package-lock.json
  2. 1 0
      package.json
  3. 46 39
      src/views/salary/allocation/index.vue

+ 5 - 0
package-lock.json

@@ -3724,6 +3724,11 @@
       "integrity": "sha512-z2S+W9X73hAUUki+N+9Za2lBlun89zigOyGrsax+KUQ6wKW4ZoWpEYBkGhQjwAjjDCkWxhY0VKEhk8wzY7F5cA==",
       "dev": true
     },
+    "decimal.js": {
+      "version": "10.5.0",
+      "resolved": "https://registry.npmmirror.com/decimal.js/-/decimal.js-10.5.0.tgz",
+      "integrity": "sha512-8vDa8Qxvr/+d94hSh5P3IJwI5t8/c0KsMp+g8bNw9cY2icONa5aPfvKeieW1WlG0WQYwwhJ7mjui2xtiePQSXw=="
+    },
     "deep-is": {
       "version": "0.1.4",
       "resolved": "https://registry.npmmirror.com/deep-is/-/deep-is-0.1.4.tgz",

+ 1 - 0
package.json

@@ -14,6 +14,7 @@
     "@mdi/font": "^7.4.47",
     "axios": "^1.7.2",
     "core-js": "^3.8.3",
+    "decimal.js": "^10.5.0",
     "echarts": "^5.4.3",
     "element-ui": "^2.15.14",
     "fs": "0.0.1-security",

+ 46 - 39
src/views/salary/allocation/index.vue

@@ -2,7 +2,12 @@
   <div class="pa-3 white">
     <m-search :items="searchItems" v-model="searchValues" class="mb-3" @search="onSearch">
       <template #button>
-        <div class="ml-3">可发放绩效:{{ statisticObj.residue + ' / ' + statisticObj.total }}</div>
+        <div class="ml-3">
+          <el-tag v-if="query.month">{{ query.month }}</el-tag>
+          <el-tag v-if="query.employeeCategory" class="ml-3">{{ query.employeeCategory }}</el-tag>
+          可发放绩效:<el-tag>{{ totalAllocationPerformanceSalary }}</el-tag>
+          总绩效: <el-tag>{{ totalGrantPerformanceSalary }}</el-tag>
+        </div>
       </template>
     </m-search>
     <m-table
@@ -40,6 +45,7 @@
 
 <script>
 import { dateFormat } from '@/utils/date'
+import Decimal from 'decimal.js'
 import {
   getAllocationPage,
   saveAllocationGrant,
@@ -102,13 +108,15 @@ export default {
       },
       orders: [],
       employeeCategoryItems: [],
-      statisticObj: {
-        residue: null,
-        total: null
-      }
+      totalGrantPerformanceSalary: 0
     }
   },
   computed: {
+    totalAllocationPerformanceSalary () {
+      return Object.values(this.values).reduce((r, v) => {
+        return new Decimal(r).plus(v || 0)
+      }, 0).toFixed(2)
+    },
     searchItems () {
       return [
         {
@@ -204,42 +212,42 @@ export default {
     },
     // 领导分配绩效薪资
     onSave () {
-      this.$confirm('确定提交所有数据?', '提示', {
-        confirmButtonText: '确定',
-        cancelButtonText: '取消',
-        type: 'warning'
-      }).then(async () => {
-        try {
-          await saveAllocationGrant({
-            ...this.query,
-            employeePerformanceGrantItems: Object.keys(this.values).reduce((res, key) => {
-              res.push({
-                employeePerformanceId: key,
-                allocationPerformanceSalary: this.values[key]
-              })
-              return res
-            }, [])
-          })
-          if (this.statisticObj.residue !== this.statisticObj.total) {
-            this.$confirm('当前非完全配额,是否强制提交', '提示', {
-              confirmButtonText: '确定',
-              cancelButtonText: '取消',
-              type: 'warning'
-            }).then(() => {
-              this.onSaveAll(true)
-            }).catch(_ => {
-              this.onSaveAll(false)
-            })
-          } else {
+      try {
+        if (this.totalGrantPerformanceSalary !== this.totalAllocationPerformanceSalary) {
+          this.$confirm('当前非完全配额,是否强制提交', '提示', {
+            confirmButtonText: '确定',
+            cancelButtonText: '取消',
+            type: 'warning'
+          }).then(() => {
+            this.onSaveAll(true)
+          }).catch(_ => {
             this.onSaveAll(false)
-          }
-        } catch (error) {
-          this.$message.error(error)
+          })
+          return
         }
-      }).catch(_ => {})
+        this.$confirm('确定提交所有数据?', '提示', {
+          confirmButtonText: '确定',
+          cancelButtonText: '取消',
+          type: 'warning'
+        }).then(() => {
+          this.onSaveAll(false)
+        }).catch(_ => {})
+      } catch (error) {
+        this.$message.error(error)
+      }
     },
     async onSaveAll (force) {
       try {
+        await saveAllocationGrant({
+          ...this.query,
+          employeePerformanceGrantItems: Object.keys(this.values).reduce((res, key) => {
+            res.push({
+              employeePerformanceId: key,
+              allocationPerformanceSalary: this.values[key]
+            })
+            return res
+          }, [])
+        })
         await saveAllocation({
           ...this.query,
           force: force ? 1 : 0
@@ -266,9 +274,8 @@ export default {
     async onStatistics () {
       try {
         const { data } = await getAllocationStatistics(this.query)
-        const { totalAllocationPerformanceSalary, totalGrantPerformanceSalary } = data
-        this.statisticObj.residue = totalGrantPerformanceSalary - totalAllocationPerformanceSalary
-        this.statisticObj.total = totalGrantPerformanceSalary || 0
+        const { totalGrantPerformanceSalary } = data
+        this.totalGrantPerformanceSalary = totalGrantPerformanceSalary
       } catch (error) {
         this.$message.error(error)
       }