Showing
4 changed files
with
129 additions
and
242 deletions
| @@ -2,29 +2,8 @@ | @@ -2,29 +2,8 @@ | ||
| 2 | <div> | 2 | <div> |
| 3 | <div class="mt-8"> | 3 | <div class="mt-8"> |
| 4 | <div class="flex"> | 4 | <div class="flex"> |
| 5 | - <div class="flex" v-if="interfaceType === 'SYSTEM' && isAdmin(role)"> | ||
| 6 | - <Select | ||
| 7 | - v-model:value="selectTenant" | ||
| 8 | - allowClear | ||
| 9 | - @change="onSelect" | ||
| 10 | - style="width: 150px" | ||
| 11 | - placeholder="请选择租户" | ||
| 12 | - :options="selectOptions" | ||
| 13 | - show-search | ||
| 14 | - :filter-option="filterOption" | ||
| 15 | - /> | ||
| 16 | - <Select | ||
| 17 | - v-model:value="selectSysTenant" | ||
| 18 | - allowClear | ||
| 19 | - @change="onSelctTenant" | ||
| 20 | - style="width: 150px; margin-left: 10px" | ||
| 21 | - v-if="selectTenantOptions.length > 0" | ||
| 22 | - placeholder="请选择租户" | ||
| 23 | - :options="selectTenantOptions" | ||
| 24 | - show-search | ||
| 25 | - :filter-option="filterTenantOption" | ||
| 26 | - /> | ||
| 27 | - </div> | 5 | + <SelectTenant :interfaceType="interfaceType" @emitToken="onHandleEmitToken" /> |
| 6 | + <div class="ml-2"></div> | ||
| 28 | <Button | 7 | <Button |
| 29 | :disabled="interfaceType === 'SYSTEM' && isAdmin(role) ? testDisabled : false" | 8 | :disabled="interfaceType === 'SYSTEM' && isAdmin(role) ? testDisabled : false" |
| 30 | @click="handleTest(isSingleClickText)" | 9 | @click="handleTest(isSingleClickText)" |
| @@ -57,17 +36,13 @@ | @@ -57,17 +36,13 @@ | ||
| 57 | </div> | 36 | </div> |
| 58 | </template> | 37 | </template> |
| 59 | <script lang="ts" setup name="testRequest"> | 38 | <script lang="ts" setup name="testRequest"> |
| 60 | - import { ref, nextTick, onMounted } from 'vue'; | 39 | + import { ref, nextTick } from 'vue'; |
| 61 | import { Button } from 'ant-design-vue'; | 40 | import { Button } from 'ant-design-vue'; |
| 62 | import TestBodyCellTable from '../paramsTest/testEditParamsCellTable.vue'; | 41 | import TestBodyCellTable from '../paramsTest/testEditParamsCellTable.vue'; |
| 63 | import moment from 'moment'; | 42 | import moment from 'moment'; |
| 64 | import { useUtils } from '../../../hooks/useUtils'; | 43 | import { useUtils } from '../../../hooks/useUtils'; |
| 65 | import JsonEditor from '../../SimpleRequest/components/jsonEditor.vue'; | 44 | import JsonEditor from '../../SimpleRequest/components/jsonEditor.vue'; |
| 66 | import { useMessage } from '/@/hooks/web/useMessage'; | 45 | import { useMessage } from '/@/hooks/web/useMessage'; |
| 67 | - import { getTenantAllPageLists, getTenantPageList } from '/@/api/tenant/tenantApi'; | ||
| 68 | - import { selectType } from '../../../config/types'; | ||
| 69 | - import { Select } from 'ant-design-vue'; | ||
| 70 | - import { getUserToken } from '/@/api/sys/user'; | ||
| 71 | import { USER_INFO_KEY } from '/@/enums/cacheEnum'; | 46 | import { USER_INFO_KEY } from '/@/enums/cacheEnum'; |
| 72 | import { getAuthCache } from '/@/utils/auth'; | 47 | import { getAuthCache } from '/@/utils/auth'; |
| 73 | import { isAdmin } from '/@/enums/roleEnum'; | 48 | import { isAdmin } from '/@/enums/roleEnum'; |
| @@ -77,6 +52,7 @@ | @@ -77,6 +52,7 @@ | ||
| 77 | RequestBodyTypeEnum, | 52 | RequestBodyTypeEnum, |
| 78 | TableDefaultTypeEnum, | 53 | TableDefaultTypeEnum, |
| 79 | } from '../../../config/enum'; | 54 | } from '../../../config/enum'; |
| 55 | + import SelectTenant from '../components/selectTenant.vue'; | ||
| 80 | 56 | ||
| 81 | const userInfo: any = getAuthCache(USER_INFO_KEY); | 57 | const userInfo: any = getAuthCache(USER_INFO_KEY); |
| 82 | 58 | ||
| @@ -93,21 +69,6 @@ | @@ -93,21 +69,6 @@ | ||
| 93 | }, | 69 | }, |
| 94 | }); | 70 | }); |
| 95 | 71 | ||
| 96 | - onMounted(async () => { | ||
| 97 | - if (isAdmin(role)) { | ||
| 98 | - const res = await getTenantPageList(); | ||
| 99 | - selectOptions.value = res.map((m) => ({ label: m.name, value: m.tenantId })); | ||
| 100 | - } else { | ||
| 101 | - //租户 | ||
| 102 | - const { token } = await getUserToken(userInfo?.userId); | ||
| 103 | - getToken.value = token; | ||
| 104 | - } | ||
| 105 | - }); | ||
| 106 | - | ||
| 107 | - const selectOptions = ref<selectType[]>([]); | ||
| 108 | - | ||
| 109 | - const selectTenantOptions = ref<selectType[]>([]); | ||
| 110 | - | ||
| 111 | const { createMessage } = useMessage(); | 72 | const { createMessage } = useMessage(); |
| 112 | 73 | ||
| 113 | const showTestEditCell = ref(false); | 74 | const showTestEditCell = ref(false); |
| @@ -116,10 +77,6 @@ | @@ -116,10 +77,6 @@ | ||
| 116 | 77 | ||
| 117 | const excuteData = ref({}); | 78 | const excuteData = ref({}); |
| 118 | 79 | ||
| 119 | - const selectTenant = ref(undefined); | ||
| 120 | - | ||
| 121 | - const selectSysTenant = ref(undefined); | ||
| 122 | - | ||
| 123 | const testEditCellTableRef = ref<InstanceType<typeof TestBodyCellTable>>(); | 80 | const testEditCellTableRef = ref<InstanceType<typeof TestBodyCellTable>>(); |
| 124 | 81 | ||
| 125 | const jsonEditorRef = ref<InstanceType<typeof JsonEditor>>(); | 82 | const jsonEditorRef = ref<InstanceType<typeof JsonEditor>>(); |
| @@ -132,44 +89,14 @@ | @@ -132,44 +89,14 @@ | ||
| 132 | 89 | ||
| 133 | const getToken = ref(''); | 90 | const getToken = ref(''); |
| 134 | 91 | ||
| 135 | - const filterOption = (input: string, option: any) => { | ||
| 136 | - return option.label.includes(input); | ||
| 137 | - }; | ||
| 138 | - | ||
| 139 | - const filterTenantOption = (input: string, option: any) => { | ||
| 140 | - return option.label.includes(input); | ||
| 141 | - }; | ||
| 142 | - | ||
| 143 | - const onSelect = async (e) => { | ||
| 144 | - if (e) { | ||
| 145 | - testDisabled.value = false; | ||
| 146 | - } else { | ||
| 147 | - testDisabled.value = true; | ||
| 148 | - } | ||
| 149 | - selectSysTenant.value = undefined; | ||
| 150 | - const rest = (await getTenantAllPageLists(e)) as any; | ||
| 151 | - selectTenantOptions.value = rest?.map((m) => ({ label: m.realName, value: m.id })); | ||
| 152 | - }; | 92 | + const isSingleClickText = ref('open'); |
| 153 | 93 | ||
| 154 | - const onSelctTenant = async (e) => { | ||
| 155 | - if (e) { | ||
| 156 | - testDisabled.value = false; | ||
| 157 | - } else { | ||
| 158 | - testDisabled.value = true; | ||
| 159 | - } | ||
| 160 | - const { token } = await getUserToken(e); | 94 | + const onHandleEmitToken = (token, flag) => { |
| 161 | getToken.value = token; | 95 | getToken.value = token; |
| 96 | + testDisabled.value = flag; | ||
| 162 | }; | 97 | }; |
| 163 | 98 | ||
| 164 | - const isSingleClickText = ref('open'); | ||
| 165 | - | ||
| 166 | const handleTest = (o) => { | 99 | const handleTest = (o) => { |
| 167 | - if (isAdmin(role)) { | ||
| 168 | - if (!selectTenant.value || !selectSysTenant.value) { | ||
| 169 | - createMessage.error('请选择租户或者租户管理员'); | ||
| 170 | - throw Error('请选择租户或者租户管理员'); | ||
| 171 | - } | ||
| 172 | - } | ||
| 173 | if (o === 'open') { | 100 | if (o === 'open') { |
| 174 | showTestEditCell.value = true; | 101 | showTestEditCell.value = true; |
| 175 | emits('testBodyInterface'); | 102 | emits('testBodyInterface'); |
| @@ -270,9 +197,6 @@ | @@ -270,9 +197,6 @@ | ||
| 270 | isSingleClickText.value = 'open'; | 197 | isSingleClickText.value = 'open'; |
| 271 | showTestEditCell.value = false; | 198 | showTestEditCell.value = false; |
| 272 | testResult.value = ''; | 199 | testResult.value = ''; |
| 273 | - selectTenant.value = undefined; | ||
| 274 | - selectSysTenant.value = undefined; | ||
| 275 | - selectTenantOptions.value = []; | ||
| 276 | }; | 200 | }; |
| 277 | 201 | ||
| 278 | const onCloseTest = () => { | 202 | const onCloseTest = () => { |
| 1 | +<template> | ||
| 2 | + <div class="flex" v-if="interfaceType === 'SYSTEM' && isAdmin(role)"> | ||
| 3 | + <Select | ||
| 4 | + v-model:value="selectTenant" | ||
| 5 | + @change="onSelect" | ||
| 6 | + style="width: 150px" | ||
| 7 | + placeholder="请选择租户" | ||
| 8 | + :options="selectOptions" | ||
| 9 | + show-search | ||
| 10 | + :filter-option="filterOption" | ||
| 11 | + /> | ||
| 12 | + <Select | ||
| 13 | + v-model:value="selectSysTenant" | ||
| 14 | + @change="onSelctTenant" | ||
| 15 | + style="width: 150px; margin-left: 10px" | ||
| 16 | + v-if="selectTenantOptions.length > 0" | ||
| 17 | + placeholder="请选择租户" | ||
| 18 | + :options="selectTenantOptions" | ||
| 19 | + show-search | ||
| 20 | + :filter-option="filterTenantOption" | ||
| 21 | + /> | ||
| 22 | + </div> | ||
| 23 | +</template> | ||
| 24 | +<script lang="ts" setup name="selectTenant"> | ||
| 25 | + import { onMounted, ref, onUnmounted } from 'vue'; | ||
| 26 | + import { selectType } from '../../../config/types'; | ||
| 27 | + import { Select } from 'ant-design-vue'; | ||
| 28 | + import { getUserToken } from '/@/api/sys/user'; | ||
| 29 | + import { USER_INFO_KEY } from '/@/enums/cacheEnum'; | ||
| 30 | + import { getAuthCache } from '/@/utils/auth'; | ||
| 31 | + import { isAdmin } from '/@/enums/roleEnum'; | ||
| 32 | + import { getTenantAllPageLists, getTenantPageList } from '/@/api/tenant/tenantApi'; | ||
| 33 | + | ||
| 34 | + defineProps({ | ||
| 35 | + interfaceType: { | ||
| 36 | + type: String, | ||
| 37 | + }, | ||
| 38 | + }); | ||
| 39 | + | ||
| 40 | + const emits = defineEmits(['emitToken']); | ||
| 41 | + | ||
| 42 | + const userInfo: any = getAuthCache(USER_INFO_KEY); | ||
| 43 | + | ||
| 44 | + const role: string = userInfo?.roles[0]; | ||
| 45 | + | ||
| 46 | + onMounted(async () => { | ||
| 47 | + if (isAdmin(role)) { | ||
| 48 | + const res = await getTenantPageList(); | ||
| 49 | + selectOptions.value = res.map((m) => ({ label: m.name, value: m.tenantId })); | ||
| 50 | + } else { | ||
| 51 | + //租户 | ||
| 52 | + const { token } = await getUserToken(userInfo?.userId); | ||
| 53 | + getToken.value = token; | ||
| 54 | + emits('emitToken', getToken.value, testDisabled.value); | ||
| 55 | + } | ||
| 56 | + }); | ||
| 57 | + | ||
| 58 | + const selectOptions = ref<selectType[]>([]); | ||
| 59 | + | ||
| 60 | + const testDisabled = ref(true); | ||
| 61 | + | ||
| 62 | + const selectTenantOptions = ref<selectType[]>([]); | ||
| 63 | + | ||
| 64 | + const selectTenant = ref(undefined); | ||
| 65 | + | ||
| 66 | + const selectSysTenant = ref(undefined); | ||
| 67 | + | ||
| 68 | + const getToken = ref(''); | ||
| 69 | + | ||
| 70 | + const filterOption = (input: string, option: any) => { | ||
| 71 | + return option.label.includes(input); | ||
| 72 | + }; | ||
| 73 | + | ||
| 74 | + const filterTenantOption = (input: string, option: any) => { | ||
| 75 | + return option.label.includes(input); | ||
| 76 | + }; | ||
| 77 | + | ||
| 78 | + const onSelect = async (e) => { | ||
| 79 | + if (e) { | ||
| 80 | + testDisabled.value = false; | ||
| 81 | + } else { | ||
| 82 | + testDisabled.value = true; | ||
| 83 | + } | ||
| 84 | + selectSysTenant.value = undefined; | ||
| 85 | + const rest = (await getTenantAllPageLists(e)) as any; | ||
| 86 | + selectTenantOptions.value = rest?.map((m) => ({ label: m.realName, value: m.id })); | ||
| 87 | + }; | ||
| 88 | + | ||
| 89 | + const onSelctTenant = async (e) => { | ||
| 90 | + if (e) { | ||
| 91 | + testDisabled.value = false; | ||
| 92 | + } else { | ||
| 93 | + testDisabled.value = true; | ||
| 94 | + } | ||
| 95 | + const { token } = await getUserToken(e); | ||
| 96 | + getToken.value = token; | ||
| 97 | + emits('emitToken', getToken.value, testDisabled.value); | ||
| 98 | + }; | ||
| 99 | + | ||
| 100 | + onUnmounted(() => { | ||
| 101 | + selectTenant.value = undefined; | ||
| 102 | + selectSysTenant.value = undefined; | ||
| 103 | + selectTenantOptions.value = []; | ||
| 104 | + getToken.value = ''; | ||
| 105 | + }); | ||
| 106 | +</script> | ||
| 107 | + | ||
| 108 | +<style scoped lang="less"></style> |
| @@ -2,29 +2,8 @@ | @@ -2,29 +2,8 @@ | ||
| 2 | <div> | 2 | <div> |
| 3 | <div class="mt-8"> | 3 | <div class="mt-8"> |
| 4 | <div class="flex"> | 4 | <div class="flex"> |
| 5 | - <div class="flex" v-if="interfaceType === 'SYSTEM' && isAdmin(role)"> | ||
| 6 | - <Select | ||
| 7 | - allowClear | ||
| 8 | - v-model:value="selectTenant" | ||
| 9 | - @change="onSelect" | ||
| 10 | - style="width: 150px" | ||
| 11 | - placeholder="请选择租户" | ||
| 12 | - :options="selectOptions" | ||
| 13 | - show-search | ||
| 14 | - :filter-option="filterOption" | ||
| 15 | - /> | ||
| 16 | - <Select | ||
| 17 | - v-model:value="selectSysTenant" | ||
| 18 | - allowClear | ||
| 19 | - @change="onSelctTenant" | ||
| 20 | - style="width: 150px; margin-left: 10px" | ||
| 21 | - v-if="selectTenantOptions.length > 0" | ||
| 22 | - placeholder="请选择租户" | ||
| 23 | - :options="selectTenantOptions" | ||
| 24 | - show-search | ||
| 25 | - :filter-option="filterTenantOption" | ||
| 26 | - /> | ||
| 27 | - </div> | 5 | + <SelectTenant :interfaceType="interfaceType" @emitToken="onHandleEmitToken" /> |
| 6 | + <div class="ml-2"></div> | ||
| 28 | <Button | 7 | <Button |
| 29 | :disabled="interfaceType === 'SYSTEM' && isAdmin(role) ? testDisabled : false" | 8 | :disabled="interfaceType === 'SYSTEM' && isAdmin(role) ? testDisabled : false" |
| 30 | @click="handleTest(isSingleClickText)" | 9 | @click="handleTest(isSingleClickText)" |
| @@ -44,17 +23,14 @@ | @@ -44,17 +23,14 @@ | ||
| 44 | </div> | 23 | </div> |
| 45 | </template> | 24 | </template> |
| 46 | <script lang="ts" setup name="testRequest"> | 25 | <script lang="ts" setup name="testRequest"> |
| 47 | - import { ref, nextTick, onMounted } from 'vue'; | 26 | + import { ref, nextTick } from 'vue'; |
| 48 | import { Button } from 'ant-design-vue'; | 27 | import { Button } from 'ant-design-vue'; |
| 49 | import TestHeaderEditCellTable from './testEditHeaderCellTable.vue'; | 28 | import TestHeaderEditCellTable from './testEditHeaderCellTable.vue'; |
| 50 | import { useMessage } from '/@/hooks/web/useMessage'; | 29 | import { useMessage } from '/@/hooks/web/useMessage'; |
| 51 | - import { selectType } from '../../../config/types'; | ||
| 52 | - import { Select } from 'ant-design-vue'; | ||
| 53 | - import { getUserToken } from '/@/api/sys/user'; | ||
| 54 | import { USER_INFO_KEY } from '/@/enums/cacheEnum'; | 30 | import { USER_INFO_KEY } from '/@/enums/cacheEnum'; |
| 55 | - import { getTenantAllPageLists, getTenantPageList } from '/@/api/tenant/tenantApi'; | ||
| 56 | import { getAuthCache } from '/@/utils/auth'; | 31 | import { getAuthCache } from '/@/utils/auth'; |
| 57 | import { isAdmin } from '/@/enums/roleEnum'; | 32 | import { isAdmin } from '/@/enums/roleEnum'; |
| 33 | + import SelectTenant from '../components/selectTenant.vue'; | ||
| 58 | 34 | ||
| 59 | const emits = defineEmits(['testHeaderInterface', 'closeTest']); | 35 | const emits = defineEmits(['testHeaderInterface', 'closeTest']); |
| 60 | 36 | ||
| @@ -71,21 +47,6 @@ | @@ -71,21 +47,6 @@ | ||
| 71 | }, | 47 | }, |
| 72 | }); | 48 | }); |
| 73 | 49 | ||
| 74 | - onMounted(async () => { | ||
| 75 | - if (isAdmin(role)) { | ||
| 76 | - const res = await getTenantPageList(); | ||
| 77 | - selectOptions.value = res.map((m) => ({ label: m.name, value: m.tenantId })); | ||
| 78 | - } else { | ||
| 79 | - //租户 | ||
| 80 | - const { token } = await getUserToken(userInfo?.userId); | ||
| 81 | - getToken.value = token; | ||
| 82 | - } | ||
| 83 | - }); | ||
| 84 | - | ||
| 85 | - const selectOptions = ref<selectType[]>([]); | ||
| 86 | - | ||
| 87 | - const selectTenantOptions = ref<selectType[]>([]); | ||
| 88 | - | ||
| 89 | const testDisabled = ref(true); | 50 | const testDisabled = ref(true); |
| 90 | 51 | ||
| 91 | const { createMessage } = useMessage(); | 52 | const { createMessage } = useMessage(); |
| @@ -94,54 +55,20 @@ | @@ -94,54 +55,20 @@ | ||
| 94 | 55 | ||
| 95 | const excuteData = ref({}); | 56 | const excuteData = ref({}); |
| 96 | 57 | ||
| 97 | - const selectTenant = ref(undefined); | ||
| 98 | - | ||
| 99 | - const selectSysTenant = ref(undefined); | ||
| 100 | - | ||
| 101 | const testEditCellTableRef = ref<InstanceType<typeof TestHeaderEditCellTable>>(); | 58 | const testEditCellTableRef = ref<InstanceType<typeof TestHeaderEditCellTable>>(); |
| 102 | 59 | ||
| 103 | const testResult = ref(''); | 60 | const testResult = ref(''); |
| 104 | 61 | ||
| 105 | const getToken = ref(''); | 62 | const getToken = ref(''); |
| 106 | 63 | ||
| 107 | - const filterOption = (input: string, option: any) => { | ||
| 108 | - return option.label.includes(input); | ||
| 109 | - }; | ||
| 110 | - | ||
| 111 | - const filterTenantOption = (input: string, option: any) => { | ||
| 112 | - return option.label.includes(input); | ||
| 113 | - }; | ||
| 114 | - | ||
| 115 | - const onSelect = async (e) => { | ||
| 116 | - if (e) { | ||
| 117 | - testDisabled.value = false; | ||
| 118 | - } else { | ||
| 119 | - testDisabled.value = true; | ||
| 120 | - } | ||
| 121 | - selectSysTenant.value = undefined; | ||
| 122 | - const rest = (await getTenantAllPageLists(e)) as any; | ||
| 123 | - selectTenantOptions.value = rest?.map((m) => ({ label: m.realName, value: m.id })); | ||
| 124 | - }; | 64 | + const isSingleClickText = ref('open'); |
| 125 | 65 | ||
| 126 | - const onSelctTenant = async (e) => { | ||
| 127 | - if (e) { | ||
| 128 | - testDisabled.value = false; | ||
| 129 | - } else { | ||
| 130 | - testDisabled.value = true; | ||
| 131 | - } | ||
| 132 | - const { token } = await getUserToken(e); | 66 | + const onHandleEmitToken = (token, flag) => { |
| 133 | getToken.value = token; | 67 | getToken.value = token; |
| 68 | + testDisabled.value = flag; | ||
| 134 | }; | 69 | }; |
| 135 | 70 | ||
| 136 | - const isSingleClickText = ref('open'); | ||
| 137 | - | ||
| 138 | const handleTest = (o) => { | 71 | const handleTest = (o) => { |
| 139 | - if (isAdmin(role)) { | ||
| 140 | - if (!selectTenant.value || !selectSysTenant.value) { | ||
| 141 | - createMessage.error('请选择租户或者租户管理员'); | ||
| 142 | - throw Error('请选择租户或者租户管理员'); | ||
| 143 | - } | ||
| 144 | - } | ||
| 145 | if (o === 'open') { | 72 | if (o === 'open') { |
| 146 | showTestEditCell.value = true; | 73 | showTestEditCell.value = true; |
| 147 | emits('testHeaderInterface'); | 74 | emits('testHeaderInterface'); |
| @@ -187,9 +114,6 @@ | @@ -187,9 +114,6 @@ | ||
| 187 | const setValue = () => { | 114 | const setValue = () => { |
| 188 | showTestEditCell.value = false; | 115 | showTestEditCell.value = false; |
| 189 | testResult.value = ''; | 116 | testResult.value = ''; |
| 190 | - selectTenant.value = undefined; | ||
| 191 | - selectSysTenant.value = undefined; | ||
| 192 | - selectTenantOptions.value = []; | ||
| 193 | }; | 117 | }; |
| 194 | 118 | ||
| 195 | const onCloseTest = () => { | 119 | const onCloseTest = () => { |
| @@ -2,29 +2,8 @@ | @@ -2,29 +2,8 @@ | ||
| 2 | <div> | 2 | <div> |
| 3 | <div class="mt-8"> | 3 | <div class="mt-8"> |
| 4 | <div class="flex"> | 4 | <div class="flex"> |
| 5 | - <div class="flex" v-if="interfaceType === 'SYSTEM' && isAdmin(role)"> | ||
| 6 | - <Select | ||
| 7 | - allowClear | ||
| 8 | - v-model:value="selectTenant" | ||
| 9 | - @change="onSelect" | ||
| 10 | - style="width: 150px" | ||
| 11 | - placeholder="请选择租户" | ||
| 12 | - :options="selectOptions" | ||
| 13 | - show-search | ||
| 14 | - :filter-option="filterOption" | ||
| 15 | - /> | ||
| 16 | - <Select | ||
| 17 | - v-model:value="selectSysTenant" | ||
| 18 | - allowClear | ||
| 19 | - @change="onSelctTenant" | ||
| 20 | - style="width: 150px; margin-left: 10px" | ||
| 21 | - v-if="selectTenantOptions.length > 0" | ||
| 22 | - placeholder="请选择租户" | ||
| 23 | - :options="selectTenantOptions" | ||
| 24 | - show-search | ||
| 25 | - :filter-option="filterTenantOption" | ||
| 26 | - /> | ||
| 27 | - </div> | 5 | + <SelectTenant :interfaceType="interfaceType" @emitToken="onHandleEmitToken" /> |
| 6 | + <div class="ml-2"></div> | ||
| 28 | <Button | 7 | <Button |
| 29 | :disabled="interfaceType === 'SYSTEM' && isAdmin(role) ? testDisabled : false" | 8 | :disabled="interfaceType === 'SYSTEM' && isAdmin(role) ? testDisabled : false" |
| 30 | @click="handleTest(isSingleClickText)" | 9 | @click="handleTest(isSingleClickText)" |
| @@ -44,21 +23,18 @@ | @@ -44,21 +23,18 @@ | ||
| 44 | </div> | 23 | </div> |
| 45 | </template> | 24 | </template> |
| 46 | <script lang="ts" setup name="testRequest"> | 25 | <script lang="ts" setup name="testRequest"> |
| 47 | - import { ref, nextTick, onMounted } from 'vue'; | 26 | + import { ref, nextTick } from 'vue'; |
| 48 | import { Button } from 'ant-design-vue'; | 27 | import { Button } from 'ant-design-vue'; |
| 49 | import TestParamsCellTable from './testEditParamsCellTable.vue'; | 28 | import TestParamsCellTable from './testEditParamsCellTable.vue'; |
| 50 | import moment from 'moment'; | 29 | import moment from 'moment'; |
| 51 | import { useUtils } from '../../../hooks/useUtils'; | 30 | import { useUtils } from '../../../hooks/useUtils'; |
| 52 | import { useMessage } from '/@/hooks/web/useMessage'; | 31 | import { useMessage } from '/@/hooks/web/useMessage'; |
| 53 | - import { getTenantAllPageLists, getTenantPageList } from '/@/api/tenant/tenantApi'; | ||
| 54 | - import { selectType } from '../../../config/types'; | ||
| 55 | - import { Select } from 'ant-design-vue'; | ||
| 56 | - import { getUserToken } from '/@/api/sys/user'; | ||
| 57 | import { USER_INFO_KEY } from '/@/enums/cacheEnum'; | 32 | import { USER_INFO_KEY } from '/@/enums/cacheEnum'; |
| 58 | import { getAuthCache } from '/@/utils/auth'; | 33 | import { getAuthCache } from '/@/utils/auth'; |
| 59 | import { isAdmin } from '/@/enums/roleEnum'; | 34 | import { isAdmin } from '/@/enums/roleEnum'; |
| 60 | import { TableDefaultTypeEnum } from '../../../config/enum'; | 35 | import { TableDefaultTypeEnum } from '../../../config/enum'; |
| 61 | import { AggregateDataEnum } from '/@/views/report/config/timeConfig'; | 36 | import { AggregateDataEnum } from '/@/views/report/config/timeConfig'; |
| 37 | + import SelectTenant from '../components/selectTenant.vue'; | ||
| 62 | 38 | ||
| 63 | const userInfo: any = getAuthCache(USER_INFO_KEY); | 39 | const userInfo: any = getAuthCache(USER_INFO_KEY); |
| 64 | 40 | ||
| @@ -75,33 +51,14 @@ | @@ -75,33 +51,14 @@ | ||
| 75 | }, | 51 | }, |
| 76 | }); | 52 | }); |
| 77 | 53 | ||
| 78 | - onMounted(async () => { | ||
| 79 | - if (isAdmin(role)) { | ||
| 80 | - const res = await getTenantPageList(); | ||
| 81 | - selectOptions.value = res.map((m) => ({ label: m.name, value: m.tenantId })); | ||
| 82 | - } else { | ||
| 83 | - //租户 | ||
| 84 | - const { token } = await getUserToken(userInfo?.userId); | ||
| 85 | - getToken.value = token; | ||
| 86 | - } | ||
| 87 | - }); | ||
| 88 | - | ||
| 89 | - const selectOptions = ref<selectType[]>([]); | ||
| 90 | - | ||
| 91 | const testDisabled = ref(true); | 54 | const testDisabled = ref(true); |
| 92 | 55 | ||
| 93 | - const selectTenantOptions = ref<selectType[]>([]); | ||
| 94 | - | ||
| 95 | const { createMessage } = useMessage(); | 56 | const { createMessage } = useMessage(); |
| 96 | 57 | ||
| 97 | const showTestEditCell = ref(false); | 58 | const showTestEditCell = ref(false); |
| 98 | 59 | ||
| 99 | const excuteData = ref({}); | 60 | const excuteData = ref({}); |
| 100 | 61 | ||
| 101 | - const selectTenant = ref(undefined); | ||
| 102 | - | ||
| 103 | - const selectSysTenant = ref(undefined); | ||
| 104 | - | ||
| 105 | const testEditCellTableRef = ref<InstanceType<typeof TestParamsCellTable>>(); | 62 | const testEditCellTableRef = ref<InstanceType<typeof TestParamsCellTable>>(); |
| 106 | 63 | ||
| 107 | const testResult = ref(''); | 64 | const testResult = ref(''); |
| @@ -110,34 +67,11 @@ | @@ -110,34 +67,11 @@ | ||
| 110 | 67 | ||
| 111 | const getToken = ref(''); | 68 | const getToken = ref(''); |
| 112 | 69 | ||
| 113 | - const filterOption = (input: string, option: any) => { | ||
| 114 | - return option.label.includes(input); | ||
| 115 | - }; | ||
| 116 | - | ||
| 117 | - const filterTenantOption = (input: string, option: any) => { | ||
| 118 | - return option.label.includes(input); | ||
| 119 | - }; | ||
| 120 | - | ||
| 121 | - const onSelect = async (e) => { | ||
| 122 | - if (e) { | ||
| 123 | - testDisabled.value = false; | ||
| 124 | - } else { | ||
| 125 | - testDisabled.value = true; | ||
| 126 | - } | ||
| 127 | - selectSysTenant.value = undefined; | ||
| 128 | - const rest = (await getTenantAllPageLists(e)) as any; | ||
| 129 | - selectTenantOptions.value = rest?.map((m) => ({ label: m.realName, value: m.id })); | ||
| 130 | - }; | ||
| 131 | - | ||
| 132 | - const onSelctTenant = async (e) => { | ||
| 133 | - if (e) { | ||
| 134 | - testDisabled.value = false; | ||
| 135 | - } else { | ||
| 136 | - testDisabled.value = true; | ||
| 137 | - } | ||
| 138 | - const { token } = await getUserToken(e); | 70 | + const onHandleEmitToken = (token, flag) => { |
| 139 | getToken.value = token; | 71 | getToken.value = token; |
| 72 | + testDisabled.value = flag; | ||
| 140 | }; | 73 | }; |
| 74 | + | ||
| 141 | const isSingleClickText = ref('open'); | 75 | const isSingleClickText = ref('open'); |
| 142 | 76 | ||
| 143 | const handleTest = (o) => { | 77 | const handleTest = (o) => { |
| @@ -241,9 +175,6 @@ | @@ -241,9 +175,6 @@ | ||
| 241 | isSingleClickText.value = 'open'; | 175 | isSingleClickText.value = 'open'; |
| 242 | showTestEditCell.value = false; | 176 | showTestEditCell.value = false; |
| 243 | testResult.value = ''; | 177 | testResult.value = ''; |
| 244 | - selectTenant.value = undefined; | ||
| 245 | - selectSysTenant.value = undefined; | ||
| 246 | - selectTenantOptions.value = []; | ||
| 247 | }; | 178 | }; |
| 248 | 179 | ||
| 249 | const onCloseTest = () => { | 180 | const onCloseTest = () => { |