List.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  1. <template>
  2. <page-list
  3. :list="list"
  4. :columns="templateListColumns || columns"
  5. :show-tag-columns="true"
  6. :show-tag-filter="true"
  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 { mapGetters } from 'vuex'
  18. import ListMixin from '@/mixins/list'
  19. import ResTemplateListMixin from '@/mixins/resTemplateList'
  20. import WindowsMixin from '@/mixins/windows'
  21. import { getTenantFilter, getDomainFilter, getDescriptionFilter, getCreatedAtFilter } from '@/utils/common/tableFilter'
  22. import GlobalSearchMixin from '@/mixins/globalSearch'
  23. import ColumnsMixin from '../mixins/columns'
  24. import SingleActionsMixin from '../mixins/singleActions'
  25. export default {
  26. name: 'LbcertList',
  27. mixins: [WindowsMixin, ListMixin, GlobalSearchMixin, ColumnsMixin, SingleActionsMixin, ResTemplateListMixin],
  28. props: {
  29. id: String,
  30. getParams: {
  31. type: [Function, Object],
  32. },
  33. },
  34. data () {
  35. return {
  36. list: this.$list.createList(this, {
  37. ctx: this,
  38. id: this.id,
  39. resource: 'loadbalancercertificates',
  40. getParams: this.getParam,
  41. isTemplate: this.isTemplate,
  42. templateLimit: this.templateLimit,
  43. filterOptions: {
  44. id: {
  45. label: this.$t('table.title.id'),
  46. },
  47. name: {
  48. label: this.$t('network.text_317'),
  49. filter: true,
  50. formatter: val => {
  51. return `name.contains(${val})`
  52. },
  53. },
  54. description: getDescriptionFilter(),
  55. projects: getTenantFilter(),
  56. project_domains: getDomainFilter(),
  57. created_at: getCreatedAtFilter(),
  58. },
  59. responseData: this.responseData,
  60. hiddenColumns: ['created_at'],
  61. }),
  62. exportDataOptions: {
  63. items: [
  64. { label: 'ID', key: 'id' },
  65. { label: this.$t('network.text_317'), key: 'name' },
  66. { label: this.$t('network.text_318'), key: 'common_name' },
  67. { label: this.$t('network.text_319'), key: 'not_after' },
  68. { label: this.$t('network.text_320'), key: 'subject_alternative_names' },
  69. { label: this.$t('dictionary.project'), key: 'tenant' },
  70. { label: this.$t('common.createdAt'), key: 'created_at' },
  71. ],
  72. },
  73. groupActions: [
  74. {
  75. label: this.$t('network.text_26'),
  76. permission: 'lb_loadbalancercertificates_create',
  77. action: () => {
  78. this.createDialog('LbcertsCreateDialog', {
  79. title: this.$t('network.text_321'),
  80. data: this.list.selectedItems,
  81. onManager: this.onManager,
  82. })
  83. },
  84. meta: () => {
  85. return {
  86. buttonType: 'primary',
  87. // validate: this.hasService(this.userInfo, 'lbagent') || this.hasHypervisors(['Aliyun', 'Qcloud', 'Huawei', 'Aws']),
  88. }
  89. },
  90. },
  91. {
  92. label: this.$t('storage.text_33'),
  93. actions: (obj) => {
  94. return [
  95. {
  96. label: this.$t('compute.text_283'),
  97. permission: 'lb_loadbalancercertificates_perform_set_user_metadata',
  98. action: () => {
  99. this.createDialog('SetTagDialog', {
  100. data: this.list.selectedItems,
  101. columns: this.columns,
  102. onManager: this.onManager,
  103. params: {
  104. resources: 'lb_loadbalancercertificates',
  105. },
  106. mode: 'add',
  107. })
  108. },
  109. },
  110. {
  111. label: this.$t('network.text_131'),
  112. permission: 'lb_loadbalancercertificates_delete',
  113. action: () => {
  114. this.createDialog('DeleteResDialog', {
  115. vm: this,
  116. title: this.$t('network.text_131'),
  117. alert: this.$t('network.text_768'),
  118. data: this.list.selectedItems,
  119. columns: this.columns,
  120. onManager: this.onManager,
  121. name: this.$t('network.text_143'),
  122. })
  123. },
  124. meta: () => {
  125. return {
  126. validate: this.list.allowDelete(),
  127. }
  128. },
  129. },
  130. ]
  131. },
  132. meta: () => {
  133. const selectedLength = this.list.selectedItems.length
  134. return {
  135. validate: selectedLength,
  136. tooltip: '',
  137. }
  138. },
  139. },
  140. ],
  141. }
  142. },
  143. computed: {
  144. ...mapGetters(['userInfo', 'capability']),
  145. },
  146. created () {
  147. this.initSidePageTab('lbcert-detail')
  148. this.list.fetchData()
  149. },
  150. methods: {
  151. getParam () {
  152. const ret = {
  153. ...(R.is(Function, this.getParams) ? this.getParams() : this.getParams),
  154. }
  155. return ret
  156. },
  157. hasService ($userInfo, service) {
  158. if ($userInfo && $userInfo.services && $userInfo.services.length) {
  159. const results = $userInfo.services.filter(item => {
  160. return item.type === service && item.status === true
  161. })
  162. return results && results.length > 0
  163. }
  164. return false
  165. },
  166. hasHypervisors (hypervisors) {
  167. for (let i = 0, len = hypervisors.length; i < len; i++) {
  168. if ((this.capability.loadbalancer_engine_brands || []).indexOf(hypervisors[i]) !== -1) {
  169. return true
  170. }
  171. }
  172. return false
  173. },
  174. handleOpenSidepage (row) {
  175. this.sidePageTriggerHandle(this, 'LbcertSidePage', {
  176. id: row.id,
  177. resource: 'loadbalancercertificates',
  178. getParams: this.getParam,
  179. }, {
  180. list: this.list,
  181. })
  182. },
  183. },
  184. }
  185. </script>
  186. <style scoped lang="less">
  187. @import '~@/styles/less/theme';
  188. .status-dot {
  189. width: 8px;
  190. height: 8px;
  191. border-radius: 50%;
  192. position: relative;
  193. display: inline-flex;
  194. }
  195. .success {
  196. background-color: @success-color;
  197. }
  198. .danger {
  199. background-color: @error-color;
  200. }
  201. .info {
  202. background-color: @normal-color;
  203. }
  204. .warning {
  205. background-color: @warning-color;
  206. }
  207. </style>