index.vue 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689
  1. <template>
  2. <div class="createTask-bigBox">
  3. <dv-border-box1 ref="borderRef" style="width: 80%; height: calc(100% - 20px); margin: 0 auto">
  4. <el-container style="height: 30px"></el-container>
  5. <el-container>
  6. <span class="span_class">任务名称</span>
  7. <el-input style="width: 300px" type="text" placeholder="请输入任务名称" v-model="formData.taskName"> </el-input>
  8. </el-container>
  9. <el-container style="height: 10px"></el-container>
  10. <el-container>
  11. <span class="span_class">任务类型</span>
  12. <el-radio v-model="formData.taskType" label="1">单数据多算法任务</el-radio>
  13. <el-radio v-model="formData.taskType" label="2">多数据单算法任务</el-radio>
  14. </el-container>
  15. <el-container style="height: 10px"></el-container>
  16. <el-container>
  17. <span class="span_class">算法任务</span>
  18. <el-checkbox-group v-model="formData.tasks">
  19. <el-checkbox label="1">训练</el-checkbox>
  20. <el-checkbox label="2">测试</el-checkbox>
  21. </el-checkbox-group>
  22. </el-container>
  23. <el-container style="height: 10px"></el-container>
  24. <el-container>
  25. <span class="span_class">选择算法</span>
  26. <el-container style="display: flex; flex-direction: column">
  27. <el-container v-for="(item, index) in formData.algorithms" :key="index" style="margin-top: 5px">
  28. <el-select style="width: 200px" v-model="formData.algoIdx[index]" placeholder="请选择" @change="onAlgorithmModelSelect(index)">
  29. <el-option v-for="(item1, index) in algorithms" :key="item1.id" :label="item1.name" :value="index"> </el-option>
  30. </el-select>
  31. <el-button style="margin-left: 20px" @click="showSuperParameterConfig(item, index)"> 超参配置 </el-button>
  32. <span class="span_class1">选择模型</span>
  33. <el-select style="width: 200px" v-model="formData.algoModelId[index]" placeholder="未选择将使用默认模型">
  34. <el-option v-for="item1 in formData.algoModelList[index]" :key="item1.id" :label="item1.modelName" :value="item1.id"> </el-option>
  35. </el-select>
  36. <el-button @click="showAddModelDialog(item, index)"> 导入模型 </el-button>
  37. <el-button v-show="formData.algorithms.length > 1" @click="removeItem(index)"> 删除算法 </el-button>
  38. <el-button v-show="formData.taskType === '1' && index + 1 === formData.algorithms.length" @click="appendNewItem"> 添加算法 </el-button>
  39. </el-container>
  40. </el-container>
  41. </el-container>
  42. <el-container style="height: 10px"></el-container>
  43. <el-container>
  44. <span class="span_class">选择训练数据</span>
  45. <el-container style="display: flex; flex-direction: column">
  46. <el-container v-for="(item, index) in formData.data" :key="index" style="margin-top: 5px">
  47. <el-button v-show="formData.data" @click="showDataSelectionDialog(index, true)"> 选择批次 </el-button>
  48. <span v-if="!item || item.length === 0" class="span_class" style="font-size: 15px; color: red">未完成</span>
  49. <span v-else class="span_class" style="font-size: 15px; color: greenyellow">已选择</span>
  50. <el-button v-show="formData.data.length > 1" style="margin-left: 20px" @click="removeDataItem(index, true)"> 删除数据 </el-button>
  51. <el-button
  52. v-show="formData.taskType === '2' && index + 1 === formData.data.length"
  53. style="margin-left: 20px"
  54. @click="appendNewDataItem(true)"
  55. >
  56. 添加数据
  57. </el-button>
  58. </el-container>
  59. </el-container>
  60. </el-container>
  61. <el-container style="height: 10px"></el-container>
  62. <el-container>
  63. <span class="span_class">选择测试数据</span>
  64. <el-container style="display: flex; flex-direction: column">
  65. <el-container v-for="(item, index) in formData.testData" :key="index" style="margin-top: 5px">
  66. <el-button v-show="formData.testData" @click="showDataSelectionDialog(index, false)"> 选择批次 </el-button>
  67. <span v-if="!item || item.length === 0" class="span_class" style="font-size: 15px; color: red">未完成</span>
  68. <span v-else class="span_class" style="font-size: 15px; color: greenyellow">已选择</span>
  69. <el-button v-show="formData.testData.length > 1" style="margin-left: 20px" @click="removeDataItem(index, false)"> 删除数据 </el-button>
  70. <el-button
  71. v-show="formData.taskType === '2' && index + 1 === formData.testData.length"
  72. style="margin-left: 20px"
  73. @click="appendNewDataItem(false)"
  74. >
  75. 添加数据
  76. </el-button>
  77. </el-container>
  78. </el-container>
  79. </el-container>
  80. <el-container style="height: 10px"></el-container>
  81. <el-container>
  82. <span class="span_class">是否训练扩增</span>
  83. <el-checkbox v-model="formData.expandData">扩增</el-checkbox>
  84. <el-button v-show="formData.expandData" style="margin-left: 20px" @click="showExpandDataSuperParameterConfig"> 超参配置 </el-button>
  85. </el-container>
  86. <el-form-item style="margin-top: 20px; margin-left: 30px">
  87. <el-button type="primary" @click="submit"> 提交 </el-button>
  88. <el-button @click="cancel"> 取消 </el-button>
  89. </el-form-item>
  90. </dv-border-box1>
  91. <FormDialog ref="formDialogRef" @update="handleUpdateModelList" />
  92. <el-dialog v-model="expandDataDialogVisible" title="数据扩增超参配置">
  93. <!-- <span style="font-size: 16px; color: darkorange; font-weight: bold"> 数据扩增超参 </span>-->
  94. <!-- <el-container v-for="(item, index) in expandDataConfig" :key="index" style="margin-top: 5px">-->
  95. <!-- <span class="span_class"> {{ item.name }}</span>-->
  96. <!-- <el-input style="width: 300px" type="text" :placeholder="'请输入' + item.name" v-model="item.defaultValue"> </el-input>-->
  97. <!-- </el-container>-->
  98. <el-container style="margin-top: 5px">
  99. <AmplifyForm
  100. @update-data="updateBatchData"
  101. @update-model="updateModelData"
  102. @update-params="updateParamsList"
  103. :show-select-batch-button="true"
  104. :use-data="true"
  105. :data-list="selectedBatchDataList"
  106. />
  107. </el-container>
  108. <el-container style="height: 10px"></el-container>
  109. <span class="dialog-footer">
  110. <el-button type="primary" @click="submitExpandDataConfigDialog">确 定</el-button>
  111. <el-button @click="expandDataDialogVisible = false">取 消</el-button>
  112. </span>
  113. </el-dialog>
  114. <el-dialog v-model="dialogVisible" :title="superParameterFormData.title">
  115. <span style="font-size: 16px; font-weight: bold; color: darkorange"> 训练超参 </span>
  116. <el-container v-for="(item, index) in superParameterFormData.trainParams" :key="index">
  117. <span class="span_class"> {{ item.name }}</span>
  118. <el-tooltip effect="dark" :content="item?.prompt" placement="top">
  119. <i :class="'iconfont icon-yiwen'"></i>
  120. </el-tooltip>
  121. <el-input style="width: 300px" type="text" :placeholder="'请输入' + item.name" v-model="item.defaultValue"> </el-input>
  122. </el-container>
  123. <el-container style="height: 10px"></el-container>
  124. <span style="font-size: 16px; font-weight: bold; color: darkorange"> 验证超参 </span>
  125. <el-container v-for="(item, index) in superParameterFormData.verifyParams" :key="index">
  126. <span class="span_class"> {{ item.name }}</span>
  127. <el-tooltip effect="dark" :content="item?.prompt" placement="top">
  128. <i :class="'iconfont icon-yiwen'"></i>
  129. </el-tooltip>
  130. <el-input style="width: 300px" type="text" :placeholder="'请输入' + item.name" v-model="item.defaultValue"> </el-input>
  131. </el-container>
  132. <el-container style="height: 10px"></el-container>
  133. <span style="font-size: 16px; font-weight: bold; color: darkorange"> 测试超参 </span>
  134. <el-container v-for="(item, index) in superParameterFormData.testParams" :key="index">
  135. <span class="span_class"> {{ item.name }}</span>
  136. <el-tooltip effect="dark" :content="item?.prompt" placement="top">
  137. <i :class="'iconfont icon-yiwen'"></i>
  138. </el-tooltip>
  139. <el-input style="width: 300px" type="text" :placeholder="'请输入' + item.name" v-model="item.defaultValue"> </el-input>
  140. </el-container>
  141. <el-container style="height: 10px"></el-container>
  142. <span class="dialog-footer">
  143. <el-button type="primary" @click="submitConfigDialog">确 定</el-button>
  144. <el-button @click="dialogVisible = false">取 消</el-button>
  145. </span>
  146. </el-dialog>
  147. <el-dialog v-model="dataDialogVisible" title="选择数据批次" style="width: 70vw">
  148. <el-container>
  149. <el-table :data="batchDataList" tooltip-effect="dark" style="width: 100%" @selection-change="handleSelectionChange">
  150. <el-table-column type="selection" width="55"> </el-table-column>
  151. <el-table-column prop="batchNum" label="所有批次" width="120"> </el-table-column>
  152. <el-table-column prop="batchSize" label="数量" width="80"> </el-table-column>
  153. </el-table>
  154. <el-container style="display: flex; flex-direction: column; justify-content: center; margin-right: 10px; margin-left: 10px">
  155. <el-button type="primary" :disabled="!canSelect" @click="clickSelectData"> {{ '=>' }} </el-button>
  156. <el-container style="height: 10px"></el-container>
  157. <el-button type="primary" :disabled="!canDeselect" @click="clickDeselectData"> {{ '<=' }} </el-button>
  158. </el-container>
  159. <el-table :data="selectedBatchDataList" tooltip-effect="dark" style="width: 100%" @selection-change="handleDeselectionChange">
  160. <el-table-column type="selection" width="55"> </el-table-column>
  161. <el-table-column prop="batchNum" label="已选批次" width="120"> </el-table-column>
  162. <el-table-column prop="batchSize" label="数量" width="80"> </el-table-column>
  163. </el-table>
  164. </el-container>
  165. <el-container style="height: 10px"></el-container>
  166. <span class="dialog-footer">
  167. <el-button type="primary" @click="submitDataDialog">确 定</el-button>
  168. <el-button @click="dataDialogVisible = false">取 消</el-button>
  169. </span>
  170. </el-dialog>
  171. </div>
  172. </template>
  173. <script setup lang="ts">
  174. import { reactive, ref, onMounted, computed } from 'vue'
  175. import { addModelApi, queryModelList } from '@/api/modules/ag/model'
  176. import { createTaskApi } from '@/api/modules/task/task'
  177. import FormDialog from '@/components/FormDialog/index.vue'
  178. import { useRouter } from 'vue-router'
  179. import { listTaskConfigurationApi } from '@/api/modules/task/taskConfiguration'
  180. import { amplifyApi, batchListDataApi } from '@/api/modules/demo/data'
  181. import { getDictsApi, listDataApi } from '@/api/modules/system/dictData'
  182. import { ElMessage } from 'element-plus'
  183. import AmplifyForm from '@/views/demo/data/AmplifyForm.vue'
  184. let selectedBatchDataList1 = ref([] as any[])
  185. let model = ref({})
  186. let parameList = ref([] as any[])
  187. // 监听 AmplifyForm 组件传递的数据
  188. const updateBatchData = data => {
  189. selectedBatchDataList1.value = data
  190. }
  191. const updateModelData = data => {
  192. model.value = data
  193. console.log('model', model.value)
  194. }
  195. // 监听 parameList 更新
  196. const updateParamsList = data => {
  197. parameList.value = data
  198. console.log('params', parameList.value)
  199. }
  200. // 提交逻辑
  201. const getTrainAugmentationParams = () => {
  202. let batchNum = selectedBatchDataList1.value.map(batch => batch.batchNum).join()
  203. // 将 parameList 中的值也传递到接口
  204. parameList.value.forEach(item => {
  205. item.value = model.value[`${item.agName}`]
  206. })
  207. return {
  208. batchNum: batchNum,
  209. taskName: model.value.taskName,
  210. augmentationType: model.value.augmentationType,
  211. otherParams: parameList.value
  212. }
  213. }
  214. const valid = data => {
  215. let ret = {
  216. code: 400,
  217. message: 'OK'
  218. }
  219. if (!data.taskName || data.taskName.length === 0) {
  220. ret.message = '任务名称不能为空'
  221. return ret
  222. }
  223. if (!data.taskItemList || data.taskItemList.length === 0) {
  224. ret.message = '请选择算法任务'
  225. return ret
  226. }
  227. data.algTaskList.forEach(obj => {
  228. if (!obj || !obj.id) {
  229. ret.message = '请选择算法模型'
  230. }
  231. })
  232. if (ret.message !== 'OK') {
  233. return ret
  234. }
  235. if (data.taskItemList.includes('1')) {
  236. data.trainBatchNumList.forEach(obj => {
  237. if (!obj) {
  238. ret.message = '请选择训练数据集'
  239. }
  240. })
  241. if (ret.message !== 'OK') {
  242. return ret
  243. }
  244. }
  245. if (data.taskItemList.includes('2')) {
  246. data.testBatchNumList.forEach(obj => {
  247. if (!obj) {
  248. ret.message = '请选择测试数据集'
  249. }
  250. })
  251. if (ret.message !== 'OK') {
  252. return ret
  253. }
  254. }
  255. if (data.hasTrainAugmentation) {
  256. if (!data.trainAugmentationParams || data.trainAugmentationParams.length === 0) {
  257. ret.message = '请配置扩增参数'
  258. return ret
  259. }
  260. }
  261. ret.code = 200
  262. return ret
  263. }
  264. const submit = () => {
  265. const params = {
  266. taskName: formData.taskName,
  267. taskType: formData.taskType,
  268. taskItemList: formData.tasks,
  269. algTaskList: formData.algorithms,
  270. trainBatchNumList: formData.data,
  271. testBatchNumList: formData.testData,
  272. hasTrainAugmentation: formData.expandData,
  273. trainAugmentationParams: getTrainAugmentationParams()
  274. }
  275. console.log('submit data', params)
  276. let result = valid(params)
  277. // console.log(result)
  278. if (result.code !== 200) {
  279. ElMessage.error(result.message)
  280. return
  281. }
  282. let __idx = 0
  283. params.algTaskList.forEach(obj => {
  284. obj.algorithmId = obj.id
  285. // if (!obj.trainParams) {
  286. // return
  287. // }
  288. let o1 = JSON.parse(obj.trainParams)
  289. let o2 = JSON.parse(obj.verifyParams)
  290. let o3 = JSON.parse(obj.testParams)
  291. if (formData.algoModelId[__idx] && formData.algoModelId[__idx].length > 0) {
  292. const __trained = {
  293. agName: 'pretrained_model',
  294. defaultValue: true,
  295. modelId: formData.algoModelId[__idx]
  296. }
  297. o1.push(__trained)
  298. o2.push(__trained)
  299. o3.push(__trained)
  300. }
  301. obj.params = JSON.stringify(o1) + ';;;' + JSON.stringify(o2) + ';;;' + JSON.stringify(o3)
  302. __idx++
  303. })
  304. // console.log('submit', params)
  305. createTaskApi(params)
  306. .then(res => {
  307. // console.log(res)
  308. if (res.code !== 200) {
  309. ElMessage.error(res.msg)
  310. } else {
  311. router.push(`/index`)
  312. }
  313. })
  314. .catch(err => {
  315. console.log(err)
  316. })
  317. }
  318. const loadExpandDataParams = () => {
  319. listDataApi({
  320. dictType: 'expand_data_params',
  321. pageNum: 1,
  322. pageSize: 10000
  323. })
  324. .then(res => {
  325. // console.log(res)
  326. expandDataConfig.value = reactive([])
  327. res.data.list.forEach(obj => {
  328. expandDataConfig.value.push({
  329. name: obj.dictLabel,
  330. defaultValue: obj.dictValue
  331. })
  332. })
  333. expandDataDialogVisible.value = true
  334. })
  335. .catch(err => {
  336. console.log(err)
  337. })
  338. }
  339. const showExpandDataSuperParameterConfig = () => {
  340. loadExpandDataParams()
  341. }
  342. // 数据扩增超参修改保存
  343. const submitExpandDataConfigDialog = () => {
  344. expandDataDialogVisible.value = false
  345. }
  346. const expandDataDialogVisible = ref(false)
  347. let expandDataConfig = ref(
  348. reactive([
  349. // {
  350. // name: 'config1',
  351. // defaultValue: 'a'
  352. // }
  353. ])
  354. )
  355. const submitConfigDialog = () => {
  356. dialogVisible.value = false
  357. formData.algorithms[superParameterFormData.index].trainParams = JSON.stringify(superParameterFormData.trainParams)
  358. formData.algorithms[superParameterFormData.index].verifyParams = JSON.stringify(superParameterFormData.verifyParams)
  359. formData.algorithms[superParameterFormData.index].testParams = JSON.stringify(superParameterFormData.testParams)
  360. }
  361. // 选择批次的数据结果
  362. const submitDataDialog = () => {
  363. // console.log(selectedBatchDataList.value)
  364. let val = ''
  365. for (let i = 0; i < selectedBatchDataList.value.length; i++) {
  366. val += selectedBatchDataList.value[i].batchNum + ','
  367. }
  368. if (bIsTrainData.value) {
  369. formData.data[selectDataIndex] = val.substring(0, val.length - 1)
  370. } else {
  371. formData.testData[selectDataIndex] = val.substring(0, val.length - 1)
  372. }
  373. dataDialogVisible.value = false
  374. }
  375. const canSelect = computed(() => {
  376. // console.log(tempSelectedBatchDataList)
  377. return tempSelectedBatchDataList.value.length > 0
  378. })
  379. const canDeselect = computed(() => {
  380. return tempDeselectedBatchDataList.value.length > 0
  381. })
  382. const handleUpdateModelList = () => {
  383. updateModelList(UPDATE_INDEX.value.id, UPDATE_INDEX.value.idx)
  384. }
  385. onMounted(() => {
  386. listTaskConfigurationApi({ pageNum: 1, pageSize: 10000 }).then(res => {
  387. // console.log(res)
  388. algorithms = reactive(res.data.list)
  389. })
  390. batchListDataApi().then(res => {
  391. // console.log(res)
  392. queryBatchData.value = reactive(res.data)
  393. })
  394. })
  395. let queryBatchData = ref(reactive([]))
  396. const handleSelectionChange = data => {
  397. tempSelectedBatchDataList.value = reactive(data)
  398. // console.log(data)
  399. }
  400. const handleDeselectionChange = data => {
  401. tempDeselectedBatchDataList.value = reactive(data)
  402. // console.log(data)
  403. }
  404. const clickSelectData = () => {
  405. let set = new Set()
  406. for (let i = 0; i < tempSelectedBatchDataList.value.length; i++) {
  407. set.add(tempSelectedBatchDataList.value[i].batchNum)
  408. selectedBatchDataList.value.push(tempSelectedBatchDataList.value[i])
  409. }
  410. let newArray = []
  411. for (let i = 0; i < batchDataList.value.length; i++) {
  412. if (!set.has(batchDataList.value[i].batchNum)) {
  413. newArray.push(batchDataList.value[i])
  414. }
  415. }
  416. batchDataList.value = reactive(newArray)
  417. // console.log(batchDataList)
  418. }
  419. const clickDeselectData = () => {
  420. let set = new Set()
  421. for (let i = 0; i < tempDeselectedBatchDataList.value.length; i++) {
  422. set.add(tempDeselectedBatchDataList.value[i].batchNum)
  423. batchDataList.value.push(tempDeselectedBatchDataList.value[i])
  424. }
  425. let newArray = []
  426. for (let i = 0; i < selectedBatchDataList.value.length; i++) {
  427. if (!set.has(selectedBatchDataList.value[i].batchNum)) {
  428. newArray.push(selectedBatchDataList.value[i])
  429. }
  430. }
  431. selectedBatchDataList.value = reactive(newArray)
  432. }
  433. const router = useRouter()
  434. let bIsTrainData = ref(false)
  435. let dialogVisible = ref(false)
  436. let batchDataList = ref(reactive([]))
  437. let selectedBatchDataList = ref(reactive([]))
  438. let tempSelectedBatchDataList = ref(reactive([]))
  439. let tempDeselectedBatchDataList = ref(reactive([]))
  440. const formData = reactive({
  441. taskName: null,
  442. taskType: '1',
  443. tasks: [],
  444. algorithms: [{}],
  445. algoIdx: [null],
  446. algoModelId: [null],
  447. algoModelList: [[]],
  448. // 训练数据
  449. data: [null],
  450. // 测试数据
  451. testData: [null],
  452. expandData: false,
  453. expandConfig: null
  454. })
  455. let selectDataIndex = null
  456. const dataDialogVisible = ref(false)
  457. const showDataSelectionDialog = (index, isTrainData) => {
  458. bIsTrainData.value = isTrainData
  459. batchDataList.value = queryBatchData.value
  460. selectedBatchDataList.value = reactive([])
  461. tempSelectedBatchDataList.value = reactive([])
  462. tempDeselectedBatchDataList.value = reactive([])
  463. selectDataIndex = index
  464. fillCurrentDataDialogList(index, isTrainData)
  465. dataDialogVisible.value = true
  466. }
  467. const fillCurrentDataDialogList = (index, isTrainData) => {
  468. let list = []
  469. try {
  470. list = bIsTrainData.value ? formData.data[index]?.split(',') : formData.testData[index]?.split(',')
  471. } catch (e) {
  472. console.log(e)
  473. }
  474. let selected = new Set(list)
  475. batchDataList.value = []
  476. selectedBatchDataList.value = []
  477. batchListDataApi().then(res => {
  478. // console.log(res)
  479. for (let i = 0; i < res.data.length; i++) {
  480. if (selected.has(res.data[i].batchNum)) {
  481. selectedBatchDataList.value.push(res.data[i])
  482. } else {
  483. batchDataList.value.push(res.data[i])
  484. }
  485. }
  486. })
  487. }
  488. let superParameterFormData = reactive({})
  489. const showSuperParameterConfig = (item, index) => {
  490. superParameterFormData = reactive({
  491. index: index,
  492. trainParams: JSON.parse(item.trainParams),
  493. testParams: JSON.parse(item.testParams),
  494. verifyParams: JSON.parse(item.verifyParams),
  495. title: '超参配置'
  496. })
  497. // console.log(superParameterFormData)
  498. dialogVisible.value = true
  499. }
  500. let algorithms = reactive([])
  501. const onAlgorithmModelSelect = index => {
  502. formData.algorithms[index] = algorithms[formData.algoIdx[index]]
  503. updateModelList(formData.algorithms[index].id, index)
  504. }
  505. const formDialogRef = ref<InstanceType<typeof FormDialog> | null>(null)
  506. let UPDATE_INDEX = ref({ id: null, idx: null })
  507. const fileDescription = ref('')
  508. const showAddModelDialog = async (item, index) => {
  509. let _id = null
  510. try {
  511. _id = item.id
  512. } catch (e) {
  513. ElMessage.error('请先选择算法模型')
  514. return
  515. }
  516. if (!_id || _id.length === 0) {
  517. ElMessage.error('请先选择算法模型')
  518. return
  519. }
  520. UPDATE_INDEX.value = {
  521. id: _id,
  522. idx: index
  523. }
  524. let _res = await getDictsApi('zip_file_format_description')
  525. _res.data.forEach(item => {
  526. // 检查item对象是否包含dict和des属性
  527. if (item.dictLabel === '多目标检测导入模型') {
  528. fileDescription.value = item.remark
  529. }
  530. })
  531. const params = {
  532. title: '算法模型配置',
  533. width: 580,
  534. isEdit: true,
  535. itemsOptions: [
  536. {
  537. label: '模型名称',
  538. prop: 'modelName',
  539. rules: [{ required: true, message: '模型名称不能为空', trigger: 'blur' }],
  540. compOptions: {
  541. placeholder: '请输入模型名称'
  542. }
  543. },
  544. {
  545. label: '模型',
  546. tooltip: fileDescription,
  547. prop: 'modelAddress',
  548. rules: [], //{ required: true, message: '模型不能为空', trigger: 'blur' }
  549. compOptions: {
  550. elTagName: 'slot'
  551. }
  552. },
  553. {
  554. label: '训练样本数',
  555. prop: 'sampleNumber',
  556. compOptions: {
  557. placeholder: '请输入训练样本数'
  558. }
  559. },
  560. {
  561. label: '训练循环次数',
  562. prop: 'cycleEpoch',
  563. compOptions: {
  564. placeholder: '请输入训练循环次数'
  565. }
  566. }
  567. ],
  568. model: {},
  569. api: addModelApi
  570. }
  571. console.log('check item:', item)
  572. formDialogRef.value?.openDialog(params, item.id)
  573. }
  574. // 获取算法模型绑定列表
  575. const updateModelList = (id, index) => {
  576. // 获取算法列表?
  577. queryModelList({ id: id }).then(res => {
  578. console.log('algorithm task model get: ', res)
  579. if (res.code === 200) {
  580. formData.algoModelList[index] = [{ id: null, modelName: '未选择' }, ...res.data]
  581. }
  582. })
  583. }
  584. const appendNewItem = () => {
  585. formData.algorithms.push({})
  586. formData.algoIdx.push(null)
  587. formData.algoModelId.push(null)
  588. formData.algoModelList.push([])
  589. }
  590. const appendNewDataItem = isTrainData => {
  591. if (isTrainData) {
  592. formData.data.push([])
  593. } else {
  594. formData.testData.push([])
  595. }
  596. }
  597. const removeItem = idx => {
  598. formData.algorithms.splice(idx, 1)
  599. formData.algoIdx.splice(idx, 1)
  600. formData.algoModelId.splice(idx, 1)
  601. formData.algoModelList.splice(idx, 1)
  602. }
  603. const removeDataItem = (idx, isTrainData) => {
  604. if (isTrainData) {
  605. formData.data.splice(idx, 1)
  606. } else {
  607. formData.testData.splice(idx, 1)
  608. }
  609. }
  610. const cancel = () => {
  611. // console.log('cancel')
  612. router.push(`/index`)
  613. }
  614. </script>
  615. <style scoped>
  616. .createTask-bigBox {
  617. width: 100%;
  618. height: 100%;
  619. overflow: hidden;
  620. background-image: url('../../../assets/taaisImg/53bg.png');
  621. background-repeat: no-repeat;
  622. background-size: 100% 100%;
  623. }
  624. .span_class {
  625. display: flex;
  626. align-self: center;
  627. justify-content: center;
  628. width: 120px;
  629. font-size: 13px;
  630. }
  631. .span_class1 {
  632. display: flex;
  633. align-self: center;
  634. justify-content: center;
  635. width: 65px;
  636. font-size: 13px;
  637. }
  638. </style>