Browse Source

feat: 注视序列轨迹前端搭建

WANGKANG 7 months ago
parent
commit
5904838338

+ 221 - 0
src/api/interface/demo/trackSequence.ts

@@ -0,0 +1,221 @@
+import { PageQuery, BaseEntity } from '@/api/interface/index'
+export interface TrackSequenceVO extends BaseEntity {
+  /**
+   * ID
+   */
+  id: string | number
+
+  /**
+   * 任务名称
+   */
+  name: string
+
+  /**
+    * 状态
+        0:未开始
+        1:进行中
+        2:完成
+        3:失败
+        4:中断
+    */
+  status: string
+
+  /**
+   * 开始时间
+   */
+  startTime: string
+
+  /**
+   * 结束时间
+   */
+  endTime: string
+
+  /**
+   * 耗时
+   */
+  costSecond: number
+
+  /**
+   * 日志
+   */
+  log: string
+
+  /**
+   * 备注
+   */
+  remarks: string
+
+  /**
+   * $column.columnComment
+   */
+  url: string
+
+  /**
+   * $column.columnComment
+   */
+  inputOssId: string | number
+
+  /**
+   * 输入路径
+   */
+  inputPath: string
+
+  /**
+   * 输出路径
+   */
+  outputPath: string
+
+  /**
+   * zip文件输出路径
+   */
+  zipFilePath: string
+}
+
+export interface TrackSequenceForm {
+  /**
+   * ID
+   */
+  id?: string | number
+
+  /**
+   * 任务名称
+   */
+  name?: string
+
+  /**
+        * 状态
+0:未开始
+1:进行中
+2:完成
+3:失败
+4:中断
+        */
+  status?: string
+
+  /**
+   * 开始时间
+   */
+  startTime?: string
+
+  /**
+   * 结束时间
+   */
+  endTime?: string
+
+  /**
+   * 耗时
+   */
+  costSecond?: number
+
+  /**
+   * 日志
+   */
+  log?: string
+
+  /**
+   * 备注
+   */
+  remarks?: string
+
+  /**
+   * $column.columnComment
+   */
+  version?: number
+
+  /**
+   * $column.columnComment
+   */
+  url?: string
+
+  /**
+   * $column.columnComment
+   */
+  inputOssId?: string | number
+
+  /**
+   * 输入路径
+   */
+  inputPath?: string
+
+  /**
+   * 输出路径
+   */
+  outputPath?: string
+
+  /**
+   * zip文件输出路径
+   */
+  zipFilePath?: string
+}
+
+export interface TrackSequenceQuery extends PageQuery {
+  /**
+   * 任务名称
+   */
+  name?: string
+
+  /**
+        * 状态
+0:未开始
+1:进行中
+2:完成
+3:失败
+4:中断
+        */
+  status?: string
+
+  /**
+   * 开始时间
+   */
+  startTime?: string
+
+  /**
+   * 结束时间
+   */
+  endTime?: string
+
+  /**
+   * 耗时
+   */
+  costSecond?: number
+
+  /**
+   * 日志
+   */
+  log?: string
+
+  /**
+   * 备注
+   */
+  remarks?: string
+
+  /**
+   * $column.columnComment
+   */
+  url?: string
+
+  /**
+   * $column.columnComment
+   */
+  inputOssId?: string | number
+
+  /**
+   * 输入路径
+   */
+  inputPath?: string
+
+  /**
+   * 输出路径
+   */
+  outputPath?: string
+
+  /**
+   * zip文件输出路径
+   */
+  zipFilePath?: string
+
+  /**
+   * 日期范围参数
+   */
+  params?: any
+}

+ 8 - 0
src/api/modules/demo/toInfrared.ts

@@ -68,3 +68,11 @@ export const importToInfraredDataApi = (data: any) => {
 export const exportToInfraredApi = (data: any) => {
   return http.downloadPost('/demo/toInfrared/export', data)
 }
+
+export const startToInfraredApi = (id: string | number) => {
+  return http.downloadPost('/demo/toInfrared/start' + id)
+}
+
+export const stopToInfraredApi = (id: string | number) => {
+  return http.downloadPost('/demo/toInfrared/stop' + id)
+}

+ 78 - 0
src/api/modules/demo/trackSequence.ts

@@ -0,0 +1,78 @@
+import http from '@/api'
+import { TrackSequenceVO, TrackSequenceForm, TrackSequenceQuery } from '@/api/interface/demo/trackSequence'
+/**
+ * @name 查询注视轨迹序列列表
+ * @param query 参数
+ * @returns 返回列表
+ */
+export const listTrackSequenceApi = (query: TrackSequenceQuery) => {
+  return http.get<TrackSequenceVO[]>('/demo/trackSequence/list', query, { loading: true })
+}
+
+/**
+ * @name 查询注视轨迹序列详细
+ * @param id id
+ * @returns returns
+ */
+export const getTrackSequenceApi = (id: string | number) => {
+  return http.get<TrackSequenceVO>(`/demo/trackSequence/${id}`)
+}
+
+/**
+ * @name 新增注视轨迹序列
+ * @param data data
+ * @returns returns
+ */
+export const addTrackSequenceApi = (data: TrackSequenceForm) => {
+  return http.post<any>('/demo/trackSequence', data, { loading: false })
+}
+
+/**
+ * @name 修改注视轨迹序列
+ * @param data data
+ * @returns returns
+ */
+export const updateTrackSequenceApi = (data: TrackSequenceForm) => {
+  return http.put<any>('/demo/trackSequence', data, { loading: false })
+}
+
+/**
+ * @name 删除注视轨迹序列
+ * @param id id
+ * @returns returns
+ */
+export const delTrackSequenceApi = (id: string | number | Array<string | number>) => {
+  return http.delete<any>(`/demo/trackSequence/${id}`)
+}
+
+/**
+ * @name 下载模板
+ * @returns returns
+ */
+export const importTemplateApi = () => {
+  return http.downloadPost('/demo/trackSequence/importTemplate', {})
+}
+
+/**
+ * @name 导入数据
+ * @returns returns
+ */
+export const importTrackSequenceDataApi = (data: any) => {
+  return http.post('/demo/trackSequence/importData', data)
+}
+
+/**
+ * @name 导出数据
+ * @returns returns
+ */
+export const exportTrackSequenceApi = (data: any) => {
+  return http.downloadPost('/demo/trackSequence/export', data)
+}
+
+export const startTrackSequenceApi = (id: string | number) => {
+  return http.downloadPost('/demo/trackSequence/start' + id)
+}
+
+export const stopTrackSequenceApi = (id: string | number) => {
+  return http.downloadPost('/demo/trackSequence/stop' + id)
+}

+ 230 - 0
src/views/demo/trackSequence/index.vue

@@ -0,0 +1,230 @@
+<template>
+  <div class="table-box">
+    <ProTable ref="proTable" :columns="columns" row-key="id" :request-api="listTrackSequenceApi">
+      <!-- 表格 header 按钮 -->
+      <template #tableHeader="scope">
+        <el-button type="primary" v-auth="['demo:trackSequence:add']" icon="CirclePlus" @click="openDialog(1, '注视轨迹序列新增')"> 新增 </el-button>
+        <!-- <el-button type="primary" v-auth="['demo:trackSequence:import']" icon="Upload" plain @click="batchAdd"> 导入 </el-button>
+        <el-button type="primary" v-auth="['demo:trackSequence:export']" icon="Download" plain @click="downloadFile"> 导出 </el-button> -->
+        <el-button
+          type="danger"
+          v-auth="['demo:trackSequence: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:trackSequence:start']"
+          v-if="scope.row.status == '0' || scope.row.status == '3' || scope.row.status == '4'"
+          ><!-- @click="starttrackSequence(scope.row)" -->
+          <!-- @confirm="stoptrackSequence(scope.row)" -->
+          开始
+        </el-button>
+        <el-popconfirm title="确定终止此任务吗?" v-if="scope.row.status == '1'">
+          <template #reference>
+            <el-button type="primary" link icon="Delete"> 终止 </el-button>
+          </template>
+        </el-popconfirm>
+        <el-button type="primary" link icon="View" v-auth="['demo:trackSequence:download']" v-if="scope.row.status == '2'">
+          <!-- @click="dowloadtrackSequence(scope.row)" -->
+          下载
+        </el-button>
+        <!-- <el-button type="primary" link icon="View" v-auth="['demo:toInfrared:query']" @click="openDialog(3, '查看', scope.row)"> 查看 </el-button> -->
+        <!-- <el-button type="primary" link icon="EditPen"v-auth="['demo:toInfrared:edit']" @click="openDialog(2, '编辑', scope.row)"> 编辑 </el-button> -->
+        <el-button
+          type="primary"
+          link
+          icon="Delete"
+          v-auth="['demo:toInfrared:remove']"
+          @click="deleteToInfrared(scope.row)"
+          :disabled="scope.row.status == '1'"
+        >
+          删除
+        </el-button>
+      </template>
+    </ProTable>
+    <FormDialog ref="formDialogRef" />
+    <ImportExcel ref="dialogRef" />
+  </div>
+</template>
+
+<script setup lang="tsx" name="TrackSequence">
+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 {
+  listTrackSequenceApi,
+  delTrackSequenceApi,
+  addTrackSequenceApi,
+  updateTrackSequenceApi,
+  importTemplateApi,
+  importTrackSequenceDataApi,
+  exportTrackSequenceApi,
+  getTrackSequenceApi,
+  startTrackSequenceApi,
+  stopTrackSequenceApi
+} from '@/api/modules/demo/trackSequence'
+import statusEnums from '@/utils/status'
+
+// ProTable 实例
+const proTable = ref<ProTableInstance>()
+
+// 删除注视轨迹序列信息
+const deleteTrackSequence = async (params: any) => {
+  await useHandleData(delTrackSequenceApi, params.id, '删除【' + params.id + '】注视轨迹序列')
+  proTable.value?.getTableList()
+}
+
+// 批量删除注视轨迹序列信息
+const batchDelete = async (ids: string[]) => {
+  await useHandleData(delTrackSequenceApi, ids, '删除所选注视轨迹序列信息')
+  proTable.value?.clearSelection()
+  proTable.value?.getTableList()
+}
+
+// 导出注视轨迹序列列表
+const downloadFile = async () => {
+  ElMessageBox.confirm('确认导出注视轨迹序列数据?', '温馨提示', { type: 'warning' }).then(() =>
+    useDownload(exportTrackSequenceApi, '注视轨迹序列列表', proTable.value?.searchParam)
+  )
+}
+
+// 批量添加注视轨迹序列
+const dialogRef = ref<InstanceType<typeof ImportExcel> | null>(null)
+const batchAdd = () => {
+  const params = {
+    title: '注视轨迹序列',
+    tempApi: importTemplateApi,
+    importApi: importTrackSequenceDataApi,
+    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 getTrackSequenceApi(row?.id || null)
+  }
+  // 重置表单
+  setItemsOptions()
+  const params = {
+    title,
+    width: 580,
+    isEdit: type !== 3,
+    itemsOptions: itemsOptions,
+    model: type == 1 ? {} : res.data,
+    api: type == 1 ? addTrackSequenceApi : updateTrackSequenceApi,
+    getTableList: proTable.value?.getTableList
+  }
+  formDialogRef.value?.openDialog(params)
+}
+
+// 表格配置项
+const columns = reactive<ColumnProps<any>[]>([
+  { type: 'selection', fixed: 'left', width: 70 },
+  { prop: 'id', label: '主键ID', width: 180 },
+  {
+    prop: 'name',
+    label: '任务名称',
+    search: {
+      el: 'input'
+    },
+    width: 150
+  },
+  {
+    prop: 'status',
+    label: '任务状态',
+    search: {
+      el: 'select'
+    },
+    tag: true,
+    enum: statusEnums,
+    width: 150
+  },
+  {
+    prop: 'startTime',
+    label: '开始时间',
+    width: 180
+  },
+  {
+    prop: 'endTime',
+    label: '结束时间',
+    width: 180
+  },
+  {
+    prop: 'costSecond',
+    label: '耗时',
+    width: 120
+  },
+  {
+    prop: 'log',
+    label: '日志',
+    width: 120
+  },
+  {
+    prop: 'outputPath',
+    label: '输出路径',
+    width: 120
+  },
+  {
+    prop: 'remarks',
+    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: 'inputOssId',
+      rules: [{ required: true, message: '图片集不能为空', trigger: 'blur' }],
+      compOptions: {
+        elTagName: 'file-upload',
+        fileSize: 4096,
+        fileType: ['zip'],
+        placeholder: '请上传图片集'
+      }
+    },
+    {
+      label: '备注',
+      prop: 'remarks',
+      rules: [],
+      compOptions: {
+        placeholder: '请输入备注'
+      }
+    }
+  ]
+}
+</script>