UpdateProxySetting.vue 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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.cloudaccount')" :count="params.data.length" :action="params.title" />
  6. <dialog-table :data="params.data" :columns="params.columns.slice(0, 3)" />
  7. <a-form
  8. v-bind="formItemLayout"
  9. :form="form.fc">
  10. <proxy-setting :fc="form.fc" :account="params.data[0]" />
  11. </a-form>
  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 DialogMixin from '@/mixins/dialog'
  21. import WindowsMixin from '@/mixins/windows'
  22. import ProxySetting from '../components/ProxySetting'
  23. export default {
  24. name: 'UpdateProxySettingDialog',
  25. components: {
  26. ProxySetting,
  27. },
  28. mixins: [DialogMixin, WindowsMixin],
  29. data () {
  30. return {
  31. loading: false,
  32. form: {
  33. fc: this.$form.createForm(this),
  34. },
  35. formItemLayout: {
  36. wrapperCol: {
  37. span: 21,
  38. },
  39. labelCol: {
  40. span: 3,
  41. },
  42. },
  43. }
  44. },
  45. methods: {
  46. async handleConfirm () {
  47. this.loading = true
  48. try {
  49. const values = await this.form.fc.validateFields()
  50. values.proxy_setting = values.proxy_setting || 'DIRECT'
  51. const ids = this.params.data.map(item => item.id)
  52. if (ids.length > 1) {
  53. await this.params.onManager('batchUpdate', {
  54. ids,
  55. managerArgs: {
  56. data: values,
  57. },
  58. })
  59. } else {
  60. await this.params.onManager('update', {
  61. id: ids[0],
  62. managerArgs: {
  63. data: values,
  64. },
  65. })
  66. }
  67. this.cancelDialog()
  68. } catch (error) {
  69. throw error
  70. } finally {
  71. this.loading = false
  72. }
  73. },
  74. },
  75. }
  76. </script>