浏览代码

客户分润认领 提交

lifanagju_citu 4 月之前
父节点
当前提交
720c657457
共有 2 个文件被更改,包括 90 次插入19 次删除
  1. 6 1
      src/api/salary.js
  2. 84 18
      src/views/salary/claim/components/form.vue

+ 6 - 1
src/api/salary.js

@@ -161,7 +161,12 @@ export function getSalaryFixedEmployeeStatistics (data) {
   return http.post('/employee/basic/salary/month/trend', data)
 }
 
-// 客户分润认领
+// 客户分润认领 列表
 export function getCustomerProfitSharingClaim (data) {
   return http.post('/customer/performance/page', data)
 }
+
+// 客户分润认领 提交
+export function getCustomerProfitSharingClaimAdd (data) {
+  return http.post('/customer/performance/add/claim', data)
+}

+ 84 - 18
src/views/salary/claim/components/form.vue

@@ -1,11 +1,16 @@
 <template>
   <m-dialog title="分润认领" ref="dialog" @sure="onSure">
+    <m-divider content-position="left">基准分润</m-divider>
+    <m-form :items="showItemForm" v-model="itemData" v-loading="loading"></m-form>
+    <m-divider content-position="left">新增分润认领</m-divider>
     <m-form ref="form" :items="formItems" v-model="formValues" v-loading="loading"></m-form>
   </m-dialog>
 </template>
 
 <script>
 import { mapGetters } from 'vuex'
+import { getCustomerProfitSharingClaimAdd } from '@/api/salary'
+import { getRosterList } from '@/api/system'
 export default {
   name: 'ClaimForm',
   data () {
@@ -17,8 +22,29 @@ export default {
         employeeProfitSharingRatio: null
       },
       itemData: {},
+      showItemForm: [{
+        label: '客户编号',
+        prop: 'customerId',
+        type: 'select',
+        items: [],
+        options: {
+          filterable: true,
+          remote: true,
+          disabled: true
+        }
+      }, {
+        label: '员工分润比例',
+        prop: 'ratioShow',
+        type: 'select',
+        options: {
+          filterable: true,
+          remote: true,
+          disabled: true
+        }
+      }],
       filterLoading: false,
       loading: false,
+      empList: [],
       items: []
     }
   },
@@ -57,7 +83,9 @@ export default {
           handles: {
             change: (v) => {
               const nodes = this.$refs.form.$refs.organizationNo.getCheckedNodes()
-              console.log(nodes[0].data.organizationNo, '选中机构编码')
+              // console.log(nodes, '选中nodes')
+              // console.log(nodes[0].data.organizationNo, '选中机构编码')
+              this.getEmpData(nodes[0]?.data?.organizationNo, nodes[0]?.data?.organizationCategory)
               // this.formValues.organizationNo = nodes[0].data.organizationNo
               // this.formValues.organizationName = nodes[0].data.organizationName
             }
@@ -76,7 +104,7 @@ export default {
             valueKey: 'personnelCode',
             defaultFirstOption: true,
             loading: this.filterLoading,
-            items: []
+            items: this.empList
           },
           // handles: {
           //   change: (v) => {
@@ -88,15 +116,53 @@ export default {
           rules: [
             { required: true, message: '请选择分润员工', trigger: 'change' }
           ]
+        },
+        {
+          label: '分润比例',
+          prop: 'employeeProfitSharingRatio',
+          type: 'number',
+          options: {
+            precision: 0,
+            min: 1,
+            max: 100,
+            placeholder: '请输入分润比例'
+          },
+          rules: [
+            { required: true, message: '请输入分润比例', trigger: 'blur' }
+          ]
         }
         // employeeProfitSharingRatio
       ]
     }
   },
   methods: {
+    async getEmpData (id, organizationCategory) {
+      if (!id) {
+        this.empList = []
+        return
+      }
+      try {
+        this.filterLoading = true
+        const organizationNoKey = organizationCategory === '支行' ? 'parentOrganizationNo' : 'organizationNo'
+        const params = {
+          // entity: { [organizationNoKey]: id },
+          [organizationNoKey]: id,
+          page: { current: 1, size: 9999 }
+        }
+        const { data } = await getRosterList(params)
+        this.empList = data.records
+      } catch (error) {
+        this.empList = []
+        this.$message.error(error)
+      } finally {
+        this.filterLoading = false
+      }
+    },
     async open (item) {
-      console.log(item, '分润认领')
+      // console.log(item, '分润认领')
       this.loading = true
+      this.itemData = item || {}
+      if (item?.employeeProfitSharingRatio) this.itemData.ratioShow = item.employeeProfitSharingRatio * 100
       this.$refs.dialog.open()
       // if (!item) {
       //   this.itemData = {}
@@ -117,6 +183,7 @@ export default {
       //   }
       // }
       this.formValues.serialNumber = item.serialNumber
+      this.formValues.customerId = item.customerId
       this.$nextTick(() => {
         this.$refs.form.clearValidate()
         this.loading = false
@@ -127,21 +194,20 @@ export default {
         if (!valid) {
           return
         }
-        console.log(this.formValues, 'submit')
-        // this.loading = true
-        // try {
-        //   await saveAllocationConfig({
-        //     performanceSalaryManageEmployeeId: this.itemData.performanceSalaryManageEmployeeId,
-        //     ...this.formValues
-        //   })
-        //   this.$refs.dialog.close()
-        //   this.$message.success('操作成功')
-        //   this.$emit('success')
-        // } catch (error) {
-        //   this.$message.error(error)
-        // } finally {
-        //   this.loading = false
-        // }
+        this.loading = true
+        try {
+          await getCustomerProfitSharingClaimAdd({
+            ...this.formValues,
+            employeeProfitSharingRatio: this.formValues.employeeProfitSharingRatio / 100
+          })
+          this.$refs.dialog.close()
+          this.$message.success('操作成功')
+          this.$emit('success')
+        } catch (error) {
+          this.$message.error(error)
+        } finally {
+          this.loading = false
+        }
       })
     }
   }