ソースを参照

feat: 数据增广代码回滚

Suuuuuukang 9 ヶ月 前
コミット
5d24f249bf

+ 8 - 0
src/views/demo/data/index.vue

@@ -12,6 +12,8 @@
         <el-button type="primary" v-auth="['demo:data:add']" :icon="CirclePlus" @click="openDialog(1, '数据新增')"> 新增 </el-button>
         <el-button type="primary" v-auth="['demo:data:import']" :icon="Upload" plain @click="batchAdd"> 导入数据集 </el-button>
         <el-button type="primary" v-auth="['demo:data:export']" :icon="Download" plain @click="downloadFile(scope.selectedListIds)"> 导出 </el-button>
+        <el-button type="primary" v-auth="['system:user:add']" :icon="CirclePlus" @click="dataAmplify()"> 数据增广 </el-button>
+
         <el-button
           type="danger"
           v-auth="['demo:data:remove']"
@@ -77,6 +79,7 @@ import {
 import { listDataApi as listDictDataApi } from '@/api/modules/system/dictData'
 import { uploadPure } from '@/api/modules/upload'
 import http from '@/api'
+import {useRouter} from "vue-router";
 
 onMounted(() => {
   state.cacheData.url = 'http://localhost:9090/profile/upload/2024/08/08/144745610/test.png'
@@ -358,6 +361,11 @@ const batchAdd = () => {
   dialogRef.value?.acceptParams(params)
 }
 
+const router = useRouter()
+// const dataAmplify = () => {
+//   router.push(`/data/amplify`)
+// }
+
 const formDialogRef = ref<InstanceType<typeof FormDialog> | null>(null)
 // 打开弹框的功能
 const openDialog = async (type: number, title: string, row?: any) => {

+ 29 - 0
src/views/demo/dataAugmentation/index.scss

@@ -0,0 +1,29 @@
+.amplify-container {
+  width: 100%;
+  height: 100%;
+  padding-top: 50px;
+
+  // position: relative;
+  .amplify-main {
+    width: 80%;
+    height: calc(100% - 50px);
+    margin: 0 auto;
+    overflow-y: scroll;
+  }
+  .el-footer {
+    position: absolute;
+    bottom: 0;
+    left: 50%;
+    height: 50px;
+    .submit {
+      right: 0;
+    }
+  }
+}
+::-webkit-scrollbar {
+  display: none;
+}
+.dialog-footer {
+  // margin-top: 30px;
+  margin: 0 auto;
+}

+ 170 - 0
src/views/demo/dataAugmentation/index.vue

@@ -0,0 +1,170 @@
+<template>
+  <div class="amplify-container">
+    <div class="amplify-main">
+      <ProForm :items-options="items" :model="model"> </ProForm>
+      <el-button type="primary" style="margin-left: 50px" @click="showDataSelectionDialog()">选择批次</el-button>
+    </div>
+
+    <el-footer>
+      <el-button class="submit" type="primary" @click="handleSubmit">提交</el-button>
+    </el-footer>
+    <el-dialog v-model="dataDialogVisible" title="选择数据批次" style="width: 70vw">
+      <el-container>
+        <el-table :data="batchDataList" tooltip-effect="dark" style="width: 100%; margin-bottom: 30px" @selection-change="handleSelectionChange">
+          <el-table-column type="selection"> </el-table-column>
+          <el-table-column prop="batchNum" label="所有批次"> </el-table-column>
+          <el-table-column prop="batchSize" label="数量"> </el-table-column>
+        </el-table>
+
+        <el-container style="display: flex; flex-direction: column; align-items: center; justify-content: center; margin: 0 30px">
+          <el-button type="primary" icon="ArrowRightBold" :disabled="!canSelect" @click="clickSelectData"></el-button>
+          <el-button
+            type="primary"
+            style="margin: 10px 0 0"
+            icon="ArrowLeftBold"
+            :disabled="!canDeselect"
+            @click="clickDeselectData"
+          ></el-button>
+        </el-container>
+
+        <el-table :data="selectedBatchDataList" tooltip-effect="dark" style="width: 100%" @selection-change="handleDeselectionChange">
+          <el-table-column type="selection"> </el-table-column>
+          <el-table-column prop="batchNum" label="已选批次"> </el-table-column>
+          <el-table-column prop="batchSize" label="数量"> </el-table-column>
+        </el-table>
+      </el-container>
+      <template #footer>
+        <div class="dialog-footer">
+          <el-button @click="dataDialogVisible = false">取 消</el-button>
+          <el-button type="primary" @click="dataDialogVisible = false"> 确 定 </el-button>
+        </div>
+      </template>
+    </el-dialog>
+  </div>
+</template>
+<script setup lang="tsx" name="amplify">
+import { reactive, ref, computed, onMounted } from 'vue'
+import ProForm from '@/components/ProForm/index.vue'
+import { batchListDataApi, amplifyApi } from '@/api/modules/demo/data'
+import { getDictsApi } from '@/api/modules/system/dictData'
+let model = {
+  taskName: 'ssss',
+  transfer: null
+}
+const dataDialogVisible = ref(false)
+let batchDataList = ref(reactive([] as any[]))
+let selectedBatchDataList = ref(reactive([] as any[]))
+let tempSelectedBatchDataList = ref(reactive([] as any[]))
+let tempDeselectedBatchDataList = ref(reactive([] as any[]))
+let parameList = ref(reactive([] as any[]))
+let queryBatchData = ref(reactive([] as any[]))
+onMounted(() => {
+  batchListDataApi().then(res => {
+    // batchDataList.value = reactive(res.data)
+    queryBatchData.value = reactive(res.data)
+  })
+  getDictsApi('expand_data_params').then(res => {
+    parameList.value = reactive(JSON.parse(res.data[0].remark))
+    parameList.value.forEach(item => {
+      items.push({
+        label: item.name,
+        prop: item.agName,
+        span: 12,
+        rules: [{ required: item.required, message: '不能为空' }],
+        compOptions: {
+          elTagName: 'input',
+          clearable: true,
+          placeholder: '请输入..'
+        }
+      })
+      model[`${item.agName}`] = item.defaultValue
+    })
+  })
+})
+const handleSelectionChange = data => {
+  tempSelectedBatchDataList.value = reactive(data)
+}
+let canSelect = computed(() => {
+  return tempSelectedBatchDataList.value.length > 0
+})
+const handleDeselectionChange = data => {
+  tempDeselectedBatchDataList.value = reactive(data)
+}
+const clickSelectData = () => {
+  let set = new Set()
+  for (let i = 0; i < tempSelectedBatchDataList.value.length; i++) {
+    set.add(tempSelectedBatchDataList.value[i].batchNum)
+    selectedBatchDataList.value.push(tempSelectedBatchDataList.value[i])
+  }
+  let newArray = [] as any[]
+  for (let i = 0; i < batchDataList.value.length; i++) {
+    if (!set.has(batchDataList.value[i].batchNum)) {
+      newArray.push(batchDataList.value[i])
+    }
+  }
+  batchDataList.value = reactive(newArray)
+}
+const canDeselect = computed(() => {
+  return tempDeselectedBatchDataList.value.length > 0
+})
+const clickDeselectData = () => {
+  let set = new Set()
+  for (let i = 0; i < tempDeselectedBatchDataList.value.length; i++) {
+    set.add(tempDeselectedBatchDataList.value[i].batchNum)
+    batchDataList.value.push(tempDeselectedBatchDataList.value[i])
+  }
+  let newArray = [] as any[]
+  for (let i = 0; i < selectedBatchDataList.value.length; i++) {
+    if (!set.has(selectedBatchDataList.value[i].batchNum)) {
+      newArray.push(selectedBatchDataList.value[i])
+    }
+  }
+  selectedBatchDataList.value = reactive(newArray)
+}
+const showDataSelectionDialog = () => {
+  // bIsTrainData.value = isTrainData
+  if (selectedBatchDataList.value.length === 0) {
+    batchDataList.value = queryBatchData.value
+  }
+  dataDialogVisible.value = true
+}
+const handleSubmit = () => {
+  let val = [] as any[]
+  for (let i = 0; i < selectedBatchDataList.value.length; i++) {
+    val.push(selectedBatchDataList.value[i].batchNum)
+  }
+  const batchNum = val.join()
+  const otherParams = [] as any[]
+
+  parameList.value.map(item => {
+    item.value = model[`${item.agName}`]
+  })
+  console.log('parameList.value', parameList.value)
+  const data = {
+    batchNum,
+    taskName: model.taskName,
+    otherParams: JSON.stringify(parameList.value)
+  }
+  console.log('data', data)
+  amplifyApi(data).then(res => {
+    console.log(res)
+  })
+}
+let items: ProForm.ItemsOptions[] = reactive([
+  {
+    label: '任务名称',
+    prop: 'taskName',
+    span: 14,
+    // labelWidth: '90px',
+    rules: [{ required: true, message: '请输入任务名称' }],
+    compOptions: {
+      elTagName: 'input',
+      clearable: true,
+      placeholder: '请输入用户名'
+    }
+  }
+])
+</script>
+<style scoped lang="scss">
+@import './index.scss';
+</style>