Browse Source

顺引接口开发

intex
liuchen864 1 week ago
parent
commit
7f016fe82a
  1. 58
      src/api/infra/outerApiHis/index.ts
  2. 1
      src/utils/dict.ts
  3. 254
      src/views/infra/outerApiHis/index.vue
  4. 82
      src/views/infra/outerApiHis/outerApiHis.data.ts

58
src/api/infra/outerApiHis/index.ts

@ -0,0 +1,58 @@
import request from '@/config/axios'
export interface OuterApiHisVO {
id: number
number: string
type: string
times: number
content: string
result: string
}
// 查询第三方接口调用记录列表
export const getOuterApiHisPage = async (params) => {
if (params.isSearch) {
delete params.isSearch
const data = {...params}
return await request.post({ url: '/infra/outer-api-his/senior', data })
} else {
return await request.get({ url: `/infra/outer-api-his/page`, params })
}
}
// 查询第三方接口调用记录详情
export const getOuterApiHis = async (id: number) => {
return await request.get({ url: `/infra/outer-api-his/get?id=` + id })
}
// 新增第三方接口调用记录
export const createOuterApiHis = async (data: OuterApiHisVO) => {
return await request.post({ url: `/infra/outer-api-his/create`, data })
}
// 修改第三方接口调用记录
export const updateOuterApiHis = async (data: OuterApiHisVO) => {
return await request.put({ url: `/infra/outer-api-his/update`, data })
}
// 删除第三方接口调用记录
export const deleteOuterApiHis = async (id: number) => {
return await request.delete({ url: `/infra/outer-api-his/delete?id=` + id })
}
// 导出第三方接口调用记录 Excel
export const exportOuterApiHis = async (params) => {
return await request.download({ url: `/infra/outer-api-his/export-excel`, params })
}
// 下载用户导入模板
export const importTemplate = () => {
return request.download({ url: '/infra/outer-api-his/get-import-template' })
}
//重试
export const retry = (id: number) => {
return request.get({
url: '/wms/outer/retry?id=' + id
})
}

1
src/utils/dict.ts

@ -127,6 +127,7 @@ export enum DICT_TYPE {
INFRA_CODEGEN_FRONT_TYPE = 'infra_codegen_front_type',
INFRA_CODEGEN_SCENE = 'infra_codegen_scene',
INFRA_FILE_STORAGE = 'infra_file_storage',
INFRA_OUTER_API_TYPE = 'outer_api_type',
// ========== BPM 模块 ==========
BPM_MODEL_CATEGORY = 'bpm_model_category',

254
src/views/infra/outerApiHis/index.vue

@ -0,0 +1,254 @@
<template>
<ContentWrap>
<!-- 搜索工作栏 -->
<Search :schema="OuterApiHis.allSchemas.searchSchema" @search="setSearchParams" @reset="setSearchParams" />
</ContentWrap>
<!-- 列表头部 -->
<TableHead
:HeadButttondata="HeadButttondata"
@button-base-click="buttonBaseClick"
:routeName="routeName"
@updataTableColumns="updataTableColumns"
@searchFormClick="searchFormClick"
:allSchemas="OuterApiHis.allSchemas"
/>
<!-- 列表 -->
<ContentWrap>
<Table
:columns="tableColumns"
:data="tableObject.tableList"
:loading="tableObject.loading"
:pagination="{
total: tableObject.total
}"
v-model:pageSize="tableObject.pageSize"
v-model:currentPage="tableObject.currentPage"
v-model:sort="tableObject.sort"
>
<template #code="{row}">
<el-button type="primary" link @click="openDetail(row, '代码', row.code)">
<span>{{ row.code }}</span>
</el-button>
</template>
<template #action="{ row }">
<ButtonBase :Butttondata="butttondata(row)" @button-base-click="buttonTableClick($event,row)" />
</template>
</Table>
</ContentWrap>
<!-- 表单弹窗添加/修改 -->
<BasicForm
ref="basicFormRef"
@success="formsSuccess"
:rules="OuterApiHisRules"
:formAllSchemas="OuterApiHis.allSchemas"
:apiUpdate="OuterApiHisApi.updateOuterApiHis"
:apiCreate="OuterApiHisApi.createOuterApiHis"
@searchTableSuccess="searchTableSuccess"
:isBusiness="false"
/>
<!-- 详情 -->
<Detail ref="detailRef" :isBasic="true" :allSchemas="OuterApiHis.allSchemas" />
<!-- 导入 -->
<ImportForm ref="importFormRef" url="/infra/outer-api-his/import" :importTemplateData="importTemplateData" @success="importSuccess" />
</template>
<script setup lang="ts">
import download from '@/utils/download'
import { OuterApiHis,OuterApiHisRules } from './outerApiHis.data'
import * as OuterApiHisApi from '@/api/infra/outerApiHis'
import * as defaultButtons from '@/utils/disposition/defaultButtons'
import TableHead from '@/components/TableHead/src/TableHead.vue'
import ImportForm from '@/components/ImportForm/src/ImportForm.vue'
import Detail from '@/components/Detail/src/Detail.vue'
defineOptions({ name: 'OuterApiHis' })
const message = useMessage() //
const { t } = useI18n() //
const route = useRoute() //
const routeName = ref()
routeName.value = route.name
const tableColumns = ref(OuterApiHis.allSchemas.tableColumns)
//
const searchTableSuccess = (formField, searchField, val, formRef) => {
nextTick(() => {
const setV = {}
setV[formField] = val[0][searchField]
formRef.setValues(setV)
})
}
//
const updataTableColumns = (val) => {
tableColumns.value = val
}
const { tableObject, tableMethods } = useTable({
getListApi: OuterApiHisApi.getOuterApiHisPage //
})
//
const { getList, setSearchParams } = tableMethods
//
const HeadButttondata = [
// defaultButtons.defaultAddBtn({hasPermi:'wms:outerApiHis:create'}), //
// defaultButtons.defaultImportBtn({hasPermi:'wms:outerApiHis:import'}), //
// defaultButtons.defaultExportBtn({hasPermi:'wms:outerApiHis:export'}), //
defaultButtons.defaultFreshBtn(null), //
defaultButtons.defaultFilterBtn(null), //
defaultButtons.defaultSetBtn(null), //
]
//
const buttonBaseClick = (val, item) => {
if (val == 'add') { //
openForm('create')
} else if (val == 'import') { //
handleImport()
} else if (val == 'export') { //
handleExport()
} else if (val == 'refresh') { //
getList()
} else if (val == 'filtrate') { //
} else { //
console.log('其他按钮', item)
}
}
// -
const butttondata = (row) =>{
return [
// defaultButtons.mainListEditBtn({hasPermi:'wms:outerApiHis:update'}), //
// defaultButtons.mainListDeleteBtn({hasPermi:'wms:outerApiHis:delete'}), //
defaultButtons.retryBtn({hide: row.times >= 3}), //
]
}
// -
const buttonTableClick = async (val, row) => {
if (val == 'edit') { //
openForm('update', row)
} else if (val == 'delete') { //
handleDelete(row.id)
} else if (val == 'retry') { //
handleRetry(row)
}
}
/** 添加/修改操作 */
const basicFormRef = ref()
const openForm = (type: string, row?: any) => {
basicFormRef.value.open(type, row)
}
// form
const formsSuccess = async (formType,data) => {
var isHave =OuterApiHis.allSchemas.formSchema.some(function (item) {
return item.field === 'activeTime' || item.field === 'expireTime';
});
if(isHave){
if(data.activeTime && data.expireTime && data.activeTime >=data.expireTime){
message.error('失效时间要大于生效时间')
return;
}
}
if(data.activeTime==0)data.activeTime = null;
if(data.expireTime==0)data.expireTime = null;
if (formType === 'create') {
await OuterApiHisApi.createOuterApiHis(data)
message.success(t('common.createSuccess'))
} else {
await OuterApiHisApi.updateOuterApiHis(data)
message.success(t('common.updateSuccess'))
}
basicFormRef.value.dialogVisible = false
getList()
}
/** 详情操作 */
const detailRef = ref()
const openDetail = (row: any, titleName: any, titleValue: any) => {
detailRef.value.openDetail(row, titleName, titleValue, 'basicOuterApiHis')
}
/** 删除按钮操作 */
const handleDelete = async (id: number) => {
try {
//
await message.delConfirm()
//
await OuterApiHisApi.deleteOuterApiHis(id)
message.success(t('common.delSuccess'))
//
await getList()
} catch {}
}
/** 导出按钮操作 */
const exportLoading = ref(false) //
const handleExport = async () => {
try {
//
await message.exportConfirm()
//
exportLoading.value = true
const data = await OuterApiHisApi.exportOuterApiHis(tableObject.params)
download.excel(data, '第三方接口调用记录.xlsx')
} catch {
} finally {
exportLoading.value = false
}
}
/** 导入 */
const importFormRef = ref()
const handleImport = () => {
importFormRef.value.open()
}
//
const importTemplateData = reactive({
templateUrl: '',
templateTitle: '第三方接口调用记录导入模版.xlsx'
})
//
const importSuccess = () => {
getList()
}
//
const searchFormClick = (searchData) => {
tableObject.params = {
isSearch: true,
filters: searchData.filters
}
getList() //
}
//
const handleRetry = (row) => {
OuterApiHisApi.retry(row.id).then(res => {
if(res){
message.success(t('common.retrySuccess'))
}else{
message.success(t('common.retryFinish'))
}
getList()
}).catch(() => {
getList()
})
}
/** 初始化 **/
onMounted(async () => {
getList()
importTemplateData.templateUrl = await OuterApiHisApi.importTemplate()
})
</script>

82
src/views/infra/outerApiHis/outerApiHis.data.ts

@ -0,0 +1,82 @@
import type { CrudSchema } from '@/hooks/web/useCrudSchemas'
import { dateFormatter } from '@/utils/formatTime'
// 表单校验
export const OuterApiHisRules = reactive({
type: [required],
times: [required],
})
export const OuterApiHis = useCrudSchemas(reactive<CrudSchema[]>([
{
label: 'ID',
field: 'id',
sort: 'custom',
isForm: false,
},
{
label: '编号',
field: 'number',
sort: 'custom',
isSearch: true,
},
{
label: '类型',
field: 'type',
sort: 'custom',
isSearch: true,
dictType: DICT_TYPE.INFRA_OUTER_API_TYPE,
dictClass: 'string',
form: {
component: 'SelectV2'
},
},
{
label: '执行次数',
field: 'times',
sort: 'custom',
form: {
component: 'InputNumber',
value: 1
},
search: {
component: 'InputNumber',
value: 1
}
},
{
label: '内容',
field: 'content',
sort: 'custom',
},
{
label: '结果',
field: 'result',
sort: 'custom',
isSearch: true,
},
{
label: '是否成功',
field: 'success',
sort: 'custom',
isSearch: true,
dictType: DICT_TYPE.TRUE_FALSE,
dictClass: 'string',
},
{
label: '创建时间',
field: 'createTime',
sort: 'custom',
formatter: dateFormatter,
isForm: false,
},
{
label: '操作',
field: 'action',
isForm: false,
table: {
width: 150,
fixed: 'right'
}
}
]))
Loading…
Cancel
Save