Comparing version 1.2.5 to 1.2.6
@@ -5,2 +5,3 @@ import './utils'; | ||
import './layouts/charts'; | ||
import './layouts/screen'; | ||
import './Documents'; | ||
@@ -7,0 +8,0 @@ declare global { |
@@ -7,2 +7,3 @@ "use strict"; | ||
require("./layouts/charts"); | ||
require("./layouts/screen"); | ||
require("./Documents"); |
/// <reference types="react" /> | ||
import * as React from 'react'; | ||
import { BaseModalProps } from './interface'; | ||
/** | ||
* 说明 BaseModal 是一个没有任何功能的组件,并不是一个Model。 | ||
* | ||
* 但它有一些好处,特别适用于开发 Model的时候进行继承以达到简化代码的目的: | ||
* | ||
* 1. `BaseModal` 约束了 `props` 参数,必须传入 `show:boolean` | ||
* 2. 可选参数可传入 `isEdit:boolean` `data:any` `dispatch:any` ,用于一般的弹框参数约束 | ||
* 3. 可以传入任何扩展参数,自行设定(不会报TypeScript编译问题) | ||
* 4. 提供 `_isReShow(old)` 方法,判断每次触发 `render` 时,是不是重新打开 | ||
*/ | ||
export default class BaseModal extends React.PureComponent<BaseModalProps, any> { | ||
_isReShow(old: any): boolean; | ||
} |
@@ -14,2 +14,12 @@ "use strict"; | ||
var React = require("react"); | ||
/** | ||
* 说明 BaseModal 是一个没有任何功能的组件,并不是一个Model。 | ||
* | ||
* 但它有一些好处,特别适用于开发 Model的时候进行继承以达到简化代码的目的: | ||
* | ||
* 1. `BaseModal` 约束了 `props` 参数,必须传入 `show:boolean` | ||
* 2. 可选参数可传入 `isEdit:boolean` `data:any` `dispatch:any` ,用于一般的弹框参数约束 | ||
* 3. 可以传入任何扩展参数,自行设定(不会报TypeScript编译问题) | ||
* 4. 提供 `_isReShow(old)` 方法,判断每次触发 `render` 时,是不是重新打开 | ||
*/ | ||
var BaseModal = /** @class */ (function (_super) { | ||
@@ -16,0 +26,0 @@ __extends(BaseModal, _super); |
import { ModalProps } from 'antd/lib/modal/Modal'; | ||
export interface BaseModalStates { | ||
data?: any; | ||
[propName: string]: any; | ||
} | ||
export interface BaseModalProps extends ModalProps { | ||
/** | ||
* 是否显示,需要自行在 visable 实现 | ||
*/ | ||
show: boolean; | ||
/** | ||
* 是否编辑模式 | ||
*/ | ||
isEdit?: boolean; | ||
/** | ||
* 打开窗口时的对象信息 | ||
*/ | ||
data?: any; | ||
/** | ||
* 全局事件发送器 | ||
*/ | ||
dispatch?: any; | ||
/** | ||
* 自定义属性 | ||
*/ | ||
[propName: string]: any; | ||
} |
/// <reference types="react" /> | ||
import * as React from 'react'; | ||
import { FromModalProps } from './interface'; | ||
/** | ||
* 表单弹框,支持各种类型的表单元素填写,当提交时,会调用 onOk 方法将编辑的对象信息以参数传递回去。 | ||
* | ||
*/ | ||
export default class FromModal extends React.Component<FromModalProps> { | ||
@@ -5,0 +9,0 @@ private _warpColumns(columns); |
@@ -277,2 +277,6 @@ "use strict"; | ||
}(React.PureComponent)); | ||
/** | ||
* 表单弹框,支持各种类型的表单元素填写,当提交时,会调用 onOk 方法将编辑的对象信息以参数传递回去。 | ||
* | ||
*/ | ||
var FromModal = /** @class */ (function (_super) { | ||
@@ -279,0 +283,0 @@ __extends(FromModal, _super); |
import { ModalProps } from 'antd/lib/modal/Modal'; | ||
/** | ||
* 表单的字段定义 | ||
*/ | ||
export interface Column { | ||
@@ -23,14 +26,55 @@ /** | ||
disabled?: boolean; | ||
/** | ||
* 字段类型,目前支持 'text' | 'number' | 'select' | 'radio' | 'checkbox' | 'date' | 'switch' | 'daterange' | 'icon' | ||
* 如果不填,则默认为 `text` | ||
* */ | ||
type?: string; | ||
options?: any[]; | ||
/** | ||
* 字段选项,适用于 `checkbox` `radio` `switch` 等 | ||
* 当字段类型为 `switch`时, 数组长度必须为 2, 第一个参数放正常状态,第二个参数放异常状态 | ||
*/ | ||
options?: { | ||
name: string; | ||
value: string; | ||
}[]; | ||
/** | ||
* 后面的字段和此字段放在同一行,后续有时间再支持 | ||
* | ||
*/ | ||
inline?: boolean; | ||
/** | ||
* rule 用法: https://github.com/yiminghe/async-validator | ||
*/ | ||
rule?: any[]; | ||
/** | ||
* 字段联动,目前只支持 `text` `select` 类型,受影响的字段只能是具有 `options` 属性的类型 | ||
* | ||
*/ | ||
link?: { | ||
/** | ||
* 受影响的字段 | ||
*/ | ||
field: string; | ||
/** | ||
* 字段变化事件时,触发联动效果 ,默认为 `change` | ||
* | ||
*/ | ||
type?: "change" | "blur"; | ||
/** | ||
* 打开表单弹框时,马上触发一次联动 | ||
*/ | ||
onload?: boolean; | ||
/** | ||
* 联动事件 | ||
*/ | ||
callback: { | ||
Function(txt: string): any[]; | ||
}; | ||
/** | ||
* 联动事件返回列表中,对应显示在页面上的 name 的属性字段 | ||
*/ | ||
name: string; | ||
/** | ||
* 联动事件返回列表中,对应显示在页面上的 value 的属性字段 | ||
*/ | ||
value: string; | ||
@@ -40,6 +84,18 @@ }; | ||
export interface FromModalProps extends ModalProps { | ||
/** | ||
* 表彰的列定义,传一个数组 | ||
*/ | ||
columns: Column[]; | ||
/** | ||
* 是否编辑模式, | ||
*/ | ||
isEdit?: boolean; | ||
/** | ||
* 表单对象信息 | ||
*/ | ||
data?: any; | ||
default: any; | ||
columns: Column[]; | ||
/** | ||
* 对象的默认值 | ||
*/ | ||
default?: any; | ||
} |
/// <reference types="react" /> | ||
import * as React from 'react'; | ||
import { InfoModalProps } from './interface'; | ||
/** | ||
* 弹出一个对象信息弹框 | ||
* */ | ||
export default class InfoModal extends React.PureComponent<InfoModalProps> { | ||
@@ -5,0 +8,0 @@ buildForm(): JSX.Element[]; |
@@ -23,3 +23,5 @@ "use strict"; | ||
var React = require("react"); | ||
// 表单 | ||
/** | ||
* 弹出一个对象信息弹框 | ||
* */ | ||
var InfoModal = /** @class */ (function (_super) { | ||
@@ -26,0 +28,0 @@ __extends(InfoModal, _super); |
import { ModalProps } from 'antd/lib/modal/Modal'; | ||
/** | ||
* 对象字段信息 | ||
* | ||
*/ | ||
export interface Column { | ||
/** | ||
* 字段标题 | ||
*/ | ||
title: string; | ||
/** | ||
* 字段的 filed | ||
*/ | ||
field: string; | ||
key?: string; | ||
/** | ||
* 如果有转换,可以传一个 render | ||
*/ | ||
render?: Function; | ||
} | ||
/** | ||
* 对象的信息弹框 props | ||
* | ||
*/ | ||
export interface InfoModalProps extends ModalProps { | ||
/** | ||
* 对象信息 | ||
*/ | ||
data: any; | ||
/** | ||
* 对象字段列表 | ||
*/ | ||
columns: Column[]; | ||
} |
@@ -24,4 +24,12 @@ "use strict"; | ||
var _ = require("lodash"); | ||
var interface_1 = require("./interface"); | ||
var utils_1 = require("../../../utils"); | ||
/** | ||
* @private | ||
*/ | ||
var MODE; | ||
(function (MODE) { | ||
MODE[MODE["ADD"] = 0] = "ADD"; | ||
MODE[MODE["EDIT"] = 1] = "EDIT"; | ||
MODE[MODE["COMMON"] = 2] = "COMMON"; | ||
})(MODE || (MODE = {})); | ||
var ListModal = /** @class */ (function (_super) { | ||
@@ -32,3 +40,3 @@ __extends(ListModal, _super); | ||
_this.rowKey = 'id'; | ||
_this.mode = interface_1.MODE.COMMON; | ||
_this.mode = MODE.COMMON; | ||
_this.state = { | ||
@@ -52,3 +60,3 @@ list: [], | ||
if (old.show === false && this.props.show === true) { | ||
this.mode = interface_1.MODE.COMMON; | ||
this.mode = MODE.COMMON; | ||
this.editObject = {}; | ||
@@ -66,3 +74,3 @@ var columns_1 = this.buildOption(); | ||
else if (old.show === true && this.props.show === false) { | ||
this.mode = interface_1.MODE.COMMON; | ||
this.mode = MODE.COMMON; | ||
this.editObject = {}; | ||
@@ -92,3 +100,3 @@ this.setState({ | ||
} | ||
this.mode = interface_1.MODE.COMMON; | ||
this.mode = MODE.COMMON; | ||
}; | ||
@@ -111,10 +119,10 @@ ListModal.prototype.doEdit = function (record, save) { | ||
} | ||
this.mode = interface_1.MODE.COMMON; | ||
this.mode = MODE.COMMON; | ||
}; | ||
ListModal.prototype.exitEditMode = function (record, save) { | ||
switch (this.mode) { | ||
case interface_1.MODE.ADD: | ||
case MODE.ADD: | ||
this.doAdd(record, save); | ||
break; | ||
case interface_1.MODE.EDIT: | ||
case MODE.EDIT: | ||
this.doEdit(record, save); | ||
@@ -127,4 +135,4 @@ break; | ||
ListModal.prototype.add = function () { | ||
if (this.mode === interface_1.MODE.COMMON) { | ||
this.mode = interface_1.MODE.ADD; | ||
if (this.mode === MODE.COMMON) { | ||
this.mode = MODE.ADD; | ||
var list = _.concat([], this.state.list); | ||
@@ -144,4 +152,4 @@ var obj_1 = _.assign({ _edit: true, _add: true, }, this.props.param); | ||
var _this = this; | ||
if (this.mode === interface_1.MODE.COMMON) { | ||
this.mode = interface_1.MODE.EDIT; | ||
if (this.mode === MODE.COMMON) { | ||
this.mode = MODE.EDIT; | ||
this.editObject = _.assign({}, this.props.param, record); | ||
@@ -162,3 +170,3 @@ var list = _.concat([], this.state.list); | ||
var _this = this; | ||
if (column.readonly && this.mode == interface_1.MODE.EDIT) { | ||
if (column.readonly && this.mode == MODE.EDIT) { | ||
if (render) { | ||
@@ -272,3 +280,3 @@ return render(text); | ||
utils_1.Ajax.POST(this.props.query, this.param, function (json) { | ||
_this.mode = interface_1.MODE.COMMON; | ||
_this.mode = MODE.COMMON; | ||
_this.setState({ | ||
@@ -275,0 +283,0 @@ list: json.list, |
import { ModalProps } from 'antd/lib/modal/Modal'; | ||
import { ColumnProps } from 'antd/lib/table/interface'; | ||
export declare enum MODE { | ||
ADD = 0, | ||
EDIT = 1, | ||
COMMON = 2, | ||
} | ||
/** | ||
* 列信息,继承 antd - Table 的列信息,扩展了一些自定义属性 | ||
* | ||
*/ | ||
export interface Column<T> extends ColumnProps<T> { | ||
/** | ||
* | ||
*/ | ||
type?: string; | ||
@@ -10,0 +12,0 @@ readonly?: boolean; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var MODE; | ||
(function (MODE) { | ||
MODE[MODE["ADD"] = 0] = "ADD"; | ||
MODE[MODE["EDIT"] = 1] = "EDIT"; | ||
MODE[MODE["COMMON"] = 2] = "COMMON"; | ||
})(MODE = exports.MODE || (exports.MODE = {})); |
{ | ||
"name": "vap", | ||
"version": "1.2.5", | ||
"version": "1.2.6", | ||
"description": "vap", | ||
@@ -10,3 +10,9 @@ "main": "index.js", | ||
"author": "ada87", | ||
"license": "ISC" | ||
"license": "ISC", | ||
"devDependencies": { | ||
"@types/d3": "^5.0.0", | ||
"@types/jquery": "^3.3.1", | ||
"@types/react": "^16.0.41", | ||
"@types/three": "^0.91.0" | ||
} | ||
} |
@@ -8,3 +8,4 @@ declare const _default: { | ||
WHEN: (...pos: Promise<void>[]) => Promise<void[]>; | ||
SESION: (...urls: string[]) => void; | ||
}; | ||
export default _default; |
@@ -47,2 +47,3 @@ "use strict"; | ||
var antd_1 = require("antd"); | ||
var Cache_1 = require("./Cache"); | ||
var _ = require("lodash"); | ||
@@ -148,16 +149,44 @@ /** | ||
*/ | ||
var CACHE_URL = new Set(); | ||
function GET(url, callback) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var json; | ||
var json_1, data, json, data_1, resp; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
if (!callback) return [3 /*break*/, 2]; | ||
if (!callback) return [3 /*break*/, 4]; | ||
if (!!CACHE_URL.has(url)) return [3 /*break*/, 2]; | ||
return [4 /*yield*/, request(url)]; | ||
case 1: | ||
json_1 = _a.sent(); | ||
callback.call(null, json_1); | ||
return [2 /*return*/]; | ||
case 2: | ||
data = Cache_1.default.sessionData(url); | ||
if (data) { | ||
callback.call(null, data); | ||
return [2 /*return*/]; | ||
} | ||
return [4 /*yield*/, request(url)]; | ||
case 3: | ||
json = _a.sent(); | ||
Cache_1.default.sessionData(url, json); | ||
callback.call(null, json); | ||
return [3 /*break*/, 3]; | ||
case 2: return [2 /*return*/, request(url)]; | ||
case 3: return [2 /*return*/]; | ||
return [3 /*break*/, 5]; | ||
case 4: | ||
if (!CACHE_URL.has(url)) { | ||
return [2 /*return*/, request(url)]; | ||
} | ||
data_1 = Cache_1.default.sessionData(url); | ||
if (data_1) { | ||
return [2 /*return*/, new Promise(function (resolve) { | ||
resolve(data_1); | ||
})]; | ||
} | ||
resp = request(url); | ||
resp.then(function (json) { | ||
Cache_1.default.sessionData(url, json); | ||
}); | ||
return [2 /*return*/, resp]; | ||
case 5: return [2 /*return*/]; | ||
} | ||
@@ -289,2 +318,20 @@ }); | ||
} | ||
exports.default = { GET: GET, POST: POST, PUT: PUT, PATCH: PATCH, DELETE: DELETE, WHEN: WHEN }; | ||
/** | ||
* 注册需要缓存的链接地址,只能是 GET 请求的 URL | ||
* 此URL 在一次打开的过程中只会请求一次, | ||
* 如果需要清除,可以调用 Cache.sessionDelete(url) 来清除 | ||
* | ||
*/ | ||
function SESION() { | ||
var urls = []; | ||
for (var _a = 0; _a < arguments.length; _a++) { | ||
urls[_a] = arguments[_a]; | ||
} | ||
urls.map(function (url) { | ||
if (!CACHE_URL.has(url)) { | ||
CACHE_URL.add(url); | ||
} | ||
}); | ||
} | ||
; | ||
exports.default = { GET: GET, POST: POST, PUT: PUT, PATCH: PATCH, DELETE: DELETE, WHEN: WHEN, SESION: SESION }; |
@@ -5,3 +5,6 @@ declare const _default: { | ||
LISTEN: (key: string, callback: Function) => void; | ||
sessionDelete: (key: string) => void; | ||
sessionData: (key: string, value?: any) => string; | ||
sessionString: (key: string, value: string) => string; | ||
}; | ||
export default _default; |
@@ -5,2 +5,3 @@ "use strict"; | ||
var CACHE = {}; | ||
var session = sessionStorage; | ||
exports.default = { | ||
@@ -33,3 +34,28 @@ /** | ||
console.log(key); | ||
}, | ||
/** | ||
* 删除SESSION缓存 | ||
*/ | ||
sessionDelete: function (key) { | ||
session.removeItem(key); | ||
}, | ||
/** | ||
* 本地 windows Session | ||
*/ | ||
sessionData: function (key, value) { | ||
if (value === void 0) { value = undefined; } | ||
if (value) { | ||
var txt = JSON.stringify(value); | ||
session.setItem(key, txt); | ||
} | ||
else { | ||
if (session.getItem(key)) { | ||
return JSON.parse(session.getItem(key)); | ||
} | ||
} | ||
return ''; | ||
}, | ||
sessionString: function (key, value) { | ||
return ''; | ||
} | ||
}; |
@@ -5,3 +5,2 @@ export { default as Ajax } from './Ajax'; | ||
export { default as Const } from './Const'; | ||
export { default as Format } from './Format'; | ||
export { default as Renders } from './Renders'; |
@@ -11,5 +11,3 @@ "use strict"; | ||
exports.Const = Const_1.default; | ||
var Format_1 = require("./Format"); | ||
exports.Format = Format_1.default; | ||
var Renders_1 = require("./Renders"); | ||
exports.Renders = Renders_1.default; |
@@ -1,2 +0,1 @@ | ||
/// <reference types="react" /> | ||
export interface Value { | ||
@@ -20,5 +19,5 @@ name: string; | ||
statusRender: (statusMap?: StatusMap, def?: string) => Render; | ||
momentRender: (format?: string, nearly?: number, calendar?: number) => Render; | ||
momentRender: (time?: boolean, format?: string, nearly?: number) => Render; | ||
htmlRender: (className?: string) => (val: any) => JSX.Element; | ||
}; | ||
export default _default; |
@@ -76,6 +76,6 @@ "use strict"; | ||
*/ | ||
momentRender: function (format, nearly, calendar) { | ||
momentRender: function (time, format, nearly) { | ||
if (time === void 0) { time = true; } | ||
if (format === void 0) { format = null; } | ||
if (nearly === void 0) { nearly = 3; } | ||
if (calendar === void 0) { calendar = 14; } | ||
var now = moment(); | ||
@@ -87,9 +87,12 @@ var from = now.unix(); | ||
var diff = from - to; | ||
var txt = time.format('YYYY-MM-DD HH:mm:ss'); | ||
var txt = ''; | ||
if (diff >= 0 && diff < 86400 * nearly) { | ||
txt = time.fromNow(); | ||
} | ||
else if (diff >= 86400 * nearly && diff <= 86400 * calendar) { | ||
txt = time.calendar(); | ||
else if (time) { | ||
txt = time.format('YYYY-MM-DD HH:mm:ss'); | ||
} | ||
else { | ||
txt = time.format('YYYY-MM-DD'); | ||
} | ||
return React.createElement("span", null, txt); | ||
@@ -96,0 +99,0 @@ }; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
147237
78
3825
4