changeName.vue 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <template>
  2. <base-dialog @cancel="cancelDialog">
  3. <div slot="header">{{$t('monitor.edit_name')}}</div>
  4. <div slot="body">
  5. <dialog-selected-tips :name="$t('monitor.dashboard.title')" :count="params.data.length" :action="$t('monitor.edit_name')" />
  6. <dialog-table :data="params.data" :columns="params.columns" />
  7. </div>
  8. <div slot="footer">
  9. <a-form :form="form" v-bind="formItemLayout">
  10. <a-form-item :label="$t('common.name')">
  11. <a-input v-decorator="decorators.name" :placeholder="$t('monitor.text_7')" />
  12. </a-form-item>
  13. </a-form>
  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. export default {
  23. name: 'MonitorDashboardChangeName',
  24. mixins: [DialogMixin, WindowsMixin],
  25. data () {
  26. return {
  27. loading: false,
  28. form: this.$form.createForm(this),
  29. formItemLayout: {
  30. wrapperCol: { span: 20 },
  31. labelCol: { span: 3 },
  32. },
  33. decorators: {
  34. name: [
  35. 'name',
  36. {
  37. initialValue: this.params.data[0].name,
  38. rules: [
  39. { required: true, message: `${this.$t('common.placeholder')}${this.$t('common.name')}` },
  40. ],
  41. },
  42. ],
  43. },
  44. }
  45. },
  46. methods: {
  47. async handleConfirm () {
  48. this.loading = true
  49. try {
  50. const values = await this.form.validateFields()
  51. await new this.$Manager('alertdashboards', 'v1').update({
  52. id: this.params.data[0].id,
  53. data: values,
  54. })
  55. this.loading = false
  56. this.cancelDialog()
  57. this.params.ok(values.name)
  58. } catch (error) {
  59. this.loading = false
  60. throw error
  61. }
  62. },
  63. },
  64. }
  65. </script>
  66. <style scoped>
  67. </style>