List.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. <template>
  2. <page-list
  3. :list="list"
  4. :columns="columns"
  5. :group-actions="groupActions"
  6. :single-actions="singleActions"
  7. :export-data-options="exportDataOptions" />
  8. </template>
  9. <script>
  10. import * as R from 'ramda'
  11. import WindowsMixin from '@/mixins/windows'
  12. import ListMixin from '@/mixins/list'
  13. import SingleActionsMixin from '../mixins/singleActions'
  14. import ColumnsMixin from '../mixins/columns'
  15. import { filterOptions } from '../utils/filters'
  16. export default {
  17. name: 'PhoneSpecList',
  18. mixins: [WindowsMixin, ListMixin, ColumnsMixin, SingleActionsMixin],
  19. props: {
  20. id: String,
  21. getParams: {
  22. type: Object,
  23. },
  24. },
  25. data () {
  26. return {
  27. list: this.$list.createList(this, {
  28. id: this.id,
  29. resource: 'llm_skus',
  30. getParams: this.getParam,
  31. filterOptions,
  32. hiddenColumns: [],
  33. }),
  34. groupActions: [
  35. {
  36. label: this.$t('common.create'),
  37. action: () => {
  38. if (this.isApplyType) {
  39. this.$router.push('/app-llm-sku/create')
  40. } else {
  41. this.$router.push('/llm-sku/create')
  42. }
  43. },
  44. meta: () => {
  45. return {
  46. buttonType: 'primary',
  47. validate: true,
  48. }
  49. },
  50. },
  51. {
  52. label: this.$t('table.action.delete'),
  53. action: () => {
  54. this.createDialog('DeleteResDialog', {
  55. vm: this,
  56. data: this.list.selectedItems,
  57. columns: this.columns,
  58. title: this.$t('table.action.delete'),
  59. name: this.$t('aice.spec'),
  60. onManager: this.onManager,
  61. })
  62. },
  63. meta: () => {
  64. const ret = { validate: this.list.selected.length }
  65. if (this.list.selectedItems.some(item => !item.can_delete)) {
  66. ret.validate = false
  67. return ret
  68. }
  69. return ret
  70. },
  71. },
  72. ],
  73. }
  74. },
  75. computed: {
  76. isApplyType () {
  77. return this.$route.path.includes('app-llm')
  78. },
  79. exportDataOptions () {
  80. return {
  81. downloadType: 'local',
  82. title: this.$t('aice.spec'),
  83. items: [
  84. { label: 'ID', key: 'id' },
  85. ...this.columns,
  86. ],
  87. }
  88. },
  89. },
  90. created () {
  91. this.initSidePageTab('detail')
  92. this.list.fetchData()
  93. },
  94. methods: {
  95. getParam () {
  96. const ret = {
  97. ...this.getParams,
  98. details: true,
  99. }
  100. ret.filter = R.is(Array, ret.filters) ? ret.filters : (R.is(String, ret.filters) ? [ret.filters] : [])
  101. ret.filter.push(`llm_type.${this.isApplyType ? 'notin' : 'in'}(vllm,ollama)`)
  102. return ret
  103. },
  104. handleOpenSidepage (row) {
  105. this.sidePageTriggerHandle(this, 'LlmSkuSidePage', {
  106. id: row.id,
  107. resource: 'llm_skus',
  108. getParams: this.getParam,
  109. }, {
  110. list: this.list,
  111. })
  112. },
  113. },
  114. }
  115. </script>
  116. <style>
  117. </style>