瀏覽代碼

yvan-ext 发布

lizw 3 年之前
父節點
當前提交
e7f132a129
共有 2 個文件被更改,包括 236 次插入2 次删除
  1. 235 1
      dist/yvan-ext.js
  2. 1 1
      dist/yvan-ext.js.map

+ 235 - 1
dist/yvan-ext.js

@@ -64,6 +64,7 @@ define(['exports', 'axios', 'qs', 'lodash', 'jquery', 'recast', 'lay-excel', 'xl
     };
     var numberfield = {
         labelAlign: 'right',
+        decimalPrecision: 6,
         labelWidth: labelWidth,
     };
     var checkbox = {
@@ -197,6 +198,12 @@ define(['exports', 'axios', 'qs', 'lodash', 'jquery', 'recast', 'lay-excel', 'xl
             flex: 1
         },
     };
+    var bpmn = {
+        hideRefresh: false,
+        autoLoad: true,
+        dataSource: '',
+        bpmnConfig: {}
+    };
 
     var Defaults = /*#__PURE__*/Object.freeze({
         __proto__: null,
@@ -229,7 +236,8 @@ define(['exports', 'axios', 'qs', 'lodash', 'jquery', 'recast', 'lay-excel', 'xl
         splitter: splitter,
         maintab: maintab,
         rows: rows,
-        cols: cols
+        cols: cols,
+        bpmn: bpmn
     });
 
     var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
@@ -8788,6 +8796,47 @@ define(['exports', 'axios', 'qs', 'lodash', 'jquery', 'recast', 'lay-excel', 'xl
         return (hash & 0x7FFFFFFF) + "";
     }
 
+    var ScopeEngine = /** @class */ (function () {
+        function ScopeEngine() {
+        }
+        ScopeEngine.getVjsonAndModel = function (table, bill, layout) {
+            // 生成controller
+            var controller = {};
+            var title = table.name;
+            var vjsonItem = { xtype: "form", items: [] };
+            for (var i = 0; i < table.fields.length; i++) {
+                var item = table.fields[i];
+                if (item.hasOwnProperty("fieldset")) {
+                    vjsonItem.items.push({
+                        xtype: 'fieldset',
+                        title: item.fieldset,
+                        items: [
+                            item
+                        ]
+                    });
+                }
+                if (item.hasOwnProperty("listeners")) {
+                    controller[item.listeners.change.split(".")[1]] = function () {
+                        console.log("fuck");
+                    };
+                }
+            }
+            // 生成vjson
+            var vjson = {
+                title: title,
+                layout: 'fit',
+                items: [
+                    vjsonItem
+                ],
+                referenceHolder: true,
+            };
+            var scope = new Scope({ model: {}, vjson: vjson });
+            _.merge(scope, controller);
+            return scope;
+        };
+        return ScopeEngine;
+    }());
+
     function initComponent () {
         var ct = Ext.Component.prototype.constructor;
         Ext.Component.override({
@@ -15231,6 +15280,189 @@ define(['exports', 'axios', 'qs', 'lodash', 'jquery', 'recast', 'lay-excel', 'xl
         });
     }
 
+    /**
+     * 属性:
+     *  - autoLoad: true
+     *  - dataSource: ''
+     * 方法:
+     *  - handleZoomBig
+     *  - handleZoomSmall
+     *  - handleZoomReset
+     *  - openDiagram
+     *  - getBpmn
+     *  - getBpmnCanvas
+     *  - getBpmnOverlays
+     *  - getBpmnZoomScroll
+     * 事件:
+     *  - initFinish
+     *  - failed
+     *  - success
+     *  - itemHover
+     *  - itemOut
+     *  - itemClick
+     *  - itemDblclick
+     *  - itemMousedown
+     *  - itemMouseup
+     */
+    function initBpmn () {
+        Ext.define('Yvan.Bpmn', {
+            // extend: 'Ext.container.Container',
+            extend: 'Ext.panel.Panel',
+            alias: 'widget.bpmn',
+            xtype: 'bpmn',
+            constructor: function (config) {
+                var self = this;
+                var newConfig = _.defaultsDeep({
+                // 强制性属性
+                }, baseConfig(config, 'row-item'), config, bpmn);
+                if (!newConfig.hideToolbar) {
+                    newConfig.tbar = [];
+                    newConfig.tbar.push({
+                        xtype: 'button', iconCls: 'x-fa fa-refresh', tooltip: '刷新',
+                        listeners: {
+                            click: function (sender) {
+                                self.reload();
+                            }
+                        }
+                    });
+                    newConfig.tbar.push({
+                        xtype: 'button', tooltip: "放大", iconCls: "x-fa fa-search-plus",
+                        listeners: {
+                            click: function (sender) {
+                                self.handleZoomBig();
+                            }
+                        },
+                    });
+                    newConfig.tbar.push({
+                        xtype: 'button', tooltip: "缩小", iconCls: "x-fa fa-search-minus",
+                        listeners: {
+                            click: function (sender) {
+                                self.handleZoomSmall();
+                            }
+                        },
+                    });
+                    newConfig.tbar.push({
+                        xtype: 'button', tooltip: "还原", iconCls: "x-fa fa-reply",
+                        listeners: {
+                            click: function (sender) {
+                                self.handleZoomReset();
+                            }
+                        },
+                    });
+                }
+                this.superclass.constructor.call(self, newConfig);
+            },
+            initComponent: function () {
+                var _this = this;
+                var me = this;
+                var config = me.config;
+                var scope = lookupScope(this);
+                if (!window["IS_DESIGN_MODE"]) {
+                    //@ts-ignore
+                    require(['bpmn-modeler', 'bpmn-navigated', 'bpmn-viewer'], function (BpModeler, BpNavigated, BpmnViewer) {
+                        console.log('BpNavigated', me, BpNavigated);
+                        var dom = me.el.dom;
+                        var $dom = $(dom);
+                        var $container = $dom.find('.x-autocontainer-innerCt');
+                        var bpmn = new BpNavigated(__assign({ container: $container[0] }, config.bpmnConfig));
+                        _this._bpmn = bpmn;
+                        if (_this.autoLoad) {
+                            _this.reload();
+                        }
+                        _this.fireEvent('initFinish', _this);
+                        var eventBus = bpmn.get('eventBus');
+                        eventBus.on('element.hover', function (e) {
+                            // this.fireEvent('itemHover', this, e);
+                        });
+                        eventBus.on('element.out', function (e) {
+                            _this.fireEvent('itemOut', _this, e);
+                        });
+                        eventBus.on('element.click', function (e) {
+                            _this.fireEvent('itemClick', _this, e);
+                        });
+                        eventBus.on('element.dblclick', function (e) {
+                            _this.fireEvent('itemDblclick', _this, e);
+                        });
+                        eventBus.on('element.mousedown', function (e) {
+                            _this.fireEvent('itemMousedown', _this, e);
+                        });
+                        eventBus.on('element.mouseup', function (e) {
+                            _this.fireEvent('itemMouseup', _this, e);
+                        });
+                    });
+                }
+                this.superclass.initComponent.call(this);
+                this.on({
+                    afterrender: function (sender) {
+                        if (window["IS_DESIGN_MODE"]) {
+                            return;
+                        }
+                    }
+                });
+            },
+            /**
+             * 重新载入
+             */
+            reload: function () {
+                var _this = this;
+                var _a;
+                if (typeof this.dataSource === 'string' && this.dataSource) {
+                    var scope = lookupScope(this);
+                    var fn = lookupFn(scope, this.dataSource);
+                    (_a = fn.call(scope, this)) === null || _a === void 0 ? void 0 : _a.then(function (res) {
+                        _this.openDiagram(res.data);
+                    });
+                }
+            },
+            /**
+             * 获取bpmn
+             */
+            getBpmn: function () {
+                return this._bpmn;
+            },
+            getBpmnCanvas: function () {
+                var _a;
+                return (_a = this.getBpmn()) === null || _a === void 0 ? void 0 : _a.get('canvas');
+            },
+            getBpmnOverlays: function () {
+                var _a;
+                return (_a = this.getBpmn()) === null || _a === void 0 ? void 0 : _a.get('overlays');
+            },
+            getBpmnZoomScroll: function () {
+                var _a;
+                return (_a = this.getBpmn()) === null || _a === void 0 ? void 0 : _a.get('zoomScroll');
+            },
+            handleZoomBig: function () {
+                var _a;
+                (_a = this.getBpmnZoomScroll()) === null || _a === void 0 ? void 0 : _a.stepZoom(1);
+            },
+            handleZoomSmall: function () {
+                var _a;
+                (_a = this.getBpmnZoomScroll()) === null || _a === void 0 ? void 0 : _a.stepZoom(-1);
+            },
+            handleZoomReset: function () {
+                var _a;
+                (_a = this.getBpmnZoomScroll()) === null || _a === void 0 ? void 0 : _a.reset();
+            },
+            openDiagram: function (diagram) {
+                var _this = this;
+                if (!this.getBpmn()) {
+                    return;
+                }
+                this.getBpmn().importXML(diagram, function (err) {
+                    if (err) {
+                        // YvEventDispatch(this.onFailed, this, undefined);
+                        _this.fireEvent('failed', _this, err);
+                        return console.error('could not import BPMN 2.0 diagram', err);
+                    }
+                    // zoom to fit full viewport
+                    _this.getBpmnCanvas().zoom('fit-viewport');
+                    _this.fireEvent('success', _this);
+                });
+            },
+        });
+    }
+
     var FixClass = /** @class */ (function () {
         function FixClass() {
         }
@@ -15472,6 +15704,7 @@ define(['exports', 'axios', 'qs', 'lodash', 'jquery', 'recast', 'lay-excel', 'xl
         initCombogrid();
         initComboGridMulti();
         initIframe();
+        initBpmn();
     }
 
     exports.axios = axios;
@@ -15487,6 +15720,7 @@ define(['exports', 'axios', 'qs', 'lodash', 'jquery', 'recast', 'lay-excel', 'xl
     exports.ReportScope = ReportScope;
     exports.SIMPLE_RE = SIMPLE_RE;
     exports.Scope = Scope;
+    exports.ScopeEngine = ScopeEngine;
     exports.SystemEventFu = SystemEventFu;
     exports.ajax = ajax;
     exports.baseConfigProcess = baseConfigProcess;

File diff suppressed because it is too large
+ 1 - 1
dist/yvan-ext.js.map