index.vue 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <template>
  2. <div>
  3. <ListTemplate ref="listTemplateRefs" :card-title="$attrs.label" v-loading="loading">
  4. <template #tool>
  5. <slot name="tool"></slot>
  6. </template>
  7. <template #actions="{ row }">
  8. <m-button text type="primary" size="small" @click="onOpen('salarySolutionDetailsRefs', row)">查看</m-button>
  9. <slot name="actions" :row="row"></slot>
  10. <m-button text type="primary" size="small" @click="onOpen('salarySolutionHistory', row)">版本记录</m-button>
  11. <m-button text type="danger" size="small" @click="onDelete(row)">删除</m-button>
  12. </template>
  13. </ListTemplate>
  14. <SalarySolutionDetails ref="salarySolutionDetailsRefs"></SalarySolutionDetails>
  15. <SalarySolutionHistory ref="salarySolutionHistory">
  16. <template #actions="{ row }">
  17. <m-button type="primary" text @click="$emit('history', row)" size="small">查看规则配置</m-button>
  18. </template>
  19. </SalarySolutionHistory>
  20. </div>
  21. </template>
  22. <script>
  23. import {
  24. deleteSolution,
  25. sendSalaryRelease
  26. } from '@/api/salary'
  27. import ListTemplate from '../components/ListTemplate.vue'
  28. import SalarySolutionHistory from './salarySolutionHistory.vue'
  29. import SalarySolutionDetails from './salarySolutionDetails.vue'
  30. export default {
  31. name: 'salary-solution-list',
  32. components: {
  33. ListTemplate,
  34. SalarySolutionHistory,
  35. SalarySolutionDetails
  36. },
  37. data () {
  38. return {
  39. loading: false
  40. }
  41. },
  42. mounted () {
  43. this.$emit('mounted')
  44. },
  45. methods: {
  46. onInit () {
  47. this.$refs.listTemplateRefs.onInit()
  48. },
  49. async onSend (row) {
  50. this.loading = true
  51. try {
  52. await sendSalaryRelease({ performanceSolutionId: row.performanceSolutionId })
  53. this.$message.success('发布成功')
  54. this.$refs.listTemplateRefs.onInit()
  55. } catch (error) {
  56. this.$message.error(error)
  57. } finally {
  58. this.loading = false
  59. }
  60. },
  61. onOpen (ref, item) {
  62. this.$refs[ref]?.open && this.$refs[ref].open(item)
  63. },
  64. onDelete (item) {
  65. this.$confirm(`确定删除${item.title}吗?`, '提示').then(async () => {
  66. try {
  67. await deleteSolution({ performanceSolutionId: item.performanceSolutionId })
  68. this.$message.success('删除成功')
  69. this.onInit()
  70. } catch (error) {
  71. this.$message.error(error)
  72. }
  73. }).catch(_ => {})
  74. }
  75. }
  76. }
  77. </script>
  78. <style lang="scss" scoped>
  79. </style>