SaveAsInstantModel.vue 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. <template>
  2. <base-dialog @cancel="cancelDialog">
  3. <div slot="header">{{action}}</div>
  4. <div slot="body">
  5. <dialog-selected-tips :name="$t('aice.model')" :count="params.data.length" :action="action" />
  6. <dialog-table :data="params.data" :columns="columns" />
  7. <a-form-model ref="form" :model="form" :rules="rules" :label-col="{ span: 4 }" :wrapper-col="{ span: 15 }">
  8. <a-form-model-item :label="$t('table.title.name')" prop="name">
  9. <a-input v-model="form.name" :placeholder="$t('common.tips.input', [$t('table.title.name')])" />
  10. </a-form-model-item>
  11. </a-form-model>
  12. </div>
  13. <div slot="footer">
  14. <a-button type="primary" @click="handleConfirm" :loading="loading">{{ $t('dialog.ok') }}</a-button>
  15. <a-button @click="cancelDialog">{{ $t('dialog.cancel') }}</a-button>
  16. </div>
  17. </base-dialog>
  18. </template>
  19. <script>
  20. import { mapGetters } from 'vuex'
  21. import DialogMixin from '@/mixins/dialog'
  22. import WindowsMixin from '@/mixins/windows'
  23. import { validateModelForm } from '@/utils/validate'
  24. export default {
  25. name: 'LlmModelSaveInstantModelDialog',
  26. components: {
  27. },
  28. mixins: [DialogMixin, WindowsMixin],
  29. data () {
  30. return {
  31. loading: false,
  32. action: this.params.actionText,
  33. form: {
  34. name: `${this.params.data[0].name}:${this.params.data[0].tag}`,
  35. },
  36. rules: {
  37. name: [
  38. { required: true, message: this.$t('common.tips.input', [this.$t('table.title.name')]) },
  39. ],
  40. },
  41. columns: [
  42. {
  43. field: 'name',
  44. title: this.$t('aice.model'),
  45. },
  46. {
  47. field: 'id',
  48. title: 'ID',
  49. },
  50. {
  51. field: 'tag',
  52. title: 'Tag',
  53. },
  54. {
  55. field: 'size',
  56. title: 'Size',
  57. },
  58. ],
  59. }
  60. },
  61. computed: {
  62. ...mapGetters(['userInfo']),
  63. },
  64. methods: {
  65. async doSubmit () {
  66. return new this.$Manager('llms').performAction({
  67. id: this.params.resId,
  68. action: 'save-instant-model',
  69. data: {
  70. model_id: this.params.data[0].id,
  71. name: this.form.name,
  72. },
  73. })
  74. },
  75. async handleConfirm () {
  76. this.loading = true
  77. try {
  78. await validateModelForm(this.$refs.form)
  79. await this.doSubmit()
  80. this.loading = false
  81. this.cancelDialog()
  82. } catch (error) {
  83. this.loading = false
  84. throw error
  85. }
  86. },
  87. changeAutoStart (val) {
  88. const { checked } = val.target
  89. this.form.fd.auto_start = checked
  90. },
  91. },
  92. }
  93. </script>