123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251 |
- 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
|