List.vue 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270
  1. <template>
  2. <page-list
  3. :list="list"
  4. :columns="templateListColumns || columns"
  5. :show-tag-columns="true"
  6. :show-tag-filter="true"
  7. :export-data-options="exportDataOptions"
  8. :group-actions="groupActions"
  9. :showSearchbox="showSearchbox"
  10. :showGroupActions="showGroupActions"
  11. :single-actions="singleActions"
  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 expectStatus from '@/constants/expectStatus'
  20. import {
  21. getFilter,
  22. getStatusFilter,
  23. getBrandFilter,
  24. getAccountFilter,
  25. getTenantFilter,
  26. getDomainFilter,
  27. getDescriptionFilter,
  28. getCreatedAtFilter,
  29. } from '@/utils/common/tableFilter'
  30. import { disableDeleteAction } from '@/utils/common/tableActions'
  31. import WindowsMixin from '@/mixins/windows'
  32. import GlobalSearchMixin from '@/mixins/globalSearch'
  33. import ColumnsMixin from '../mixins/columns'
  34. import SingleActionsMixin from '../mixins/singleActions'
  35. export default {
  36. name: 'FileSystemList',
  37. mixins: [WindowsMixin, ListMixin, GlobalSearchMixin, ColumnsMixin, SingleActionsMixin, ResTemplateListMixin],
  38. props: {
  39. id: String,
  40. cloudEnv: String,
  41. cloudEnvOptions: {
  42. type: Array,
  43. },
  44. getParams: {
  45. type: [Function, Object],
  46. },
  47. hiddenActions: {
  48. type: Array,
  49. default: () => ([]),
  50. },
  51. },
  52. data () {
  53. return {
  54. list: this.$list.createList(this, {
  55. ctx: this,
  56. id: this.id,
  57. resource: 'file_systems',
  58. getParams: this.getParam,
  59. isTemplate: this.isTemplate,
  60. templateLimit: this.templateLimit,
  61. steadyStatus: Object.values(expectStatus.nas).flat(),
  62. filterOptions: {
  63. id: {
  64. label: this.$t('table.title.id'),
  65. },
  66. name: {
  67. label: this.$t('storage.text_40'),
  68. filter: true,
  69. formatter: val => {
  70. return `name.contains("${val}")`
  71. },
  72. },
  73. description: getDescriptionFilter(),
  74. status: getStatusFilter('nas'),
  75. cloudaccount: getAccountFilter(),
  76. brand: getBrandFilter('nas_brands'),
  77. billing_type: getFilter({
  78. field: 'billing_type',
  79. title: this.$t('storage.billing_type'),
  80. items: [
  81. { label: this.$t('billingType.postpaid'), key: 'postpaid' },
  82. { label: this.$t('billingType.prepaid'), key: 'prepaid' },
  83. ],
  84. }),
  85. projects: getTenantFilter(),
  86. project_domains: getDomainFilter(),
  87. created_at: getCreatedAtFilter(),
  88. },
  89. responseData: this.responseData,
  90. hiddenColumns: ['created_at'],
  91. }),
  92. exportDataOptions: {
  93. items: [
  94. { label: 'ID', key: 'id' },
  95. { label: this.$t('storage.text_40'), key: 'name' },
  96. { label: this.$t('storage.text_41'), key: 'status' },
  97. { label: this.$t('storage.capacity'), key: 'capacity' },
  98. { label: this.$t('storage.text_46'), key: 'provider' },
  99. { label: this.$t('storage.filesystem.storage.type'), key: 'storage_type' },
  100. { label: this.$t('storage.filesystem.type'), key: 'file_system_type' },
  101. { label: this.$t('storage.filesystem.protocol'), key: 'protocol' },
  102. { label: this.$t('storage.text_47'), key: 'region' },
  103. { label: this.$t('storage.text_94'), key: 'manager' },
  104. { label: this.$t('storage.billing_type'), key: 'billing_type' },
  105. { label: this.$t('storage.created_at'), key: 'created_at' },
  106. {
  107. label: this.$t('storage.text_48'),
  108. key: 'public_scope',
  109. hidden: () => {
  110. return !this.$store.getters.l3PermissionEnable && (this.$store.getters.scopeResource && this.$store.getters.scopeResource.domain.includes('file_systems'))
  111. },
  112. },
  113. { label: this.$t('storage.text_49', [this.$t('dictionary.domain')]), key: 'project_domain' },
  114. ],
  115. },
  116. groupActions: [
  117. {
  118. label: this.$t('storage.text_31'),
  119. permission: 'file_systems_create',
  120. action: () => {
  121. this.$router.push({
  122. path: '/nas/create',
  123. query: {
  124. type: this.cloudEnv,
  125. },
  126. })
  127. },
  128. meta: () => {
  129. return {
  130. buttonType: 'primary',
  131. validate: !this.cloudEnvEmpty,
  132. tooltip: this.cloudEnvEmpty ? this.$t('common.no_platform_available') : '',
  133. }
  134. },
  135. hidden: () => this.hiddenActions.includes('create'),
  136. },
  137. {
  138. label: this.$t('storage.text_33'),
  139. actions: (obj) => {
  140. const selectedLength = this.list.selectedItems.length
  141. const notSelectedTooltip = selectedLength <= 0 ? this.$t('storage.filesystem.select.at.least.one') : ''
  142. return [
  143. {
  144. label: this.$t('compute.text_283'),
  145. permission: 'file_systems_perform_set_user_metadata',
  146. action: () => {
  147. this.createDialog('SetTagDialog', {
  148. data: this.list.selectedItems,
  149. columns: this.columns,
  150. onManager: this.onManager,
  151. params: {
  152. resources: 'file_systems',
  153. },
  154. mode: 'add',
  155. })
  156. },
  157. },
  158. {
  159. label: this.$t('storage.text_100'),
  160. permission: 'file_systems_perform_syncstatus',
  161. action: () => {
  162. this.onManager('batchPerformAction', {
  163. steadyStatus: ['available'],
  164. managerArgs: {
  165. action: 'syncstatus',
  166. },
  167. })
  168. },
  169. meta: () => ({
  170. validate: selectedLength,
  171. tooltip: notSelectedTooltip,
  172. }),
  173. },
  174. {
  175. label: this.$t('common_641', [this.$t('dictionary.project')]),
  176. action: () => {
  177. this.createDialog('ChangeOwenrDialog', {
  178. data: this.list.selectedItems,
  179. columns: this.columns,
  180. name: this.$t('dictionary.filesystem'),
  181. onManager: this.onManager,
  182. resource: 'file_systems',
  183. })
  184. },
  185. meta: () => {
  186. const ret = {
  187. validate: false,
  188. tooltip: '',
  189. }
  190. if (this.isProjectMode) {
  191. ret.tooltip = this.$t('storage.check_sys_permission', [this.$t('dictionary.domain')])
  192. return ret
  193. }
  194. return {
  195. validate: true,
  196. }
  197. },
  198. },
  199. disableDeleteAction(Object.assign(this, {
  200. permission: 'file_systems_update',
  201. }), {
  202. name: this.$t('dictionary.nas'),
  203. }),
  204. {
  205. label: this.$t('storage.text_36'),
  206. permission: 'file_systems_delete',
  207. action: () => {
  208. this.createDialog('DeleteResDialog', {
  209. vm: this,
  210. data: this.list.selectedItems,
  211. columns: this.columns,
  212. title: this.$t('storage.text_36'),
  213. name: this.$t('dictionary.nas'),
  214. onManager: this.onManager,
  215. })
  216. },
  217. meta: () => {
  218. return {
  219. validate: this.list.allowDelete(),
  220. }
  221. },
  222. },
  223. ]
  224. },
  225. meta: () => {
  226. const selectedLength = this.list.selectedItems.length
  227. return {
  228. validate: selectedLength,
  229. tooltip: '',
  230. }
  231. },
  232. },
  233. ],
  234. }
  235. },
  236. watch: {
  237. cloudEnv (val) {
  238. this.$nextTick(() => {
  239. this.list.fetchData(0)
  240. })
  241. },
  242. },
  243. created () {
  244. this.initSidePageTab('file-system-detail')
  245. this.list.fetchData()
  246. },
  247. methods: {
  248. getParam () {
  249. const ret = {
  250. ...(R.is(Function, this.getParams) ? this.getParams() : this.getParams),
  251. detail: true,
  252. }
  253. if (this.cloudEnv) ret.cloud_env = this.cloudEnv
  254. return ret
  255. },
  256. handleOpenSidepage (row, tab) {
  257. this.sidePageTriggerHandle(this, 'FileSystemSidePage', {
  258. id: row.id,
  259. resource: 'file_systems',
  260. getParams: this.getParam,
  261. }, {
  262. list: this.list,
  263. tab,
  264. })
  265. },
  266. },
  267. }
  268. </script>