123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258 |
- <template>
- <div class="table-box">
- <ProTable ref="proTable" :columns="columns" row-key="id" :request-api="listAlgorithmConfigApi">
- <!-- 表格 header 按钮 -->
- <template #tableHeader="scope">
- <el-button type="primary" v-auth="['demo:algorithmConfig:add']" icon="CirclePlus" @click="openDialog(1, '通用算法配置新增')">
- 新增
- </el-button>
- <el-button type="primary" v-auth="['demo:algorithmConfig:import']" icon="Upload" plain @click="batchAdd"> 导入 </el-button>
- <el-button type="primary" v-auth="['demo:algorithmConfig:export']" icon="Download" plain @click="downloadFile"> 导出 </el-button>
- <el-button
- type="danger"
- v-auth="['demo:algorithmConfig: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:algorithmConfig:query']" @click="openDialog(3, '通用算法配置查看', scope.row)">
- 查看
- </el-button>
- <el-button type="primary" link icon="EditPen" v-auth="['demo:algorithmConfig:edit']" @click="openDialog(2, '通用算法配置编辑', scope.row)">
- 编辑
- </el-button>
- <el-button type="primary" link icon="Delete" v-auth="['demo:algorithmConfig:remove']" @click="deleteAlgorithmConfig(scope.row)">
- 删除
- </el-button>
- </template>
- </ProTable>
- <FormDialog ref="formDialogRef" />
- <ImportExcel ref="dialogRef" />
- </div>
- </template>
- <script setup lang="tsx" name="AlgorithmConfig">
- 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 {
- listAlgorithmConfigApi,
- delAlgorithmConfigApi,
- addAlgorithmConfigApi,
- updateAlgorithmConfigApi,
- importTemplateApi,
- importAlgorithmConfigDataApi,
- exportAlgorithmConfigApi,
- getAlgorithmConfigApi
- } from '@/api/modules/demo/algorithmConfig'
- // ProTable 实例
- const proTable = ref<ProTableInstance>()
- // 删除通用算法配置信息
- const deleteAlgorithmConfig = async (params: any) => {
- await useHandleData(delAlgorithmConfigApi, params.id, '删除【' + params.id + '】通用算法配置')
- proTable.value?.getTableList()
- }
- // 批量删除通用算法配置信息
- const batchDelete = async (ids: string[]) => {
- await useHandleData(delAlgorithmConfigApi, ids, '删除所选通用算法配置信息')
- proTable.value?.clearSelection()
- proTable.value?.getTableList()
- }
- // 导出通用算法配置列表
- const downloadFile = async () => {
- ElMessageBox.confirm('确认导出通用算法配置数据?', '温馨提示', { type: 'warning' }).then(() =>
- useDownload(exportAlgorithmConfigApi, '通用算法配置列表', proTable.value?.searchParam)
- )
- }
- // 批量添加通用算法配置
- const dialogRef = ref<InstanceType<typeof ImportExcel> | null>(null)
- const batchAdd = () => {
- const params = {
- title: '通用算法配置',
- tempApi: importTemplateApi,
- importApi: importAlgorithmConfigDataApi,
- 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 getAlgorithmConfigApi(row?.id || null)
- }
- // 重置表单
- setItemsOptions()
- const params = {
- title,
- width: 580,
- isEdit: type !== 3,
- itemsOptions: itemsOptions,
- model: type == 1 ? {} : res.data,
- api: type == 1 ? addAlgorithmConfigApi : updateAlgorithmConfigApi,
- getTableList: proTable.value?.getTableList
- }
- formDialogRef.value?.openDialog(params)
- }
- // 表格配置项
- const columns = reactive<ColumnProps<any>[]>([
- { type: 'selection', fixed: 'left', width: 70 },
- { prop: 'id', label: 'ID' },
- {
- prop: 'tool',
- label: '工具',
- search: {
- el: 'input'
- },
- width: 120
- },
- {
- prop: 'module',
- label: '模块',
- search: {
- el: 'input'
- },
- width: 120
- },
- {
- prop: 'algorithmName',
- label: '算法名称',
- search: {
- el: 'input'
- },
- width: 120
- },
- {
- prop: 'startApi',
- label: '开始接口',
- search: {
- el: 'input'
- },
- width: 120
- },
- {
- prop: 'pauseApi',
- label: '暂停接口',
- search: {
- el: 'input'
- },
- width: 120
- },
- {
- prop: 'terminateApi',
- label: '终止接口',
- search: {
- el: 'input'
- },
- width: 120
- },
- {
- prop: 'parameters',
- label: '参数',
- search: {
- el: 'input'
- },
- 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: 'tool',
- rules: [{ required: true, message: '工具名称不能为空', trigger: 'blur' }],
- compOptions: {
- placeholder: '请输入工具名称'
- }
- },
- {
- label: '模块',
- prop: 'module',
- rules: [{ required: true, message: '模块不能为空', trigger: 'blur' }],
- compOptions: {
- placeholder: '请输入模块'
- }
- },
- {
- label: '算法名称',
- prop: 'algorithmName',
- rules: [{ required: true, message: '算法名称不能为空', trigger: 'blur' }],
- compOptions: {
- placeholder: '请输入算法名称'
- }
- },
- {
- label: '开始接口',
- prop: 'startApi',
- rules: [{ required: true, message: '开始接口不能为空', trigger: 'blur' }],
- compOptions: {
- placeholder: '请输入开始接口'
- }
- },
- {
- label: '暂停接口',
- prop: 'pauseApi',
- rules: [{ required: true, message: '暂停接口不能为空', trigger: 'blur' }],
- compOptions: {
- placeholder: '请输入暂停接口'
- }
- },
- {
- label: '终止接口',
- prop: 'terminateApi',
- rules: [{ required: true, message: '终止接口不能为空', trigger: 'blur' }],
- compOptions: {
- placeholder: '请输入终止接口'
- }
- },
- {
- label: '参数',
- prop: 'parameters',
- rules: [{ required: true, message: '参数不能为空', trigger: 'blur' }],
- compOptions: {
- type: 'textarea',
- rows: 2,
- placeholder: '请输入参数'
- }
- },
- {
- label: '备注',
- prop: 'remarks',
- rules: [{ required: false, message: '备注不能为空', trigger: 'blur' }],
- compOptions: {
- placeholder: '请输入备注'
- }
- }
- ]
- }
- </script>
|