/** Copyright 2020 Tianshu AI Platform. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================= */ import { getEmptyFormatter, ALGORITHM_RESOURCE_ENUM } from '@/utils'; import { algList } from '@/config'; export function getColumns({ doEdit, createTrain, doDownload, doFork, doDelete, active, allAlgorithmUsageList, isAdmin, }) { const data = JSON.parse(JSON.stringify(algList)); data.forEach((item) => { item.label = item.auxInfo; item.value = item.id; }); const dropdownList = data; const isPreset = active === String(ALGORITHM_RESOURCE_ENUM.PRESET); return [ { label: 'ID', prop: 'id', width: 80, sortable: 'custom', fixed: true, hide: isPreset, // 预置算法隐藏 ID 列 }, { label: '名称', prop: 'algorithmName', fixed: true, minWidth: '160px', }, { label: '模型类别', prop: 'algorithmUsage', formatter: getEmptyFormatter(), minWidth: '100px', // dropdownList: allAlgorithmUsageList, dropdownList: [ { label: '全部', value: '', }, { label: '健康状态', value: '健康状态', }, { label: '安全预警', value: '安全预警', }, { label: '异常检测', value: '异常检测', }, { label: '其他', value: '其他', }, ], }, { label: '是否支持推理', prop: 'inference', formatter(value) { return value ? '支持' : '不支持'; }, minWidth: '140px', dropdownList: [ { label: '全部', value: null, }, { label: '支持', value: true, }, { label: '不支持', value: false, }, ], }, { label: '描述', prop: 'description', minWidth: '200px', }, { label: '创建时间', prop: 'createTime', type: 'time', minWidth: '160px', sortable: 'custom', }, { label: '创建人', prop: 'originUserId', hide: !isAdmin, }, { label: '操作', type: 'operation', width: '370px', fixed: 'right', operations: [ { label: '在线编辑', func: doEdit, hide: isPreset, iconAfter: 'externallink', }, { label: '创建训练任务', func: createTrain, }, { label: '下载', func: doDownload, }, { label: 'Fork', func: doFork, }, { label: '删除', func: doDelete, hide: isPreset && !isAdmin, }, ], }, ]; } export function getQueryFormItems({ active }) { return [ { prop: 'algorithmName', placeholder: active === String(ALGORITHM_RESOURCE_ENUM.PRESET) ? '请输入算法名称' : '请输入算法名称或 ID', class: 'w-200', change: 'query', }, { type: 'button', btnText: '重置', func: 'resetQuery', }, { type: 'button', btnText: '搜索', btnType: 'primary', func: 'query', }, ]; }