List.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. <template>
  2. <page-list
  3. :list="list"
  4. :columns="columns"
  5. :group-actions="groupActions"
  6. :single-actions="singleActions"
  7. :showSearchbox="showSearchbox"
  8. :showGroupActions="showGroupActions"
  9. :export-data-options="exportDataOptions" />
  10. </template>
  11. <script>
  12. import * as R from 'ramda'
  13. import WindowsMixin from '@/mixins/windows'
  14. import ListMixin from '@/mixins/list'
  15. import { getStatusFilter } from '@/utils/common/tableFilter'
  16. import expectStatus from '@/constants/expectStatus'
  17. import ColumnsMixin from '../mixins/columns'
  18. import SingleActionsMixin from '../mixins/singleActions'
  19. export default {
  20. name: 'ProjectSharingList',
  21. components: {
  22. },
  23. mixins: [WindowsMixin, ListMixin, ColumnsMixin, SingleActionsMixin],
  24. props: {
  25. id: String,
  26. getParams: {
  27. type: Object,
  28. default: () => ({}),
  29. },
  30. accountData: Object,
  31. },
  32. data () {
  33. return {
  34. list: this.$list.createList(this, {
  35. id: this.id,
  36. apiVersion: 'v1',
  37. resource: 'billtasks',
  38. getParams: this.getParam,
  39. steadyStatus: Object.values(expectStatus.billtasks).flat(),
  40. filterOptions: {
  41. // account: getAccountFilter({ distinctType: 'field' }),
  42. task_type: {
  43. label: this.$t('cloudenv.task_type'),
  44. dropdown: true,
  45. items: [
  46. { key: 'pull_bill', label: this.$t('cloudenv.task_type.pull_bill') },
  47. { key: 'prepaid_amortizing', label: this.$t('cloudenv.task_type.prepaid_amortizing') },
  48. { key: 'project_sharing', label: this.$t('cloudenv.task_type.project_sharing') },
  49. { key: 'recalculate', label: this.$t('cloudenv.task_type.recalculate') },
  50. { key: 'delete_bill', label: this.$t('cloudenv.task_type.delete_bill') },
  51. ],
  52. },
  53. status: getStatusFilter({ statusModule: 'billtasks' }),
  54. },
  55. }),
  56. groupActions: [
  57. {
  58. label: this.$t('common.create'),
  59. permission: 'billtasks_create',
  60. action: () => {
  61. this.createDialog('BilltasksCreateDialog', {
  62. onManager: this.onManager,
  63. type: 'create_billtask',
  64. data: [this.accountData],
  65. account_id: this.accountData.id,
  66. success: () => {
  67. this.list.refresh()
  68. },
  69. })
  70. },
  71. meta: () => {
  72. return {
  73. buttonType: 'primary',
  74. }
  75. },
  76. },
  77. {
  78. label: this.$t('dialog.cancel'),
  79. permission: 'billtasks_perform_cancel',
  80. action: (obj) => {
  81. this.createDialog('BilltasksCancelDialog', {
  82. vm: this,
  83. data: this.list.selectedItems,
  84. columns: this.columns,
  85. onManager: this.onManager,
  86. })
  87. },
  88. meta: () => {
  89. const ret = { validate: true }
  90. if (!this.list.selectedItems.length) {
  91. ret.validate = false
  92. return ret
  93. }
  94. const canCancel = this.list.selectedItems.every(item => item.status === 'running' || item.status === 'queued')
  95. if (!canCancel) {
  96. ret.validate = false
  97. ret.tooltip = this.$t('cloudenv.billtask_cannot_cancel')
  98. }
  99. return ret
  100. },
  101. },
  102. ],
  103. }
  104. },
  105. computed: {
  106. exportDataOptions () {
  107. const items = this.columns.map(item => {
  108. return {
  109. key: item.field,
  110. label: item.title,
  111. formatter: item.formatter,
  112. }
  113. })
  114. return {
  115. title: this.$t('cloudenv.bill_tasks'),
  116. downloadType: 'local',
  117. items,
  118. }
  119. },
  120. },
  121. created () {
  122. this.fetchData()
  123. this.$bus.$on('refreshBillTaskList', () => {
  124. this.list.refresh()
  125. })
  126. },
  127. methods: {
  128. fetchData () {
  129. this.list.fetchData()
  130. },
  131. getParam () {
  132. const getParams = (R.is(Function, this.getParams) ? this.getParams() : this.getParams)
  133. const ret = {
  134. details: false,
  135. ...getParams,
  136. }
  137. return ret
  138. },
  139. handleOpenSidepage (row) {
  140. this.sidePageTriggerHandle(this, 'BilltaskSidePage', {
  141. id: row.id,
  142. resource: 'billtasks',
  143. getParams: this.getParam,
  144. }, {
  145. list: this.list,
  146. tab: 'event-drawer',
  147. })
  148. },
  149. },
  150. }
  151. </script>