ScheduledSettings.vue 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. <template>
  2. <div>
  3. <page-body>
  4. <a-form :form="form.fc" v-bind="formLayout" hideRequiredMark>
  5. <a-form-item :label="$t('cloudenv.text_95')">
  6. <a-input :placeholder="$t('cloudenv.text_190')" v-decorator="decorators.name" />
  7. </a-form-item>
  8. <a-form-item :label="$t('cloudenv.text_360')">
  9. {{ $t('cloudenv.sync_account') }}
  10. </a-form-item>
  11. <scheduled-task-time ref="taskTime" :form="form" />
  12. </a-form>
  13. </page-body>
  14. </div>
  15. </template>
  16. <script>
  17. import ScheduledTaskTime from '@Cloudenv/sections/ScheduledTaskTime'
  18. export default {
  19. name: 'ScheduledSettings',
  20. components: {
  21. ScheduledTaskTime,
  22. },
  23. props: {
  24. account: {
  25. type: Object,
  26. default: () => { return {} },
  27. },
  28. },
  29. data () {
  30. return {
  31. loading: false,
  32. form: {
  33. fc: this.$form.createForm(this),
  34. },
  35. decorators: {
  36. name: [
  37. 'name',
  38. {
  39. initialValue: this.account.name ? `aoto-sync-${this.account.name}-${this.$moment().format('YYYYMMDD')}` : '',
  40. rules: [
  41. { required: true, message: `${this.$t('common.placeholder')}${this.$t('common.name')}` },
  42. ],
  43. },
  44. ],
  45. },
  46. formLayout: {
  47. wrapperCol: {
  48. md: { span: 18 },
  49. xl: { span: 19 },
  50. xxl: { span: 21 },
  51. },
  52. labelCol: {
  53. md: { span: 8 },
  54. xl: { span: 5 },
  55. xxl: { span: 3 },
  56. },
  57. },
  58. }
  59. },
  60. methods: {
  61. generateData (resId, values) {
  62. const params = {
  63. resource_type: 'cloudaccount',
  64. label_type: 'id',
  65. labels: [resId],
  66. operation: 'sync',
  67. generate_name: values.name,
  68. }
  69. this.$refs.taskTime.transformParams(params, values)
  70. return params
  71. },
  72. async handleConfirm (resId) {
  73. this.loading = true
  74. try {
  75. const values = await this.form.fc.validateFields()
  76. const params = this.generateData(resId, values)
  77. await new this.$Manager('scheduledtasks', 'v1').create({ data: params })
  78. this.$router.push('/cloudaccount')
  79. } catch (error) {
  80. throw error
  81. } finally {
  82. this.loading = false
  83. }
  84. },
  85. },
  86. }
  87. </script>