Commit 9cacf393b7dad7609779c4496d6953032d7ec6d5

Authored by dev001
1 parent d5ff8196

fix: 选用模板创建组态时选择产品默认赋值设备

... ... @@ -8,10 +8,10 @@ VITE_GLOB_PUBLIC_PATH = /
8 8 # Please note that no line breaks
9 9
10 10 # 本地
11   -VITE_PROXY = [["/api","http://localhost:8080/api"],["/thingskit-scada","http://localhost:5173/thingskit-scada"],["/large-designer", "http://localhost:5555/large-designer/"]]
  11 +VITE_PROXY = [["/api","http://10.0.152.126:8080/api"],["/thingskit-scada","http://localhost:5173/thingskit-scada"],["/large-designer", "http://localhost:5555/large-designer/"]]
12 12
13 13 # 实时数据的ws地址
14   -VITE_GLOB_WEB_SOCKET = ws://localhost:8080/api/ws/plugins/telemetry?token=
  14 +VITE_GLOB_WEB_SOCKET = ws://10.152.126:8080/api/ws/plugins/telemetry?token=
15 15
16 16 # Delete console
17 17 VITE_GLOB_DROP_CONSOLE = true
... ...
... ... @@ -142,13 +142,19 @@
142 142
143 143 const selectOptions: Ref<any[]> = ref([]);
144 144
145   - const handleTemplateChange = (_, option) => {
  145 + const handleTemplateChange = async (_, option) => {
146 146 const { productAndDevice } = option;
  147 + console.log(option, 'option');
147 148 if (!productAndDevice) return;
148 149 selectOptions.value = productAndDevice.map((item) => ({
149 150 label: item.name,
150 151 value: item.profileId,
151 152 }));
  153 + await nextTick();
  154 + // 赋值
  155 + selectDeviceProfileRef.value?.setFieldsValue(
  156 + productAndDevice.map((item) => ({ label: item.name, value: item.profileId }))
  157 + );
152 158 };
153 159 //
154 160
... ...
... ... @@ -19,7 +19,7 @@
19 19 </template>
20 20 </template>
21 21 <script lang="ts" setup name="SelectDevice">
22   - import { ref, Ref, PropType, unref } from 'vue';
  22 + import { ref, Ref, PropType, unref, nextTick } from 'vue';
23 23 import { Select } from 'ant-design-vue';
24 24 import SelectDevice from './SelectDevice.vue';
25 25 import { createPickerSearch } from '/@/utils/pickerSearch';
... ... @@ -51,6 +51,16 @@
51 51 return unref(bindDeviceRef.deviceAttrRef)?.map((item: any) => item.emitChange());
52 52 };
53 53
  54 + const setFieldsValue = async (productIds) => {
  55 + await nextTick();
  56 + if (!productIds && !productIds.length) {
  57 + return;
  58 + }
  59 + selectValue.value = productIds;
  60 +
  61 + profileList.value = productIds;
  62 + };
  63 +
54 64 const setValue = (value: any) => {
55 65 console.log(value);
56 66 selectValue.value = value.map((item) => ({
... ... @@ -75,6 +85,7 @@
75 85 getSelectDevice,
76 86 setValue,
77 87 retValue,
  88 + setFieldsValue,
78 89 });
79 90 </script>
80 91 <style scoped lang="css"></style>
... ...