BatchConfirm.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. <template>
  2. <base-dialog @cancel="cancelDialog">
  3. <div slot="header">{{action}}</div>
  4. <div slot="body">
  5. <dialog-selected-tips :name="isApplyType ? $t('aice.app_llm') : $t('aice.llm')" :count="params.data.length" :action="action" />
  6. <dialog-table :data="params.data" :columns="columns" />
  7. <!-- <a-form :form="form.fc" v-show="isRestart">
  8. <a-form-item class="mb-0">
  9. <a-checkbox :checked="form.fd.sync_image" @change="changeSyncImage">
  10. {{$t('aice.phone.restart.sync_image.pompt')}}
  11. </a-checkbox>
  12. </a-form-item>
  13. </a-form> -->
  14. </div>
  15. <div slot="footer">
  16. <a-button type="primary" @click="handleConfirm" :loading="loading">{{ $t('dialog.ok') }}</a-button>
  17. <a-button @click="cancelDialog">{{ $t('dialog.cancel') }}</a-button>
  18. </div>
  19. </base-dialog>
  20. </template>
  21. <script>
  22. import { mapGetters } from 'vuex'
  23. import DialogMixin from '@/mixins/dialog'
  24. import WindowsMixin from '@/mixins/windows'
  25. export default {
  26. name: 'LlmBatchConfirmDialog',
  27. mixins: [DialogMixin, WindowsMixin],
  28. data () {
  29. return {
  30. isApplyType: this.$route.path.includes('app-llm'),
  31. loading: false,
  32. action: this.params.actionText,
  33. form: {
  34. fc: this.$form.createForm(this),
  35. fd: {
  36. sync_image: false,
  37. },
  38. },
  39. decorators: {
  40. sync_image: [
  41. 'sync_image',
  42. {
  43. valuePropName: 'checked',
  44. initialValue: false,
  45. },
  46. ],
  47. },
  48. formItemLayout: {
  49. wrapperCol: {
  50. span: 21,
  51. },
  52. labelCol: {
  53. span: 3,
  54. },
  55. },
  56. }
  57. },
  58. computed: {
  59. ...mapGetters(['userInfo']),
  60. columns () {
  61. const showFields = ['name', 'llm_ip', 'status', 'llm_sku']
  62. return this.params.columns.filter((item) => { return showFields.includes(item.field) })
  63. },
  64. isRestart () {
  65. if (this.action === this.$t('aice.action.restart') || this.action === this.$t('aice.action.reset')) {
  66. return true
  67. }
  68. return false
  69. },
  70. },
  71. methods: {
  72. async doShutDownSubmit () {
  73. const data = {}
  74. if (this.form.fd.sync_image) {
  75. data.sync_image = true
  76. }
  77. const ids = this.params.data.map(item => item.id)
  78. return this.params.onManager('batchPerformAction', {
  79. id: ids,
  80. steadyStatus: this.params.steadyStatus,
  81. managerArgs: {
  82. action: this.params.action,
  83. data,
  84. },
  85. })
  86. },
  87. async handleConfirm () {
  88. this.loading = true
  89. try {
  90. await this.doShutDownSubmit()
  91. this.loading = false
  92. this.cancelDialog()
  93. } catch (error) {
  94. this.loading = false
  95. throw error
  96. }
  97. },
  98. changeSyncImage (val) {
  99. const { checked } = val.target
  100. this.form.fd.sync_image = checked
  101. },
  102. },
  103. }
  104. </script>