clone.vue 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <template>
  2. <base-dialog @cancel="cancelDialog">
  3. <div slot="header">{{$t('monitor.dashboard.dialog.clone')}}</div>
  4. <div slot="body">
  5. <dialog-selected-tips :name="$t('monitor.dashboard.title')" :count="params.data.length" :action="$t('monitor.dashboard.dialog.clone')" />
  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.clone_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: 'CloneMonitorDashboard',
  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. clone_name: [
  35. 'clone_name',
  36. {
  37. rules: [
  38. { required: true, message: `${this.$t('common.placeholder')}${this.$t('common.name')}` },
  39. ],
  40. },
  41. ],
  42. },
  43. }
  44. },
  45. methods: {
  46. async handleConfirm () {
  47. this.loading = true
  48. try {
  49. const values = await this.form.validateFields()
  50. await new this.$Manager('alertdashboards', 'v1').performAction({
  51. id: this.params.data[0].id,
  52. action: 'clone-dashboard',
  53. data: values,
  54. })
  55. this.loading = false
  56. this.cancelDialog()
  57. this.params.refresh()
  58. } catch (error) {
  59. this.loading = false
  60. throw error
  61. }
  62. },
  63. },
  64. }
  65. </script>
  66. <style scoped>
  67. </style>