1
|
1
|
import { defineStore } from "pinia";
|
2
|
|
-import { KeyBoundComponentList, SocketComponentRecord, SocketReceiveMessageType, SocketSendMessageItemType, SocketSendMessageType, SocketStoreType, UnsubscribePoolType } from '@/store/external/modules/socketStore.d'
|
|
2
|
+import { KeyBoundComponentList, SocketComponentRecord, SocketConnectionPoolType, SocketReceiveMessageType, SocketSendMessageItemType, SocketSendMessageType, SocketStoreType, UnsubscribePoolType } from '@/store/external/modules/socketStore.d'
|
3
|
3
|
import { CreateComponentType } from "@/packages/index.d";
|
4
|
4
|
import { RequestContentTypeEnum } from "@/enums/external/httpEnum";
|
5
|
5
|
import { useChartEditStore } from "@/store/modules/chartEditStore/chartEditStore";
|
...
|
...
|
@@ -59,13 +59,14 @@ export const useSocketStore = defineStore({ |
59
|
59
|
updateConnectionPool(entityId: string, keys: string[], componentId: string) {
|
60
|
60
|
const isExist = Reflect.has(this.connectionPool, entityId)
|
61
|
61
|
if (isExist) {
|
62
|
|
- const temp = Reflect.get(this.connectionPool, entityId)
|
|
62
|
+ const temp = Reflect.get(this.connectionPool, entityId) as { [key: string]: KeyBoundComponentList[] }
|
63
|
63
|
keys.forEach(key => {
|
64
|
64
|
const isExistKey = Reflect.has(temp, key)
|
65
|
65
|
if (!isExistKey) {
|
66
|
66
|
const keyBindEntityIdList = Reflect.get(temp, key) || []
|
67
|
67
|
Reflect.set(temp, key, [...keyBindEntityIdList, { componentId }] as KeyBoundComponentList[])
|
68
|
|
-
|
|
68
|
+ } else {
|
|
69
|
+ temp[key].push({ componentId })
|
69
|
70
|
}
|
70
|
71
|
})
|
71
|
72
|
} else {
|
...
|
...
|
@@ -260,53 +261,53 @@ export const useSocketStore = defineStore({ |
260
|
261
|
* 修改后的代码
|
261
|
262
|
* 修改ws绑定单个文本组件,然后有多个,并且进行分组,显示的信息为原始信息,而非过滤函数返回的信息
|
262
|
263
|
*/
|
263
|
|
- chartEditStore.getComponentList.forEach(targetItem => {
|
264
|
|
- if (targetItem.isGroup) {
|
265
|
|
- /**
|
266
|
|
- * 如果是分组,并且request里是ws,则分组组件这个整体是接受ws绑定的,之前分组是不能绑定ws的
|
267
|
|
- */
|
268
|
|
- if(targetItem.request.requestUrl?.includes('ws')){
|
269
|
|
- const _value = this.getComponentValueByKeys(targetItem, value)
|
270
|
|
- const { filter } = targetItem
|
271
|
|
- const { value: filterValue, reason, flag } = useFilterFn(filter, _value)
|
272
|
|
- targetItem.option.dataset = flag ? filterValue : reason
|
273
|
|
- try{
|
274
|
|
- const dumpSaveHistoryInput = JSON.parse((!targetItem.saveHistoryInput ? null: targetItem.saveHistoryInput) as string) ||JSON.parse(window.localStorage.getItem('CACHE_HISTORY_INPUT_VALUE') as string)
|
275
|
|
- if(!dumpSaveHistoryInput) return
|
276
|
|
- if(!Array.isArray(dumpSaveHistoryInput)) return
|
277
|
|
- targetItem.groupList?.forEach((item:CreateComponentType)=>{
|
278
|
|
- dumpSaveHistoryInput?.forEach((inputItem:{id:string,inputValue:string})=>{
|
279
|
|
- if(item.id === inputItem.id){
|
280
|
|
- item.option.dataset= Function('res', `return ${inputItem?.inputValue}`)(targetItem.option?.dataset)
|
|
264
|
+ chartEditStore.getComponentList.forEach(targetItem => {
|
|
265
|
+ if (targetItem.isGroup) {
|
|
266
|
+ /**
|
|
267
|
+ * 如果是分组,并且request里是ws,则分组组件这个整体是接受ws绑定的,之前分组是不能绑定ws的
|
|
268
|
+ */
|
|
269
|
+ if (targetItem.request.requestUrl?.includes('ws')) {
|
|
270
|
+ const _value = this.getComponentValueByKeys(targetItem, value)
|
|
271
|
+ const { filter } = targetItem
|
|
272
|
+ const { value: filterValue, reason, flag } = useFilterFn(filter, _value)
|
|
273
|
+ targetItem.option.dataset = flag ? filterValue : reason
|
|
274
|
+ try {
|
|
275
|
+ const dumpSaveHistoryInput = JSON.parse((!targetItem.saveHistoryInput ? null : targetItem.saveHistoryInput) as string) || JSON.parse(window.localStorage.getItem('CACHE_HISTORY_INPUT_VALUE') as string)
|
|
276
|
+ if (!dumpSaveHistoryInput) return
|
|
277
|
+ if (!Array.isArray(dumpSaveHistoryInput)) return
|
|
278
|
+ targetItem.groupList?.forEach((item: CreateComponentType) => {
|
|
279
|
+ dumpSaveHistoryInput?.forEach((inputItem: { id: string, inputValue: string }) => {
|
|
280
|
+ if (item.id === inputItem.id) {
|
|
281
|
+ item.option.dataset = Function('res', `return ${inputItem?.inputValue}`)(targetItem.option?.dataset)
|
|
282
|
+ }
|
|
283
|
+ })
|
|
284
|
+ })
|
|
285
|
+ } catch (e) {
|
|
286
|
+ console.log(e)
|
281
|
287
|
}
|
282
|
|
- })
|
283
|
|
- })
|
284
|
|
- }catch(e){
|
285
|
|
- console.log(e)
|
286
|
|
- }
|
287
|
|
- }
|
288
|
|
- /**
|
289
|
|
- * 这也是分组,但这个是分组这个整体不绑定ws,而是下面的子组件都绑定了ws
|
290
|
|
- */
|
291
|
|
- targetItem.groupList?.forEach(groupItem => {
|
292
|
|
- if (groupItem.id === id) {
|
|
288
|
+ }
|
|
289
|
+ /**
|
|
290
|
+ * 这也是分组,但这个是分组这个整体不绑定ws,而是下面的子组件都绑定了ws
|
|
291
|
+ */
|
|
292
|
+ targetItem.groupList?.forEach(groupItem => {
|
|
293
|
+ if (groupItem.id === id) {
|
293
|
294
|
const _value = this.getComponentValueByKeys(groupItem, value)
|
294
|
295
|
const { filter } = groupItem
|
295
|
296
|
const { value: filterValue, reason, flag } = useFilterFn(filter, _value)
|
296
|
297
|
groupItem.option.dataset = flag ? filterValue : reason
|
|
298
|
+ }
|
|
299
|
+ })
|
|
300
|
+ } else {
|
|
301
|
+ //单个
|
|
302
|
+ if (targetItem.id === id) {
|
|
303
|
+ const _value = this.getComponentValueByKeys(targetItem, value)
|
|
304
|
+ const { filter } = targetItem
|
|
305
|
+ const { value: filterValue, reason, flag } = useFilterFn(filter, _value)
|
|
306
|
+ targetItem.option.dataset = flag ? filterValue : reason
|
297
|
307
|
}
|
298
|
|
- })
|
299
|
|
- } else {
|
300
|
|
- //单个
|
301
|
|
- if (targetItem.id === id) {
|
302
|
|
- const _value = this.getComponentValueByKeys(targetItem, value)
|
303
|
|
- const { filter } = targetItem
|
304
|
|
- const { value: filterValue, reason, flag } = useFilterFn(filter, _value)
|
305
|
|
- targetItem.option.dataset = flag ? filterValue : reason
|
306
|
|
- }
|
307
|
|
- }
|
308
|
|
- //
|
309
|
|
- })
|
|
308
|
+ }
|
|
309
|
+ //
|
|
310
|
+ })
|
310
|
311
|
},
|
311
|
312
|
|
312
|
313
|
/**
|
...
|
...
|
|