List.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  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 WindowsMixin from '@/mixins/windows'
  11. import ListMixin from '@/mixins/list'
  12. import { getSetPublicAction, getEnabledSwitchActions } from '@/utils/common/tableActions'
  13. import expectStatus from '@/constants/expectStatus'
  14. import SingleActionsMixin from '../mixins/singleActions'
  15. import ColumnsMixin from '../mixins/columns'
  16. import { filterOptions } from '../utils/filters'
  17. export default {
  18. name: 'PhoneInstantAppList',
  19. mixins: [WindowsMixin, ListMixin, ColumnsMixin, SingleActionsMixin],
  20. props: {
  21. id: String,
  22. getParams: {
  23. type: Object,
  24. default: () => { },
  25. },
  26. },
  27. data () {
  28. return {
  29. list: this.$list.createList(this, {
  30. id: this.id,
  31. resource: 'llm_instant_models',
  32. getParams: this.getParam,
  33. filterOptions,
  34. hiddenColumns: [],
  35. steadyStatus: {
  36. status: expectStatus.mcp ? Object.values(expectStatus.image).flat() : [],
  37. },
  38. }),
  39. groupActions: [
  40. {
  41. label: this.$t('common.create'),
  42. action: () => {
  43. this.createDialog('LlmInstantmodelCreateDialog', {
  44. onManager: this.onManager,
  45. refresh: () => this.list.fetchData(),
  46. })
  47. },
  48. meta: () => {
  49. return {
  50. buttonType: 'primary',
  51. validate: true,
  52. }
  53. },
  54. },
  55. {
  56. label: this.$t('aice.llm_image.import_community'),
  57. action: () => {
  58. this.$router.push({ name: 'LlmInstantmodelImportCommunity' })
  59. },
  60. },
  61. {
  62. label: this.$t('common.batchAction'),
  63. actions: () => {
  64. return [
  65. {
  66. label: this.$t('aice.perform_sync_status'),
  67. action: () => {
  68. const ids = []
  69. for (let i = 0; i < this.list.selectedItems.length; i++) {
  70. ids.push(this.list.selectedItems[i].id)
  71. }
  72. this.onManager('batchPerformAction', {
  73. steadyStatus: ['active'],
  74. id: ids,
  75. managerArgs: {
  76. action: 'syncstatus',
  77. },
  78. })
  79. this.refresh()
  80. },
  81. },
  82. {
  83. label: this.$t('aice.mounted_apps.auto_cache.enable'),
  84. permission: 'llm_instant_models_perform_enable_auto_cache',
  85. action: () => {
  86. this.createDialog('InstantAppAutoCacheDialog', {
  87. data: this.list.selectedItems,
  88. columns: this.columns,
  89. onManager: this.onManager,
  90. refresh: this.refresh,
  91. })
  92. },
  93. meta: () => {
  94. const ret = { validate: true, tooltip: null }
  95. for (let i = 0; i < this.list.selectedItems.length; i++) {
  96. if (!this.list.selectedItems[i].enabled) {
  97. ret.validate = false
  98. return ret
  99. }
  100. }
  101. return ret
  102. },
  103. },
  104. getSetPublicAction(this, {
  105. name: this.$t('aice.mounted_apps'),
  106. scope: 'project',
  107. resource: 'llm_instant_models',
  108. }, {
  109. permission: 'llm_instant_models_perform_public,llm_instant_models_perform_private',
  110. }),
  111. ...getEnabledSwitchActions(this, undefined, ['llm_instant_models_perform_enable', 'llm_instant_models_perform_disable'], {
  112. metas: [
  113. () => {
  114. const isEnable = !!this.list.selectedItems.find(item => item.enabled)
  115. return {
  116. validate: this.list.selectedItems.length && !isEnable,
  117. }
  118. },
  119. () => {
  120. const isDisable = !!this.list.selectedItems.find(item => !item.enabled)
  121. return {
  122. validate: this.list.selectedItems.length && !isDisable,
  123. }
  124. },
  125. ],
  126. resourceName: this.$t('aice.mounted_apps'),
  127. }),
  128. {
  129. label: this.$t('table.action.delete'),
  130. action: () => {
  131. this.createDialog('DeleteResDialog', {
  132. vm: this,
  133. data: this.list.selectedItems,
  134. columns: this.columns,
  135. title: this.$t('table.action.delete'),
  136. name: this.$t('aice.mounted_apps'),
  137. onManager: this.onManager,
  138. })
  139. },
  140. meta: () => {
  141. const ret = { validate: this.list.selected.length }
  142. if (this.list.selectedItems.some(item => !item.can_delete)) {
  143. ret.validate = false
  144. return ret
  145. }
  146. return ret
  147. },
  148. },
  149. ]
  150. },
  151. },
  152. ],
  153. }
  154. },
  155. computed: {
  156. exportDataOptions () {
  157. return {
  158. downloadType: 'local',
  159. title: this.$t('aice.image'),
  160. items: [
  161. { label: 'ID', key: 'id' },
  162. ...this.columns,
  163. ],
  164. }
  165. },
  166. },
  167. created () {
  168. this.initSidePageTab('detail')
  169. this.list.fetchData()
  170. },
  171. methods: {
  172. getParam () {
  173. const ret = {
  174. ...this.getParams,
  175. details: true,
  176. }
  177. return ret
  178. },
  179. handleOpenSidepage (row) {
  180. this.sidePageTriggerHandle(this, 'LlmInstantModelSidePage', {
  181. id: row.id,
  182. resource: 'llm_instant_models',
  183. getParams: this.getParam,
  184. }, {
  185. list: this.list,
  186. })
  187. },
  188. },
  189. }
  190. </script>
  191. <style>
  192. </style>