|
@@ -0,0 +1,224 @@
|
|
|
+<template>
|
|
|
+ <div class="table-box">
|
|
|
+ <ProTable ref="proTable" :columns="columns" row-key="id" :request-api="listConfigApi">
|
|
|
+ <!-- 表格 header 按钮 -->
|
|
|
+ <template #tableHeader="scope">
|
|
|
+ <el-button type="primary" v-auth="['ag:config:add']" icon="CirclePlus" @click="openDialog(1, '算法配置新增')"> 新增 </el-button>
|
|
|
+ <el-button type="primary" v-auth="['ag:config:import']" icon="Upload" plain @click="batchAdd"> 导入 </el-button>
|
|
|
+ <el-button type="primary" v-auth="['ag:config:export']" icon="Download" plain @click="downloadFile"> 导出 </el-button>
|
|
|
+ <el-button
|
|
|
+ type="danger"
|
|
|
+ v-auth="['ag:config: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="['ag:config:query']" @click="openDialog(3, '算法配置查看', scope.row)"> 查看 </el-button>
|
|
|
+ <el-button type="primary" link icon="EditPen" v-auth="['ag:config:edit']" @click="openDialog(2, '算法配置编辑', scope.row)"> 编辑 </el-button>
|
|
|
+ <el-button type="primary" link icon="Delete" v-auth="['ag:config:remove']" @click="deleteConfig(scope.row)"> 删除 </el-button>
|
|
|
+ </template>
|
|
|
+ </ProTable>
|
|
|
+ <FormDialog ref="formDialogRef" />
|
|
|
+ <ImportExcel ref="dialogRef" />
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script setup lang="tsx" name="Config">
|
|
|
+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 {
|
|
|
+ listConfigApi,
|
|
|
+ delConfigApi,
|
|
|
+ addConfigApi,
|
|
|
+ updateConfigApi,
|
|
|
+ importTemplateApi,
|
|
|
+ importConfigDataApi,
|
|
|
+ exportConfigApi,
|
|
|
+ getConfigApi
|
|
|
+} from '@/api/modules/ag/config'
|
|
|
+import { getDictsApi } from '@/api/modules/system/dictData'
|
|
|
+
|
|
|
+// ProTable 实例
|
|
|
+const proTable = ref<ProTableInstance>()
|
|
|
+
|
|
|
+// 删除算法配置信息
|
|
|
+const deleteConfig = async (params: any) => {
|
|
|
+ await useHandleData(delConfigApi, params.id, '删除【' + params.id + '】算法配置')
|
|
|
+ proTable.value?.getTableList()
|
|
|
+}
|
|
|
+
|
|
|
+// 批量删除算法配置信息
|
|
|
+const batchDelete = async (ids: string[]) => {
|
|
|
+ await useHandleData(delConfigApi, ids, '删除所选算法配置信息')
|
|
|
+ proTable.value?.clearSelection()
|
|
|
+ proTable.value?.getTableList()
|
|
|
+}
|
|
|
+
|
|
|
+// 导出算法配置列表
|
|
|
+const downloadFile = async () => {
|
|
|
+ ElMessageBox.confirm('确认导出算法配置数据?', '温馨提示', { type: 'warning' }).then(() =>
|
|
|
+ useDownload(exportConfigApi, '算法配置列表', proTable.value?.searchParam)
|
|
|
+ )
|
|
|
+}
|
|
|
+
|
|
|
+// 批量添加算法配置
|
|
|
+const dialogRef = ref<InstanceType<typeof ImportExcel> | null>(null)
|
|
|
+const batchAdd = () => {
|
|
|
+ const params = {
|
|
|
+ title: '算法配置',
|
|
|
+ tempApi: importTemplateApi,
|
|
|
+ importApi: importConfigDataApi,
|
|
|
+ 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 getConfigApi(row?.id || null)
|
|
|
+ }
|
|
|
+ // 重置表单
|
|
|
+ setItemsOptions()
|
|
|
+ const params = {
|
|
|
+ title,
|
|
|
+ width: 580,
|
|
|
+ isEdit: type !== 3,
|
|
|
+ itemsOptions: itemsOptions,
|
|
|
+ model: type == 1 ? {} : res.data,
|
|
|
+ api: type == 1 ? addConfigApi : updateConfigApi,
|
|
|
+ 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: '类型',
|
|
|
+ tag: true,
|
|
|
+ enum: () => getDictsApi('biz_ag_type'),
|
|
|
+ search: {
|
|
|
+ el: 'tree-select'
|
|
|
+ },
|
|
|
+ fieldNames: { label: 'dictLabel', value: 'dictValue' }
|
|
|
+ },
|
|
|
+ {
|
|
|
+ prop: 'subsystem',
|
|
|
+ label: '分系统',
|
|
|
+ tag: true,
|
|
|
+ enum: () => getDictsApi('biz_sub_config'),
|
|
|
+ search: {
|
|
|
+ el: 'tree-select'
|
|
|
+ },
|
|
|
+ fieldNames: { label: 'dictLabel', value: 'dictValue' }
|
|
|
+ },
|
|
|
+ {
|
|
|
+ prop: 'algorithmName',
|
|
|
+ label: '算法名称',
|
|
|
+ search: {
|
|
|
+ el: 'input'
|
|
|
+ },
|
|
|
+ width: 120
|
|
|
+ },
|
|
|
+ {
|
|
|
+ prop: 'algorithmAddress',
|
|
|
+ label: '算法地址',
|
|
|
+ search: {
|
|
|
+ el: 'input'
|
|
|
+ },
|
|
|
+ width: 120
|
|
|
+ },
|
|
|
+ { prop: 'operation', label: '操作', width: 230, fixed: 'right' }
|
|
|
+])
|
|
|
+// 表单配置项
|
|
|
+let itemsOptions: ProForm.ItemsOptions[] = []
|
|
|
+const setItemsOptions = () => {
|
|
|
+ itemsOptions = [
|
|
|
+ {
|
|
|
+ label: '类型',
|
|
|
+ prop: 'type',
|
|
|
+ rules: [{ required: true, message: '类型不能为空', trigger: 'change' }],
|
|
|
+ options: {
|
|
|
+ labelKey: 'dictLabel',
|
|
|
+ valueKey: 'dictValue'
|
|
|
+ },
|
|
|
+ compOptions: {
|
|
|
+ elTagName: 'radio-group',
|
|
|
+ labelKey: 'dictLabel',
|
|
|
+ valueKey: 'dictValue',
|
|
|
+ enum: () => getDictsApi('biz_ag_type'),
|
|
|
+ placeholder: '请选择类型'
|
|
|
+ }
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: '父id',
|
|
|
+ prop: 'parentId',
|
|
|
+ compOptions: {
|
|
|
+ placeholder: '请输入父id'
|
|
|
+ }
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: '分系统',
|
|
|
+ prop: 'subsystem',
|
|
|
+ compOptions: {
|
|
|
+ elTagName: 'select',
|
|
|
+ labelKey: 'dictLabel',
|
|
|
+ valueKey: 'dictValue',
|
|
|
+ enum: () => getDictsApi('biz_sub_config'),
|
|
|
+ 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',
|
|
|
+ compOptions: {
|
|
|
+ type: 'textarea',
|
|
|
+ clearable: true,
|
|
|
+ placeholder: '请输入内容',
|
|
|
+ rows: 8
|
|
|
+ }
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: '备注',
|
|
|
+ prop: 'remarks',
|
|
|
+ compOptions: {
|
|
|
+ placeholder: '请输入备注'
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ]
|
|
|
+}
|
|
|
+</script>
|