Commit b2ad4d171a23135cc939234a14e19a363ca54f95

Authored by xp.Huang
2 parents 4ebea6ec 61ab426c

Merge branch 'dev-fix-ww' into 'main_dev'

fix: 修复teambition中BUG

See merge request yunteng/thingskit-front!569
... ... @@ -27,30 +27,14 @@ export const step1Schemas: FormSchema[] = [
27 27 component: 'Input',
28 28 componentProps: {
29 29 maxLength: 255,
  30 + placeholder: '请输入别名',
30 31 },
31 32 },
32 33 {
33 34 field: 'name',
34 35 label: '设备名称',
35 36 component: 'Input',
36   - dynamicRules: () => {
37   - return [
38   - {
39   - required: true,
40   - validator: (_, value) => {
41   - // 支持英文字母、数字、下划线(_)、中划线(-)、点号(.)、半角冒号(:)和特殊字符@,长度限制为4~32个字符
42   - const reg = /^[A-Za-z0-9_\( \)\-\@\:\.]+$/;
43   - const strLength = String(value).length as number;
44   - if (!reg.test(value) || strLength > 32 || strLength < 4) {
45   - return Promise.reject(
46   - '请输入支持英文字母、数字、下划线(_)、中划线(-)、点号(.)、半角冒号(:)和特殊字符@,长度限制为4~32个字符'
47   - );
48   - }
49   - return Promise.resolve();
50   - },
51   - },
52   - ];
53   - },
  37 + rules: [{ required: true, message: '设备名称为必填项' }],
54 38 slot: 'snCode',
55 39 },
56 40 {
... ... @@ -97,6 +81,7 @@ export const step1Schemas: FormSchema[] = [
97 81 });
98 82 },
99 83 showSearch: true,
  84 + placeholder: '请选择产品',
100 85 filterOption: (inputValue: string, option: Record<'label' | 'value', string>) =>
101 86 option.label.includes(inputValue),
102 87 };
... ... @@ -120,6 +105,17 @@ export const step1Schemas: FormSchema[] = [
120 105 },
121 106 },
122 107 {
  108 + field: 'code',
  109 + label: '设备标识',
  110 + required: true,
  111 + component: 'Input',
  112 + componentProps: {
  113 + maxLength: 255,
  114 + placeholder: '请输入设备标识',
  115 + },
  116 + ifShow: ({ values }) => values?.transportType === TransportTypeEnum.TCP,
  117 + },
  118 + {
123 119 field: 'brand',
124 120 component: 'ApiRadioGroup',
125 121 label: '选择厂家',
... ...
... ... @@ -28,15 +28,16 @@ export const columns: BasicColumn[] = [
28 28 slots: { customRender: 'name', title: 'deviceTitle' },
29 29 customRender: ({ record }) => {
30 30 return h('div', { style: 'display:flex;flex-direction:column' }, [
  31 + record.alias &&
  32 + h(
  33 + 'div',
  34 + {
  35 + class: 'cursor-pointer',
  36 + },
  37 + `${record.alias}`
  38 + ),
31 39 h(
32   - 'p',
33   - {
34   - class: 'cursor-pointer',
35   - },
36   - `${record.alias}`
37   - ),
38   - h(
39   - 'p',
  40 + 'div',
40 41 {
41 42 class: 'cursor-pointer text-blue-500',
42 43 onClick: () => {
... ...
... ... @@ -40,7 +40,7 @@
40 40 </template>
41 41 <template #snCode="{ model, field }">
42 42 <div class="flex">
43   - <Input v-model:value="model[field]" />
  43 + <Input v-model:value="model[field]" placeholder="请输入设备名称" />
44 44 <a-button type="link" @click="generateSN">自动生成</a-button>
45 45 </div>
46 46 </template>
... ...
... ... @@ -428,7 +428,7 @@
428 428 createMessage.success('删除成功');
429 429 handleReload();
430 430 } catch (error) {
431   - createMessage.error('删除失败');
  431 + throw error;
432 432 } finally {
433 433 setLoading(false);
434 434 }
... ...
... ... @@ -138,7 +138,7 @@ const deviceTableColumn: BasicColumn[] = [
138 138 },
139 139 },
140 140 [
141   - h('div', { class: 'truncate' }, record.alias),
  141 + record.alias && h('div', { class: 'truncate' }, record.alias),
142 142 h('div', { class: 'text-blue-400 truncate' }, record.name),
143 143 ]
144 144 ),
... ...
... ... @@ -294,8 +294,9 @@
294 294 watch(
295 295 () => props.frontId,
296 296 async (target, oldTarget) => {
297   - if (isControlComponent(oldTarget!) && isControlComponent(target!)) return;
298   - await resetFormFields();
  297 + if ([isControlComponent(oldTarget!), isControlComponent(target!)].some(Boolean)) {
  298 + await resetFormFields();
  299 + }
299 300 }
300 301 );
301 302
... ...
... ... @@ -14,6 +14,7 @@
14 14 import { useCalcGridLayout } from '../../hook/useCalcGridLayout';
15 15 import { FrontComponent } from '../../const/const';
16 16 import { frontComponentMap } from '../../components/help';
  17 + import { ValidateErrorEntity } from 'ant-design-vue/es/form/interface';
17 18
18 19 interface DataComponentRouteParams extends RouteParams {
19 20 id: string;
... ... @@ -75,7 +76,14 @@
75 76 unref(isEdit) ? handleUpdateComponent(value) : handleAddComponent(value);
76 77 resetForm();
77 78 } catch (error: unknown) {
78   - window.console.error(error);
  79 + if (
  80 + ((error || {}) as ValidateErrorEntity).errorFields &&
  81 + ((error || {}) as ValidateErrorEntity).errorFields.length
  82 + ) {
  83 + const tooltip = ((error || {}) as ValidateErrorEntity).errorFields[0];
  84 + createMessage.warning(tooltip.errors[0]);
  85 + }
  86 + throw error;
79 87 }
80 88 };
81 89
... ... @@ -97,7 +105,7 @@
97 105 closeModal();
98 106 emit('create');
99 107 } catch (error) {
100   - console.log(error);
  108 + throw error;
101 109 // createMessage.error('创建失败');
102 110 } finally {
103 111 changeOkLoading(false);
... ...
... ... @@ -289,6 +289,7 @@ export const dataSourceSchema = (isEdit: boolean, frontId?: FrontComponent): For
289 289 component: 'ApiSelect',
290 290 label: '命令类型',
291 291 defaultValue: CommandTypeEnum.CUSTOM.toString(),
  292 + rules: [{ required: true, message: '请选择命令类型' }],
292 293 colProps: { span: 8 },
293 294 ifShow: ({ model }) =>
294 295 isControlComponent(frontId!) && isTcpProfile(model[DataSourceField.TRANSPORT_TYPE]),
... ... @@ -347,6 +348,7 @@ export const dataSourceSchema = (isEdit: boolean, frontId?: FrontComponent): For
347 348 component: 'Input',
348 349 label: '命令',
349 350 colProps: { span: 8 },
  351 + rules: [{ required: true, message: '请输入下发命令' }],
350 352 // 是控制组件 && 自定义命令 && 传输协议为TCP
351 353 ifShow: ({ model }) =>
352 354 isControlComponent(frontId!) &&
... ...