cloneChart.vue 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <template>
  2. <base-dialog @cancel="cancelDialog">
  3. <div slot="header">{{$t('monitor.dashboard.dialog.project.clone')}}</div>
  4. <div slot="body">
  5. <dialog-selected-tips :name="$t('monitor.dashboard.dialog.project.title')" :count="params.data.length" :action="$t('monitor.dashboard.dialog.project.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_panel_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: 'CloneMonitorDashboardChart',
  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_panel_name: [
  35. 'clone_panel_name',
  36. {
  37. initialValue: this.params.panelName || '',
  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. const params = {
  52. panel_id: this.params.data[0].id,
  53. ...values,
  54. }
  55. await new this.$Manager('alertdashboards', 'v1').performAction({
  56. id: this.params.data[0].dashboard_id,
  57. action: 'clone-panel',
  58. data: params,
  59. })
  60. this.loading = false
  61. this.cancelDialog()
  62. this.params.refresh()
  63. } catch (error) {
  64. this.loading = false
  65. throw error
  66. }
  67. },
  68. },
  69. }
  70. </script>
  71. <style scoped>
  72. </style>