List.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. <template>
  2. <page-list
  3. :list="list"
  4. :columns="filterColumns"
  5. :group-actions="groupActions"
  6. :single-actions="!hiddenSingleActions && singleActions"
  7. :export-data-options="exportDataOptions" />
  8. </template>
  9. <script>
  10. // import { mapGetters } from 'vuex'
  11. import * as R from 'ramda'
  12. import {
  13. getStatusFilter,
  14. getTenantFilter,
  15. getDescriptionFilter,
  16. getCreatedAtFilter,
  17. } from '@/utils/common/tableFilter'
  18. import WindowsMixin from '@/mixins/windows'
  19. import ListMixin from '@/mixins/list'
  20. import SingleActionsMixin from '../mixins/singleActions'
  21. import ColumnsMixin from '../mixins/columns'
  22. // import expectStatus from '@/constants/expectStatus'
  23. export default {
  24. name: 'ScheduledtasksList',
  25. mixins: [WindowsMixin, ListMixin, ColumnsMixin, SingleActionsMixin],
  26. props: {
  27. id: String,
  28. getParams: {
  29. type: Function || Object,
  30. default: {},
  31. },
  32. hiddenColumns: {
  33. type: Array,
  34. default: () => { return [] },
  35. },
  36. hiddenSingleActions: Boolean,
  37. },
  38. data () {
  39. return {
  40. list: this.$list.createList(this, {
  41. id: this.id,
  42. apiVersion: 'v1',
  43. resource: 'scheduledtasks',
  44. getParams: this.getParam,
  45. filterOptions: {
  46. name: {
  47. label: this.$t('cloudenv.text_95'),
  48. filter: true,
  49. formatter: val => {
  50. return `name.contains("${val}")`
  51. },
  52. },
  53. description: getDescriptionFilter(),
  54. enabled: {
  55. label: this.$t('cloudenv.text_97'),
  56. dropdown: true,
  57. items: [
  58. { label: this.$t('cloudenv.text_334'), key: true },
  59. { label: this.$t('cloudenv.text_335'), key: false },
  60. ],
  61. },
  62. status: getStatusFilter('scheduledtask'),
  63. operation: {
  64. label: this.$t('cloudenv.text_425'),
  65. dropdown: true,
  66. items: Object.keys(this.$t('cloudenvScheduledtaskRuleAction')).map((k) => {
  67. return {
  68. label: this.$t('cloudenvScheduledtaskRuleAction')[k],
  69. key: k,
  70. }
  71. }),
  72. },
  73. projects: getTenantFilter(),
  74. created_at: getCreatedAtFilter(),
  75. },
  76. hiddenColumns: ['resource_type', 'created_at'],
  77. }),
  78. exportDataOptions: {
  79. items: [
  80. { label: 'ID', key: 'id' },
  81. { label: this.$t('cloudenv.text_95'), key: 'name' },
  82. { label: this.$t('cloudenv.text_97'), key: 'enabled' },
  83. { label: this.$t('cloudenv.text_98'), key: 'status' },
  84. { label: this.$t('cloudenv.text_425'), key: 'operation' },
  85. { label: this.$t('cloudenv.text_426'), key: 'label_type' },
  86. { label: this.$t('cloudenv.text_427'), key: 'timer_desc' },
  87. { label: this.$t('cloudenv.text_428'), key: 'created_at' },
  88. { label: this.$t('dictionary.project'), key: 'tenant' },
  89. ],
  90. },
  91. groupActions: [
  92. {
  93. label: this.$t('cloudenv.text_104'),
  94. permission: 'scheduledtasks_create',
  95. action: () => {
  96. this.$router.push({
  97. path: '/scheduledtask/create',
  98. })
  99. },
  100. meta: () => {
  101. return {
  102. buttonType: 'primary',
  103. }
  104. },
  105. },
  106. {
  107. label: this.$t('common.batchAction'),
  108. actions: () => {
  109. return [
  110. {
  111. label: this.$t('cloudenv.text_334'),
  112. permission: 'scheduledtasks_perform_enable',
  113. action: () => {
  114. this.list.batchPerformAction('enable', null, this.list.steadyStatus)
  115. },
  116. meta: () => {
  117. const validate = this.list.selectedItems.length && this.list.selectedItems.every(item => !item.enabled)
  118. return {
  119. validate,
  120. tooltip: !validate ? this.$t('cloudenv.text_429') : '',
  121. }
  122. },
  123. },
  124. {
  125. label: this.$t('cloudenv.text_335'),
  126. permission: 'scheduledtasks_perform_disable',
  127. action: () => {
  128. this.createDialog('ScheduledtaskDisabledDialog', {
  129. columns: this.columns,
  130. data: this.list.selectedItems,
  131. onManager: this.onManager,
  132. })
  133. },
  134. meta: () => {
  135. const validate = this.list.selectedItems.length && this.list.selectedItems.every(item => item.enabled)
  136. return {
  137. validate,
  138. tooltip: !validate ? this.$t('cloudenv.text_430') : '',
  139. }
  140. },
  141. },
  142. {
  143. label: this.$t('cloudenv.text_108'),
  144. permission: 'scheduledtasks_delete',
  145. action: () => {
  146. this.createDialog('DeleteResDialog', {
  147. vm: this,
  148. data: this.list.selectedItems,
  149. columns: this.columns,
  150. title: this.$t('cloudenv.text_108'),
  151. name: this.$t('cloudenv.text_431'),
  152. onManager: this.onManager,
  153. })
  154. },
  155. meta: () => {
  156. return {
  157. validate: this.list.allowDelete(),
  158. }
  159. },
  160. },
  161. ]
  162. },
  163. },
  164. ],
  165. }
  166. },
  167. computed: {
  168. filterColumns () {
  169. return this.columns.filter(item => !this.hiddenColumns.includes(item.field))
  170. },
  171. },
  172. created () {
  173. this.initSidePageTab('scheduledtask-detail')
  174. this.list.fetchData()
  175. this.$bus.$on('ScheduledtasksListSingleRefresh', args => {
  176. this.list.singleRefresh(...args)
  177. }, this)
  178. },
  179. methods: {
  180. handleOpenSidepage (row) {
  181. // this.initSidePageTab(initSidePageTab)
  182. this.sidePageTriggerHandle(this, 'ScheduledtaskSidePage', {
  183. id: row.id,
  184. apiVersion: 'v1',
  185. resource: 'scheduledtasks',
  186. getParams: {
  187. details: true,
  188. utc_offset: this.$moment().utcOffset() / 60,
  189. },
  190. }, {
  191. list: this.list,
  192. })
  193. },
  194. getParam () {
  195. return {
  196. details: true,
  197. utc_offset: this.$moment().utcOffset() / 60,
  198. ...(R.is(Function, this.getParams) ? this.getParams() : this.getParams),
  199. }
  200. },
  201. },
  202. }
  203. </script>