amplify.vue 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <template>
  2. <div class="amplify-container">
  3. <AmplifyForm @update-data="updateBatchData" @update-model="updateModelData" @update-params="updateParamsList" :show-select-batch-button="true" />
  4. <div style="margin: 0 auto">
  5. <el-footer>
  6. <el-button class="submit" type="primary" @click="handleSubmit">提交</el-button>
  7. </el-footer>
  8. </div>
  9. </div>
  10. </template>
  11. <script setup lang="tsx">
  12. import { ref } from 'vue'
  13. import AmplifyForm from './AmplifyForm.vue'
  14. import { amplifyApi } from '@/api/modules/demo/data'
  15. let selectedBatchDataList = ref([] as any[])
  16. let model = ref({})
  17. let parameList = ref([] as any[])
  18. // 监听 AmplifyForm 组件传递的数据
  19. const updateBatchData = data => {
  20. selectedBatchDataList.value = data
  21. }
  22. const updateModelData = data => {
  23. model.value = data
  24. }
  25. // 监听 parameList 更新
  26. const updateParamsList = data => {
  27. parameList.value = data
  28. }
  29. // 提交逻辑
  30. const handleSubmit = () => {
  31. let batchNum = selectedBatchDataList.value.map(batch => batch.batchNum).join()
  32. // 将 parameList 中的值也传递到接口
  33. parameList.value.forEach(item => {
  34. item.value = model.value[`${item.agName}`]
  35. })
  36. const data = {
  37. batchNum,
  38. augmentationType: model.value.augmentationType,
  39. taskName: model.value.taskName,
  40. otherParams: parameList.value
  41. }
  42. amplifyApi(data).then(res => {
  43. console.log(res)
  44. })
  45. }
  46. </script>
  47. <style scoped>
  48. .amplify-container {
  49. /* 样式 */
  50. }
  51. </style>