UpdateIsAutoAlloc.vue 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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.network')" :count="params.data.length" :action="params.title" />
  6. <dialog-table class="mb-2" :data="params.data" :columns="params.columns.slice(0, 3)" />
  7. <a-form :form="form.fc" v-bind="formItemLayout">
  8. <a-form-item :label="$t('common_498')">
  9. <a-switch v-decorator="decorators.is_auto_alloc" />
  10. <template slot="extra">{{$t('common_500')}}</template>
  11. </a-form-item>
  12. </a-form>
  13. </div>
  14. <div slot="footer">
  15. <a-button type="primary" @click="handleConfirm" :loading="loading">{{ $t('dialog.ok') }}</a-button>
  16. <a-button @click="cancelDialog">{{ $t('dialog.cancel') }}</a-button>
  17. </div>
  18. </base-dialog>
  19. </template>
  20. <script>
  21. import DialogMixin from '@/mixins/dialog'
  22. import WindowsMixin from '@/mixins/windows'
  23. export default {
  24. name: 'NetworkUpdateIsAutoAllocDialog',
  25. mixins: [DialogMixin, WindowsMixin],
  26. data () {
  27. return {
  28. loading: false,
  29. form: {
  30. fc: this.$form.createForm(this),
  31. },
  32. decorators: {
  33. is_auto_alloc: [
  34. 'is_auto_alloc',
  35. {
  36. initialValue: this.params.data.length === 1 ? this.params.data[0].is_auto_alloc : this.params.data.every(item => item.is_auto_alloc),
  37. valuePropName: 'checked',
  38. }],
  39. },
  40. formItemLayout: {
  41. wrapperCol: {
  42. span: 19,
  43. },
  44. labelCol: {
  45. span: 5,
  46. },
  47. },
  48. }
  49. },
  50. methods: {
  51. async handleConfirm () {
  52. this.loading = true
  53. try {
  54. const values = await this.form.fc.validateFields()
  55. const ids = this.params.data.map(item => item.id)
  56. if (ids.length > 1) {
  57. await this.params.onManager('batchUpdate', {
  58. ids,
  59. managerArgs: {
  60. data: values,
  61. },
  62. })
  63. } else {
  64. await this.params.onManager('update', {
  65. id: ids[0],
  66. managerArgs: {
  67. data: values,
  68. },
  69. })
  70. }
  71. this.cancelDialog()
  72. } finally {
  73. this.loading = false
  74. }
  75. },
  76. },
  77. }
  78. </script>