Files
pj_admin_cloud/src/views/hard/third-door-log/index.vue
T
2025-04-08 19:06:51 +08:00

120 lines
4.1 KiB
Vue

<template>
<div class="layout-padding">
<div class="layout-padding-auto layout-padding-view">
<el-form ref="queryRef" :inline="true" :model="state.queryForm" @keyup.enter="getDataList">
<el-row>
<el-form-item style="width: 300px" label="请求类型" prop="thirdApiType">
<dict-select v-model="state.queryForm.thirdApiType" dict-code="third_api_type" />
</el-form-item>
<el-form-item style="width: 300px" label="接口类型" prop="thirdBizType">
<dict-select v-model="state.queryForm.thirdBizType" dict-code="third_biz_type" />
</el-form-item>
<el-form-item style="width: 450px" label="请求时间" prop="createTimeList">
<el-date-picker v-model="state.queryForm.createTimeList" value-format="YYYY-MM-DD HH:mm:ss" type="datetimerange" />
</el-form-item>
<el-form-item>
<el-button icon="Search" type="primary" @click="getDataList">{{ $t("common.queryBtn") }}</el-button>
<el-button icon="Refresh" @click="resetQuery">{{ $t("common.resetBtn") }}</el-button>
</el-form-item>
</el-row>
</el-form>
<el-table
:data="state.dataList"
v-loading="state.loading"
border
:cell-style="tableStyle.cellStyle"
:header-cell-style="tableStyle.headerCellStyle"
@selection-change="selectionChangHandle"
@sort-change="sortChangeHandle"
>
<el-table-column type="selection" width="40" align="center" />
<el-table-column type="index" label="#" width="40" />
<el-table-column prop="apiType" label="请求类型">
<template #default="{ row }">
<dict-tag :options="third_api_type" :value="row.apiType" />
</template>
</el-table-column>
<el-table-column prop="bizType" label="api类型">
<template #default="{ row }">
<dict-tag :options="third_biz_type" :value="row.bizType" />
</template>
</el-table-column>
<el-table-column prop="apiUrl" label="api url" show-overflow-tooltip />
<el-table-column prop="res" label="res" show-overflow-tooltip />
<el-table-column prop="req" label="req" show-overflow-tooltip />
<el-table-column prop="error" label="调用错误" show-overflow-tooltip />
<el-table-column prop="timeConsuming" label="耗时(毫秒)" show-overflow-tooltip />
</el-table>
<pagination @size-change="sizeChangeHandle" @current-change="currentChangeHandle" v-bind="state.pagination" />
</div>
<!-- 编辑、新增 -->
<form-dialog ref="formDialogRef" @refresh="getDataList(false)" />
</div>
</template>
<script setup lang="ts" name="systemThirdDoorLog">
import { BasicTableProps, useTable } from "/@/hooks/table"
import * as thirdDoorLog from "/@/api/thirdparty/third-door-log"
import { useMessage, useMessageBox } from "/@/hooks/message"
import { useDict } from "/@/hooks/dict"
// 引入组件
const FormDialog = defineAsyncComponent(() => import("./form.vue"))
// 定义查询字典
const { third_biz_type, third_api_type } = useDict("third_biz_type", "third_api_type")
// 定义变量内容
const formDialogRef = ref()
// 搜索变量
const queryRef = ref()
const showSearch = ref(true)
// 多选变量
const selectObjs = ref([]) as any
const multiple = ref(true)
const state: BasicTableProps = reactive<BasicTableProps>({
queryForm: {},
pageList: thirdDoorLog.fetchList,
})
// table hook
const { getDataList, currentChangeHandle, sizeChangeHandle, sortChangeHandle, downBlobFile, tableStyle } = useTable(state)
// 清空搜索条件
const resetQuery = () => {
// 清空搜索条件
queryRef.value?.resetFields()
// 清空多选
selectObjs.value = []
getDataList()
}
// 导出excel
const exportExcel = () => {
downBlobFile("/third/thirdDoorLog/export", Object.assign(state.queryForm, { ids: selectObjs }), "thirdDoorLog.xlsx")
}
// 多选事件
const selectionChangHandle = (objs: { id: string }[]) => {
selectObjs.value = objs.map(({ id }) => id)
multiple.value = !objs.length
}
// 删除操作
const handleDelete = async (ids: string[]) => {
try {
await useMessageBox().confirm("此操作将永久删除")
} catch {
return
}
try {
await thirdDoorLog.delObjs(ids)
getDataList()
useMessage().success("删除成功")
} catch (err: any) {
useMessage().error(err.msg)
}
}
</script>