Эх сурвалжийг харах

feat: 可辨识性分析总任务前端任务初步添加

WANGKANG 3 сар өмнө
parent
commit
dd5f6af347

+ 146 - 0
src/api/interface/demo/algorithmTaskTrack.ts

@@ -0,0 +1,146 @@
+import { PageQuery, BaseEntity } from '@/api/interface/index'
+export interface AlgorithmTaskTrackVO extends BaseEntity {
+  /**
+   * 主键ID
+   */
+  id: string | number
+
+  /**
+   * 任务名称
+   */
+  name: string
+
+  /**
+   * 任务状态
+   */
+  status: string
+
+  /**
+   * 开始时间
+   */
+  startTime: string
+
+  /**
+   * 结束时间
+   */
+  endTime: string
+
+  /**
+   * 耗时
+   */
+  costSecond: number
+
+  /**
+   * 日志
+   */
+  log: string
+
+  /**
+   * 备注
+   */
+  remarks: string
+
+  /**
+   * 系统
+   */
+  system: string
+}
+
+export interface AlgorithmTaskTrackForm {
+  /**
+   * 主键ID
+   */
+  id?: string | number
+
+  /**
+   * 任务名称
+   */
+  name?: string
+
+  /**
+   * 任务状态
+   */
+  status?: string
+
+  /**
+   * 开始时间
+   */
+  startTime?: string
+
+  /**
+   * 结束时间
+   */
+  endTime?: string
+
+  /**
+   * 耗时
+   */
+  costSecond?: number
+
+  /**
+   * 日志
+   */
+  log?: string
+
+  /**
+   * 备注
+   */
+  remarks?: string
+
+  /**
+   * 乐观锁
+   */
+  version?: number
+
+  /**
+   * 系统
+   */
+  system?: string
+}
+
+export interface AlgorithmTaskTrackQuery extends PageQuery {
+  /**
+   * 任务名称
+   */
+  name?: string
+
+  /**
+   * 任务状态
+   */
+  status?: string
+
+  /**
+   * 开始时间
+   */
+  startTime?: string
+
+  /**
+   * 结束时间
+   */
+  endTime?: string
+
+  /**
+   * 耗时
+   */
+  costSecond?: number
+
+  /**
+   * 日志
+   */
+  log?: string
+
+  /**
+   * 备注
+   */
+  remarks?: string
+
+  /**
+   * 系统
+   */
+  system?: string
+
+  /**
+   * 日期范围参数
+   */
+  params?: any
+}

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

@@ -0,0 +1,70 @@
+import http from '@/api'
+import { AlgorithmTaskTrackVO, AlgorithmTaskTrackForm, AlgorithmTaskTrackQuery } from '@/api/interface/demo/algorithmTaskTrack'
+/**
+ * @name 查询可辨识性分析总任务列表
+ * @param query 参数
+ * @returns 返回列表
+ */
+export const listAlgorithmTaskTrackApi = (query: AlgorithmTaskTrackQuery) => {
+  return http.get<AlgorithmTaskTrackVO[]>('/demo/algorithmTaskTrack/list', query, { loading: true })
+}
+
+/**
+ * @name 查询可辨识性分析总任务详细
+ * @param id id
+ * @returns returns
+ */
+export const getAlgorithmTaskTrackApi = (id: string | number) => {
+  return http.get<AlgorithmTaskTrackVO>(`/demo/algorithmTaskTrack/${id}`)
+}
+
+/**
+ * @name 新增可辨识性分析总任务
+ * @param data data
+ * @returns returns
+ */
+export const addAlgorithmTaskTrackApi = (data: AlgorithmTaskTrackForm) => {
+  return http.post<any>('/demo/algorithmTaskTrack', data, { loading: false })
+}
+
+/**
+ * @name 修改可辨识性分析总任务
+ * @param data data
+ * @returns returns
+ */
+export const updateAlgorithmTaskTrackApi = (data: AlgorithmTaskTrackForm) => {
+  return http.put<any>('/demo/algorithmTaskTrack', data, { loading: false })
+}
+
+/**
+ * @name 删除可辨识性分析总任务
+ * @param id id
+ * @returns returns
+ */
+export const delAlgorithmTaskTrackApi = (id: string | number | Array<string | number>) => {
+  return http.delete<any>(`/demo/algorithmTaskTrack/${id}`)
+}
+
+/**
+ * @name 下载模板
+ * @returns returns
+ */
+export const importTemplateApi = () => {
+  return http.downloadPost('/demo/algorithmTaskTrack/importTemplate', {})
+}
+
+/**
+ * @name 导入数据
+ * @returns returns
+ */
+export const importAlgorithmTaskTrackDataApi = (data: any) => {
+  return http.post('/demo/algorithmTaskTrack/importData', data)
+}
+
+/**
+ * @name 导出数据
+ * @returns returns
+ */
+export const exportAlgorithmTaskTrackApi = (data: any) => {
+  return http.downloadPost('/demo/algorithmTaskTrack/export', data)
+}

+ 276 - 0
src/views/demo/algorithmTaskTrack/index.vue

@@ -0,0 +1,276 @@
+<template>
+  <div class="table-box">
+    <ProTable ref="proTable" :columns="columns" row-key="id" :request-api="listAlgorithmTaskTrackApi">
+      <!-- 表格 header 按钮 -->
+      <template #tableHeader="scope">
+        <el-button type="primary" v-auth="['demo:algorithmTaskTrack:add']" icon="CirclePlus" @click="openDialog(1, '可辨识性分析总任务新增')">
+          新增
+        </el-button>
+        <el-button type="primary" v-auth="['demo:algorithmTaskTrack:import']" icon="Upload" plain @click="batchAdd"> 导入 </el-button>
+        <el-button type="primary" v-auth="['demo:algorithmTaskTrack:export']" icon="Download" plain @click="downloadFile"> 导出 </el-button>
+        <el-button
+          type="danger"
+          v-auth="['demo:algorithmTaskTrack: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:algorithmTaskTrack:query']"
+          @click="openDialog(3, '可辨识性分析总任务查看', scope.row)"
+        >
+          查看
+        </el-button>
+        <el-button
+          type="primary"
+          link
+          icon="EditPen"
+          v-auth="['demo:algorithmTaskTrack:edit']"
+          @click="openDialog(2, '可辨识性分析总任务编辑', scope.row)"
+        >
+          编辑
+        </el-button>
+        <el-button type="primary" link icon="Delete" v-auth="['demo:algorithmTaskTrack:remove']" @click="deleteAlgorithmTaskTrack(scope.row)">
+          删除
+        </el-button>
+      </template>
+    </ProTable>
+    <FormDialog ref="formDialogRef" />
+    <ImportExcel ref="dialogRef" />
+  </div>
+</template>
+
+<script setup lang="tsx" name="AlgorithmTaskTrack">
+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 {
+  listAlgorithmTaskTrackApi,
+  delAlgorithmTaskTrackApi,
+  addAlgorithmTaskTrackApi,
+  updateAlgorithmTaskTrackApi,
+  importTemplateApi,
+  importAlgorithmTaskTrackDataApi,
+  exportAlgorithmTaskTrackApi,
+  getAlgorithmTaskTrackApi
+} from '@/api/modules/demo/algorithmTaskTrack'
+
+// ProTable 实例
+const proTable = ref<ProTableInstance>()
+
+// 删除可辨识性分析总任务信息
+const deleteAlgorithmTaskTrack = async (params: any) => {
+  await useHandleData(delAlgorithmTaskTrackApi, params.id, '删除【' + params.id + '】可辨识性分析总任务')
+  proTable.value?.getTableList()
+}
+
+// 批量删除可辨识性分析总任务信息
+const batchDelete = async (ids: string[]) => {
+  await useHandleData(delAlgorithmTaskTrackApi, ids, '删除所选可辨识性分析总任务信息')
+  proTable.value?.clearSelection()
+  proTable.value?.getTableList()
+}
+
+// 导出可辨识性分析总任务列表
+const downloadFile = async () => {
+  ElMessageBox.confirm('确认导出可辨识性分析总任务数据?', '温馨提示', { type: 'warning' }).then(() =>
+    useDownload(exportAlgorithmTaskTrackApi, '可辨识性分析总任务列表', proTable.value?.searchParam)
+  )
+}
+
+// 批量添加可辨识性分析总任务
+const dialogRef = ref<InstanceType<typeof ImportExcel> | null>(null)
+const batchAdd = () => {
+  const params = {
+    title: '可辨识性分析总任务',
+    tempApi: importTemplateApi,
+    importApi: importAlgorithmTaskTrackDataApi,
+    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 getAlgorithmTaskTrackApi(row?.id || null)
+  }
+  // 重置表单
+  setItemsOptions()
+  const params = {
+    title,
+    width: 580,
+    isEdit: type !== 3,
+    itemsOptions: itemsOptions,
+    model: type == 1 ? {} : res.data,
+    api: type == 1 ? addAlgorithmTaskTrackApi : updateAlgorithmTaskTrackApi,
+    getTableList: proTable.value?.getTableList
+  }
+  formDialogRef.value?.openDialog(params)
+}
+
+// 表格配置项
+const columns = reactive<ColumnProps<any>[]>([
+  { type: 'selection', fixed: 'left', width: 70 },
+  { prop: 'id', label: '主键ID' },
+  {
+    prop: 'name',
+    label: '任务名称',
+    search: {
+      el: 'input'
+    },
+    width: 120
+  },
+  {
+    prop: 'status',
+    label: '任务状态',
+    search: {
+      el: 'input'
+    },
+    width: 120
+  },
+  {
+    prop: 'startTime',
+    label: '开始时间',
+    search: {
+      el: 'date-picker',
+      props: { type: 'datetimerange', valueFormat: 'YYYY-MM-DD HH:mm:ss' }
+    },
+    width: 120
+  },
+  {
+    prop: 'endTime',
+    label: '结束时间',
+    search: {
+      el: 'date-picker',
+      props: { type: 'datetimerange', valueFormat: 'YYYY-MM-DD HH:mm:ss' }
+    },
+    width: 120
+  },
+  {
+    prop: 'costSecond',
+    label: '耗时',
+    search: {
+      el: 'input'
+    },
+    width: 120
+  },
+  {
+    prop: 'log',
+    label: '日志',
+    search: {
+      el: 'input'
+    },
+    width: 120
+  },
+  {
+    prop: 'remarks',
+    label: '备注',
+    search: {
+      el: 'input'
+    },
+    width: 120
+  },
+  {
+    prop: 'system',
+    label: '系统',
+    search: {
+      el: 'input'
+    },
+    width: 120
+  },
+  { prop: 'operation', label: '操作', width: 230, fixed: 'right' }
+])
+// 表单配置项
+let itemsOptions: ProForm.ItemsOptions[] = []
+const setItemsOptions = () => {
+  itemsOptions = [
+    {
+      label: '任务名称',
+      prop: 'name',
+      rules: [{ required: true, message: '任务名称不能为空', trigger: 'blur' }],
+      compOptions: {
+        placeholder: '请输入任务名称'
+      }
+    },
+    {
+      label: '任务状态',
+      prop: 'status',
+      rules: [{ required: true, message: '任务状态不能为空', trigger: 'blur' }],
+      compOptions: {
+        placeholder: '请输入任务状态'
+      }
+    },
+    {
+      label: '开始时间',
+      prop: 'startTime',
+      rules: [{ required: true, message: '开始时间不能为空', trigger: 'change' }],
+      compOptions: {
+        elTagName: 'date-picker',
+        type: 'date',
+        placeholder: '请选择开始时间'
+      }
+    },
+    {
+      label: '结束时间',
+      prop: 'endTime',
+      rules: [{ required: true, message: '结束时间不能为空', trigger: 'change' }],
+      compOptions: {
+        elTagName: 'date-picker',
+        type: 'date',
+        placeholder: '请选择结束时间'
+      }
+    },
+    {
+      label: '耗时',
+      prop: 'costSecond',
+      rules: [{ required: true, message: '耗时不能为空', trigger: 'blur' }],
+      compOptions: {
+        placeholder: '请输入耗时'
+      }
+    },
+    {
+      label: '日志',
+      prop: 'log',
+      rules: [{ required: true, message: '日志不能为空', trigger: 'blur' }],
+      compOptions: {
+        type: 'textarea',
+        clearable: true,
+        placeholder: '请输入内容'
+      }
+    },
+    {
+      label: '备注',
+      prop: 'remarks',
+      rules: [{ required: true, message: '备注不能为空', trigger: 'blur' }],
+      compOptions: {
+        placeholder: '请输入备注'
+      }
+    },
+    {
+      label: '系统',
+      prop: 'system',
+      rules: [{ required: true, message: '系统不能为空', trigger: 'blur' }],
+      compOptions: {
+        placeholder: '请输入系统'
+      }
+    }
+  ]
+}
+</script>