| | |
| | | collectType: string, |
| | | param: string, |
| | | descp: string, |
| | | isAuth: number, |
| | | authUrl: string, |
| | | status: number |
| | | } |
| | | |
| | |
| | | |
| | | export interface HttpTokenVO { |
| | | id: string |
| | | apiId: string, |
| | | loginUrl: string, |
| | | clientId: string, |
| | | clientSecret: string, |
| | | username: string, |
| | | password: string, |
| | | refreshFreq: string, |
| | | token: string, |
| | | } |
| | | |
| | | export interface HttpTokenPageReqVO extends PageParam { |
| | | apiId?: string |
| | | loginUrl?: string |
| | | } |
| | | |
| | | // 查询HttpToken列表 |
| | |
| | | return request.get({ url: '/data/channel/http/token/page', params }) |
| | | } |
| | | |
| | | // 查询HttpToken列表 |
| | | export const getHttpTokenList = () => { |
| | | return request.get({ url: '/data/channel/http/token/list'}) |
| | | } |
| | | |
| | | // 查询HttpToken详情 |
| | | export const getHttpToken = (id: number) => { |
| | | return request.get({ url: `/data/channel/http/token/info/${id}`}) |
| | |
| | | ENABLE: true, // 启用 |
| | | DISABLE: false // 禁用 |
| | | } |
| | | |
| | | export const CommonInfraBool = { |
| | | TRUE: true, // 启用 |
| | | FALSE: false // 禁用 |
| | | } |
文件名从 src/views/data/channel/http/HttpApiForm.vue 修改 |
| | |
| | | </el-col> |
| | | </el-row> |
| | | <el-row> |
| | | <el-col :span="12"> |
| | | <el-form-item label="是否认证" prop="isAuth"> |
| | | <el-select v-model="formData.isAuth" placeholder="请选择"> |
| | | <el-option |
| | | v-for="dict in getBoolDictOptions(DICT_TYPE.INFRA_BOOLEAN_STRING)" |
| | | :key="dict.value" |
| | | :label="dict.label" |
| | | :value="dict.value" |
| | | /> |
| | | </el-select> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="认证地址" prop="authUrl"> |
| | | <el-select v-model="formData.authUrl" clearable placeholder="请选择数据源"> |
| | | <el-option |
| | | v-for="item in httpTokenList" |
| | | :key="item.id" |
| | | :label="item.loginUrl" |
| | | :value="item.id" |
| | | /> |
| | | </el-select> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | |
| | | <el-row> |
| | | <el-col :span="24"> |
| | | <el-form-item label="描述" prop="descp"> |
| | | <el-input v-model="formData.descp" placeholder="请输入描述" type="textarea" maxlength="100" |
| | |
| | | </template> |
| | | <script lang="ts" setup> |
| | | import * as HttpApi from '@/api/data/channel/http' |
| | | import * as HttpToken from '@/api/data/channel/http/token' |
| | | import { DICT_TYPE, getStrDictOptions, getBoolDictOptions } from '@/utils/dict' |
| | | import {CommonStatusEnum, CommonInfraBool} from '@/utils/constants' |
| | | import * as DataSourceConfigApi from "@/api/infra/dataSourceConfig"; |
| | | import {HttpTokenVO} from "@/api/data/channel/http/token"; |
| | | |
| | | defineOptions({name: 'DataHttpApiForm'}) |
| | | |
| | |
| | | const formType = ref('') // 表单的类型:create - 新增;update - 修改 |
| | | const formData = ref({ |
| | | id: undefined, |
| | | name: undefined, |
| | | code: undefined, |
| | | name: undefined, |
| | | url: undefined, |
| | | method: undefined, |
| | | collectType: undefined, |
| | | param: undefined, |
| | | descp: undefined, |
| | | status: undefined |
| | | isAuth: CommonInfraBool.FALSE, |
| | | authUrl: undefined |
| | | }) |
| | | const formRules = reactive({ |
| | | name: [{required: true, message: '名称不能为空', trigger: 'blur'}], |
| | |
| | | url: [{required: true, message: 'url不能为空', trigger: 'blur'}], |
| | | }) |
| | | const formRef = ref() // 表单 Ref |
| | | const httpTokenList = ref([] as HttpToken.HttpTokenVO[]) |
| | | |
| | | /** 打开弹窗 */ |
| | | const open = async (type: string, id?: number) => { |
| | |
| | | formLoading.value = false |
| | | } |
| | | } |
| | | // 加载认证列表 |
| | | httpTokenList.value = await HttpToken.getHttpTokenList() |
| | | } |
| | | defineExpose({open}) // 提供 open 方法,用于打开弹窗 |
| | | |
| | |
| | | const resetForm = () => { |
| | | formData.value = { |
| | | id: undefined, |
| | | name: undefined, |
| | | code: undefined, |
| | | name: undefined, |
| | | url: undefined, |
| | | method: undefined, |
| | | collectType: undefined, |
| | | param: undefined, |
| | | descp: undefined, |
| | | status: undefined |
| | | isAuth: CommonInfraBool.FALSE, |
| | | authUrl: undefined |
| | | } |
| | | formRef.value?.resetFields() |
| | | } |
对比新文件 |
| | |
| | | <template> |
| | | <Dialog v-model="dialogVisible" :title="dialogTitle" width="50%"> |
| | | <el-form |
| | | ref="formRef" |
| | | v-loading="formLoading" |
| | | :model="formData" |
| | | :rules="formRules" |
| | | label-width="120px" |
| | | > |
| | | <el-row> |
| | | <el-col :span="24"> |
| | | <el-form-item label="认证地址" prop="loginUrl"> |
| | | <el-input v-model="formData.loginUrl" placeholder="请输认证地址"/> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | <el-row> |
| | | <el-col :span="12"> |
| | | <el-form-item label="ClientId" prop="clientId"> |
| | | <el-input v-model="formData.clientId" placeholder="请输ClientId"/> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="ClientSecret" prop="clientSecret"> |
| | | <el-input v-model="formData.clientSecret" placeholder="请输ClientSecret"/> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | <el-row> |
| | | <el-col :span="12"> |
| | | <el-form-item label="用户名" prop="username"> |
| | | <el-input v-model="formData.username" placeholder="请输用户名"/> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="密码" prop="password"> |
| | | <el-input v-model="formData.password" placeholder="请输密码"/> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | <el-row> |
| | | <el-col :span="12"> |
| | | <el-form-item label="刷新频率" prop="refreshFreq"> |
| | | <el-input v-model="formData.refreshFreq" placeholder="请输刷新频率"/> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | </el-form> |
| | | <template #footer> |
| | | <el-button :disabled="formLoading" type="primary" @click="submitForm">确 定</el-button> |
| | | <el-button @click="dialogVisible = false">取 消</el-button> |
| | | </template> |
| | | </Dialog> |
| | | </template> |
| | | <script lang="ts" setup> |
| | | import * as HttpTokenApi from '@/api/data/channel/http/token' |
| | | import { DICT_TYPE, getStrDictOptions, getBoolDictOptions } from '@/utils/dict' |
| | | |
| | | defineOptions({name: 'HttpTokenForm'}) |
| | | |
| | | const {t} = useI18n() // 国际化 |
| | | const message = useMessage() // 消息弹窗 |
| | | const dialogVisible = ref(false) // 弹窗的是否展示 |
| | | const dialogTitle = ref('') // 弹窗的标题 |
| | | const formLoading = ref(false) // 表单的加载中:1)修改时的数据加载;2)提交的按钮禁用 |
| | | const formType = ref('') // 表单的类型:create - 新增;update - 修改 |
| | | const formData = ref({ |
| | | id: undefined, |
| | | loginUrl: undefined, |
| | | clientId: undefined, |
| | | clientSecret: undefined, |
| | | username: undefined, |
| | | password: undefined, |
| | | token: undefined, |
| | | refreshFreq: undefined |
| | | }) |
| | | const formRules = reactive({ |
| | | loginUrl: [{required: true, message: '登录地址不能为空', trigger: 'blur'}], |
| | | username: [{required: true, message: '用户名不能为空', trigger: 'blur'}], |
| | | password: [{required: true, message: '密码不能为空', trigger: 'blur'}], |
| | | refreshFreq: [{required: true, message: '刷新频率不能为空', trigger: 'blur'}] |
| | | }) |
| | | const formRef = ref() // 表单 Ref |
| | | |
| | | /** 打开弹窗 */ |
| | | const open = async (type: string, id?: number, apiId?: string) => { |
| | | dialogVisible.value = true |
| | | dialogTitle.value = t('action.' + type) |
| | | formType.value = type |
| | | resetForm() |
| | | if (apiId) { |
| | | formData.value.apiId = apiId |
| | | } |
| | | // 修改时,设置数据 |
| | | if (id) { |
| | | formLoading.value = true |
| | | try { |
| | | formData.value = await HttpTokenApi.getHttpToken(id) |
| | | } finally { |
| | | formLoading.value = false |
| | | } |
| | | } |
| | | } |
| | | defineExpose({open}) // 提供 open 方法,用于打开弹窗 |
| | | |
| | | /** 提交表单 */ |
| | | const emit = defineEmits(['success']) // 定义 success 事件,用于操作成功后的回调 |
| | | const submitForm = async () => { |
| | | // 校验表单 |
| | | if (!formRef) return |
| | | const valid = await formRef.value.validate() |
| | | if (!valid) return |
| | | // 提交请求 |
| | | formLoading.value = true |
| | | try { |
| | | const data = formData.value as unknown as HttpTokenApi.HttpTokenVO |
| | | if (formType.value === 'create') { |
| | | await HttpTokenApi.createHttpToken(data) |
| | | message.success(t('common.createSuccess')) |
| | | } else { |
| | | await HttpTokenApi.updateHttpToken(data) |
| | | message.success(t('common.updateSuccess')) |
| | | } |
| | | dialogVisible.value = false |
| | | // 发送操作成功的事件 |
| | | emit('success') |
| | | } finally { |
| | | formLoading.value = false |
| | | } |
| | | } |
| | | |
| | | /** 重置表单 */ |
| | | const resetForm = () => { |
| | | formData.value = { |
| | | id: undefined, |
| | | loginUrl: undefined, |
| | | clientId: undefined, |
| | | clientSecret: undefined, |
| | | username: undefined, |
| | | password: undefined, |
| | | token: undefined, |
| | | refreshFreq: undefined |
| | | } |
| | | formRef.value?.resetFields() |
| | | } |
| | | </script> |
对比新文件 |
| | |
| | | <template> |
| | | <!-- 搜索 --> |
| | | <ContentWrap> |
| | | <el-form |
| | | class="-mb-15px" |
| | | :model="queryParams" |
| | | ref="queryFormRef" |
| | | :inline="true" |
| | | label-width="68px" |
| | | > |
| | | <el-form-item label="名称" prop="name"> |
| | | <el-input |
| | | v-model="queryParams.name" |
| | | placeholder="请输入名称" |
| | | clearable |
| | | @keyup.enter="handleQuery" |
| | | class="!w-240px" |
| | | /> |
| | | </el-form-item> |
| | | <el-form-item> |
| | | <el-button @click="handleQuery"> |
| | | <Icon icon="ep:search" class="mr-5px"/> |
| | | 搜索 |
| | | </el-button> |
| | | <el-button @click="resetQuery"> |
| | | <Icon icon="ep:refresh" class="mr-5px"/> |
| | | 重置 |
| | | </el-button> |
| | | <el-button |
| | | type="primary" |
| | | plain |
| | | @click="openForm('create')" |
| | | v-hasPermi="['data:channel-http:create']" |
| | | > |
| | | <Icon icon="ep:plus" class="mr-5px"/> |
| | | 新增 |
| | | </el-button> |
| | | </el-form-item> |
| | | </el-form> |
| | | </ContentWrap> |
| | | |
| | | <!-- 列表 --> |
| | | <ContentWrap> |
| | | <el-table v-loading="loading" :data="list"> |
| | | <el-table-column label="认证地址" header-align="center" align="left" min-width="300" prop="loginUrl"/> |
| | | <el-table-column label="ClientId" align="center" prop="clientId"/> |
| | | <el-table-column label="ClientSecret" align="center" prop="clientSecret"/> |
| | | <el-table-column label="用户名" align="center" prop="username"/> |
| | | <el-table-column label="密码" align="center" prop="password"/> |
| | | <el-table-column label="刷新频率" align="center" prop="refreshFreq"/> |
| | | <el-table-column label="操作" align="center" min-width="110" fixed="right"> |
| | | <template #default="scope"> |
| | | <el-button |
| | | link |
| | | type="primary" |
| | | @click="openForm('update', scope.row.id)" |
| | | v-hasPermi="['data:channel-http:update']" |
| | | > |
| | | 编辑 |
| | | </el-button> |
| | | <el-button |
| | | link |
| | | type="danger" |
| | | @click="handleDelete(scope.row.id)" |
| | | v-hasPermi="['data:channel-http:delete']" |
| | | > |
| | | 删除 |
| | | </el-button> |
| | | </template> |
| | | </el-table-column> |
| | | </el-table> |
| | | <!-- 分页 --> |
| | | <Pagination |
| | | :total="total" |
| | | v-model:page="queryParams.pageNo" |
| | | v-model:limit="queryParams.pageSize" |
| | | @pagination="getList" |
| | | /> |
| | | </ContentWrap> |
| | | |
| | | <!-- 表单弹窗:添加/修改 --> |
| | | <TokenForm ref="formRef" @success="getList"/> |
| | | |
| | | </template> |
| | | <script lang="ts" setup> |
| | | import * as HttpToken from '@/api/data/channel/http/token' |
| | | import TokenForm from './TokenForm.vue' |
| | | |
| | | defineOptions({name: 'HttpToken'}) |
| | | |
| | | const message = useMessage() // 消息弹窗 |
| | | const {t} = useI18n() // 国际化 |
| | | |
| | | const loading = ref(true) // 列表的加载中 |
| | | const total = ref(0) // 列表的总页数 |
| | | const list = ref([]) // 列表的数据 |
| | | const queryParams = reactive({ |
| | | pageNo: 1, |
| | | pageSize: 10, |
| | | loginUrl: undefined |
| | | }) |
| | | const queryFormRef = ref() // 搜索的表单 |
| | | const exportLoading = ref(false) // 导出的加载中 |
| | | |
| | | /** 查询列表 */ |
| | | const getList = async () => { |
| | | loading.value = true |
| | | try { |
| | | const page = await HttpToken.getHttpTokenPage(queryParams) |
| | | list.value = page.list |
| | | total.value = page.total |
| | | } finally { |
| | | loading.value = false |
| | | } |
| | | } |
| | | |
| | | /** 搜索按钮操作 */ |
| | | const handleQuery = () => { |
| | | queryParams.pageNo = 1 |
| | | getList() |
| | | } |
| | | |
| | | /** 重置按钮操作 */ |
| | | const resetQuery = () => { |
| | | queryFormRef.value.resetFields() |
| | | handleQuery() |
| | | } |
| | | |
| | | /** 添加/修改操作 */ |
| | | const formRef = ref() |
| | | const openForm = (type: string, id?: number) => { |
| | | formRef.value.open(type, id) |
| | | } |
| | | |
| | | /** 删除按钮操作 */ |
| | | const handleDelete = async (id: number) => { |
| | | try { |
| | | // 删除的二次确认 |
| | | await message.delConfirm() |
| | | // 发起删除 |
| | | await HttpToken.deleteHttpToken(id) |
| | | message.success(t('common.delSuccess')) |
| | | // 刷新列表 |
| | | await getList() |
| | | } catch { |
| | | } |
| | | } |
| | | |
| | | /** 初始化 **/ |
| | | onMounted(async () => { |
| | | await getList() |
| | | }) |
| | | </script> |