Bläddra i källkod

feat: 算法任务配置基本搭建

WANGKANG 9 månader sedan
förälder
incheckning
45f58d8418

+ 148 - 0
src/api/interface/demo/AlgorithmConfigTrack.ts

@@ -0,0 +1,148 @@
+import { PageQuery, BaseEntity } from '@/api/interface/index'
+export interface AlgorithmConfigTrackVO extends BaseEntity {
+    /**
+    * 主键ID
+    */
+        id: string | number;
+
+    /**
+    * 类型
+    */
+        type: string;
+
+    /**
+    * 父id
+    */
+        parentId: string | number;
+
+    /**
+    * 分系统
+    */
+        subsystem: string;
+
+    /**
+    * 算法名称
+    */
+        algorithmName: string;
+
+    /**
+    * 算法地址
+    */
+        algorithmAddress: string;
+
+    /**
+    * 参数配置
+    */
+        parameterConfig: string;
+
+    /**
+    * 备注
+    */
+        remarks: string;
+
+    /**
+    * 系统
+    */
+        system: string;
+
+    }
+
+    export interface AlgorithmConfigTrackForm {
+        /**
+        * 主键ID
+        */
+        id?: string | number;
+
+        /**
+        * 类型
+        */
+        type?: string;
+
+        /**
+        * 父id
+        */
+        parentId?: string | number;
+
+        /**
+        * 分系统
+        */
+        subsystem?: string;
+
+        /**
+        * 算法名称
+        */
+        algorithmName?: string;
+
+        /**
+        * 算法地址
+        */
+        algorithmAddress?: string;
+
+        /**
+        * 参数配置
+        */
+        parameterConfig?: string;
+
+        /**
+        * 备注
+        */
+        remarks?: string;
+
+        /**
+        * 乐观锁
+        */
+        version?: number;
+
+        /**
+        * 系统
+        */
+        system?: string;
+
+    }
+
+    export interface AlgorithmConfigTrackQuery extends PageQuery {
+        /**
+        * 类型
+        */
+        type?: string;
+
+        /**
+        * 父id
+        */
+        parentId?: string | number;
+
+        /**
+        * 分系统
+        */
+        subsystem?: string;
+
+        /**
+        * 算法名称
+        */
+        algorithmName?: string;
+
+        /**
+        * 算法地址
+        */
+        algorithmAddress?: string;
+
+        /**
+        * 参数配置
+        */
+        parameterConfig?: string;
+
+        /**
+        * 备注
+        */
+        remarks?: string;
+
+        /**
+        * 系统
+        */
+        system?: string;
+
+    /**
+    * 日期范围参数
+    */
+    params?: any;
+    }

+ 70 - 0
src/api/modules/demo/AlgorithmConfigTrack.ts

@@ -0,0 +1,70 @@
+import http from '@/api'
+import { AlgorithmConfigTrackVO, AlgorithmConfigTrackForm, AlgorithmConfigTrackQuery  } from '@/api/interface/demo/AlgorithmConfigTrack'
+/**
+ * @name 查询算法配置列表
+ * @param query 参数
+ * @returns 返回列表
+ */
+export const listAlgorithmConfigTrackApi = (query: AlgorithmConfigTrackQuery) => {
+    return http.get<AlgorithmConfigTrackVO[]>('/demo/AlgorithmConfigTrack/list', query, { loading: true })
+}
+
+/**
+ * @name 查询算法配置详细
+ * @param id id
+ * @returns returns
+ */
+export const getAlgorithmConfigTrackApi = (id: string | number) => {
+    return http.get<AlgorithmConfigTrackVO>(`/demo/AlgorithmConfigTrack/${id}`)
+}
+
+/**
+ * @name 新增算法配置
+ * @param data data
+ * @returns returns
+ */
+export const addAlgorithmConfigTrackApi = (data: AlgorithmConfigTrackForm) => {
+    return http.post<any>('/demo/AlgorithmConfigTrack', data, { loading: false })
+}
+
+/**
+ * @name 修改算法配置
+ * @param data data
+ * @returns returns
+ */
+export const updateAlgorithmConfigTrackApi = (data: AlgorithmConfigTrackForm) => {
+    return http.put<any>('/demo/AlgorithmConfigTrack', data, { loading: false })
+}
+
+/**
+ * @name 删除算法配置
+ * @param id id
+ * @returns returns
+ */
+export const delAlgorithmConfigTrackApi = (id: string | number | Array<string | number>) => {
+    return http.delete<any>(`/demo/AlgorithmConfigTrack/${id}`)
+}
+
+/**
+ * @name 下载模板
+ * @returns returns
+ */
+export const importTemplateApi = () => {
+    return http.downloadPost('/demo/AlgorithmConfigTrack/importTemplate', {})
+}
+
+/**
+ * @name 导入数据
+ * @returns returns
+ */
+export const importAlgorithmConfigTrackDataApi = (data: any) => {
+    return http.post('/demo/AlgorithmConfigTrack/importData', data)
+}
+
+/**
+ * @name 导出数据
+ * @returns returns
+ */
+export const exportAlgorithmConfigTrackApi = (data: any) => {
+    return http.downloadPost('/demo/AlgorithmConfigTrack/export', data)
+}

+ 259 - 0
src/views/demo/AlgorithmConfigTrack/index.vue

@@ -0,0 +1,259 @@
+<template>
+  <div class="table-box">
+    <ProTable ref="proTable" :columns="columns" row-key="id" :request-api="listAlgorithmConfigTrackApi">
+      <!-- 表格 header 按钮 -->
+      <template #tableHeader="scope">
+        <el-button type="primary" v-auth="['demo:AlgorithmConfigTrack:add']" icon="CirclePlus" @click="openDialog(1, '算法任务配置新增')">
+          新增
+        </el-button>
+        <el-button type="primary" v-auth="['demo:AlgorithmConfigTrack:import']" icon="Upload" plain @click="batchAdd"> 导入 </el-button>
+        <el-button type="primary" v-auth="['demo:AlgorithmConfigTrack:export']" icon="Download" plain @click="downloadFile"> 导出 </el-button>
+        <el-button
+          type="danger"
+          v-auth="['demo:AlgorithmConfigTrack:remove']"
+          icon="Delete"
+          plain
+          :disabled="!scope.isSelected"
+          @click="batchDelete(scope.selectedListIds)"
+        >
+          批量删除
+        </el-button>
+      </template>
+      <!-- 表格操作 -->
+      <template #operation="scope">
+        <el-button type="primary" link icon="View" v-auth="['demo:AlgorithmConfigTrack:query']" @click="openDialog(3, '算法任务配置查看', scope.row)">
+          查看
+        </el-button>
+        <el-button
+          type="primary"
+          link
+          icon="EditPen"
+          v-auth="['demo:AlgorithmConfigTrack:edit']"
+          @click="openDialog(2, '算法任务配置编辑', scope.row)"
+        >
+          编辑
+        </el-button>
+        <el-button type="primary" link icon="Delete" v-auth="['demo:AlgorithmConfigTrack:remove']" @click="deleteAlgorithmConfigTrack(scope.row)">
+          删除
+        </el-button>
+      </template>
+    </ProTable>
+    <FormDialog ref="formDialogRef" />
+    <ImportExcel ref="dialogRef" />
+  </div>
+</template>
+
+<script setup lang="tsx" name="AlgorithmConfigTrack">
+import { ref, reactive } from 'vue'
+import { useHandleData } from '@/hooks/useHandleData'
+import { useDownload } from '@/hooks/useDownload'
+import { ElMessageBox } from 'element-plus'
+import ProTable from '@/components/ProTable/index.vue'
+import ImportExcel from '@/components/ImportExcel/index.vue'
+import FormDialog from '@/components/FormDialog/index.vue'
+import { ProTableInstance, ColumnProps } from '@/components/ProTable/interface'
+import {
+  listAlgorithmConfigTrackApi,
+  delAlgorithmConfigTrackApi,
+  addAlgorithmConfigTrackApi,
+  updateAlgorithmConfigTrackApi,
+  importTemplateApi,
+  importAlgorithmConfigTrackDataApi,
+  exportAlgorithmConfigTrackApi,
+  getAlgorithmConfigTrackApi
+} from '@/api/modules/demo/AlgorithmConfigTrack'
+
+// ProTable 实例
+const proTable = ref<ProTableInstance>()
+
+// 删除算法任务配置信息
+const deleteAlgorithmConfigTrack = async (params: any) => {
+  await useHandleData(delAlgorithmConfigTrackApi, params.id, '删除【' + params.id + '】算法任务配置')
+  proTable.value?.getTableList()
+}
+
+// 批量删除算法任务配置信息
+const batchDelete = async (ids: string[]) => {
+  await useHandleData(delAlgorithmConfigTrackApi, ids, '删除所选算法任务配置信息')
+  proTable.value?.clearSelection()
+  proTable.value?.getTableList()
+}
+
+// 导出算法任务配置列表
+const downloadFile = async () => {
+  ElMessageBox.confirm('确认导出算法任务配置数据?', '温馨提示', { type: 'warning' }).then(() =>
+    useDownload(exportAlgorithmConfigTrackApi, '算法任务配置列表', proTable.value?.searchParam)
+  )
+}
+
+// 批量添加算法任务配置
+const dialogRef = ref<InstanceType<typeof ImportExcel> | null>(null)
+const batchAdd = () => {
+  const params = {
+    title: '算法任务配置',
+    tempApi: importTemplateApi,
+    importApi: importAlgorithmConfigTrackDataApi,
+    getTableList: proTable.value?.getTableList
+  }
+  dialogRef.value?.acceptParams(params)
+}
+
+const formDialogRef = ref<InstanceType<typeof FormDialog> | null>(null)
+// 打开弹框的功能
+const openDialog = async (type: number, title: string, row?: any) => {
+  let res = { data: {} }
+  if (row?.id) {
+    res = await getAlgorithmConfigTrackApi(row?.id || null)
+  }
+  // 重置表单
+  setItemsOptions()
+  const params = {
+    title,
+    width: 580,
+    isEdit: type !== 3,
+    itemsOptions: itemsOptions,
+    model: type == 1 ? {} : res.data,
+    api: type == 1 ? addAlgorithmConfigTrackApi : updateAlgorithmConfigTrackApi,
+    getTableList: proTable.value?.getTableList
+  }
+  formDialogRef.value?.openDialog(params)
+}
+
+// 表格配置项
+const columns = reactive<ColumnProps<any>[]>([
+  { type: 'selection', fixed: 'left', width: 70 },
+  { prop: 'id', label: '主键ID' },
+  //   {
+  //     prop: 'type',
+  //     label: '类型',
+  //     search: {
+  //       el: 'input'
+  //     },
+  //     width: 120
+  //   },
+  //   {
+  //     prop: 'parentId',
+  //     label: '父id',
+  //     search: {
+  //       el: 'input'
+  //     },
+  //     width: 120
+  //   },
+  //   {
+  //     prop: 'subsystem',
+  //     label: '分系统',
+  //     search: {
+  //       el: 'input'
+  //     },
+  //     width: 120
+  //   },
+  {
+    prop: 'algorithmName',
+    label: '算法名称',
+    search: {
+      el: 'input'
+    }
+  },
+  {
+    prop: 'algorithmAddress',
+    label: '算法地址',
+    search: {
+      el: 'input'
+    }
+  },
+  {
+    prop: 'parameterConfig',
+    label: '参数配置',
+    search: {
+      el: 'input'
+    }
+  },
+  {
+    prop: 'remarks',
+    label: '备注',
+    search: {
+      el: 'input'
+    }
+  },
+  //   {
+  //     prop: 'system',
+  //     label: '系统',
+  //     search: {
+  //       el: 'input'
+  //     }
+  //   },
+  { prop: 'operation', label: '操作', width: 230, fixed: 'right' }
+])
+// 表单配置项
+let itemsOptions: ProForm.ItemsOptions[] = []
+const setItemsOptions = () => {
+  itemsOptions = [
+    // {
+    //   label: '类型',
+    //   prop: 'type',
+    //   rules: [{ required: true, message: '类型不能为空', trigger: 'blur' }],
+    //   compOptions: {
+    //     placeholder: '请输入类型'
+    //   }
+    // },
+    // {
+    //   label: '父id',
+    //   prop: 'parentId',
+    //   rules: [{ required: true, message: '父id不能为空', trigger: 'blur' }],
+    //   compOptions: {
+    //     placeholder: '请输入父id'
+    //   }
+    // },
+    // {
+    //   label: '分系统',
+    //   prop: 'subsystem',
+    //   rules: [{ required: true, message: '分系统不能为空', trigger: 'blur' }],
+    //   compOptions: {
+    //     placeholder: '请输入分系统'
+    //   }
+    // },
+    {
+      label: '算法名称',
+      prop: 'algorithmName',
+      rules: [{ required: true, message: '算法名称不能为空', trigger: 'blur' }],
+      compOptions: {
+        placeholder: '请输入算法名称'
+      }
+    },
+    {
+      label: '算法地址',
+      prop: 'algorithmAddress',
+      rules: [{ required: true, message: '算法地址不能为空', trigger: 'blur' }],
+      compOptions: {
+        placeholder: '请输入算法地址'
+      }
+    },
+    {
+      label: '参数配置',
+      prop: 'parameterConfig',
+      rules: [{ required: true, message: '参数配置不能为空', trigger: 'blur' }],
+      compOptions: {
+        type: 'textarea',
+        clearable: true,
+        placeholder: '请输入内容'
+      }
+    },
+    {
+      label: '备注',
+      prop: 'remarks',
+      rules: [{ required: false, message: '备注不能为空', trigger: 'blur' }],
+      compOptions: {
+        placeholder: '请输入备注'
+      }
+    }
+    // {
+    //   label: '系统',
+    //   prop: 'system',
+    //   rules: [{ required: true, message: '系统不能为空', trigger: 'blur' }],
+    //   compOptions: {
+    //     placeholder: '请输入系统'
+    //   }
+    // }
+  ]
+}
+</script>

+ 1 - 1
src/views/demo/AlgorithmModelTrack/index.vue

@@ -233,7 +233,7 @@ const setItemsOptions = () => {
     {
       label: '备注',
       prop: 'remarks',
-      rules: [{ required: true, message: '备注不能为空', trigger: 'blur' }],
+      rules: [{ required: false, message: '备注不能为空', trigger: 'blur' }],
       compOptions: {
         placeholder: '请输入备注'
       }