|  |  |  | 
|---|
|  |  |  | <template> | 
|---|
|  |  |  | <el-collapse v-model="activeName" accordion> | 
|---|
|  |  |  | <el-collapse-item | 
|---|
|  |  |  | v-for="item in threeResourceLogs" | 
|---|
|  |  |  | :key="item.id" | 
|---|
|  |  |  | name="1" | 
|---|
|  |  |  | style="overflow: auto; max-height: 600px" | 
|---|
|  |  |  | <AppContainer> | 
|---|
|  |  |  | <ProTableV2 | 
|---|
|  |  |  | :columns="columns" | 
|---|
|  |  |  | :operationBtns="operationBtns" | 
|---|
|  |  |  | :table-data="threeResourceLogs" | 
|---|
|  |  |  | :column-render-map="columnsRenderProps" | 
|---|
|  |  |  | > | 
|---|
|  |  |  | <ProForm :model="item" is-read> | 
|---|
|  |  |  | <ProFormItemV2 label="method:"> | 
|---|
|  |  |  | {{ EnumResourceMethodText[item.method] }} | 
|---|
|  |  |  | </ProFormItemV2> | 
|---|
|  |  |  | <ProFormItemV2 label="domain:">{{ item.domain }} </ProFormItemV2> | 
|---|
|  |  |  | <ProFormItemV2 label="path:"> {{ item.path }}</ProFormItemV2> | 
|---|
|  |  |  | <ProFormItemV2 label="requestHeaders:" label-position="top"> | 
|---|
|  |  |  | <json-viewer | 
|---|
|  |  |  | :copyable="true" | 
|---|
|  |  |  | :boxed="true" | 
|---|
|  |  |  | :value="JSON.parse(item.requestHeaders)" | 
|---|
|  |  |  | ></json-viewer> | 
|---|
|  |  |  | </ProFormItemV2> | 
|---|
|  |  |  | <ProFormItemV2 label="request:" label-position="top"> | 
|---|
|  |  |  | <json-viewer | 
|---|
|  |  |  | :copyable="true" | 
|---|
|  |  |  | :boxed="true" | 
|---|
|  |  |  | :value="JSON.parse(item.request)" | 
|---|
|  |  |  | ></json-viewer> | 
|---|
|  |  |  | </ProFormItemV2> | 
|---|
|  |  |  | <ProFormItemV2 label="responseHeaders:" label-position="top"> | 
|---|
|  |  |  | <json-viewer | 
|---|
|  |  |  | :copyable="true" | 
|---|
|  |  |  | :boxed="true" | 
|---|
|  |  |  | :value="JSON.parse(item.responseHeaders)" | 
|---|
|  |  |  | ></json-viewer> | 
|---|
|  |  |  | </ProFormItemV2> | 
|---|
|  |  |  | <ProFormItemV2 label="response:" label-position="top"> | 
|---|
|  |  |  | <json-viewer | 
|---|
|  |  |  | :copyable="true" | 
|---|
|  |  |  | :boxed="true" | 
|---|
|  |  |  | :value="JSON.parse(item.response)" | 
|---|
|  |  |  | ></json-viewer> | 
|---|
|  |  |  | </ProFormItemV2> | 
|---|
|  |  |  | <ProFormItemV2 label="isSuccess:"> {{ item.isSuccess ? '是' : '否' }}</ProFormItemV2> | 
|---|
|  |  |  | <ProFormItemV2 label="elapsedMilliseconds:"> {{ item.elapsedMilliseconds }}</ProFormItemV2> | 
|---|
|  |  |  | <ProFormItemV2 label="createdUser:"> | 
|---|
|  |  |  | <json-viewer | 
|---|
|  |  |  | :copyable="true" | 
|---|
|  |  |  | :boxed="true" | 
|---|
|  |  |  | :value="JSON.parse(JSON.stringify(item.createdUser))" | 
|---|
|  |  |  | ></json-viewer> | 
|---|
|  |  |  | </ProFormItemV2> | 
|---|
|  |  |  | <ProFormItemV2 label="createdTime:"> | 
|---|
|  |  |  | {{ format(item.createdTime, 'YYYY-MM-DD HH:mm:ss') }}</ProFormItemV2 | 
|---|
|  |  |  | <template #requestHeaders="{ row }"> | 
|---|
|  |  |  | <el-button | 
|---|
|  |  |  | type="primary" | 
|---|
|  |  |  | link | 
|---|
|  |  |  | @click="handleAdd({ json: { requestHeaders: JSON.parse(row.requestHeaders) } })" | 
|---|
|  |  |  | >查看</el-button | 
|---|
|  |  |  | > | 
|---|
|  |  |  | </ProForm> | 
|---|
|  |  |  | </el-collapse-item> | 
|---|
|  |  |  | </el-collapse> | 
|---|
|  |  |  | </template> | 
|---|
|  |  |  | <template #request="{ row }"> | 
|---|
|  |  |  | <el-button | 
|---|
|  |  |  | type="primary" | 
|---|
|  |  |  | link | 
|---|
|  |  |  | @click="handleAdd({ json: { request: JSON.parse(row.request) } })" | 
|---|
|  |  |  | >查看</el-button | 
|---|
|  |  |  | > | 
|---|
|  |  |  | </template> | 
|---|
|  |  |  | <template #responseHeaders="{ row }"> | 
|---|
|  |  |  | <el-button | 
|---|
|  |  |  | type="primary" | 
|---|
|  |  |  | link | 
|---|
|  |  |  | @click="handleAdd({ json: { responseHeaders: JSON.parse(row.responseHeaders) } })" | 
|---|
|  |  |  | >查看</el-button | 
|---|
|  |  |  | > | 
|---|
|  |  |  | </template> | 
|---|
|  |  |  | <template #response="{ row }"> | 
|---|
|  |  |  | <el-button | 
|---|
|  |  |  | type="primary" | 
|---|
|  |  |  | link | 
|---|
|  |  |  | @click="handleAdd({ json: { response: JSON.parse(row.response) } })" | 
|---|
|  |  |  | >查看</el-button | 
|---|
|  |  |  | > | 
|---|
|  |  |  | </template> | 
|---|
|  |  |  | <template #createdUser="{ row }"> | 
|---|
|  |  |  | <el-button | 
|---|
|  |  |  | type="primary" | 
|---|
|  |  |  | link | 
|---|
|  |  |  | @click="handleAdd({ json: { createdUser: row.createdUser } })" | 
|---|
|  |  |  | >查看</el-button | 
|---|
|  |  |  | > | 
|---|
|  |  |  | </template> | 
|---|
|  |  |  | </ProTableV2> | 
|---|
|  |  |  | <JsonViewerDialog v-bind="dialogProps" /> | 
|---|
|  |  |  | </AppContainer> | 
|---|
|  |  |  | </template> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <script setup lang="ts"> | 
|---|
|  |  |  | import { ProForm, ProFormItemV2 } from '@bole-core/components'; | 
|---|
|  |  |  | import { | 
|---|
|  |  |  | AppContainer, | 
|---|
|  |  |  | ProTableV2, | 
|---|
|  |  |  | defineColumns, | 
|---|
|  |  |  | ProTableV2Props, | 
|---|
|  |  |  | useFormDialog, | 
|---|
|  |  |  | defineOperationBtns, | 
|---|
|  |  |  | } from '@bole-core/components'; | 
|---|
|  |  |  | import { EnumResourceMethodText } from '@/constants'; | 
|---|
|  |  |  | import JsonViewer from 'vue-json-viewer'; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import { format } from '@/utils'; | 
|---|
|  |  |  | import JsonViewerDialog from './JsonViewerDialog.vue'; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | defineOptions({ | 
|---|
|  |  |  | name: 'ThreeResourceLogsView', | 
|---|
|  |  |  | 
|---|
|  |  |  | type Props = { | 
|---|
|  |  |  | threeResourceLogs: API.GetThreeResourceLogsQueryResultItem[]; | 
|---|
|  |  |  | }; | 
|---|
|  |  |  | const activeName = ref('1'); | 
|---|
|  |  |  | const props = withDefaults(defineProps<Props>(), { | 
|---|
|  |  |  | threeResourceLogs: () => [] as API.GetThreeResourceLogsQueryResultItem[], | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | </script> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <style lang="scss" scoped> | 
|---|
|  |  |  | @use '@/style/common.scss' as *; | 
|---|
|  |  |  | </style> | 
|---|
|  |  |  | const columns = defineColumns( | 
|---|
|  |  |  | [ | 
|---|
|  |  |  | 'method', | 
|---|
|  |  |  | 'domain', | 
|---|
|  |  |  | 'path', | 
|---|
|  |  |  | 'requestHeaders', | 
|---|
|  |  |  | 'request', | 
|---|
|  |  |  | 'responseHeaders', | 
|---|
|  |  |  | 'response', | 
|---|
|  |  |  | 'isSuccess', | 
|---|
|  |  |  | 'elapsedMilliseconds', | 
|---|
|  |  |  | 'createdUser', | 
|---|
|  |  |  | 'createdTime', | 
|---|
|  |  |  | ].map((x, index) => ({ | 
|---|
|  |  |  | id: index + '', | 
|---|
|  |  |  | enCode: x, | 
|---|
|  |  |  | name: x, | 
|---|
|  |  |  | width: 160, | 
|---|
|  |  |  | })) | 
|---|
|  |  |  | ); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | const operationBtns = defineOperationBtns([ | 
|---|
|  |  |  | { | 
|---|
|  |  |  | data: { | 
|---|
|  |  |  | enCode: 'detailBtn', | 
|---|
|  |  |  | name: '查看', | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | emits: { | 
|---|
|  |  |  | onClick: (role) => openDialog(role), | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | ]); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | const columnsRenderProps: ProTableV2Props['columnRenderMap'] = { | 
|---|
|  |  |  | method: { type: 'enum', valueEnum: EnumResourceMethodText }, | 
|---|
|  |  |  | isSuccess: { | 
|---|
|  |  |  | formatter: (row: API.GetResourceLogsQueryResultItem) => { | 
|---|
|  |  |  | return row.isSuccess ? '是' : '否'; | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | createdTime: { type: 'date', format: 'YYYY-MM-DD HH:mm:ss' }, | 
|---|
|  |  |  | }; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | const { dialogProps, handleAdd } = useFormDialog({ | 
|---|
|  |  |  | defaultFormParams: { | 
|---|
|  |  |  | json: null, | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | }); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | function openDialog(row: API.GetResourceLogsQueryResultItem) { | 
|---|
|  |  |  | handleAdd({ | 
|---|
|  |  |  | json: { | 
|---|
|  |  |  | requestHeaders: JSON.parse(row.requestHeaders), | 
|---|
|  |  |  | request: JSON.parse(row.request), | 
|---|
|  |  |  | responseHeaders: JSON.parse(row.responseHeaders), | 
|---|
|  |  |  | response: JSON.parse(row.response), | 
|---|
|  |  |  | createdUser: row.createdUser, | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | </script> | 
|---|