modelTrainEdit.vue 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <template>
  2. <m-dialog title="创建任务" :visible.sync="show" @submit="handleSubmit">
  3. <MForm ref="form" :items="formItems" v-model="formValues" v-loading="loading"></MForm>
  4. </m-dialog>
  5. </template>
  6. <script>
  7. import MDialog from '@/components/Dialog'
  8. import MForm from '@/components/MForm'
  9. import {
  10. createDataTasks
  11. } from '@/api/dataChart'
  12. export default {
  13. name: 'modelTrainEdit',
  14. components: { MDialog, MForm },
  15. data () {
  16. return {
  17. show: false,
  18. formValues: {},
  19. formItems: [
  20. {
  21. label: '任务名称',
  22. key: 'task_name',
  23. type: 'text',
  24. rules: [v => !!v || '请输入任务名称']
  25. },
  26. {
  27. label: 'PostgreSQL连接字符串',
  28. key: 'db_connection',
  29. type: 'text',
  30. rules: [v => !!v || '请输入PostgreSQL连接字符串']
  31. },
  32. {
  33. label: '数据库名称',
  34. key: 'db_name',
  35. type: 'text',
  36. rules: [v => !!v || '请输入数据库名称']
  37. },
  38. {
  39. label: '业务上下文描述',
  40. key: 'business_context',
  41. type: 'textarea',
  42. rules: [v => !!v || '请输入业务上下文描述']
  43. }
  44. ],
  45. loading: false
  46. }
  47. },
  48. methods: {
  49. open (item) {
  50. this.show = true
  51. },
  52. async handleSubmit () {
  53. const check = this.$refs.form.validate()
  54. if (!check) {
  55. return
  56. }
  57. this.loading = true
  58. try {
  59. await createDataTasks({
  60. ...this.formValues,
  61. enable_sql_validation: true,
  62. enable_llm_repair: true,
  63. modify_original_file: true,
  64. enable_training_data_load: true
  65. })
  66. this.$snackbar.success('创建成功')
  67. this.show = false
  68. this.$emit('success')
  69. } catch (error) {
  70. this.$snackbar.error(error)
  71. } finally {
  72. this.loading = false
  73. }
  74. }
  75. }
  76. }
  77. </script>
  78. <style lang="scss" scoped>
  79. </style>