dcim-topology2d 1.1.5 → 1.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/core/src/calling.js +3 -0
- package/core/src/common.js +21 -94
- package/core/src/core.js +4 -3
- package/core/src/divLayer.js +6 -3
- package/core/src/models/node.js +7 -6
- package/core/src/models/pen.js +6 -6
- package/core/src/store/data.d.ts +4 -1
- package/core/src/store/data.js +4 -0
- package/core/src/utils/assignment.d.ts +3 -0
- package/core/src/utils/assignment.js +69 -0
- package/core/src/utils/index.d.ts +1 -0
- package/core/src/utils/index.js +1 -0
- package/package.json +1 -1
    
        package/core/src/calling.js
    CHANGED
    
    | @@ -71,12 +71,14 @@ var Calling = (function () { | |
| 71 71 | 
             
                    if (data.nodes) {
         | 
| 72 72 | 
             
                        for (var _i = 0, _a = data.nodes; _i < _a.length; _i++) {
         | 
| 73 73 | 
             
                            var item = _a[_i];
         | 
| 74 | 
            +
                            item.TID = this.id;
         | 
| 74 75 | 
             
                            item.rect.x = 0;
         | 
| 75 76 | 
             
                            item.rect.y = 0;
         | 
| 76 77 | 
             
                            this.store.data.pens.push(new Node(item));
         | 
| 77 78 | 
             
                        }
         | 
| 78 79 | 
             
                        for (var _b = 0, _c = data.lines; _b < _c.length; _b++) {
         | 
| 79 80 | 
             
                            var item = _c[_b];
         | 
| 81 | 
            +
                            item.TID = this.id;
         | 
| 80 82 | 
             
                            this.store.data.pens.push(new Line(item));
         | 
| 81 83 | 
             
                        }
         | 
| 82 84 | 
             
                    }
         | 
| @@ -84,6 +86,7 @@ var Calling = (function () { | |
| 84 86 | 
             
                    if (data.pens) {
         | 
| 85 87 | 
             
                        for (var _d = 0, _e = data.pens; _d < _e.length; _d++) {
         | 
| 86 88 | 
             
                            var item = _e[_d];
         | 
| 89 | 
            +
                            item.TID = this.id;
         | 
| 87 90 | 
             
                            if (!item.from) {
         | 
| 88 91 | 
             
                                this.store.data.pens.push(new Node(item));
         | 
| 89 92 | 
             
                            } else {
         | 
    
        package/core/src/common.js
    CHANGED
    
    | @@ -3,10 +3,10 @@ import {DivLayer} from './divLayer'; | |
| 3 3 | 
             
            import {AnimateLayer} from './animateLayer';
         | 
| 4 4 | 
             
            import {RenderLayer} from './renderLayer';
         | 
| 5 5 | 
             
            import {Offscreen} from './offscreen';
         | 
| 6 | 
            -
            import {Line, Node, Point | 
| 6 | 
            +
            import {Line, Node, Point} from './models';
         | 
| 7 7 | 
             
            import {setConfItemNode, setStatisticalData} from './healps';
         | 
| 8 | 
            -
            import {s8, formatPadding, getRect} from './utils';
         | 
| 9 | 
            -
            import { useStore, clearStore } from './store'
         | 
| 8 | 
            +
            import {s8, formatPadding, getRect, setInitNodeDataValidat, setDefaultNodeValidat} from './utils';
         | 
| 9 | 
            +
            import { useStore, clearStore, syncMqttData } from './store'
         | 
| 10 10 | 
             
            import {POLL} from './poll';
         | 
| 11 11 | 
             
            import axios from 'axios';
         | 
| 12 12 | 
             
            import * as mqtt from './mqtt.min';
         | 
| @@ -189,7 +189,7 @@ var Common = /** @class */ (function () { | |
| 189 189 | 
             
                    // for old data.
         | 
| 190 190 | 
             
                    if (data.nodes) {
         | 
| 191 191 | 
             
                        for (var _i = 0, _a = data.nodes; _i < _a.length; _i++) {
         | 
| 192 | 
            -
                            _a[_i] | 
| 192 | 
            +
                            setInitNodeDataValidat(_a[_i], this.id);
         | 
| 193 193 | 
             
                            const item = new Node(_a[_i]);
         | 
| 194 194 | 
             
                            this.store.data.pens.push(item);
         | 
| 195 195 | 
             
                            this.store.pens[item.id] = item;
         | 
| @@ -210,8 +210,8 @@ var Common = /** @class */ (function () { | |
| 210 210 | 
             
                    if (data.pens) {
         | 
| 211 211 | 
             
                        for (var _d = 0, _e = data.pens; _d < _e.length; _d++) {
         | 
| 212 212 | 
             
                            const item = _e[_d];
         | 
| 213 | 
            -
                            item.TID = this.id;
         | 
| 214 213 | 
             
                            if (!item.from) {
         | 
| 214 | 
            +
                                setInitNodeDataValidat(item, this.id);
         | 
| 215 215 | 
             
                                const node = new Node(item);
         | 
| 216 216 | 
             
                                this.store.data.pens.push(node);
         | 
| 217 217 | 
             
                                this.store.pens[item.id] = node;
         | 
| @@ -491,6 +491,7 @@ var Common = /** @class */ (function () { | |
| 491 491 | 
             
                        let topics = mqttTopics
         | 
| 492 492 | 
             
                        this.isEnd = false;
         | 
| 493 493 | 
             
                        // let num = 0; // 记录推送的次数,用于判单丢失情况
         | 
| 494 | 
            +
                        //console.log('mqtt.connect======', url)
         | 
| 494 495 | 
             
                        this.mqttClient = mqtt.connect(url, options);
         | 
| 495 496 | 
             
                        var _this = this;
         | 
| 496 497 | 
             
                        this.mqttClient.on('message', function (topic, message) {
         | 
| @@ -928,8 +929,15 @@ var Common = /** @class */ (function () { | |
| 928 929 | 
             
                        }
         | 
| 929 930 | 
             
                    });
         | 
| 930 931 | 
             
                    if (ret.data && ret.data.data) {
         | 
| 931 | 
            -
                        if (assetData) ret.data.data.asset = assetData
         | 
| 932 | 
            -
                        drawedData =  | 
| 932 | 
            +
                        if (assetData) ret.data.data.asset = assetData;
         | 
| 933 | 
            +
                        drawedData = ret.data.data;
         | 
| 934 | 
            +
                        if(panelData) {
         | 
| 935 | 
            +
                            syncMqttData.data = drawedData; // 初始化调用
         | 
| 936 | 
            +
                            Store.set('mqtt:responseData', drawedData);
         | 
| 937 | 
            +
                        }else {
         | 
| 938 | 
            +
                            syncMqttData.data = null;
         | 
| 939 | 
            +
                            this.mqttDataDrawing(canvasData, drawedData);
         | 
| 940 | 
            +
                        }
         | 
| 933 941 | 
             
                    }
         | 
| 934 942 | 
             
                    this.clearInterValAll();
         | 
| 935 943 | 
             
                    this.timmerByTopology = setTimeout(() => {
         | 
| @@ -943,109 +951,29 @@ var Common = /** @class */ (function () { | |
| 943 951 | 
             
                    } else {
         | 
| 944 952 | 
             
                        return {
         | 
| 945 953 | 
             
                            mqttData: drawedData,
         | 
| 946 | 
            -
                            detailData: detailJson
         | 
| 954 | 
            +
                            // detailData: detailJson
         | 
| 947 955 | 
             
                        }
         | 
| 948 956 | 
             
                    }
         | 
| 949 957 | 
             
                };
         | 
| 950 958 | 
             
                Common.prototype.mqttDataDrawing = function (data, retData, detailJson) {
         | 
| 951 959 | 
             
                    const syncData = retData
         | 
| 952 | 
            -
                    const detailData = detailJson ? detailJson.data : [];
         | 
| 960 | 
            +
                    //const detailData = detailJson ? detailJson.data : [];
         | 
| 953 961 | 
             
                    // console.log('收到消息', syncData)
         | 
| 954 962 | 
             
                    Store.set('mqtt:responseData', syncData);
         | 
| 955 963 | 
             
                    data.pens.map((item) => {
         | 
| 956 | 
            -
                        item.TID = this.id;
         | 
| 957 964 | 
             
                        if (item.children && item.children.length) {
         | 
| 958 965 | 
             
                            item.children.map((_item) => {
         | 
| 959 | 
            -
                                 | 
| 960 | 
            -
                                item.defaultFontColor = item.font.color;
         | 
| 961 | 
            -
                                if (item.name === 'line') item.defaultLineColor = item.strokeStyle;
         | 
| 962 | 
            -
                                if (!_item.data) return
         | 
| 963 | 
            -
                                //const node = detailData.length > 0 ? detailData : syncData
         | 
| 964 | 
            -
                                const functionData = _item.events.filter((ev) => {
         | 
| 965 | 
            -
                                    return ev.action === EventAction.Function
         | 
| 966 | 
            -
                                })
         | 
| 967 | 
            -
                                const dataValue = functionData[0]
         | 
| 968 | 
            -
                                if (functionData.length > 0 && dataValue.value && retData) {
         | 
| 969 | 
            -
                                    _item.data.map((d) => {
         | 
| 970 | 
            -
                                        const {kpiData, tagData} = retData;
         | 
| 971 | 
            -
                                        const key = d.key;
         | 
| 972 | 
            -
                                        const value = d.value;
         | 
| 973 | 
            -
                                        const _syncItem = key === 'tagId' ? tagData[value] : kpiData[value];
         | 
| 974 | 
            -
                                        if ((key === 'tagId' || key === 'kpiAddr') && _syncItem) {
         | 
| 975 | 
            -
                                            const isControl = parseInt(_syncItem.isControlDis); // 是否可控,0可控,1不可控
         | 
| 976 | 
            -
                                            if (!isControl) {
         | 
| 977 | 
            -
                                                d.tagVal = value
         | 
| 978 | 
            -
                                                d.controlParams = _syncItem
         | 
| 979 | 
            -
                                                // delete _syncItem[value]
         | 
| 980 | 
            -
                                                // Object.assign(d, _syncItem)
         | 
| 981 | 
            -
                                            }
         | 
| 982 | 
            -
                                        }
         | 
| 983 | 
            -
                                    })
         | 
| 984 | 
            -
                                    //console.log('定制函数=====')
         | 
| 985 | 
            -
                                    try {
         | 
| 986 | 
            -
                                        const func = new Function('pen', 'params', dataValue.value)
         | 
| 987 | 
            -
                                        func(_item, JSON.stringify(retData))
         | 
| 988 | 
            -
                                    }catch (e) {
         | 
| 989 | 
            -
                                        console.log(`自定义函数 ${item.id} 出错>>>`, e);
         | 
| 990 | 
            -
                                    }
         | 
| 991 | 
            -
                                } else {
         | 
| 992 | 
            -
                                    // console.log('默认函数')
         | 
| 993 | 
            -
                                    setConfItemNode(_item, syncData);
         | 
| 994 | 
            -
                                }
         | 
| 995 | 
            -
                                this.machAnimateReset(item);
         | 
| 966 | 
            +
                                setDefaultNodeValidat(_item, syncData);
         | 
| 996 967 | 
             
                            })
         | 
| 997 968 | 
             
                        } else {
         | 
| 998 | 
            -
                            item | 
| 999 | 
            -
                            item.defaultFontColor = item.font.color;
         | 
| 1000 | 
            -
                            if (item.name === 'line') item.defaultLineColor = item.strokeStyle;
         | 
| 1001 | 
            -
                            if (!item.data) return
         | 
| 1002 | 
            -
                            //const node = detailData.length > 0 ? detailData : syncData
         | 
| 1003 | 
            -
                            const functionData = item.events.filter((ev) => {
         | 
| 1004 | 
            -
                                return ev.action === EventAction.Function
         | 
| 1005 | 
            -
                            })
         | 
| 1006 | 
            -
                            const dataValue = functionData[0]
         | 
| 1007 | 
            -
                            if (functionData.length > 0 && dataValue.value && retData) {
         | 
| 1008 | 
            -
                                item.data.map((d) => {
         | 
| 1009 | 
            -
                                    const {kpiData, tagData} = retData;
         | 
| 1010 | 
            -
                                    const key = d.key;
         | 
| 1011 | 
            -
                                    const value = d.value;
         | 
| 1012 | 
            -
                                    const _syncItem = key === 'tagId' ? tagData[value] : kpiData[value];
         | 
| 1013 | 
            -
                                    if ((key === 'tagId' || key === 'kpiAddr') && _syncItem) {
         | 
| 1014 | 
            -
                                        const isControl = parseInt(_syncItem.isControlDis); // 是否可控,0可控,1不可控
         | 
| 1015 | 
            -
                                        if (!isControl) {
         | 
| 1016 | 
            -
                                            d.tagVal = value;
         | 
| 1017 | 
            -
                                            d.controlParams = _syncItem;
         | 
| 1018 | 
            -
                                            // delete _syncItem[value]
         | 
| 1019 | 
            -
                                            // Object.assign(d, _syncItem)
         | 
| 1020 | 
            -
                                        }
         | 
| 1021 | 
            -
                                    }
         | 
| 1022 | 
            -
                                });
         | 
| 1023 | 
            -
                                try {
         | 
| 1024 | 
            -
                                    const func = new Function('pen', 'params', dataValue.value);
         | 
| 1025 | 
            -
                                    func(item, JSON.stringify(retData));
         | 
| 1026 | 
            -
                                }catch (e) {
         | 
| 1027 | 
            -
                                    console.log(`自定义函数 ${item.id} 出错>>>`, e);
         | 
| 1028 | 
            -
                                }
         | 
| 1029 | 
            -
                            } else {
         | 
| 1030 | 
            -
                                // console.log('默认函数')
         | 
| 1031 | 
            -
                                setConfItemNode(item, syncData);
         | 
| 1032 | 
            -
                            }
         | 
| 1033 | 
            -
                            this.machAnimateReset(item);
         | 
| 969 | 
            +
                            setDefaultNodeValidat(item, syncData);
         | 
| 1034 970 | 
             
                        }
         | 
| 1035 971 | 
             
                    })
         | 
| 1036 | 
            -
                    // | 
| 972 | 
            +
                    //console.log('执行完毕-----', this.store.data.pens)
         | 
| 1037 973 | 
             
                    this.render();
         | 
| 1038 974 | 
             
                    this.animate(true);
         | 
| 1039 975 | 
             
                    return data
         | 
| 1040 976 | 
             
                };
         | 
| 1041 | 
            -
                Common.prototype.machAnimateReset = function (pen) {
         | 
| 1042 | 
            -
                    if (!pen.animateFrames || pen.animateFrames.length <= 0) return;
         | 
| 1043 | 
            -
                    for (var _a = 0, _af = pen.animateFrames; _a < _af.length; _a++) {
         | 
| 1044 | 
            -
                        var ani = _af[_a];
         | 
| 1045 | 
            -
                        ani.state.strokeStyle = pen.strokeStyle;
         | 
| 1046 | 
            -
                        ani.state.fillStyle = pen.fillStyle;
         | 
| 1047 | 
            -
                    }
         | 
| 1048 | 
            -
                };
         | 
| 1049 977 | 
             
                Common.prototype.getTagParamsForKpiAddrs = async function (assetId, tagParams, apiStr) {
         | 
| 1050 978 | 
             
                    let params = {
         | 
| 1051 979 | 
             
                        assetId: assetId,
         | 
| @@ -1178,8 +1106,7 @@ var Common = /** @class */ (function () { | |
| 1178 1106 | 
             
                Common.prototype.doMqttDrow = function (ret) {
         | 
| 1179 1107 | 
             
                    let canvasData = this.store.data;
         | 
| 1180 1108 | 
             
                    ret = JSON.parse(ret);
         | 
| 1181 | 
            -
                    // | 
| 1182 | 
            -
                    // console.log('this.canvas.data',this.canvas.data)
         | 
| 1109 | 
            +
                    //console.log('处理消息', ret)
         | 
| 1183 1110 | 
             
                    this.mqttDataDrawing(canvasData, ret)
         | 
| 1184 1111 | 
             
                };
         | 
| 1185 1112 | 
             
                Common.prototype.hidePenByTag = function (pens, val) {
         | 
    
        package/core/src/core.js
    CHANGED
    
    | @@ -47,7 +47,6 @@ var Topology = (function (_super) { | |
| 47 47 | 
             
                        close: false, //闭合
         | 
| 48 48 | 
             
                    };
         | 
| 49 49 | 
             
                    _this.onMouseMove = function (e) {
         | 
| 50 | 
            -
                        _this.store.data.dataResize = 0;
         | 
| 51 50 | 
             
                        if (Store.get('addingArbitraryGraph')) {
         | 
| 52 51 | 
             
                            return
         | 
| 53 52 | 
             
                        }
         | 
| @@ -179,12 +178,13 @@ var Topology = (function (_super) { | |
| 179 178 | 
             
                            if ((moveLeft || moveTop)) {
         | 
| 180 179 | 
             
                                _this.scroll(moveLeft ? -100 : 0, moveTop ? -100 : 0);
         | 
| 181 180 | 
             
                            }
         | 
| 182 | 
            -
                            // | 
| 181 | 
            +
                            //console.log('_this.moveIn.type----', _this.moveIn.type)
         | 
| 183 182 | 
             
                            switch (_this.moveIn.type) {
         | 
| 184 183 | 
             
                                case _this.moveInType.None:
         | 
| 185 184 | 
             
                                    _this.hoverLayer.dragRect = new Rect(_this.mouseDown.x, _this.mouseDown.y, pos.x - _this.mouseDown.x, pos.y - _this.mouseDown.y);
         | 
| 186 185 | 
             
                                    break;
         | 
| 187 186 | 
             
                                case _this.moveInType.Nodes:
         | 
| 187 | 
            +
                                    _this.store.data.dataResize = 0;
         | 
| 188 188 | 
             
                                    if (_this.activeLayer.locked()) {
         | 
| 189 189 | 
             
                                        break;
         | 
| 190 190 | 
             
                                    }
         | 
| @@ -197,6 +197,7 @@ var Topology = (function (_super) { | |
| 197 197 | 
             
                                    }
         | 
| 198 198 | 
             
                                    break;
         | 
| 199 199 | 
             
                                case _this.moveInType.ResizeCP:
         | 
| 200 | 
            +
                                    _this.store.data.dataResize = 1;
         | 
| 200 201 | 
             
                                    var p1 = new Point(_this.mouseDown.x, _this.mouseDown.y);
         | 
| 201 202 | 
             
                                    var p2 = new Point(pos.x, pos.y);
         | 
| 202 203 | 
             
                                    var offsetX = p2.x - p1.x;
         | 
| @@ -562,7 +563,7 @@ var Topology = (function (_super) { | |
| 562 563 | 
             
                        _this.needCache = false;
         | 
| 563 564 | 
             
                    };
         | 
| 564 565 | 
             
                    _this.onkeydown = function (key) {
         | 
| 565 | 
            -
                        if (_this.store.data.locked ||
         | 
| 566 | 
            +
                        if (_this.store && _this.store.data.locked ||
         | 
| 566 567 | 
             
                                key.target.tagName === 'INPUT' ||
         | 
| 567 568 | 
             
                                key.target.tagName === 'TEXTAREA') {
         | 
| 568 569 | 
             
                            return;
         | 
    
        package/core/src/divLayer.js
    CHANGED
    
    | @@ -85,9 +85,12 @@ var DivLayer = /** @class */ (function (_super) { | |
| 85 85 | 
             
                    return _this;
         | 
| 86 86 | 
             
                }
         | 
| 87 87 | 
             
                DivLayer.prototype.addIframe = function (node) {
         | 
| 88 | 
            -
                     | 
| 89 | 
            -
                     | 
| 90 | 
            -
             | 
| 88 | 
            +
                    let iframe = document.getElementById(`iframe${node.id}`);
         | 
| 89 | 
            +
                    if (!iframe){
         | 
| 90 | 
            +
                        iframe = createIframeElement(node);
         | 
| 91 | 
            +
                        this.iframes[node.id] = iframe;
         | 
| 92 | 
            +
                        commonStore[node.TID].parentElem.appendChild(iframe);
         | 
| 93 | 
            +
                    }
         | 
| 91 94 | 
             
                    return iframe;
         | 
| 92 95 | 
             
                };
         | 
| 93 96 | 
             
                DivLayer.prototype.addGif = function (node) {
         | 
    
        package/core/src/models/node.js
    CHANGED
    
    | @@ -239,12 +239,13 @@ var Node = /** @class */ (function (_super) { | |
| 239 239 | 
             
                    if (this.iframe ||
         | 
| 240 240 | 
             
                            this.elementId ||
         | 
| 241 241 | 
             
                            this.hasGif()) {
         | 
| 242 | 
            -
                         | 
| 243 | 
            -
             | 
| 244 | 
            -
             | 
| 245 | 
            -
                         | 
| 246 | 
            -
             | 
| 247 | 
            -
                         | 
| 242 | 
            +
                        Store.set(this.generateStoreKey('LT:addDiv'), this);
         | 
| 243 | 
            +
                        // if(type || this.iframe) {
         | 
| 244 | 
            +
                        //     // 复合Echarts初始化
         | 
| 245 | 
            +
                        //     createChildrenDivByElementId(this);
         | 
| 246 | 
            +
                        // }else {
         | 
| 247 | 
            +
                        //     Store.set(this.generateStoreKey('LT:addDiv'), this);
         | 
| 248 | 
            +
                        // }
         | 
| 248 249 | 
             
                    }
         | 
| 249 250 | 
             
                };
         | 
| 250 251 | 
             
                Node.prototype.hasGif = function () {
         | 
    
        package/core/src/models/pen.js
    CHANGED
    
    | @@ -21,9 +21,6 @@ var Pen = /** @class */ (function () { | |
| 21 21 | 
             
                    this.strokeStyle = '';
         | 
| 22 22 | 
             
                    this.visitStrokeStyle = '';
         | 
| 23 23 | 
             
                    this.fillStyle = '';
         | 
| 24 | 
            -
                    this.defaultFillStyle = '';
         | 
| 25 | 
            -
                    this.defaultFontColor = '#fff';
         | 
| 26 | 
            -
                    this.defaultStrokeStyle = '';
         | 
| 27 24 | 
             
                    this.font = {
         | 
| 28 25 | 
             
                        color: '',
         | 
| 29 26 | 
             
                        fontFamily: '"Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Helvetica, Arial',
         | 
| @@ -48,6 +45,9 @@ var Pen = /** @class */ (function () { | |
| 48 45 | 
             
                    this.events = [];
         | 
| 49 46 | 
             
                    this.eventFns = ['link', 'doAnimate', 'doFn', 'doWindowFn'];
         | 
| 50 47 | 
             
                    this.floorImageIndex = false;
         | 
| 48 | 
            +
                    this.defaultFillStyle = '';
         | 
| 49 | 
            +
                    this.defaultFontColor = '';
         | 
| 50 | 
            +
                    this.defaultStrokeStyle = '';
         | 
| 51 51 | 
             
                    if (json) {
         | 
| 52 52 | 
             
                        this.id = json.id || s8();
         | 
| 53 53 | 
             
                        this.name = json.name || '';
         | 
| @@ -76,9 +76,6 @@ var Pen = /** @class */ (function () { | |
| 76 76 | 
             
                        this.visitStrokeStyle = json.visitStrokeStyle || '';
         | 
| 77 77 | 
             
                        this.strokeStyle = json.strokeStyle || '';
         | 
| 78 78 | 
             
                        this.fillStyle = json.fillStyle || '';
         | 
| 79 | 
            -
                        this.defaultFillStyle = json.defaultFillStyle || '';
         | 
| 80 | 
            -
                        this.defaultFontColor = json.defaultFontColor || '#fff';
         | 
| 81 | 
            -
                        this.defaultStrokeStyle = json.defaultStrokeStyle || '';
         | 
| 82 79 | 
             
                        this.lineCap = json.lineCap;
         | 
| 83 80 | 
             
                        this.globalAlpha = (json.globalAlpha || json.globalAlpha === 0) ? json.globalAlpha : 1
         | 
| 84 81 | 
             
                        this.rotate = json.rotate || 0;
         | 
| @@ -111,6 +108,9 @@ var Pen = /** @class */ (function () { | |
| 111 108 | 
             
                        this.tipId = json.tipId;
         | 
| 112 109 | 
             
                        this.title = json.title;
         | 
| 113 110 | 
             
                        this.visible = json.visible !== false;
         | 
| 111 | 
            +
                        this.defaultFillStyle = json.defaultFillStyle || '';
         | 
| 112 | 
            +
                        this.defaultFontColor = json.defaultFontColor || '';
         | 
| 113 | 
            +
                        this.defaultStrokeStyle = json.defaultStrokeStyle || '';
         | 
| 114 114 | 
             
                        if (json.rectInParent) {
         | 
| 115 115 | 
             
                            this.rectInParent = json.rectInParent;
         | 
| 116 116 | 
             
                        }
         | 
    
        package/core/src/store/data.d.ts
    CHANGED
    
    
    
        package/core/src/store/data.js
    CHANGED
    
    | @@ -14,6 +14,9 @@ import { Lock } from '../models'; | |
| 14 14 | 
             
            import {DefalutOptions} from '../options';
         | 
| 15 15 | 
             
            import {s8} from '../utils';
         | 
| 16 16 | 
             
            import { commonStore } from './common'
         | 
| 17 | 
            +
            export const syncMqttData = {
         | 
| 18 | 
            +
                data: null
         | 
| 19 | 
            +
            }
         | 
| 17 20 | 
             
            export var createStore = function () {
         | 
| 18 21 | 
             
                return {
         | 
| 19 22 | 
             
                    id: '',
         | 
| @@ -78,5 +81,6 @@ export var clearStore = function (store, del) { | |
| 78 81 | 
             
                    scaleX: 1,
         | 
| 79 82 | 
             
                    scaleY: 1
         | 
| 80 83 | 
             
                };
         | 
| 84 | 
            +
                syncMqttData.data = null;
         | 
| 81 85 | 
             
                if(del) delete commonStore[store.id];
         | 
| 82 86 | 
             
            };
         | 
| @@ -0,0 +1,69 @@ | |
| 1 | 
            +
            // 变量赋值操作
         | 
| 2 | 
            +
            import {syncMqttData} from '../store';
         | 
| 3 | 
            +
            import { setConfItemNode } from '../healps';
         | 
| 4 | 
            +
            import { EventAction } from '../models';
         | 
| 5 | 
            +
            export function setInitNodeDataValidat(node, TID) {
         | 
| 6 | 
            +
                const syncData = syncMqttData.data;
         | 
| 7 | 
            +
                if (node.children && node.children.length) {
         | 
| 8 | 
            +
                    node.children.map((_item) => {
         | 
| 9 | 
            +
                        node.TID = TID;
         | 
| 10 | 
            +
                        setDefaultColorValidat(node);
         | 
| 11 | 
            +
                        setDefaultNodeValidat(node, syncData);
         | 
| 12 | 
            +
                    })
         | 
| 13 | 
            +
                }else {
         | 
| 14 | 
            +
                    node.TID = TID;
         | 
| 15 | 
            +
                    setDefaultColorValidat(node);
         | 
| 16 | 
            +
                    setDefaultNodeValidat(node, syncData);
         | 
| 17 | 
            +
                }
         | 
| 18 | 
            +
            }
         | 
| 19 | 
            +
            export function setDefaultColorValidat(node) {
         | 
| 20 | 
            +
                node.defaultFillStyle = node.fillStyle;
         | 
| 21 | 
            +
                node.defaultFontColor = node.font.color;
         | 
| 22 | 
            +
                if (node.name === 'line') {
         | 
| 23 | 
            +
                    node.defaultStrokeStyle = node.font.color;
         | 
| 24 | 
            +
                }
         | 
| 25 | 
            +
            }
         | 
| 26 | 
            +
            export function setDefaultNodeValidat(node, retData) {
         | 
| 27 | 
            +
                //const item = JSON.parse(JSON.stringify(node));
         | 
| 28 | 
            +
                if (!node.data || !retData) return;
         | 
| 29 | 
            +
                //const node = detailData.length > 0 ? detailData : syncData
         | 
| 30 | 
            +
                const functionData = node.events.filter((ev) => {
         | 
| 31 | 
            +
                    return ev.action === EventAction.Function
         | 
| 32 | 
            +
                })
         | 
| 33 | 
            +
                const dataValue = functionData[0]
         | 
| 34 | 
            +
                if (functionData.length > 0 && dataValue.value && retData) {
         | 
| 35 | 
            +
                    node.data.map((d) => {
         | 
| 36 | 
            +
                        const {kpiData, tagData} = retData;
         | 
| 37 | 
            +
                        const key = d.key;
         | 
| 38 | 
            +
                        const value = d.value;
         | 
| 39 | 
            +
                        const _syncItem = key === 'tagId' ? tagData[value] : kpiData[value];
         | 
| 40 | 
            +
                        if ((key === 'tagId' || key === 'kpiAddr') && _syncItem) {
         | 
| 41 | 
            +
                            const isControl = parseInt(_syncItem.isControlDis); // 是否可控,0可控,1不可控
         | 
| 42 | 
            +
                            if (!isControl) {
         | 
| 43 | 
            +
                                d.tagVal = value
         | 
| 44 | 
            +
                                d.controlParams = _syncItem
         | 
| 45 | 
            +
                                // delete _syncItem[value]
         | 
| 46 | 
            +
                                // Object.assign(d, _syncItem)
         | 
| 47 | 
            +
                            }
         | 
| 48 | 
            +
                        }
         | 
| 49 | 
            +
                    })
         | 
| 50 | 
            +
                    // console.log('定制函数=====')
         | 
| 51 | 
            +
                    try {
         | 
| 52 | 
            +
                        const func = new Function('pen', 'params', dataValue.value)
         | 
| 53 | 
            +
                        func(node, JSON.stringify(retData))
         | 
| 54 | 
            +
                    }catch (e) {
         | 
| 55 | 
            +
                        console.log(`自定义函数 ${node.id} 出错>>>`, e);
         | 
| 56 | 
            +
                    }
         | 
| 57 | 
            +
                } else {
         | 
| 58 | 
            +
                    // console.log('默认函数')
         | 
| 59 | 
            +
                    setConfItemNode(node, retData);
         | 
| 60 | 
            +
                }
         | 
| 61 | 
            +
                if (node.animateFrames && node.animateFrames.length) {
         | 
| 62 | 
            +
                    for (var _a = 0, _af = node.animateFrames; _a < _af.length; _a++) {
         | 
| 63 | 
            +
                        var ani = _af[_a];
         | 
| 64 | 
            +
                        ani.state.strokeStyle = node.strokeStyle;
         | 
| 65 | 
            +
                        ani.state.fillStyle = node.fillStyle;
         | 
| 66 | 
            +
                    }
         | 
| 67 | 
            +
                }
         | 
| 68 | 
            +
                //return node;
         | 
| 69 | 
            +
            } 
         | 
    
        package/core/src/utils/index.js
    CHANGED