index.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. <template>
  2. <div class="amplify-container">
  3. <div class="amplify-main">
  4. <ProForm :items-options="items" :model="model"> </ProForm>
  5. <el-button type="primary" style="margin-left: 50px" @click="showDataSelectionDialog()">选择批次</el-button>
  6. </div>
  7. <el-footer>
  8. <el-button class="submit" type="primary" @click="handleSubmit">提交</el-button>
  9. </el-footer>
  10. <el-dialog v-model="dataDialogVisible" title="选择数据批次" style="width: 70vw">
  11. <el-container>
  12. <el-table :data="batchDataList" tooltip-effect="dark" style="width: 100%; margin-bottom: 30px" @selection-change="handleSelectionChange">
  13. <el-table-column type="selection"> </el-table-column>
  14. <el-table-column prop="batchNum" label="所有批次"> </el-table-column>
  15. <el-table-column prop="batchSize" label="数量"> </el-table-column>
  16. </el-table>
  17. <el-container style="display: flex; flex-direction: column; align-items: center; justify-content: center; margin: 0 30px">
  18. <el-button type="primary" icon="ArrowRightBold" :disabled="!canSelect" @click="clickSelectData"></el-button>
  19. <el-button
  20. type="primary"
  21. style="margin: 10px 0 0"
  22. icon="ArrowLeftBold"
  23. :disabled="!canDeselect"
  24. @click="clickDeselectData"
  25. ></el-button>
  26. </el-container>
  27. <el-table :data="selectedBatchDataList" tooltip-effect="dark" style="width: 100%" @selection-change="handleDeselectionChange">
  28. <el-table-column type="selection"> </el-table-column>
  29. <el-table-column prop="batchNum" label="已选批次"> </el-table-column>
  30. <el-table-column prop="batchSize" label="数量"> </el-table-column>
  31. </el-table>
  32. </el-container>
  33. <template #footer>
  34. <div class="dialog-footer">
  35. <el-button @click="dataDialogVisible = false">取 消</el-button>
  36. <el-button type="primary" @click="dataDialogVisible = false"> 确 定 </el-button>
  37. </div>
  38. </template>
  39. </el-dialog>
  40. </div>
  41. </template>
  42. <script setup lang="tsx" name="amplify">
  43. import { reactive, ref, computed, onMounted } from 'vue'
  44. import ProForm from '@/components/ProForm/index.vue'
  45. import { batchListDataApi, amplifyApi } from '@/api/modules/demo/data'
  46. import { getDictsApi } from '@/api/modules/system/dictData'
  47. let model = {
  48. taskName: 'ssss',
  49. transfer: null
  50. }
  51. const dataDialogVisible = ref(false)
  52. let batchDataList = ref(reactive([] as any[]))
  53. let selectedBatchDataList = ref(reactive([] as any[]))
  54. let tempSelectedBatchDataList = ref(reactive([] as any[]))
  55. let tempDeselectedBatchDataList = ref(reactive([] as any[]))
  56. let parameList = ref(reactive([] as any[]))
  57. let queryBatchData = ref(reactive([] as any[]))
  58. onMounted(() => {
  59. batchListDataApi().then(res => {
  60. // batchDataList.value = reactive(res.data)
  61. queryBatchData.value = reactive(res.data)
  62. })
  63. getDictsApi('expand_data_params').then(res => {
  64. parameList.value = reactive(JSON.parse(res.data[0].remark))
  65. parameList.value.forEach(item => {
  66. items.push({
  67. label: item.name,
  68. prop: item.agName,
  69. span: 12,
  70. rules: [{ required: item.required, message: '不能为空' }],
  71. compOptions: {
  72. elTagName: 'input',
  73. clearable: true,
  74. placeholder: '请输入..'
  75. }
  76. })
  77. model[`${item.agName}`] = item.defaultValue
  78. })
  79. })
  80. })
  81. const handleSelectionChange = data => {
  82. tempSelectedBatchDataList.value = reactive(data)
  83. }
  84. let canSelect = computed(() => {
  85. return tempSelectedBatchDataList.value.length > 0
  86. })
  87. const handleDeselectionChange = data => {
  88. tempDeselectedBatchDataList.value = reactive(data)
  89. }
  90. const clickSelectData = () => {
  91. let set = new Set()
  92. for (let i = 0; i < tempSelectedBatchDataList.value.length; i++) {
  93. set.add(tempSelectedBatchDataList.value[i].batchNum)
  94. selectedBatchDataList.value.push(tempSelectedBatchDataList.value[i])
  95. }
  96. let newArray = [] as any[]
  97. for (let i = 0; i < batchDataList.value.length; i++) {
  98. if (!set.has(batchDataList.value[i].batchNum)) {
  99. newArray.push(batchDataList.value[i])
  100. }
  101. }
  102. batchDataList.value = reactive(newArray)
  103. }
  104. const canDeselect = computed(() => {
  105. return tempDeselectedBatchDataList.value.length > 0
  106. })
  107. const clickDeselectData = () => {
  108. let set = new Set()
  109. for (let i = 0; i < tempDeselectedBatchDataList.value.length; i++) {
  110. set.add(tempDeselectedBatchDataList.value[i].batchNum)
  111. batchDataList.value.push(tempDeselectedBatchDataList.value[i])
  112. }
  113. let newArray = [] as any[]
  114. for (let i = 0; i < selectedBatchDataList.value.length; i++) {
  115. if (!set.has(selectedBatchDataList.value[i].batchNum)) {
  116. newArray.push(selectedBatchDataList.value[i])
  117. }
  118. }
  119. selectedBatchDataList.value = reactive(newArray)
  120. }
  121. const showDataSelectionDialog = () => {
  122. // bIsTrainData.value = isTrainData
  123. if (selectedBatchDataList.value.length === 0) {
  124. batchDataList.value = queryBatchData.value
  125. }
  126. dataDialogVisible.value = true
  127. }
  128. const handleSubmit = () => {
  129. let val = [] as any[]
  130. for (let i = 0; i < selectedBatchDataList.value.length; i++) {
  131. val.push(selectedBatchDataList.value[i].batchNum)
  132. }
  133. const batchNum = val.join()
  134. const otherParams = [] as any[]
  135. parameList.value.map(item => {
  136. item.value = model[`${item.agName}`]
  137. })
  138. console.log('parameList.value', parameList.value)
  139. const data = {
  140. batchNum,
  141. taskName: model.taskName,
  142. otherParams: JSON.stringify(parameList.value)
  143. }
  144. console.log('data', data)
  145. amplifyApi(data).then(res => {
  146. console.log(res)
  147. })
  148. }
  149. let items: ProForm.ItemsOptions[] = reactive([
  150. {
  151. label: '任务名称',
  152. prop: 'taskName',
  153. span: 14,
  154. // labelWidth: '90px',
  155. rules: [{ required: true, message: '请输入任务名称' }],
  156. compOptions: {
  157. elTagName: 'input',
  158. clearable: true,
  159. placeholder: '请输入用户名'
  160. }
  161. }
  162. ])
  163. </script>
  164. <style scoped lang="scss">
  165. @import './index.scss';
  166. </style>