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 20 mode: 'code',
21 21 mainMenuBar: false,
22 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 34 } as object;
24 35 let editor = new jsoneditor(jsoneditorRef.value, options);
25 36 editor.set(jsonValue.value);
... ... @@ -29,6 +40,12 @@
29 40
30 41 const getJsonValue = () => unref(jsonInstance).get();
31 42
  43 + // const setJsonMode = (mode) => {
  44 + // nextTick(() => {
  45 + // unref(jsonInstance).setMode(mode);
  46 + // });
  47 + // };
  48 +
32 49 const setJsonValue = (Json) => {
33 50 nextTick(() => {
34 51 unref(jsonInstance).set(Json);
... ...
... ... @@ -4,14 +4,16 @@
4 4 <a-row>
5 5 <Button @click="handleExcute" type="primary"> 执行测试请求 </Button>
6 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 17 </div>
16 18 <div class="mt-8">
17 19 <a-row type="flex" justify="center">
... ... @@ -35,6 +37,7 @@
35 37 import { useUtils } from '../../../hooks/useUtils';
36 38 import JsonEditor from '../../SimpleRequest/components/jsonEditor.vue';
37 39 import { Tag } from 'ant-design-vue';
  40 + import { useThrottleFn } from '@vueuse/shared';
38 41
39 42 const emits = defineEmits(['emitExcute']);
40 43
... ... @@ -87,12 +90,19 @@
87 90
88 91 const isPostToken = ref('');
89 92
  93 + const isShowTestResult = ref(false);
  94 +
90 95 //执行测试接口
91 96 const handleExcute = () => {
92 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 106 const getValue = async () => {
97 107 await nextTick();
98 108 //获取Params和Header和Body
... ...
... ... @@ -33,20 +33,27 @@
33 33 </template>
34 34 <template #slotFillAddress="{ model }">
35 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 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 57 </div>
51 58 </template>
52 59 </BasicForm>
... ...
... ... @@ -75,9 +75,12 @@
75 75 </Tooltip>
76 76 </template>
77 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 84 </template>
82 85
83 86 <template #deviceType="{ record }">
... ...
... ... @@ -2,18 +2,20 @@ import { FormSchema } from '/@/components/Form';
2 2
3 3 export const tcpSchemas: FormSchema[] = [
4 4 {
5   - field: 'upScriptId',
6   - label: '上行脚本',
  5 + field: 'authScriptId',
  6 + label: '鉴权脚本',
7 7 component: 'Input',
8   - slot: 'upScriptId',
  8 + slot: 'authScriptId',
9 9 colProps: { span: 24 },
  10 + required: true,
10 11 },
11 12 {
12   - field: 'authScriptId',
13   - label: '鉴权脚本',
  13 + field: 'upScriptId',
  14 + label: '上行脚本',
14 15 component: 'Input',
15   - slot: 'authScriptId',
  16 + slot: 'upScriptId',
16 17 colProps: { span: 24 },
  18 + required: true,
17 19 },
18 20 ];
19 21
... ...
1 1 <template>
2 2 <div>
3 3 <BasicForm :showResetButton="false" :showSubmitButton="false" @register="register">
4   - <template #upScriptId="{ model, field }">
  4 + <template #authScriptId="{ model, field }">
5 5 <div style="display: flex; align-items: center">
6 6 <div>
7 7 <Select
8   - @change="handleUpChange"
  8 + @change="handleAuthChange"
9 9 placeholder="请选择"
10 10 v-model:value="model[field]"
11 11 style="width: 305px"
12 12 show-search
13   - :options="selectUpOptions"
14   - :filter-option="handleSearch"
  13 + :options="selectAuthOptions"
  14 + :filter-option="handleAuthSearch"
15 15 allowClear
16 16 />
17 17 </div>
18 18 <div>
19 19 <span
20   - @click="handleCreateOrEdit('add')"
  20 + @click="handleCreateOrEditAuth('add')"
21 21 class="ml-2"
22 22 style="color: #409eff; cursor: pointer"
23 23 size="small"
... ... @@ -25,27 +25,27 @@
25 25 >
26 26 </div>
27 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 29 >测试脚本</a-button
30 30 >
31 31 </template>
32   - <template #authScriptId="{ model, field }">
  32 + <template #upScriptId="{ model, field }">
33 33 <div style="display: flex; align-items: center">
34 34 <div>
35 35 <Select
36   - @change="handleAuthChange"
  36 + @change="handleUpChange"
37 37 placeholder="请选择"
38 38 v-model:value="model[field]"
39 39 style="width: 305px"
40 40 show-search
41   - :options="selectAuthOptions"
42   - :filter-option="handleAuthSearch"
  41 + :options="selectUpOptions"
  42 + :filter-option="handleSearch"
43 43 allowClear
44 44 />
45 45 </div>
46 46 <div>
47 47 <span
48   - @click="handleCreateOrEditAuth('add')"
  48 + @click="handleCreateOrEdit('add')"
49 49 class="ml-2"
50 50 style="color: #409eff; cursor: pointer"
51 51 size="small"
... ... @@ -53,7 +53,7 @@
53 53 >
54 54 </div>
55 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 57 >测试脚本</a-button
58 58 >
59 59 </template>
... ... @@ -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 115 labelWidth: 180,
116 116 schemas: tcpSchemas,
117 117 actionColOptions: {
... ... @@ -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 177 return {
177 178 ...values,
178 179 type: 'TCP',
... ...
... ... @@ -59,10 +59,14 @@
59 59 <Card title="脚本内容" :bodyStyle="{ padding: 0, height: '280px' }">
60 60 <template #extra>
61 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 67 <QuestionCircleOutlined style="font-size: 1rem" />
64 68 </Tooltip>
65   - <Tooltip v-if="!ifAdd" :title="defaultUpTitle" class="ml-2">
  69 + <Tooltip v-else :title="defaultUpTitle" class="ml-2">
66 70 <QuestionCircleOutlined style="font-size: 1rem" />
67 71 </Tooltip>
68 72 </template>
... ... @@ -95,7 +99,7 @@
95 99 />
96 100 </a-form-item>
97 101 </a-form>
98   - <TestScriptModal @register="registerModal" @success="handleSuccess" />
  102 + <TestScriptModal @register="registerModal" />
99 103 </div>
100 104 </template>
101 105 <script setup lang="ts">
... ... @@ -195,6 +199,7 @@
195 199
196 200 const handleScriptType = ({ target }) => {
197 201 const { value } = target;
  202 + scriptForm.scriptType = value;
198 203 switchScriptTypeGetContent(value);
199 204 };
200 205
... ...
... ... @@ -238,7 +238,11 @@
238 238 const userStore = useUserStore();
239 239 const permissionStore = usePermissionStore();
240 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 246 try {
243 247 const { token, refreshToken } = await getUserToken(record.id);
244 248 userStore.storeToken(token, refreshToken);
... ... @@ -253,7 +257,8 @@
253 257 });
254 258 router.addRoute(PAGE_NOT_FOUND_ROUTE as unknown as RouteRecordRaw);
255 259 permissionStore.setDynamicAddedRoute(true);
256   - go(PageEnum.BASE_HOME);
  260 + if (record?.hasPassword) go(PageEnum.BASE_HOME);
  261 + else go(PageEnum.SYSTEM_PASSWORD);
257 262 } catch (error) {
258 263 } finally {
259 264 }
... ...