@lambo-design/shared 1.0.0-beta.51 → 1.0.0-beta.52

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/utils/assist.js CHANGED
@@ -1,88 +1,88 @@
1
- // deepCopy
2
-
3
-
4
- export function deepCopy(data) {
5
- let i;
6
- const t = typeOf(data);
7
- let o;
8
-
9
- if (t === 'array') {
10
- o = [];
11
- } else if (t === 'object') {
12
- o = {};
13
- } else {
14
- return data;
15
- }
16
-
17
- if (t === 'array') {
18
- for (i = 0; i < data.length; i++) {
19
- o.push(deepCopy(data[i]));
20
- }
21
- } else if (t === 'object') {
22
- for (i in data) {
23
- o[i] = deepCopy(data[i]);
24
- }
25
- }
26
- return o;
27
- }
28
-
29
- export function typeOf(obj) {
30
- const toString = Object.prototype.toString;
31
- const map = {
32
- '[object Boolean]': 'boolean',
33
- '[object Number]': 'number',
34
- '[object String]': 'string',
35
- '[object Function]': 'function',
36
- '[object Array]': 'array',
37
- '[object Date]': 'date',
38
- '[object RegExp]': 'regExp',
39
- '[object Undefined]': 'undefined',
40
- '[object Null]': 'null',
41
- '[object Object]': 'object'
42
- };
43
- return map[toString.call(obj)];
44
- }
45
-
46
- export function operateBtn(vm, h, currentRow, operationName, operation, type, permission) {
47
- return h('Button', {
48
- props: {
49
- type: type,
50
- size: "small",
51
- ghost: true,
52
- },
53
- directives: [(permission === '' || permission === null) ? '' : {
54
- name: "permission",
55
- value: permission
56
- }],
57
- style: {
58
- margin: '0 2px'
59
- },
60
- on: {
61
- 'click': () => {
62
- operation(vm, currentRow);
63
- }
64
- }
65
- }, operationName);
66
-
67
- }
68
-
69
- export function operateHref(vm, h, currentRow, operationName, operation, type, permission) {
70
- return h('a', {
71
- style: {
72
- margin: '0 4px'
73
- },
74
- directives: [(permission === '' || permission === null) ? '' : {
75
- name: "permission",
76
- value: permission
77
- }],
78
- on: {
79
- 'click': () => {
80
- operation(vm, currentRow);
81
- }
82
- }
83
- }, operationName);
84
- }
85
-
86
- export function isJson(arg) {
87
- return typeof (arg) == "object" && Object.prototype.toString.call(arg).toLowerCase() == "[object object]" && !arg.length
88
- };
1
+ // deepCopy
2
+
3
+
4
+ export function deepCopy(data) {
5
+ let i;
6
+ const t = typeOf(data);
7
+ let o;
8
+
9
+ if (t === 'array') {
10
+ o = [];
11
+ } else if (t === 'object') {
12
+ o = {};
13
+ } else {
14
+ return data;
15
+ }
16
+
17
+ if (t === 'array') {
18
+ for (i = 0; i < data.length; i++) {
19
+ o.push(deepCopy(data[i]));
20
+ }
21
+ } else if (t === 'object') {
22
+ for (i in data) {
23
+ o[i] = deepCopy(data[i]);
24
+ }
25
+ }
26
+ return o;
27
+ }
28
+
29
+ export function typeOf(obj) {
30
+ const toString = Object.prototype.toString;
31
+ const map = {
32
+ '[object Boolean]': 'boolean',
33
+ '[object Number]': 'number',
34
+ '[object String]': 'string',
35
+ '[object Function]': 'function',
36
+ '[object Array]': 'array',
37
+ '[object Date]': 'date',
38
+ '[object RegExp]': 'regExp',
39
+ '[object Undefined]': 'undefined',
40
+ '[object Null]': 'null',
41
+ '[object Object]': 'object'
42
+ };
43
+ return map[toString.call(obj)];
44
+ }
45
+
46
+ export function operateBtn(vm, h, currentRow, operationName, operation, type, permission) {
47
+ return h('Button', {
48
+ props: {
49
+ type: type,
50
+ size: "small",
51
+ ghost: true,
52
+ },
53
+ directives: [(permission === '' || permission === null) ? '' : {
54
+ name: "permission",
55
+ value: permission
56
+ }],
57
+ style: {
58
+ margin: '0 2px'
59
+ },
60
+ on: {
61
+ 'click': () => {
62
+ operation(vm, currentRow);
63
+ }
64
+ }
65
+ }, operationName);
66
+
67
+ }
68
+
69
+ export function operateHref(vm, h, currentRow, operationName, operation, type, permission) {
70
+ return h('a', {
71
+ style: {
72
+ margin: '0 4px'
73
+ },
74
+ directives: [(permission === '' || permission === null) ? '' : {
75
+ name: "permission",
76
+ value: permission
77
+ }],
78
+ on: {
79
+ 'click': () => {
80
+ operation(vm, currentRow);
81
+ }
82
+ }
83
+ }, operationName);
84
+ }
85
+
86
+ export function isJson(arg) {
87
+ return typeof (arg) == "object" && Object.prototype.toString.call(arg).toLowerCase() == "[object object]" && !arg.length
88
+ };
package/utils/date.js CHANGED
@@ -4,33 +4,6 @@ import config from '../config/config'
4
4
  * 本项目已集成 moment.js (http://momentjs.cn/),推荐使用 moment.js
5
5
  */
6
6
  import moment from "moment";
7
-
8
- /**
9
- * 对Date的扩展,将 Date 转化为指定格式的String
10
- * 月(M)、日(d)、小时(h)、分(m)、秒(s)、季度(q) 可以用 1-2 个占位符,
11
- * 年(y)可以用 1-4 个占位符,毫秒(S)只能用 1 个占位符(是 1-3 位的数字)
12
- * 例:
13
- * (new Date()).Format("yyyy-MM-dd hh:mm:ss.S") ==> 2006-07-02 08:09:04.423
14
- * (new Date()).Format("yyyy-M-d h:m:s.S") ==> 2006-7-2 8:9:4.18
15
- */
16
- Date.prototype.Format = function (fmt) {
17
- let o = {
18
- "M+": this.getMonth() + 1, //月份
19
- "d+": this.getDate(), //日
20
- "H+": this.getHours(), //小时
21
- "m+": this.getMinutes(), //分
22
- "s+": this.getSeconds(), //秒
23
- "q+": Math.floor((this.getMonth() + 3) / 3), //季度
24
- "S": this.getMilliseconds() //毫秒
25
- };
26
- if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
27
- for (let k in o)
28
- if (new RegExp("(" + k + ")").test(fmt)){
29
- fmt = fmt.replace(RegExp.$1, (RegExp.$1.length === 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)))
30
- }
31
- return fmt;
32
- }
33
-
34
7
  export function timestampToTime(timestamp) {
35
8
  let date = new Date(timestamp);
36
9
  let Y = date.getFullYear() + '-';