-
Notifications
You must be signed in to change notification settings - Fork 2.5k
/
quote.vue
127 lines (116 loc) · 3.07 KB
/
quote.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
<template>
<div>
<a-input-search
v-model:model-value="keyword"
:placeholder="t('apiTestManagement.quoteSearchPlaceholder')"
allow-clear
class="mr-[8px] w-[240px]"
@search="loadQuoteList"
@press-enter="loadQuoteList"
@clear="loadQuoteList"
/>
<ms-base-table v-bind="propsRes" no-disable v-on="propsEvent">
<template #num="{ record }">
<MsButton type="text" @click="toScenario(record.id)">{{ record.num }}</MsButton>
</template>
</ms-base-table>
</div>
</template>
<script setup lang="ts">
import MsButton from '@/components/pure/ms-button/index.vue';
import MsBaseTable from '@/components/pure/ms-table/base-table.vue';
import { MsTableColumn } from '@/components/pure/ms-table/type';
import useTable from '@/components/pure/ms-table/useTable';
import { getDefinitionReference } from '@/api/modules/api-test/management';
import { useI18n } from '@/hooks/useI18n';
import useOpenNewPage from '@/hooks/useOpenNewPage';
import { RouteEnum } from '@/enums/routeEnum';
const props = defineProps<{
sourceId: string | number;
}>();
const { t } = useI18n();
const { openNewPage } = useOpenNewPage();
const keyword = ref('');
const quoteLocaleMap: Record<string, any> = {
COPY: 'common.copy',
REF: 'apiTestManagement.quote',
};
const resourceLocaleMap: Record<string, any> = {
API: 'case.detail.resource.api',
};
const columns: MsTableColumn = [
{
title: 'ID',
dataIndex: 'num',
slotName: 'num',
width: 150,
sortable: {
sortDirections: ['ascend', 'descend'],
sorter: true,
},
},
{
title: 'apiTestManagement.resourceName',
dataIndex: 'resourceName',
showTooltip: true,
width: 150,
sortable: {
sortDirections: ['ascend', 'descend'],
sorter: true,
},
},
{
title: 'apiTestManagement.resourceType',
dataIndex: 'resourceType',
width: 100,
},
{
title: 'apiTestManagement.quoteType',
dataIndex: 'refType',
width: 100,
},
{
title: 'apiTestManagement.belongOrg',
dataIndex: 'organizationName',
showTooltip: true,
width: 150,
},
{
title: 'apiTestManagement.belongProject',
dataIndex: 'projectName',
showTooltip: true,
width: 150,
},
];
const { propsRes, propsEvent, loadList, setLoadListParams } = useTable(
getDefinitionReference,
{
columns,
scroll: { x: '100%' },
selectable: false,
heightUsed: 374,
showJumpMethod: true,
},
(item) => ({
...item,
refType: t(quoteLocaleMap[item.refType] || ''),
resourceType: t(resourceLocaleMap[item.resourceType] || ''),
})
);
function loadQuoteList() {
setLoadListParams({
keyword: keyword.value,
resourceId: props.sourceId,
});
loadList();
}
function toScenario(id: string) {
openNewPage(RouteEnum.API_TEST_SCENARIO, {
id,
});
}
onBeforeMount(() => {
loadQuoteList();
});
</script>
<style lang="less" scoped></style>