singleActions.js 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. import { mapGetters } from 'vuex'
  2. import i18n from '@/locales'
  3. export default {
  4. computed: mapGetters(['isAdminMode']),
  5. created () {
  6. this.singleActions = [
  7. {
  8. label: i18n.t('cloudenv.text_383'),
  9. permission: 'schedpolicies_update',
  10. action: (obj) => {
  11. this.createDialog('UpdateSchedpolicyDialog', {
  12. data: [obj],
  13. columns: this.columns,
  14. title: i18n.t('cloudenv.text_383'),
  15. onManager: this.onManager,
  16. })
  17. },
  18. },
  19. {
  20. label: i18n.t('cloudenv.text_311'),
  21. actions: obj => {
  22. return [
  23. {
  24. label: i18n.t('cloudenv.text_334'),
  25. permission: 'schedpolicies_update',
  26. action: obj => {
  27. this.onManager('update', {
  28. id: obj.id,
  29. managerArgs: {
  30. data: { enabled: true },
  31. },
  32. })
  33. },
  34. meta: obj => {
  35. return {
  36. validate: !obj.enabled,
  37. }
  38. },
  39. },
  40. {
  41. label: i18n.t('cloudenv.text_335'),
  42. permission: 'schedpolicies_update',
  43. action: obj => {
  44. this.onManager('update', {
  45. id: obj.id,
  46. managerArgs: {
  47. data: { enabled: false },
  48. },
  49. })
  50. },
  51. meta: obj => {
  52. return {
  53. validate: obj.enabled,
  54. }
  55. },
  56. },
  57. {
  58. label: i18n.t('cloudenv.text_108'),
  59. permission: 'schedpolicies_delete',
  60. action: () => {
  61. this.createDialog('DeleteResDialog', {
  62. vm: this,
  63. data: [obj],
  64. columns: this.columns,
  65. title: i18n.t('cloudenv.text_415'),
  66. name: this.$t('dictionary.schedpolicie'),
  67. onManager: this.onManager,
  68. })
  69. },
  70. meta: () => {
  71. return {
  72. validate: obj.can_delete,
  73. }
  74. },
  75. },
  76. ]
  77. },
  78. },
  79. ]
  80. },
  81. }