List.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  1. <template>
  2. <page-list
  3. :list="list"
  4. show-tag-columns
  5. show-tag-filter
  6. :columns="templateListColumns || columns"
  7. :single-actions="singleActions"
  8. :group-actions="groupActions"
  9. :showSearchbox="showSearchbox"
  10. :showGroupActions="showGroupActions"
  11. :export-data-options="exportDataOptions"
  12. :show-single-actions="!isTemplate"
  13. :show-page="!isTemplate" />
  14. </template>
  15. <script>
  16. import * as R from 'ramda'
  17. import ListMixin from '@/mixins/list'
  18. import ResTemplateListMixin from '@/mixins/resTemplateList'
  19. import WindowsMixin from '@/mixins/windows'
  20. import expectStatus from '@/constants/expectStatus'
  21. import {
  22. getDomainFilter,
  23. getStatusFilter,
  24. getDescriptionFilter,
  25. getCreatedAtFilter,
  26. getBrandFilter,
  27. getTenantFilter,
  28. getAccountFilter,
  29. getCloudProviderFilter,
  30. } from '@/utils/common/tableFilter'
  31. import GlobalSearchMixin from '@/mixins/globalSearch'
  32. import SingleActionsMixin from '../mixins/singleActions'
  33. import ColumnsMixin from '../mixins/columns'
  34. export default {
  35. name: 'DnsZoneList',
  36. mixins: [WindowsMixin, ListMixin, GlobalSearchMixin, ColumnsMixin, SingleActionsMixin, ResTemplateListMixin],
  37. props: {
  38. id: String,
  39. getParams: {
  40. type: [Function, Object],
  41. },
  42. cloudEnv: String,
  43. },
  44. data () {
  45. return {
  46. list: this.$list.createList(this, {
  47. ctx: this,
  48. id: this.id,
  49. resource: 'dns_zones',
  50. getParams: this.getParam,
  51. isTemplate: this.isTemplate,
  52. templateLimit: this.templateLimit,
  53. steadyStatus: {
  54. status: Object.values(expectStatus.dnszone).flat(),
  55. },
  56. filterOptions: {
  57. id: {
  58. label: this.$t('table.title.id'),
  59. },
  60. name: {
  61. label: this.$t('network.text_21'),
  62. filter: true,
  63. formatter: val => {
  64. return `name.contains("${val}")`
  65. },
  66. },
  67. description: getDescriptionFilter(),
  68. status: getStatusFilter('dnszone'),
  69. brand: getBrandFilter(),
  70. account: getAccountFilter(),
  71. manager: getCloudProviderFilter(),
  72. zone_type: {
  73. label: this.$t('network.text_717'),
  74. dropdown: true,
  75. multiple: true,
  76. items: [
  77. { label: 'PublicZone', key: 'PublicZone' },
  78. { label: 'PrivateZone', key: 'PrivateZone' },
  79. ],
  80. filter: true,
  81. formatter: val => {
  82. return `zone_type.contains("${val}")`
  83. },
  84. },
  85. project_domains: getDomainFilter(),
  86. tenant: getTenantFilter(),
  87. created_at: getCreatedAtFilter(),
  88. },
  89. responseData: this.responseData,
  90. hiddenColumns: ['created_at'],
  91. }),
  92. groupActions: [
  93. {
  94. label: this.$t('network.text_26'),
  95. permission: 'dns_zones_create',
  96. action: () => {
  97. this.$router.push({
  98. name: 'DnsZoneCreate',
  99. params: {
  100. cloudEnv: this.cloudEnv,
  101. },
  102. })
  103. },
  104. meta: () => {
  105. return {
  106. buttonType: 'primary',
  107. }
  108. },
  109. },
  110. {
  111. label: this.$t('compute.text_275'),
  112. actions: () => {
  113. return [
  114. {
  115. label: this.$t('compute.text_283'),
  116. permission: 'dns_zones_perform_set_user_metadata',
  117. action: () => {
  118. this.createDialog('SetTagDialog', {
  119. data: this.list.selectedItems,
  120. columns: this.columns,
  121. onManager: this.onManager,
  122. params: {
  123. resources: 'dns_zones',
  124. },
  125. mode: 'add',
  126. })
  127. },
  128. },
  129. {
  130. label: this.$t('network.text_131'),
  131. permission: 'dns_zones_delete',
  132. action: () => {
  133. this.createDialog('DeleteResDialog', {
  134. vm: this,
  135. title: this.$t('network.text_131'),
  136. name: this.$t('dictionary.dns_zone'),
  137. data: this.list.selectedItems,
  138. columns: this.columns,
  139. onManager: this.onManager,
  140. alert: this.$t('network.text_762'),
  141. })
  142. },
  143. meta: () => {
  144. return {
  145. validate: this.list.allowDelete(),
  146. }
  147. },
  148. },
  149. ]
  150. },
  151. meta: () => {
  152. const ret = {
  153. validate: true,
  154. tooltip: null,
  155. }
  156. ret.validate = this.list.selectedItems.length > 0
  157. if (!ret.validate) return ret
  158. return ret
  159. },
  160. },
  161. ],
  162. }
  163. },
  164. computed: {
  165. exportDataOptions () {
  166. return {
  167. downloadType: 'local',
  168. title: this.$t('dictionary.dns_zone'),
  169. items: [
  170. ...this.columns,
  171. { field: 'manager', title: this.$t('dictionary.cloudprovider') },
  172. ],
  173. }
  174. },
  175. },
  176. watch: {
  177. cloudEnv (val) {
  178. this.$nextTick(() => {
  179. this.list.fetchData(0)
  180. })
  181. },
  182. },
  183. created () {
  184. this.initSidePageTab('dns-zone-detail')
  185. this.list.fetchData()
  186. this.$bus.$on('DnsZoneListSingleRefresh', (...arg) => {
  187. this.list.refresh(...arg)
  188. }, false)
  189. },
  190. methods: {
  191. getParam () {
  192. const ret = {
  193. ...(R.is(Function, this.getParams) ? this.getParams() : this.getParams),
  194. detail: true,
  195. }
  196. if (this.cloudEnv) ret.cloud_env = this.cloudEnv
  197. return ret
  198. },
  199. handleOpenSidepage (row, tab) {
  200. this.sidePageTriggerHandle(this, 'DnsZoneSidePage', {
  201. id: row.id,
  202. resource: 'dns_zones',
  203. }, {
  204. list: this.list,
  205. tab,
  206. })
  207. },
  208. },
  209. }
  210. </script>