index.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  1. <template>
  2. <div>
  3. <m-empty v-if="!permission.includes('salary:claim:sharingClaim:list')"></m-empty>
  4. <m-search v-permission="['salary:claim:sharingClaim:list']" class="mb-3" :items="searchItems" v-model="searchValues" @search="onSearch"></m-search>
  5. <m-table
  6. :cardTitle="cardTitle"
  7. v-loading="loading"
  8. v-permission="['salary:claim:sharingClaim:list']"
  9. :items="items"
  10. :headers="headers"
  11. :page-size="pageInfo.size"
  12. :page-current="pageInfo.current"
  13. :total="total"
  14. @page-change="onPageChange"
  15. @sort-change="onSortChange"
  16. >
  17. <template #employeeProfitSharingRatio="{ row }">
  18. {{ row.employeeProfitSharingRatio * 100 + '%' }}
  19. </template>
  20. <template #actions="{ row }">
  21. <m-button type="primary" text @click="onClaim(row, false)" v-if="!majorOrganization">分润认领</m-button>
  22. <m-button type="primary" text @click="onClaim(row, true)" v-if="majorOrganization">专业部门分配</m-button>
  23. </template>
  24. </m-table>
  25. <ClaimForm ref="claimFormRef" @submit="onSubmit" />
  26. </div>
  27. </template>
  28. <script>
  29. import { dateFormat } from '@/utils/date'
  30. import {
  31. getProfitSharingClaim,
  32. getCustomerProfitSharingClaimDeptAdd,
  33. getCustomerProfitSharingClaimAdd,
  34. getAccessOrganization
  35. } from '@/api/salary'
  36. import ClaimForm from '../components/form.vue'
  37. import {
  38. HEADERS
  39. } from '../utils'
  40. import { mapGetters } from 'vuex'
  41. export default {
  42. name: 'salaryClaimSharing',
  43. components: {
  44. ClaimForm
  45. },
  46. data () {
  47. return {
  48. searchValues: {
  49. manageOrganizationNo: null,
  50. subjectName: null,
  51. customerId: null,
  52. month: dateFormat('YYYY-mm', new Date())
  53. },
  54. headers: HEADERS,
  55. items: [],
  56. total: 0,
  57. pageInfo: {
  58. current: 1,
  59. size: 10
  60. },
  61. orders: [],
  62. loading: false,
  63. cardTitle: null,
  64. isDept: false,
  65. organizationItems: [],
  66. defaultManageOrganization: {},
  67. majorOrganization: false
  68. }
  69. },
  70. computed: {
  71. ...mapGetters(['permission']),
  72. searchItems () {
  73. return [
  74. {
  75. label: '机构名称',
  76. prop: 'manageOrganizationNo',
  77. type: 'select',
  78. options: {
  79. clearable: false,
  80. placeholder: '请选择机构名称',
  81. items: this.organizationItems,
  82. labelValue: 'organizationNo'
  83. }
  84. },
  85. {
  86. label: '月份',
  87. prop: 'month',
  88. type: 'datePicker',
  89. options: {
  90. clearable: false,
  91. type: 'month',
  92. format: 'yyyy-MM',
  93. valueFormat: 'yyyy-MM',
  94. placeholder: '选择查询月份'
  95. }
  96. },
  97. {
  98. label: '客户编号',
  99. prop: 'customerId',
  100. type: 'input',
  101. options: {
  102. placeholder: '请输入客户编号'
  103. }
  104. },
  105. {
  106. label: '科目名称',
  107. prop: 'subjectName',
  108. type: 'input',
  109. options: {
  110. placeholder: '请输入科目名称'
  111. }
  112. }
  113. ]
  114. }
  115. },
  116. methods: {
  117. async onInit (cardTitle) {
  118. if (this.cardTitle) {
  119. this.cardTitle = cardTitle
  120. }
  121. const data = await this.onGetDeptList()
  122. if (!data) {
  123. return
  124. }
  125. this.searchValues.manageOrganizationNo = data[0].organizationNo
  126. this.defaultManageOrganization = data[0]
  127. this.majorOrganization = data[0].majorOrganization
  128. this.getPage()
  129. },
  130. async getPage () {
  131. if (!this.searchValues.manageOrganizationNo) {
  132. this.$message.warning('请选择机构')
  133. return
  134. }
  135. this.loading = true
  136. try {
  137. const { data } = await getProfitSharingClaim({
  138. page: {
  139. ...this.pageInfo,
  140. orders: this.orders
  141. },
  142. ...this.searchValues
  143. })
  144. this.majorOrganization = this.organizationItems.find(e => e.organizationNo === this.searchValues.manageOrganizationNo).majorOrganization
  145. this.items = data.records
  146. this.total = data.total
  147. } catch (error) {
  148. this.$message.error(error)
  149. } finally {
  150. this.loading = false
  151. }
  152. },
  153. async onGetDeptList () {
  154. try {
  155. const { data } = await getAccessOrganization()
  156. if (!data.length) {
  157. return
  158. }
  159. this.organizationItems = data.map(e => {
  160. return {
  161. ...e,
  162. label: `${e.parentOrganizationName} - ${e.organizationName}`
  163. }
  164. })
  165. return data
  166. } catch (error) {
  167. this.$message.error(error)
  168. }
  169. },
  170. onClaim (item, isDept) {
  171. this.isDept = isDept
  172. this.$refs.claimFormRef.open(item, isDept)
  173. },
  174. async onSubmit (query) {
  175. this.$refs.claimFormRef.setLoading(true)
  176. const submitApi = this.isDept ? getCustomerProfitSharingClaimDeptAdd : getCustomerProfitSharingClaimAdd
  177. try {
  178. await submitApi(query)
  179. this.$refs.claimFormRef.close()
  180. this.$message.success('操作成功')
  181. this.getPage()
  182. } catch (error) {
  183. this.$message.error(error)
  184. } finally {
  185. this.$refs.claimFormRef.setLoading(false)
  186. }
  187. },
  188. onSearch () {
  189. if (!this.searchValues.manageOrganizationNo) {
  190. this.searchValues.manageOrganizationNo = this.defaultManageOrganization.organizationNo
  191. }
  192. this.pageInfo.current = 1
  193. this.getPage()
  194. },
  195. onPageChange (index) {
  196. this.pageInfo.current = index
  197. this.getPage()
  198. },
  199. onSortChange (v) {
  200. this.orders = v
  201. this.getPage()
  202. }
  203. }
  204. }
  205. </script>
  206. <style lang="scss" scoped>
  207. /* 自定义样式 */
  208. </style>