index.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. <template>
  2. <div>
  3. <div v-if="!customerId" style="min-height: 400px;" class="d-flex justify-center align-center">
  4. <div>
  5. <el-input v-model="customerIdModel" placeholder="请输入客户编号"></el-input>
  6. </div>
  7. <m-button class="ml-3" type="orange" @click="onSearchCustomer">查询</m-button>
  8. </div>
  9. <template v-if="customerId">
  10. <m-search class="mb-3" :items="searchItems" v-model="searchValues" @search="onSearch"></m-search>
  11. <m-table
  12. v-loading="loading"
  13. :cardTitle="cardTitle"
  14. :items="items"
  15. :headers="headers"
  16. :page-size="pageInfo.size"
  17. :page-current="pageInfo.current"
  18. :total="total"
  19. @page-change="onPageChange"
  20. @sort-change="onSortChange"
  21. >
  22. <template #employeeProfitSharingRatio="{ row }">
  23. {{ row.employeeProfitSharingRatio * 100 + '%' }}
  24. </template>
  25. <template #actions="{ row }">
  26. <m-button type="primary" text @click="onEdit(row)">分润认领</m-button>
  27. </template>
  28. </m-table>
  29. </template>
  30. <StaffForm ref="staffFormRefs" @success="initPage" />
  31. </div>
  32. </template>
  33. <script>
  34. import { dateFormat } from '@/utils/date'
  35. import { getCustomerProfitSharingClaim, getClaimRatioMax } from '@/api/salary'
  36. import StaffForm from './staffForm'
  37. import { HEADERS } from '../utils'
  38. export default {
  39. name: 'salaryClaimStaff',
  40. components: {
  41. StaffForm
  42. },
  43. data () {
  44. return {
  45. customerIdModel: null,
  46. customerId: null,
  47. searchItems: [
  48. {
  49. label: '月份',
  50. prop: 'month',
  51. type: 'datePicker',
  52. options: {
  53. clearable: false,
  54. type: 'month',
  55. format: 'yyyy-MM',
  56. valueFormat: 'yyyy-MM',
  57. placeholder: '选择查询月份'
  58. }
  59. },
  60. {
  61. label: '客户编号',
  62. prop: 'customerId',
  63. type: 'input',
  64. options: {
  65. clearable: false,
  66. placeholder: '请输入客户编号'
  67. }
  68. },
  69. {
  70. label: '科目名称',
  71. prop: 'subjectName',
  72. type: 'input',
  73. options: {
  74. placeholder: '请输入科目名称'
  75. }
  76. }
  77. ],
  78. searchValues: {
  79. subjectName: null,
  80. customerId: null,
  81. month: dateFormat('YYYY-mm', new Date())
  82. },
  83. headers: HEADERS,
  84. items: [],
  85. total: 0,
  86. pageInfo: {
  87. current: 1,
  88. size: 10
  89. },
  90. orders: [],
  91. loading: false,
  92. cardTitle: null,
  93. maxRatio: 0
  94. }
  95. },
  96. methods: {
  97. async onInit (cardTitle) {
  98. this.cardTitle = cardTitle
  99. this.customerIdModel = null
  100. this.customerId = null
  101. this.searchValues.customerId = null
  102. },
  103. async onSearchCustomer () {
  104. this.customerId = this.customerIdModel
  105. this.searchValues.customerId = this.customerIdModel
  106. this.loading = true
  107. await this.getRatioMax()
  108. this.initPage()
  109. },
  110. async getRatioMax () {
  111. try {
  112. const { data } = await getClaimRatioMax()
  113. this.maxRatio = data
  114. } catch (error) {
  115. this.$message.error(error)
  116. }
  117. },
  118. async initPage () {
  119. this.loading = true
  120. try {
  121. const { data } = await getCustomerProfitSharingClaim({
  122. page: {
  123. ...this.pageInfo,
  124. orders: this.orders
  125. },
  126. ...this.searchValues
  127. })
  128. this.items = data.records
  129. this.total = data.total
  130. } catch (error) {
  131. this.$message.error(error)
  132. } finally {
  133. this.loading = false
  134. }
  135. },
  136. onEdit (item) {
  137. this.$refs.staffFormRefs.open({
  138. ...item,
  139. maxRatio: this.maxRatio
  140. })
  141. },
  142. onSearch () {
  143. if (!this.searchValues.customerId) return this.$message.warning('请输入要查询的客户编码')
  144. this.pageInfo.current = 1
  145. this.initPage()
  146. },
  147. onPageChange (index) {
  148. this.pageInfo.current = index
  149. this.initPage()
  150. },
  151. onSortChange (v) {
  152. this.orders = v
  153. this.initPage()
  154. }
  155. }
  156. }
  157. </script>
  158. <style lang="scss" scoped>
  159. /* 自定义样式 */
  160. </style>