ResSync.vue 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  1. <template>
  2. <page-list
  3. :list="list"
  4. :columns="columns"
  5. :group-actions="groupActions"
  6. :single-actions="singleActions"
  7. :export-data-options="exportDataOptions" />
  8. </template>
  9. <script>
  10. import * as R from 'ramda'
  11. import {
  12. getStatusFilter,
  13. } from '@/utils/common/tableFilter'
  14. import {
  15. getStatusTableColumn,
  16. getEnabledTableColumn,
  17. } from '@/utils/common/tableColumn'
  18. import WindowsMixin from '@/mixins/windows'
  19. import ListMixin from '@/mixins/list'
  20. export default {
  21. name: 'ResSyncForCloudaccountSidepage',
  22. mixins: [WindowsMixin, ListMixin],
  23. props: {
  24. id: String,
  25. resId: String,
  26. data: Object,
  27. getParams: [Function, Object],
  28. },
  29. data () {
  30. return {
  31. columns: [
  32. {
  33. field: 'name',
  34. title: this.$t('table.title.name'),
  35. minWidth: 100,
  36. slots: {
  37. default: ({ row }) => {
  38. return row.name
  39. },
  40. },
  41. },
  42. getStatusTableColumn({ statusModule: 'scheduledtask', minWidth: 90 }),
  43. getEnabledTableColumn({ minWidth: 90 }),
  44. {
  45. field: 'operation',
  46. title: this.$t('cloudenv.text_425'),
  47. width: 80,
  48. showOverflow: 'title',
  49. formatter: ({ row }) => {
  50. return this.$t('cloudenvScheduledtaskRuleAction')[row.operation] || '-'
  51. },
  52. },
  53. {
  54. field: 'timer_desc',
  55. title: this.$t('cloudenv.text_427'),
  56. minWidth: 200,
  57. showOverflow: 'title',
  58. formatter: ({ row }) => {
  59. return row.timer_desc || '-'
  60. },
  61. },
  62. ],
  63. list: this.$list.createList(this, {
  64. id: this.id,
  65. apiVersion: 'v1',
  66. resource: 'scheduledtasks',
  67. getParams: this.getParam,
  68. filterOptions: {
  69. name: {
  70. label: this.$t('cloudenv.text_95'),
  71. filter: true,
  72. formatter: val => {
  73. return `name.contains("${val}")`
  74. },
  75. },
  76. enabled: {
  77. label: this.$t('cloudenv.text_97'),
  78. dropdown: true,
  79. items: [
  80. { label: this.$t('cloudenv.text_334'), key: true },
  81. { label: this.$t('cloudenv.text_335'), key: false },
  82. ],
  83. },
  84. status: getStatusFilter('scheduledtask'),
  85. },
  86. hiddenColumns: ['resource_type', 'created_at'],
  87. }),
  88. exportDataOptions: {
  89. items: [
  90. { label: 'ID', key: 'id' },
  91. { label: this.$t('cloudenv.text_95'), key: 'name' },
  92. { label: this.$t('cloudenv.text_97'), key: 'enabled' },
  93. { label: this.$t('cloudenv.text_98'), key: 'status' },
  94. { label: this.$t('cloudenv.text_427'), key: 'timer_desc' },
  95. { label: this.$t('dictionary.project'), key: 'tenant' },
  96. ],
  97. },
  98. groupActions: [
  99. {
  100. label: this.$t('cloudenv.text_104'),
  101. permission: 'scheduledtasks_create',
  102. action: () => {
  103. this.createDialog('ScheduledtaskCreateDialog', {
  104. data: [this.data],
  105. resId: this.resId,
  106. columns: this.columns,
  107. onManager: this.onManager,
  108. callback: () => {
  109. this.refresh()
  110. },
  111. })
  112. },
  113. meta: () => {
  114. return {
  115. buttonType: 'primary',
  116. }
  117. },
  118. },
  119. {
  120. label: this.$t('common.batchAction'),
  121. actions: () => {
  122. return [
  123. {
  124. label: this.$t('cloudenv.text_334'),
  125. permission: 'scheduledtasks_perform_enable',
  126. action: () => {
  127. this.list.batchPerformAction('enable', null, this.list.steadyStatus)
  128. },
  129. meta: () => {
  130. const validate = this.list.selectedItems.length && this.list.selectedItems.every(item => !item.enabled)
  131. return {
  132. validate,
  133. tooltip: !validate ? this.$t('cloudenv.text_429') : '',
  134. }
  135. },
  136. },
  137. {
  138. label: this.$t('cloudenv.text_335'),
  139. permission: 'scheduledtasks_perform_disable',
  140. action: () => {
  141. this.createDialog('ScheduledtaskDisabledDialog', {
  142. columns: this.columns,
  143. data: this.list.selectedItems,
  144. onManager: this.onManager,
  145. })
  146. },
  147. meta: () => {
  148. const validate = this.list.selectedItems.length && this.list.selectedItems.every(item => item.enabled)
  149. return {
  150. validate,
  151. tooltip: !validate ? this.$t('cloudenv.text_430') : '',
  152. }
  153. },
  154. },
  155. {
  156. label: this.$t('cloudenv.text_108'),
  157. permission: 'scheduledtasks_delete',
  158. action: () => {
  159. this.createDialog('DeleteResDialog', {
  160. vm: this,
  161. data: this.list.selectedItems,
  162. columns: this.columns,
  163. title: this.$t('cloudenv.text_108'),
  164. name: this.$t('cloudenv.text_431'),
  165. onManager: this.onManager,
  166. })
  167. },
  168. meta: () => {
  169. return {
  170. validate: this.list.allowDelete(),
  171. }
  172. },
  173. },
  174. ]
  175. },
  176. },
  177. ],
  178. singleActions: [
  179. {
  180. label: this.$t('cloudenv.text_334'),
  181. permission: 'scheduledtasks_perform_enable',
  182. action: (obj) => {
  183. this.createDialog('ScheduledtaskEnabledDialog', {
  184. data: [obj],
  185. columns: this.columns,
  186. onManager: this.onManager,
  187. })
  188. },
  189. meta: (obj) => {
  190. return {
  191. validate: !obj.enabled,
  192. tooltip: obj.enabled ? this.$t('cloudenv.text_455') : '',
  193. }
  194. },
  195. },
  196. {
  197. label: this.$t('cloudenv.text_335'),
  198. permission: 'scheduledtasks_perform_disable',
  199. action: (obj) => {
  200. this.createDialog('ScheduledtaskDisabledDialog', {
  201. data: [obj],
  202. columns: this.columns,
  203. onManager: this.onManager,
  204. })
  205. },
  206. meta: (obj) => {
  207. return {
  208. validate: obj.enabled,
  209. tooltip: !obj.enabled ? this.$t('cloudenv.text_456') : '',
  210. }
  211. },
  212. },
  213. {
  214. label: this.$t('cloudenv.text_108'),
  215. permission: 'scheduledtasks_delete',
  216. action: obj => {
  217. this.createDialog('DeleteResDialog', {
  218. vm: this,
  219. data: [obj],
  220. columns: this.columns,
  221. title: this.$t('cloudenv.text_108'),
  222. onManager: this.onManager,
  223. success: () => {
  224. this.destroySidePages()
  225. },
  226. })
  227. },
  228. meta: (obj) => this.$getDeleteResult(obj),
  229. },
  230. ],
  231. }
  232. },
  233. created () {
  234. this.list.fetchData()
  235. },
  236. methods: {
  237. refresh () {
  238. this.list.fetchData()
  239. },
  240. getParam () {
  241. const ret = {
  242. details: true,
  243. utc_offset: this.$moment().utcOffset() / 60,
  244. ...(R.is(Function, this.getParams) ? this.getParams() : this.getParams),
  245. }
  246. return ret
  247. },
  248. },
  249. }
  250. </script>