فهرست منبع

仓库布局 remove / add / edit / save

luoyifan 2 سال پیش
والد
کامیت
737878670d
5فایلهای تغییر یافته به همراه277 افزوده شده و 21 حذف شده
  1. 5 6
      assets/mxgraph-editor/resources/grapheditor.txt
  2. 3 0
      assets/mxgraph/fix.css
  3. 1 1
      assets/yvan_require.js
  4. 267 13
      dist/yvan-ext.js
  5. 1 1
      dist/yvan-ext.js.map

+ 5 - 6
assets/mxgraph-editor/resources/grapheditor.txt

@@ -8,7 +8,7 @@ done=完成
 doubleClickOrientation=双击以更改方向
 error=错误
 errorSavingFile=保存文件时出错
-ok=好啊
+ok=确定
 updatingDocument=更新文件。请稍候...
 updatingSelection=更新所选内容。请稍候...
 # 自定义资源
@@ -108,7 +108,7 @@ enterPropertyName=输入属性名
 entityRelation=实体联系
 exitGroup=退出组
 expand=扩大
-export=出
+export=
 extras=其他
 file=文件
 fileNotFound=找不到文件
@@ -139,7 +139,6 @@ formatted=格式化
 formattedText=格式化文本
 gap=间隔
 glass=玻璃
-general=常规{1}
 global=全局
 gradient=渐变
 gradientColor=渐变颜色
@@ -161,7 +160,7 @@ html=HTML
 id=ID
 image=Image
 images=Images
-import=Import
+import=导入
 increaseIndent=增加缩进
 insert=插入
 insertColumnBefore=向左插入列
@@ -200,7 +199,7 @@ moreResults=更多结果
 move=移动
 moveSelectionTo=将所选内容移动到 {1}
 navigation=导航
-new=新
+new=新
 noColor=没有颜色
 noFiles=没有文件
 noMoreResults=没有更多的结果
@@ -220,7 +219,7 @@ openInThisWindow=在这个窗口打开
 options=选项
 organic=器质性
 orthogonal=直角
-outline=概述
+outline=大纲
 oval=椭圆
 pages=页
 pageView=页面查看

+ 3 - 0
assets/mxgraph/fix.css

@@ -0,0 +1,3 @@
+.geDialog {
+    box-sizing: content-box;
+}

+ 1 - 1
assets/yvan_require.js

@@ -96,7 +96,6 @@ define(["require", "exports"], function (require2, exports) {
                 'lay-excel': '/assets/layui-excel/excel',
                 'xlsx': '/assets/xlsx/xlsx.full.min',
 
-
                 'modeler': '../../node_modules/bpmn-js/dist/bpmn-modeler.development',
                 'bpmn-js-properties-panel': '../../node_modules/bpmn-js-properties-panel/dist/bpmn-js-properties-panel.umd',
 
@@ -241,6 +240,7 @@ define(["require", "exports"], function (require2, exports) {
                 'mxgraph': {
                     deps: [
                         'css!/assets/mxgraph/styles/grapheditor.css',
+                        'css!/assets/mxgraph/fix.css',
                         'mxgraphDialogs'
                     ]
                 },

+ 267 - 13
dist/yvan-ext.js

@@ -2807,6 +2807,7 @@ define(['exports', 'axios', 'qs', 'lodash', 'jquery', 'moment', 'recast', 'xlsx'
         dbcode: undefined,
         report: undefined,
         widget: undefined,
+        whLayout: undefined,
     };
     window['handles'] = handles$1;
     function setDictTree(value) {
@@ -2830,6 +2831,9 @@ define(['exports', 'axios', 'qs', 'lodash', 'jquery', 'moment', 'recast', 'xlsx'
     function setWidget(value) {
         handles$1.widget = value;
     }
+    function setWhLayout(value) {
+        handles$1.whLayout = value;
+    }
     function setViewoutlinetree(value) {
         handles$1.viewoutlinetree = value;
     }
@@ -4921,11 +4925,62 @@ define(['exports', 'axios', 'qs', 'lodash', 'jquery', 'moment', 'recast', 'xlsx'
             console.error(msg, e);
         });
     }
+    function saveWhLayout(param) {
+        return request.post(getLayoutUrl() + "@saveWhLayout", {
+            args: [
+                param,
+            ]
+        }).catch(function (e) {
+            var _a, _b;
+            var msg = ((_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.msg) || 'saveWhLayout ERROR!';
+            showErrorDialog('发生错误:' + msg);
+            console.error(msg, e);
+        });
+    }
+    function deleteWhLayout(param) {
+        return request.post(getLayoutUrl() + "@deleteWhLayout", {
+            args: [
+                param,
+            ]
+        }).catch(function (e) {
+            var _a, _b;
+            var msg = ((_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.msg) || 'deleteWhLayout ERROR!';
+            showErrorDialog('发生错误:' + msg);
+            console.error(msg, e);
+        });
+    }
+    function loadWhLayoutAll() {
+        return request.post(getLayoutUrl() + "@loadWhLayoutAll", {
+            args: []
+        }).catch(function (e) {
+            var _a, _b;
+            var msg = ((_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.msg) || 'loadWhLayoutAll ERROR!';
+            showErrorDialog('发生错误:' + msg);
+            console.error(msg, e);
+        });
+    }
+    function loadWhLayout(param) {
+        return request.post(getLayoutUrl() + "@loadWhLayout", {
+            args: [
+                param,
+            ]
+        }).catch(function (e) {
+            var _a, _b;
+            var msg = ((_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.msg) || 'loadWhLayout ERROR!';
+            showErrorDialog('发生错误:' + msg);
+            console.error(msg, e);
+        });
+    }
     var baseUrl = "/api/com/yvan/studio/FileManager";
+    var layoutUrl = "/api/com/yvan/studio/LayoutManager";
     function getBaseUrl() {
         // return getCurrentProject().url + baseUrl
         return baseUrl;
     }
+    function getLayoutUrl() {
+        // return getCurrentProject().url + baseUrl
+        return layoutUrl;
+    }
     var Request = /** @class */ (function () {
         function Request(axiosInstance) {
             this.axiosInstance = axiosInstance;
@@ -13960,20 +14015,38 @@ define(['exports', 'axios', 'qs', 'lodash', 'jquery', 'moment', 'recast', 'xlsx'
             this.viewModel.set('layoutCode', this.layoutCode);
             this.viewModel.set('layoutName', this.layoutName);
             if (this.layoutCode) {
-                this.viewModel.set('title', this.layoutName);
+                this.viewModel.set('title', this.layoutName + ' [' + this.layoutCode + ']');
             }
             else {
                 this.viewModel.set('title', '新建图纸');
             }
         };
+        WidgetDesign.prototype.reload = function () {
+            var _this = this;
+            this.setLoading(true);
+            loadWhLayout({
+                layoutCode: this.layoutCode,
+                layoutName: this.layoutName,
+            }).then(function (res) {
+                if (res.success) {
+                    var xml = res.data.layoutContent;
+                    var doc = mxUtils.parseXml(xml);
+                    var graph = _this.editorUi.editor.graph;
+                    graph.setSelectionCells(graph.importGraphModel(doc.documentElement));
+                }
+            }).finally(function () {
+                _this.setLoading(false);
+            });
+        };
         WidgetDesign.prototype.editorInit = function (sender) {
+            var that = this;
             var dom = $(sender.el.dom).find('.geEditor')[0];
             //@ts-ignore
             require(['mxgraph'], function () {
                 var editorUiInit = EditorUi.prototype.init;
                 EditorUi.prototype.init = function () {
                     editorUiInit.apply(this, arguments);
-                    this.actions.get('export').setEnabled(false);
+                    // this.actions.get('export').setEnabled(false);
                     // Updates action states which require a backend
                     // if (!Editor.useLocalStorage) {
                     //     mxUtils.post(OPEN_URL, '', mxUtils.bind(this, function (req) {
@@ -13985,11 +14058,25 @@ define(['exports', 'axios', 'qs', 'lodash', 'jquery', 'moment', 'recast', 'xlsx'
                     //         this.actions.get('export').setEnabled(enabled);
                     //     }));
                     // }
+                    // this.actions.get('save').setEnabled(enabled);
+                    console.log('EditorUi=editorUi', this);
+                    this.actions.get('save').funct = that.onFileSave.bind(that);
+                    this.actions.get('saveAs').funct = that.onFileSaveAs.bind(that);
+                    this.actions.get('open').visible = false;
+                    this.actions.get('new').visible = false;
+                    this.actions.get('preview').visible = false;
+                    this.actions.get('print').visible = false;
+                    this.actions.get('pageSetup').visible = false;
+                    this.actions.get('help').visible = false;
+                    this.actions.get('about').visible = false;
+                    this.menus.menus.help.setEnabled(false);
+                    that.editorUi = this;
+                    if (that.layoutCode) {
+                        that.reload();
+                    }
                 };
                 var RESOURCE_BASE = '/assets/mxgraph-editor/resources/grapheditor';
                 var mxLanguage = 'zh';
-                // Adds required resources (disables loading of fallback properties, this can only
-                // be used if we know that all keys are defined in the language specific file)
                 mxResources.loadDefaultBundle = false;
                 var bundle = mxResources.getDefaultBundle(RESOURCE_BASE, mxLanguage) ||
                     mxResources.getSpecialBundle(RESOURCE_BASE, mxLanguage);
@@ -14002,14 +14089,103 @@ define(['exports', 'axios', 'qs', 'lodash', 'jquery', 'moment', 'recast', 'xlsx'
                     var themes = new Object();
                     themes[Graph.prototype.defaultThemeName] = xhr[1].getDocumentElement();
                     // Main
-                    new EditorUi(new Editor(urlParams['chrome'] == '0', themes), dom);
+                    new EditorUi(new Editor(false, themes), dom);
                 }, function () {
-                    document.body.innerHTML = '<center style="margin-top:10%;">Error loading resource files. Please check browser console.</center>';
+                    dom.innerHTML = '<center style="margin-top:10%;">Error loading resource files. Please check browser console.</center>';
                 });
             });
         };
         WidgetDesign.prototype.onDestroy = function () {
         };
+        WidgetDesign.prototype.onFileLoad = function () {
+        };
+        WidgetDesign.prototype.onFileSaveAs = function () {
+            var _this = this;
+            this.showSaveAsDlg({ code: this.layoutCode, name: this.layoutName })
+                .then(function (_a) {
+                var code = _a.code, name = _a.name;
+                _this.layoutCode = code;
+                _this.layoutName = name;
+                _this.onSave();
+            });
+        };
+        WidgetDesign.prototype.onSave = function () {
+            var _this = this;
+            var layoutContent = this.editorUi.getEditBlankXml();
+            var layoutCode = this.layoutCode;
+            var layoutName = this.layoutName;
+            if (!layoutCode || !layoutName) {
+                msg$1('图形编号和图形名称必填');
+                return;
+            }
+            this.viewModel.set('title', this.layoutName + ' [' + this.layoutCode + ']');
+            this.setLoading(true);
+            saveWhLayout({
+                layoutCode: layoutCode, layoutName: layoutName, layoutContent: layoutContent
+            }).then(function (res) {
+                msg$1(res.msg);
+            }).finally(function () {
+                _this.setLoading(false);
+            });
+        };
+        WidgetDesign.prototype.onFileSave = function () {
+            if (!this.layoutCode || !this.layoutName) {
+                this.onFileSaveAs();
+            }
+            else {
+                this.onSave();
+            }
+        };
+        WidgetDesign.prototype.showSaveAsDlg = function (_a) {
+            var code = _a.code, name = _a.name;
+            return new Promise(function (resolve, reject) {
+                var viewModel = new Ext.app.ViewModel({
+                    data: {
+                        code: code !== null && code !== void 0 ? code : '',
+                        name: name !== null && name !== void 0 ? name : '',
+                    }
+                });
+                var dlg = Ext.create('Ext.window.Window', {
+                    title: '保存',
+                    viewModel: viewModel,
+                    layout: {
+                        type: "vbox",
+                        pack: "start",
+                        align: "stretch"
+                    },
+                    items: [
+                        {
+                            xtype: 'textfield', fieldLabel: '图编号', margin: '0 15 15 0',
+                            bind: '{code}'
+                        },
+                        {
+                            xtype: 'textfield', fieldLabel: '图名称', margin: '0 15 15 0',
+                            bind: '{name}'
+                        }
+                    ],
+                    fbar: [
+                        {
+                            xtype: 'button', text: '保存', iconCls: 'x-fa fa-save', listeners: {
+                                click: function () {
+                                    var code = viewModel.get('code');
+                                    var name = viewModel.get('name');
+                                    resolve({ code: code, name: name });
+                                    dlg.close();
+                                }
+                            }
+                        },
+                        {
+                            xtype: 'button', text: '取消', iconCls: 'x-fa fa-times', listeners: {
+                                click: function () {
+                                    dlg.close();
+                                }
+                            }
+                        },
+                    ]
+                });
+                dlg.show();
+            });
+        };
         return WidgetDesign;
     }(Scope));
     //@ts-ignore
@@ -14017,7 +14193,6 @@ define(['exports', 'axios', 'qs', 'lodash', 'jquery', 'moment', 'recast', 'xlsx'
         path: {},
         shim: {}
     });
-    //# sourceMappingURL=WhLayoutDesign.js.map
 
     // init()
     var Workbench = /** @class */ (function (_super) {
@@ -30475,8 +30650,9 @@ define(['exports', 'axios', 'qs', 'lodash', 'jquery', 'moment', 'recast', 'xlsx'
                                 if (res.success) {
                                     msg$1('添加成功');
                                     // 添加
-                                    handles$1.mainWindow.showWidget(widgetPath, title);
-                                    me.reload();
+                                    handles$1.mainWindow.showWidget(widgetPath, title, function () {
+                                        me.reload();
+                                    });
                                     win.close();
                                 }
                             });
@@ -30494,6 +30670,7 @@ define(['exports', 'axios', 'qs', 'lodash', 'jquery', 'moment', 'recast', 'xlsx'
         };
         WidgetGridController.prototype.widgetRemove = function (sender) {
             var _this = this;
+            //@ts-ignore
             var record = this.getView().selection.data;
             if (!record) {
                 msg$1('请选择一行');
@@ -30522,11 +30699,14 @@ define(['exports', 'axios', 'qs', 'lodash', 'jquery', 'moment', 'recast', 'xlsx'
             }
         };
         WidgetGridController.prototype.onDestory = function (sender) {
+            var me = this;
             setWidget(undefined);
             instance$3.unregiste(me.reloadData.bind(this));
         };
         WidgetGridController.prototype.reloadData = function (res) {
             var me = this;
+            //@ts-ignore
+            var view = me.getView();
             if (typeof res === 'object') {
                 // const data = []
                 // _.forOwn(res, (v, k) => {
@@ -30536,31 +30716,34 @@ define(['exports', 'axios', 'qs', 'lodash', 'jquery', 'moment', 'recast', 'xlsx'
                 //         vjson : v
                 //     })
                 // })
-                me.getView().setStore(new Ext.data.Store({
+                view.setStore(new Ext.data.Store({
                     fields: ['widget_path', 'widget_name'],
                     data: res.data,
                 }));
             }
             else if (typeof res === 'boolean') {
-                me.getView().setLoading(res);
+                view.setLoading(res);
             }
         };
         WidgetGridController.prototype.reload = function () {
             instance$3.reloadForce(undefined);
         };
         WidgetGridController.prototype.filterChanged = function (sender, value) {
+            //@ts-ignore
             this.view.store.clearFilter();
             if (value) {
+                //@ts-ignore
                 this.view.store.filterBy(function (record) {
                     var widget_path = record.get('widget_path');
                     var widget_name = record.get('widget_name');
-                    return (system.pinyinMatch(widget_name, value) ||
-                        _.includes(_.toLower(widget_path), _.toLower(value)));
+                    return (window['system'].pinyinMatch(widget_name, value) ||
+                        _$2.includes(_$2.toLower(widget_path), _$2.toLower(value)));
                 });
             }
         };
         WidgetGridController.prototype.onClearClick = function () {
             var _a, _b;
+            //@ts-ignore
             (_b = (_a = this.getReferences()) === null || _a === void 0 ? void 0 : _a.txtFilter) === null || _b === void 0 ? void 0 : _b.setValue('');
         };
         WidgetGridController.prototype.onDblClick = function (sender, record) {
@@ -30651,12 +30834,83 @@ define(['exports', 'axios', 'qs', 'lodash', 'jquery', 'moment', 'recast', 'xlsx'
     var WhLayoutController = /** @class */ (function () {
         function WhLayoutController() {
         }
+        WhLayoutController.prototype.onLoad = function (sender) {
+            var _this = this;
+            var me = this;
+            setWhLayout(me);
+            _$2.defer(function () {
+                _this.reload();
+            });
+        };
         WhLayoutController.prototype.reload = function () {
+            //@ts-ignore
+            var view = this.getView();
+            view.setLoading(true);
+            loadWhLayoutAll().then(function (res) {
+                view.setStore(new Ext.data.Store({
+                    fields: ['layout_code', 'layout_name'],
+                    data: res.data,
+                }));
+            }).finally(function () {
+                view.setLoading(false);
+            });
         };
         WhLayoutController.prototype.add = function () {
             handles$1.mainWindow.showLayoutDesign(undefined, undefined);
         };
+        WhLayoutController.prototype.edit = function (data) {
+            handles$1.mainWindow.showLayoutDesign(data.layout_code, data.layout_name);
+        };
         WhLayoutController.prototype.remove = function () {
+            var _this = this;
+            var _a;
+            //@ts-ignore
+            var view = this.getView();
+            var record = (_a = view.selection) === null || _a === void 0 ? void 0 : _a.data;
+            if (!record) {
+                msg$1('请选择一行数据');
+                return;
+            }
+            var layoutCode = record.layout_code;
+            Ext.Msg.confirm('提示', "是否删除图形:" + layoutCode + "?", function (btn) {
+                if (btn === 'yes') {
+                    deleteWhLayout({ layoutCode: layoutCode }).then(function (res) {
+                        if (res.success) {
+                            msg$1(res.msg);
+                            _this.reload();
+                        }
+                    });
+                }
+            });
+        };
+        WhLayoutController.prototype.onDblClick = function () {
+            var _a;
+            //@ts-ignore
+            var view = this.getView();
+            var record = (_a = view.selection) === null || _a === void 0 ? void 0 : _a.data;
+            if (!record) {
+                msg$1('请选择一行数据');
+                return;
+            }
+            this.edit(record);
+        };
+        WhLayoutController.prototype.filterChanged = function (sender, value) {
+            //@ts-ignore
+            this.view.store.clearFilter();
+            if (value) {
+                //@ts-ignore
+                this.view.store.filterBy(function (record) {
+                    var widget_path = record.get('widget_path');
+                    var widget_name = record.get('widget_name');
+                    return (window['system'].pinyinMatch(widget_name, value) ||
+                        _$2.includes(_$2.toLower(widget_path), _$2.toLower(value)));
+                });
+            }
+        };
+        WhLayoutController.prototype.onClearClick = function () {
+            var _a, _b;
+            //@ts-ignore
+            (_b = (_a = this.getReferences()) === null || _a === void 0 ? void 0 : _a.txtFilter) === null || _b === void 0 ? void 0 : _b.setValue('');
         };
         return WhLayoutController;
     }());

تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 1 - 1
dist/yvan-ext.js.map