List.vue 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. <template>
  2. <page-list
  3. :list="list"
  4. :columns="columns"
  5. :single-actions="singleActions"
  6. :export-data-options="exportDataOptions" />
  7. </template>
  8. <script>
  9. import ColumnsMixin from '../mixins/columns'
  10. import SingleActionsMixin from '../mixins/singleActions'
  11. import WindowsMixin from '@/mixins/windows'
  12. import ListMixin from '@/mixins/list'
  13. export default {
  14. name: 'AnsiblePlaybookList',
  15. mixins: [WindowsMixin, ListMixin, ColumnsMixin, SingleActionsMixin],
  16. props: {
  17. id: String,
  18. getParams: {
  19. type: [Function, Object],
  20. },
  21. },
  22. data () {
  23. return {
  24. list: this.$list.createList(this, {
  25. id: this.id,
  26. resource: 'ansibleplaybooks',
  27. getParams: this.getParams,
  28. filterOptions: {
  29. name: {
  30. label: this.$t('compute.text_228'),
  31. filter: true,
  32. formatter: val => {
  33. return `name.contains("${val}")`
  34. },
  35. },
  36. status: {
  37. label: this.$t('compute.text_229'),
  38. dropdown: true,
  39. multiple: true,
  40. items: (function (t) {
  41. const _items = []
  42. const statusItems = t.$t('status.ansiblePlaybook')
  43. for (const key in statusItems) {
  44. _items.push({
  45. key,
  46. label: statusItems[key],
  47. })
  48. }
  49. return _items
  50. })(this),
  51. filter: true,
  52. formatter: val => {
  53. return `status.in(${val.join(',')})`
  54. },
  55. },
  56. },
  57. }),
  58. exportDataOptions: {
  59. items: [
  60. { label: 'ID', key: 'id' },
  61. { label: this.$t('compute.text_228'), key: 'name' },
  62. { label: this.$t('compute.text_229'), key: 'status' },
  63. { label: this.$t('compute.text_230'), key: 'start_time' },
  64. { label: this.$t('compute.text_231'), key: 'end_time' },
  65. { label: this.$t('dictionary.project'), key: 'tenant' },
  66. ],
  67. },
  68. }
  69. },
  70. created () {
  71. this.initSidePageTab('detail')
  72. this.list.fetchData()
  73. },
  74. methods: {
  75. handleOpenSidepage (row) {
  76. this.sidePageTriggerHandle(this, 'AnsiblePlaybookSidepage', {
  77. id: row.id,
  78. resource: 'ansibleplaybooks',
  79. getParams: this.getParams,
  80. }, {
  81. list: this.list,
  82. })
  83. },
  84. },
  85. }
  86. </script>