List.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. <template>
  2. <page-card-list
  3. :list="list"
  4. :single-actions="singleActions"
  5. :card-fields="cardFields">
  6. <template #group-actions-append>
  7. <div class="d-flex align-items-center ml-3">
  8. <span class="chart-form-label">{{$t('helm.text_9')}}</span>
  9. <base-select
  10. v-model="type"
  11. :options="typeOpts"
  12. isDefaultSelect
  13. :select-props="{ placeholder: $t('helm.text_10') }" />
  14. <span class="chart-form-labe ml-3">{{$t('helm.text_11')}}</span>
  15. <base-select
  16. version="v1"
  17. v-model="repo"
  18. resource="repos"
  19. idKey="name"
  20. :params="repoParams"
  21. isDefaultSelect
  22. :select-props="{ placeholder: $t('helm.text_10') }" />
  23. </div>
  24. </template>
  25. <!-- <template #tool-actions-between>
  26. <a-button @click="toRepo" type="link" size="small">{{$t('helm.text_12')}}</a-button>
  27. </template> -->
  28. <template #tool-actions-append>
  29. <search-box :options="options" :value="searchValue" @input="search" :placeholder="$t('helm.text_13')" />
  30. </template>
  31. </page-card-list>
  32. </template>
  33. <script>
  34. import * as R from 'ramda'
  35. import WindowsMixin from '@/mixins/windows'
  36. import { getNameDescriptionTableColumn } from '@/utils/common/tableColumn'
  37. import ListMixin from '@/mixins/list'
  38. export default {
  39. name: 'K8SChartPageList',
  40. mixins: [WindowsMixin, ListMixin],
  41. data () {
  42. return {
  43. list: this.$list.createList(this, {
  44. resource: 'charts',
  45. apiVersion: 'v1',
  46. idKey: 'name',
  47. }),
  48. cardFields: {
  49. url: 'chart.icon',
  50. title: 'name',
  51. desc: 'chart.description',
  52. description: row => {
  53. if (row.type === 'internal') return this.$t('helm.text_14')
  54. if (row.type === 'external') return this.$t('helm.text_15')
  55. return '-'
  56. },
  57. },
  58. searchValue: {},
  59. repo: undefined,
  60. type: this.$route.query.type || 'internal',
  61. typeOpts: [
  62. { key: 'internal', label: this.$t('helm.text_14') },
  63. { key: 'external', label: this.$t('helm.text_15') },
  64. ],
  65. options: {
  66. name: {
  67. label: this.$t('helm.text_16'),
  68. },
  69. // type: {
  70. // label: '类型',
  71. // multiple: true,
  72. // dropdown: true,
  73. // filter: true,
  74. // item: [
  75. // { key: 'internal', label: `${this.$t('dictionary.server')}应用` },
  76. // { key: 'external', label: `${this.$t('dictionary.server')}应用` },
  77. // ]
  78. // }
  79. },
  80. columns: [
  81. getNameDescriptionTableColumn({
  82. vm: this,
  83. }),
  84. {
  85. field: 'created_at',
  86. title: this.$t('helm.text_17'),
  87. formatter: ({ cellValue }) => {
  88. return this.$moment(cellValue).format()
  89. },
  90. },
  91. ],
  92. singleActions: [
  93. {
  94. label: this.$t('helm.text_18'),
  95. // permission: 'k8s_charts_create',
  96. action: (obj) => {
  97. this.$router.push({
  98. path: '/k8s-chart/create',
  99. query: {
  100. repo: obj.repo,
  101. name: obj.name,
  102. type: obj.type,
  103. },
  104. })
  105. },
  106. meta: () => ({
  107. buttonType: 'primary',
  108. }),
  109. },
  110. ],
  111. }
  112. },
  113. computed: {
  114. repoParams () {
  115. return {
  116. limit: 0,
  117. scope: this.$store.getters.scope,
  118. type: this.type,
  119. }
  120. },
  121. },
  122. watch: {
  123. repo (val) {
  124. this.repoChange(val)
  125. },
  126. },
  127. methods: {
  128. repoChange (val) {
  129. if (val) {
  130. this.list.getParams = { ...this.list.getParams, repo: val }
  131. } else {
  132. const params = R.clone(this.list.getParams)
  133. delete params.repo
  134. this.list.getParams = params
  135. }
  136. this.fetchData()
  137. },
  138. fetchData () {
  139. this.list.data = {}
  140. if (!this.list.getParams.repo) return
  141. this.list.fetchData()
  142. },
  143. search (val) {
  144. this.searchValue = val
  145. if (R.isEmpty(val)) {
  146. const params = R.clone(this.list.getParams)
  147. delete params.keyword
  148. this.list.getParams = params
  149. this.fetchData()
  150. return
  151. }
  152. this.list.getParams = { ...this.list.getParams, keyword: val.name[0] }
  153. this.fetchData()
  154. },
  155. toRepo () {
  156. this.$router.push('/k8s-repo')
  157. },
  158. },
  159. }
  160. </script>
  161. <style lang="less" scoped>
  162. .chart-form-label {
  163. color: rgba(0, 0, 0, 0.85);
  164. }
  165. </style>