| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168 |
- <template>
- <page-card-list
- :list="list"
- :single-actions="singleActions"
- :card-fields="cardFields">
- <template #group-actions-append>
- <div class="d-flex align-items-center ml-3">
- <span class="chart-form-label">{{$t('helm.text_9')}}</span>
- <base-select
- v-model="type"
- :options="typeOpts"
- isDefaultSelect
- :select-props="{ placeholder: $t('helm.text_10') }" />
- <span class="chart-form-labe ml-3">{{$t('helm.text_11')}}</span>
- <base-select
- version="v1"
- v-model="repo"
- resource="repos"
- idKey="name"
- :params="repoParams"
- isDefaultSelect
- :select-props="{ placeholder: $t('helm.text_10') }" />
- </div>
- </template>
- <!-- <template #tool-actions-between>
- <a-button @click="toRepo" type="link" size="small">{{$t('helm.text_12')}}</a-button>
- </template> -->
- <template #tool-actions-append>
- <search-box :options="options" :value="searchValue" @input="search" :placeholder="$t('helm.text_13')" />
- </template>
- </page-card-list>
- </template>
- <script>
- import * as R from 'ramda'
- import WindowsMixin from '@/mixins/windows'
- import { getNameDescriptionTableColumn } from '@/utils/common/tableColumn'
- import ListMixin from '@/mixins/list'
- export default {
- name: 'K8SChartPageList',
- mixins: [WindowsMixin, ListMixin],
- data () {
- return {
- list: this.$list.createList(this, {
- resource: 'charts',
- apiVersion: 'v1',
- idKey: 'name',
- }),
- cardFields: {
- url: 'chart.icon',
- title: 'name',
- desc: 'chart.description',
- description: row => {
- if (row.type === 'internal') return this.$t('helm.text_14')
- if (row.type === 'external') return this.$t('helm.text_15')
- return '-'
- },
- },
- searchValue: {},
- repo: undefined,
- type: this.$route.query.type || 'internal',
- typeOpts: [
- { key: 'internal', label: this.$t('helm.text_14') },
- { key: 'external', label: this.$t('helm.text_15') },
- ],
- options: {
- name: {
- label: this.$t('helm.text_16'),
- },
- // type: {
- // label: '类型',
- // multiple: true,
- // dropdown: true,
- // filter: true,
- // item: [
- // { key: 'internal', label: `${this.$t('dictionary.server')}应用` },
- // { key: 'external', label: `${this.$t('dictionary.server')}应用` },
- // ]
- // }
- },
- columns: [
- getNameDescriptionTableColumn({
- vm: this,
- }),
- {
- field: 'created_at',
- title: this.$t('helm.text_17'),
- formatter: ({ cellValue }) => {
- return this.$moment(cellValue).format()
- },
- },
- ],
- singleActions: [
- {
- label: this.$t('helm.text_18'),
- // permission: 'k8s_charts_create',
- action: (obj) => {
- this.$router.push({
- path: '/k8s-chart/create',
- query: {
- repo: obj.repo,
- name: obj.name,
- type: obj.type,
- },
- })
- },
- meta: () => ({
- buttonType: 'primary',
- }),
- },
- ],
- }
- },
- computed: {
- repoParams () {
- return {
- limit: 0,
- scope: this.$store.getters.scope,
- type: this.type,
- }
- },
- },
- watch: {
- repo (val) {
- this.repoChange(val)
- },
- },
- methods: {
- repoChange (val) {
- if (val) {
- this.list.getParams = { ...this.list.getParams, repo: val }
- } else {
- const params = R.clone(this.list.getParams)
- delete params.repo
- this.list.getParams = params
- }
- this.fetchData()
- },
- fetchData () {
- this.list.data = {}
- if (!this.list.getParams.repo) return
- this.list.fetchData()
- },
- search (val) {
- this.searchValue = val
- if (R.isEmpty(val)) {
- const params = R.clone(this.list.getParams)
- delete params.keyword
- this.list.getParams = params
- this.fetchData()
- return
- }
- this.list.getParams = { ...this.list.getParams, keyword: val.name[0] }
- this.fetchData()
- },
- toRepo () {
- this.$router.push('/k8s-repo')
- },
- },
- }
- </script>
- <style lang="less" scoped>
- .chart-form-label {
- color: rgba(0, 0, 0, 0.85);
- }
- </style>
|