UpdateCluster.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. <template>
  2. <base-dialog @cancel="cancelDialog">
  3. <div slot="header">{{params.title}}</div>
  4. <div slot="body">
  5. <dialog-selected-tips :name="$t('dictionary.loadbalancer')" :count="params.data.length" :action="params.title" />
  6. <dialog-table :data="params.data" :columns="params.columns.slice(0, 3)" />
  7. <a-form :form="form.fc" v-bind="formItemLayout">
  8. <a-form-item :label="$t('network.text_19')">
  9. <base-select
  10. remote
  11. showSync
  12. :params="clusterParams"
  13. v-decorator="decorators.cluster_id"
  14. resource="loadbalancerclusters"
  15. :remote-fn="q => ({ filter: `name.contains(${q})` })"
  16. :select-props="{ placeholder: $t('network.text_79') }" />
  17. <!-- <p slot="extra" v-if="this.params.data.length === 1">{{$t('network.text_80')}}<a-button type="link" size="small" @click="createCluster">{{$t('network.text_26')}}</a-button>
  18. </p> -->
  19. </a-form-item>
  20. </a-form>
  21. </div>
  22. <div slot="footer">
  23. <a-button type="primary" @click="handleConfirm" :loading="loading">{{ $t('dialog.ok') }}</a-button>
  24. <a-button @click="cancelDialog">{{ $t('dialog.cancel') }}</a-button>
  25. </div>
  26. </base-dialog>
  27. </template>
  28. <script>
  29. import DialogMixin from '@/mixins/dialog'
  30. import WindowsMixin from '@/mixins/windows'
  31. import expectStatus from '@/constants/expectStatus'
  32. export default {
  33. name: 'LbUpdateCluster',
  34. mixins: [DialogMixin, WindowsMixin],
  35. data () {
  36. return {
  37. loading: false,
  38. form: {
  39. fc: this.$form.createForm(this),
  40. },
  41. decorators: {
  42. cluster_id: [
  43. 'cluster_id',
  44. {
  45. initialValue: this.params.data[0].cluster_id,
  46. rules: [
  47. { required: true, message: this.$t('network.text_79') },
  48. ],
  49. },
  50. ],
  51. },
  52. formItemLayout: {
  53. wrapperCol: {
  54. span: 20,
  55. },
  56. labelCol: {
  57. span: 4,
  58. },
  59. },
  60. }
  61. },
  62. computed: {
  63. clusterParams () {
  64. return {
  65. limit: 0,
  66. scope: this.$store.getters.scope,
  67. zone_id: this.params.data[0].zone_id,
  68. }
  69. },
  70. },
  71. methods: {
  72. createCluster () {
  73. this.createDialog('LoadbalancerclusterCreateDialog', {
  74. title: this.$t('network.text_26'),
  75. })
  76. },
  77. async handleConfirm () {
  78. this.loading = true
  79. try {
  80. const values = await this.form.fc.validateFields()
  81. const ids = this.params.data.map(item => item.id)
  82. await this.params.onManager('batchUpdate', {
  83. id: ids,
  84. steadyStatus: Object.values(expectStatus.lb).flat(),
  85. managerArgs: {
  86. data: values,
  87. },
  88. })
  89. this.params.refresh()
  90. this.cancelDialog()
  91. } catch (err) {
  92. throw err
  93. } finally {
  94. this.loading = false
  95. }
  96. },
  97. },
  98. }
  99. </script>