|
@@ -1,4 +1,4 @@
|
|
|
-define(['exports', 'sql-formatter'], function (exports, sqlFormatter) { 'use strict';
|
|
|
+define(['exports', 'node-sql-parser', 'sql-formatter'], function (exports, nodeSqlParser, sqlFormatter) { 'use strict';
|
|
|
|
|
|
var labelWidth = 80;
|
|
|
var windows = {
|
|
@@ -13,6 +13,19 @@ define(['exports', 'sql-formatter'], function (exports, sqlFormatter) { 'use str
|
|
|
labelAlign: 'right',
|
|
|
labelWidth: labelWidth,
|
|
|
};
|
|
|
+ var tagfield = {
|
|
|
+ labelAlign: 'right',
|
|
|
+ labelWidth: labelWidth,
|
|
|
+ valueField: 'id',
|
|
|
+ displayField: 'text',
|
|
|
+ autoLoad: true,
|
|
|
+ mode: 'local',
|
|
|
+ forceSelection: true,
|
|
|
+ triggerAction: 'all',
|
|
|
+ enableKeyEvents: true,
|
|
|
+ queryMode: 'local',
|
|
|
+ filterPickList: true,
|
|
|
+ };
|
|
|
var combo = {
|
|
|
labelAlign: 'right',
|
|
|
labelWidth: labelWidth,
|
|
@@ -155,6 +168,8 @@ define(['exports', 'sql-formatter'], function (exports, sqlFormatter) { 'use str
|
|
|
hideRefresh: false,
|
|
|
hideExpand: false,
|
|
|
hideCollapse: false,
|
|
|
+ root: [],
|
|
|
+ rootVisible: false,
|
|
|
};
|
|
|
var search = {
|
|
|
labelAlign: 'right',
|
|
@@ -203,6 +218,7 @@ define(['exports', 'sql-formatter'], function (exports, sqlFormatter) { 'use str
|
|
|
__proto__: null,
|
|
|
windows: windows,
|
|
|
date: date,
|
|
|
+ tagfield: tagfield,
|
|
|
combo: combo,
|
|
|
comboGrid: comboGrid,
|
|
|
comboGridPicker: comboGridPicker,
|
|
@@ -62936,7 +62952,7 @@ define(['exports', 'sql-formatter'], function (exports, sqlFormatter) { 'use str
|
|
|
});
|
|
|
return;
|
|
|
}
|
|
|
- else if (sender.$className === 'Ext.form.field.ComboBox') {
|
|
|
+ else if (sender.$className === 'Ext.form.field.ComboBox' || sender.$className === 'Ext.form.field.Tag') {
|
|
|
getDictFn(bizKey, function (r) {
|
|
|
var _a, _b;
|
|
|
if (sender.store) {
|
|
@@ -64099,6 +64115,7 @@ define(['exports', 'sql-formatter'], function (exports, sqlFormatter) { 'use str
|
|
|
function getGridEditRows(grid) {
|
|
|
return grid.getGridEditRows();
|
|
|
}
|
|
|
+ //# sourceMappingURL=systemLib.js.map
|
|
|
|
|
|
var SystemLib = /*#__PURE__*/Object.freeze({
|
|
|
__proto__: null,
|
|
@@ -64151,8 +64168,6 @@ define(['exports', 'sql-formatter'], function (exports, sqlFormatter) { 'use str
|
|
|
// 强制性属性
|
|
|
}, baseConfig(config, 'row-item'), config, tree);
|
|
|
lodash.assign(newConfig, {
|
|
|
- root: [],
|
|
|
- rootVisible: false,
|
|
|
tbar: [
|
|
|
{
|
|
|
xtype: 'trigger',
|
|
@@ -96421,6 +96436,13 @@ define(['exports', 'sql-formatter'], function (exports, sqlFormatter) { 'use str
|
|
|
return;
|
|
|
}
|
|
|
var record = grid.selection;
|
|
|
+ if (lodash.isArray(record)) {
|
|
|
+ record = record[0];
|
|
|
+ }
|
|
|
+ if (!record) {
|
|
|
+ msg('无法对多行进行移动');
|
|
|
+ return;
|
|
|
+ }
|
|
|
// const records = grid.selModel.getSelection()
|
|
|
// if (records.length !== 1) {
|
|
|
// msg('无法对多行进行移动')
|
|
@@ -96448,6 +96470,13 @@ define(['exports', 'sql-formatter'], function (exports, sqlFormatter) { 'use str
|
|
|
return;
|
|
|
}
|
|
|
var record = grid.selection;
|
|
|
+ if (lodash.isArray(record)) {
|
|
|
+ record = record[0];
|
|
|
+ }
|
|
|
+ if (!record) {
|
|
|
+ msg('无法对多行进行移动');
|
|
|
+ return;
|
|
|
+ }
|
|
|
var index = grid.store.indexOf(record);
|
|
|
if (index < grid.store.getCount() - 1) {
|
|
|
grid.store.removeAt(index);
|
|
@@ -131766,6 +131795,151 @@ define(['exports', 'sql-formatter'], function (exports, sqlFormatter) { 'use str
|
|
|
}
|
|
|
//# sourceMappingURL=combo.js.map
|
|
|
|
|
|
+ /**
|
|
|
+ xtype: 'tagfield',
|
|
|
+ displayField: 'show',
|
|
|
+ valueField: 'id',
|
|
|
+ queryMode: 'local',
|
|
|
+ filterPickList: true,
|
|
|
+ store: {
|
|
|
+ fields: ['id', 'show'],
|
|
|
+ data: [
|
|
|
+ {id: 0, show: 'Battlestar Galactica'},
|
|
|
+ {id: 1, show: 'Doctor Who'},
|
|
|
+ {id: 2, show: 'Farscape'},
|
|
|
+ {id: 3, show: 'Firefly'},
|
|
|
+ {id: 4, show: 'Star Trek'},
|
|
|
+ {id: 5, show: 'Star Wars: Christmas Special'}
|
|
|
+ ]
|
|
|
+ }
|
|
|
+ */
|
|
|
+ function initTag () {
|
|
|
+ var cc = Ext.form.field.Tag.prototype.constructor;
|
|
|
+ var _a = Ext.form.field.Tag.prototype, initComponent = _a.initComponent, setData = _a.setData, setStore = _a.setStore;
|
|
|
+ Ext.form.field.Tag.override({
|
|
|
+ constructor: function (config) {
|
|
|
+ var newConfig = lodash.defaultsDeep({
|
|
|
+ // 强制性属性
|
|
|
+ }, baseConfig(config, 'col-item'), config, tagfield);
|
|
|
+ if (typeof config.dict === 'string') {
|
|
|
+ window['yvanLib'].system.getDict(config.dict)(this, newConfig);
|
|
|
+ }
|
|
|
+ else if (typeof newConfig.store == 'undefined') {
|
|
|
+ if (lodash.isArray(newConfig.data)) {
|
|
|
+ // ExtJS 无法直接接受数组模式
|
|
|
+ newConfig.store = {
|
|
|
+ fields: [newConfig.valueField, newConfig.displayField],
|
|
|
+ data: newConfig.data
|
|
|
+ };
|
|
|
+ delete newConfig.data;
|
|
|
+ }
|
|
|
+ else if (typeof newConfig.data !== 'object') {
|
|
|
+ newConfig.store = {
|
|
|
+ fields: [newConfig.valueField, newConfig.displayField],
|
|
|
+ data: []
|
|
|
+ };
|
|
|
+ delete newConfig.data;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ cc.call(this, newConfig);
|
|
|
+ },
|
|
|
+ setDict: function (bizKey) {
|
|
|
+ window['yvanLib'].system.getDict(bizKey)(this, this.config);
|
|
|
+ this.dict = bizKey;
|
|
|
+ },
|
|
|
+ getDict: function () {
|
|
|
+ return this.dict;
|
|
|
+ },
|
|
|
+ setData: function (value) {
|
|
|
+ if (!value) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ var config = value.config;
|
|
|
+ if (!this.store) {
|
|
|
+ this.store = new Ext.data.Store({
|
|
|
+ fields: [config.valueField, config.displayField],
|
|
|
+ data: value
|
|
|
+ });
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ this.store.getProxy().setData(value);
|
|
|
+ this.store.load();
|
|
|
+ }
|
|
|
+ },
|
|
|
+ setLoading: function (value) {
|
|
|
+ if (value) {
|
|
|
+ if (!this.loadMask) {
|
|
|
+ this.loadMask = new Ext.LoadMask(this, { msg: "loading..." });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ if (this.loadMask) {
|
|
|
+ this.loadMask.destroy();
|
|
|
+ delete this.loadMask;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ reload: function () {
|
|
|
+ dataSourceReload(this);
|
|
|
+ },
|
|
|
+ initComponent: function () {
|
|
|
+ var that = this;
|
|
|
+ var toggle = function (e) {
|
|
|
+ var readOnly = that.readOnly, disabled = that.disabled;
|
|
|
+ if (readOnly || disabled) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if ($(e.target).is('.x-form-trigger')) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ // 点击后下拉
|
|
|
+ if (that.isExpanded) {
|
|
|
+ that.collapse();
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ that.expand();
|
|
|
+ that.doQuery(that.allQuery, true);
|
|
|
+ }
|
|
|
+ };
|
|
|
+ this.on({
|
|
|
+ afterrender: function (sender) {
|
|
|
+ var config = this.config;
|
|
|
+ if (config.dataSource && config.autoLoad) {
|
|
|
+ dataSourceReload(this);
|
|
|
+ }
|
|
|
+ // 点击后下拉
|
|
|
+ $(this.el.dom).on('click', toggle.bind(this));
|
|
|
+ },
|
|
|
+ focusenter: function (sender, event, opt) {
|
|
|
+ var _a;
|
|
|
+ if (((_a = sender.ownerCt) === null || _a === void 0 ? void 0 : _a.xtype) === 'celleditor') {
|
|
|
+ // 表格内编辑框,获取焦点后自动弹开
|
|
|
+ toggle.call(this, event);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ destory: function () {
|
|
|
+ $(this.el.dom).off('click', toggle.bind(this));
|
|
|
+ },
|
|
|
+ });
|
|
|
+ initComponent.call(this);
|
|
|
+ },
|
|
|
+ focus2: function () {
|
|
|
+ this.focus();
|
|
|
+ var that = this;
|
|
|
+ lodash.defer(function () {
|
|
|
+ if (that.isExpanded) {
|
|
|
+ that.collapse();
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ that.expand();
|
|
|
+ that.doQuery(that.allQuery, true);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ //# sourceMappingURL=tagfield.js.map
|
|
|
+
|
|
|
function initComboGridMulti () {
|
|
|
Ext.define('Yvan.LocalComboGrid', {
|
|
|
extend: 'Ext.form.field.Picker',
|
|
@@ -133717,6 +133891,485 @@ define(['exports', 'sql-formatter'], function (exports, sqlFormatter) { 'use str
|
|
|
}
|
|
|
//# sourceMappingURL=bpmn.js.map
|
|
|
|
|
|
+ function initSqlComplex () {
|
|
|
+ Ext.define('Yvan.SqlComplex', {
|
|
|
+ extend: 'Ext.panel.Panel',
|
|
|
+ xtype: 'sqlcomplex',
|
|
|
+ alias: 'widget.sqlcomplex',
|
|
|
+ getSqlExpress: function () {
|
|
|
+ },
|
|
|
+ constructor: function (config) {
|
|
|
+ var reference = config.reference;
|
|
|
+ var me = this;
|
|
|
+ var newConfig = __assign(__assign({}, config), { layout: 'border', items: [
|
|
|
+ {
|
|
|
+ region: 'west',
|
|
|
+ width: 280,
|
|
|
+ border: false,
|
|
|
+ split: true,
|
|
|
+ reference: reference + '_tree',
|
|
|
+ xtype: 'yvtree',
|
|
|
+ hideRefresh: true,
|
|
|
+ hideExpand: true,
|
|
|
+ hideCollapse: true,
|
|
|
+ listeners: {
|
|
|
+ itemdblclick: function (sender, record, item, index, e) {
|
|
|
+ var field = record.get('field');
|
|
|
+ var defaultValue = record.get('defaultValue');
|
|
|
+ if (!field) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ var tabExpress = me.down('tabpanel');
|
|
|
+ var sqleditor = me.down('sqleditor');
|
|
|
+ var expressGrid = me.down('yvgrid');
|
|
|
+ if (tabExpress.getActiveTab().key !== 'grid') {
|
|
|
+ // SQL 模式
|
|
|
+ sqleditor.insertText(field + '=');
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ // 表格模式
|
|
|
+ expressGrid.appendEditRow({
|
|
|
+ field: field,
|
|
|
+ operator: '=',
|
|
|
+ value: defaultValue,
|
|
|
+ remark: '',
|
|
|
+ });
|
|
|
+ lodash.defer(function () {
|
|
|
+ gridChanged(me, expressGrid);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ },
|
|
|
+ {
|
|
|
+ region: 'center',
|
|
|
+ xtype: 'tabpanel',
|
|
|
+ reference: reference + '_tab',
|
|
|
+ tabPosition: 'bottom',
|
|
|
+ listeners: {
|
|
|
+ afterrender: function (sender) {
|
|
|
+ var scope = lookupScope(me);
|
|
|
+ var value = scope.viewModel.get(me.config.bindValue);
|
|
|
+ // sql 转换为 grid
|
|
|
+ try {
|
|
|
+ var list_1 = parseSqlToGrid(value);
|
|
|
+ lodash.defer(function () {
|
|
|
+ var grid = me.down('yvgrid');
|
|
|
+ grid.setData(list_1);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ catch (e) {
|
|
|
+ console.error(e);
|
|
|
+ msg$1('无法解析SQL语法! 目前只能以 SQL 模式打开,如果在表格中做修改,将会覆盖原语句!');
|
|
|
+ var tabSql = sender.down('sqleditor');
|
|
|
+ sender.setActiveTab(tabSql);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ beforetabchange: function (sender, newCard, oldCard, eOpts) {
|
|
|
+ var scope = lookupScope(me);
|
|
|
+ var value = scope.viewModel.get(me.config.bindValue);
|
|
|
+ if (newCard.key === 'grid') {
|
|
|
+ // sql 转换为 grid
|
|
|
+ try {
|
|
|
+ var list_2 = parseSqlToGrid(value);
|
|
|
+ lodash.defer(function () {
|
|
|
+ var grid = me.down('yvgrid');
|
|
|
+ grid.setData(list_2);
|
|
|
+ });
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ catch (e) {
|
|
|
+ msg$1('无法解析 SQL 语法! 表格模式只适用于简单语法');
|
|
|
+ console.error(e);
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if (newCard.key === 'sql') {
|
|
|
+ // grid 转换为 sql
|
|
|
+ lodash.defer(function () {
|
|
|
+ var editor = me.down('sqleditor');
|
|
|
+ editor.setValue(value);
|
|
|
+ });
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ items: [
|
|
|
+ {
|
|
|
+ title: '表格模式',
|
|
|
+ key: 'grid',
|
|
|
+ xtype: 'yvgrid',
|
|
|
+ _mode: 'select',
|
|
|
+ reference: reference + '_grid',
|
|
|
+ hideFootbar: true,
|
|
|
+ pagination: false,
|
|
|
+ tbar: [
|
|
|
+ {
|
|
|
+ xtype: 'button',
|
|
|
+ text: '删除',
|
|
|
+ iconCls: 'x-fa fa-minus-circle',
|
|
|
+ cls: 'ext-btn-danger',
|
|
|
+ bind: {
|
|
|
+ disabled: '{!' + reference + '_grid.selection}',
|
|
|
+ },
|
|
|
+ listeners: {
|
|
|
+ click: function (sender) {
|
|
|
+ var grid = sender.up('yvgrid');
|
|
|
+ removeGridRow(grid);
|
|
|
+ gridChanged(me, grid);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ store: {},
|
|
|
+ listeners: {
|
|
|
+ editfinish: function (sender) {
|
|
|
+ gridChanged(me, sender);
|
|
|
+ },
|
|
|
+ },
|
|
|
+ columns: [
|
|
|
+ {
|
|
|
+ dataIndex: 'field',
|
|
|
+ header: '字段', sortable: false, menuDisabled: true,
|
|
|
+ width: 190,
|
|
|
+ renderer: function (value, context, record, rowIdx, colIdx, store, view) {
|
|
|
+ var column = context.column;
|
|
|
+ var propertyConfig = me.config.propertyConfig;
|
|
|
+ // 找到 propertyConfig 对应 propertyName 名称的 dict 字典的 dict.text 值
|
|
|
+ var field = record.get('field');
|
|
|
+ if (field) {
|
|
|
+ var idx = lodash.findIndex(propertyConfig, function (p) { return p.field === field; });
|
|
|
+ if (idx >= 0) {
|
|
|
+ var meta = propertyConfig[idx];
|
|
|
+ return meta.text;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return value;
|
|
|
+ }
|
|
|
+ },
|
|
|
+ {
|
|
|
+ dataIndex: 'operator',
|
|
|
+ header: '运算符', sortable: false, menuDisabled: true,
|
|
|
+ dict: 'operator',
|
|
|
+ width: 65,
|
|
|
+ editor: { xtype: 'combo' },
|
|
|
+ },
|
|
|
+ {
|
|
|
+ dataIndex: 'value',
|
|
|
+ header: '值', sortable: false, menuDisabled: true,
|
|
|
+ flex: 1,
|
|
|
+ getEditor: function (record) {
|
|
|
+ var column = this;
|
|
|
+ var grid = lodash.get(column, 'ownerCt.grid.ownerGrid');
|
|
|
+ var propertyConfig = me.config.propertyConfig;
|
|
|
+ var field = record.get('field');
|
|
|
+ if (!field) {
|
|
|
+ // 没有填 propertyName
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ var idx = lodash.findIndex(propertyConfig, function (p) { return p.field === field; });
|
|
|
+ if (idx < 0) {
|
|
|
+ console.error('没有找到 field=' + field + ". propertyConfig");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ var meta = propertyConfig[idx];
|
|
|
+ if ((record.get('operator') === 'in' || record.get('operator') === 'notIn') && meta.editor.xtype === 'combo') {
|
|
|
+ return new Ext.grid.CellEditor({
|
|
|
+ field: __assign(__assign({ dict: meta.dict }, meta.editor), { xtype: 'tagfield' })
|
|
|
+ });
|
|
|
+ }
|
|
|
+ return new Ext.grid.CellEditor({
|
|
|
+ field: __assign({ dict: meta.dict }, meta.editor)
|
|
|
+ });
|
|
|
+ },
|
|
|
+ renderer: function (valueList, context, record, rowIdx, colIdx, store, view) {
|
|
|
+ var column = context.column;
|
|
|
+ var grid = lodash.get(view, 'ownerGrid');
|
|
|
+ var propertyConfig = me.config.propertyConfig;
|
|
|
+ // 找到 propertyConfig 对应 propertyName 名称的 dict 字典的 dict.text 值
|
|
|
+ var field = record.get('field');
|
|
|
+ if (field) {
|
|
|
+ var idx = lodash.findIndex(propertyConfig, function (p) { return (p.field) === field; });
|
|
|
+ if (idx >= 0) {
|
|
|
+ var meta = propertyConfig[idx];
|
|
|
+ var dictName = lodash.get(meta, 'dict');
|
|
|
+ if (dictName && window['DICT_CACHE'][dictName]) {
|
|
|
+ var dict_1 = window['DICT_CACHE'][dictName];
|
|
|
+ var valueText_1 = [];
|
|
|
+ lodash.forEach(lodash.split(valueList, ','), function (value) {
|
|
|
+ var idxKv = lodash.findIndex(dict_1, function (kv) { return lodash.toString(kv.id) === lodash.toString(value); });
|
|
|
+ if (idxKv >= 0) {
|
|
|
+ valueText_1.push(dict_1[idxKv].text);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ valueText_1.push(value);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ return valueText_1.join(',');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return valueList;
|
|
|
+ },
|
|
|
+ },
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: 'SQL模式',
|
|
|
+ key: 'sql',
|
|
|
+ xtype: 'sqleditor',
|
|
|
+ reference: reference + '_sql',
|
|
|
+ listeners: {
|
|
|
+ change: function (sender) {
|
|
|
+ var scope = lookupScope(me);
|
|
|
+ // 保存 editor 写入的值
|
|
|
+ scope.viewModel.set(me.config.bindValue, sender.getValue());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ ]
|
|
|
+ }
|
|
|
+ ] });
|
|
|
+ this.superclass.constructor.call(this, newConfig);
|
|
|
+ },
|
|
|
+ initComponent: function () {
|
|
|
+ // 货位条件树
|
|
|
+ var me = this;
|
|
|
+ me.superclass.initComponent.apply(this, arguments);
|
|
|
+ var tree = this.down('yvtree');
|
|
|
+ var config = me.config;
|
|
|
+ tree.setRootNode(buildConfigTree(config.propertyConfig));
|
|
|
+ },
|
|
|
+ });
|
|
|
+ function gridChanged(me, grid) {
|
|
|
+ var data = grid.getDataRows();
|
|
|
+ var propertyConfig = me.config.propertyConfig;
|
|
|
+ var bindValue = me.config.bindValue;
|
|
|
+ var scope = lookupScope(me);
|
|
|
+ var sql = parseGridToSql(data);
|
|
|
+ scope.viewModel.set(bindValue, sql);
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 用于从 propertyConfig 解析出树形结构
|
|
|
+ * { text: '库别分类', field: 'loc_classify', operator: '=', category: '库位属性', editor: {xtype: 'combo'}, dict: 'AREA_CLASSIFY', },
|
|
|
+ * ->
|
|
|
+ * {text: '库别分类', field: 'loc_classify', operator: '=', leaf: true},
|
|
|
+ */
|
|
|
+ function buildConfigTree(propertyConfig) {
|
|
|
+ var root = {
|
|
|
+ expanded: true,
|
|
|
+ leaf: false,
|
|
|
+ children: []
|
|
|
+ };
|
|
|
+ var categoryObj = {};
|
|
|
+ var cfgList = propertyConfig;
|
|
|
+ lodash.forEach(cfgList, function (cfg) {
|
|
|
+ var cateNode = categoryObj[cfg.category];
|
|
|
+ if (!cateNode) {
|
|
|
+ cateNode = {
|
|
|
+ text: cfg.category, expanded: true, leaf: false,
|
|
|
+ children: []
|
|
|
+ };
|
|
|
+ categoryObj[cfg.category] = cateNode;
|
|
|
+ root.children.push(cateNode);
|
|
|
+ }
|
|
|
+ cateNode.children.push({
|
|
|
+ text: cfg.text,
|
|
|
+ field: cfg.field,
|
|
|
+ operator: cfg.operator,
|
|
|
+ defaultValue: cfg.defaultValue,
|
|
|
+ leaf: true,
|
|
|
+ });
|
|
|
+ });
|
|
|
+ return root;
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 将表格变成 SQL where语句 [
|
|
|
+ * {field: 'f1', value: 1, operator: '='}
|
|
|
+ * {field: 'f2', value: 2, operator: '='}
|
|
|
+ * {field: 'f3', value: '3', operator: '>='}
|
|
|
+ * {field: 'f4', value: 4, operator: '='}
|
|
|
+ * ]
|
|
|
+ * ->
|
|
|
+ * f1=v1 and f2=v2
|
|
|
+ */
|
|
|
+ function parseGridToSql(list) {
|
|
|
+ var sqls = [];
|
|
|
+ lodash.forEach(list, function (i) {
|
|
|
+ var _a;
|
|
|
+ if (i.operator === 'in') {
|
|
|
+ sqls.push(i.field + ' in (' + (i.value) + ')');
|
|
|
+ }
|
|
|
+ else if (i.operator === 'notIn') {
|
|
|
+ sqls.push(i.field + ' not in (' + (i.value) + ')');
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ sqls.push(i.field + ' ' + i.operator + ' ' + ((_a = i.value) !== null && _a !== void 0 ? _a : 0));
|
|
|
+ }
|
|
|
+ });
|
|
|
+ return sqls.join(' AND ');
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 将 SQL 语句的 where 片段变成表格
|
|
|
+ * @param sql f1=1 and f2=2 and f3>="3" and f4=4
|
|
|
+ * @return [
|
|
|
+ {field: 'f1', value: 1, operator: '='}
|
|
|
+ {field: 'f2', value: 2, operator: '='}
|
|
|
+ {field: 'f3', value: '3', operator: '>='}
|
|
|
+ {field: 'f4', value: 4, operator: '='}
|
|
|
+ ]
|
|
|
+ */
|
|
|
+ function parseSqlToGrid(sql) {
|
|
|
+ if (!sql || !lodash.trim(sql)) {
|
|
|
+ return [];
|
|
|
+ }
|
|
|
+ var parser = new window['NodeSQLParser'].Parser();
|
|
|
+ var ast = parser.astify('select * from dual where ' + sql);
|
|
|
+ var ret = [];
|
|
|
+ exp(ast.where, ret);
|
|
|
+ return ret;
|
|
|
+ }
|
|
|
+ function exp(ast, ret) {
|
|
|
+ if (ast.type === 'binary_expr') {
|
|
|
+ if (lodash.toUpper(ast.operator) === 'AND') {
|
|
|
+ if (ast.left.type === 'binary_expr') {
|
|
|
+ exp(ast.left, ret);
|
|
|
+ }
|
|
|
+ if (ast.right.type === 'binary_expr') {
|
|
|
+ exp(ast.right, ret);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if (['=', '>=', '>', '<=', '<', 'IN', 'NOT IN'].includes(lodash.toUpper(ast.operator))) {
|
|
|
+ if (ast.left.type === 'column_ref') {
|
|
|
+ if (ast.right.type === 'number' ||
|
|
|
+ ast.right.type === 'single_quote_string' ||
|
|
|
+ ast.right.type === 'double_quote_string') {
|
|
|
+ // 具体值相等
|
|
|
+ ret.push({ field: ast.left.column, value: ast.right.value, operator: ast.operator });
|
|
|
+ }
|
|
|
+ else if ((lodash.toUpper(ast.operator) === 'IN' || lodash.toUpper(ast.operator) === 'NOT IN')
|
|
|
+ && ast.right.type === 'expr_list') {
|
|
|
+ // in / not in
|
|
|
+ var valueList_1 = [];
|
|
|
+ lodash.forEach(ast.right.value, function (item) {
|
|
|
+ valueList_1.push(item.value);
|
|
|
+ });
|
|
|
+ var operator = void 0;
|
|
|
+ if (lodash.toUpper(ast.operator) === 'IN') {
|
|
|
+ operator = 'in';
|
|
|
+ }
|
|
|
+ else if (lodash.toUpper(ast.operator) === 'NOT IN') {
|
|
|
+ operator = 'notIn';
|
|
|
+ }
|
|
|
+ ret.push({
|
|
|
+ field: ast.left.column, value: valueList_1.join(','),
|
|
|
+ operator: operator
|
|
|
+ });
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ throw new Error('ast.right must is value.');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ throw new Error('ast.left must is column_ref.');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ // 必须用 AND 条件符匹配
|
|
|
+ throw new Error('ast.operator must is "AND / =".');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ throw new Error('ast.type must is "binary_expr".');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * json5.stringify( new NodeSQLParser.Parser().astify("").where)
|
|
|
+ * select * from aa where f1=1 and f2=2 and f3='3' and f4>=4 and f4<3
|
|
|
+ {
|
|
|
+ type: 'binary_expr',
|
|
|
+ operator: 'AND',
|
|
|
+ left: {
|
|
|
+ type: 'binary_expr',
|
|
|
+ operator: 'AND',
|
|
|
+ left: {
|
|
|
+ type: 'binary_expr',
|
|
|
+ operator: 'AND',
|
|
|
+ left: {
|
|
|
+ type: 'binary_expr',
|
|
|
+ operator: 'AND',
|
|
|
+ left: {
|
|
|
+ type: 'binary_expr',
|
|
|
+ operator: '=',
|
|
|
+ left: {
|
|
|
+ type: 'column_ref',
|
|
|
+ table: null,
|
|
|
+ column: 'f1'
|
|
|
+ },
|
|
|
+ right: {
|
|
|
+ type: 'number',
|
|
|
+ value: 1
|
|
|
+ }
|
|
|
+ },
|
|
|
+ right: {
|
|
|
+ type: 'binary_expr',
|
|
|
+ operator: '=',
|
|
|
+ left: {
|
|
|
+ type: 'column_ref',
|
|
|
+ table: null,
|
|
|
+ column: 'f2'
|
|
|
+ },
|
|
|
+ right: {
|
|
|
+ type: 'number',
|
|
|
+ value: 2
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ right: {
|
|
|
+ type: 'binary_expr',
|
|
|
+ operator: '=',
|
|
|
+ left: {
|
|
|
+ type: 'column_ref',
|
|
|
+ table: null,
|
|
|
+ column: 'f3'
|
|
|
+ },
|
|
|
+ right: {
|
|
|
+ type: 'single_quote_string',
|
|
|
+ value: '3'
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ right: {
|
|
|
+ type: 'binary_expr',
|
|
|
+ operator: '>=',
|
|
|
+ left: {
|
|
|
+ type: 'column_ref',
|
|
|
+ table: null,
|
|
|
+ column: 'f4'
|
|
|
+ },
|
|
|
+ right: {
|
|
|
+ type: 'number',
|
|
|
+ value: 4
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ right: {
|
|
|
+ type: 'binary_expr',
|
|
|
+ operator: '<',
|
|
|
+ left: {
|
|
|
+ type: 'column_ref',
|
|
|
+ table: null,
|
|
|
+ column: 'f4'
|
|
|
+ },
|
|
|
+ right: {
|
|
|
+ type: 'number',
|
|
|
+ value: 3
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ * */
|
|
|
+ }
|
|
|
+
|
|
|
function initSqlEditor () {
|
|
|
Ext.define('com.yvan.studio.SqlEditor', {
|
|
|
extend: 'Ext.panel.Panel',
|
|
@@ -134087,6 +134740,7 @@ define(['exports', 'sql-formatter'], function (exports, sqlFormatter) { 'use str
|
|
|
initMainTab();
|
|
|
initTextfield();
|
|
|
initCombo();
|
|
|
+ initTag();
|
|
|
initRows();
|
|
|
initCols();
|
|
|
initForm();
|
|
@@ -134112,8 +134766,8 @@ define(['exports', 'sql-formatter'], function (exports, sqlFormatter) { 'use str
|
|
|
initIframe();
|
|
|
initBpmn();
|
|
|
initSqlEditor();
|
|
|
+ initSqlComplex();
|
|
|
}
|
|
|
- //# sourceMappingURL=init.js.map
|
|
|
|
|
|
exports.Defaults = Defaults;
|
|
|
exports.ExcelImportDialog = ExcelImportDialog;
|