Parcourir la source

yvan-ext-mobile 打包上传到npm

lizw il y a 3 ans
Parent
commit
5ed2986135
52 fichiers modifiés avec 41664 ajouts et 7759 suppressions
  1. 0 1
      .gitignore
  2. 8 0
      .npmignore
  3. 0 72
      build/rollup.amd.js
  4. 0 44
      build/rollup.config.js
  5. 0 64
      build/rollup.iife.js
  6. 0 79
      build/rollup.ugfi.js
  7. 187 0
      dist/Defaults.d.ts
  8. 54 0
      dist/PropertyDescription.d.ts
  9. 27 0
      dist/PropertyDescriptionTable.d.ts
  10. 104 0
      dist/Scope.d.ts
  11. 13 0
      dist/controls/base.d.ts
  12. 1 0
      dist/controls/cols.d.ts
  13. 1 0
      dist/controls/grid.d.ts
  14. 1 0
      dist/controls/gridcolumn.d.ts
  15. 5 0
      dist/controls/stores.d.ts
  16. 15 0
      dist/index.d.ts
  17. 3 0
      dist/init.d.ts
  18. 59 0
      dist/lib/ajax.d.ts
  19. 80 0
      dist/lib/config.d.ts
  20. 1 0
      dist/lib/fix.d.ts
  21. 31 0
      dist/lib/lib.d.ts
  22. 1 0
      dist/lib/locale-zh_CN.d.ts
  23. 255 0
      dist/lib/systemLib.d.ts
  24. 4 0
      dist/lib/systemLibEval.d.ts
  25. 14 0
      dist/message.d.ts
  26. 24 41
      src/types.ts
  27. 0 0
      dist/yvan-ext-mobile.css
  28. 40774 0
      dist/yvan-ext-mobile.js
  29. 1 0
      dist/yvan-ext-mobile.js.map
  30. 1 38
      package.json
  31. 0 0
      rollup.build.css
  32. 0 221
      src/Defaults.ts
  33. 0 106
      src/PropertyDescription.ts
  34. 0 507
      src/PropertyDescriptionTable.ts
  35. 0 314
      src/Scope.ts
  36. 0 55
      src/controls/base.ts
  37. 0 24
      src/controls/cols.js
  38. 0 460
      src/controls/grid.js
  39. 0 37
      src/controls/gridcolumn.js
  40. 0 143
      src/controls/stores.js
  41. 0 13
      src/global.d.ts
  42. 0 23
      src/index.ts
  43. 0 96
      src/init.ts
  44. 0 284
      src/lib/ajax.ts
  45. 0 177
      src/lib/config.ts
  46. 0 39
      src/lib/fix.js
  47. 0 155
      src/lib/lib.ts
  48. 0 49
      src/lib/locale-zh_CN.js
  49. 0 1196
      src/lib/systemLib.ts
  50. 0 21
      src/lib/systemLibEval.js
  51. 0 116
      src/message.ts
  52. 0 3384
      yarn.lock

+ 0 - 1
.gitignore

@@ -1,6 +1,5 @@
 .DS_Store
 /node_modules
-/dist
 
 # local env files
 .env.local

+ 8 - 0
.npmignore

@@ -0,0 +1,8 @@
+/build
+/doc
+/node_modules
+/src
+.gitignore
+/rollup.build.css
+/tsconfig.json
+/yarn.lock

+ 0 - 72
build/rollup.amd.js

@@ -1,72 +0,0 @@
-import { name } from '../package.json'
-import { resolve } from 'path'
-import typescript from 'rollup-plugin-typescript'
-import postcss from 'rollup-plugin-postcss';
-import simplevars from 'postcss-simple-vars';
-import nested from 'postcss-nested';
-import cssnext from 'postcss-cssnext';
-import nodeResolve from 'rollup-plugin-node-resolve'
-import commonjs from 'rollup-plugin-commonjs'
-import amd from 'rollup-plugin-amd'
-import replace from 'rollup-plugin-replace'
-import json from '@rollup/plugin-json';
-import builtins from 'rollup-plugin-node-builtins';
-
-export default {
-    // 入口文件
-    input: resolve(__dirname, '../src/index.ts'),
-    plugins: [
-        // tsx(),
-        nodeResolve({
-            browser: true
-        }),
-        postcss({
-            extensions: ['.css'],
-            // extract: true,
-            extract: 'yvan-ext-mobile.css',
-            plugins: [
-                simplevars(),
-                nested(),
-                cssnext({ warnForDuplicates: false, }),
-                // cssnano()
-            ]
-        }),
-        typescript({
-            "include": [
-                "./src/**/*.ts",
-                "./src/**/*.js"
-            ],
-            "exclude": [
-                "./dist",
-                "./node_modules"
-            ]
-        }),
-        commonjs({
-            include: 'node_modules/**',
-            namedExports: {
-                'node_modules/react-is/index.js': ['isFragment', 'ForwardRef', 'isMemo'],
-            }
-        }),
-        replace({
-            'process.env.NODE_ENV': JSON.stringify('development')
-        }),
-        // amd({
-        //     include: 'src/**', // Optional, Default: undefined (everything)
-        //     // exclude: ['node_modules/**'], // Optional, Default: undefined (nothing)
-        //     converter: {}, // Optional, Default: undefined
-        //     rewire: function (moduleId, parentPath) { // Optional, Default: false
-        //         return './basePath/' + moduleId;
-        //     }
-        // }),
-        json(),
-        builtins()
-    ],
-    output: {
-        // 打包名称
-        name: name,
-        exports: 'named',
-        sourcemap: true,
-        file: resolve(__dirname, `../dist/${name}.js`),
-        format: 'amd',
-    },
-}

+ 0 - 44
build/rollup.config.js

@@ -1,44 +0,0 @@
-import { name } from '../package.json'
-import { resolve } from 'path'
-import typescript from 'rollup-plugin-typescript2'
-import postcss from 'rollup-plugin-postcss';
-import simplevars from 'postcss-simple-vars';
-import nested from 'postcss-nested';
-import cssnext from 'postcss-cssnext';
-
-export default {
-    // 入口文件
-    input: resolve(__dirname, '../src/index.ts'),
-    plugins: [
-        // tsx(),
-        postcss({
-            extensions: ['.css'],
-            // extract: true,
-            extract: 'wotu-ui.css',
-            plugins: [
-                simplevars(),
-                nested(),
-                cssnext({ warnForDuplicates: false, }),
-                // cssnano()
-            ]
-        }),
-        typescript({
-            "include": [
-                "./src/**/*.ts",
-                "./src/**/*.tsx"
-            ],
-            "exclude": [
-                "./dist",
-                "./node_modules"
-            ]
-        }),
-    ],
-    output: {
-        // 打包名称
-        name: name,
-        exports: 'named',
-        sourcemap: true,
-        file: resolve(__dirname, `../dist/${name}.js`),
-        format: 'umd',
-    },
-}

+ 0 - 64
build/rollup.iife.js

@@ -1,64 +0,0 @@
-import { name } from '../package.json'
-import { resolve } from 'path'
-import react from 'react';
-import reactDom from 'react-dom';
-import typescript from 'rollup-plugin-typescript'
-import postcss from 'rollup-plugin-postcss';
-import simplevars from 'postcss-simple-vars';
-import nested from 'postcss-nested';
-import cssnext from 'postcss-cssnext';
-import nodeResolve from 'rollup-plugin-node-resolve'
-import commonjs from 'rollup-plugin-commonjs'
-import replace from 'rollup-plugin-replace'
-import {uglify} from 'rollup-plugin-uglify'
-
-export default {
-    // 入口文件
-    input: resolve(__dirname, '../src/index.ts'),
-    plugins: [
-        // tsx(),
-        nodeResolve({
-            browser: true
-        }),
-        postcss({
-            extensions: ['.css'],
-            extract: true,
-            extract: 'wotu-ui.css',
-            plugins: [
-                simplevars(),
-                nested(),
-                cssnext({ warnForDuplicates: false, }),
-                // cssnano()
-            ]
-        }),
-        typescript({
-            "include": [
-                "./src/**/*.ts",
-                "./src/**/*.tsx"
-            ],
-            "exclude": [
-                "./dist",
-                "./node_modules"
-            ]
-        }),
-        commonjs({
-            include: 'node_modules/**',
-            namedExports: {
-                'node_modules/react-is/index.js': ['isFragment', 'ForwardRef', 'isMemo'],
-                react: Object.keys(react),
-                'react-dom': Object.keys(reactDom)
-            }
-        }),
-        replace({
-            'process.env.NODE_ENV': JSON.stringify('production')
-        }),
-        uglify()
-    ],
-    output: {
-        // 打包名称
-        name: 'WotuUI',
-        sourcemap: true,
-        file: resolve(__dirname, `../dist/WotuUI.js`),
-        format: 'iife'
-    },
-}

+ 0 - 79
build/rollup.ugfi.js

@@ -1,79 +0,0 @@
-import { name } from '../package.json'
-import { resolve } from 'path'
-import react from 'react';
-import reactDom from 'react-dom';
-import typescript from 'rollup-plugin-typescript'
-import postcss from 'rollup-plugin-postcss';
-import simplevars from 'postcss-simple-vars';
-import nested from 'postcss-nested';
-import cssnext from 'postcss-cssnext';
-import nodeResolve from 'rollup-plugin-node-resolve'
-import commonjs from 'rollup-plugin-commonjs'
-import amd from 'rollup-plugin-amd'
-import replace from 'rollup-plugin-replace'
-import json from '@rollup/plugin-json';
-import builtins from 'rollup-plugin-node-builtins';
-import {uglify} from "rollup-plugin-uglify";
-
-
-export default {
-    // 入口文件
-    input: resolve(__dirname, '../src/index.ts'),
-    plugins: [
-        // tsx(),
-        nodeResolve({
-            browser: true
-        }),
-        postcss({
-            extensions: ['.css'],
-            extract: true,
-            extract: 'wotu-ui.css',
-            plugins: [
-                simplevars(),
-                nested(),
-                cssnext({ warnForDuplicates: false, }),
-                // cssnano()
-            ]
-        }),
-        typescript({
-            "include": [
-                "./src/**/*.ts",
-                "./src/**/*.tsx"
-            ],
-            "exclude": [
-                "./dist",
-                "./node_modules"
-            ]
-        }),
-        commonjs({
-            include: 'node_modules/**',
-            namedExports: {
-                'node_modules/react-is/index.js': ['isFragment', 'ForwardRef', 'isMemo'],
-                react: Object.keys(react),
-                'react-dom': Object.keys(reactDom)
-            }
-        }),
-        replace({
-            'process.env.NODE_ENV': JSON.stringify('development')
-        }),
-        // amd({
-        //     include: 'src/**', // Optional, Default: undefined (everything)
-        //     // exclude: ['node_modules/**'], // Optional, Default: undefined (nothing)
-        //     converter: {}, // Optional, Default: undefined
-        //     rewire: function (moduleId, parentPath) { // Optional, Default: false
-        //         return './basePath/' + moduleId;
-        //     }
-        // }),
-        json(),
-        builtins(),
-        uglify()
-    ],
-    output: {
-        // 打包名称
-        name: name,
-        exports: 'named',
-        sourcemap: true,
-        file: resolve(__dirname, `../dist/${name}.js`),
-        format: 'amd',
-    },
-}

+ 187 - 0
dist/Defaults.d.ts

@@ -0,0 +1,187 @@
+export declare const windows: {
+    modal: boolean;
+    width: number;
+    height: number;
+    maximizable: boolean;
+    constrain: boolean;
+    shadow: boolean;
+};
+export declare const date: {
+    labelAlign: string;
+    labelWidth: number;
+};
+export declare const combo: {
+    labelAlign: string;
+    labelWidth: number;
+    valueField: string;
+    displayField: string;
+    autoLoad: boolean;
+    mode: string;
+    forceSelection: boolean;
+    triggerAction: string;
+    enableKeyEvents: boolean;
+};
+export declare const comboGrid: {
+    selectOnTab: boolean;
+    pickerHeight: number;
+    pickerWidth: number;
+    editEnable: any;
+};
+export declare const comboGridPicker: {
+    xtype: string;
+    layout: string;
+    selModel: {
+        selType: string;
+        mode: string;
+    };
+};
+export declare const comboGridMulti: {
+    selectOnTab: boolean;
+    pickerHeight: number;
+    pickerWidth: number;
+    editEnable: any;
+    splitChar: string;
+    displayField: string;
+    valueField: string;
+    autoLoad: boolean;
+};
+export declare const comboGridMultiPicker: {
+    selType: string;
+    selModel: {
+        type: string;
+        checkOnly: boolean;
+    };
+};
+export declare const numberfield: {
+    labelAlign: string;
+    labelWidth: number;
+};
+export declare const checkbox: {
+    labelAlign: string;
+    labelWidth: number;
+    checkedValue: boolean;
+    uncheckedValue: boolean;
+};
+export declare const checkboxgroup: {
+    labelAlign: string;
+    labelWidth: number;
+};
+export declare const radio: {
+    labelAlign: string;
+    labelWidth: number;
+};
+export declare const radiogroup: {
+    labelAlign: string;
+    labelWidth: number;
+    simpleValue: boolean;
+    layout: string;
+    defaults: {
+        xtype: string;
+        name: string;
+        margin: string;
+    };
+};
+export declare const form: {
+    margin: string;
+    border: boolean;
+    defaults: {
+        margin: string;
+        border: boolean;
+    };
+};
+export declare const column: {
+    menuDisabled: boolean;
+};
+export declare const grid: {
+    border: boolean;
+    columnLines: boolean;
+    rowLines: boolean;
+    plugins: {
+        cellediting: {
+            clicksToEdit: number;
+        };
+        gridfilters: boolean;
+    };
+    multiColumnSort: boolean;
+    viewConfig: {
+        enableTextSelection: boolean;
+        sortOnClick: boolean;
+    };
+    selModel: {
+        type: string;
+        checkOnly: boolean;
+    };
+    pagination: boolean;
+    pageSize: number;
+    pageSizeOption: string[];
+    hideFootbar: boolean;
+    hideRefresh: boolean;
+    hideExport: boolean;
+    hideAutoSize: boolean;
+    hideClearFilter: boolean;
+    hideSaveGridUIConfig: boolean;
+    hideClearGridUIConfig: boolean;
+    autoLoad: boolean;
+    remoteSort: boolean;
+    remoteFilter: boolean;
+    enableLocking: boolean;
+    enableColumnMove: boolean;
+    enableColumnHide: boolean;
+    enableColumnResize: boolean;
+    hidden: boolean;
+    disabled: boolean;
+    exportExcelPageSize: number;
+    exportExcelCurrentPage: number;
+    exportExcelTotal: number;
+};
+export declare const fieldContainer: {
+    labelAlign: string;
+    labelWidth: number;
+    layout: string;
+    defaults: {
+        flex: number;
+    };
+};
+export declare const tree: {
+    autoLoad: boolean;
+    hideFilter: boolean;
+    hideToolbar: boolean;
+    hideRefresh: boolean;
+    hideExpand: boolean;
+    hideCollapse: boolean;
+};
+export declare const search: {
+    labelAlign: string;
+    labelWidth: number;
+};
+export declare const text: {
+    labelAlign: string;
+    labelWidth: number;
+    msgTarget: string;
+};
+export declare const toolbar: {
+    overflowHandler: string;
+};
+export declare const tbfill: {};
+export declare const tbseparator: {};
+export declare const button: {};
+export declare const fieldSet: {
+    margin: string;
+    border: boolean;
+    defaults: {
+        margin: string;
+        border: boolean;
+    };
+};
+export declare const storeAjax: {
+    timeout: number;
+};
+export declare const panel: {};
+export declare const splitter: {};
+export declare const maintab: {};
+export declare const rows: {};
+export declare const cols: {
+    defaults: {
+        flex: number;
+    };
+};

+ 54 - 0
dist/PropertyDescription.d.ts

@@ -0,0 +1,54 @@
+export declare type GroupType = 'css' | 'data' | 'bind' | 'common' | 'event';
+export interface PropertyValue {
+    /**
+     * 属性名
+     */
+    name: string;
+    /**
+     * 默认值
+     */
+    default: any;
+    /**
+     * 隶属分组
+     */
+    group: GroupType;
+    /**
+     * 描述
+     */
+    desc: string;
+    /**
+     * 取值范围
+     */
+    type: 'boolean' | 'number' | 'string' | 'object' | 'dataSource' | 'valid' | 'format' | Array<string> | 'widget';
+    eventParamter?: string[];
+    eventResult?: string;
+    eventDoc?: (vjson: any) => string;
+    expr?: boolean;
+}
+export interface EventValue {
+    /**
+     * 属性名
+     */
+    name: string;
+    /**
+     * 描述
+     */
+    desc: string;
+}
+export interface PropertyDescriptionInterface {
+    props: PropertyValue[];
+    events?: EventValue[];
+}
+export declare class PropertyDescription {
+    propertyes: PropertyDescriptionInterface;
+    constructor(...args: PropertyDescriptionInterface[]);
+    merge(pd: PropertyDescriptionInterface): void;
+    /**
+     * 根据分组名 获取属性定义
+     */
+    getPropsByGroup(name: GroupType): PropertyValue[];
+    /**
+     * 获取全部事件
+     */
+    getEvents(): EventValue[];
+}

+ 27 - 0
dist/PropertyDescriptionTable.d.ts

@@ -0,0 +1,27 @@
+import {PropertyDescription, PropertyDescriptionInterface, PropertyValue} from './PropertyDescription';
+
+export declare const PropertyDescriptionTable: Map<String, PropertyDescription>;
+export declare const width: PropertyValue;
+export declare const height: PropertyValue;
+export declare const fieldLabel: PropertyValue;
+export declare const text: PropertyValue;
+export declare const iconCls: PropertyValue;
+export declare const borderless: PropertyValue;
+export declare const labelAlign: PropertyValue;
+export declare const type: PropertyValue;
+export declare const labelWidth: PropertyValue;
+export declare const gravity: PropertyValue;
+export declare const hidden: PropertyValue;
+export declare const readonly: PropertyValue;
+export declare const disabled: PropertyValue;
+export declare const loading: PropertyValue;
+export declare const required: PropertyValue;
+export declare const value: PropertyValue;
+export declare const prompt: PropertyValue;
+export declare const validType: PropertyValue;
+export declare const metaId: PropertyValue;
+export declare const template: PropertyValue;
+export declare const tooltip: PropertyValue;
+export declare const onClick: PropertyValue;
+export declare const YvBase: PropertyDescriptionInterface;
+export declare const YvDataSource: PropertyDescriptionInterface;

+ 104 - 0
dist/Scope.d.ts

@@ -0,0 +1,104 @@
+export declare class Scope {
+    private static readonly SHOW_PAGE_STACK;
+    /**
+     * 业务模块的唯一编号
+     */
+    id: string;
+    /**
+     * 构造函数传入的最初始的 vjson
+     */
+    originalVjson: any;
+    /**
+     * 一个 ExtJS 能接受的配置对象
+     */
+    vjson: any;
+    /**
+     * 原始 vjsonModel 对象
+     */
+    model: any;
+    /**
+     * 双向绑定的模型对象
+     */
+    viewModel: any;
+    /**
+     * 构建完成之后的 Ext控件句柄
+     */
+    _handle: any;
+    /**
+     * 页面显示的时候带的参数 在设计刷新的时候使用
+     */
+    _vjsonOption: any;
+    _dataOption: any;
+    /**
+     * 最顶部的 scope 对象
+     */
+    topScope: any;
+    _lastShowTime: number;
+    constructor({ model, vjson }: {
+        model: any;
+        vjson: any;
+    });
+    /**
+     * 模块载入完成之后的回调
+     */
+    onLoad(): void;
+    /**
+     * 组件卸载之后的回调
+     */
+    onDestroy(): void;
+    get isScope(): boolean;
+    /**
+     * 产生一个当前模块有效的唯一id
+     * @param key 唯一编号
+     */
+    uid(key: any): string;
+    _onDestroy(): void;
+    _onLoad(): void;
+    showMainWindow(): void;
+    /**
+     * 渲染模块到全屏
+     * allowBack 是否允许后退(退出)
+     * vjsonOption 界面覆盖选项(可以为空)
+     * dataOption 数据覆盖选项(可以为空)
+     */
+    render(option?: {
+        allowBack: boolean;
+        vjsonOption: {};
+        dataOption: {};
+    }): any;
+    /**
+     * 对话框"保存"成功.
+     * 关闭对话框,并响应 success 方法
+     * @param data 要傳回的數據(可以為空)
+     */
+    dialogSuccess(data?: any): void;
+    /**
+     * 设置等待状态
+     * @param value
+     * @param msg
+     */
+    setLoading(value: boolean): void;
+    /**
+     * 关闭对话框(或标签页)
+     */
+    close(): void;
+    /**
+     * 获取 viewModel 里包含的数据(只读)
+     */
+    get data(): any;
+    /**
+     * 设置 viewModel 中的数据
+     * 可以是 key, value 模式
+     * 也可以是 {key:value} 模式
+     */
+    set(path: any, value: any): any;
+    /**
+     * 寻找模块内所有的 xtype 对应的对象
+     * @param xtypeKey
+     */
+    down(xtypeKey: any): any;
+    /**
+     * 获取所有设置过 Reference 名称的组件
+     */
+    get refs(): any;
+}

+ 13 - 0
dist/controls/base.d.ts

@@ -0,0 +1,13 @@
+declare type DragType = 'rows-container' | 'cols-container' | 'col-item' | 'row-item';
+/**
+ * 构建所有组件的公共属性
+ * @param config 原始config
+ * @param dragType 组件模式
+ *      不填,代表不能在设计时被拖拽
+ *      row-container 是一个rows容器
+ *      col-container 是一个cols容器
+ *      col-item cols中的一个格子(非容器),比如 textfield / combofield 等等
+ *      row-item rows中的一行,比如 tree / grid / panel 等等
+ */
+export declare function baseConfig(config: any, dragType?: DragType): any;
+export {};

+ 1 - 0
dist/controls/cols.d.ts

@@ -0,0 +1 @@
+export default function _default(): void;

+ 1 - 0
dist/controls/grid.d.ts

@@ -0,0 +1 @@
+export default function _default(): void;

+ 1 - 0
dist/controls/gridcolumn.d.ts

@@ -0,0 +1 @@
+export default function _default(): void;

+ 5 - 0
dist/controls/stores.d.ts

@@ -0,0 +1,5 @@
+/**
+ * 构建一个 grid 支持的 dataSource
+ */
+export function gridInvokeBuild(scope: any, grid: any, config: any, dataSource: any, reloadParams?: {}): void;
+export default function _default(): void;

+ 15 - 0
dist/index.d.ts

@@ -0,0 +1,15 @@
+import * as axios from 'axios';
+import qs from 'qs';
+import lodash from 'lodash';
+import jquery from 'jquery';
+import json5 from 'json5';
+import moment from 'moment';
+import './wotu-ui.css';
+
+export { axios, qs, lodash, jquery, json5, moment, };
+export * from './Scope';
+export * from './init';
+export * from './lib/ajax';
+export * from './lib/lib';
+export * from './lib/config';
+export * from './message';

+ 3 - 0
dist/init.d.ts

@@ -0,0 +1,3 @@
+import './lib/fix';
+
+export declare function init(): void;

+ 59 - 0
dist/lib/ajax.d.ts

@@ -0,0 +1,59 @@
+import {PlainObject} from "../types";
+
+export declare type ApiMethod = 'get' | 'post' | 'put' | 'patch' | 'delete' | 'download' | 'post-json' | 'post-file' | 'invoke' | 'sql' | string;
+export declare type ApiDataType = 'json' | 'form-data' | 'form';
+export interface ApiObject {
+    url: string;
+    param: PlainObject;
+    method: ApiMethod;
+    data?: object;
+    args: any[];
+    db?: string;
+    headers?: PlainObject;
+    filterModel?: {
+        [key: string]: any;
+    };
+    sortModel?: {
+        colId: string | undefined;
+        sort: string | null | undefined;
+    }[];
+    config?: {
+        withCredentials?: boolean;
+        cancelExecutor?: (cancel: Function) => void;
+    };
+    dataType?: ApiDataType;
+    /**
+     * 下载文件名
+     */
+    fileName?: string;
+    /**
+     * 上传文件(如果需要的话)
+     */
+    file?: any;
+}
+export declare type ApiFunction = (api: ApiObject) => Promise<ApiResult>;
+/**
+ * 组件中 Api 的声明
+ */
+export declare type Api = ApiFunction | ApiObject;
+export interface ApiResult {
+    rawData: object;
+    status: number;
+    headers: object;
+    data?: any;
+    pagination?: any;
+    success: boolean;
+    msg: string;
+    errors?: {
+        [propName: string]: string;
+    };
+}
+export interface CreateAjaxOption {
+    baseUrl: string;
+    timeout: number;
+}
+/**
+ * 创建一个 Ajax 客户端
+ */
+export declare function createAjax(createOption: CreateAjaxOption): ApiFunction;
+export declare function downLoad(downLoadUrl: string, filename: string, data: any, header: any, isJson?: boolean): void;

+ 80 - 0
dist/lib/config.d.ts

@@ -0,0 +1,80 @@
+import {ConfigProcess} from "../types";
+import {ApiFunction} from "./ajax";
+
+export declare type ServerInvokeUrlTransformFunction = (jsUrl: string, option?: any) => string | undefined;
+export declare type SqlUrlTransformFunction = (jsUrl: string, option?: any) => string | undefined;
+export interface ApiConvert {
+    /**
+     * 从表格 dataSource 属性,转换为 ExtJS.storeOption 属性
+     */
+    gridInvokeBuild: (scope: any, grid: any, config: any, dataSource: any, params: any, reloadParams: any) => object;
+}
+/**
+ * YvanUI 全局扩展配置
+ */
+export interface ConfigOption {
+    /**
+     * 是否在设计器模式
+     */
+    designMode: boolean;
+    /**
+     * 扩展自定义的 ajax 方法
+     */
+    ajax: ApiFunction;
+    /**
+     * 扩展自定义的后端请求方法
+     */
+    apiConvert: ApiConvert;
+    /**
+     * serverJS Url转换为Ajax请求
+     */
+    serverInvokeUrlTransform: ServerInvokeUrlTransformFunction;
+    /**
+     * Sql Url转换为Ajax请求
+     */
+    sqlUrlTransform: SqlUrlTransformFunction;
+    /**
+     * 获取拼音首字母的函数
+     */
+    pinyinFunction: (py: string) => string;
+    /**
+     * Scope onload 时扩展方法
+     */
+    scopeOnLoad: (scope: any) => void;
+}
+/**
+ * 全局 ajax 方法
+ */
+export declare const ajax: {
+    func?: ApiFunction;
+};
+export declare let scopeOnLoad: (scope: any) => void;
+export declare let apiConvert: ApiConvert;
+export declare const baseConfigProcessList: ConfigProcess[];
+/**
+ * 在基类添加 Config 的处理方法
+ */
+export declare function baseConfigProcess(option?: any): (target: any, propertyKey: any) => void;
+export declare function isDesignMode(): boolean;
+export declare function setDesignMode(v: boolean): void;
+/**
+ * 将业务定义的 url 转换为调用服务端 groovy 的 url
+ */
+export declare function serverInvokeUrlTransform(url: string, option?: any): string;
+/**
+ * 将业务定义的 url 转换为调用服务端 sql 的 Url
+ */
+export declare function sqlUrlTransform(url: string): string;
+/**
+ * YvanUI 全局扩展配置
+ */
+export declare function extend(option: Partial<ConfigOption>): void;
+export declare function getApiConvert(): ApiConvert;
+export declare function getPinyin(v: string): any;
+/**
+ * 适用于 Select / Tree 等,作筛选的通用方法.
+ * 1.首字母模糊匹配(不区分大小写)
+ * 2.标识的模糊匹配(不区分大小写)
+ * 3.名称的模糊匹配,且支持以逗号(全角或半角)隔开的字词匹配,并自动去空格,如“南京, 物流 ”可以匹配出“南京九州通物流技术开发有限公司”
+ */
+export declare function keywordFilter(keyword: string, label: string, value?: string): boolean;

+ 1 - 0
dist/lib/fix.d.ts

@@ -0,0 +1 @@
+export {};

+ 31 - 0
dist/lib/lib.d.ts

@@ -0,0 +1,31 @@
+import {FunctionRegiste, LibParamType} from "../types";
+import {Scope} from "../Scope";
+
+export declare function getRegList(): FunctionRegiste[];
+export declare function getRegParamList(methodName: string): any;
+/**
+ * 模拟点击按钮
+ */
+export declare function raiseClick(buttonHandle: any): boolean;
+/**
+ * 标注系统全局函数的参数
+ * @param title 函数名称
+ * @param type 函数类型
+ * @param allowEmpty 可否为空
+ */
+export declare function LibParam(title: string, type: LibParamType, allowEmpty?: boolean): (target: any, methodName: any, paramsIndex: any) => void;
+/**
+ * 标注函数变成"系统全局函数"
+ */
+export declare function Lib(registe: FunctionRegiste): (target: any, propertyKey: string, descriptor: PropertyDescriptor) => any;
+/**
+ * 解析事件
+ *   'scope.私有方法名'
+ *   'system.系统函数名'
+ *   'format.格式化名'
+ */
+export declare function lookupFn(scope: Scope, event: string): Function;
+/**
+ * 从 ext.element 获取 scope 对象
+ */
+export declare function lookupScope(extHandle: any): Scope;

+ 1 - 0
dist/lib/locale-zh_CN.d.ts

@@ -0,0 +1 @@
+export function initLocale(): void;

+ 255 - 0
dist/lib/systemLib.d.ts

@@ -0,0 +1,255 @@
+export declare const SIMPLE_RE: RegExp;
+/**
+ * 对某个表达式进行求值
+ * a:{query.a},b:{query.b} -> a:aValue,b:bValue
+ *
+ * @example
+ * calcExpress(cc.viewModel.data, "WH_ID:{query.WH_ID},C:{theGrid.selection.data.WH_ID}")
+ * 计算出来的值是: "WH_ID:queryWhId,C:JH000000001"
+ *
+ * @param data 数据环境对象
+ * @param express 表达式对象
+ */
+export declare function calcExpress(data: any, express: any): any;
+/**
+ * 对个对象进行表达式求值,不用回调
+ * @example
+ * calcObjectFlat({query:{a:'aValue',b1:'b1Value',b2:'b2Value',d1:1,d2:2}}, { a:'{query.a}', b:{b1:'{query.b1}', b2:'{query.b2}'},c:'aa',d:['{query.d1}','{query.d2}'] })
+ *
+ * {
+ *     a: '{query.a}',
+ *     b: {
+ *         b1: '{query.b1}',
+ *         b2: '{query.b2}',
+ *     },
+ *     c: 'aa',
+ *     d: [
+ *         '{query.d1}',
+ *         '{query.d2}'
+ *     ]
+ * }
+ *
+ * 计算结果为
+ * {
+ *     a: 'aValue',
+ *     b: {
+ *         b1: 'b1Value',
+ *         b2: 'b2Value'
+ *     },
+ *     c: 'aa'
+ *     d: [
+ *         '1',
+ *         '2'
+ *     ]
+ * }
+ *
+ * @param data
+ * @param paramObject
+ */
+export declare function calcObjectFlat(data: any, paramObject: any): any;
+/**
+ * 合併 data 到當前的 ViewModel 對象
+ */
+export declare function mergeViewModel(viewModel: any, propertyName: any, data: any): void;
+/**
+ * 转换内联结构的行,到平面结构
+ * company: { name:'公司1', id:'编号1' } => { company_id:'编号1', company_name:'公司1' }
+ *
+ * @param array
+ * @param flatOption
+ * @return {[]}
+ */
+export declare function flatRow(array: any): any[];
+/**
+ * 根据表达式进入写值
+ * express="{query.a}"   写值就是 viewModel.set('query.a', value)
+ * express="test-{query.a}"   写值就会失败
+ *
+ * @example
+ * tryWriteByExpress(cc.viewModel, "{query.WH_ID}", "111")
+ * 写值成功
+ *
+ * tryWriteByExpress(cc.viewModel, "test-{query.WH_ID}", "111")
+ * 写值失败
+ *
+ * @param viewModel VM对象
+ * @param express 表达式对象
+ * @param value 目标值
+ */
+export declare function tryWriteByExpress(viewModel: any, express: any, value: any): void;
+/**
+ * 尝试根据含表达式的对象回写, calcObjectFlat 的逆向方法
+ * @example
+ * tryWriteObject({ a:'{query.a}', b:{b1:'{query.b1}', b2:'{query.b2}'},c:'aa',d:['{query.d1}','{query.d2}']}, {a:'aValue', b:{b1:'b1Value', b2:'b2Value'}, c:'aa', d:[1,2]})
+ *
+ * expressObject:
+ * {
+ *     a: '{query.a}',
+ *     b: {
+ *         b1: '{query.b1}',
+ *         b2: '{query.b2}',
+ *     },
+ *     c: 'aa',
+ *     d: [
+ *         '{query.a}',
+ *         '{query.b2}'
+ *     ]
+ * }
+ *
+ * valueObject:
+ * {
+ *     a: 'aValue',
+ *     b: {
+ *         b1: 'b1Value',
+ *         b2: 'b2Value'
+ *     },
+ *     c: 'aa'
+ *     c: [
+ *         'aValue',
+ *         'b2Value'
+ *     ]
+ * }
+ *
+ * 系统会尝试回写
+ * viewModel.set('query.a', 'aValue')
+ * viewModel.set('query.b1', 'b1Value')
+ * viewModel.set('query.b2', 'b2Value')
+ *
+ * @param expressObject 含表达式的对象
+ * @param valueObject 表达式计算完成之后的结果对象
+ * @param writeFn 写入的方法 (path, value)=>void
+ */
+export declare function tryWriteObject(expressObject: any, valueObject: any, writeFn: any): void;
+/**
+ * 尝试去掉变量两边括号
+ * {a} => a
+ * a => a
+ */
+export declare function tryVarSimple(value: any): any;
+/**
+ * 对多个表达式进行求值. 异步回调的方式返回
+ *      {
+ *          a: 1,
+ *          b: '{someBind}',
+ *          c: ['a', 'b', 'c'],
+ *          d: ['a', 'b', '{someBind}'],
+ *          e: {
+ *              y: 1,
+ *              z: 2
+ *          },
+ *          f: {
+ *              y: 1,
+ *              z: '{someBind}'
+ *          }
+ *      }
+ *
+ *      // Will produce
+ *      {
+ *          b: value,
+ *          d: ['a', 'b', value],
+ *          f: {
+ *              y: 1,
+ *              z: value
+ *          }
+ *      }
+ * @param viewModel scope.viewModel对象
+ * @param paramObject 求值对象
+ */
+export declare function calcObject(viewModel: any, paramObject: any): Promise<unknown>;
+/**
+ * 用于任意组件 Ext.Component 构造时,获取当前组件对应的表格(如果不是 grid.columns 对象就会返回 undefined)
+ * @param config 组件构造函数传入的 config 配置文件
+ */
+export declare function getParentGrid(config: any): any;
+/**
+ * 解析
+ * {
+ *     condition: "{skuId}",
+ *     errorMsg: "无法编辑",
+ *     notice: 'msg'
+ * }
+ */
+export declare function tryEnable(data: any, enableSetting: any): boolean;
+/**
+ * 动态的为 combo 或 columns.combo 设置下拉框的值
+ * @param sender 目标对象
+ * @param config 目标对象的配置(在构造函数之前也可以)
+ * @param getDictFn 获取字典的方法
+ * @param bizKey 传入字典的参数
+ * @param multiValueSeparator 多个字典值的分割符号
+ */
+export declare function setComboStore(sender: any, config: any, getDictFn: any, bizKey: any, multiValueSeparator?: string): Promise<unknown>;
+/**
+ * 调用服务器 Ajax
+ */
+export declare function invokeServer(url: string, ...args: any[]): any;
+export declare function clearViewModelValues(viewModel: any, propertyName: any): void;
+export declare function reloadGrid(scope: any, gridRefName: any): void;
+/**
+ * 将 Ext.data.Model 对象 (及子属性) 转换为 js.object 对象
+ */
+export declare function toPlainObject(obj: any): any;
+export declare function confirm(msg: any, sender?: any): Promise<void>;
+/**
+ * 任何符号字符串都替换成下换线
+ */
+export declare function normId(value: string): string;
+/**
+ *
+ * @param sender
+ * @param propertyName
+ * @param gridRefName
+ */
+export declare function clearViewModelReloadGrid(sender: any, propertyName: any, gridRefName: any): void;
+export declare class SystemEventFu {
+    confirm(text: any, fn: any): (sender: any) => void;
+    gridRemoveCurrentRow(gridRefName: any): (sender: any) => void;
+    loadForm(invokeUrl: string, invokeParam: any, writeTarget: any): (sender: any) => void;
+    commit(groovyUrl: string, arg0: any, successCallback: any): (sender: any) => void;
+    formCommit(groovyUrl: string, arg0: any): (sender: any) => void;
+    dialogSuccess(lookupObject: any): (sender: any) => void;
+    clearViewModelValues(propertyName: string): (sender: any) => void;
+    getGrid(url: any): (sender: any, config: any) => void;
+    clearViewModelReloadGrid(propertyName: string, gridRefName?: string): (sender: any) => void;
+    reloadGrid(gridRefName: string): (sender: any) => void;
+    showDialog(url: string, lookupForData: any, successCallback: any): (sender: any) => void;
+    showWidget(widgetUrl: any, lookup: any): (sender: any, queryValue: any) => void;
+    clearViewModelByLookup(lookup: any): (sender: any) => void;
+    closeMe(callBack: any): (sender: any) => void;
+}
+/**
+ * 清空 viewmodel 里下属的所有属性
+ * @param viewModel VM对象
+ * @param propertyKey 要清空的属性,可以是 "a.b.c" 这种表达模式
+ * @param ignoreProps 要忽略清空的属性名集合, 比如 ["a.b","b"]
+ */
+export declare function clearViewModel(viewModel: any, propertyKey: any, ignoreProps: any): void;
+export declare function clearViewModelByLookup(sender: any, lookup: any): void;
+export declare function showWidget(widgetUrl: any, lookup: any, sender: any, queryValue: any, vjson?: {}): void;
+/**
+ * 停止事件的默认行为
+ * @param e
+ */
+export declare function stopEvent(e: any): void;
+/**
+ * 屏幕中央显示一个黑框提示
+ */
+export declare function msg(content: any): void;
+/**
+ * 错误对话框的强提醒
+ */
+export declare function showErrorDialog(msg: any, sender?: any): void;
+/**
+ * 用于计算 express 表达式
+ */
+export declare function evalFunction(data: any, express: any): any;
+/**
+ * 获取表格编辑的行数据
+ */
+export declare function getGridEditRows(grid: any): {
+    rows: any[];
+    newRows: any[];
+    modifyRows: any[];
+    removeRecords: any[];
+    err: string;
+};

+ 4 - 0
dist/lib/systemLibEval.d.ts

@@ -0,0 +1,4 @@
+/**
+ * 用于计算 express 表达式
+ */
+export function evalFunction(data: any, express: any): any;

+ 14 - 0
dist/message.d.ts

@@ -0,0 +1,14 @@
+export declare function prompt(message: any, multiLine?: boolean, value?: string): Promise<unknown>;
+export declare function confirm(message: any): Promise<unknown>;
+export declare function showInfoDialog(msg: any, fn?: any): void;
+/**
+ * 显示错误异常信息
+ * @param msg 错误内容
+ * @param fn 确定之后的回调
+ */
+export declare function showErrorDialog(msg: any, fn?: any): void;
+export declare function msgError(msg: any, fn?: any): void;
+/**
+ * 中间灰底白字提示
+ */
+export declare function msg(message: string): void;

+ 24 - 41
src/types.ts

@@ -1,25 +1,21 @@
 export interface PlainObject {
     [propsName: string]: any;
 }
-
 export interface VJson {
     [propName: string]: any;
 }
-
 export interface Model {
-    success: boolean
-    msg: string
-    data: any
+    success: boolean;
+    msg: string;
+    data: any;
 }
-
 /**
  * 处理 VJson 的
  * @param this 是指 scope 对象
  * @param vjson 是待处理的 VJson 对象
  * @result 返回处理 VJson 的 Promise 异步结果
  */
-export type ConfigProcess = (me, config) => any
-
+export declare type ConfigProcess = (me: any, config: any) => any;
 /**
  * 参数的填写类型
  *    module 选择一个功能模块
@@ -31,9 +27,10 @@ export type ConfigProcess = (me, config) => any
  *    string 任意字符串
  *    object 任意对象 (JSON5)
  */
-export type LibParamType = 'module' | 'viewModel' | 'refs' | 'event' | 'lookup' | 'string' | 'object'
-    | (() => Promise<string[] | { id: string, value: string }[]>)
-
+export declare type LibParamType = 'module' | 'viewModel' | 'refs' | 'event' | 'lookup' | 'string' | 'object' | (() => Promise<string[] | {
+    id: string;
+    value: string;
+}[]>);
 /**
  * 注册函数中的参数
  */
@@ -48,30 +45,25 @@ export interface FunctionArgument {
      *    string 任意字符串
      *    object 任意对象 (JSON5)
      */
-    type: LibParamType
-
+    type: LibParamType;
     /**
      * 参数中文说明
      */
-    title: string
-
+    title: string;
     /**
      * 参数名称
      */
-    name: string
-
+    name: string;
     /**
      * 是否允许为空
      */
-    allowEmpty?: boolean
-
+    allowEmpty?: boolean;
     /**
      * 过滤器
      * @param list
      */
-    filter?: (items: any[]) => any[]
+    filter?: (items: any[]) => any[];
 }
-
 /**
  * 注册函数, 用在 @Lib 装饰器
  */
@@ -79,52 +71,43 @@ export interface FunctionRegiste {
     /**
      * 函数名
      */
-    name?: string
-
+    name?: string;
     /**
      * 中文说明
      */
-    title?: string
-
+    title?: string;
     /**
      * 作者
      */
-    author?: string
-
+    author?: string;
     /**
      * 创建时间
      */
-    createAt?: string
-
+    createAt?: string;
     /**
      * 更新时间
      */
-    updateAt?: string
-
+    updateAt?: string;
     /**
      * 备注
      */
-    remark?: string
-
+    remark?: string;
     /**
      * 类型
      * system: 系统方法
      * format: 格式化作用
      */
-    type: 'system' | 'format'
-
+    type: 'system' | 'format';
     /**
      * 分类名称
      */
-    category?: string
-
+    category?: string;
     /**
      * 文档链接
      */
-    link?: string
-
+    link?: string;
     /**
      * 方法体
      */
-    target?: Function
-}
+    target?: Function;
+}

src/wotu-ui.css → dist/yvan-ext-mobile.css


Fichier diff supprimé car celui-ci est trop grand
+ 40774 - 0
dist/yvan-ext-mobile.js


Fichier diff supprimé car celui-ci est trop grand
+ 1 - 0
dist/yvan-ext-mobile.js.map


+ 1 - 38
package.json

@@ -6,47 +6,10 @@
   "main": "dist/yvan-ext-mobile.js",
   "typings": "dist/index.d.ts",
   "scripts": {
-    "clean": "rimraf dist/",
-    "dev": "rollup -w -c build/rollup.amd.js --environment NODE_ENV:development",
-    "tsd": "tsc --emitDeclarationOnly",
-    "build": "rollup -c build/rollup.amd.js --environment NODE_ENV:development"
+    "build": "yarn -v"
   },
   "devDependencies": {
-    "@rollup/plugin-json": "^4.1.0",
-    "@types/jest": "^24.0.12",
-    "@types/jquery": "^3.3.31",
-    "@types/moment": "^2.13.0",
-    "@types/lodash": "^4.14.149",
-    "@types/qs": "^6.5.1",
-    "@types/rollup": "^0.54.0",
-    "cssnano": "^4.1.10",
-    "postcss-cssnext": "^3.1.0",
-    "postcss-less-engine": "^0.6.2",
-    "postcss-nested": "^4.2.1",
-    "postcss-simple-vars": "^5.0.2",
-    "prettier": "^1.18.2",
-    "prettier-config-standard": "^1.0.1",
-    "reflect-metadata": "^0.1.13",
-    "rimraf": "^3.0.2",
-    "rollup": "^1.27.0",
-    "rollup-plugin-amd": "^4.0.0",
-    "rollup-plugin-commonjs": "^10.1.0",
-    "rollup-plugin-node-builtins": "^2.1.2",
-    "rollup-plugin-node-resolve": "^5.2.0",
-    "rollup-plugin-postcss": "2.8.2",
-    "rollup-plugin-replace": "^2.2.0",
-    "rollup-plugin-terser": "^5.1.2",
-    "rollup-plugin-typescript": "^1.0.1",
-    "rollup-plugin-typescript2": "^0.25.2",
-    "rollup-plugin-uglify": "^6.0.4",
-    "tslib": "^1.11.1",
-    "typescript": "~3.8.3"
   },
   "dependencies": {
-    "axios": "^0.20.0",
-    "qs": "6.5.1",
-    "lodash": "^4.14.149",
-    "jquery": "^3.6.0",
-    "json5": "^2.2.0"
   }
 }

+ 0 - 0
rollup.build.css


+ 0 - 221
src/Defaults.ts

@@ -1,221 +0,0 @@
-const labelWidth = 80
-
-export const windows = {
-    modal: true,
-    width: 900,
-    height: 600,
-    maximizable: true,
-    constrain: true,
-    shadow: false,
-    // manageHeight: true,
-    // draggable: true,
-    // scrollable: true,
-}
-
-export const date = {
-    labelAlign: 'right',
-    labelWidth,
-}
-
-export const combo = {
-    labelAlign: 'right',
-    labelWidth,
-    valueField: 'id',
-    displayField: 'text',
-    autoLoad: true,
-    mode: 'local',
-    forceSelection: true,
-    triggerAction: 'all',
-    enableKeyEvents: true,
-}
-
-export const comboGrid = {
-    selectOnTab: true,
-    pickerHeight: 500,
-    pickerWidth: 850,
-    editEnable: null,
-}
-
-export const comboGridPicker = {
-    xtype: 'yvgrid',
-    layout: 'fit',
-    selModel: {
-        selType: 'rowmodel',
-        mode: 'SINGLE'
-    },
-}
-
-export const comboGridMulti = {
-    selectOnTab: true,
-    pickerHeight: 500,
-    pickerWidth: 850,
-    editEnable: null,
-    splitChar: ',',
-    displayField: 'text',
-    valueField: 'id',
-    autoLoad: true,
-}
-
-export const comboGridMultiPicker = {
-    selType: 'checkboxmodel',
-    selModel: {
-        type: 'checkboxmodel',
-        checkOnly: false
-    },
-}
-
-export const numberfield = {
-    labelAlign: 'right',
-    labelWidth,
-}
-
-export const checkbox = {
-    labelAlign: 'right',
-    labelWidth,
-    checkedValue: true,
-    uncheckedValue: false,
-}
-
-export const checkboxgroup = {
-    labelAlign: 'right',
-    labelWidth,
-}
-
-export const radio = {
-    labelAlign: 'right',
-    labelWidth,
-}
-
-export const radiogroup = {
-    labelAlign: 'right',
-    labelWidth,
-    simpleValue: true,
-    layout: 'hbox',
-    defaults: {
-        xtype: 'radio',
-        name: 'type',
-        margin: '0 15 0 0'
-    },
-}
-
-export const form = {
-    margin: '5 5 0 0',
-    border: false,
-    defaults: {
-        margin: '0 0 5 0',
-        border: false,
-    },
-}
-
-export const column = {
-    menuDisabled: true
-}
-
-export const grid = {
-    border: true,
-    columnLines: true,
-    rowLines: true,
-    plugins: {
-        cellediting: {
-            clicksToEdit: 1
-        },
-        gridfilters: true
-    },
-    multiColumnSort: true,
-    viewConfig: {
-        enableTextSelection: true,
-        sortOnClick: false,
-    },
-    selModel: {
-        type: 'checkboxmodel',
-        checkOnly: false
-    },
-    pagination: true,
-    pageSize: 50,
-    pageSizeOption: ['20', '50', '100', '200', '300'],
-    hideFootbar: false,
-    hideRefresh: false,
-    hideExport: false,
-    hideAutoSize: false,
-    hideClearFilter: false,
-    hideSaveGridUIConfig: false,
-    hideClearGridUIConfig: false,
-    autoLoad: true,
-    remoteSort: false,
-    remoteFilter: false,
-    enableLocking: true,
-    enableColumnMove: true,
-    enableColumnHide: true,
-    enableColumnResize: true,
-    hidden: false,
-    disabled: false,
-    exportExcelPageSize: 100,
-    exportExcelCurrentPage: 1,
-    exportExcelTotal: 0,
-}
-
-export const fieldContainer = {
-    labelAlign: 'right',
-    labelWidth,
-    layout: 'hbox',
-    defaults: {
-        flex: 1,
-    }
-}
-
-export const tree = {
-    autoLoad: true,
-    hideFilter: false,
-    hideToolbar: false,
-    hideRefresh: false,
-    hideExpand: false,
-    hideCollapse: false,
-}
-
-export const search = {
-    labelAlign: 'right',
-    labelWidth,
-}
-
-export const text = {
-    labelAlign: 'right',
-    labelWidth,
-    msgTarget: 'qtip',
-}
-
-export const toolbar = {
-    overflowHandler: 'menu',
-}
-
-export const tbfill = {}
-
-export const tbseparator = {}
-
-export const button = {}
-
-export const fieldSet = {
-    margin: '5 5 0 0',
-    border: false,
-    defaults: {
-        margin: '0 0 5 0',
-        border: false,
-    },
-}
-
-export const storeAjax = {
-    timeout: 60000
-}
-
-export const panel = {}
-
-export const splitter = {}
-
-export const maintab = {}
-
-export const rows = {}
-
-export const cols = {
-    defaults: {
-        flex: 1
-    },
-}

+ 0 - 106
src/PropertyDescription.ts

@@ -1,106 +0,0 @@
-import _ from 'lodash'
-
-export type GroupType = 'css' | 'data' | 'bind' | 'common' | 'event'
-
-export interface PropertyValue {
-  /**
-   * 属性名
-   */
-  name: string
-
-  /**
-   * 默认值
-   */
-  default: any
-
-  /**
-   * 隶属分组
-   */
-  group: GroupType
-
-  /**
-   * 描述
-   */
-  desc: string
-
-  /**
-   * 取值范围
-   */
-  type:
-    | 'boolean'
-    | 'number'
-    | 'string'
-    | 'object'
-    | 'dataSource'
-    | 'valid'
-    | 'format'
-    | Array<string>
-    | 'widget'
-
-  eventParamter?: string[]
-
-  eventResult?: string
-
-  eventDoc?:(vjson:any)=>string
-
-  expr?: boolean,
-}
-
-export interface EventValue {
-  /**
-   * 属性名
-   */
-  name: string
-
-  /**
-   * 描述
-   */
-  desc: string
-}
-
-export interface PropertyDescriptionInterface {
-  props: PropertyValue[]
-  events?: EventValue[]
-}
-
-export class PropertyDescription {
-  propertyes: PropertyDescriptionInterface = {
-    props: [],
-    events: []
-  }
-
-  constructor(...args: PropertyDescriptionInterface[]) {
-    _.each(args, arg => {
-      this.merge(arg)
-    })
-  }
-
-  merge(pd: PropertyDescriptionInterface) {
-    this.propertyes.props = <any>(
-      _.uniqBy([...this.propertyes.props, ...pd.props], 'name')
-    )
-    if (pd.events) {
-      if (this.propertyes.events) {
-        this.propertyes.events = <any>(
-          _.uniqBy([...this.propertyes.events, ...pd.events], 'name')
-        )
-      } else {
-        this.propertyes.events = <any>_.uniqBy([...pd.events], 'name')
-      }
-    }
-  }
-
-  /**
-   * 根据分组名 获取属性定义
-   */
-  getPropsByGroup(name: GroupType): PropertyValue[] {
-    return _.filter(this.propertyes.props, i => i.group === name)
-  }
-
-  /**
-   * 获取全部事件
-   */
-  getEvents(): EventValue[] {
-    return this.propertyes.events!
-  }
-}

+ 0 - 507
src/PropertyDescriptionTable.ts

@@ -1,507 +0,0 @@
-import _ from 'lodash'
-import {PropertyDescription, PropertyDescriptionInterface, PropertyValue} from './PropertyDescription'
-
-export const PropertyDescriptionTable = new Map<String, PropertyDescription>()
-
-PropertyDescriptionTable.set(
-    'tabCell',
-    new PropertyDescription({
-        props: [
-            {
-                name: 'header',
-                default: '',
-                group: 'common',
-                desc: '选项卡名称',
-                type: 'string'
-            },
-            {
-                name: 'close',
-                default: '',
-                group: 'common',
-                desc: '是否允许关闭',
-                type: 'boolean'
-            },
-        ]
-    })
-)
-
-export const width: PropertyValue = {
-    name: 'width',
-    default: '',
-    group: 'common',
-    desc: '宽',
-    type: 'number'
-}
-
-export const height: PropertyValue = {
-    name: 'height',
-    default: '',
-    group: 'common',
-    desc: '高',
-    type: 'number'
-}
-
-export const fieldLabel: PropertyValue = {
-    name: 'fieldLabel',
-    default: '',
-    group: 'common',
-    desc: '文本描述',
-    type: 'string',
-    expr: true,
-};
-
-export const text: PropertyValue = {
-    name: 'text',
-    default: '',
-    group: 'common',
-    desc: '文本描述',
-    type: 'string',
-    expr: true,
-};
-
-export const iconCls: PropertyValue = {
-    name: 'iconCls',
-    default: '',
-    group: 'common',
-    desc: '图标',
-    type: 'string',
-    expr: true,
-};
-
-export const borderless: PropertyValue = {
-    name: 'borderless',
-    default: '',
-    group: 'css',
-    desc: '是否有边框',
-    type: 'boolean',
-};
-export const labelAlign: PropertyValue = {
-    name: 'labelAlign',
-    default: '',
-    group: 'common',
-    desc: '描述对齐方式',
-    type: ['left', 'right', 'center']
-};
-export const type: PropertyValue = {
-    name: 'type',
-    default: '',
-    group: 'css',
-    desc: '容器内部线类型',
-    type: ['line', 'clean', 'wide', 'space', 'form']
-};
-export const labelWidth: PropertyValue = {
-    name: 'labelWidth',
-    default: undefined,
-    group: 'common',
-    desc: '文本宽度',
-    type: 'number'
-};
-export const gravity: PropertyValue = {
-    name: 'gravity',
-    default: 1,
-    group: 'common',
-    desc: '占位权重',
-    type: 'number'
-};
-export const hidden: PropertyValue = {
-    name: 'hidden',
-    default: false,
-    group: 'common',
-    desc: '隐藏',
-    type: 'boolean',
-    expr: true,
-};
-export const readonly: PropertyValue = {
-    name: 'readonly',
-    default: false,
-    group: 'common',
-    desc: '只读',
-    type: 'boolean',
-    expr: true,
-};
-export const disabled: PropertyValue = {
-    name: 'disabled',
-    default: false,
-    group: 'common',
-    desc: '禁用',
-    type: 'boolean',
-    expr: true,
-};
-export const loading: PropertyValue = {
-    name: 'loading',
-    default: false,
-    group: 'common',
-    desc: '载入中',
-    type: 'boolean',
-    expr: true,
-};
-export const required: PropertyValue = {
-    name: 'required',
-    default: false,
-    group: 'common',
-    desc: '必填',
-    type: 'boolean',
-    expr: true,
-};
-export const value: PropertyValue = {
-    name: 'value',
-    default: '',
-    group: 'common',
-    desc: '字段值',
-    type: 'string',
-    expr: true,
-};
-export const prompt: PropertyValue = {
-    name: 'prompt',
-    default: '请输入',
-    group: 'common',
-    desc: '水印',
-    type: 'string'
-};
-export const validType: PropertyValue = {
-    name: 'validType',
-    default: '',
-    group: 'common',
-    desc: '校验类型',
-    type: 'valid'
-};
-export const metaId: PropertyValue = {
-    name: 'metaId',
-    default: '',
-    group: 'bind',
-    desc: '元数据ID',
-    type: 'string'
-};
-export const template: PropertyValue = {
-    name: 'template',
-    default: '',
-    group: 'common',
-    desc: 'HTML内容',
-    type: 'string',
-    expr: true,
-}
-
-export const tooltip: PropertyValue = {
-    name: 'tooltip',
-    default: '',
-    group: 'common',
-    desc: '悬停提示',
-    type: 'string'
-}
-
-export const onClick: PropertyValue = {
-    name: 'onClick',
-    default: '',
-    group: 'event',
-    desc: '点击事件',
-    eventParamter: [
-        'sender: YvanUI.CtlButton',
-        'e: any'
-    ],
-    eventDoc(vjson) {
-        return (vjson['text'] ? vjson['text'] : '按钮') + '被点击后触发';
-    },
-    type: 'string'
-}
-
-PropertyDescriptionTable.set(
-    'rows',
-    new PropertyDescription({
-        props: [
-            gravity,
-            width
-        ]
-    })
-)
-
-PropertyDescriptionTable.set(
-    'cols',
-    new PropertyDescription({
-        props: [
-            gravity,
-            height
-        ]
-    })
-)
-
-PropertyDescriptionTable.set(
-    'window',
-    new PropertyDescription({
-        props: [
-            {
-                name: '_designMode',
-                default: 'module',
-                group: 'common',
-                desc: '设计类型',
-                type: ['none', 'dialog', 'scroll-dialog']
-            },
-            {
-                name: 'title',
-                default: '',
-                group: 'common',
-                desc: '对话框标题',
-                type: 'string'
-            },
-            {
-                name: 'modal',
-                default: '',
-                group: 'common',
-                desc: '是否模态',
-                type: 'boolean'
-            },
-            _.merge(_.cloneDeep(width), {default: 200}),
-            _.merge(_.cloneDeep(height), {default: 200}),
-            {
-                name: 'top',
-                default: 200,
-                group: 'common',
-                desc: '顶像素',
-                type: 'number'
-            },
-            {
-                name: 'left',
-                default: 200,
-                group: 'common',
-                desc: '左像素',
-                type: 'number'
-            }
-        ]
-    })
-)
-
-PropertyDescriptionTable.set(
-    'layout',
-    new PropertyDescription({
-        props: [
-            {
-                name: 'borderless',
-                default: true,
-                group: 'css',
-                desc: '有无边框',
-                type: 'boolean'
-            },
-            {
-                name: 'type',
-                default: '',
-                group: 'css',
-                desc: '布局类型',
-                type: ['line', 'clean', 'wide', 'space', 'form']
-            },
-            {
-                name: '_designMode',
-                default: 'module',
-                group: 'common',
-                desc: '设计类型',
-                type: ['none', 'module', 'scroll-module']
-            }
-        ]
-    })
-)
-
-export const YvBase: PropertyDescriptionInterface = {
-    props: [
-        {
-            name: 'bind',
-            default: '',
-            group: 'bind',
-            desc: '实体类名',
-            type: 'string'
-        },
-        {
-            name: 'ref',
-            default: '',
-            group: 'bind',
-            desc: '控件名',
-            type: 'string'
-        },
-        {
-            name: 'css',
-            default: '',
-            group: 'css',
-            desc: '样式类名',
-            type: 'string'
-        },
-        {
-            name: 'hidden',
-            default: false,
-            group: 'common',
-            desc: '是否显示',
-            type: 'boolean'
-        },
-        {
-            name: 'padding',
-            default: undefined,
-            group: 'css',
-            desc: '内边距',
-            type: 'object'
-        },
-        {
-            name: 'margin',
-            default: undefined,
-            group: 'css',
-            desc: '外边距',
-            type: 'object'
-        },
-        {
-            name: 'ff',
-            default: 0,
-            group: 'common',
-            desc: '自动定焦时间',
-            type: 'number'
-        },
-        width, height,
-        {
-            name: 'autowidth',
-            default: false,
-            group: 'common',
-            desc: '自动计算宽度',
-            type: 'boolean'
-        },
-        {
-            name: 'autoheight',
-            default: false,
-            group: 'common',
-            desc: '自动计算高度',
-            type: 'boolean'
-        },
-    ],
-    events: [
-        {name: 'onRender', desc: '第一次控件被渲染时触发'}
-    ]
-}
-
-export const YvDataSource: PropertyDescriptionInterface = {
-    props: [
-        {
-            name: 'type',
-            default: '',
-            group: 'data',
-            desc: '数据源类型',
-            type: 'dataSource'
-        }
-    ],
-    events: [{name: 'onDataComplete', desc: '数据绑定完成后触发'}]
-}
-
-PropertyDescriptionTable.set(
-    'template',
-    new PropertyDescription(YvBase, {
-        props: [
-            template
-        ]
-    })
-)
-
-PropertyDescriptionTable.set(
-    'fieldset',
-    new PropertyDescription(YvBase, {
-        props: [
-            {
-                name: 'label',
-                default: '',
-                group: 'common',
-                desc: '字段组标题',
-                type: 'string'
-            }
-        ]
-    })
-)
-
-PropertyDescriptionTable.set(
-    'iframe',
-    new PropertyDescription(YvBase, {
-        props: [
-            {
-                name: 'src',
-                default: '',
-                group: 'common',
-                desc: '地址路径',
-                type: 'string'
-            }
-        ]
-    })
-)
-
-PropertyDescriptionTable.set(
-    'uploader',
-    new PropertyDescription(YvBase, {
-        props: [
-            width, height,
-            {
-                name: 'value',
-                default: '上传',
-                group: 'common',
-                desc: '文本描述',
-                type: 'string'
-            },
-            {
-                name: 'upload',
-                default: '/upload',
-                group: 'common',
-                desc: '上传地址',
-                type: 'string'
-            },
-        ],
-        events: [
-            {name: 'onFileUpload', desc: '文件上传成功结束时触发'},
-            {name: 'onFileUploadError', desc: '在上传过程中发生服务器端错误时触发'},
-        ]
-    })
-)
-
-PropertyDescriptionTable.set(
-    'viewer',
-    new PropertyDescription(YvBase, {
-        props: [
-            value,
-            gravity,
-            {
-                name: 'imgWidth',
-                default: '',
-                group: 'common',
-                desc: '图片宽',
-                type: 'string'
-            },
-            {
-                name: 'imgHeight',
-                default: '',
-                group: 'common',
-                desc: '图片高',
-                type: 'string'
-            }
-        ]
-    })
-)
-
-PropertyDescriptionTable.set(
-    'image',
-    new PropertyDescription(YvBase, {
-        props: [
-            value,
-            gravity,
-            {
-                name: 'imgWidth',
-                default: '',
-                group: 'common',
-                desc: '图片宽',
-                type: 'string'
-            },
-            {
-                name: 'imgHeight',
-                default: '',
-                group: 'common',
-                desc: '图片高',
-                type: 'string'
-            }
-        ]
-    })
-)
-
-PropertyDescriptionTable.set(
-    'scrollview',
-    new PropertyDescription(YvBase, {
-        props: [
-            width, height
-        ]
-    })
-)

+ 0 - 314
src/Scope.ts

@@ -1,314 +0,0 @@
-import _ from 'lodash'
-import {lookupScope} from "./lib/lib";
-
-export class Scope {
-    private static readonly SHOW_PAGE_STACK: Scope[] = [];
-
-    /**
-     * 业务模块的唯一编号
-     */
-    id = _.uniqueId('scope_')
-
-    /**
-     * 构造函数传入的最初始的 vjson
-     */
-    originalVjson
-
-    /**
-     * 一个 ExtJS 能接受的配置对象
-     */
-    vjson
-
-    /**
-     * 原始 vjsonModel 对象
-     */
-    model
-
-    /**
-     * 双向绑定的模型对象
-     */
-    viewModel
-
-    /**
-     * 构建完成之后的 Ext控件句柄
-     */
-    _handle
-
-    /**
-     * 页面显示的时候带的参数 在设计刷新的时候使用
-     */
-    _vjsonOption
-    _dataOption
-
-    /**
-     * 最顶部的 scope 对象
-     */
-    topScope
-
-    _lastShowTime = 0
-
-    constructor({model, vjson}) {
-        const that = this
-        this.model = model
-        this.originalVjson = _.cloneDeep(vjson)
-        this.vjson = this.originalVjson // this.buildVjson()
-    }
-
-    /**
-     * 模块载入完成之后的回调
-     */
-    onLoad() {
-
-    }
-
-    /**
-     * 组件卸载之后的回调
-     */
-    onDestroy() {
-
-    }
-
-    get isScope() {
-        return true;
-    }
-
-    /**
-     * 产生一个当前模块有效的唯一id
-     * @param key 唯一编号
-     */
-    uid(key) {
-        return this.id + key
-    }
-
-    _onDestroy() {
-        this.onDestroy()
-    }
-
-    _onLoad() {
-        this.onLoad()
-    }
-
-    showMainWindow() {
-        const handle = (window as any).mainWindow?._handle
-        if (handle) {
-            handle.setStyle({'z-index': 1})
-            Ext.Viewport.getLayout().setAnimation({type: 'slide', direction: 'right', duration: 300})
-            Ext.Viewport.setActiveItem(handle)
-            Scope.SHOW_PAGE_STACK.length = 0
-            Scope.SHOW_PAGE_STACK.push((window as any).mainWindow)
-        }
-    }
-
-    /**
-     * 渲染模块到全屏
-     * allowBack 是否允许后退(退出)
-     * vjsonOption 界面覆盖选项(可以为空)
-     * dataOption 数据覆盖选项(可以为空)
-     */
-    render(option = {
-        allowBack: true,
-        vjsonOption: {},
-        dataOption: {}
-    }) {
-        const that = this
-        let has = false;
-        (Ext.Viewport.getItems().items as []).forEach((item, idx) => {
-            if (!has && item === that._handle) {
-                has = true
-            }
-        })
-        if (!has) {
-            _.defaults(option, {
-                allowBack: true,
-                vjsonOption: {},
-                dataOption: {}
-            })
-            const {
-                allowBack,
-                vjsonOption,
-                dataOption
-            } = option
-            this._vjsonOption = vjsonOption;
-            this._dataOption = dataOption;
-            const vmodel = _.defaultsDeep({
-                data: {}
-            }, that.model, dataOption)
-
-            //this.viewModel = new Ext.app.ViewModel(vmodel);
-            //this.viewModel.yvanScope = this
-
-            let config = _.defaultsDeep({
-                    // viewModel: this.viewModel,
-                    viewModel: vmodel,
-                    yvanScope: this,
-                    referenceHolder: true,
-                },
-                vjsonOption,
-                that.vjson,
-                {
-                    xtype: 'panel',
-                    // showAnimation: 'slide',
-                    // hideAnimation: 'slideOut',
-                }
-            )
-
-            if (allowBack) {
-                config = _.defaultsDeep({
-                    iconCls: 'x-fa fa-angle-left',
-                    cls: 'navbar',
-                    tools: [
-                        {
-                            iconCls: 'x-fa fa-home',
-                            handler: function () {
-                                that.showMainWindow()
-                            },
-                        },
-                    ],
-                }, config)
-            }
-            that._handle = Ext.create(config)
-            this.viewModel = that._handle.getViewModel()
-            this.viewModel.yvanScope = this
-            that._handle.on({
-                renderedchange(sender, item, rendered, opts) {
-                    // 记录句柄
-                    if (rendered) {
-                        that._handle = this
-                        window['cp'] = that
-
-                        // 调用onLoad回调
-                        try {
-                            that._onLoad()
-                        } catch (e) {
-                            console.error('errorAt onLoad', e)
-                        }
-                        const $back = $(sender.el.dom)
-                            .find('.navbar>.x-panelheader')
-                            .find('.x-body-el>.fa-angle-left')
-                        $back.off('click');
-                        $back.on('click', () => {
-                            const handle = Ext.Viewport.getActiveItem();
-                            // 显示前一个页面
-                            const index = Scope.SHOW_PAGE_STACK.findIndex(scope => scope._handle === handle);
-                            // console.log("###### remove", index)
-                            if (index >= 0) {
-                                Scope.SHOW_PAGE_STACK.splice(index, 1);
-                            }
-                            const scopeArr = _.sortBy(Scope.SHOW_PAGE_STACK, scope => scope._lastShowTime)
-                            if (scopeArr.length > 0) {
-                                const scope = scopeArr[scopeArr.length - 1]
-                                scope._handle.setStyle({'z-index': 1})
-                                Ext.Viewport.getLayout().setAnimation({type: 'slide', direction: 'right', duration: 300})
-                                Ext.Viewport.setActiveItem(scope._handle)
-                                scope._lastShowTime = new Date().getTime()
-                                // console.log("###### show", (scopeArr.length - 1), Scope.SHOW_PAGE_STACK)
-                            }
-                            // 关闭
-                            handle.setStyle({'z-index': 0})
-                            // Ext.Viewport.getLayout().setAnimation({type: 'slide', direction: 'right', duration: 300})
-                            Ext.Viewport.remove(handle)
-                            handle.close()
-                        })
-                    }
-                },
-                destroy() {
-                    // 卸载
-                    window['cp'] = Ext.Viewport.items?.getAt(Ext.Viewport.items.items.length - 2)?.getViewModel()?.yvanScope
-                    that._onDestroy()
-                },
-            })
-        } else {
-            window['cp'] = that
-            // 调用onLoad回调
-            try {
-                that._onLoad()
-            } catch (e) {
-                console.error('errorAt onLoad', e)
-            }
-        }
-        Ext.Viewport.add(that._handle)
-        if ((window as any).mainWindow === that || (window as any).loginWindow === that) {
-            Scope.SHOW_PAGE_STACK.length = 0
-        }
-        that._handle.setStyle({'z-index': 1})
-        let actived = false;
-        (Ext.Viewport.getItems().items as []).forEach((item, idx) => {
-            if (!actived && item === that._handle) {
-                actived = true
-                Ext.Viewport.getLayout().setAnimation({type: 'slide', direction: 'left', duration: 300})
-                Ext.Viewport.setActiveItem(idx)
-                that._lastShowTime = new Date().getTime()
-                Scope.SHOW_PAGE_STACK.push(that)
-            }
-        })
-        return that._handle
-    }
-
-    /**
-     * 对话框"保存"成功.
-     * 关闭对话框,并响应 success 方法
-     * @param data 要傳回的數據(可以為空)
-     */
-    dialogSuccess(data?) {
-        this._handle.fireEvent('success', this, data)
-        const sender = this._handle.config.animateTarget
-        const scope = lookupScope(sender)
-        if (typeof this['success'] === 'function') {
-            this['success'].call(scope, sender, data)
-        }
-        this.close()
-    }
-
-    /**
-     * 设置等待状态
-     * @param value
-     * @param msg
-     */
-    setLoading(value: boolean) {
-        const scope = this
-        if (value) {
-            scope?._handle?.setMasked({xtype: 'loadmask', message: '请稍等...'});
-        } else {
-            scope?._handle?.unmask();
-        }
-        // scope._handle?.setLoading(value)
-    }
-
-    /**
-     * 关闭对话框(或标签页)
-     */
-    close() {
-        this._handle.close()
-    }
-
-    /**
-     * 获取 viewModel 里包含的数据(只读)
-     */
-    get data() {
-        return this.viewModel.getData()
-    }
-
-    /**
-     * 设置 viewModel 中的数据
-     * 可以是 key, value 模式
-     * 也可以是 {key:value} 模式
-     */
-    set(path, value) {
-        return this.viewModel.set(path, value)
-    }
-
-    /**
-     * 寻找模块内所有的 xtype 对应的对象
-     * @param xtypeKey
-     */
-    down(xtypeKey) {
-        return this._handle.down(xtypeKey)
-    }
-
-    /**
-     * 获取所有设置过 Reference 名称的组件
-     */
-    get refs() {
-        return this._handle.getReferences()
-    }
-}

+ 0 - 55
src/controls/base.ts

@@ -1,55 +0,0 @@
-import _ from 'lodash'
-
-type DragType = 'rows-container' | 'cols-container' | 'col-item' | 'row-item'
-
-/**
- * 构建所有组件的公共属性
- * @param config 原始config
- * @param dragType 组件模式
- *      不填,代表不能在设计时被拖拽
- *      row-container 是一个rows容器
- *      col-container 是一个cols容器
- *      col-item cols中的一个格子(非容器),比如 textfield / combofield 等等
- *      row-item rows中的一行,比如 tree / grid / panel 等等
- */
-export function baseConfig(config, dragType?: DragType) {
-    if (config && config.designMode && dragType) {
-
-        let cc = ''
-        switch (dragType) {
-            case "cols-container":
-                cc = 'design_cols_container'
-                break
-
-            case "col-item":
-                cc = 'design_col_item'
-                break
-
-            case "rows-container":
-                cc = 'design_rows_container'
-                break
-
-            case "row-item":
-                cc = 'design_row_item'
-                break
-        }
-
-        if (typeof config.cls === 'string') {
-            _.extend(config, {
-                cls: [config.cls, 'yvan_design', cc]
-            })
-
-        } else if (_.isArray(config.cls)) {
-            _.extend(config, {
-                cls: [...config.cls, 'yvan_design', cc]
-            })
-
-        } else {
-            _.extend(config, {
-                cls: ['yvan_design', cc]
-            })
-        }
-    }
-
-    return config
-}

+ 0 - 24
src/controls/cols.js

@@ -1,24 +0,0 @@
-import _ from 'lodash'
-import {cols} from '../Defaults'
-import {baseConfig} from "./base";
-
-export default function () {
-
-    Ext.define('Yvan.Cols', {
-        extend: 'Ext.container.Container',
-        xtype: 'cols',
-
-        constructor(config) {
-            const self = this
-            const newConfig = _.defaultsDeep({
-                // 强制性属性
-                layout: 'hbox',
-                minHeight: config.designMode ? 32 : 0
-
-            }, baseConfig(config, 'cols-container'), config, cols)
-
-            this.superclass.constructor.call(self, newConfig)
-        },
-    });
-
-}

+ 0 - 460
src/controls/grid.js

@@ -1,460 +0,0 @@
-import _ from 'lodash'
-import {grid} from '../Defaults'
-import {baseConfig} from "./base";
-import {lookupFn, lookupScope} from "../lib/lib";
-import {
-    disabled,
-    fieldLabel,
-    gravity,
-    height,
-    metaId,
-    PropertyDescriptionTable,
-    tooltip,
-    value,
-    width,
-    YvBase
-} from "../PropertyDescriptionTable";
-import {PropertyDescription} from "../PropertyDescription";
-import {gridInvokeBuild} from "./stores";
-import {msg} from 'src/message';
-
-
-const defaultGrid = grid
-export default function () {
-
-    Ext.define('Yvan.Grid', {
-        extend: 'Ext.grid.Grid',
-        xtype: 'yvgrid',
-
-        constructor(config) {
-            const me = this
-            const {dataSource} = config
-            if (!window["IS_DESIGN_MODE"]) {
-                this.columnConfigCacheKey = this.makeColumnConfigCacheKey(config)
-                if (Array.isArray(config.columns) && config.columns.length > 0) {
-                    const cacheData = this.getColumnConfigCache()
-                    if (Array.isArray(cacheData) && cacheData.length > 0) {
-                        const newColumns = []
-
-                        for (let j = 0; j < cacheData.length; j++) {
-                            const itData = cacheData[j]
-                            for (let i = 0; i < config.columns.length; i++) {
-                                const column = config.columns[i]
-                                if (itData.dataIndex === column.dataIndex) {
-                                    if (itData.width) {
-                                        column.width = itData.width
-                                    }
-                                    column.hidden = itData.hidden
-                                    column.locked = itData.locked
-                                    newColumns.push(column)
-                                    break
-                                }
-                            }
-                        }
-                        config.columns = newColumns
-                    }
-                }
-            }
-            const newConfig = _.defaultsDeep({
-                // 强制性属性 bug.
-                // lock 属性会造成 Cannot read properties of undefined (reading 'els')
-                // enableLocking: false,
-                // syncRowHeight: false,
-
-            }, baseConfig(config, 'row-item'), config, grid)
-
-            // 在面板上的组件
-            const scope = newConfig.$initParent.yvanScope || newConfig.$initParent.lookupReferenceHolder().yvanScope;
-
-            const buttons = []
-
-            const {getRowClass} = newConfig
-            if (typeof getRowClass === 'string' && (
-                _.startsWith(getRowClass, "scope.") ||
-                _.startsWith(getRowClass, "system."))
-            ) {
-                const fn = lookupFn(scope, getRowClass)
-                _.set(newConfig, 'viewConfig.getRowClass', fn)
-            }
-
-            if (!newConfig.hideAutoSize) {
-                buttons.push({
-                    xtype: 'button',
-                    iconCls: 'x-fa fa-text-width',
-                    tooltip: '自适应宽度',
-                    listeners: {
-                        click: this.autoSizeColumns
-                    }
-                })
-            }
-
-            _.each(newConfig.columns, c => {
-                const {renderer} = c
-                if (typeof renderer === 'string' && (
-                    _.startsWith(renderer, "scope.") ||
-                    _.startsWith(renderer, "system."))
-                ) {
-                    if (newConfig.$initParent) {
-                        if (scope) {
-                            const rendererFn = lookupFn(scope, renderer)
-                            c.renderer = rendererFn
-                        }
-                    }
-                }
-            })
-
-            this.superclass.constructor.call(this, newConfig)
-            // this.store.pageSize = newConfig.pageSize
-        },
-
-        setData(value) {
-            const me = this
-            me._setDataReal(value)
-        },
-
-        /**
-         * 添加行,并进入编辑状态
-         * @param record 新行的属性集
-         * @param editRowCol 要编辑的列序号,或 dataIndex 的名称
-         */
-        appendEditRow(record, editRowCol) {
-            const records = this.getStore().add(record)
-            const recNew = records[0]
-            this.setSelection(records)
-
-            if (typeof editRowCol === 'string' && editRowCol) {
-                editRowCol = this.columns.findIndex((c) => c.dataIndex === editRowCol)
-            }
-
-            if (typeof editRowCol === 'number') {
-                const ce = this.findPlugin('cellediting')
-                this.editingPlugin = ce
-                ce.startEdit(recNew, editRowCol)
-            }
-        },
-
-        /**
-         * 移除行
-         * @param record 如果记录传空,就是当前选中的行
-         */
-        removeEditRow(record) {
-            if (!record) {
-                record = this.selection
-            }
-
-            if (!record) {
-                msg('请选中要删除的行')
-                return
-            }
-
-            this.getStore().remove(record)
-        },
-
-        /**
-         * 获取全部原始数据
-         */
-        getDataRows() {
-            return this.getStore().data.items.map(r => r.data)
-        },
-
-        getEditRecord() {
-            const me = this
-            const editingPlugin = me.editingPlugin || me.ownerGrid.editingPlugin
-            const rowIdx = editingPlugin?.activeEditor?.context?.rowIdx
-
-            let record;
-            if (!rowIdx) {
-                record = me.getSelectionModel().getLastSelected()
-            } else {
-                record = me.store.getAt(rowIdx)
-            }
-
-            return record
-        },
-
-        getEditRow() {
-            const me = this
-            return me.getEditRecord()?.data
-        },
-
-        setEditRow(rowValues) {
-            const me = this
-            const record = me.getEditRecord()
-            if (record) {
-                _.forOwn(rowValues, (v, k) => {
-                    record.set(k, v)
-                })
-            }
-        },
-
-        _transform(data) {
-            // 无论是 grid._setDataReal 还是 stores.gridInvokeBuild 都会走这个函数,设值前都可以改变表格值
-            _.forEach(data, row => {
-                row._origin = _.clone(row)
-            })
-        },
-
-        _setDataReal(value) {
-            const me = this
-            this._transform(value)
-            me.setStore(new Ext.data.Store({
-                fields: getFileds(this),
-                data: value
-            }))
-        },
-
-        /**
-         * 轻量级刷新
-         */
-        refreshData() {
-            const store = this.getStore()
-            if (store) {
-                store.reload()
-            }
-        },
-
-        /**
-         * 为表格强制设置焦点
-         * @param seq 顺序号
-         */
-        focusRow(seq) {
-            this.setSelection(this.store.getAt(seq))
-            this.getView().focusRow(seq)
-        },
-
-        /**
-         * 重新载入数据(重新计算参数)
-         */
-        reload(reloadParams = {}) {
-            const me = this
-            const {config} = me
-
-            if (config.dataSourceCallbackFn) {
-                // 函数请求刷新
-                const scope = lookupScope(this)
-                _.defer(() => {
-                    me.setLoading(true)
-                })
-                config.dataSourceCallbackFn.call(scope, me, {
-                    successCallback(value) {
-                        me._setDataReal(value)
-                        _.defer(() => {
-                            me.setLoading(false)
-                        })
-                        me.fireEvent('dataLoadComplete', me, true, value);
-                    },
-                    failCallback(error) {
-                        _.defer(() => {
-                            me.setLoading(false)
-                        })
-                        me.fireEvent('dataLoadComplete', me, false, error);
-                    }
-                })
-                return
-            }
-
-            // if (this.store) {
-            //     this.store.reload({aaaa: 1, bbbb: 2})
-            // }
-            const {dataSource} = config
-            if (_.isPlainObject(dataSource) && !window["IS_DESIGN_MODE"]) {
-                const scope = lookupScope(me)
-                gridInvokeBuild(scope, me, config, dataSource, reloadParams)
-            }
-        },
-
-        initialize() {
-            const me = this
-            const {config} = me
-            const scope = lookupScope(this)
-
-            if (!window["IS_DESIGN_MODE"]) {
-                // 转换 dataSource 属性
-                convertDataSource(me, scope, config)
-            }
-
-            // this.on({
-            //
-            //
-            //
-            //     destory() {
-            //     },
-            // })
-
-
-            if (this.store?.proxy) {
-                // 为 stores.proxy.buildRequest 做准备
-                this.store.proxy.$owner = this
-            }
-
-            this.superclass.initialize.call(this)
-        },
-
-        afterRender() {
-            const me = this
-            const {config} = this
-            const {dataSource} = config
-
-            if (config.autoLoad) {
-                if (config.dataSourceCallbackFn) {
-                    me.reload()
-
-                } else if (_.isPlainObject(dataSource)) {
-                    me.reload()
-                }
-            }
-        },
-
-        // 生成列自定义的缓存key
-        makeColumnConfigCacheKey(config) {
-            const me = this
-            const scope = config.$initParent.yvanScope || config.$initParent.lookupReferenceHolder().yvanScope;
-            let key = "gridColumnCache-" + scope.scopeKey + "-"
-            if (config.reference) {
-                key += config.reference
-            } else {
-                let subKey = ""
-                for (let i = 0; i < config.columns.length; i++) {
-                    const column = config.columns[i]
-                    if (column.dataIndex) {
-                        subKey += column.dataIndex
-                    }
-                }
-                key += subKey
-            }
-            return key
-        },
-
-        getColumnConfigCache() {
-            const key = this.columnConfigCacheKey
-            const dataStr = localStorage.getItem(key)
-            if (dataStr) {
-                return JSON.parse(dataStr)
-            }
-            return ""
-        },
-
-        setColumnConfigCache() {
-            const key = this.columnConfigCacheKey
-            const cacheData = []
-            const columns = this.headerCt.getGridColumns()
-            let index = 0
-            for (let i = 0; i < columns.length; i++) {
-                const column = columns[i]
-                if (column.dataIndex) {
-                    cacheData.push({
-                        dataIndex: column.dataIndex,
-                        width: column.width,
-                        hidden: column.hidden,
-                        locked: column.locked,
-                        index
-                    })
-                    index++
-                }
-            }
-            localStorage.setItem(key, JSON.stringify(cacheData))
-        },
-
-        autoSizeColumns(sender) {
-            const grid = sender.up('grid')
-            // const columns = grid.columns;
-            // for (let i = 0; i < columns.length; i++) {
-            //     const column = columns[i];
-            //     grid.getView().autoSizeColumn(column);
-            //     column.setWidth(column.getWidth() + 5);
-            // }
-            for (let i = 1; i < grid.headerCt.getColumnCount(); i++) {
-                grid.headerCt.getGridColumns()[i].autoSize(i);
-                grid.headerCt.getGridColumns()[i].setWidth(grid.headerCt.getGridColumns()[i].getWidth() + 15);
-            }
-        },
-
-        clearFilter(sender) {
-            const grid = sender.up('grid')
-            grid.filters.clearFilters()
-            grid.getStore().sorters.removeAll()
-            // grid.getStore().reload()
-        },
-
-        setLoading(value) {
-            if (value) {
-                this.mask('读取中')
-            } else {
-                this.unmask()
-            }
-        },
-    })
-
-    PropertyDescriptionTable.set(
-        'yvgrid',
-        new PropertyDescription(YvBase, {
-            props: [
-                fieldLabel, value, disabled,
-                gravity, tooltip, metaId, width, height
-            ],
-        })
-    )
-}
-
-/**
- * 获取 columns 中所有的 dataIndex
- */
-function getFileds(newConfig) {
-    const fields = []
-    _.forEach(newConfig.columns, c => {
-        if (c.dataIndex) {
-            fields.push(c.dataIndex)
-        }
-    })
-    return fields
-}
-
-function convertDataSource(sender, scope, newConfig) {
-    if (typeof newConfig.store !== 'undefined') {
-        // 有 store 属性的情况下,不做任何事
-        return
-    }
-
-    if (typeof newConfig.dataSource === 'undefined') {
-        // 没有定义 dataSource 的情况下,不做任何事
-        return
-    }
-
-    if (_.isArray(newConfig.data)) {
-        // 有 data 属性赋值的情况下
-        newConfig.store = {
-            fields: getFileds(newConfig),
-            data: newConfig.data
-        }
-        delete newConfig.data
-        return
-    }
-
-    let {dataSource} = newConfig
-    if (typeof dataSource === 'string') {
-        // dataSource 是字符串的情况下,找到成员函数
-        dataSource = lookupFn(scope, dataSource)
-    }
-
-    if (typeof dataSource === 'function') {
-        // dataSource 是函数的情况下,在 afterrender 之后进行回调
-        newConfig.store = new Ext.data.Store({
-            fields: getFileds(newConfig),
-            // data: [],
-            autoLoad: true,
-            proxy: {
-                type: 'memory',
-                data: [],
-                // reader: {
-                //     type: 'json',
-                //     rootProperty: 'users'
-                // }
-            }
-        })
-        newConfig.dataSourceCallbackFn = dataSource
-        return
-    }
-
-
-    // throw new TypeError('无法识别的调用方法')
-}

+ 0 - 37
src/controls/gridcolumn.js

@@ -1,37 +0,0 @@
-import _ from "lodash";
-import {baseConfig} from "./base";
-import {column} from "../Defaults";
-
-export default function () {
-
-    const ct = Ext.grid.column.Column.prototype.constructor
-    Ext.grid.column.Column.override({
-        constructor: function (config) {
-            const newConfig = _.defaults({}, config, column)
-            if (newConfig.header && !newConfig.text) {
-                newConfig.text = newConfig.header
-            }
-            ct.call(this, newConfig)
-        }
-    });
-
-    // 227573
-    // const {onTitleElClick} = Ext.grid.column.Column.prototype
-    // Ext.define('Yvan.ColumnOverride', {
-    //     override: 'Ext.grid.column.Column',
-    //
-    //     config: {
-    //         enableSortOnClick: false,
-    //     },
-    //
-    //     // /**@Overrides*/
-    //     onTitleElClick: function (e, t, sortOnClick) {
-    //         // return this.callParent([e, t, this.enableSortOnClick && sortOnClick]);
-    //         if (!$(e.target).is('.x-column-header-trigger')) {
-    //             // 不是点击菜单的情况下,让列自适应宽度
-    //             this.autoSize()
-    //         }
-    //         return onTitleElClick.call(this, e, t, false)
-    //     }
-    // });
-}

+ 0 - 143
src/controls/stores.js

@@ -1,143 +0,0 @@
-import _ from 'lodash'
-import {lookupFn, lookupScope} from "../lib/lib";
-import {apiConvert, serverInvokeUrlTransform} from "../lib/config";
-import {calcObjectFlat} from '../lib/systemLib'
-import {storeAjax} from '../Defaults'
-
-/**
- * 构建一个 grid 支持的 dataSource
- */
-export function gridInvokeBuild(scope, grid, config, dataSource, reloadParams = {}) {
-    const me = grid
-    const params = calcObjectFlat(scope.viewModel.data, dataSource.params)
-    let storeOption = {}
-    if (dataSource.method === 'invoke') {
-
-        const fields = []
-        _.forEach(grid.columns, col => {
-            const c = {}
-            if (col.dataIndex) {
-                c.name = col.dataIndex
-                fields.push(c)
-            }
-            if (col.dataType) {
-                c.type = col.dataType
-            }
-        })
-
-        // 默认支持 gridInvoke
-        storeOption = {
-            fields,
-            // remoteSort: config.remoteSort, 虚拟store的方式不能设置此属性
-            // remoteFilter: config.remoteFilter, 虚拟store的方式不能设置此属性
-            autoLoad: true,
-            pageSize: me.store?.pageSize || config.pageSize,
-            proxy: {
-                type: 'jsonAjax',
-                $owner: me,
-                url: serverInvokeUrlTransform(dataSource.url, {scope, grid}),
-                extraParams: _.defaultsDeep({}, reloadParams, params),
-                reader: {
-                    type: 'json',
-                    rootProperty: 'data',
-                    totalProperty: 'pagination.total',
-                    successProperty: 'success',
-                    messageProperty: 'msg',
-                    transform: function (data) {
-                        if (typeof grid._transform === 'function') {
-                            // 系统转换函数
-                            grid._transform(data.data)
-                        }
-                        if (grid.dataTransform) {
-                            if (typeof grid.dataTransform === 'string') {
-                                grid.dataTransform = lookupFn(lookupScope(grid), grid.dataTransform)
-                            }
-
-                            return grid.dataTransform.call(scope, grid, data)
-                        }
-                        return data
-                    }
-                }
-            },
-            listeners: {
-                load: function (store, records, successful, operation) {
-                    me.fireEvent('dataLoadComplete', me, successful, records);
-                }
-            }
-        }
-
-    } else if (apiConvert) {
-        // 外部扩展的 apiConvert
-        storeOption = apiConvert.gridInvokeBuild(scope, grid, config, dataSource, params, reloadParams)
-
-    } else {
-        throw new TypeError("不支持的 API 请求方式")
-    }
-    me.setStore(new Ext.data.virtual.Store(storeOption))
-
-}
-
-export default function () {
-
-    Ext.define('Yvan.JsonAjaxProxy', {
-        extend: 'Ext.data.proxy.Ajax',
-        alias: 'proxy.jsonAjax',
-        actionMethods: {
-            create: "POST",
-            read: "POST",
-            update: "POST",
-            destroy: "POST"
-        },
-        timeout: storeAjax.timeout,
-        buildRequest: function (operation) {
-            // 参考源码 ext-all-debug.js:71468 method:buildRequest
-            const me = this
-            const {$owner} = me // 在 grid.initComponent 中赋值 $owner
-            const scope = lookupScope($owner)
-
-            const gridParam = me.getParams(operation)
-            const customParam = {}
-
-            // 提取 srot 元素
-            if (gridParam.sort) {
-                const sort = JSON.parse(gridParam.sort)
-                // 字符串 [{"property":"BRANCHID","direction":"ASC"}]
-                // 转换为对象 [{colId: "BRANCHID", sort: "asc"}]
-                customParam.sortModel = []
-                _.forEach(sort, s => {
-                    customParam.sortModel.push({
-                        colId: s.property,
-                        sort: _.toLower(s.direction)
-                    })
-                })
-                delete gridParam.sort
-            }
-            delete gridParam.filter
-
-            // 被 grid.constructor 作为方法存在
-            const extraParams = _.cloneDeep(me.getExtraParams())
-            const params = _.defaultsDeep(gridParam, extraParams)
-
-            let request = new Ext.data.Request({
-                params: {},
-                action: operation.getAction(),
-                records: operation.getRecords(),
-                url: me.buildUrl(),
-                jsonData: {
-                    args: [
-                        params
-                    ],
-                    ...customParam
-                },
-                proxy: me
-            });
-
-            operation.setRequest(request);
-            return request;
-        },
-        afterRequest: function (req, res) {
-            // Extend.afterExtRequest(req, res)
-        }
-    });
-
-}

+ 0 - 13
src/global.d.ts

@@ -1,13 +0,0 @@
-import JQueryStatic from 'jquery'
-
-interface ExtInterface {
-    [v: string]: any
-}
-
-declare global {
-    // @ts-ignore
-    // const $: JQueryStatic;
-
-    // @ts-ignore
-    const Ext: ExtInterface;
-}

+ 0 - 23
src/index.ts

@@ -1,23 +0,0 @@
-import * as axios from 'axios'
-import qs from 'qs'
-import lodash from 'lodash'
-import jquery from 'jquery'
-import json5 from 'json5'
-import moment from 'moment'
-import './wotu-ui.css'
-
-export {
-    axios,
-    qs,
-    lodash,
-    jquery,
-    json5,
-    moment,
-}
-
-export * from './Scope'
-export * from './init'
-export * from './lib/ajax'
-export * from './lib/lib'
-export * from './lib/config'
-export * from './message'

+ 0 - 96
src/init.ts

@@ -1,96 +0,0 @@
-import _ from 'lodash'
-import {lookupFn, lookupScope} from "./lib/lib"
-import initCols from './controls/cols'
-import initGrid from './controls/grid'
-import initGridColumn from './controls/gridcolumn'
-import initStores from './controls/stores'
-import * as SystemLib from './lib/systemLib'
-import {initLocale} from './lib/locale-zh_CN'
-import './lib/fix'
-
-export function init() {
-
-    /**
-     * 改变事件的触发方式
-     */
-    const _getFireInfo = Ext.util.Event.prototype.getFireInfo
-    Ext.util.Event.prototype.getFireInfo = function (listener, fromWrapped) {
-        var observable = this.observable,
-            fireFn = listener.fireFn,
-            scope = listener.scope,
-            namedScope = listener.namedScope,
-            fn, origin;
-
-        fn = fromWrapped ? listener.fn : fireFn;
-
-        if (typeof fn === 'string' &&
-            (_.startsWith(fn, 'scope.') ||
-                _.startsWith(fn, 'system.') ||
-                _.startsWith(fn, 'format.')
-            )) {
-
-            if (window["IS_DESIGN_MODE"]) {
-                fn = Ext.emptyFn
-            } else {
-                scope = lookupScope(observable)
-                fn = lookupFn(scope, fn)
-            }
-
-            return {scope, fn}
-        }
-
-        return _getFireInfo.call(this, listener, fromWrapped)
-    }
-    // const _addListener = Ext.mixin.Observable.prototype.addListener
-    // Ext.mixin.Observable.prototype.addListener = function (eventName, fn, scope, options, order, caller) {
-    //     console.log('addListener', eventName, fn, scope, options, order, caller)
-    //     // const scope = lookupScope(this)
-    //     // const fn = lookupFn(scope, fn)
-    //
-    //     return _addListener.call(this, eventName, fn, scope, options, order, caller)
-    // }
-
-    /**
-     * 改变事件的获取方式.
-     * 具体见: ext-all-debug.js:23216 addListener
-     * https://docs.sencha.com/extjs/6.6.0/classic/Ext.util.Observable.html#method-addListener
-     * https://docs.sencha.com/extjs/6.6.0/classic/src/Observable.js.html#Ext.mixin.Observable-method-addListener
-     */
-    // const _doAddListener = Ext.mixin.Observable.prototype.doAddListener
-    // Ext.mixin.Observable.prototype.doAddListener = function (ename, fn, scope, options, order, caller, manager) {
-    //     console.log('doAddListener', ename, fn, scope)
-    //     if (typeof fn === 'string' &&
-    //         (_.startsWith(fn, 'scope.') ||
-    //             _.startsWith(fn, 'system.') ||
-    //             _.startsWith(fn, 'format.')
-    //         )) {
-    //
-    //         if (window["IS_DESIGN_MODE"]) {
-    //             fn = Ext.emptyFn
-    //         } else {
-    //             // console.log('doAddListener', ename, fn, scope, options, order, caller, manager)
-    //             // const vm = this.lookupViewModel()
-    //             // if (vm && vm.yvanScope) {
-    //             //     scope = vm.yvanScope
-    //             //     fn = scope[fn.substr('scope.'.length)]
-    //             // }
-    //             scope = lookupScope(this)
-    //             fn = lookupFn(scope, fn)
-    //         }
-    //     }
-    //
-    //     _doAddListener.call(this, ename, fn, scope, options, order, caller, manager)
-    // }
-
-    // 将 SystemLib 扩展到 window.system 下
-    if (!window['system']) {
-        window['system'] = {}
-    }
-    _.extend(window['system'], SystemLib)
-
-    initCols()
-    initLocale()
-    initGridColumn()
-    initGrid()
-    initStores()
-}

+ 0 - 284
src/lib/ajax.ts

@@ -1,284 +0,0 @@
-import axios, {AxiosRequestConfig, AxiosResponse} from 'axios'
-import {PlainObject} from "../types";
-import _ from 'lodash'
-import Qs from 'qs'
-import {serverInvokeUrlTransform, sqlUrlTransform, ajax} from "./config";
-
-export type ApiMethod =
-    'get'
-    | 'post'
-    | 'put'
-    | 'patch'
-    | 'delete'
-    | 'download'
-    | 'post-json'
-    | 'post-file'
-    | 'invoke'
-    | 'sql'
-    | string
-
-export type ApiDataType = 'json' | 'form-data' | 'form'
-
-export interface ApiObject {
-    url: string
-    param: PlainObject
-    method: ApiMethod
-    data?: object
-    args: any[],
-    db?: string
-    headers?: PlainObject
-    filterModel?: { [key: string]: any; };
-    sortModel?: { colId: string | undefined; sort: string | null | undefined; }[];
-    config?: {
-        withCredentials?: boolean
-        cancelExecutor?: (cancel: Function) => void
-    }
-    dataType?: ApiDataType
-
-    /**
-     * 下载文件名
-     */
-    fileName?: string,
-
-    /**
-     * 上传文件(如果需要的话)
-     */
-    file?: any,
-}
-
-
-export type ApiFunction = (api: ApiObject) => Promise<ApiResult>;
-
-/**
- * 组件中 Api 的声明
- */
-export type Api = ApiFunction | ApiObject;
-
-export interface ApiResult {
-    rawData: object
-    status: number
-    headers: object
-    data?: any
-    pagination?: any
-    success: boolean
-    msg: string
-    errors?: {
-        [propName: string]: string
-    }
-}
-
-export interface CreateAjaxOption {
-    baseUrl: string
-    timeout: number
-}
-
-
-/**
- * 创建一个 Ajax 客户端
- */
-export function createAjax(createOption: CreateAjaxOption): ApiFunction {
-
-    if (createOption.baseUrl) {
-        axios.defaults.baseURL = createOption.baseUrl
-        axios.defaults.timeout = createOption.timeout
-        axios.defaults.timeoutErrorMessage = '网络超时'
-    }
-
-    return function (option: ApiObject) {
-
-        //@ts-ignore
-        option.method = (option.method || 'get').toLocaleLowerCase();
-
-        //@ts-ignore
-        const ax: AxiosRequestConfig = {
-            ...option
-        };
-
-        switch (option.method) {
-            case 'get':
-                ax.method = 'GET';
-                ax.params = option.param;
-                ax.headers = {
-                    ...option.headers
-                };
-                break
-
-            case 'post':
-                ax.method = 'POST';
-                ax.headers = {
-                    'Content-Type': 'application/x-www-form-urlencoded',
-                    ...option.headers
-                };
-                ax.params = option.param;
-                ax.data = Qs.stringify(option.data);
-                break
-
-            case 'put' :
-            case 'patch':
-            case 'delete':
-                ax.method = option.method;
-                ax.headers = option.headers;
-                ax.params = option.param;
-                ax.data = Qs.stringify(option.data);
-                break
-
-            case 'download':
-                downLoad(createOption.baseUrl + option.url, option.fileName || 'file',
-                    option.data, option.headers);
-                return new Promise<ApiResult>((resolver, reject) => {
-                });
-                break
-
-            case "invoke":
-                ax.url = serverInvokeUrlTransform(option.url, option)
-                ax.method = 'POST';
-                ax.headers = {
-                    'Content-Type': 'application/json',
-                    ...option.headers
-                };
-                if (typeof option.args === 'object') {
-                    ax.data = JSON.stringify({
-                        args: option.args,
-                    })
-                } else {
-                    ax.data = JSON.stringify({
-                        args: [
-                            {
-                                ...option.data,
-                                ...option.param
-                            }
-                        ],
-                        filterModel: option.filterModel,
-                        sortModel: option.sortModel
-                    })
-                }
-                break
-
-            case 'post-json':
-                ax.method = 'POST';
-                ax.headers = {
-                    'Content-Type': 'application/json',
-                    ...option.headers
-                };
-                ax.data = JSON.stringify({...option.data, filterModel: option.filterModel, sortModel: option.sortModel})
-                break
-
-            case 'post-file':
-                //TODO 刘壮. 上传文件
-                var forms = new FormData();
-                ax.headers = {
-                    'Content-Type': 'multipart/form-data',
-                    ...option.headers
-                };
-                _.forOwn(option.data, (value, key) => {
-                    if (key === 'files') {
-                        let i = 0;
-                        _.each(value, f => {
-                            // @ts-ignore
-                            forms.append('file' + (++i), f)
-                        })
-                    } else {
-                        forms.append(key, value)
-                    }
-                });
-                ax.data = forms;
-                ax.method = 'POST'
-                break
-
-            case "sql":
-                ax.url = sqlUrlTransform(option.url)
-                ax.method = 'POST';
-                ax.headers = {
-                    'Content-Type': 'application/json',
-                    ...option.headers
-                };
-                ax.data = JSON.stringify({
-                    args: [option.data],
-                    db: option.db,
-                    filterModel: option.filterModel,
-                    sortModel: option.sortModel
-                })
-                break
-
-            default:
-                throw new Error('not implements')
-        }
-
-        return new Promise<ApiResult>((resolver, reject) => {
-            axios(ax).then((resolverRaw: AxiosResponse<any>) => {
-                const apiResult: ApiResult = {
-                    rawData: resolverRaw.data,
-                    status: resolverRaw.status,
-                    success: (resolverRaw.data && resolverRaw.data.success),
-                    data: resolverRaw.data.data,
-                    pagination: resolverRaw.data.pagination,
-                    msg: (resolverRaw.data.msg),
-                    errors: resolverRaw.data.errors,
-                    headers: resolverRaw.headers
-                }
-                resolver(apiResult)
-
-            }).catch((reason: any) => {
-                reject(reason)
-            })
-        })
-    }
-}
-
-
-export function downLoad(downLoadUrl: string, filename: string, data: any, header: any, isJson: boolean = false) {
-    const YvanUI: any = _.get(window, 'YvanUI');
-    YvanUI.loading();
-    const createObjectURL = (object: any) => {
-        return (window.URL) ? window.URL.createObjectURL(object) : _.get(window, 'webkitURL').createObjectURL(object)
-    };
-
-    // const formData = new FormData();
-    // _.forOwn(data, (v, k) => {
-    //     formData.append(k, v);
-    // });
-    let formData = '';
-
-    const xhr = new XMLHttpRequest();
-    xhr.open('POST', downLoadUrl);
-    xhr.responseType = 'blob';
-    // xhr.setRequestHeader('Authorization', $.cookie('auth'))
-    if (isJson) {
-        formData = data ? JSON.stringify(data) : '';
-        xhr.setRequestHeader('Content-Type', 'application/json');
-    } else {
-        formData = data ? Qs.stringify(data) : '';
-        xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
-    }
-    //
-    if (header) {
-        _.forOwn(header, (v, k) => {
-            xhr.setRequestHeader(k, v);
-        })
-    }
-    xhr.onload = function (e: any) {
-        if (this.status === 200) {
-            const blob = this.response;
-            if (_.hasIn(window, 'navigator.msSaveOrOpenBlob')) {
-                navigator.msSaveBlob(blob, filename)
-                YvanUI.clearLoading();
-
-            } else {
-                const a = document.createElement('a')
-                const url = createObjectURL(blob)
-                a.href = url
-                a.download = filename
-                document.append(a)
-                a.click()
-                a.remove()
-                window.URL.revokeObjectURL(url)
-                YvanUI.clearLoading()
-            }
-        }
-    };
-    xhr.send(formData);
-}
-
-
-
-

+ 0 - 177
src/lib/config.ts

@@ -1,177 +0,0 @@
-import {ConfigProcess} from "../types";
-import {ApiFunction} from "./ajax";
-import _ from 'lodash'
-
-export type ServerInvokeUrlTransformFunction = (jsUrl: string, option?: any) => string | undefined;
-
-export type SqlUrlTransformFunction = (jsUrl: string, option?: any) => string | undefined;
-
-export interface ApiConvert {
-    /**
-     * 从表格 dataSource 属性,转换为 ExtJS.storeOption 属性
-     */
-    gridInvokeBuild: (scope, grid, config, dataSource, params, reloadParams) => object
-}
-
-/**
- * YvanUI 全局扩展配置
- */
-export interface ConfigOption {
-
-    /**
-     * 是否在设计器模式
-     */
-    designMode: boolean
-
-    /**
-     * 扩展自定义的 ajax 方法
-     */
-    ajax: ApiFunction;
-
-    /**
-     * 扩展自定义的后端请求方法
-     */
-    apiConvert: ApiConvert;
-
-    /**
-     * serverJS Url转换为Ajax请求
-     */
-    serverInvokeUrlTransform: ServerInvokeUrlTransformFunction;
-
-    /**
-     * Sql Url转换为Ajax请求
-     */
-    sqlUrlTransform: SqlUrlTransformFunction;
-
-    /**
-     * 获取拼音首字母的函数
-     */
-    pinyinFunction: (py: string) => string
-
-    /**
-     * Scope onload 时扩展方法
-     */
-    scopeOnLoad: (scope: any) => void
-}
-
-/**
- * 全局 ajax 方法
- */
-export const ajax: {
-    func?: ApiFunction
-} = {}
-
-/**
- * 计算拼音的函数
- */
-let pinyinFunc: Function = (str) => (str)
-
-export let scopeOnLoad: (scope: any) => void = null
-
-export let apiConvert: ApiConvert = undefined
-
-export const baseConfigProcessList: ConfigProcess[] = []
-
-/**
- * 在基类添加 Config 的处理方法
- */
-export function baseConfigProcess(option?: any) {
-    return (target, propertyKey) => {
-        baseConfigProcessList.push(target[propertyKey])
-    }
-}
-
-let designMode: boolean = false
-
-export function isDesignMode(): boolean {
-    return designMode
-}
-
-export function setDesignMode(v: boolean) {
-    designMode = v
-}
-
-/**
- * 将业务定义的 url 转换为调用服务端 groovy 的 url
- */
-export function serverInvokeUrlTransform(url: string, option?: any): string {
-    return _.get(window, '_YvanUI_serverInvokePrefix')(url, option);
-}
-
-/**
- * 将业务定义的 url 转换为调用服务端 sql 的 Url
- */
-export function sqlUrlTransform(url: string): string {
-    return _.get(window, '_YvanUI_sqlPrefix')(url);
-}
-
-/**
- * YvanUI 全局扩展配置
- */
-export function extend(option: Partial<ConfigOption>) {
-    if (option.ajax) {
-        ajax.func = option.ajax
-    }
-
-    if (option.serverInvokeUrlTransform) {
-        _.extend(window, {_YvanUI_serverInvokePrefix: option.serverInvokeUrlTransform});
-    }
-
-    if (option.sqlUrlTransform) {
-        _.extend(window, {_YvanUI_sqlPrefix: option.sqlUrlTransform});
-    }
-
-    if (option.pinyinFunction) {
-        pinyinFunc = option.pinyinFunction
-    }
-
-    if (option.scopeOnLoad) {
-        scopeOnLoad = option.scopeOnLoad
-    }
-
-    if (option.apiConvert) {
-        apiConvert = option.apiConvert
-    }
-
-    if (typeof option.designMode !== 'undefined') {
-        setDesignMode(option.designMode)
-    }
-}
-
-export function getApiConvert() {
-    return apiConvert
-}
-
-export function getPinyin(v: string) {
-    return pinyinFunc(v)
-}
-
-/**
- * 适用于 Select / Tree 等,作筛选的通用方法.
- * 1.首字母模糊匹配(不区分大小写)
- * 2.标识的模糊匹配(不区分大小写)
- * 3.名称的模糊匹配,且支持以逗号(全角或半角)隔开的字词匹配,并自动去空格,如“南京, 物流 ”可以匹配出“南京九州通物流技术开发有限公司”
- */
-export function keywordFilter(keyword: string, label: string, value?: string) {
-    if (!keyword) {
-        return true
-    }
-    const ws = _.trim(keyword).split(/\s+|\.|,|\)|\(|,|。|-|—/g)
-    const labelPy = _.toLower(getPinyin(label))
-    value = _.toLower(_.trim(value))
-
-    let found = 0
-    _.some(ws, (word) => {
-        if (labelPy.indexOf(word.toLowerCase()) >= 0 || label.indexOf(word) >= 0) {
-            found++
-            return
-        }
-
-        if (value && value.indexOf(word.toLowerCase()) >= 0) {
-            found++
-            return
-        }
-    })
-
-    return found >= ws.length
-}

+ 0 - 39
src/lib/fix.js

@@ -1,39 +0,0 @@
-import _ from 'lodash'
-import {baseConfigProcess} from "./config";
-import {lookupFn} from "./lib";
-
-class FixClass {
-
-    @baseConfigProcess()
-    fix(me, config) {
-        const {fix} = config
-        if (!fix) {
-            return
-        }
-
-        delete config.fix
-
-        // 这里有个 bug
-        // 但凡是调用了 this.lookupViewModel() 就会出现绑定不了的情况
-        // const scope = config.$initParent.lookupReferenceHolder().yvanScope //lookupScope(me)
-        let scope
-        if (config.$initParent) {
-            // 在面板上的组件
-            scope = config.$initParent.lookupReferenceHolder().yvanScope //lookupScope(me)
-        } else if (config.column) {
-            // 在列上的组件
-            scope = config.column.lookupReferenceHolder().yvanScope //lookupScope(me)
-        }
-
-        if (_.isArray(fix)) {
-            _.each(fix, (f) => {
-                const fn = lookupFn(scope, f)
-                fn.call(this, me, config)
-            })
-
-        } else if (_.isString(fix)) {
-            const fn = lookupFn(scope, fix)
-            fn.call(this, me, config)
-        }
-    }
-}

+ 0 - 155
src/lib/lib.ts

@@ -1,155 +0,0 @@
-import _ from 'lodash'
-import {FunctionRegiste, LibParamType} from "../types"
-import {Scope} from "../Scope"
-
-export function getRegList(): FunctionRegiste[] {
-    let regList = _.get(window, 'yvanLib.regList')
-    if (!regList) {
-        regList = []
-        _.set(window, 'yvanLib.regList', regList)
-    }
-    return regList
-}
-
-export function getRegParamList(methodName: string) {
-    let regParamList = _.get(window, 'yvanLib.regParamList')
-    if (!regParamList) {
-        regParamList = {}
-        _.set(window, 'yvanLib.regParamList', regParamList)
-    }
-
-    if (!_.has(regParamList, methodName)) {
-        regParamList[methodName] = []
-    }
-
-    return regParamList[methodName]
-}
-
-/**
- * 模拟点击按钮
- */
-export function raiseClick(buttonHandle) {
-    if (!buttonHandle) {
-        return false
-    }
-    if (buttonHandle.disabled) {
-        // 按钮是禁止状态
-        return false
-    }
-    if (buttonHandle.hidden) {
-        // 按钮是隐藏状态
-        return false
-    }
-
-    // 按钮点击
-    buttonHandle.click()
-    return true
-}
-
-/**
- * 标注系统全局函数的参数
- * @param title 函数名称
- * @param type 函数类型
- * @param allowEmpty 可否为空
- */
-export function LibParam(title: string, type: LibParamType, allowEmpty = false) {
-    return function (target: any, methodName: any, paramsIndex: any) {
-        const systemFnArgs = getRegParamList(methodName)
-        systemFnArgs[paramsIndex] = {
-            type,
-            title,
-            name: methodName,
-            allowEmpty,
-        }
-    }
-}
-
-/**
- * 标注函数变成"系统全局函数"
- */
-export function Lib(registe: FunctionRegiste) {
-    return function (target, propertyKey: string, descriptor: PropertyDescriptor) {
-        const libList = getRegList()
-        libList.push({
-            ...registe,
-            name: propertyKey,
-            target: target[propertyKey]
-        })
-
-        if (registe.type === 'system') {
-            _.set(window, 'yvanLib.system.' + propertyKey, target[propertyKey])
-
-        } else if (registe.type === 'format') {
-            _.set(window, 'yvanLib.format.' + propertyKey, target[propertyKey])
-
-        }
-
-        return target
-    }
-}
-
-/**
- * 解析事件
- *   'scope.私有方法名'
- *   'system.系统函数名'
- *   'format.格式化名'
- */
-export function lookupFn(scope: Scope, event: string): Function {
-    if (window["IS_DESIGN_MODE"]) {
-        return Ext.emptyFn
-    }
-
-    if (!_.startsWith(event, 'scope.') &&
-        !_.startsWith(event, 'system.') &&
-        !_.startsWith(event, 'format.')) {
-        console.error('无法识别的事件响应类型', event)
-        throw new TypeError('无法识别的事件响应类型')
-    }
-
-    // 为 eval 准备环境
-    const {system, format} = window['yvanLib']
-    const data = scope.viewModel.data
-
-    const keys: any[] = []
-    const values: any[] = []
-    _.forOwn(data, (value, key) => {
-        const idxKey = key.indexOf('//')
-        if (idxKey >= 0) {
-            keys.push(key.substr(0, idxKey))
-        } else {
-            keys.push(key)
-        }
-        values.push(value)
-    })
-
-    const func: Function = //eval(event)
-        Function('scope', 'system', 'format', ...keys, 'return ' + event)
-
-    const funcResult = func(scope, system, format, ...values)
-
-    if (typeof funcResult !== 'function') {
-        console.error('无法识别的事件响应类型', event, func)
-        throw new TypeError('无法识别的事件响应类型')
-    }
-
-    return funcResult
-}
-
-/**
- * 从 ext.element 获取 scope 对象
- */
-export function lookupScope(extHandle: any): Scope {
-    if (!extHandle) {
-        // @ts-ignore
-        return
-    }
-    if (extHandle.isScope) {
-        return extHandle
-    }
-    if (extHandle.column) {
-        // 列上的组件
-        return extHandle.column.lookupReferenceHolder().yvanScope
-    }
-    const vm = extHandle.lookupViewModel()
-    return vm.yvanScope
-}

+ 0 - 49
src/lib/locale-zh_CN.js

@@ -1,49 +0,0 @@
-function initLocale() {
-    Ext.define('Ext.locale.zh_CN.Panel', {
-        override: 'Ext.Panel',
-        config: {
-            standardButtons: {
-                ok: {
-                    text: '确定'
-                },
-            }
-        },
-    })
-    Ext.define('Ext.locale.zh_CN.picker.Date', {
-        override: 'Ext.picker.Date',
-        config: {
-            doneButton: '完成',
-        }
-    });
-    Ext.define('Ext.locale.zh_CN.picker.Picker', {
-        override: 'Ext.picker.Picker',
-        config: {
-            doneButton: '完成',
-        }
-    });
-
-    const _getStandardButtons = Ext.MessageBox.prototype.getStandardButtons
-    Ext.MessageBox.override({
-        getStandardButtons(){
-            const ret = _getStandardButtons.apply(this, arguments)
-            ret.ok.text = "确定"
-            return ret
-        }
-    });
-    // Ext.define('Ext.locale.zh_CN.MessageBox', {
-    //     override: 'Ext.MessageBox',
-    //     config: {
-    //         standardButtons: {
-    //             ok: {
-    //                 text: '确定'
-    //             },
-    //         }
-    //     }
-    // });
-}
-
-// standardButtons
-
-export {
-    initLocale
-}

Fichier diff supprimé car celui-ci est trop grand
+ 0 - 1196
src/lib/systemLib.ts


+ 0 - 21
src/lib/systemLibEval.js

@@ -1,21 +0,0 @@
-import _ from "lodash";
-
-/**
- * 用于计算 express 表达式
- */
-export function evalFunction(data, express) {
-    const keys = []
-    const values = []
-    _.forOwn(data, (value, key) => {
-        keys.push(key)
-        values.push(value)
-    })
-
-    const func = Function(...keys, 'return ' + express)
-
-    try {
-        return func(...values)
-    } catch (e) {
-        return
-    }
-}

+ 0 - 116
src/message.ts

@@ -1,116 +0,0 @@
-import $ from 'jquery'
-import _ from 'lodash'
-
-export function prompt(message, multiLine = false, value = '') {
-    return new Promise((resolve, reject) => {
-        Ext.Msg.show({
-            title: message,
-            message: null,
-            buttons: Ext.MessageBox.OKCANCEL,
-            prompt: true,
-            defaultFocus: 'textfield',
-            multiLine: multiLine,
-            showAnimation: false,
-            hideAnimation: false,
-            value: value,
-            fn(okcancel, value) {
-                if (okcancel === 'ok') {
-                    resolve(value)
-                } else {
-                    reject()
-                }
-            }
-        });
-    })
-}
-
-export function confirm(message) {
-    return new Promise((resolve, reject) => {
-        return Ext.Msg.show({
-            title: '',
-            message: message || null,
-            buttons: Ext.MessageBox.YESNO,
-            defaultFocus: '#yes',
-            prompt: false,
-            showAnimation: false,
-            hideAnimation: false,
-            fn(yesno) {
-                if (yesno === 'yes') {
-                    resolve()
-                }
-            }
-        });
-    })
-}
-
-export function showInfoDialog(msg, fn?) {
-    console.error(msg)
-    Ext.Msg.show({
-        title: '提示',
-        message: msg,
-        showAnimation: false,
-        hideAnimation: false,
-        defaultFocus: '#ok',
-        prompt: false,
-        fn,
-    });
-}
-
-/**
- * 显示错误异常信息
- * @param msg 错误内容
- * @param fn 确定之后的回调
- */
-export function showErrorDialog(msg, fn?) {
-    console.error(msg)
-    Ext.Msg.show({
-        title: '错误',
-        message: msg,
-        showAnimation: false,
-        hideAnimation: false,
-        defaultFocus: '#ok',
-        prompt: false,
-        fn,
-    });
-}
-
-export function msgError(msg, fn?) {
-    showErrorDialog(msg, fn)
-}
-
-/**
- * 中间灰底白字提示
- */
-export function msg(message: string): void {
-    console.log(message)
-
-    const $body = $('body')
-
-    $body.find('[xtype=tooltip]').remove()
-    const $w = $(
-        '<div xtype="tooltip" class="yvan-msg yvan-anim yvan-anim-00">' +
-        '  <div class="yvan-msg-content">' +
-        _.escape(message) +
-        '</div></div>'
-    )
-    $body.append($w)
-
-    const iframeWidth = $w.parent().width() as number
-    const iframeHeight = $w.parent().height() as number
-
-    const windowWidth = $w.width() as number
-    const windowHeight = $w.height() as number
-
-    let setWidth = (iframeWidth - windowWidth) / 2
-    let setHeight = (iframeHeight - windowHeight) / 2
-    if (iframeHeight < windowHeight || setHeight < 0) {
-        setHeight = 0
-    }
-    if (iframeWidth < windowWidth || setWidth < 0) {
-        setWidth = 0
-    }
-    $w.css({left: setWidth, top: setHeight})
-    setTimeout(() => {
-        $w.remove()
-    }, 3000)
-}

Fichier diff supprimé car celui-ci est trop grand
+ 0 - 3384
yarn.lock