Commit dee0acbae676900856b52b4026cfb310e97820d2

Authored by loveumiko
1 parent 84ebe0b7

fix: 修复组态引用模板时先选择启用模板没选择组织设备没数据

@@ -19,7 +19,7 @@ @@ -19,7 +19,7 @@
19 }; 19 };
20 </script> 20 </script>
21 <script lang="ts" setup name="SelectAttributes"> 21 <script lang="ts" setup name="SelectAttributes">
22 - import { reactive, UnwrapRef, watchEffect, ref } from 'vue'; 22 + import { reactive, UnwrapRef, watchEffect, ref, watch } from 'vue';
23 import { propTypes } from '/@/utils/propTypes'; 23 import { propTypes } from '/@/utils/propTypes';
24 import { Select } from 'ant-design-vue'; 24 import { Select } from 'ant-design-vue';
25 import { createPickerSearch } from '/@/utils/pickerSearch'; 25 import { createPickerSearch } from '/@/utils/pickerSearch';
@@ -40,6 +40,19 @@ @@ -40,6 +40,19 @@
40 40
41 const initVal = async () => { 41 const initVal = async () => {
42 if (props.value) { 42 if (props.value) {
  43 + dynamicInput.params.push({
  44 + name: props.value.label,
  45 + profileId: props.value.value,
  46 + deviceType: props.value?.deviceType,
  47 + transportType: props.value?.transportType,
  48 + deviceList: props.value.deviceList?.filter(Boolean)?.map((item) => item.deviceId),
  49 + });
  50 + }
  51 + };
  52 +
  53 + watch(
  54 + () => props.organizationId,
  55 + async () => {
43 if (props.organizationId) { 56 if (props.organizationId) {
44 const resp = await byOrganizationIdGetMasterDevice({ 57 const resp = await byOrganizationIdGetMasterDevice({
45 organizationId: props.organizationId, 58 organizationId: props.organizationId,
@@ -51,15 +64,11 @@ @@ -51,15 +64,11 @@
51 value: item.tbDeviceId, 64 value: item.tbDeviceId,
52 })); 65 }));
53 } 66 }
54 - dynamicInput.params.push({  
55 - name: props.value.label,  
56 - profileId: props.value.value,  
57 - deviceType: props.value?.deviceType,  
58 - transportType: props.value?.transportType,  
59 - deviceList: props.value.deviceList?.filter(Boolean)?.map((item) => item.deviceId),  
60 - }); 67 + },
  68 + {
  69 + immediate: true,
61 } 70 }
62 - }; 71 + );
63 72
64 //数值改变 73 //数值改变
65 const valEffect = watchEffect(() => { 74 const valEffect = watchEffect(() => {