Procházet zdrojové kódy

Report 报表二开

luoyifan před 3 roky
rodič
revize
8c112a4392

+ 1 - 0
dist/index.d.ts

@@ -17,3 +17,4 @@ export * from './lib/lib';
 export * from './lib/config';
 export * from './lib/systemLib';
 export * from './ExcelImportDialog';
+export * from './report/Report';

+ 13 - 0
dist/report/Report.d.ts

@@ -0,0 +1,13 @@
+import { Scope } from "../Scope";
+export declare function buildReportScope(config: any, reportId: any, invokeServerFn: any, getDictFnName: any): ReportScope;
+export declare class ReportScope extends Scope {
+    report_id: string;
+    report: any;
+    invokeServerFn: any;
+    constructor({ model, vjson }: {
+        model: any;
+        vjson: any;
+    }, invokeServerFn: any);
+    onLoad(): void;
+    reload(): void;
+}

+ 251 - 0
dist/report/Report.js

@@ -0,0 +1,251 @@
+import { __assign, __extends, __read, __spread, __values } from "tslib";
+import { Scope } from "../Scope";
+import _ from 'lodash';
+import { invokeServer, showErrorDialog } from "../lib/systemLib";
+export function buildReportScope(config, reportId) {
+    var _a = buildVjson(config), model = _a.model, vjson = _a.vjson, report = _a.report;
+    var ret = new ReportScope({ model: model, vjson: vjson });
+    ret.report_id = reportId;
+    ret.report = report;
+    return ret;
+}
+function buildVjson(config) {
+    var e_1, _a, e_2, _b, e_3, _c;
+    var model = {
+        data: {
+            report_name: config.report_name,
+            query: {},
+            sum: {},
+        }
+    };
+    var report = config.report ? window['json5'].parse(config.report) : {};
+    var conditionRows = [];
+    var sumRows = [];
+    model.data.has_sum = _.size(report.summary) > 0;
+    // query 查询条件
+    var newRow = false;
+    var currentRow = { xtype: 'cols', items: [], };
+    conditionRows.push(currentRow);
+    try {
+        for (var _d = __values(report.query), _e = _d.next(); !_e.done; _e = _d.next()) {
+            var item = _e.value;
+            if (newRow) {
+                currentRow = { xtype: 'cols', items: [], };
+                conditionRows.push(currentRow);
+            }
+            var vj = window['json5'].parse(item.conditionFieldExtend);
+            if (item.conditionFieldXtype) {
+                vj.xtype = item.conditionFieldXtype;
+                if (item.conditionFieldXtype === 'combo') {
+                    vj.fix = ['system.getProjectDict("' + item.conditionFieldDict + '")'];
+                }
+            }
+            else {
+                // 没有组件类型,是个空占位符
+                vj.border = false;
+            }
+            if (item.conditionFieldBind) {
+                vj.bind = {
+                    value: '{query.' + item.conditionFieldBind + '}'
+                };
+                model.data.query[item.conditionFieldBind] = '';
+            }
+            if (item.conditionFieldFlex) {
+                vj.flex = item.conditionFieldFlex;
+            }
+            if (item.conditionFieldXtype) {
+                vj.fieldLabel = item.conditionFieldLabel;
+            }
+            if (item.fieldLabel) {
+                vj.fieldLabel = item.fieldLabel;
+            }
+            newRow = item.conditionFieldWrap || false;
+            currentRow.items.push(vj);
+        }
+    }
+    catch (e_1_1) { e_1 = { error: e_1_1 }; }
+    finally {
+        try {
+            if (_e && !_e.done && (_a = _d.return)) _a.call(_d);
+        }
+        finally { if (e_1) throw e_1.error; }
+    }
+    if (currentRow) {
+        currentRow.margin = '10 0 10 0';
+    }
+    // sum 汇总条件
+    newRow = true;
+    try {
+        for (var _f = __values(report.summary), _g = _f.next(); !_g.done; _g = _f.next()) {
+            var item = _g.value;
+            if (newRow) {
+                currentRow = {
+                    xtype: 'cols',
+                    defaultType: 'displayfield',
+                    defaults: {
+                        labelWidth: 70,
+                    },
+                    items: []
+                };
+                sumRows.push(currentRow);
+            }
+            var vj = __assign({}, window['json5'].parse(item.sumFieldExtend));
+            if (item.sumFieldBind) {
+                vj.bind = '{sum.' + item.sumFieldBind + '}';
+                model.data.sum[item.sumFieldBind] = '';
+            }
+            else {
+                // 没有组件类型,是个空占位符
+                vj.border = false;
+            }
+            if (item.sumFieldFlex) {
+                vj.flex = item.sumFieldFlex;
+            }
+            if (item.sumFieldLabel) {
+                vj.fieldLabel = item.sumFieldLabel;
+            }
+            // sumFieldBind: "zs"
+            // sumFieldExtend: "{}"
+            // sumFieldFlex: 1
+            // sumFieldLabel: "总数"
+            // sumFieldWrap: false
+            newRow = item.sumFieldWrap || false;
+            currentRow.items.push(vj);
+        }
+    }
+    catch (e_2_1) { e_2 = { error: e_2_1 }; }
+    finally {
+        try {
+            if (_g && !_g.done && (_b = _f.return)) _b.call(_f);
+        }
+        finally { if (e_2) throw e_2.error; }
+    }
+    if (currentRow) {
+        currentRow.margin = '10 0 10 0';
+    }
+    // column 结果字段
+    var columns = [];
+    try {
+        for (var _h = __values(report.columns), _j = _h.next(); !_j.done; _j = _h.next()) {
+            var item = _j.value;
+            var vj = __assign({ dataIndex: item.dataIndex, header: item.header, hidden: item.hidden, sortable: item.sortable, filterable: item.filterable }, window['json5'].parse(item.fieldExtend));
+            if (item.xtype) {
+                if (item.xtype == 'checkbox') {
+                    vj.xtype = 'checkcolumn';
+                    vj.disabled = true;
+                }
+                else {
+                    vj.xtype = item.xtype;
+                }
+            }
+            if (item.dataType) {
+                vj.dataType = item.dataType;
+            }
+            if (item.align) {
+                vj.align = item.align;
+            }
+            if (item.width) {
+                vj.width = item.width;
+            }
+            if (item.dict) {
+                vj.fix = ['system.getProjectDict("' + item.dict + '")'];
+            }
+            columns.push(vj);
+        }
+    }
+    catch (e_3_1) { e_3 = { error: e_3_1 }; }
+    finally {
+        try {
+            if (_j && !_j.done && (_c = _h.return)) _c.call(_h);
+        }
+        finally { if (e_3) throw e_3.error; }
+    }
+    var vjson = {
+        bind: {
+            title: '{report_name}',
+        },
+        layout: 'fit',
+        referenceHolder: true,
+        items: [
+            {
+                layout: 'border',
+                border: false,
+                items: [
+                    {
+                        region: 'north',
+                        border: false,
+                        tbar: {
+                            xtype: 'toolbar',
+                            border: false,
+                            items: [
+                                {
+                                    xtype: 'button',
+                                    text: '查询',
+                                    iconCls: 'x-fa fa-search',
+                                    listeners: {
+                                        click: 'scope.reload',
+                                    },
+                                },
+                                {
+                                    xtype: 'button',
+                                    text: '关闭',
+                                    iconCls: 'x-fa fa-times',
+                                    listeners: {
+                                        click: 'system.closeMe()',
+                                    },
+                                },
+                            ],
+                        },
+                        defaults: {
+                            margin: '8 0 0 0'
+                        },
+                        items: __spread(conditionRows, sumRows),
+                    },
+                    __assign({ region: 'center', xtype: 'yvgrid', reference: 'grid1', border: false, selModel: { selType: 'rowmodel', mode: 'SINGLE', }, autoLoad: false, dataSource: {
+                            method: 'invoke',
+                            url: '/report/Report@execute',
+                            params: {
+                                dataSource: report.dataSource,
+                                pagination: report.grid.pagination || true,
+                                report_id: config.report_id,
+                                query: '{query}',
+                            },
+                        }, columns: columns }, report.grid),
+                ],
+            },
+        ],
+    };
+    return { model: model, vjson: vjson, report: report };
+}
+var ReportScope = /** @class */ (function (_super) {
+    __extends(ReportScope, _super);
+    function ReportScope(_a) {
+        var model = _a.model, vjson = _a.vjson;
+        return _super.call(this, { model: model, vjson: vjson }) || this;
+    }
+    ReportScope.prototype.onLoad = function () {
+        this.reload();
+    };
+    ReportScope.prototype.reload = function () {
+        var _this = this;
+        // http://127.0.0.1:8095/api/com/galaxis/wms/report/Report@executeSum
+        if (this.viewModel.get('has_sum')) {
+            invokeServer('/report/Report@executeSum', {
+                dataSource: this.report.dataSource,
+                report_id: this.report_id,
+                query: this.viewModel.get('query'),
+            }).then(function (res) {
+                if (!res.success) {
+                    showErrorDialog(res.msg);
+                }
+                else {
+                    window['system'].mergeViewModel(_this.viewModel, 'sum', res.data, false);
+                }
+            });
+        }
+        this.refs.grid1.reload();
+    };
+    return ReportScope;
+}(Scope));
+export { ReportScope };
+//# sourceMappingURL=Report.js.map

Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 1 - 0
dist/report/Report.js.map


+ 14 - 6
dist/yvan-ext.css

@@ -1,12 +1,20 @@
-/* 表格内部的拖动条不可见 */
-.x-grid .x-splitter {
+/* 空表格文字 */
+.x-grid-scrollbar-clipper .x-grid-empty {
+    text-align: center;
+}
+.x-grid-scrollbar-clipper-locked .x-grid-empty {
     display: none;
 }
 
-.x-grid-locking-body .x-box-item.x-panel-default.x-grid {
-    left: 0 !important;
-    border-style: none;
-}
+/* 表格内部的拖动条不可见 */
+/*.x-grid .x-splitter {*/
+/*    display: none;*/
+/*}*/
+
+/*.x-grid-locking-body .x-box-item.x-panel-default.x-grid {*/
+/*    left: 0 !important;*/
+/*    border-style: none;*/
+/*}*/
 
 /* 对话框 警告和提示 */
 .x-dlg-icon.info {

+ 270 - 6
dist/yvan-ext.js

@@ -37782,6 +37782,18 @@ define(['exports'], function (exports) { 'use strict';
         if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
     }
 
+    function __values(o) {
+        var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
+        if (m) return m.call(o);
+        if (o && typeof o.length === "number") return {
+            next: function () {
+                if (o && i >= o.length) o = void 0;
+                return { value: o && o[i++], done: !o };
+            }
+        };
+        throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
+    }
+
     function __read(o, n) {
         var m = typeof Symbol === "function" && o[Symbol.iterator];
         if (!m) return o;
@@ -38313,7 +38325,7 @@ define(['exports'], function (exports) { 'use strict';
         for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);
     }
 
-    function __values(o) {
+    function __values$1(o) {
         var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
         if (m) return m.call(o);
         if (o && typeof o.length === "number") return {
@@ -38393,7 +38405,7 @@ define(['exports'], function (exports) { 'use strict';
     function __asyncValues(o) {
         if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
         var m = o[Symbol.asyncIterator], i;
-        return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
+        return m ? m.call(o) : (o = typeof __values$1 === "function" ? __values$1(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
         function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
         function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
     }
@@ -38445,7 +38457,7 @@ define(['exports'], function (exports) { 'use strict';
         __generator: __generator,
         __createBinding: __createBinding,
         __exportStar: __exportStar,
-        __values: __values,
+        __values: __values$1,
         __read: __read$1,
         __spread: __spread$1,
         __spreadArrays: __spreadArrays,
@@ -38587,7 +38599,7 @@ define(['exports'], function (exports) { 'use strict';
         for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding$1(o, m, p);
     }
 
-    function __values$1(o) {
+    function __values$2(o) {
         var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
         if (m) return m.call(o);
         if (o && typeof o.length === "number") return {
@@ -38667,7 +38679,7 @@ define(['exports'], function (exports) { 'use strict';
     function __asyncValues$1(o) {
         if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
         var m = o[Symbol.asyncIterator], i;
-        return m ? m.call(o) : (o = typeof __values$1 === "function" ? __values$1(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
+        return m ? m.call(o) : (o = typeof __values$2 === "function" ? __values$2(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
         function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
         function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
     }
@@ -38719,7 +38731,7 @@ define(['exports'], function (exports) { 'use strict';
         __generator: __generator$1,
         __createBinding: __createBinding$1,
         __exportStar: __exportStar$1,
-        __values: __values$1,
+        __values: __values$2,
         __read: __read$2,
         __spread: __spread$2,
         __spreadArrays: __spreadArrays$1,
@@ -96033,6 +96045,7 @@ define(['exports'], function (exports) { 'use strict';
         }
         // throw new TypeError('无法识别的调用方法')
     }
+    //# sourceMappingURL=grid.js.map
 
     function initTextfield () {
         var cc = Ext.form.field.Text.prototype.constructor;
@@ -131269,6 +131282,255 @@ define(['exports'], function (exports) { 'use strict';
     };
     //# sourceMappingURL=ExcelImportDialog.js.map
 
+    function buildReportScope(config, reportId, invokeServerFn, getDictFnName) {
+        var _a = buildVjson(config, invokeServerFn, getDictFnName), model = _a.model, vjson = _a.vjson, report = _a.report;
+        var ret = new ReportScope({ model: model, vjson: vjson }, invokeServerFn);
+        ret.report_id = reportId;
+        ret.report = report;
+        return ret;
+    }
+    function buildVjson(config, invokeServerFn, getDictFnName) {
+        var e_1, _a, e_2, _b, e_3, _c;
+        var model = {
+            data: {
+                report_name: config.report_name,
+                query: {},
+                sum: {},
+            }
+        };
+        var json5 = window['YvanUI'].json5;
+        var report = config.report ? json5.parse(config.report) : {};
+        var conditionRows = [];
+        var sumRows = [];
+        model.data.has_sum = lodash.size(report.summary) > 0;
+        // query 查询条件
+        var newRow = false;
+        var currentRow = { xtype: 'cols', items: [], };
+        conditionRows.push(currentRow);
+        try {
+            for (var _d = __values(report.query), _e = _d.next(); !_e.done; _e = _d.next()) {
+                var item = _e.value;
+                if (newRow) {
+                    currentRow = { xtype: 'cols', items: [], };
+                    conditionRows.push(currentRow);
+                }
+                var vj = json5.parse(item.conditionFieldExtend);
+                if (item.conditionFieldXtype) {
+                    vj.xtype = item.conditionFieldXtype;
+                    if (item.conditionFieldXtype === 'combo') {
+                        vj.fix = ['system.' + getDictFnName + '("' + item.conditionFieldDict + '")'];
+                    }
+                }
+                else {
+                    // 没有组件类型,是个空占位符
+                    vj.border = false;
+                }
+                if (item.conditionFieldBind) {
+                    vj.bind = {
+                        value: '{query.' + item.conditionFieldBind + '}'
+                    };
+                    model.data.query[item.conditionFieldBind] = '';
+                }
+                if (item.conditionFieldFlex) {
+                    vj.flex = item.conditionFieldFlex;
+                }
+                if (item.conditionFieldXtype) {
+                    vj.fieldLabel = item.conditionFieldLabel;
+                }
+                if (item.fieldLabel) {
+                    vj.fieldLabel = item.fieldLabel;
+                }
+                newRow = item.conditionFieldWrap || false;
+                currentRow.items.push(vj);
+            }
+        }
+        catch (e_1_1) { e_1 = { error: e_1_1 }; }
+        finally {
+            try {
+                if (_e && !_e.done && (_a = _d.return)) _a.call(_d);
+            }
+            finally { if (e_1) throw e_1.error; }
+        }
+        if (currentRow) {
+            currentRow.margin = '10 0 10 0';
+        }
+        // sum 汇总条件
+        newRow = true;
+        try {
+            for (var _f = __values(report.summary), _g = _f.next(); !_g.done; _g = _f.next()) {
+                var item = _g.value;
+                if (newRow) {
+                    currentRow = {
+                        xtype: 'cols',
+                        defaultType: 'displayfield',
+                        defaults: {
+                            labelWidth: 70,
+                        },
+                        items: []
+                    };
+                    sumRows.push(currentRow);
+                }
+                var vj = __assign({}, json5.parse(item.sumFieldExtend));
+                if (item.sumFieldBind) {
+                    vj.bind = '{sum.' + item.sumFieldBind + '}';
+                    model.data.sum[item.sumFieldBind] = '';
+                }
+                else {
+                    // 没有组件类型,是个空占位符
+                    vj.border = false;
+                }
+                if (item.sumFieldFlex) {
+                    vj.flex = item.sumFieldFlex;
+                }
+                if (item.sumFieldLabel) {
+                    vj.fieldLabel = item.sumFieldLabel;
+                }
+                // sumFieldBind: "zs"
+                // sumFieldExtend: "{}"
+                // sumFieldFlex: 1
+                // sumFieldLabel: "总数"
+                // sumFieldWrap: false
+                newRow = item.sumFieldWrap || false;
+                currentRow.items.push(vj);
+            }
+        }
+        catch (e_2_1) { e_2 = { error: e_2_1 }; }
+        finally {
+            try {
+                if (_g && !_g.done && (_b = _f.return)) _b.call(_f);
+            }
+            finally { if (e_2) throw e_2.error; }
+        }
+        if (currentRow) {
+            currentRow.margin = '10 0 10 0';
+        }
+        // column 结果字段
+        var columns = [];
+        try {
+            for (var _h = __values(report.columns), _j = _h.next(); !_j.done; _j = _h.next()) {
+                var item = _j.value;
+                var vj = __assign({ dataIndex: item.dataIndex, header: item.header, hidden: item.hidden, sortable: item.sortable, filterable: item.filterable }, json5.parse(item.fieldExtend));
+                if (item.xtype) {
+                    if (item.xtype == 'checkbox') {
+                        vj.xtype = 'checkcolumn';
+                        vj.disabled = true;
+                    }
+                    else {
+                        vj.xtype = item.xtype;
+                    }
+                }
+                if (item.dataType) {
+                    vj.dataType = item.dataType;
+                }
+                if (item.align) {
+                    vj.align = item.align;
+                }
+                if (item.width) {
+                    vj.width = item.width;
+                }
+                if (item.dict) {
+                    vj.fix = ['system.' + getDictFnName + '("' + item.dict + '")'];
+                }
+                columns.push(vj);
+            }
+        }
+        catch (e_3_1) { e_3 = { error: e_3_1 }; }
+        finally {
+            try {
+                if (_j && !_j.done && (_c = _h.return)) _c.call(_h);
+            }
+            finally { if (e_3) throw e_3.error; }
+        }
+        var vjson = {
+            bind: {
+                title: '{report_name}',
+            },
+            layout: 'fit',
+            referenceHolder: true,
+            items: [
+                {
+                    layout: 'border',
+                    border: false,
+                    items: [
+                        {
+                            region: 'north',
+                            border: false,
+                            tbar: {
+                                xtype: 'toolbar',
+                                border: false,
+                                items: [
+                                    {
+                                        xtype: 'button',
+                                        text: '查询',
+                                        iconCls: 'x-fa fa-search',
+                                        listeners: {
+                                            click: 'scope.reload',
+                                        },
+                                    },
+                                    {
+                                        xtype: 'button',
+                                        text: '关闭',
+                                        iconCls: 'x-fa fa-times',
+                                        listeners: {
+                                            click: 'system.closeMe()',
+                                        },
+                                    },
+                                ],
+                            },
+                            defaults: {
+                                margin: '8 0 0 0'
+                            },
+                            items: __spread(conditionRows, sumRows),
+                        },
+                        __assign({ region: 'center', xtype: 'yvgrid', reference: 'grid1', border: false, selModel: { selType: 'rowmodel', mode: 'SINGLE', }, autoLoad: false, dataSource: {
+                                method: 'invoke',
+                                url: '/report/Report@execute',
+                                params: {
+                                    dataSource: report.dataSource,
+                                    pagination: report.grid.pagination || true,
+                                    report_id: config.report_id,
+                                    query: '{query}',
+                                },
+                            }, columns: columns }, report.grid),
+                    ],
+                },
+            ],
+        };
+        return { model: model, vjson: vjson, report: report };
+    }
+    var ReportScope = /** @class */ (function (_super) {
+        __extends(ReportScope, _super);
+        function ReportScope(_a, invokeServerFn) {
+            var model = _a.model, vjson = _a.vjson;
+            var _this = _super.call(this, { model: model, vjson: vjson }) || this;
+            _this.invokeServerFn = invokeServerFn;
+            return _this;
+        }
+        ReportScope.prototype.onLoad = function () {
+            this.reload();
+        };
+        ReportScope.prototype.reload = function () {
+            var _this = this;
+            // http://127.0.0.1:8095/api/com/galaxis/wms/report/Report@executeSum
+            if (this.viewModel.get('has_sum')) {
+                this.invokeServerFn('/report/Report@executeSum', {
+                    dataSource: this.report.dataSource,
+                    report_id: this.report_id,
+                    query: this.viewModel.get('query'),
+                }).then(function (res) {
+                    if (!res.success) {
+                        showErrorDialog$1(res.msg);
+                    }
+                    else {
+                        window['system'].mergeViewModel(_this.viewModel, 'sum', res.data, false);
+                    }
+                });
+            }
+            this.refs.grid1.reload();
+        };
+        return ReportScope;
+    }(Scope));
+
     function initCombogrid () {
         Ext.define('Yvan.ComboGrid', {
             extend: 'Ext.form.field.Picker',
@@ -131998,6 +132260,7 @@ define(['exports'], function (exports) { 'use strict';
     exports.Lib = Lib;
     exports.LibParam = LibParam;
     exports.PropertyDescriptionTable = PropertyDescriptionTable;
+    exports.ReportScope = ReportScope;
     exports.SIMPLE_RE = SIMPLE_RE;
     exports.Scope = Scope;
     exports.SystemEventFu = SystemEventFu;
@@ -132005,6 +132268,7 @@ define(['exports'], function (exports) { 'use strict';
     exports.axios = index;
     exports.baseConfigProcess = baseConfigProcess;
     exports.baseConfigProcessList = baseConfigProcessList;
+    exports.buildReportScope = buildReportScope;
     exports.calcExpress = calcExpress;
     exports.calcObject = calcObject;
     exports.calcObjectFlat = calcObjectFlat;

Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 1 - 1
dist/yvan-ext.js.map