index.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. <template>
  2. <div>
  3. <m-search class="mb-3" :items="searchItems" v-model="searchValues" @search="onSearch"></m-search>
  4. <m-table
  5. :cardTitle="cardTitle"
  6. v-loading="loading"
  7. v-permission="['salary:claim:sharingClaim:list']"
  8. :items="items"
  9. :headers="headers"
  10. :page-size="pageInfo.size"
  11. :page-current="pageInfo.current"
  12. :total="total"
  13. @page-change="onPageChange"
  14. >
  15. <template #employeeProfitSharingRatio="{ row }">
  16. {{ row.employeeProfitSharingRatio * 100 + '%' }}
  17. </template>
  18. <template #actions="{ row }">
  19. <m-button type="primary" text @click="onClaim(row, false)" v-permission="['salary:claim:sharingClaim:claim']">分润认领</m-button>
  20. <m-button type="primary" text @click="onClaim(row, true)" v-permission="['salary:claim:sharingClaim:allot']">专业部门分配</m-button>
  21. </template>
  22. </m-table>
  23. <ClaimForm ref="claimFormRef" @submit="onSubmit" />
  24. </div>
  25. </template>
  26. <script>
  27. import { dateFormat } from '@/utils/date'
  28. import {
  29. getProfitSharingClaim,
  30. getCustomerProfitSharingClaimDeptAdd,
  31. getCustomerProfitSharingClaimAdd
  32. } from '@/api/salary'
  33. import ClaimForm from '../components/form.vue'
  34. export default {
  35. name: 'salaryClaimSharing',
  36. components: {
  37. ClaimForm
  38. },
  39. data () {
  40. return {
  41. searchItems: [
  42. {
  43. label: '月份',
  44. prop: 'month',
  45. type: 'datePicker',
  46. options: {
  47. clearable: false,
  48. type: 'month',
  49. format: 'yyyy-MM',
  50. valueFormat: 'yyyy-MM',
  51. placeholder: '选择查询月份'
  52. }
  53. },
  54. {
  55. label: '客户编号',
  56. prop: 'customerId',
  57. type: 'input',
  58. options: {
  59. placeholder: '请输入客户编号'
  60. }
  61. },
  62. {
  63. label: '科目名称',
  64. prop: 'subjectName',
  65. type: 'input',
  66. options: {
  67. placeholder: '请输入科目名称'
  68. }
  69. }
  70. ],
  71. searchValues: {
  72. subjectName: null,
  73. customerId: null,
  74. month: dateFormat('YYYY-mm', new Date())
  75. },
  76. headers: [
  77. { label: '客户编号', prop: 'customerId', align: 'center' },
  78. { label: '一级科目编码/名称', prop: 'oneLevelSubject', width: 180 },
  79. { label: '二级科目编码/名称', prop: 'twoLevelSubject', width: 180 },
  80. { label: '金额', prop: 'amount' },
  81. { label: '机构名称', prop: 'organizationName' },
  82. { label: '统一认证号1', prop: 'unifiedCertificationNumber1', width: 150 },
  83. { label: '员工姓名1', prop: 'employeeName1', width: 120 },
  84. { label: '统一认证号2', prop: 'unifiedCertificationNumber2', width: 150 },
  85. { label: '员工姓名2', prop: 'employeeName2', width: 120 },
  86. { label: '管户层级标识', prop: 'customerLevelIdentifier' },
  87. { label: '客户类别标识', prop: 'customerCategoryIdentifier' },
  88. { label: '员工分润比例', prop: 'employeeProfitSharingRatio', align: 'center' },
  89. { label: '数据日期', prop: 'dataDate', width: 120 },
  90. { label: '操作', prop: 'actions', fixed: 'right', width: 180 }
  91. ],
  92. items: [],
  93. total: 0,
  94. pageInfo: {
  95. current: 1,
  96. size: 10
  97. },
  98. loading: false,
  99. cardTitle: null,
  100. isDept: false
  101. }
  102. },
  103. methods: {
  104. async onInit (cardTitle) {
  105. if (this.cardTitle) {
  106. this.cardTitle = cardTitle
  107. }
  108. this.loading = true
  109. try {
  110. const { data } = await getProfitSharingClaim({
  111. ...this.pageInfo,
  112. ...this.searchValues
  113. })
  114. this.items = data.records
  115. this.total = data.total
  116. } catch (error) {
  117. this.$message.error(error)
  118. } finally {
  119. this.loading = false
  120. }
  121. },
  122. onClaim (item, isDept) {
  123. this.isDept = isDept
  124. this.$refs.claimFormRef.open(item, isDept)
  125. },
  126. async onSubmit (query) {
  127. this.$refs.claimFormRef.setLoading(true)
  128. const submitApi = this.isDept ? getCustomerProfitSharingClaimDeptAdd : getCustomerProfitSharingClaimAdd
  129. try {
  130. await submitApi(query)
  131. this.$refs.claimFormRef.close()
  132. this.$message.success('操作成功')
  133. this.onInit()
  134. } catch (error) {
  135. this.$message.error(error)
  136. } finally {
  137. this.$refs.claimFormRef.setLoading(false)
  138. }
  139. },
  140. onSearch () {
  141. this.pageInfo.current = 1
  142. this.onInit()
  143. },
  144. onPageChange (index) {
  145. this.pageInfo.current = index
  146. this.onInit()
  147. }
  148. }
  149. }
  150. </script>
  151. <style lang="scss" scoped>
  152. /* 自定义样式 */
  153. </style>