Browse Source

任务:YT-182,mq接口记录查询功能

syhx
ljlong_2630 2 months ago
parent
commit
4f1d7c5deb
  1. 55
      src/api/infra/apiMqDetail/index.ts
  2. 53
      src/api/infra/apiMqMain/index.ts
  3. 103
      src/views/infra/apiMqDetail/apiMqDetail.data.ts
  4. 244
      src/views/infra/apiMqDetail/index.vue
  5. 97
      src/views/infra/apiMqMain/apiMqMain.data.ts
  6. 263
      src/views/infra/apiMqMain/index.vue

55
src/api/infra/apiMqDetail/index.ts

@ -0,0 +1,55 @@
import request from '@/config/axios'
export interface ApiMqDetailVO {
id: number
masterId: number
number: string
type: string
content: string
times: number
available: string
departmentCode: string
extraProperties: string
siteId: string
}
// 查询mq执行记录子列表
export const getApiMqDetailPage = async (params) => {
if (params.isSearch) {
delete params.isSearch
const data = {...params}
return await request.post({ url: '/infra/api-mq-detail/senior', data })
} else {
return await request.get({ url: `/infra/api-mq-detail/page`, params })
}
}
// 查询mq执行记录子详情
export const getApiMqDetail = async (id: number) => {
return await request.get({ url: `/infra/api-mq-detail/get?id=` + id })
}
// 新增mq执行记录子
export const createApiMqDetail = async (data: ApiMqDetailVO) => {
return await request.post({ url: `/infra/api-mq-detail/create`, data })
}
// 修改mq执行记录子
export const updateApiMqDetail = async (data: ApiMqDetailVO) => {
return await request.put({ url: `/infra/api-mq-detail/update`, data })
}
// 删除mq执行记录子
export const deleteApiMqDetail = async (id: number) => {
return await request.delete({ url: `/infra/api-mq-detail/delete?id=` + id })
}
// 导出mq执行记录子 Excel
export const exportApiMqDetail = async (params) => {
return await request.download({ url: `/infra/api-mq-detail/export-excel`, params })
}
// 下载用户导入模板
export const importTemplate = () => {
return request.download({ url: '/infra/api-mq-detail/get-import-template' })
}

53
src/api/infra/apiMqMain/index.ts

@ -0,0 +1,53 @@
import request from '@/config/axios'
export interface ApiMqMainVO {
id: number
number: string
type: string
times: number
available: string
departmentCode: string
extraProperties: string
siteId: string
}
// 查询mq执行记录主列表
export const getApiMqMainPage = async (params) => {
if (params.isSearch) {
delete params.isSearch
const data = {...params}
return await request.post({ url: '/infra/api-mq-main/senior', data })
} else {
return await request.get({ url: `/infra/api-mq-main/page`, params })
}
}
// 查询mq执行记录主详情
export const getApiMqMain = async (id: number) => {
return await request.get({ url: `/infra/api-mq-main/get?id=` + id })
}
// 新增mq执行记录主
export const createApiMqMain = async (data: ApiMqMainVO) => {
return await request.post({ url: `/infra/api-mq-main/create`, data })
}
// 修改mq执行记录主
export const updateApiMqMain = async (data: ApiMqMainVO) => {
return await request.put({ url: `/infra/api-mq-main/update`, data })
}
// 删除mq执行记录主
export const deleteApiMqMain = async (id: number) => {
return await request.delete({ url: `/infra/api-mq-main/delete?id=` + id })
}
// 导出mq执行记录主 Excel
export const exportApiMqMain = async (params) => {
return await request.download({ url: `/infra/api-mq-main/export-excel`, params })
}
// 下载用户导入模板
export const importTemplate = () => {
return request.download({ url: '/infra/api-mq-main/get-import-template' })
}

103
src/views/infra/apiMqDetail/apiMqDetail.data.ts

@ -0,0 +1,103 @@
import type { CrudSchema } from '@/hooks/web/useCrudSchemas'
import { dateFormatter } from '@/utils/formatTime'
// 表单校验
export const ApiMqDetailRules = reactive({
masterId: [required],
number: [required],
type: [required],
times: [required]
})
export const ApiMqDetail = useCrudSchemas(reactive<CrudSchema[]>([
{
label: '主业务编号编号',
field: 'number',
sort: 'custom',
isSearch: true
},
{
label: '类型',
field: 'type',
sort: 'custom',
isSearch: true,
form: {
component: 'SelectV2'
}
},
{
label: '内容',
field: 'content',
sort: 'custom',
isSearch: true,
form: {
component: 'Editor',
componentProps: {
valueHtml: '',
height: 200
}
}
},
{
label: '执行次数(默认1)',
field: 'times',
sort: 'custom',
isSearch: true,
form: {
component: 'InputNumber',
value: 0
}
},
{
label: '是否可用',
field: 'available',
sort: 'custom',
dictType: DICT_TYPE.TRUE_FALSE,
dictClass: 'string', // 默认都是字符串类型其他暂不考虑
isSearch: true
},
// {
// label: '部门',
// field: 'departmentCode',
// sort: 'custom',
// isSearch: true
// },
{
label: '创建时间',
field: 'createTime',
sort: 'custom',
formatter: dateFormatter,
isSearch: true,
search: {
component: 'DatePicker',
componentProps: {
valueFormat: 'YYYY-MM-DD HH:mm:ss',
type: 'daterange',
defaultTime: [new Date('1 00:00:00'), new Date('1 23:59:59')]
}
},
isForm: false
},
// {
// label: '扩展属性',
// field: 'extraProperties',
// sort: 'custom',
// isSearch: true
// },
// {
// label: '地点ID',
// field: 'siteId',
// sort: 'custom',
// isSearch: true
// },
// {
// label: '操作',
// field: 'action',
// isForm: false,
// table: {
// width: 150,
// fixed: 'right'
// }
// }
]))

244
src/views/infra/apiMqDetail/index.vue

@ -0,0 +1,244 @@
<template>
<ContentWrap>
<!-- 搜索工作栏 -->
<Search :schema="ApiMqDetail.allSchemas.searchSchema" @search="setSearchParams" @reset="setSearchParams" />
</ContentWrap>
<!-- 列表头部 -->
<TableHead
:HeadButttondata="HeadButttondata"
@button-base-click="buttonBaseClick"
:routeName="routeName"
@updataTableColumns="updataTableColumns"
@searchFormClick="searchFormClick"
:allSchemas="ApiMqDetail.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" @button-base-click="buttonTableClick($event,row)" />
</template>
</Table>
</ContentWrap>
<!-- 表单弹窗添加/修改 -->
<BasicForm
ref="basicFormRef"
@success="formsSuccess"
:rules="ApiMqDetailRules"
:formAllSchemas="ApiMqDetail.allSchemas"
:apiUpdate="ApiMqDetailApi.updateApiMqDetail"
:apiCreate="ApiMqDetailApi.createApiMqDetail"
@searchTableSuccess="searchTableSuccess"
:isBusiness="false"
/>
<!-- 详情 -->
<Detail ref="detailRef" :isBasic="true" :allSchemas="ApiMqDetail.allSchemas" />
<!-- 导入 -->
<ImportForm ref="importFormRef" url="/infra/api-mq-detail/import" :importTemplateData="importTemplateData" @success="importSuccess" />
</template>
<script setup lang="ts">
import download from '@/utils/download'
import { ApiMqDetail,ApiMqDetailRules } from './apiMqDetail.data'
import * as ApiMqDetailApi from '@/api/infra/apiMqDetail'
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: 'ApiMqDetail' })
const message = useMessage() //
const { t } = useI18n() //
const route = useRoute() //
const routeName = ref()
routeName.value = route.name
const tableColumns = ref(ApiMqDetail.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: ApiMqDetailApi.getApiMqDetailPage //
})
//
const { getList, setSearchParams } = tableMethods
//
const HeadButttondata = [
defaultButtons.defaultAddBtn({hasPermi:'infra:api-mq-detail:create'}), //
defaultButtons.defaultImportBtn({hasPermi:'infra:api-mq-detail:import'}), //
defaultButtons.defaultExportBtn({hasPermi:'infra:api-mq-detail:export'}), //
defaultButtons.defaultFreshBtn(null), //
defaultButtons.defaultFilterBtn(null), //
defaultButtons.defaultSetBtn(null), //
// {
// label: '',
// name: 'zdy',
// hide: false,
// type: 'primary',
// icon: 'Select',
// color: ''
// },
]
//
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 = [
// defaultButtons.mainListEditBtn({hasPermi:'infra:api-mq-detail:update'}), //
// defaultButtons.mainListDeleteBtn({hasPermi:'infra:api-mq-detail:delete'}), //
]
// -
const buttonTableClick = async (val, row) => {
if (val == 'edit') { //
openForm('update', row)
} else if (val == 'delete') { //
handleDelete(row.id)
}
}
/** 添加/修改操作 */
const basicFormRef = ref()
const openForm = (type: string, row?: any) => {
basicFormRef.value.open(type, row)
}
// form
const formsSuccess = async (formType,data) => {
var isHave =ApiMqDetail.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 ApiMqDetailApi.createApiMqDetail(data)
message.success(t('common.createSuccess'))
} else {
await ApiMqDetailApi.updateApiMqDetail(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, 'basicApiMqDetail')
}
/** 删除按钮操作 */
const handleDelete = async (id: number) => {
try {
//
await message.delConfirm()
//
await ApiMqDetailApi.deleteApiMqDetail(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 ApiMqDetailApi.exportApiMqDetail(tableObject.params)
download.excel(data, 'mq执行记录子.xlsx')
} catch {
} finally {
exportLoading.value = false
}
}
/** 导入 */
const importFormRef = ref()
const handleImport = () => {
importFormRef.value.open()
}
//
const importTemplateData = reactive({
templateUrl: '',
templateTitle: 'mq执行记录子导入模版.xlsx'
})
//
const importSuccess = () => {
getList()
}
//
const searchFormClick = (searchData) => {
tableObject.params = {
isSearch: true,
filters: searchData.filters
}
getList() //
}
/** 初始化 **/
onMounted(async () => {
getList()
importTemplateData.templateUrl = await ApiMqDetailApi.importTemplate()
})
</script>

97
src/views/infra/apiMqMain/apiMqMain.data.ts

@ -0,0 +1,97 @@
import type { CrudSchema } from '@/hooks/web/useCrudSchemas'
import { dateFormatter } from '@/utils/formatTime'
// 表单校验
export const ApiMqMainRules = reactive({
number: [required],
type: [required],
times: [required]
})
export const ApiMqMain = useCrudSchemas(reactive<CrudSchema[]>([
{
label: '业务编号',
field: 'number',
sort: 'custom',
isSearch: true
},
{
label: '类型',
field: 'type',
sort: 'custom',
isSearch: true,
form: {
component: 'SelectV2'
}
},
{
label: '执行次数',
field: 'times',
sort: 'custom',
isSearch: true,
form: {
component: 'InputNumber',
value: 0
}
},
{
label: '是否可用',
field: 'available',
sort: 'custom',
dictType: DICT_TYPE.TRUE_FALSE,
dictClass: 'string', // 默认都是字符串类型其他暂不考虑
isSearch: true,
form: {
component: 'Switch',
value: 'TRUE',
componentProps: {
inactiveValue: 'FALSE',
activeValue: 'TRUE'
}
}
},
// {
// label: '部门',
// field: 'departmentCode',
// sort: 'custom',
// isSearch: true
// },
{
label: '创建时间',
field: 'createTime',
sort: 'custom',
formatter: dateFormatter,
isSearch: true,
search: {
component: 'DatePicker',
componentProps: {
valueFormat: 'YYYY-MM-DD HH:mm:ss',
type: 'daterange',
defaultTime: [new Date('1 00:00:00'), new Date('1 23:59:59')]
}
},
isForm: false
},
// {
// label: '扩展属性',
// field: 'extraProperties',
// sort: 'custom',
// isSearch: true
// },
// {
// label: '地点ID',
// field: 'siteId',
// sort: 'custom',
// isSearch: true
// },
// {
// label: '操作',
// field: 'action',
// isForm: false,
// table: {
// width: 150,
// fixed: 'right'
// }
// }
]))

263
src/views/infra/apiMqMain/index.vue

@ -0,0 +1,263 @@
<template>
<ContentWrap>
<!-- 搜索工作栏 -->
<Search :schema="ApiMqMain.allSchemas.searchSchema" @search="setSearchParams" @reset="setSearchParams" />
</ContentWrap>
<!-- 列表头部 -->
<TableHead
:HeadButttondata="HeadButttondata"
@button-base-click="buttonBaseClick"
:routeName="routeName"
@updataTableColumns="updataTableColumns"
@searchFormClick="searchFormClick"
:allSchemas="ApiMqMain.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 #number="{row}">
<el-button type="primary" link @click="openDetail(row, '业务编号', row.number)">
<span>{{ row.number }}</span>
</el-button>
</template>
<template #action="{ row }">
<ButtonBase :Butttondata="butttondata" @button-base-click="buttonTableClick($event,row)" />
</template>
</Table>
</ContentWrap>
<!-- 表单弹窗添加/修改 -->
<BasicForm
ref="basicFormRef"
@success="formsSuccess"
:rules="ApiMqMainRules"
:formAllSchemas="ApiMqMain.allSchemas"
:searchTableParams="searchTableParams"
:tableAllSchemas="ApiMqDetail.allSchemas"
:tableFormRules="ApiMqDetailRules"
:apiUpdate="ApiMqMainApi.updateApiMqMain"
:apiCreate="ApiMqMainApi.createApiMqMain"
:isBusiness="true"
@searchTableSuccess="searchTableSuccess"
/>
<!-- 详情 -->
<Detail ref="detailRef" :isBasic="true" :allSchemas="ApiMqMain.allSchemas" />
<!-- 详情 -->
<Detail
ref="detailRef"
:isBasic="false"
:allSchemas="ApiMqMain.allSchemas"
:detailAllSchemas="ApiMqDetail.allSchemas"
:detailAllSchemasRules="ApiMqDetailRules"
:searchTableParams="searchTableParams"
:apiPage="ApiMqDetailApi.getApiMqDetailPage"
/>
<!-- 导入 -->
<ImportForm ref="importFormRef" url="/infra/api-mq-main/import" :importTemplateData="importTemplateData" @success="importSuccess" />
</template>
<script setup lang="ts">
import download from '@/utils/download'
import { ApiMqMain,ApiMqMainRules } from './apiMqMain.data'
import * as ApiMqMainApi from '@/api/infra/apiMqMain'
import { ApiMqDetail,ApiMqDetailRules } from '../apiMqDetail/apiMqDetail.data'
import * as ApiMqDetailApi from '@/api/infra/apiMqDetail'
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: 'ApiMqMain' })
const message = useMessage() //
const { t } = useI18n() //
const route = useRoute() //
const routeName = ref()
routeName.value = route.name
const tableColumns = ref([...ApiMqMain.allSchemas.tableColumns,...ApiMqDetail.allSchemas.tableMainColumns])
//
const searchTableSuccess = (formField, searchField, val, formRef) => {
nextTick(() => {
const setV = {}
setV[formField] = val[0][searchField]
formRef.setValues(setV)
})
}
//
const searchTableParams = ref([
])
//
const updataTableColumns = (val) => {
tableColumns.value = val
}
const { tableObject, tableMethods } = useTable({
getListApi: ApiMqMainApi.getApiMqMainPage //
})
//
const { getList, setSearchParams } = tableMethods
//
const HeadButttondata = [
// defaultButtons.defaultAddBtn({hasPermi:'infra:api-mq-main:create'}), //
// defaultButtons.defaultImportBtn({hasPermi:'infra:api-mq-main:import'}), //
// defaultButtons.defaultExportBtn({hasPermi:'infra:api-mq-main:export'}), //
defaultButtons.defaultFreshBtn(null), //
defaultButtons.defaultFilterBtn(null), //
defaultButtons.defaultSetBtn(null), //
// {
// label: '',
// name: 'zdy',
// hide: false,
// type: 'primary',
// icon: 'Select',
// color: ''
// },
]
//
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 = [
// defaultButtons.mainListEditBtn({hasPermi:'infra:api-mq-main:update'}), //
// defaultButtons.mainListDeleteBtn({hasPermi:'infra:api-mq-main:delete'}), //
]
// -
const buttonTableClick = async (val, row) => {
if (val == 'edit') { //
openForm('update', row)
} else if (val == 'delete') { //
handleDelete(row.id)
}
}
/** 添加/修改操作 */
const basicFormRef = ref()
const openForm = (type: string, row?: any) => {
basicFormRef.value.open(type, row)
}
// form
const formsSuccess = async (formType,data) => {
var isHave =ApiMqMain.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 ApiMqMainApi.createApiMqMain(data)
message.success(t('common.createSuccess'))
} else {
await ApiMqMainApi.updateApiMqMain(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, 'basicApiMqMain')
}
/** 删除按钮操作 */
const handleDelete = async (id: number) => {
try {
//
await message.delConfirm()
//
await ApiMqMainApi.deleteApiMqMain(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 ApiMqMainApi.exportApiMqMain(tableObject.params)
download.excel(data, 'mq执行记录主.xlsx')
} catch {
} finally {
exportLoading.value = false
}
}
/** 导入 */
const importFormRef = ref()
const handleImport = () => {
importFormRef.value.open()
}
//
const importTemplateData = reactive({
templateUrl: '',
templateTitle: 'mq执行记录主导入模版.xlsx'
})
//
const importSuccess = () => {
getList()
}
//
const searchFormClick = (searchData) => {
tableObject.params = {
isSearch: true,
filters: searchData.filters
}
getList() //
}
/** 初始化 **/
onMounted(async () => {
getList()
importTemplateData.templateUrl = await ApiMqMainApi.importTemplate()
})
</script>
Loading…
Cancel
Save