style(sj_map_reduce): 优化工作流批次参数详情展示方式

This commit is contained in:
xlsea 2024-06-21 16:46:01 +08:00
parent 07d58b8bcc
commit c2197b0088
5 changed files with 103 additions and 12 deletions

View File

@ -60,6 +60,7 @@
"clipboard": "2.0.11", "clipboard": "2.0.11",
"dayjs": "1.11.11", "dayjs": "1.11.11",
"echarts": "5.5.0", "echarts": "5.5.0",
"highlight.js": "^11.9.0",
"lodash-es": "4.17.21", "lodash-es": "4.17.21",
"naive-ui": "2.38.2", "naive-ui": "2.38.2",
"nprogress": "0.2.0", "nprogress": "0.2.0",

View File

@ -53,6 +53,9 @@ importers:
echarts: echarts:
specifier: 5.5.0 specifier: 5.5.0
version: 5.5.0 version: 5.5.0
highlight.js:
specifier: ^11.9.0
version: 11.9.0
lodash-es: lodash-es:
specifier: 4.17.21 specifier: 4.17.21
version: 4.17.21 version: 4.17.21

View File

@ -103,7 +103,13 @@ const theme = computed(() => {
watch( watch(
() => nodeExpression.value, () => nodeExpression.value,
val => { val => {
emit('update:modelValue', val); let value = val;
if (props.lang === 'json') {
try {
value = JSON.stringify(JSON.parse(val));
} catch {}
}
emit('update:modelValue', value);
} }
); );
</script> </script>

View File

@ -1,7 +1,9 @@
<script setup lang="tsx"> <script setup lang="tsx">
import { nextTick, ref, useSlots, watch } from 'vue'; import { nextTick, ref, useSlots, watch } from 'vue';
import type { DataTableColumn } from 'naive-ui'; import type { DataTableColumn } from 'naive-ui';
import { NButton, NTag } from 'naive-ui'; import { NButton, NCode, NPopover, NTag } from 'naive-ui';
import hljs from 'highlight.js/lib/core';
import json from 'highlight.js/lib/languages/json';
import { isNotNull, translateOptions } from '@/utils/common'; import { isNotNull, translateOptions } from '@/utils/common';
import { import {
jobExecutorEnum, jobExecutorEnum,
@ -19,6 +21,8 @@ defineOptions({
name: 'DetailCard' name: 'DetailCard'
}); });
hljs.registerLanguage('json', json);
interface Props { interface Props {
id?: string; id?: string;
ids?: string[]; ids?: string[];
@ -168,7 +172,7 @@ const columns = ref<DataTableColumn<Workflow.JobBatchType>[]>([
width: 64, width: 64,
render: row => { render: row => {
return ( return (
<NButton type="info" text onClick={() => getLogRows(row)}> <NButton type="primary" text onClick={() => getLogRows(row)}>
<span class="w-28px ws-break-spaces">{`查看\n日志`}</span> <span class="w-28px ws-break-spaces">{`查看\n日志`}</span>
</NButton> </NButton>
); );
@ -178,18 +182,21 @@ const columns = ref<DataTableColumn<Workflow.JobBatchType>[]>([
key: 'id', key: 'id',
title: $t('page.jobBatch.jobTask.id'), title: $t('page.jobBatch.jobTask.id'),
align: 'left', align: 'left',
titleAlign: 'center',
minWidth: 64 minWidth: 64
}, },
{ {
key: 'groupName', key: 'groupName',
title: $t('page.jobBatch.jobTask.groupName'), title: $t('page.jobBatch.jobTask.groupName'),
align: 'left', align: 'left',
minWidth: 120 titleAlign: 'center',
minWidth: 180
}, },
{ {
key: 'taskStatus', key: 'taskStatus',
title: $t('page.jobBatch.jobTask.taskStatus'), title: $t('page.jobBatch.jobTask.taskStatus'),
align: 'left', align: 'left',
titleAlign: 'center',
minWidth: 80, minWidth: 80,
render: row => { render: row => {
if (row.taskStatus === null) { if (row.taskStatus === null) {
@ -211,7 +218,8 @@ const columns = ref<DataTableColumn<Workflow.JobBatchType>[]>([
key: 'clientInfo', key: 'clientInfo',
title: $t('page.jobBatch.jobTask.clientInfo'), title: $t('page.jobBatch.jobTask.clientInfo'),
align: 'left', align: 'left',
minWidth: 120, titleAlign: 'center',
minWidth: 150,
render: row => { render: row => {
if (row.clientInfo) { if (row.clientInfo) {
const parts = row.clientInfo?.split('@'); const parts = row.clientInfo?.split('@');
@ -224,25 +232,58 @@ const columns = ref<DataTableColumn<Workflow.JobBatchType>[]>([
{ {
key: 'argsStr', key: 'argsStr',
title: $t('page.jobBatch.jobTask.argsStr'), title: $t('page.jobBatch.jobTask.argsStr'),
align: 'left', align: 'center',
minWidth: 120 titleAlign: 'center',
minWidth: 120,
render: row => {
let argsJson = JSON.parse(row.argsStr!);
try {
if (argsJson.jobParams) {
argsJson.jobParams = JSON.parse(argsJson.jobParams.replaceAll('\\"', '"'));
}
if (argsJson.mapResult) {
argsJson.mapResult = JSON.parse(argsJson.mapResult.replaceAll('\\"', '"'));
}
} catch {}
argsJson = JSON.stringify(argsJson, null, ' ');
return (
<NPopover trigger="click">
{{
trigger: () => (
<NButton type="primary" text>
<span class="w-28px ws-break-spaces">{`查看\n参数`}</span>
</NButton>
),
default: () => (
<NCode class="max-h-300px overflow-auto" hljs={hljs} code={argsJson} language="json" show-line-numbers />
)
}}
</NPopover>
);
}
}, },
{ {
key: 'resultMessage', key: 'resultMessage',
title: $t('page.jobBatch.jobTask.resultMessage'), title: $t('page.jobBatch.jobTask.resultMessage'),
align: 'left', align: 'left',
titleAlign: 'center',
minWidth: 120 minWidth: 120
}, },
{ {
key: 'retryCount', key: 'retryCount',
title: $t('page.jobBatch.jobTask.retryCount'), title: $t('page.jobBatch.jobTask.retryCount'),
align: 'left', align: 'left',
titleAlign: 'center',
minWidth: 64 minWidth: 64
}, },
{ {
key: 'createDt', key: 'createDt',
title: $t('page.jobBatch.jobTask.createDt'), title: $t('page.jobBatch.jobTask.createDt'),
align: 'left', align: 'left',
titleAlign: 'center',
minWidth: 120 minWidth: 120
} }
]); ]);

View File

@ -1,5 +1,7 @@
<script setup lang="tsx"> <script setup lang="tsx">
import { NButton, NTag } from 'naive-ui'; import { NButton, NCode, NPopover, NTag } from 'naive-ui';
import hljs from 'highlight.js/lib/core';
import json from 'highlight.js/lib/languages/json';
import { onBeforeUnmount, ref } from 'vue'; import { onBeforeUnmount, ref } from 'vue';
import { import {
executorTypeRecord, executorTypeRecord,
@ -17,6 +19,8 @@ defineOptions({
name: 'JobBatchDetailDrawer' name: 'JobBatchDetailDrawer'
}); });
hljs.registerLanguage('json', json);
interface Props { interface Props {
/** row data */ /** row data */
rowData?: Api.JobBatch.JobBatch | null; rowData?: Api.JobBatch.JobBatch | null;
@ -73,7 +77,7 @@ const { columns, data, loading, mobilePagination } = useTable({
key: 'groupName', key: 'groupName',
title: $t('page.jobBatch.jobTask.groupName'), title: $t('page.jobBatch.jobTask.groupName'),
align: 'left', align: 'left',
minWidth: 120 minWidth: 180
}, },
{ {
key: 'taskStatus', key: 'taskStatus',
@ -100,7 +104,7 @@ const { columns, data, loading, mobilePagination } = useTable({
key: 'clientInfo', key: 'clientInfo',
title: $t('page.jobBatch.jobTask.clientInfo'), title: $t('page.jobBatch.jobTask.clientInfo'),
align: 'left', align: 'left',
minWidth: 120, minWidth: 150,
render: row => { render: row => {
if (row.clientInfo) { if (row.clientInfo) {
const parts = row.clientInfo?.split('@'); const parts = row.clientInfo?.split('@');
@ -113,8 +117,44 @@ const { columns, data, loading, mobilePagination } = useTable({
{ {
key: 'argsStr', key: 'argsStr',
title: $t('page.jobBatch.jobTask.argsStr'), title: $t('page.jobBatch.jobTask.argsStr'),
align: 'left', align: 'center',
minWidth: 120 titleAlign: 'center',
minWidth: 120,
render: row => {
let argsJson = JSON.parse(row.argsStr!);
try {
if (argsJson.jobParams) {
argsJson.jobParams = JSON.parse(argsJson.jobParams.replaceAll('\\"', '"'));
}
if (argsJson.mapResult) {
argsJson.mapResult = JSON.parse(argsJson.mapResult.replaceAll('\\"', '"'));
}
} catch {}
argsJson = JSON.stringify(argsJson, null, ' ');
return (
<NPopover trigger="click">
{{
trigger: () => (
<NButton type="primary" text>
<span class="w-28px ws-break-spaces">{`查看\n参数`}</span>
</NButton>
),
default: () => (
<NCode
class="max-h-300px overflow-auto"
hljs={hljs}
code={argsJson}
language="json"
show-line-numbers
/>
)
}}
</NPopover>
);
}
}, },
{ {
key: 'resultMessage', key: 'resultMessage',