Commit 548a05f2245e930be3cbc91d97a82d0333a8c24f

Authored by xp.Huang
2 parents 1ebf27f7 6a85fbe2

Merge branch 'ft' into 'main_dev'

fix:修复Teambition上的问题

See merge request yunteng/thingskit-front!545
@@ -20,6 +20,17 @@ @@ -20,6 +20,17 @@
20 mode: 'code', 20 mode: 'code',
21 mainMenuBar: false, 21 mainMenuBar: false,
22 statusBar: false, 22 statusBar: false,
  23 + onFocus: () => {},
  24 + onBlur: () => {
  25 + setJsonValue('执行测试结果为:');
  26 + },
  27 + onChangeText: (e) => {
  28 + if (e.length === 0) {
  29 + setJsonValue('执行测试结果为:');
  30 + } else {
  31 + // setJsonValue(undefined);
  32 + }
  33 + },
23 } as object; 34 } as object;
24 let editor = new jsoneditor(jsoneditorRef.value, options); 35 let editor = new jsoneditor(jsoneditorRef.value, options);
25 editor.set(jsonValue.value); 36 editor.set(jsonValue.value);
@@ -29,6 +40,12 @@ @@ -29,6 +40,12 @@
29 40
30 const getJsonValue = () => unref(jsonInstance).get(); 41 const getJsonValue = () => unref(jsonInstance).get();
31 42
  43 + // const setJsonMode = (mode) => {
  44 + // nextTick(() => {
  45 + // unref(jsonInstance).setMode(mode);
  46 + // });
  47 + // };
  48 +
32 const setJsonValue = (Json) => { 49 const setJsonValue = (Json) => {
33 nextTick(() => { 50 nextTick(() => {
34 unref(jsonInstance).set(Json); 51 unref(jsonInstance).set(Json);
@@ -4,14 +4,16 @@ @@ -4,14 +4,16 @@
4 <a-row> 4 <a-row>
5 <Button @click="handleExcute" type="primary"> 执行测试请求 </Button> 5 <Button @click="handleExcute" type="primary"> 执行测试请求 </Button>
6 </a-row> 6 </a-row>
7 - <a-row class="mt-8" type="flex" justify="center" align="middle">  
8 - <a-col :span="2"> 测试地址 </a-col>  
9 - <a-col :span="22">  
10 - <Tag color="blue" style="width: 31.6vw; white-space: normal; height: auto">  
11 - {{ apiUrl?.split('{?')[0] }}  
12 - </Tag>  
13 - </a-col>  
14 - </a-row> 7 + <div v-if="isShowTestResult" style="display: flex; justify-content: space-between">
  8 + <a-row class="mt-8" type="flex" justify="center" align="middle">
  9 + <a-col :span="3"> 测试地址 </a-col>
  10 + <a-col :span="21">
  11 + <Tag color="blue" style="width: 31.6vw; white-space: normal; height: auto">
  12 + {{ apiUrl?.split('{?')[0] }}
  13 + </Tag>
  14 + </a-col>
  15 + </a-row>
  16 + </div>
15 </div> 17 </div>
16 <div class="mt-8"> 18 <div class="mt-8">
17 <a-row type="flex" justify="center"> 19 <a-row type="flex" justify="center">
@@ -35,6 +37,7 @@ @@ -35,6 +37,7 @@
35 import { useUtils } from '../../../hooks/useUtils'; 37 import { useUtils } from '../../../hooks/useUtils';
36 import JsonEditor from '../../SimpleRequest/components/jsonEditor.vue'; 38 import JsonEditor from '../../SimpleRequest/components/jsonEditor.vue';
37 import { Tag } from 'ant-design-vue'; 39 import { Tag } from 'ant-design-vue';
  40 + import { useThrottleFn } from '@vueuse/shared';
38 41
39 const emits = defineEmits(['emitExcute']); 42 const emits = defineEmits(['emitExcute']);
40 43
@@ -87,12 +90,19 @@ @@ -87,12 +90,19 @@
87 90
88 const isPostToken = ref(''); 91 const isPostToken = ref('');
89 92
  93 + const isShowTestResult = ref(false);
  94 +
90 //执行测试接口 95 //执行测试接口
91 const handleExcute = () => { 96 const handleExcute = () => {
92 emits('emitExcute'); 97 emits('emitExcute');
93 - getValue(); 98 + useThrottle();
  99 + isShowTestResult.value = true;
94 }; 100 };
95 101
  102 + const useThrottle = useThrottleFn(() => {
  103 + getValue();
  104 + }, 2000);
  105 +
96 const getValue = async () => { 106 const getValue = async () => {
97 await nextTick(); 107 await nextTick();
98 //获取Params和Header和Body 108 //获取Params和Header和Body
@@ -33,20 +33,27 @@ @@ -33,20 +33,27 @@
33 </template> 33 </template>
34 <template #slotFillAddress="{ model }"> 34 <template #slotFillAddress="{ model }">
35 <div> 35 <div>
36 - <Tag color="blue" style="width: 35vw; white-space: normal; height: auto"> 36 + <Tag
  37 + v-if="model['originUrlType'] === 'server_url'"
  38 + color="blue"
  39 + style="width: 35vw; white-space: normal; height: auto"
  40 + >
37 {{ 41 {{
38 - ` ${  
39 - model['originUrlType'] !== 'server_url'  
40 - ? !model['requestOriginUrl']  
41 - ? ''  
42 - : model['requestOriginUrl'] + model['requestHttpTypeAndUrl']?.requestUrl  
43 - : `${templateFillAddress(model['requestContentType'], model['originUrlType'])}${  
44 - model['requestHttpTypeAndUrl']?.requestUrl  
45 - }`  
46 - } 42 + ` ${`${templateFillAddress(model['requestContentType'], model['originUrlType'])}${
  43 + model['requestHttpTypeAndUrl']?.requestUrl
  44 + }`}
47 ` 45 `
48 }} 46 }}
49 </Tag> 47 </Tag>
  48 + <template v-else>
  49 + <Tag
  50 + v-if="model['requestOriginUrl']"
  51 + color="blue"
  52 + style="width: 35vw; white-space: normal; height: auto"
  53 + >
  54 + {{ ` ${model['requestOriginUrl'] + model['requestHttpTypeAndUrl']?.requestUrl}` }}
  55 + </Tag>
  56 + </template>
50 </div> 57 </div>
51 </template> 58 </template>
52 </BasicForm> 59 </BasicForm>
@@ -75,9 +75,12 @@ @@ -75,9 +75,12 @@
75 </Tooltip> 75 </Tooltip>
76 </template> 76 </template>
77 <template #deviceProfile="{ record }"> 77 <template #deviceProfile="{ record }">
78 - <a-button type="link" class="ml-2" @click="goDeviceProfile(record.deviceProfile.name)">  
79 - {{ record.deviceProfile.name }}  
80 - </a-button> 78 + <Tag.CheckableTag
  79 + @click="goDeviceProfile(record.deviceProfile.name)"
  80 + style="white-space: normal; height: auto; cursor: pointer"
  81 + >
  82 + <span style="color: #377dff">{{ record.deviceProfile.name }}</span>
  83 + </Tag.CheckableTag>
81 </template> 84 </template>
82 85
83 <template #deviceType="{ record }"> 86 <template #deviceType="{ record }">
@@ -2,18 +2,20 @@ import { FormSchema } from '/@/components/Form'; @@ -2,18 +2,20 @@ import { FormSchema } from '/@/components/Form';
2 2
3 export const tcpSchemas: FormSchema[] = [ 3 export const tcpSchemas: FormSchema[] = [
4 { 4 {
5 - field: 'upScriptId',  
6 - label: '上行脚本', 5 + field: 'authScriptId',
  6 + label: '鉴权脚本',
7 component: 'Input', 7 component: 'Input',
8 - slot: 'upScriptId', 8 + slot: 'authScriptId',
9 colProps: { span: 24 }, 9 colProps: { span: 24 },
  10 + required: true,
10 }, 11 },
11 { 12 {
12 - field: 'authScriptId',  
13 - label: '鉴权脚本', 13 + field: 'upScriptId',
  14 + label: '上行脚本',
14 component: 'Input', 15 component: 'Input',
15 - slot: 'authScriptId', 16 + slot: 'upScriptId',
16 colProps: { span: 24 }, 17 colProps: { span: 24 },
  18 + required: true,
17 }, 19 },
18 ]; 20 ];
19 21
1 <template> 1 <template>
2 <div> 2 <div>
3 <BasicForm :showResetButton="false" :showSubmitButton="false" @register="register"> 3 <BasicForm :showResetButton="false" :showSubmitButton="false" @register="register">
4 - <template #upScriptId="{ model, field }"> 4 + <template #authScriptId="{ model, field }">
5 <div style="display: flex; align-items: center"> 5 <div style="display: flex; align-items: center">
6 <div> 6 <div>
7 <Select 7 <Select
8 - @change="handleUpChange" 8 + @change="handleAuthChange"
9 placeholder="请选择" 9 placeholder="请选择"
10 v-model:value="model[field]" 10 v-model:value="model[field]"
11 style="width: 305px" 11 style="width: 305px"
12 show-search 12 show-search
13 - :options="selectUpOptions"  
14 - :filter-option="handleSearch" 13 + :options="selectAuthOptions"
  14 + :filter-option="handleAuthSearch"
15 allowClear 15 allowClear
16 /> 16 />
17 </div> 17 </div>
18 <div> 18 <div>
19 <span 19 <span
20 - @click="handleCreateOrEdit('add')" 20 + @click="handleCreateOrEditAuth('add')"
21 class="ml-2" 21 class="ml-2"
22 style="color: #409eff; cursor: pointer" 22 style="color: #409eff; cursor: pointer"
23 size="small" 23 size="small"
@@ -25,27 +25,27 @@ @@ -25,27 +25,27 @@
25 > 25 >
26 </div> 26 </div>
27 </div> 27 </div>
28 - <a-button @click="handleCreateOrEdit('test')" class="mt-4" type="primary" 28 + <a-button @click="handleCreateOrEditAuth('test')" class="mt-4" type="primary"
29 >测试脚本</a-button 29 >测试脚本</a-button
30 > 30 >
31 </template> 31 </template>
32 - <template #authScriptId="{ model, field }"> 32 + <template #upScriptId="{ model, field }">
33 <div style="display: flex; align-items: center"> 33 <div style="display: flex; align-items: center">
34 <div> 34 <div>
35 <Select 35 <Select
36 - @change="handleAuthChange" 36 + @change="handleUpChange"
37 placeholder="请选择" 37 placeholder="请选择"
38 v-model:value="model[field]" 38 v-model:value="model[field]"
39 style="width: 305px" 39 style="width: 305px"
40 show-search 40 show-search
41 - :options="selectAuthOptions"  
42 - :filter-option="handleAuthSearch" 41 + :options="selectUpOptions"
  42 + :filter-option="handleSearch"
43 allowClear 43 allowClear
44 /> 44 />
45 </div> 45 </div>
46 <div> 46 <div>
47 <span 47 <span
48 - @click="handleCreateOrEditAuth('add')" 48 + @click="handleCreateOrEdit('add')"
49 class="ml-2" 49 class="ml-2"
50 style="color: #409eff; cursor: pointer" 50 style="color: #409eff; cursor: pointer"
51 size="small" 51 size="small"
@@ -53,7 +53,7 @@ @@ -53,7 +53,7 @@
53 > 53 >
54 </div> 54 </div>
55 </div> 55 </div>
56 - <a-button @click="handleCreateOrEditAuth('test')" class="mt-4" type="primary" 56 + <a-button @click="handleCreateOrEdit('test')" class="mt-4" type="primary"
57 >测试脚本</a-button 57 >测试脚本</a-button
58 > 58 >
59 </template> 59 </template>
@@ -111,7 +111,7 @@ @@ -111,7 +111,7 @@
111 } 111 }
112 }; 112 };
113 113
114 - const [register, { getFieldsValue, resetFields, setFieldsValue }] = useForm({ 114 + const [register, { validate, resetFields, setFieldsValue }] = useForm({
115 labelWidth: 180, 115 labelWidth: 180,
116 schemas: tcpSchemas, 116 schemas: tcpSchemas,
117 actionColOptions: { 117 actionColOptions: {
@@ -171,8 +171,9 @@ @@ -171,8 +171,9 @@
171 } 171 }
172 }; 172 };
173 173
174 - const getFormData = () => {  
175 - const values = getFieldsValue(); 174 + const getFormData = async () => {
  175 + const values = await validate();
  176 + if (!values) return;
176 return { 177 return {
177 ...values, 178 ...values,
178 type: 'TCP', 179 type: 'TCP',
@@ -59,10 +59,14 @@ @@ -59,10 +59,14 @@
59 <Card title="脚本内容" :bodyStyle="{ padding: 0, height: '280px' }"> 59 <Card title="脚本内容" :bodyStyle="{ padding: 0, height: '280px' }">
60 <template #extra> 60 <template #extra>
61 <a-button @click="handleFormat" size="small">格式化</a-button> 61 <a-button @click="handleFormat" size="small">格式化</a-button>
62 - <Tooltip v-if="!ifAdd" :title="defaultAuthTitle" class="ml-2"> 62 + <Tooltip
  63 + v-if="scriptForm.scriptType !== 'TRANSPORT_TCP_UP'"
  64 + :title="defaultAuthTitle"
  65 + class="ml-2"
  66 + >
63 <QuestionCircleOutlined style="font-size: 1rem" /> 67 <QuestionCircleOutlined style="font-size: 1rem" />
64 </Tooltip> 68 </Tooltip>
65 - <Tooltip v-if="!ifAdd" :title="defaultUpTitle" class="ml-2"> 69 + <Tooltip v-else :title="defaultUpTitle" class="ml-2">
66 <QuestionCircleOutlined style="font-size: 1rem" /> 70 <QuestionCircleOutlined style="font-size: 1rem" />
67 </Tooltip> 71 </Tooltip>
68 </template> 72 </template>
@@ -95,7 +99,7 @@ @@ -95,7 +99,7 @@
95 /> 99 />
96 </a-form-item> 100 </a-form-item>
97 </a-form> 101 </a-form>
98 - <TestScriptModal @register="registerModal" @success="handleSuccess" /> 102 + <TestScriptModal @register="registerModal" />
99 </div> 103 </div>
100 </template> 104 </template>
101 <script setup lang="ts"> 105 <script setup lang="ts">
@@ -195,6 +199,7 @@ @@ -195,6 +199,7 @@
195 199
196 const handleScriptType = ({ target }) => { 200 const handleScriptType = ({ target }) => {
197 const { value } = target; 201 const { value } = target;
  202 + scriptForm.scriptType = value;
198 switchScriptTypeGetContent(value); 203 switchScriptTypeGetContent(value);
199 }; 204 };
200 205
@@ -238,7 +238,11 @@ @@ -238,7 +238,11 @@
238 const userStore = useUserStore(); 238 const userStore = useUserStore();
239 const permissionStore = usePermissionStore(); 239 const permissionStore = usePermissionStore();
240 const go = useGo(); 240 const go = useGo();
241 - async function handleLoginTenantAdmin(record: { tbUser: string; id: string }) { 241 + async function handleLoginTenantAdmin(record: {
  242 + tbUser: string;
  243 + id: string;
  244 + hasPassword: boolean;
  245 + }) {
242 try { 246 try {
243 const { token, refreshToken } = await getUserToken(record.id); 247 const { token, refreshToken } = await getUserToken(record.id);
244 userStore.storeToken(token, refreshToken); 248 userStore.storeToken(token, refreshToken);
@@ -253,7 +257,8 @@ @@ -253,7 +257,8 @@
253 }); 257 });
254 router.addRoute(PAGE_NOT_FOUND_ROUTE as unknown as RouteRecordRaw); 258 router.addRoute(PAGE_NOT_FOUND_ROUTE as unknown as RouteRecordRaw);
255 permissionStore.setDynamicAddedRoute(true); 259 permissionStore.setDynamicAddedRoute(true);
256 - go(PageEnum.BASE_HOME); 260 + if (record?.hasPassword) go(PageEnum.BASE_HOME);
  261 + else go(PageEnum.SYSTEM_PASSWORD);
257 } catch (error) { 262 } catch (error) {
258 } finally { 263 } finally {
259 } 264 }