Commit cc4527f42479f14bf8a4361d6c1060e180f88d45

Authored by xp.Huang
2 parents aa2120d8 86f47acb

Merge branch 'ww' into 'main'

fix: BUG in teambition

See merge request huang/yun-teng-iot-front!460
... ... @@ -90,6 +90,13 @@ export const deviceProfile = () => {
90 90 });
91 91 };
92 92
  93 +export const queryDeviceProfileBy = (params: Recordable) => {
  94 + return defHttp.get<DeviceRecord[]>({
  95 + url: DeviceManagerApi.DEVICE_PROFILE_URL_ME,
  96 + params,
  97 + });
  98 +};
  99 +
93 100 // 创建或编辑设备
94 101 export const createOrEditDevice = (data) => {
95 102 return defHttp.post({
... ...
... ... @@ -247,7 +247,7 @@
247 247 getSonFormValue.value,
248 248 getNameObj,
249 249 id,
250   - additionalInfoV
  250 + additionalInfoV.additionalInfo.description ? additionalInfoV : {}
251 251 );
252 252 if (!unref(isUpdate)) {
253 253 delete allPostForm.id;
... ...
... ... @@ -219,14 +219,14 @@ export const modeKafkaForm: FormSchema[] = [
219 219 return !!values.addMetadataKeyValuesAsKafkaHeaders;
220 220 },
221 221 },
222   -
223 222 {
224 223 field: 'description',
225 224 label: '说明',
226   - colProps: { span: 12 },
  225 + colProps: { span: 24 },
227 226 component: 'InputTextArea',
228 227 componentProps: {
229 228 maxLength: 255,
  229 + rows: 4,
230 230 placeholder: '请输入说明',
231 231 },
232 232 },
... ... @@ -440,10 +440,11 @@ export const modeMqttForm: FormSchema[] = [
440 440 {
441 441 field: 'description',
442 442 label: '说明',
443   - colProps: { span: 12 },
  443 + colProps: { span: 24 },
444 444 component: 'InputTextArea',
445 445 componentProps: {
446 446 maxLength: 255,
  447 + rows: 4,
447 448 placeholder: '请输入说明',
448 449 },
449 450 },
... ... @@ -610,10 +611,11 @@ export const modeRabbitMqForm: FormSchema[] = [
610 611 {
611 612 field: 'description',
612 613 label: '说明',
613   - colProps: { span: 12 },
  614 + colProps: { span: 24 },
614 615 component: 'InputTextArea',
615 616 componentProps: {
616 617 maxLength: 255,
  618 + rows: 4,
617 619 placeholder: '请输入说明',
618 620 },
619 621 },
... ... @@ -957,10 +959,11 @@ export const modeApiForm: FormSchema[] = [
957 959 {
958 960 field: 'description',
959 961 label: '说明',
960   - colProps: { span: 12 },
  962 + colProps: { span: 24 },
961 963 component: 'InputTextArea',
962 964 componentProps: {
963 965 maxLength: 255,
  966 + rows: 4,
964 967 placeholder: '请输入说明',
965 968 },
966 969 },
... ...
... ... @@ -9,7 +9,7 @@ import { scheduleOptions } from './formatData';
9 9 import { copyTransFun } from '/@/utils/fnUtils';
10 10 import { numberAndNonegativeRule } from '/@/utils/rules';
11 11 import { findDictItemByCode } from '/@/api/system/dict';
12   -import { deviceProfile } from '/@/api/device/deviceManager';
  12 +import { deviceProfile, queryDeviceProfileBy } from '/@/api/device/deviceManager';
13 13 import { getModelServices } from '/@/api/device/modelOfMatter';
14 14 import { ModelOfMatterParams } from '/@/api/device/model/modelOfMatterModel';
15 15 import useCommonFun from '../hooks/useCommonFun';
... ... @@ -237,8 +237,9 @@ export const trigger_condition_schema: FormSchema[] = [
237 237 componentProps: ({ formActionType, formModel }) => {
238 238 const { updateSchema, setFieldsValue } = formActionType;
239 239 const deviceType = formModel['deviceType'];
  240 +
240 241 return {
241   - api: deviceProfile,
  242 + api: queryDeviceProfileBy,
242 243 params: {
243 244 deviceType,
244 245 },
... ...
... ... @@ -30,6 +30,7 @@
30 30
31 31 const props = defineProps<{
32 32 record: DataBoardLayoutInfo;
  33 + isEdit: boolean;
33 34 frontId?: FrontComponent;
34 35 defaultConfig?: Partial<ComponentInfo>;
35 36 componentCategory?: FrontComponentCategory;
... ... @@ -296,6 +297,7 @@
296 297 <div class="pl-2 flex-auto">
297 298 <component
298 299 :frontId="$props.frontId"
  300 + :isEdit="isEdit"
299 301 :is="dataSourceComponent"
300 302 :ref="(el) => setFormEl(el, item.id)"
301 303 />
... ...
... ... @@ -62,7 +62,7 @@
62 62
63 63 const resetForm = () => {
64 64 isEdit.value = false;
65   - frontId.value = FrontComponent.TEXT_COMPONENT_1;
  65 + frontId.value = undefined;
66 66 componentRecord.value = {} as unknown as DataBoardLayoutInfo;
67 67 componentDefaultConfig.value = {};
68 68 };
... ... @@ -153,6 +153,7 @@
153 153 <BasicConfiguration
154 154 ref="basicConfigurationEl"
155 155 :front-id="frontId"
  156 + :isEdit="isEdit"
156 157 :record="componentRecord"
157 158 :defaultConfig="componentDefaultConfig"
158 159 :componentCategory="getComponentCategory"
... ...
... ... @@ -9,14 +9,16 @@
9 9
10 10 const props = defineProps<{
11 11 frontId?: FrontComponent;
  12 + isEdit: boolean;
12 13 }>();
13 14
14 15 defineExpose({ formActionType: formEl });
15 16
16 17 const getDataSchema = computed(() => {
17   - const { frontId } = props;
  18 + const { frontId, isEdit } = props;
  19 + console.log({ frontId });
18 20 if (!frontId) return [];
19   - return dataSourceSchema(frontId);
  21 + return dataSourceSchema(isEdit, frontId);
20 22 });
21 23
22 24 onMounted(() => {
... ...
... ... @@ -5,6 +5,7 @@
5 5 import { FrontComponent } from '../../../const/const';
6 6
7 7 defineProps<{
  8 + isEdit: boolean;
8 9 frontId?: FrontComponent;
9 10 }>();
10 11
... ... @@ -38,7 +39,7 @@
38 39 <div class="w-full flex-1">
39 40 <BasicForm
40 41 :ref="(el) => setFormEl(el)"
41   - :schemas="dataSourceSchema($props.frontId)"
  42 + :schemas="dataSourceSchema($props.isEdit, $props.frontId)"
42 43 class="w-full flex-1 data-source-form"
43 44 :show-action-button-group="false"
44 45 :row-props="{
... ...
... ... @@ -92,7 +92,7 @@ export const basicSchema: FormSchema[] = [
92 92 },
93 93 ];
94 94
95   -export const dataSourceSchema = (frontId?: FrontComponent): FormSchema[] => {
  95 +export const dataSourceSchema = (isEdit: boolean, frontId?: FrontComponent): FormSchema[] => {
96 96 return [
97 97 {
98 98 field: DataSourceField.IS_GATEWAY_DEVICE,
... ... @@ -117,6 +117,7 @@ export const dataSourceSchema = (frontId?: FrontComponent): FormSchema[] => {
117 117 component: 'ApiSelect',
118 118 label: '设备类型',
119 119 colProps: { span: 8 },
  120 + // defaultValue: DeviceTypeEnum.SENSOR,
120 121 componentProps: ({ formActionType }) => {
121 122 const { setFieldsValue } = formActionType;
122 123 return {
... ... @@ -147,14 +148,13 @@ export const dataSourceSchema = (frontId?: FrontComponent): FormSchema[] => {
147 148 rules: [{ required: true, message: '产品为必填项' }],
148 149 componentProps: ({ formActionType, formModel }) => {
149 150 const { setFieldsValue } = formActionType;
150   - const deviceProfileId = formModel[DataSourceField.DEVICE_PROFILE_ID];
151 151 const deviceType = formModel[DataSourceField.DEVICE_TYPE];
152   - if (![deviceType, deviceProfileId].every(Boolean)) return {};
153 152 return {
154 153 api: async () => {
155 154 if (!deviceType) return [];
156 155 const list = await getDeviceProfile(deviceType);
157   - if (deviceProfileId) {
  156 + if (isEdit) {
  157 + const deviceProfileId = formModel[DataSourceField.DEVICE_PROFILE_ID];
158 158 const record = list.find((item) => item.id === deviceProfileId);
159 159 setFieldsValue({ [DataSourceField.TRANSPORT_TYPE]: record?.transportType });
160 160 }
... ... @@ -254,7 +254,7 @@ export const dataSourceSchema = (frontId?: FrontComponent): FormSchema[] => {
254 254 componentProps({ formModel }) {
255 255 const deviceProfileId = formModel[DataSourceField.DEVICE_PROFILE_ID];
256 256 const transportType = formModel[DataSourceField.TRANSPORT_TYPE];
257   - if (![deviceProfileId, transportType].every(Boolean)) return {};
  257 + if (isEdit && ![deviceProfileId, transportType].every(Boolean)) return {};
258 258 return {
259 259 api: async () => {
260 260 try {
... ...